]> jfr.im git - irc/ircd-hybrid/efserv-cvs.git/commitdiff
- Added match.c which I forgot to add before.
authora1kmm <a1kmm>
Thu, 31 May 2001 08:52:02 +0000 (08:52 +0000)
committera1kmm <a1kmm>
Thu, 31 May 2001 08:52:02 +0000 (08:52 +0000)
- Split up headers into smaller headers.

22 files changed:
.depend
Makefile
channels.c
clients.c
clones.c
commands.c
config.c
database.c
efserv.c
efserv.h [deleted file]
include/conf.h [new file with mode: 0644]
include/define.h [new file with mode: 0644]
include/funcs.h [new file with mode: 0644]
include/struct.h [new file with mode: 0644]
include/utils.h [new file with mode: 0644]
log.c
match.c [new file with mode: 0644]
md5.c
msg.c
sconfig.l
sconfig.y
utils.c

diff --git a/.depend b/.depend
index 23fb4487ba30b8878d21520d3550826b45e8f475..466e43767c78e52612a00a98c7fb4ace81670b8b 100644 (file)
--- a/.depend
+++ b/.depend
@@ -1,11 +1 @@
-channels.o: channels.c efserv.h
-commands.o: commands.c efserv.h
-config.o: config.c efserv.h
-clients.o: clients.c efserv.h
-clones.o: clones.c efserv.h
-efserv.o: efserv.c efserv.h
 match.o: match.c
-msg.o: msg.c efserv.h
-utils.o: utils.c efserv.h
-sconfig.tab.o: sconfig.tab.c efserv.h
-lex.yy.o: lex.yy.c efserv.h sconfig.tab.h
index 3d587a2e3d9219b615a7f24c780a33ad2ecbea91..7d9b3434b9af4eeb94e44c9765f0cc9bccda75df 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS=-Wall -ggdb
+CFLAGS=-Wall -ggdb -Iincludes/
 BIN=efserv
 LEX=lex
 BISON=bison
index fe2a9796b2bc56011457071b8a727d94c8ce349e..0dce992e1be01ed2ea6f02aae0e0281bfe07e131 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: channels.c,v 1.5 2001/05/31 07:52:10 a1kmm Exp $
+ * $Id: channels.c,v 1.6 2001/05/31 08:52:03 a1kmm Exp $
  */
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include "efserv.h"
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
 
 void
 check_channel_status(struct Channel *ch)
index 4861d176864702ef2ae8aff4a86f23827501224d..30c514907952f574c16e4dde45c252dd5b7f1eb6 100644 (file)
--- a/clients.c
+++ b/clients.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: clients.c,v 1.4 2001/05/30 04:10:14 a1kmm Exp $
+ * $Id: clients.c,v 1.5 2001/05/31 08:52:03 a1kmm Exp $
  */
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
-#include "efserv.h"
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
 
 void cleanup_hosts(void);
 void m_chmode(char *sender, int parc, char **parv);
index a6fd717c622f3a335b766806102738df371a4617..73614537f793f5333c1be10d7d1971a8c07f8bfd 100644 (file)
--- a/clones.c
+++ b/clones.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: clones.c,v 1.3 2001/05/29 09:29:44 a1kmm Exp $
+ * $Id: clones.c,v 1.4 2001/05/31 08:52:03 a1kmm Exp $
  */
 #include <stdlib.h>
 #include <string.h>
-#include "efserv.h"
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
 
 void
 cleanup_hosts(void)
index 9ce0135b015ffce50ce7f66fa2149573e9324c9c..35a42235b0d545bf58a223960ca9ae0d9bf26940 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: commands.c,v 1.7 2001/05/30 04:10:14 a1kmm Exp $
+ * $Id: commands.c,v 1.8 2001/05/31 08:52:03 a1kmm Exp $
  */
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <assert.h>
-#include "efserv.h"
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
 
 void m_ping(char*, int, char**);
 void m_part(char*, int, char**);
index 7665a0c0f362432b83f4fe3683a46559171f4402..4a09a01bad203ff51f6ed62a34c111c8b6f216ee 100644 (file)
--- a/config.c
+++ b/config.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: config.c,v 1.7 2001/05/31 07:52:10 a1kmm Exp $
+ * $Id: config.c,v 1.8 2001/05/31 08:52:04 a1kmm Exp $
  */
 
-#include "efserv.h"
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
 
 char *values[200][2];
 int keyc;
index 63f5500737a7dbb1c374e4ed9e9a47d8fe5ec32a..ab55f80684f658c64f9a83d169cd0bf6d438f7f8 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: database.c,v 1.1 2001/05/30 04:10:15 a1kmm Exp $
+ * $Id: database.c,v 1.2 2001/05/31 08:52:04 a1kmm Exp $
  */
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
-#include "efserv.h"
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
 
 #define EFCDB_MAJOR_VERSION 0
 #define EFCDB_MINOR_VERSION 1
index aca3b93f9c6f3bd809e7a870f00170e8d27f1bf3..9e16bc444f894ff0fc0d817fd57490b11054a78f 100644 (file)
--- a/efserv.c
+++ b/efserv.c
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: efserv.c,v 1.6 2001/05/30 04:10:15 a1kmm Exp $
+ * $Id: efserv.c,v 1.7 2001/05/31 08:52:04 a1kmm Exp $
  */
 
 #include <stdarg.h>
 #include <netinet/in.h>
 #include <sys/errno.h>
 #include <string.h>
-#include "efserv.h"
+#include <time.h>
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
 
 int send_error = 0;
 time_t timenow;
diff --git a/efserv.h b/efserv.h
deleted file mode 100644 (file)
index 515ec87..0000000
--- a/efserv.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- *  efserv.h: The main header file for efserv.
- *  This is part of efserv, a services.int implementation.
- *  efserv is Copyright(C) 2001 by Andrew Miller, and others.
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *    MA  02111-1307  USA.
- * $Id: efserv.h,v 1.8 2001/05/31 07:52:10 a1kmm Exp $
- */
-
-#include <time.h>
-
-#define NICKLEN 20
-#define HOSTLEN 64
-#define USERLEN 40
-#define SERVLEN 80
-#define CHANLEN 255
-
-#define MAXCLONES_UHOST 4
-#define MAXCLONES_HOST 6
-
-#define JUPE_EXPIRE_TIME 45 /* *60 */
-#define MINIMUM_OPS  0 /* 4 */
-#define EXOP_EXPIRE_TIME 2*60 /* *60 */
-#define CHAN_SLICE_LENGTH 5
-
-#define NETNAME "test net"
-#define LOGFILE "efserv.log"
-#define CHANNEL_DB "efchans.db"
-#define VERSION "pre0.1-test"
-
-struct Command
-{
- char *name;
- void (*func)(char *sender, int argc, char **parv);
-};
-
-struct User
-{
- struct Server *server;
- char nick[NICKLEN], user[USERLEN], host[HOSTLEN];
- unsigned long flags, caps;
- struct ServAdmin *sa;
- struct List *node, *monnode;
-};
-
-struct Server
-{
- char name[SERVLEN];
- unsigned long flags;
- struct List *node;
- struct Server *uplink;
- struct Jupe *jupe;
-};
-
-struct Channel
-{
- char name[CHANLEN];
- int flags;
- time_t ts;
- struct List *ops, *nonops, *exops;
- time_t last_notempty;
-};
-
-struct ChanopUser
-{
- time_t last_opped;
- unsigned long slices;
- char uhost_md5[16];
-};
-
-struct AdminHost
-{
- char *server, *host, *user;
-};
-
-struct ServAdmin
-{
- char *name, *pass;
- int refcount, caps;
- struct List *hosts;
-};
-
-struct VoteServer
-{
- struct List *names;
- int flags;
- int refcount;
-};
-
-struct Host
-{
- char host[HOSTLEN+USERLEN+1];
- int count, rate, full;
- time_t last_recalc, last_report;
-};
-
-struct JupeVote
-{
- struct VoteServer *vs;
- struct ServAdmin *vsa;
- int score;
-};
-
-struct Jupe
-{
- char reason[255];
- int flags;
- /* Note: 15 activates an inactive JUPE, 0 deactivates an active JUPE. */
- int score;
- struct List *jupevotes;
- time_t last_active;
-};
-
-struct Hub
-{
- char *host;
- char *pass;
- int port;
-};
-
-enum
-{
- HASH_COMMAND,
- HASH_SERVER,
- HASH_USER,
- HASH_CHAN,
- HASH_HOST,
-};
-
-enum
-{
- ALEVEL_ADMIN,
- ALEVEL_OPER,
- ALEVEL_SERVADMIN,
- ALEVEL_ANY,
-};
-
-struct HashEntry
-{
- char *name;
- int type;
- void *data;
- struct HashEntry *next;
-};
-
-struct List
-{
- struct List *next, *prev;
- void *data;
-};
-
-extern struct Command Commands[];
-extern struct Server *first_server;
-extern struct List *Servers, *Users, *Channels, *Hosts, *Monitors,
-                   *serv_admins, *VoteServers, *Hubs, *HKeywords;
-extern struct Server *first_server;
-extern char *server_name, *server_pass, *server_host, *sn;
-extern int port;
-extern int reload_module, die;
-extern time_t timenow, channel_record_time;
-extern int server_count, minimum_servers;
-
-void add_to_hash(int type, char *name, void *data);
-void remove_from_hash(int type, char *name);
-void* find_in_hash(int type, const char *name);
-struct List* add_to_list(struct List **list, void *data);
-struct List* add_to_list_before(struct List **list, struct List *before,
-                                void *data);
-void move_list(struct List **dest, struct List **src);
-void remove_from_list(struct List **list, struct List *node);
-void process_smode(const char *chname, const char *mode);
-void pick_a_hub(void);
-int check_admin(struct User*, const char*, const char*);
-void hash_commands(void);
-void deref_admin(struct ServAdmin *a);
-void deref_voteserver(struct VoteServer *v);
-int match(const char *mask, const char *name);
-struct VoteServer *find_server_vote(const char *name);
-void destroy_server_links(struct Server *svr);
-void destroy_server(struct Server *svr);
-char *getmd5(struct User*);
-void cleanup_channels(void);
-void cleanup_jupes(void);
-void cleanup_hosts(void);
-void wipe_type_from_hash(int type, void (*cdata)(void*));
-void save_channel_opdb(void);
-void load_channel_opdb(void);
-
-#ifdef __GNUC__
-void fatal_error(const char *, ...)
- __attribute__((format(printf,1,2)));
-int send_msg(char *msg, ...)
- __attribute__((format(printf,1,2)));
-void log(const char *error, ...)
- __attribute__((format(printf,1,2)));
-#else
-void fatal_error(const char *, ...);
-int send_msg(char *msg, ...);
-void log(const char *error, ...);
-#endif
-
-#define find_server(name) (struct Server*)find_in_hash(HASH_SERVER,name)
-#define find_user(name) (struct User*)find_in_hash(HASH_USER,name)
-#define find_channel(name) (struct Channel*)find_in_hash(HASH_CHAN,name)
-#define find_host(name) (struct Host*)find_in_hash(HASH_HOST,name)
-
-#define UFLAG_ADMIN           0x00000001
-#define UFLAG_OPER            0x00000002
-#define UFLAG_SERVADMIN       0x00000004
-
-#define IsAdmin(x) (x->flags & UFLAG_ADMIN)
-#define IsOper(x)  (x->flags & UFLAG_OPER)
-#define IsServAdmin(x)  (x->flags & UFLAG_SERVADMIN)
-
-#define CHFLAG_BANNED         0x00000001
-#define CHFLAG_OPERONLY       0x00000002
-#define CHFLAG_ADMINONLY      0x00000004
-#define SMODES CHFLAG_BANNED | CHFLAG_OPERONLY | CHFLAG_ADMINONLY
-
-#define IsBanChan(x) (x->flags & CHFLAG_BANNED)
-#define IsOperChan(x) (x->flags & CHFLAG_OPERONLY)
-#define IsAdminChan(x) (x->flags & CHFLAG_ADMINONLY)
-#define HasSMODES(x) (x->flags & (SMODES))
-
-#define SERVFLAG_JUPED 1
-#define SERVFLAG_ACTIVE 2
-
-#define IsJuped(x) (x->flags & SERVFLAG_JUPED)
-
-/* Loop through a linked list... */
-#define FORLIST(node,list,type,var) \
- for(node=list,var=node?(type)node->data:NULL;\
-     node;\
-     node=node->next,var=node?(type)node->data:NULL\
-    )
-/* Use this form when items could be deleted from the list... */
-#define FORLISTDEL(node,nnode,list,type,var) \
- for(node=list,nnode=node?node->next:NULL,var=node?(type)node->data:NULL;\
-     node;\
-     node=nnode,nnode=node?node->next:NULL,var=node?(type)node->data:NULL\
-    )
-
-extern struct yystype
-{
- unsigned long number;
- char *string;
-} yylval;
-#define YYSTYPE struct yystype
diff --git a/include/conf.h b/include/conf.h
new file mode 100644 (file)
index 0000000..e1f6f38
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  config.h: Defines stuff relating to the config parser.
+ *  This is part of efserv, a services.int implementation.
+ *  efserv is Copyright(C) 2001 by Andrew Miller, and others.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA.
+ * $Id: conf.h,v 1.1 2001/05/31 08:52:07 a1kmm Exp $
+ */
+
+extern struct yystype
+{
+ unsigned long number;
+ char *string;
+} yylval;
+#define YYSTYPE struct yystype
+
+enum
+{
+ ALEVEL_ADMIN,
+ ALEVEL_OPER,
+ ALEVEL_SERVADMIN,
+ ALEVEL_ANY,
+};
+
diff --git a/include/define.h b/include/define.h
new file mode 100644 (file)
index 0000000..d8a76e4
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  define.h: Contains macro definitions for efserv.
+ *  This is part of efserv, a services.int implementation.
+ *  efserv is Copyright(C) 2001 by Andrew Miller, and others.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA.
+ * $Id: define.h,v 1.1 2001/05/31 08:52:07 a1kmm Exp $
+ */
+
+
+#define NICKLEN 20
+#define HOSTLEN 64
+#define USERLEN 40
+#define SERVLEN 80
+#define CHANLEN 255
+
+#define MAXCLONES_UHOST 4
+#define MAXCLONES_HOST 6
+
+#define JUPE_EXPIRE_TIME 45 /* *60 */
+#define MINIMUM_OPS  0 /* 4 */
+#define EXOP_EXPIRE_TIME 2*60 /* *60 */
+#define CHAN_SLICE_LENGTH 5
+
+#define NETNAME "test net"
+#define LOGFILE "efserv.log"
+#define CHANNEL_DB "efchans.db"
+#define VERSION "pre0.1-test"
+
+/* Below this should not be changed on setup... */
+#define UFLAG_ADMIN           0x00000001
+#define UFLAG_OPER            0x00000002
+#define UFLAG_SERVADMIN       0x00000004
+
+#define IsAdmin(x) (x->flags & UFLAG_ADMIN)
+#define IsOper(x)  (x->flags & UFLAG_OPER)
+#define IsServAdmin(x)  (x->flags & UFLAG_SERVADMIN)
+
+#define CHFLAG_BANNED         0x00000001
+#define CHFLAG_OPERONLY       0x00000002
+#define CHFLAG_ADMINONLY      0x00000004
+#define SMODES CHFLAG_BANNED | CHFLAG_OPERONLY | CHFLAG_ADMINONLY
+
+#define IsBanChan(x) (x->flags & CHFLAG_BANNED)
+#define IsOperChan(x) (x->flags & CHFLAG_OPERONLY)
+#define IsAdminChan(x) (x->flags & CHFLAG_ADMINONLY)
+#define HasSMODES(x) (x->flags & (SMODES))
+
+#define SERVFLAG_JUPED 1
+#define SERVFLAG_ACTIVE 2
+
+#define IsJuped(x) (x->flags & SERVFLAG_JUPED)
+
diff --git a/include/funcs.h b/include/funcs.h
new file mode 100644 (file)
index 0000000..a1830be
--- /dev/null
@@ -0,0 +1,30 @@
+void process_smode(const char *chname, const char *mode);
+void pick_a_hub(void);
+int check_admin(struct User*, const char*, const char*);
+void hash_commands(void);
+void deref_admin(struct ServAdmin *a);
+void deref_voteserver(struct VoteServer *v);
+int match(const char *mask, const char *name);
+struct VoteServer *find_server_vote(const char *name);
+void destroy_server_links(struct Server *svr);
+void destroy_server(struct Server *svr);
+char *getmd5(struct User*);
+void cleanup_channels(void);
+void cleanup_jupes(void);
+void cleanup_hosts(void);
+void wipe_type_from_hash(int type, void (*cdata)(void*));
+void save_channel_opdb(void);
+void load_channel_opdb(void);
+
+#ifdef __GNUC__
+void fatal_error(const char *, ...)
+ __attribute__((format(printf,1,2)));
+int send_msg(char *msg, ...)
+ __attribute__((format(printf,1,2)));
+void log(const char *error, ...)
+ __attribute__((format(printf,1,2)));
+#else
+void fatal_error(const char *, ...);
+int send_msg(char *msg, ...);
+void log(const char *error, ...);
+#endif
diff --git a/include/struct.h b/include/struct.h
new file mode 100644 (file)
index 0000000..89aa381
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *  struct.h: Defines many of the structures.
+ *  This is part of efserv, a services.int implementation.
+ *  efserv is Copyright(C) 2001 by Andrew Miller, and others.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA.
+ * $Id: struct.h,v 1.1 2001/05/31 08:52:08 a1kmm Exp $
+ */
+
+struct Command
+{
+ char *name;
+ void (*func)(char *sender, int argc, char **parv);
+};
+
+struct User
+{
+ struct Server *server;
+ char nick[NICKLEN], user[USERLEN], host[HOSTLEN];
+ unsigned long flags, caps;
+ struct ServAdmin *sa;
+ struct List *node, *monnode;
+};
+
+struct Server
+{
+ char name[SERVLEN];
+ unsigned long flags;
+ struct List *node;
+ struct Server *uplink;
+ struct Jupe *jupe;
+};
+
+struct Channel
+{
+ char name[CHANLEN];
+ int flags;
+ time_t ts;
+ struct List *ops, *nonops, *exops;
+ time_t last_notempty;
+};
+
+struct ChanopUser
+{
+ time_t last_opped;
+ unsigned long slices;
+ char uhost_md5[16];
+};
+
+struct AdminHost
+{
+ char *server, *host, *user;
+};
+
+struct ServAdmin
+{
+ char *name, *pass;
+ int refcount, caps;
+ struct List *hosts;
+};
+
+struct VoteServer
+{
+ struct List *names;
+ int flags;
+ int refcount;
+};
+
+struct Host
+{
+ char host[HOSTLEN+USERLEN+1];
+ int count, rate, full;
+ time_t last_recalc, last_report;
+};
+
+struct JupeVote
+{
+ struct VoteServer *vs;
+ struct ServAdmin *vsa;
+ int score;
+};
+
+struct Jupe
+{
+ char reason[255];
+ int flags;
+ /* Note: 15 activates an inactive JUPE, 0 deactivates an active JUPE. */
+ int score;
+ struct List *jupevotes;
+ time_t last_active;
+};
+
+struct Hub
+{
+ char *host;
+ char *pass;
+ int port;
+};
+
+extern struct Command Commands[];
+extern struct Server *first_server;
+extern struct List *Servers, *Users, *Channels, *Hosts, *Monitors,
+                   *serv_admins, *VoteServers, *Hubs, *HKeywords;
+extern struct Server *first_server;
+extern char *server_name, *server_pass, *server_host, *sn;
+extern int port;
+extern int reload_module, die;
+extern time_t timenow, channel_record_time;
+extern int server_count, minimum_servers;
+
+void add_to_hash(int type, char *name, void *data);
+void remove_from_hash(int type, char *name);
+void* find_in_hash(int type, const char *name);
+struct List* add_to_list(struct List **list, void *data);
+struct List* add_to_list_before(struct List **list, struct List *before,
+                                void *data);
+void move_list(struct List **dest, struct List **src);
+void remove_from_list(struct List **list, struct List *node);
diff --git a/include/utils.h b/include/utils.h
new file mode 100644 (file)
index 0000000..fd3a285
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  utils.h: Defines the hash and linked list tools.
+ *  This is part of efserv, a services.int implementation.
+ *  efserv is Copyright(C) 2001 by Andrew Miller, and others.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA.
+ * $Id: utils.h,v 1.1 2001/05/31 08:52:08 a1kmm Exp $
+ */
+
+enum
+{
+ HASH_COMMAND,
+ HASH_SERVER,
+ HASH_USER,
+ HASH_CHAN,
+ HASH_HOST,
+};
+
+struct HashEntry
+{
+ char *name;
+ int type;
+ void *data;
+ struct HashEntry *next;
+};
+
+struct List
+{
+ struct List *next, *prev;
+ void *data;
+};
+
+/* Loop through a linked list... */
+#define FORLIST(node,list,type,var) \
+ for(node=list,var=node?(type)node->data:NULL;\
+     node;\
+     node=node->next,var=node?(type)node->data:NULL\
+    )
+/* Use this form when items could be deleted from the list... */
+#define FORLISTDEL(node,nnode,list,type,var) \
+ for(node=list,nnode=node?node->next:NULL,var=node?(type)node->data:NULL;\
+     node;\
+     node=nnode,nnode=node?node->next:NULL,var=node?(type)node->data:NULL\
+    )
+
+#define find_server(name) (struct Server*)find_in_hash(HASH_SERVER,name)
+#define find_user(name) (struct User*)find_in_hash(HASH_USER,name)
+#define find_channel(name) (struct Channel*)find_in_hash(HASH_CHAN,name)
+#define find_host(name) (struct Host*)find_in_hash(HASH_HOST,name)
diff --git a/log.c b/log.c
index e2e4e1f717fb524bc1095e01fea8d9b54e3e36fb..30fa0f9a870a0720f208ddfc40c4b5e90fafb288 100644 (file)
--- a/log.c
+++ b/log.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: log.c,v 1.1 2001/05/30 04:10:16 a1kmm Exp $
+ * $Id: log.c,v 1.2 2001/05/31 08:52:05 a1kmm Exp $
  */
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdarg.h>
-#include "efserv.h"
+#include <time.h>
+#include "define.h"
+#include "struct.h"
 
 extern FILE *logfile;
 
diff --git a/match.c b/match.c
new file mode 100644 (file)
index 0000000..1095812
--- /dev/null
+++ b/match.c
@@ -0,0 +1,113 @@
+/*
+ *  match.c: Performs matching of masks.
+ *  This is part of efserv, a services.int implementation.
+ *  efserv is Copyright(C) 2001 by Andrew Miller, and others.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA.
+ * $Id: match.c,v 1.1 2001/05/31 08:52:05 a1kmm Exp $
+ */
+#include <assert.h>
+#include <ctype.h>
+
+#define MATCH_MAX_CALLS 512  /* ACK! This dies when it's less that this
+                                and we have long lines to parse */
+int
+match(const char *mask, const char *name)
+{
+ const unsigned char* m = (const unsigned char*)  mask;
+ const unsigned char* n = (const unsigned char*)  name;
+ const unsigned char* ma = (const unsigned char*) mask;
+ const unsigned char* na = (const unsigned char*) name;
+ int   wild  = 0;
+ int   calls = 0;
+ int   quote = 0;
+ assert(0 != mask);
+ assert(0 != name);
+ if (!mask || !name)
+  return 0;
+ while (calls++ < MATCH_MAX_CALLS)
+ {
+  if (quote)
+   quote++;
+  if (quote == 3)
+   quote = 0;
+  if (*m == '\\' && !quote)
+  {
+   m++;
+   quote = 1;
+   continue;
+  }
+  if (!quote && *m == '*')
+  {
+   /*
+    * XXX - shouldn't need to spin here, the mask should have been
+    * collapsed before match is called
+    */
+   while (*m == '*')
+    m++;
+   if (*m == '\\')
+   {
+    m++;
+    /* This means it is an invalid mask -A1kmm. */
+    if (!*m)
+     return 0;
+    quote = 2;
+   }
+   wild = 1;
+   ma = m;
+   na = n;
+  }
+  if (!*m)
+  {
+   if (!*n)
+    return 1;
+   if (quote)
+    return 0;
+   for (m--; (m > (const unsigned char*) mask) && (*m == '?'); m--)
+    ;
+   if (*m == '*' && (m > (const unsigned char*) mask))
+    return 1;
+   if (!wild)
+    return 0;
+   m = ma;
+   n = ++na;
+  } else if (!*n)
+  {
+   /*
+    * XXX - shouldn't need to spin here, the mask should have been
+    * collapsed before match is called
+    */
+   if (quote)
+    return 0;
+   while (*m == '*')
+    m++;
+   return (*m == 0);
+  }
+  if (tolower(*m) != tolower(*n) && !(!quote && *m == '?'))
+  {
+   if (!wild)
+    return 0;
+   m = ma;
+   n = ++na;
+  } else
+  {
+   if (*m)
+    m++;
+   if (*n)
+    n++;
+  }
+ }
+ return 0;
+}
diff --git a/md5.c b/md5.c
index f672e14e07856886aff39064a076273f699cbdd0..4c79341faebd57b5346a99aba76d50982c2a3c54 100644 (file)
--- a/md5.c
+++ b/md5.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: md5.c,v 1.1 2001/05/29 09:29:45 a1kmm Exp $
+ * $Id: md5.c,v 1.2 2001/05/31 08:52:05 a1kmm Exp $
  */
 #include <string.h>
-#include "efserv.h"
+#include <time.h>
+#include "define.h"
+#include "struct.h"
 
 void md5_block(unsigned long *in, unsigned long *out, unsigned long *x);
 
diff --git a/msg.c b/msg.c
index 3f88ec8ba75c15c5cfca4ef9729488f83f5ae246..e0d1912c327f26bfbd4dfccb08c13ce381e78fb5 100644 (file)
--- a/msg.c
+++ b/msg.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: msg.c,v 1.5 2001/05/31 07:52:11 a1kmm Exp $
+ * $Id: msg.c,v 1.6 2001/05/31 08:52:05 a1kmm Exp $
  */
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include "efserv.h"
+#include "define.h"
+#include "struct.h"
+#include "utils.h"
+#include "funcs.h"
+#include "config.h"
 
 void
 pm_monitor(struct User *usr, char *str)
index efea0754bda28a5039512403fe6de782ee470331..6d3e6233eeb78ebe86b8fcc0a81884ea609811f3 100644 (file)
--- a/sconfig.l
+++ b/sconfig.l
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: sconfig.l,v 1.3 2001/05/31 07:52:11 a1kmm Exp $
+ * $Id: sconfig.l,v 1.4 2001/05/31 08:52:06 a1kmm Exp $
  */
 
 %option case-insensitive
 %option noyywrap
 
 %{
-#include "efserv.h"
+#include "config.h"
 #include "sconfig.tab.h"
 #include <stdio.h>
 #include <stdlib.h>
index 47154ea7345666a6c5e2cceeb95ec919da490a70..f597930e4e36e922ce69b211102bfe46ec3ebcdb 100644 (file)
--- a/sconfig.y
+++ b/sconfig.y
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: sconfig.y,v 1.4 2001/05/31 07:52:11 a1kmm Exp $
+ * $Id: sconfig.y,v 1.5 2001/05/31 08:52:06 a1kmm Exp $
  */
 
 %{
   #include <stdlib.h>
   #include <string.h>
   #include <stdio.h>
-  #include "efserv.h"
+  #include "define.h"
+  #include "struct.h"
+  #include "utils.h"
+  #include "funcs.h"
+  #include "config.h"
   int yylex();
   void yyerror();
   struct ServAdmin *ad;
diff --git a/utils.c b/utils.c
index 6b3eca28da25f5238c23489a32edfc6ca50d982f..c17862e04d272b5324f472fd89be987572229c54 100644 (file)
--- a/utils.c
+++ b/utils.c
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *    MA  02111-1307  USA.
- * $Id: utils.c,v 1.6 2001/05/30 04:10:17 a1kmm Exp $
+ * $Id: utils.c,v 1.7 2001/05/31 08:52:06 a1kmm Exp $
  */
 
 #include <ctype.h>
 #include <stdlib.h>
 #include <strings.h>
 #include <assert.h>
-#include "efserv.h"
+#include "define.h"
+#include "utils.h"
 
 #define HASHSIZE 0x1000