Author: Bleep <tomh@inxpress.net>
[ircu2.10.12-pk.git] / ircd / m_proto.c
1 /*
2  * IRC - Internet Relay Chat, ircd/m_proto.c
3  * Copyright (C) 1990 Jarkko Oikarinen and
4  *                    University of Oulu, Computing Center
5  *
6  * See file AUTHORS in IRC package for additional names of
7  * the programmers.
8  *
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)
12  * any later version.
13  *
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.
18  *
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.
22  *
23  * $Id$
24  */
25 #if 0
26 /*
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
30  */
31 #include "handlers.h"
32 #endif /* 0 */
33 #include "client.h"
34 #include "ircd.h"
35 #include "ircd_alloc.h"
36 #include "ircd_chattr.h"
37 #include "ircd_reply.h"
38 #include "ircd_string.h"
39 #include "numeric.h"
40 #include "numnicks.h"
41 #include "s_debug.h"
42 #include "s_misc.h"
43 #include "send.h"
44 #include "supported.h"
45 #include "version.h"
46
47 #include <assert.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <string.h>
51
52 /*
53  * m_functions execute protocol messages on this server:
54  *
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...).
60  *
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.
64  *
65  *            (!IsServer(cptr)) => (cptr == sptr), because
66  *            prefixes are taken *only* from servers...
67  *
68  *            (IsServer(cptr))
69  *                    (sptr == cptr) => the message didn't
70  *                    have the prefix.
71  *
72  *                    (sptr != cptr && IsServer(sptr) means
73  *                    the prefix specified servername. (?)
74  *
75  *                    (sptr != cptr && !IsServer(sptr) means
76  *                    that message originated from a remote
77  *                    user (not local).
78  *
79  *            combining
80  *
81  *            (!IsServer(sptr)) means that, sptr can safely
82  *            taken as defining the target structure of the
83  *            message in this server.
84  *
85  *    *Always* true (if 'parse' and others are working correct):
86  *
87  *    1)      sptr->from == cptr  (note: cptr->from == cptr)
88  *
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 ]
93  *
94  *    parc    number of variable parameter strings (if zero,
95  *            parv is allowed to be NULL)
96  *
97  *    parv    a NULL terminated list of parameter pointers,
98  *
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*
104  *
105  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
106  *                    non-NULL pointers.
107  */
108
109 static const char* const PROTO_REQ = "REQ";
110 static const char* const PROTO_ACK = "ACK";
111
112 int proto_handle_ack(struct Client* cptr, const char* msg)
113 {
114   /*
115    * handle ack here, if option and args supported
116    * start option
117    */ 
118   return 0;
119 }
120
121 int proto_handle_req(struct Client* cptr, const char* msg)
122 {
123   /*
124    * handle request here if not supported args send
125    * option info. otherwise send ack
126    */
127   return 0;
128 }
129
130 int proto_send_supported(struct Client* cptr)
131 {
132   /*
133    * sendto_one(cptr, RPL_PROTOLIST, me.name, cptr->name, "stuff");
134    */
135   return 0;
136 }
137
138 int m_proto(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
139 {
140   if (0 == parc)
141     return proto_send_supported(cptr);
142
143   if (parc < 3) 
144     return need_more_params(sptr, "PROTO");
145
146   if (0 == ircd_strcmp(PROTO_REQ, parv[1]))
147     return proto_handle_req(cptr, parv[2]);
148
149   else if (0 == ircd_strcmp(PROTO_ACK, parv[1]))
150     return proto_handle_ack(cptr, parv[2]);
151
152   return 0;
153 }
154
155