[project @ 2002-07-09 14:28:08 by unknown_lamer]
[clinton/bobotpp.git] / source / Parser.H
1 // Parser.H -*- C++ -*-
2 // Copyright (c) 1997, 1998 Etienne BERNARD
3 // Copyright (c) 2002 Clinton Ebadi
4
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
8 // any later version.
9
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.
14
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18
19 #ifndef PARSER_H
20 #define PARSER_H
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "String.H"
27 #include "Person.H"
28 #include "ServerConnection.H"
29
30 #ifdef USESCRIPTS
31 #include "Interp.H"
32 #include <libguile.h>
33 #endif
34
35 struct userFunctionsStruct {
36 String name;
37 void (*function)(ServerConnection *, Person *, String, String);
38 int minLevel;
39 bool needsChannelName;
40 };
41
42 class userFunction {
43 public:
44 String name;
45 void (*function)(ServerConnection *, Person *, String, String);
46 int minLevel;
47 bool needsChannelName;
48 #ifdef USESCRIPTS
49 int argsCount;
50 SCM scmFunc;
51 #endif
52
53 userFunction(String na,
54 void (*f)(ServerConnection *, Person *,
55 String, String),
56 int m, bool n
57 #ifdef USESCRIPTS
58 , int a = -1, SCM scm_f = 0
59 #endif
60 )
61 : name(na), function(f), minLevel(m), needsChannelName(n)
62 #ifdef USESCRIPTS
63 ,argsCount(a), scmFunc(scm_f)
64 #endif
65 {
66 #ifdef USESCRIPTS
67 // scm_protect_object(scm_f);
68 #endif
69 }
70
71 #ifdef USESCRIPTS
72 // ~userFunction()
73 // { scm_unprotect_object(scmFunc); };
74 #endif
75 };
76
77 class Parser {
78 public:
79 static void parseLine(ServerConnection *, String);
80
81 static void parse001(ServerConnection *, Person *, String);
82 static void parse302(ServerConnection *, Person *, String);
83 static void parse311(ServerConnection *, Person *, String);
84 static void parse315(ServerConnection *, Person *, String);
85 static void parse324(ServerConnection *, Person *, String);
86 static void parse332(ServerConnection *, Person *, String);
87 static void parse352(ServerConnection *, Person *, String);
88 static void parse353(ServerConnection *, Person *, String);
89 static void parse366(ServerConnection *, Person *, String);
90 static void parse367(ServerConnection *, Person *, String);
91 static void parse401(ServerConnection *, Person *, String);
92 static void parse433(ServerConnection *, Person *, String);
93 static void parse473(ServerConnection *, Person *, String);
94 static void parseError(ServerConnection *, Person *, String);
95 static void parseInvite(ServerConnection *, Person *, String);
96 static void parseJoin(ServerConnection *, Person *, String);
97 static void parseKick(ServerConnection *, Person *, String);
98 static void parseMode(ServerConnection *, Person *, String);
99 static void parseNick(ServerConnection *, Person *, String);
100 static void parseNotice(ServerConnection *, Person *, String);
101 static void parsePart(ServerConnection *, Person *, String);
102 static void parsePing(ServerConnection *, Person *, String);
103 static void parsePong(ServerConnection *, Person *, String);
104 static void parsePrivmsg(ServerConnection *, Person *, String);
105 static void parseQuit(ServerConnection *, Person *, String);
106 static void parseTopic(ServerConnection *, Person *, String);
107
108 static void parseCTCP(ServerConnection *, Person *, String,
109 String);
110 static void parseMessage(ServerConnection *, Person *, String,
111 String);
112 #ifdef USESCRIPTS
113 static void parseScriptFunction(ServerConnection *, String, bool,
114 SCM, int, String);
115 #endif
116
117 static void sendNotice(Person *, String);
118 };
119
120 #endif