main.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * main.h
  3. * include file to include most other include files
  4. *
  5. */
  6. #ifndef _EGG_MAIN_H
  7. #define _EGG_MAIN_H
  8. #ifdef HAVE_CONFIG_H
  9. # include "config.h"
  10. #endif
  11. #include "pack/conf.h"
  12. #include "lush.h" /* We seem to need this everywhere... */
  13. #if (((TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION >= 5)) || (TCL_MAJOR_VERSION > 7))
  14. # define USE_TCL_EVENTS
  15. # define USE_TCL_FINDEXEC
  16. # define USE_TCL_PACKAGE
  17. # define USE_TCL_VARARGS
  18. #endif
  19. #if (TCL_MAJOR_VERSION >= 8)
  20. # define USE_TCL_OBJ
  21. #endif
  22. #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)) || (TCL_MAJOR_VERSION > 8))
  23. # define USE_TCL_BYTE_ARRAYS
  24. # define USE_TCL_ENCODING
  25. #endif
  26. #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
  27. # ifdef CONST
  28. # define EGG_CONST CONST
  29. # else
  30. # define EGG_CONST
  31. # endif
  32. #else
  33. # define EGG_CONST
  34. #endif
  35. /* UGH! Why couldn't Tcl pick a standard? */
  36. #if defined(USE_TCL_VARARGS) && (defined(__STDC__) || defined(HAS_STDARG))
  37. # ifdef HAVE_STDARG_H
  38. # include <stdarg.h>
  39. # else
  40. # ifdef HAVE_STD_ARGS_H
  41. # include <std_args.h>
  42. # endif
  43. # endif
  44. # define EGG_VARARGS(type, name) (type name, ...)
  45. # define EGG_VARARGS_DEF(type, name) (type name, ...)
  46. # define EGG_VARARGS_START(type, name, list) (va_start(list, name), name)
  47. #else
  48. # include <varargs.h>
  49. # define EGG_VARARGS(type, name) ()
  50. # define EGG_VARARGS_DEF(type, name) (va_alist) va_dcl
  51. # define EGG_VARARGS_START(type, name, list) (va_start(list), va_arg(list,type))
  52. #endif
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <string.h>
  56. #ifdef HAVE_STRINGS_H
  57. # include <strings.h>
  58. #endif
  59. #include <sys/types.h>
  60. #include "lush.h"
  61. #include "lang.h"
  62. #include "eggdrop.h"
  63. #include "flags.h"
  64. #ifdef HAVE_ZLIB_H
  65. # include <zlib.h>
  66. #endif /* HAVE_ZLIB_H */
  67. #ifndef MAKING_MODS
  68. # include "proto.h"
  69. #endif
  70. #include "cmdt.h"
  71. #include "tclegg.h"
  72. #include "tclhash.h"
  73. #include "chan.h"
  74. #include "users.h"
  75. #include "compat/compat.h"
  76. /* For pre Tcl7.5p1 versions */
  77. #ifndef HAVE_TCL_FREE
  78. # define Tcl_Free(x) n_free(x, "", 0)
  79. #endif
  80. /* For pre7.6 Tcl versions */
  81. #ifndef TCL_PATCH_LEVEL
  82. # define TCL_PATCH_LEVEL Tcl_GetVar(interp, "tcl_patchLevel", TCL_GLOBAL_ONLY)
  83. #endif
  84. #ifndef MAKING_MODS
  85. extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_LOST, DCC_SCRIPT, DCC_BOT_NEW,
  86. DCC_RELAY, DCC_RELAYING, DCC_FORK_RELAY, DCC_PRE_RELAY, DCC_CHAT_PASS,
  87. DCC_FORK_BOT, DCC_SOCKET, DCC_TELNET_ID, DCC_TELNET_NEW, DCC_TELNET_PW,
  88. DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_DNSWAIT;
  89. #endif
  90. #define iptolong(a) (0xffffffff & \
  91. (long) (htonl((unsigned long) a)))
  92. #define fixcolon(x) do { \
  93. if ((x)[0] == ':') \
  94. (x)++; \
  95. else \
  96. (x) = newsplit(&(x)); \
  97. } while (0)
  98. /* This macro copies (_len - 1) bytes from _source to _target. The
  99. * target string is NULL-terminated.
  100. */
  101. #define strncpyz(_target, _source, _len) do { \
  102. strncpy((_target), (_source), (_len) - 1); \
  103. (_target)[(_len) - 1] = 0; \
  104. } while (0)
  105. #ifdef BORGCUBES
  106. /* For net.c */
  107. # define O_NONBLOCK 00000004 /* POSIX non-blocking I/O */
  108. #endif /* BORGUBES */
  109. #define strncpy0(a,b,c) { strncpy(a, b, c-1); (a)[c-1]=0; }
  110. #ifdef strncpy
  111. #undef strncpy
  112. #endif
  113. #endif /* _EGG_MAIN_H */