1 // Parser.H -*- C++ -*-
2 // Copyright (c) 1997, 1998 Etienne BERNARD
3 // Copyright (c) 2002,2003 Clinton Ebadi
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 class ServerConnection;
38 typedef void (*fptr)(ServerConnection *, Person *, String);
40 // fptr is a parser function which may either be Scheme or C. fptr
41 // used to be what funptr is now, but I decided to make the bot even
42 // more extensible and it is now a function-like object that can be
43 // used just like it was a function pointer.
45 // This will take a lot of work to make it actually work...lots of
46 // SMOBs have to be written :(
51 // typedef void (*funptr)(ServerConnection *, Person *, String);
62 // ftpr () { Cfunc = 0; Sfunc = 0; C = true; };
63 // operator= (funptr f) { Cfunc = f; C = true; };
64 // operator= (SCM f) { Sfunc = f; C = false; };
66 // operator ()(ServerConnection * s, Person * p, String str)
71 // // ... SCM not supported for now
77 void (*function)(ServerConnection *, Person *, String, String);
79 bool needsChannelName;
85 userFunction(void (*f)(ServerConnection *, Person *,
87 int m = 0 , bool n = false
89 , int a = -1, SCM scm_f = 0
92 : function(f), minLevel(m), needsChannelName(n)
94 ,argsCount(a), scmFunc(scm_f)
99 scm_gc_protect_object(scmFunc);
107 scm_gc_unprotect_object(scmFunc);
115 static void parseLine(ServerConnection *, String);
117 static void parse001(ServerConnection *, Person *, String);
118 static void parse302(ServerConnection *, Person *, String);
119 static void parse311(ServerConnection *, Person *, String);
120 static void parse315(ServerConnection *, Person *, String);
121 static void parse324(ServerConnection *, Person *, String);
122 static void parse332(ServerConnection *, Person *, String);
123 static void parse352(ServerConnection *, Person *, String);
124 static void parse353(ServerConnection *, Person *, String);
125 static void parse366(ServerConnection *, Person *, String);
126 static void parse367(ServerConnection *, Person *, String);
127 static void parse401(ServerConnection *, Person *, String);
128 static void parse433(ServerConnection *, Person *, String);
129 static void parse473(ServerConnection *, Person *, String);
130 static void parseError(ServerConnection *, Person *, String);
131 static void parseInvite(ServerConnection *, Person *, String);
132 static void parseJoin(ServerConnection *, Person *, String);
133 static void parseKick(ServerConnection *, Person *, String);
134 static void parseMode(ServerConnection *, Person *, String);
135 static void parseNick(ServerConnection *, Person *, String);
136 static void parseNotice(ServerConnection *, Person *, String);
137 static void parsePart(ServerConnection *, Person *, String);
138 static void parsePing(ServerConnection *, Person *, String);
139 static void parsePong(ServerConnection *, Person *, String);
140 static void parsePrivmsg(ServerConnection *, Person *, String);
141 static void parseQuit(ServerConnection *, Person *, String);
142 static void parseTopic(ServerConnection *, Person *, String);
144 static void parseCTCP(ServerConnection *, Person *, String,
146 static void parseMessage(ServerConnection *, Person *, String,
149 static void parseScriptFunction(ServerConnection *, String, bool,
153 static void sendNotice(Person *, String);
156 static std::map<std::string, fptr, std::less<std::string> > functions;