home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / in4wjcxu / other / irc / include / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-14  |  3.6 KB  |  145 lines

  1. /************************************************************************
  2.  *   IRC - Internet Relay Chat, include/common.h
  3.  *   Copyright (C) 1990 Armin Gruner
  4.  *
  5.  *   This program is free software; you can redistribute it and/or modify
  6.  *   it under the terms of the GNU General Public License as published by
  7.  *   the Free Software Foundation; either version 1, or (at your option)
  8.  *   any later version.
  9.  *
  10.  *   This program is distributed in the hope that it will be useful,
  11.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *   GNU General Public License for more details.
  14.  *
  15.  *   You should have received a copy of the GNU General Public License
  16.  *   along with this program; if not, write to the Free Software
  17.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef    __common_include__
  21. #define __common_include__
  22.  
  23. #ifdef    PARAMH
  24. #include <sys/param.h>
  25. #endif
  26.  
  27. #ifndef PROTO
  28. #if __STDC__
  29. #    define PROTO(x)    x
  30. #else
  31. #    define PROTO(x)    ()
  32. #endif
  33. #endif
  34.  
  35. #ifndef NULL
  36. #define NULL 0
  37. #endif
  38.  
  39. #ifdef TRUE
  40. #undef TRUE
  41. #endif
  42.  
  43. #ifdef FALSE
  44. #undef FALSE
  45. #endif
  46.  
  47. #define FALSE (0)
  48. #define TRUE  (!FALSE)
  49.  
  50. #ifndef    MALLOCH
  51. char    *malloc(), *calloc();
  52. void    free();
  53. #else
  54. #include MALLOCH
  55. #endif
  56.  
  57. extern    int    matches PROTO((char *, char *));
  58. extern    int    mycmp PROTO((char *, char *));
  59. extern    int    myncmp PROTO((char *, char *, int));
  60. #ifdef NEED_STRTOK
  61. extern    char    *strtok PROTO((char *, char *));
  62. #endif
  63. #ifdef NEED_STRTOKEN
  64. extern    char    *strtoken PROTO((char **, char *, char *));
  65. #endif
  66. #ifdef NEED_INET_ADDR
  67. extern unsigned long inet_addr PROTO((char *));
  68. #endif
  69.  
  70. #if defined(NEED_INET_NTOA) || defined(NEED_INET_NETOF)
  71. #include <netinet/in.h>
  72. #endif
  73.  
  74. #ifdef NEED_INET_NTOA
  75. extern char *inet_ntoa PROTO((struct in_addr));
  76. #endif
  77.  
  78. #ifdef NEED_INET_NETOF
  79. extern int inet_netof PROTO((struct in_addr));
  80. #endif
  81.  
  82. extern char *myctime PROTO((time_t));
  83. extern char *strtoken PROTO((char **, char *, char *));
  84.  
  85. #ifndef MAX
  86. #define MAX(a, b)    ((a) > (b) ? (a) : (b))
  87. #endif
  88. #ifndef MIN
  89. #define MIN(a, b)    ((a) < (b) ? (a) : (b))
  90. #endif
  91.  
  92. #define DupString(x,y) do{x=MyMalloc(strlen(y)+1);(void)strcpy(x,y);}while(0)
  93.  
  94. extern unsigned char tolowertab[];
  95.  
  96. #undef tolower
  97. #define tolower(c) (tolowertab[(u_char)(c)])
  98.  
  99. extern unsigned char touppertab[];
  100.  
  101. #undef toupper
  102. #define toupper(c) (touppertab[(u_char)(c)])
  103.  
  104. #undef isalpha
  105. #undef isdigit
  106. #undef isxdigit
  107. #undef isalnum
  108. #undef isprint
  109. #undef isascii
  110. #undef isgraph
  111. #undef ispunct
  112. #undef islower
  113. #undef isupper
  114. #undef isspace
  115. #undef iscntrl
  116.  
  117. extern unsigned char char_atribs[];
  118.  
  119. #define PRINT 1
  120. #define CNTRL 2
  121. #define ALPHA 4
  122. #define PUNCT 8
  123. #define DIGIT 16
  124. #define SPACE 32
  125.  
  126. #define    iscntrl(c) (char_atribs[(u_char)(c)]&CNTRL)
  127. #define isalpha(c) (char_atribs[(u_char)(c)]&ALPHA)
  128. #define isspace(c) (char_atribs[(u_char)(c)]&SPACE)
  129. #define islower(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) > 0x5f))
  130. #define isupper(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) < 0x60))
  131. #define isdigit(c) (char_atribs[(u_char)(c)]&DIGIT)
  132. #define    isxdigit(c) (isdigit(c) || 'a' <= (c) && (c) <= 'f' || \
  133.              'A' <= (c) && (c) <= 'F')
  134. #define isalnum(c) (char_atribs[(u_char)(c)]&(DIGIT|ALPHA))
  135. #define isprint(c) (char_atribs[(u_char)(c)]&PRINT)
  136. #define isascii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f)
  137. #define isgraph(c) ((char_atribs[(u_char)(c)]&PRINT) && ((u_char)(c) != 0x32))
  138. #define ispunct(c) (!(char_atribs[(u_char)(c)]&(CNTRL|ALPHA|DIGIT)))
  139.  
  140. extern char *MyMalloc();
  141. extern void flush_connections();
  142. extern struct SLink *find_user_link(/* struct SLink *, struct Client * */);
  143.  
  144. #endif /* __common_include__ */
  145.