00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ns_config_h
00038 #define ns_config_h
00039
00040
00041 #define MEMDEBUG_SIMULATIONS
00042
00043
00044 #include <sys/types.h>
00045 #if STDC_HEADERS
00046 #include <stdlib.h>
00047 #include <stddef.h>
00048 #endif
00049
00050
00051 #ifdef WIN32
00052 #include "autoconf-win32.h"
00053 #else
00054 #include "autoconf.h"
00055 #endif
00056
00057
00058 #ifndef stand_alone
00059 #ifdef __cplusplus
00060 #include <tclcl.h>
00061 #endif
00062 #endif
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 typedef int32_t nsaddr_t;
00077 typedef int32_t nsmask_t;
00078
00079
00080 struct ns_addr_t {
00081 int32_t addr_;
00082 int32_t port_;
00083 #ifdef __cplusplus
00084 bool isEqual (ns_addr_t const &o) {
00085 return ((addr_ == o.addr_) && (port_ == o.port_))?true:false;
00086 }
00087 #endif // __cplusplus
00088 };
00089
00090
00091 #ifndef STRTOI64
00092 #if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8
00093 #define STRTOI64 strtol
00094 #define STRTOI64_FMTSTR "%ld"
00095
00096
00097 #elif defined(HAVE_STRTOQ)
00098 #define STRTOI64 strtoq
00099 #define STRTOI64_FMTSTR "%lld"
00100
00101
00102 #elif defined(HAVE_STRTOLL)
00103 #define STRTOI64 strtoll
00104 #define STRTOI64_FMTSTR "%lld"
00105
00106 #endif
00107 #endif
00108
00109 #define NS_ALIGN (8)
00110
00111
00112
00113 #define TINY_LEN 8
00114 #define SMALL_LEN 32
00115 #define MID_LEN 256
00116 #define BIG_LEN 4096
00117 #define HUGE_LEN 65536
00118 #define TRUE 1
00119 #define FALSE 0
00120
00121
00122
00123
00124
00125
00126 #ifdef HAVE_STRING_H
00127 #include <string.h>
00128 #endif
00129 #ifdef HAVE_STRINGS_H
00130 #include <strings.h>
00131 #endif
00132
00133 #ifndef HAVE_BZERO
00134 #define bzero(dest,count) memset(dest,0,count)
00135 #endif
00136 #ifndef HAVE_BCOPY
00137 #define bcopy(src,dest,size) memcpy(dest,src,size)
00138 #endif
00139
00140 #include <stdlib.h>
00141
00142 #ifdef HAVE_UNISTD_H
00143 #include <unistd.h>
00144 #endif
00145
00146 #ifdef HAVE_TIME_H
00147 #include <time.h>
00148 #endif
00149
00150 #ifdef HAVE_ARPA_INET_H
00151 #include <arpa/inet.h>
00152 #endif
00153
00154 #if (defined(__hpux) || defined(_AIX)) && defined(__cplusplus)
00155
00156 extern "C" {
00157 int strcasecmp(const char *, const char *);
00158 clock_t clock(void);
00159 #if !defined(__hpux)
00160 int gethostid(void);
00161 #endif
00162 time_t time(time_t *);
00163 char *ctime(const time_t *);
00164 }
00165 #endif
00166
00167 #if defined(NEED_SUNOS_PROTOS) && defined(__cplusplus)
00168 extern "C" {
00169 struct timeval;
00170 struct timezone;
00171 int gettimeofday(struct timeval*, ...);
00172 int ioctl(int fd, int request, ...);
00173 int close(int);
00174 int strcasecmp(const char*, const char*);
00175 int srandom(int);
00176 int random();
00177 int socket(int, int, int);
00178 int setsockopt(int s, int level, int optname, void* optval, int optlen);
00179 struct sockaddr;
00180 int connect(int s, sockaddr*, int);
00181 int bind(int s, sockaddr*, int);
00182 struct msghdr;
00183 int send(int s, void*, int len, int flags);
00184 int sendmsg(int, msghdr*, int);
00185 int recv(int, void*, int len, int flags);
00186 int recvfrom(int, void*, int len, int flags, sockaddr*, int);
00187 int gethostid();
00188 int getpid();
00189 int gethostname(char*, int);
00190 void abort();
00191 }
00192 #endif
00193
00194 #if defined(NEED_SUNOS_PROTOS) || defined(solaris)
00195 extern "C" {
00196 #if defined(NEED_SUNOS_PROTOS)
00197 caddr_t sbrk(int incr);
00198 #endif
00199 int getrusage(int who, struct rusage* rusage);
00200 }
00201 #endif
00202
00203
00204
00205 #ifdef WIN32
00206
00207 #include <windows.h>
00208 #include <winsock.h>
00209 #include <time.h>
00210
00211 #include <minmax.h>
00212 #define NOMINMAX
00213 #undef min
00214 #undef max
00215 #undef abs
00216
00217 #define MAXHOSTNAMELEN 256
00218
00219 #define _SYS_NMLN 9
00220 struct utsname {
00221 char sysname[_SYS_NMLN];
00222 char nodename[_SYS_NMLN];
00223 char release[_SYS_NMLN];
00224 char version[_SYS_NMLN];
00225 char machine[_SYS_NMLN];
00226 };
00227
00228 typedef char *caddr_t;
00229
00230 struct iovec {
00231 caddr_t iov_base;
00232 int iov_len;
00233 };
00234
00235 #ifndef TIMEZONE_DEFINED_
00236 #define TIMEZONE_DEFINED_
00237 struct timezone {
00238 int tz_minuteswest;
00239 int tz_dsttime;
00240 };
00241 #endif
00242
00243 typedef int pid_t;
00244 typedef int uid_t;
00245 typedef int gid_t;
00246
00247 #if defined(__cplusplus)
00248 extern "C" {
00249 #endif
00250
00251 int uname(struct utsname *);
00252 int getopt(int, char * const *, const char *);
00253 int strcasecmp(const char *, const char *);
00254
00255
00256
00257 int gettimeofday(struct timeval *p, struct timezone *z);
00258 int gethostid(void);
00259 int getuid(void);
00260 int getgid(void);
00261 int getpid(void);
00262 int nice(int);
00263 int sendmsg(int, struct msghdr*, int);
00264
00265
00266
00267
00268
00269 #define strncasecmp _strnicmp
00270 #if defined(__cplusplus)
00271 }
00272 #endif
00273
00274 #ifdef WSAECONNREFUSED
00275 #define ECONNREFUSED WSAECONNREFUSED
00276 #define ENETUNREACH WSAENETUNREACH
00277 #define EHOSTUNREACH WSAEHOSTUNREACH
00278 #define EWOULDBLOCK WSAEWOULDBLOCK
00279 #endif
00280
00281 #ifndef M_PI
00282 #define M_PI 3.14159265358979323846
00283 #endif
00284
00285 #endif
00286
00287 #ifdef sgi
00288 #include <math.h>
00289 #endif
00290
00291
00292 #ifndef HAVE_SNPRINTF
00293 #if defined(__cplusplus)
00294 extern "C" {
00295 #endif
00296 extern int snprintf(char *buf, int size, const char *fmt, ...);
00297 #if defined(__cplusplus)
00298 }
00299 #endif
00300 #endif
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 #endif