00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef __SERVICES_H
00047 #define __SERVICES_H
00048
00049 #include "config.h"
00050
00051 #include <sys/types.h>
00052 #include <sys/socket.h>
00053 #include <sys/time.h>
00054 #include <sys/wait.h>
00055 #include <sys/file.h>
00056 #include <sys/stat.h>
00057 #ifndef NORLIMIT
00058 #include <sys/resource.h>
00059 #endif
00060
00061 #include <errno.h>
00062 #include <signal.h>
00063 #include <stdio.h>
00064 #include <netdb.h>
00065 #include <stdlib.h>
00066 #include <string.h>
00067 #include <unistd.h>
00068 #include <stdarg.h>
00069 #include <ctype.h>
00070 #include <time.h>
00071 #include <arpa/inet.h>
00072
00073 #include <netinet/in.h>
00074
00075 #define FREE(x) do { free(x) ; (x) = NULL; } while (0)
00076
00077 #include "options.h"
00078 #include "parse.h"
00079 #include "struct.h"
00080
00081 #ifdef USE_SQL
00082 #include <libpq-fe.h>
00083 #endif
00084
00085 #ifndef _TESTMODE
00086
00087 #define assert(x) \
00088 (!(x) ? fatalSvsError(__FILE__, __LINE__, #x) : 0)
00089 #endif
00090
00091 #ifndef MAX
00092
00097 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
00098 #endif
00099
00100 #ifndef MIN
00101
00106 #define MIN(x, y) ( ( (x) < (y) ) ? (x) : (y) )
00107 #endif
00108
00116 #define strncpyzt(s_dest, s_src, s_size) \
00117 do { \
00118 strncpy((s_dest), (s_src), (s_size)); \
00119 (s_dest)[(s_size) - 1] = '\0'; \
00120 } while(0)
00121
00127 #define FATAL_ERROR 66
00128
00129 #ifndef FALSE
00130
00131 #define FALSE 0
00132 #endif
00133
00134 #ifndef TRUE
00135
00136 #define TRUE !(FALSE)
00137 #endif
00138
00142
00143 #define net_read(a,b,c) read((a), (b), (c))
00144
00146 #define net_write(a,b,c) write((a), (b), (c))
00147
00152 #define NUMSERVS 7
00153
00157 #undef DEBUG
00158
00162 #undef DBDEBUG
00163
00167 #undef CDEBUG
00168
00169 #undef C_DEBUG2
00170
00174 #define MAXEVENTS 4096
00175
00179 #define GLOBOPS_ON_RAW
00180
00182 #define VERSION_NUM VERSION
00183
00185 #define VERSION_QUOTE ("When you wake up you're all weak, throwing your life away")
00186
00188 #define VERSION_STRING (PACKAGE "-" VERSION_NUM "")
00189
00191 #define LOGCHAN "#services"
00192
00194 #define DEBUGCHAN "#services-debug"
00195
00197 #define NETWORK_CHANNELS "#sorcery:" LOGCHAN ":" DEBUGCHAN ":"
00198
00202 #undef COPYRIGHT
00203
00205 #define A_AKILL 0x01
00206
00208 #define A_IGNORE 0x02
00209
00211 #define A_AHURT 0x04
00212
00214 #define CLONE_KILLFLAG 0x01
00215
00217 #define CLONE_IGNOREFLAG 0x02
00218
00220
00221 #define CLONE_PERMTRIGGER 0x04
00222
00224 #define CLONE_OK 0x08
00225
00227 #define CLONE_ALERT 0x10
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 void flushLogs(char *);
00238 void expireChans(char *);
00239 void expireNicks(char *);
00240 void sshutdown(int);
00241 void checkTusers(char *);
00242 void readConf(void);
00243
00244
00245
00246
00247 void addUser(char *, char *, char *, char *, char *);
00248 int ConnectToServer(char *, int);
00249 void sSend(char *, ...)
00250 __attribute__ ((format (printf, 1, 2)));
00251 void logDump(FILE *, char *, ...)
00252 __attribute__ ((format (printf, 2, 3)));
00253 void breakLine(char *);
00254 void handler(int);
00255 char *xorit(char *);
00256 void sendInfoReply(UserList *);
00257
00258
00259
00260
00261 int cancel_timer(int);
00262 int timer(long, void (*func) (char *), void *);
00263 void timeralarm(void);
00264 void dumptimer(char *from);
00265
00266
00267
00268
00269 void sync_cfg(char *);
00270
00271
00272
00273
00274 void AppendBuffer(char **, const char *);
00275 void SetDynBuffer(char **, const char *);
00276 void breakString(int, char *, char *args[256], char);
00277 int match(const char *, const char *);
00278 void strtolower(char *);
00279 void doTfunc(char *);
00280 char *sfgets(char *, int, FILE *);
00281 int check_match(char *);
00282 int exp_match(char *, char *);
00283 void parse_str(char **, int, int, char *, size_t);
00284 void mask(char *, char *, int, char *);
00285 void tzapply(char *);
00286 int split_userhost(const char *input_host, MaskData *data);
00287 void free_mask(MaskData *);
00288 MaskData *make_mask(void);
00289 void *oalloc(size_t);
00290 char *genHostMask(char *);
00291 char *flagstring(int flags, const char *bits[]);
00292 int flagbit(char *, const char *bits[]);
00293 char* str_dup(const char *);
00294
00295
00296
00297
00298 unsigned char *toBase64(const unsigned char *stream, size_t left);
00299 unsigned char *fromBase64(const char *cStr, int *len);
00300
00301
00302
00303
00304 void listAkills(char *from, char type);
00305 int addakill(long length, char *mask, char *by, char type, char *reason);
00306 int removeAkill(char *from, char *mask);
00307 int removeAkillType(char *from, char *mask, int type, int restrict);
00308 void saveakills(void);
00309 void loadakills(void);
00310 int isAKilled(char *, char *, char *);
00311 char *checkAndSetAKill(char *nick, char *user, char *host);
00312 int isAHurt(char *, char *, char *);
00313 int isIgnored(char *, char *, char *);
00314 void timed_akill_queue(char *);
00315 void autoremoveakill(char *mask);
00316 void queueakill(char *, char *, char *, char *, time_t, int, int, int);
00317 const char * aktype_str(int type, int which);
00318
00319
00320
00321
00322
00323
00324 void dlogInit(void);
00325 void dlogEntry(char *, ...);
00326 void dlogDump(FILE *);
00327
00328
00329
00330
00331 void motd(char *);
00332 void help(char *, char *, char **, int);
00333 void flush_help_cache(void);
00334 help_cache *check_help_cache (char *);
00335
00336
00337
00338 #ifdef USE_SQL
00339 extern PGconn *dbConn;
00340 #endif
00341
00342
00343
00344
00346 extern char myname[255];
00347
00349 extern char mypass[33];
00350
00352 extern char hostname[255];
00353
00355 extern int port;
00356
00358 extern int server;
00359
00361 extern Service services[NUMSERVS];
00362
00364 extern database db;
00365
00367 extern u_long totalusers;
00368
00370 extern u_long mostusers;
00371
00373 extern u_long mostnicks;
00374
00376 extern u_long mostchans;
00377
00379 extern u_long mostmemos;
00380
00382 extern u_long counterOldCSFmt;
00383
00385 extern long startup, firstup;
00386
00388 extern char *OperServ, *NickServ, *ChanServ, *MemoServ, *InfoServ, *GameServ;
00389
00391 extern char coreBuffer[IRCBUF];
00392
00394 extern u_int AccessLimit, OpLimit, AkickLimit, ChanLimit, NickLimit;
00395
00397 extern time_t CTime;
00398
00400 extern time_t nextNsync, nextCsync, nextMsync;
00401
00402
00403
00404 #ifdef __string_cc__
00405 int fatalSvsError(const char *fName, int lineNo, const char *cErr)
00406 {
00407 extern FILE *corelog;
00408
00409 logDump(corelog, "Fatal Error --\n\"%s\"",
00410 coreBuffer);
00411 logDump(corelog, "Assertion: %s:%d: \"%s\" was false.",
00412 fName, lineNo, cErr);
00413 sSend(":%s GOPER :Fatal error: assertion: %s:%d: \"%s\" was false.",
00414 myname, fName, lineNo, cErr);
00415 sSend("WALLOPS :Fatal assertion error, shutdown NOW");
00416 sSend(":%s GOPER :Buffer is -> %s", myname, coreBuffer);
00417 dlogDump(corelog);
00418 sshutdown(1);
00419 return 0;
00420 }
00421 #else
00422 int fatalSvsError(const char *fName, int lineNo, const char *cErr);
00423 #endif
00424
00425
00426 int isPasswordAcceptable(const char* password, char* reason);
00427
00431 #define str_cmp strcasecmp
00432
00433 #endif