/* Copyright (c) 1993 Stephen F. White */ #ifndef _CONFIG_H_ #define _CONFIG_H_ #ifdef SYSV #include "string.h" #else #include "strings.h" #endif /* SYSV */ /* * useful macros */ #define Arraysize(x) (sizeof(x) / sizeof(x[0])) #ifndef MIN #define MIN(A, B) ((A) < (B) ? (A) : (B)) #endif #ifndef MAX #define MAX(A, B) ((A) > (B) ? (A) : (B)) #endif #define INT_SIZE 10 /* size of buffer big enough to hold an int */ #define LONG_SIZE 20 /* size of buffer big enough to hold a long */ #define STRING_INIT_SIZE 16 /* initialize length of String values */ #define STRING_DOUBLING /* double Strings when needed */ #define STRING_GROW_BY 32 /* or use this to increment linearly */ #define CODE_INIT_SIZE 32 #define SYM_INIT_SIZE 16 #define STACK_SIZE 128 #define HASH_INIT_SIZE 37 #define HASH_INIT_LOAD 2 #define MAX_TOKEN_LEN 40 /* maximum length of internal token names */ #define MAX_PATH_LEN 1024 /* maximum length of path names */ #define SYS_OBJ 0 #define ROOT_OBJ 1 /* if defined, the server will force 1 root */ #define MAX_AGE 20 /* default max. recursion, essentially */ #define MAX_TICKS 10000 /* default maximum instructions per task */ #define PLAYER_PORT 7777 /* default player port */ typedef short Serverid; typedef int Playerid; #define raise(x) cool_raise(x) /* so as not to conflict with signal.h */ #define NOTHING (-1) /* represents an invalid player */ #define BLOCK_SIZE 512 /* size of input block */ #define UDP_BLOCK_SIZE 2048 /* size of input block for YO packets */ #define PROGDIR "/tmp" /* temp directory for COOL programs */ #define RUNDIR "online" /* directory for on-line files */ /*** SYSTEM-SPECIFIC STUFF ***/ /* ( hopefully this will disappear/change when we move to gnu configure ) */ #ifdef NOVOIDPTR #define GENPTR char * #else #define GENPTR void * #endif #define MALLOC(what, number) (what *) cool_malloc((number) * sizeof(what)) #define FREE(what) cool_free( (GENPTR) what) #ifdef SYSV #define random() rand() /* sysv has no random() */ #define srandom(x) srand(x) #define index(s,c) strchr(s,(int)c) /* or index() */ #define getdtablesize() sysconf(_SC_OPEN_MAX) /* or getdtablesize() */ #endif /* SYSV */ /* * timing stuff */ #define MSG_TIMEOUT 30 /* message timeout, in seconds */ #define MSG_RETRY 1500 /* message retry interval, in msec */ #define EXP_BACKOFF /* define this for exponential backoff */ #define LOCK_TIMEOUT 30 /* lock timeout, in seconds */ /* * input quotas */ #define MAX_CMDS 100 /* maximum commands in a burst */ #define MSEC_PER_CMD 1000 /* time between commands after a burst */ #define MAX_OUTPUT 16384 /* maximum amount of queued output */ #define CONNECT_MSG "*** Connected ***\r\n" #define DISCONNECT_MSG "*** Disconnected ***\r\n" #define TRANSFER_MSG1 "*** Transferring to new connection ***\r\n" #define TRANSFER_MSG2 "*** Reconnecting to old connection ***\r\n" #ifdef STRCASE #ifdef PROTO extern int strcasecmp(const char *s, const char *t); extern int strncasecmp(const char *s, const char *t, int n); #endif /* PROTO */ #define cool_strcasecmp(a, b) strcasecmp(a, b) #define cool_strncasecmp(a, b, n) strncasecmp(a, b, n) #else extern int cool_strcasecmp(const char *s, const char *t); extern int cool_strncasecmp(const char *s, const char *t, int n); #endif #endif _CONFIG_H_