]>
jfr.im git - irc/quakenet/lightweight.git/blob - lightweight.h
2 This file is part of lightweight.
4 lightweight is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 lightweight is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with lightweight; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /* $Id: lightweight.h,v 1.64 2004/08/18 16:07:50 froo Exp $ */
28 #ifndef __LIGHTWEIGHT_H
29 #define __LIGHTWEIGHT_H
35 /* path and filename of config file */
36 #define CONFIGFILE "lightweight.conf"
38 /* define this for debugging output */
41 /* define this for CM support */
42 #define HAVE_CLEARMODE
44 /* define this for DEOPALL hack */
45 #undef HORRIBLE_DEOPALL_HACK
47 /* define this for L on channels */
48 #define SIT_ON_CHANNELS
50 /* define this for modes in burst */
51 /* Note that this is NOT sensible in conjunction with SIT_ON_CHANNELS */
52 #undef AUTOMODES_IN_BURST
54 /* number of days before expiring unused channels */
55 #define DAYS_BEFORE_EXPIRE 40
57 /* number of days before removing suspended channels */
58 #define SUSPEND_EXPIRY_TIME 40
60 /* Internal defines. */
62 /* Size of the buffer that we read into from our serverfd. */
63 #define CHUNKSIZE 65536
64 /* Maxchannels that we allow a user to have flags on. */
65 #define CHANNELSPERUSER 20
66 /* Maxusers that we allow to have flags on a channel. */
67 #define USERSPERCHANNEL 30
68 /* We need a hashfunction that returns a value x, 0 <= x < HASHMAX. */
70 /* Define TOPICSAVE to enable lightweight to save topics. */
73 /* Defines for saving data. */
74 /* Files will be named accounts.0, accounts.1, ... accounts.x, with number 0 being the newest. */
75 #define ACCOUNTFILE "accounts"
76 #define NUMBEROFSAVEFILES 9
77 /* Files will be named log.0, log.1, ... log.x, with number 0 being the newest. */
78 /* Logs will be rotated once a day, at midnight. */
80 #define DEBUGFILE "debug"
81 #define NUMBEROFLOGFILES 7
83 /* Defines from ircd. */
84 /* Things fuck up if these arent exactly as the ircd-settings. */
86 #define SERVERNAMELENGTH 100
91 /* the struct required to hold multiple auths for a single account */
93 struct user
*autheduser
; /* pointer to user authed with this account */
94 struct usersauthed
*nextinlist
; /* next in linked list */
98 char authname
[NICKLEN
+ 1]; /* Auth name: matches the broadcast ACCOUNT name */
99 struct usersauthed
*currentuser
; /* User that is currently authed with
101 struct reggedchannel
*channel
[CHANNELSPERUSER
]; /* Pointers to channels
102 * where this account is
105 char channelflags
[CHANNELSPERUSER
]; /* Flags corresponding to the channels
107 time_t lastauth
; /* last time the user authed */
108 unsigned char authlevel
; /* Authlevel, more commands will be available for people
109 * with higher authlevels. */
110 struct account
*nextbyauthname
; /* Next in linked list of hashed authnames. */
113 /* Struct to hold a registered channel in lightweight. */
114 /* Please note that this has nothing to do with the channels actually on the
115 * network, this is only the registered channels. */
116 struct reggedchannel
{
117 char channelname
[30];
118 struct account
*channeluser
[USERSPERCHANNEL
]; /* Pointers back to the users
119 * that have flags on this
120 * channel. Needed when doing
121 * a chanlev for the channel.
123 struct reggedchannel
*nextbychannelname
; /* Next in linked list of hashed
126 struct account
*founder
; /* the user who founded the channel (first
128 char addedby
[NICKLEN
+ 1]; /* the user who added the channel */
129 time_t lastused
; /* Timestamp for determining unused channels. */
130 time_t timestamp
; /* Current timestamp for channel */
131 time_t dateadded
; /* Timestamp for when the channel was added */
132 struct account
*suspendby
; /* User who suspended the channel */
133 char *suspendreason
; /* Suspend reason */
134 char *welcome
; /* welcome message */
135 char flags
; /* Channel flags */
137 char topic
[250]; /* For saving topic in a channel. */
141 /* User struct, holds a user currently online on the network. */
143 char nick
[NICKLEN
+ 1];
145 struct account
*authedas
; /* If the user is authed, this is a pointer
146 * to the corresponding account.
148 char oper
; /* 0 if non oper, non-zero if oper ('o'). */
149 struct user
*nextbynick
; /* Next in linked list of hashed nicks. */
152 /* Serverstruct, holds information about a server in the servertree. */
154 char servername
[SERVERNAMELENGTH
];
156 /* This is a 'pointer' to the parent of this server, eg. the
157 * server that is one hop closer to us on the path from us
158 * to the server in the servertree.
159 * 'Pointer' in the meaning that this is the entry in the
160 * servertree array which holds the pointer to the parent
163 int maxusers
; /* Maxusers of this server. */
164 /* This is really a duplicate, there is a global var for this too,
165 * where should it be?
171 #define ERR_DEBUG 0x0100
172 #define ERR_INFO 0x0200
173 #define ERR_WARNING 0x0400
174 #define ERR_ERROR 0x0800
175 #define ERR_FATAL 0x1000
177 #define ERR_TYPEMASK 0x00ff
178 #define ERR_PROTOCOL 0x0001
179 #define ERR_INTERNAL 0x0002
180 #define ERR_STATS 0x0003
181 #define ERR_LOADSAVE 0x0004
183 /* Forward declarations. */
184 int RestoreDBFromDisk();
185 int ConnectToServer();
186 int SendInitToServer();
188 int GetLineFromChunk();
191 char *StripBlanks(char *paddedstring
);
192 char *SeperateWord(char *sentence
);
195 char *a_strstrip(char *str
);
196 char *a_strcpy(char *dst
, const char *src
, int dst_len
);
197 char *a_strextract(char *dst
, const char *src
, int dst_len
);
198 int a_strmatch(const char *str
, const char *reg
, int case_sensitive
);
201 struct server
*GetServer();
202 void FreeServer(struct server
*);
203 struct user
*GetUser();
204 void FreeUser(struct user
*);
207 int IsCharInString(char chr
, char *string
);
208 long NumericToLong(const char *numeric
, int numericlen
);
209 char *StripBlanks(char *paddedstring
);
210 char *SeperateWord(char *sentence
);
211 int CheckAuthLevel(struct user
*user_ptr
, unsigned char level
);
212 void MessageToUser(struct user
*user
, char *message
, ...);
213 void NoticeToUser(struct user
*user
, char *message
, ...);
216 void UserNickCreation(char *numeric
, char *nick
, char isoper
);
217 void UserNickChange(char *numeric
, char *newnick
);
218 void DeleteUser(char *numeric
);
219 void UserHashStats(void);
221 /* connecttoserver.c */
222 void SendLine(char *text
);
225 void DoJoins(char *numeric
, char *channellist
, time_t timestamp
);
228 void DoChanMode(char *sender
, char *channel
, char *modes
);
231 void AddServer(int servernum
, const char *servername
, int maxusers
, int parent
);
232 void HandleSquit(char *servername
);
233 void DoSquitRecursive(int servernum
);
236 void ProcessMessage(char *numeric
, char *text
);
239 void Error(int ErrorType
, char *reason
, ...);
242 int hash(char *buffer
);
245 void RemoveAuthFromUser(struct user
*); /* removes the auth from account */
248 void FlushLogs(void);
249 int RotateLogs(void);
250 void Log(char *logtext
, ...);
251 void DebugLog(char *logtext
, ...);
254 int LoadCfg(char *configfile
);
256 /* clientcommands/<command>.c */
258 void doaddchan(struct user
*user
, char *tail
);
259 void dodelchan(struct user
*user
, char *tail
);
260 void dochangelev(struct user
*user
, char *tail
);
261 void dosave(struct user
*user
, char *tail
);
262 void dohelp(struct user
*user
, char *tail
);
263 void doshowcommands(struct user
*, char *tail
);
264 void dowhois(struct user
*user
, char *tail
);
265 void dowhois(struct user
*user
, char *tail
);
266 void dowhoami(struct user
*user
, char *tail
);
267 void dounbanall(struct user
*user
, char *tail
);
268 void doclearchan(struct user
*user
, char *tail
);
269 void doop(struct user
*user
, char *tail
);
270 void dovoice(struct user
*user
, char *tail
);
271 void dodeopall(struct user
*user
, char *tail
);
272 void dochanlev(struct user
*user
, char *tail
);
273 void doinvite(struct user
*, char *);
274 void doadduser(struct user
*, char *);
275 void doremoveuser(struct user
*, char *);
276 void dorecover(struct user
*, char *);
277 void doversion(struct user
*, char *);
278 void dodeluser(struct user
*, char *);
279 void dosuspend(struct user
*, char *);
280 void dounsuspend(struct user
*, char *);
281 void dochanstat(struct user
*, char *);
282 void dostatus(struct user
*, char *);
283 void dosuspendlist(struct user
*, char *);
284 void dochannellist(struct user
*, char *);
285 void doaccountlist(struct user
*, char *);
286 void dolistlevel(struct user
*, char *);
287 void douserlist(struct user
*, char *);
288 void doneigh(struct user
*, char *);
289 void docow(struct user
*, char *);
290 void donoticeme(struct user
*, char *);
291 void dofish(struct user
*, char *);
292 void doreauth(struct user
*, char *);
293 void doraw(struct user
*, char *);
294 void docleanupdb(struct user
*, char *);
295 void docleanupdb2(struct user
*, char *);
296 void dodie(struct user
*, char *);
297 void dowelcome(struct user
*, char *);
298 void dogrep(struct user
*, char *);
299 void dofind(struct user
*, char *);
300 void dosetinvite(struct user
*, char *);
301 void doclearinvite(struct user
*, char *);
302 void doaccountstats(struct user
*);
303 void dopart(struct user
*, char *);
304 void dosendchanlev(struct user
*, char *);
305 void dorequestowner(struct user
*, char *);
306 void dosetenable(struct user
*, char *);
310 #endif /* __LIGHTWEIGHT_H */