2 * IRC - Internet Relay Chat, ircd/m_proto.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 1, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * No need to include handlers.h here the signatures must match
28 * and we don't need to force a rebuild of all the handlers everytime
29 * we add a new one to the list. --Bleep
35 #include "ircd_alloc.h"
36 #include "ircd_chattr.h"
37 #include "ircd_reply.h"
38 #include "ircd_string.h"
44 #include "supported.h"
53 * m_functions execute protocol messages on this server:
55 * cptr is always NON-NULL, pointing to a *LOCAL* client
56 * structure (with an open socket connected!). This
57 * identifies the physical socket where the message
58 * originated (or which caused the m_function to be
59 * executed--some m_functions may call others...).
61 * sptr is the source of the message, defined by the
62 * prefix part of the message if present. If not
63 * or prefix not found, then sptr==cptr.
65 * (!IsServer(cptr)) => (cptr == sptr), because
66 * prefixes are taken *only* from servers...
69 * (sptr == cptr) => the message didn't
72 * (sptr != cptr && IsServer(sptr) means
73 * the prefix specified servername. (?)
75 * (sptr != cptr && !IsServer(sptr) means
76 * that message originated from a remote
81 * (!IsServer(sptr)) means that, sptr can safely
82 * taken as defining the target structure of the
83 * message in this server.
85 * *Always* true (if 'parse' and others are working correct):
87 * 1) sptr->from == cptr (note: cptr->from == cptr)
89 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
90 * *cannot* be a local connection, unless it's
91 * actually cptr!). [MyConnect(x) should probably
92 * be defined as (x == x->from) --msa ]
94 * parc number of variable parameter strings (if zero,
95 * parv is allowed to be NULL)
97 * parv a NULL terminated list of parameter pointers,
99 * parv[0], sender (prefix string), if not present
100 * this points to an empty string.
101 * parv[1]...parv[parc-1]
102 * pointers to additional parameters
103 * parv[parc] == NULL, *always*
105 * note: it is guaranteed that parv[0]..parv[parc-1] are all
109 static const char* const PROTO_REQ = "REQ";
110 static const char* const PROTO_ACK = "ACK";
112 int proto_handle_ack(struct Client* cptr, const char* msg)
115 * handle ack here, if option and args supported
121 int proto_handle_req(struct Client* cptr, const char* msg)
124 * handle request here if not supported args send
125 * option info. otherwise send ack
130 int proto_send_supported(struct Client* cptr)
133 * send_reply(cptr, RPL_PROTOLIST, "stuff");
138 int m_proto(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
141 return proto_send_supported(cptr);
144 return need_more_params(sptr, "PROTO");
146 if (0 == ircd_strcmp(PROTO_REQ, parv[1]))
147 return proto_handle_req(cptr, parv[2]);
149 else if (0 == ircd_strcmp(PROTO_ACK, parv[1]))
150 return proto_handle_ack(cptr, parv[2]);