ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ping.c
Revision: 2820
Committed: Wed Jan 15 23:10:26 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3983 byte(s)
Log Message:
- Clean up all files in modules/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years
- Made module handlers int type for later use

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_ping.c
23 * \brief Includes required functions for processing the PING command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "send.h"
32 #include "irc_string.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "hash.h"
36 #include "conf.h"
37 #include "s_serv.h"
38
39
40 /*
41 ** m_ping
42 ** parv[0] = sender prefix
43 ** parv[1] = origin
44 ** parv[2] = destination
45 */
46 static int
47 m_ping(struct Client *client_p, struct Client *source_p,
48 int parc, char *parv[])
49 {
50 struct Client *target_p;
51 char *origin, *destination;
52
53 if (parc < 2 || EmptyString(parv[1]))
54 {
55 sendto_one(source_p, form_str(ERR_NOORIGIN),
56 me.name, source_p->name);
57 return 0;
58 }
59
60 origin = parv[1];
61 destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
62
63 if (ConfigServerHide.disable_remote_commands && !HasUMode(source_p, UMODE_OPER))
64 {
65 sendto_one(source_p, ":%s PONG %s :%s", me.name,
66 (destination) ? destination : me.name, origin);
67 return 0;
68 }
69
70 if (!EmptyString(destination) && irccmp(destination, me.name) != 0)
71 {
72 /* We're sending it across servers.. origin == client_p->name --fl_ */
73 origin = client_p->name;
74
75 if ((target_p = hash_find_server(destination)))
76 sendto_one(target_p, ":%s PING %s :%s", source_p->name,
77 origin, destination);
78 else
79 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
80 me.name, source_p->name, destination);
81 }
82 else
83 sendto_one(source_p, ":%s PONG %s :%s", me.name,
84 (destination) ? destination : me.name, origin);
85 return 0;
86 }
87
88 static int
89 ms_ping(struct Client *client_p, struct Client *source_p,
90 int parc, char *parv[])
91 {
92 struct Client *target_p;
93 const char *origin, *destination;
94
95 if (parc < 2 || EmptyString(parv[1]))
96 {
97 sendto_one(source_p, form_str(ERR_NOORIGIN),
98 me.name, source_p->name);
99 return 0;
100 }
101
102 origin = source_p->name;
103 destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
104
105 if (!EmptyString(destination) && irccmp(destination, me.name) != 0 && irccmp(destination, me.id) != 0)
106 {
107 if ((target_p = hash_find_server(destination)))
108 sendto_one(target_p, ":%s PING %s :%s", source_p->name,
109 origin, destination);
110 else
111 sendto_one(source_p, form_str(ERR_NOSUCHSERVER), ID_or_name(&me, client_p),
112 source_p->name, destination);
113 }
114 else
115 sendto_one(source_p, ":%s PONG %s :%s", ID_or_name(&me, client_p),
116 (destination) ? destination : me.name, origin);
117 return 0;
118 }
119
120 static struct Message ping_msgtab =
121 {
122 "PING", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
123 { m_unregistered, m_ping, ms_ping, m_ignore, m_ping, m_ping }
124 };
125
126 static void
127 module_init(void)
128 {
129 mod_add_cmd(&ping_msgtab);
130 }
131
132 static void
133 module_exit(void)
134 {
135 mod_del_cmd(&ping_msgtab);
136 }
137
138 struct module module_entry = {
139 .node = { NULL, NULL, NULL },
140 .name = NULL,
141 .version = "$Revision$",
142 .handle = NULL,
143 .modinit = module_init,
144 .modexit = module_exit,
145 .flags = 0
146 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision