Procházet zdrojové kódy

* Moved a majority of eggdrop.h to proper places

svn: 639
Bryan Drewery před 22 roky
rodič
revize
f120cffe0d
17 změnil soubory, kde provedl 257 přidání a 222 odebrání
  1. 1 0
      src/cmds.c
  2. 18 0
      src/crypt.h
  3. 8 0
      src/dccutil.h
  4. 56 0
      src/debug.h
  5. 13 155
      src/eggdrop.h
  6. 5 5
      src/eggmain.h
  7. 54 0
      src/flags.c
  8. 13 0
      src/flags.h
  9. 0 3
      src/main.h
  10. 0 54
      src/misc.c
  11. 45 5
      src/misc.h
  12. 1 0
      src/mod/irc.mod/irc.c
  13. 4 0
      src/mod/irc.mod/irc.h
  14. 1 0
      src/mod/module.h
  15. 36 0
      src/net.h
  16. 1 0
      src/tclhash.c
  17. 1 0
      src/userent.c

+ 1 - 0
src/cmds.c

@@ -7,6 +7,7 @@
 
 #include "eggmain.h"
 #include "cmds.h"
+#include "debug.h"
 #include "dcc.h"
 #include "misc.h"
 #include "net.h"

+ 18 - 0
src/crypt.h

@@ -1,6 +1,24 @@
 #ifndef _CRYPT_H
 #define _CRYPT_H
 
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_OPENSSL_SSL_H
+//#  include <openssl/ssl.h>
+#  include <openssl/crypto.h>
+#  include <openssl/aes.h>
+#  include <openssl/sha.h>
+#  include <openssl/md5.h>
+#endif /* HAVE_OPENSSL_SSL_H */
+
+#define SHA_HASH_LENGTH (SHA_DIGEST_LENGTH * 2)
+#define MD5_HASH_LENGTH (MD5_DIGEST_LENGTH * 2)
+#define md5cmp(hash, string)            strcmp(hash, md5(string))
+
+
 #ifndef MAKING_MODS
 char *md5(const char *);
 char *encrypt_string(const char *, char *);

+ 8 - 0
src/dccutil.h

@@ -7,6 +7,14 @@
 #  define dprintf dprintf_eggdrop
 #endif
 
+/* Public structure for the listening port map */
+struct portmap {
+  int realport;
+  int mappedto;
+  struct portmap *next;
+};
+
+
 #ifndef MAKING_MODS
 void dprintf (int, ...);
 void chatout (char *, ...);

+ 56 - 0
src/debug.h

@@ -1,9 +1,65 @@
 #ifndef _DEBUG_H
 #define _DEBUG_H
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if !HAVE_SIGACTION             /* old "weird signals" */
+#  define sigaction sigvec
+#  ifndef sa_handler
+#    define sa_handler sv_handler
+#    define sa_mask sv_mask
+#    define sa_flags sv_flags
+#  endif
+#endif
+
+#if !HAVE_SIGEMPTYSET
+/* and they probably won't have sigemptyset, dammit */
+#  define sigemptyset(x) ((*(int *)(x))=0)
+#endif
+
+/*
+ * Undefine this to completely disable context debugging.
+ * WARNING: DO NOT send in bug reports if you undefine this!
+ */
+
+#define DEBUG_CONTEXT
+
+/*
+ *    Handy aliases for memory tracking and core dumps
+ */
+#ifdef DEBUG_CONTEXT
+#  include "main.h"
+#  define Context               eggContext(__FILE__, __LINE__, NULL)
+#  define ContextNote(note)     eggContextNote(__FILE__, __LINE__, NULL, note)
+#else
+#  define Context               {}
+#  define ContextNote(note)     {}
+#endif
+
+#ifdef DEBUG_ASSERT
+#  define Assert(expr)  do {                                            \
+        if (!(expr))                                                    \
+                eggAssert(__FILE__, __LINE__, NULL);                    \
+} while (0)
+#else
+#  define Assert(expr)  do {    } while (0)
+#endif
+
+#define debug0(x)               putlog(LOG_DEBUG,"*",x)
+#define debug1(x,a1)            putlog(LOG_DEBUG,"*",x,a1)
+#define debug2(x,a1,a2)         putlog(LOG_DEBUG,"*",x,a1,a2)
+#define debug3(x,a1,a2,a3)      putlog(LOG_DEBUG,"*",x,a1,a2,a3)
+#define debug4(x,a1,a2,a3,a4)   putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
+
+
 #ifndef MAKING_MODS
 void sdprintf (char *, ...);
 void init_signals();
+void eggContext(const char *, int, const char *);
+void eggContextNote(const char *, int, const char *, const char *);
+void eggAssert(const char *, int, const char *);
 #endif /* !MAKING_MODS */
 
 #endif /* !_DEBUG_H */

+ 13 - 155
src/eggdrop.h

@@ -9,33 +9,6 @@
 #ifndef _EGG_EGGDROP_H
 #define _EGG_EGGDROP_H
 
-#ifdef HAVE_OPENSSL_SSL_H
-# ifndef SSL_INC
-#  include <openssl/ssl.h>
-#  include <openssl/rand.h>
-#  include <openssl/err.h>
-#  include <openssl/md5.h>
-#  define SSL_INC
-# endif /* ! SSL_INC */
-# undef HAVE_SSL
-/* #define HAVE_SSL 1 */
-#endif /* HAVE_OPENSSL_SSL_H */
-
-
-/*
- * Undefine this to completely disable context debugging.
- * WARNING: DO NOT send in bug reports if you undefine this!
- */
-
-#define DEBUG_CONTEXT
-
-/*
- * Set the following to the timestamp for the logfile entries.
- * Popular times might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec)
- * Read `man strftime' for more formatting options.  Keep it below 32 chars.
- */
-#define LOG_TS "[%H:%M]"
-
 /*
 
  * HANDLEN note:
@@ -65,49 +38,6 @@
 #define MAX_BOTS     500
 #define SERVLEN      60
 
-#define SGRAB 2011         /* How much data to allow through sockets. */
-
-#define PRIV_OP 1
-#define PRIV_VOICE 2
-
-#define PRIO_DEOP 1
-#define PRIO_KICK 2
-#define KICK_BANNED 1
-#define KICK_KUSER 2
-#define KICK_KICKBAN 3
-#define KICK_MASSDEOP 4
-#define KICK_BADOP 5
-#define KICK_BADOPPED 6
-#define KICK_MANUALOP 7
-#define KICK_MANUALOPPED 8
-#define KICK_CLOSED 9
-#define KICK_FLOOD 10
-#define KICK_NICKFLOOD 11
-#define KICK_KICKFLOOD 12
-#define KICK_BOGUSUSERNAME 13
-#define KICK_MEAN 14
-#define KICK_BOGUSKEY 15
-
-#define ERR_BINSTAT 1
-#define ERR_BINMOD 2
-#define ERR_PASSWD 3
-#define ERR_WRONGBINDIR 4
-#define ERR_CONFSTAT 5
-#define ERR_TMPSTAT 6
-#define ERR_CONFDIRMOD 7
-#define ERR_CONFMOD 8
-#define ERR_TMPMOD 9
-#define ERR_NOCONF 10
-#define ERR_CONFBADENC 11
-#define ERR_WRONGUID 12
-#define ERR_WRONGUNAME 13
-#define ERR_BADCONF 14
-#define ERR_MAX 15
-
-#define EMAIL_OWNERS    0x1
-#define EMAIL_TEAM      0x2
-
-
 /*
  *     The 'configure' script should make this next part automatic,
  *     so you shouldn't need to adjust anything below.
@@ -120,6 +50,18 @@
 #define NOTENAMELEN     ((HANDLEN * 2) + 1)
 #define BADNICKCHARS	"-,+*=:!.@#;$%&"
 
+#if (NICKMAX < 9) || (NICKMAX > 32)
+#  include "invalid NICKMAX value"
+#endif
+
+#if (HANDLEN < 9) || (HANDLEN > 32)
+#  include "invalid HANDLEN value"
+#endif
+
+#if HANDLEN > NICKMAX
+#  include "HANDLEN MUST BE <= NICKMAX"
+#endif
+
 
 /* Have to use a weird way to make the compiler error out cos not all
  * compilers support #error or error
@@ -128,24 +70,6 @@
 #  include "error_you_need_vsprintf_to_compile_eggdrop"
 #endif
 
-/*
- * Enable IPv6 debugging?
- */
-#define DEBUG_IPV6 1
-#define HAVE_IPV6 1
-
-/* IPv6 sanity checks. */
-#ifdef USE_IPV6
-#  ifndef HAVE_IPV6
-#    undef USE_IPV6
-#  endif
-#  ifndef HAVE_GETHOSTBYNAME2
-#    ifndef HAVE_GETIPNODEBYNAME
-#      undef USE_IPV6
-#    endif
-#  endif
-#endif
-
 
 #if HAVE_UNISTD_H
 #  include <unistd.h>
@@ -155,17 +79,6 @@
 #  include "you_need_to_upgrade_your_compiler_to_a_standard_c_one_mate!"
 #endif
 
-#if (NICKMAX < 9) || (NICKMAX > 32)
-#  include "invalid NICKMAX value"
-#endif
-
-#if (HANDLEN < 9) || (HANDLEN > 32)
-#  include "invalid HANDLEN value"
-#endif
-
-#if HANDLEN > NICKMAX
-#  include "HANDLEN MUST BE <= NICKMAX"
-#endif
 
 /* NAME_MAX is what POSIX defines, but BSD calls it MAXNAMLEN.
  * Use 255 if we can't find anything else.
@@ -198,52 +111,6 @@
 #  define random() (rand()/16)
 #endif
 
-#if !HAVE_SIGACTION		/* old "weird signals" */
-#  define sigaction sigvec
-#  ifndef sa_handler
-#    define sa_handler sv_handler
-#    define sa_mask sv_mask
-#    define sa_flags sv_flags
-#  endif
-#endif
-
-#if !HAVE_SIGEMPTYSET
-/* and they probably won't have sigemptyset, dammit */
-#  define sigemptyset(x) ((*(int *)(x))=0)
-#endif
-
-
-/*
- *    Handy aliases for memory tracking and core dumps
- */
-
-#define my_bzero(a, b) { char *x = (char *) a; int y = (int) b; while (y--) *x++ = 0; }
-#define killsock(x)	real_killsock((x),__FILE__,__LINE__)
-
-
-#ifdef DEBUG_CONTEXT
-#  include "main.h"
-#  define Context		eggContext(__FILE__, __LINE__, NULL)
-#  define ContextNote(note)	eggContextNote(__FILE__, __LINE__, NULL, note)
-#else
-#  define Context		{}
-#  define ContextNote(note)	{}
-#endif
-
-#ifdef DEBUG_ASSERT
-#  define Assert(expr)	do {						\
-	if (!(expr))							\
-		eggAssert(__FILE__, __LINE__, NULL);			\
-} while (0)
-#else
-#  define Assert(expr)	do {	} while (0)
-#endif
-
-#define debug0(x)		putlog(LOG_DEBUG,"*",x)
-#define debug1(x,a1)		putlog(LOG_DEBUG,"*",x,a1)
-#define debug2(x,a1,a2)		putlog(LOG_DEBUG,"*",x,a1,a2)
-#define debug3(x,a1,a2,a3)	putlog(LOG_DEBUG,"*",x,a1,a2,a3)
-#define debug4(x,a1,a2,a3,a4)	putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
 
 /* These apparently are unsafe without recasting. */
 #define egg_isdigit(x)  isdigit((int)  (unsigned char) (x))
@@ -255,13 +122,6 @@
 
 /***********************************************************************/
 
-/* Public structure for the listening port map */
-struct portmap {
-  int realport;
-  int mappedto;
-  struct portmap *next;
-};
-
 /* Public structure of all the dcc connections */
 struct dcc_table {
   char *name;
@@ -278,9 +138,7 @@ struct dcc_table {
 
 struct userrec;
 
-#define SHA_HASH_LENGTH (SHA_DIGEST_LENGTH * 2)
-#define MD5_HASH_LENGTH (MD5_DIGEST_LENGTH * 2)
-#define md5cmp(hash, string)		strcmp(hash, md5(string))
+#include "crypt.h"
 
 struct auth_t {
   struct userrec *user;

+ 5 - 5
src/eggmain.h

@@ -12,6 +12,11 @@
 #  include "config.h"
 #endif
 #include "garble.h"
+#include "debug.h"
+#include "eggdrop.h"
+#include "flags.h"
+#include "chan.h"
+#include "compat/compat.h"
 
 
 
@@ -21,17 +26,12 @@
 #ifdef HAVE_STRINGS_H
 #  include <strings.h>
 #endif
-#include <sys/types.h>
 #include "lang.h"
-#include "eggdrop.h"
-#include "flags.h"
 #ifdef HAVE_ZLIB_H
 #  include <zlib.h>
 #endif /* HAVE_ZLIB_H */
 
 #include "tclegg.h"
-#include "chan.h"
-#include "compat/compat.h"
 
 
 /* This macro copies (_len - 1) bytes from _source to _target. The

+ 54 - 0
src/flags.c

@@ -751,3 +751,57 @@ struct user_entry_type USERENTRY_BOTFL =
   "BOTFL"
 };
 
+/* private returns 0 if user has access, and 1 if they dont because of +private
+ * This function does not check if the user has "op" access, it only checks if the user is
+ * restricted by +private for the channel
+ */
+int private(struct flag_record fr, struct chanset_t *chan, int type)
+{
+  if (!channel_private(chan) || glob_bot(fr) || glob_owner(fr))
+    return 0; /* user is implicitly not restricted by +private, they may however be lacking other flags */
+
+  if (type == PRIV_OP) {
+    /* |o implies all flags above. n| has access to all +private. Bots are exempt. */
+    if (chan_op(fr))
+      return 0;
+  } else if (type == PRIV_VOICE) {
+    if (chan_voice(fr))
+      return 0;
+  }
+  return 1; /* user is restricted by +private */
+}
+
+int chk_op(struct flag_record fr, struct chanset_t *chan)
+{
+  if (!chan || (!private(fr, chan, PRIV_OP) && !chk_deop(fr, chan))) {
+    if (chan_op(fr) || (glob_op(fr) && !chan_deop(fr)))
+      return 1;
+  }
+  return 0;
+}
+
+int chk_deop(struct flag_record fr, struct chanset_t *chan)
+{
+  if (chan_deop(fr) || (glob_deop(fr) && !chan_op(fr)))
+    return 1;
+  else
+    return 0;
+}
+
+int chk_voice(struct flag_record fr, struct chanset_t *chan)
+{
+  if (!chan || (!private(fr, chan, PRIV_VOICE) && !chk_devoice(fr, chan))) {
+    if (chan_voice(fr) || (glob_voice(fr) && !chan_quiet(fr)))
+      return 1;
+  }
+  return 0;
+}
+
+int chk_devoice(struct flag_record fr, struct chanset_t *chan)
+{
+  if (chan_quiet(fr) || (glob_quiet(fr) && !chan_voice(fr)))
+    return 1;
+  else
+    return 0;
+}
+

+ 13 - 0
src/flags.h

@@ -6,6 +6,13 @@
 #ifndef _EGG_FLAGS_H
 #define _EGG_FLAGS_H
 
+#include "chan.h"
+
+/* For private() checking */
+#define PRIV_OP 1
+#define PRIV_VOICE 2
+
+
 struct flag_record {
   int match;
   int global;
@@ -186,6 +193,12 @@ int sanity_check(int);
 int chan_sanity_check(int, int);
 char geticon(int);
 
+int private(struct flag_record, struct chanset_t *, int);
+int chk_op(struct flag_record, struct chanset_t *);
+int chk_deop(struct flag_record, struct chanset_t *);
+int chk_voice(struct flag_record, struct chanset_t *);
+int chk_devoice(struct flag_record, struct chanset_t *);
+
 #endif				/* MAKING_MODS */
 
 #endif				/* _EGG_FLAGS_H */

+ 0 - 3
src/main.h

@@ -5,9 +5,6 @@
 int crontab_exists();
 void crontab_create(int);
 void fatal(const char *, int);
-void eggContext(const char *, int, const char *);
-void eggContextNote(const char *, int, const char *, const char *);
-void eggAssert(const char *, int, const char *);
 #endif /* !MAKING_MODS */
 
 #endif /* !_MAIN_H */

+ 0 - 54
src/misc.c

@@ -1934,60 +1934,6 @@ void werr(int errnum)
 }
 
 
-/* private returns 0 if user has access, and 1 if they dont because of +private 
- * This function does not check if the user has "op" access, it only checks if the user is
- * restricted by +private for the channel
- */
-int private(struct flag_record fr, struct chanset_t *chan, int type)
-{
-  if (!channel_private(chan) || glob_bot(fr) || glob_owner(fr))
-    return 0; /* user is implicitly not restricted by +private, they may however be lacking other flags */
-
-  if (type == PRIV_OP) {
-    /* |o implies all flags above. n| has access to all +private. Bots are exempt. */
-    if (chan_op(fr))
-      return 0;
-  } else if (type == PRIV_VOICE) {
-    if (chan_voice(fr))
-      return 0;
-  }
-  return 1; /* user is restricted by +private */
-}
-
-int chk_op(struct flag_record fr, struct chanset_t *chan)
-{
-  if (!chan || (!private(fr, chan, PRIV_OP) && !chk_deop(fr, chan))) {
-    if (chan_op(fr) || (glob_op(fr) && !chan_deop(fr)))
-      return 1;
-  }
-  return 0;
-}
-
-int chk_deop(struct flag_record fr, struct chanset_t *chan)
-{
-  if (chan_deop(fr) || (glob_deop(fr) && !chan_op(fr)))
-    return 1;
-  else
-    return 0;
-}
-
-int chk_voice(struct flag_record fr, struct chanset_t *chan)
-{
-  if (!chan || (!private(fr, chan, PRIV_VOICE) && !chk_devoice(fr, chan))) {
-    if (chan_voice(fr) || (glob_voice(fr) && !chan_quiet(fr)))
-      return 1;
-  }
-  return 0;
-}
-
-int chk_devoice(struct flag_record fr, struct chanset_t *chan)
-{
-  if (chan_quiet(fr) || (glob_quiet(fr) && !chan_voice(fr)))
-    return 1;
-  else
-    return 0;
-}
-
 void local_check_should_lock()
 {
   module_entry *me;

+ 45 - 5
src/misc.h

@@ -3,6 +3,51 @@
 
 #include "eggmain.h"
 
+
+/*
+ * Set the following to the timestamp for the logfile entries.
+ * Popular times might be "[%H:%M]" (hour, min), or "[%H:%M:%S]" (hour, min, sec)
+ * Read `man strftime' for more formatting options.  Keep it below 32 chars.
+ */
+#define LOG_TS "[%H:%M]"
+
+
+#define KICK_BANNED 		1
+#define KICK_KUSER 		2
+#define KICK_KICKBAN 		3
+#define KICK_MASSDEOP 		4
+#define KICK_BADOP 		5
+#define KICK_BADOPPED 		6
+#define KICK_MANUALOP 		7
+#define KICK_MANUALOPPED	8
+#define KICK_CLOSED		9
+#define KICK_FLOOD 		10
+#define KICK_NICKFLOOD 		11
+#define KICK_KICKFLOOD 		12
+#define KICK_BOGUSUSERNAME 	13
+#define KICK_MEAN 		14
+#define KICK_BOGUSKEY 		15
+
+#define ERR_BINSTAT 	1
+#define ERR_BINMOD 	2
+#define ERR_PASSWD 	3
+#define ERR_WRONGBINDIR 4
+#define ERR_CONFSTAT 	5
+#define ERR_TMPSTAT 	6
+#define ERR_CONFDIRMOD 	7
+#define ERR_CONFMOD 	8
+#define ERR_TMPMOD 	9
+#define ERR_NOCONF 	10
+#define ERR_CONFBADENC 	11
+#define ERR_WRONGUID 	12
+#define ERR_WRONGUNAME 	13
+#define ERR_BADCONF 	14
+#define ERR_MAX 	15
+
+#define EMAIL_OWNERS    0x1
+#define EMAIL_TEAM      0x2
+
+
 #ifndef MAKING_MODS
 char *homedir();
 char *my_uname();
@@ -61,11 +106,6 @@ char *strchr_unescape(char *, const char, register const char);
 void str_unescape(char *, register const char);
 int str_isdigit(const char *);
 void kill_bot(char *, char *);
-int private(struct flag_record, struct chanset_t *, int);
-int chk_op(struct flag_record, struct chanset_t *);
-int chk_deop(struct flag_record, struct chanset_t *);
-int chk_voice(struct flag_record, struct chanset_t *);
-int chk_devoice(struct flag_record, struct chanset_t *);
 #endif /* !MAKING_MODS */
 
 #endif /* !_MISC_H_ */

+ 1 - 0
src/mod/irc.mod/irc.c

@@ -9,6 +9,7 @@
 #define MAKING_IRC
 #include "src/mod/module.h"
 #include "irc.h"
+#include "src/misc.h"
 #include "src/salt.h"
 #include "src/mod/server.mod/server.h"
 #undef serv

+ 4 - 0
src/mod/irc.mod/irc.h

@@ -10,6 +10,10 @@
 #define REVENGE_KICK 1		/* Kicked victim	*/
 #define REVENGE_DEOP 2		/* Took op		*/
 
+#define PRIO_DEOP 1
+#define PRIO_KICK 2
+
+
 #ifdef MAKING_IRC
 #ifdef S_AUTH
 static int check_bind_pubc(char *, char *, char *, struct userrec *, char *, char *);

+ 1 - 0
src/mod/module.h

@@ -26,6 +26,7 @@
 
 /* Just include *all* the include files...it's slower but EASIER */
 #include "src/eggmain.h"
+#include "src/debug.h"
 #include "src/color.h"
 #include "src/users.h"
 #include "src/types.h"

+ 36 - 0
src/net.h

@@ -7,10 +7,46 @@
 
 #include "types.h"
 
+
+#ifdef HAVE_OPENSSL_SSL_H
+# ifdef USE_SSL
+#  include <openssl/ssl.h>
+#  include <openssl/rand.h>
+#  include <openssl/err.h>
+#  undef HAVE_SSL
+# endif /* USE_SSL */
+/* #define HAVE_SSL 1 */
+#endif /* HAVE_OPENSSL_SSL_H */
+
+/*
+ * Enable IPv6 debugging?
+ */
+#define DEBUG_IPV6 1
+#define HAVE_IPV6 1
+
+/* IPv6 sanity checks. */
+#ifdef USE_IPV6
+#  ifndef HAVE_IPV6
+#    undef USE_IPV6
+#  endif
+#  ifndef HAVE_GETHOSTBYNAME2
+#    ifndef HAVE_GETIPNODEBYNAME
+#      undef USE_IPV6
+#    endif
+#  endif
+#endif
+
+#define SGRAB 2011         /* How much data to allow through sockets. */
+
+
 #define iptolong(a)             (0xffffffff &                           \
                                  (long) (htonl((unsigned long) a)))
 
+
 #ifndef MAKING_MODS
+
+# define killsock(x)     	real_killsock((x),__FILE__,__LINE__)
+
 IP my_atoul(char *);
 #ifdef HAVE_SSL
 int ssl_cleanup();

+ 1 - 0
src/tclhash.c

@@ -11,6 +11,7 @@
 
 #include "eggmain.h"
 #include "tclhash.h"
+#include "debug.h"
 #include "chan.h"
 #include "users.h"
 #include "match.h"

+ 1 - 0
src/userent.c

@@ -7,6 +7,7 @@
 #include "eggmain.h"
 #include "users.h"
 #include "misc.h"
+#include "debug.h"
 #include "match.h"
 #include "dccutil.h"
 #include "crypt.h"