📄 prelude.h
字号:
# include <arpa/inet.h># if (!defined (TCP_NODELAY))# include <netinet/tcp.h># endif#endif/* *//*- Data types --------------------------------------------------------------*/typedef unsigned short Bool; /* Boolean TRUE/FALSE value */typedef unsigned char byte; /* Single unsigned byte = 8 bits */typedef unsigned short dbyte; /* Double byte = 16 bits */typedef unsigned short word; /* Alternative for double-byte */typedef unsigned long dword; /* Double word >= 32 bits */#if (defined (__IS_32BIT__))typedef unsigned long qbyte; /* Quad byte = 32 bits */#elsetypedef unsigned int qbyte; /* Quad byte = 32 bits */#endiftypedef void (*function) (void); /* Address of simple function */#define local static void /* Shorthand for local functions */typedef struct { /* Memory descriptor */ size_t size; /* Size of data part */ byte *data; /* Data part follows here */} DESCR;typedef struct { /* Variable-size descriptor */ size_t max_size; /* Maximum size of data part */ size_t cur_size; /* Current size of data part */ byte *data; /* Data part follows here */} VDESCR;/*- Check compiler data type sizes ------------------------------------------*/#if (UCHAR_MAX != 0xFF)# error "Cannot compile: must change definition of 'byte'."#endif#if (USHRT_MAX != 0xFFFFU)# error "Cannot compile: must change definition of 'dbyte'."#endif#if (defined (__IS_32BIT__))# if (ULONG_MAX != 0xFFFFFFFFUL)# error "Cannot compile: must change definition of 'qbyte'."# endif#else# if (UINT_MAX != 0xFFFFFFFFU)# error "Cannot compile: must change definition of 'qbyte'."# endif#endif/*- Pseudo-functions --------------------------------------------------------*/#define FOREVER for (;;) /* FOREVER { ... } */#define until(expr) while (!(expr)) /* do { ... } until (expr) */#define streq(s1,s2) (!strcmp ((s1), (s2)))#define strneq(s1,s2) (strcmp ((s1), (s2)))#define strused(s) (*(s) != 0)#define strnull(s) (*(s) == 0)#define strclr(s) (*(s) = 0)#define strlast(s) ((s) [strlen (s) - 1])#define strterm(s) ((s) [strlen (s)])#define bit_msk(bit) (1 << (bit))#define bit_set(x,bit) ((x) |= bit_msk (bit))#define bit_clr(x,bit) ((x) &= ~bit_msk (bit))#define bit_tst(x,bit) ((x) & bit_msk (bit))#define tblsize(x) (sizeof (x) / sizeof ((x) [0]))#define tbllast(x) (x [tblsize (x) - 1])#if (defined (random))# undef random# undef randomize#endif#if (defined (min))# undef min# undef max#endif#if (defined (__IS_32BIT__))#define random(num) (int) ((long) rand () % (num))#else#define random(num) (int) ((int) rand () % (num))#endif#define randomize() srand ((unsigned) time (NULL))#define min(a,b) (((a) < (b))? (a): (b))#define max(a,b) (((a) > (b))? (a): (b))/*- ASSERT ------------------------------------------------------------------*//* If DEBUG is defined, the ASSERT macro aborts if the specified condition * is false. Note that you must include sflsyst.c in your application, for * the sys_assert() function. *//* not used for our crypt functions in php*/#if (0)void sys_assert (const char *file, unsigned line);# undef ASSERT# define ASSERT(f) \ if (f) \ ; \ else \ sys_assert (__FILE__, __LINE__)#else# define ASSERT(f)#endif/*- Boolean operators and constants -----------------------------------------*/#if (!defined (TRUE))# define TRUE 1 /* ANSI standard */# define FALSE 0#endif/*- Symbolic constants ------------------------------------------------------*/#define FORK_ERROR -1 /* Return codes from fork() */#define FORK_CHILD 0#if (!defined (LINE_MAX)) /* Length of line from text file */# define LINE_MAX 255 /* if not previously #define'd */#endif#if (!defined (PATH_MAX)) /* Length of path variable */# define PATH_MAX 2048 /* if not previously #define'd */#endif /* EDM 96/05/28 */#if (!defined (EXIT_SUCCESS)) /* ANSI, and should be in stdlib.h */# define EXIT_SUCCESS 0 /* but not defined on SunOs with */# define EXIT_FAILURE 1 /* GCC, sometimes. */#endif/*- System-specific definitions ---------------------------------------------*//* On most systems, 'timezone' is an external long variable. On a few, it * is a function that returns a string. We define TIMEZONE to be the long * value. */#define TIMEZONE timezone /* Unless redefined later *//* UNIX defines sleep() in terms of second; Win32 defines Sleep() in * terms of milliseconds. We want to be able to use sleep() anywhere. */#if (defined (__WINDOWS__))# if !defined(sleep)# if (defined (WIN32))# define sleep(a) Sleep(a*1000) /* UNIX sleep() is seconds */# else# define sleep(a) /* Do nothing? */# endif# endif /* MSVC 1.x does not define standard signals if in Windows */# if (!defined (SIGINT))# define SIGINT 2 /* Ctrl-C sequence */# define SIGILL 4 /* Illegal instruction */# define SIGSEGV 11 /* Segment violation */# define SIGTERM 15 /* Kill signal */# define SIGABRT 22 /* Termination by abort() */# endif /* MSVC 4.x does not define SIGALRM, so we pinch SIGFPE */# if (!defined (SIGALRM))# define SIGALRM SIGFPE /* Must be a known signal */# endif/* On SunOs, the ANSI C compiler costs extra, so many people install gcc * but using the standard non-ANSI C library. We have to make a few extra * definitions for this case. (Here we defined just what we needed for * Libero and SMT -- we'll add more code as required.) */#elif (defined (__UTYPE_SUNOS) || defined (__UTYPE_SUNSOLARIS))# if (!defined (_SIZE_T)) /* Non-ANSI headers/libraries */# define strerror(n) sys_errlist [n]# define memmove(d,s,l) bcopy (s,d,l) extern char *sys_errlist [];# endif extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_BSDOS))# define TIMEZONE 0 /* timezone is not available */ extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_SCO) || defined (__UTYPE_UNIXWARE)) extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_FREEBSD))# define TIMEZONE 0 /* timezone is not available */ extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_HPUX)) extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_NETBSD))# define TIMEZONE 0 /* timezone is not available */ extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_IRIX)) extern char **environ; /* Not defined in include files */#elif (defined (__UTYPE_SINIX)) extern char **environ; /* Not defined in include files */#elif (defined (__VMS__)) extern char **environ; /* Not defined in include files */ /* This data structure is often used in OpenVMS library functions */ typedef struct { /* Fixed-string descriptor: */ word length; /* Length of string in bytes */ byte dtype; /* Must be DSC$K_DTYPE_T = 14 */ byte class; /* Must be DSC$K_CLASS_S = 1 */ char *value; /* Address of start of string */ } STRING_DESC; #define VMS_STRING(name,value) STRING_DESC name = \ { sizeof (value) - 1, 14, 1, value }#endif/* On some systems (older Vaxen and Unixes) O_BINARY is not defined. */#if (!defined (O_BINARY))# define O_BINARY 0#endif/* On some systems SIGALRM is not defined; we allow it in code anyhow */#if (!defined (SIGALRM))# define SIGALRM 1#endif/* On some systems O_NDELAY is used instead of O_NONBLOCK */#if (!defined (O_NONBLOCK))# if (!defined (O_NDELAY))# define O_NDELAY 0# endif# if (defined (__VMS__))# define O_NONBLOCK 0 /* Can't use O_NONBLOCK on files */# else# define O_NONBLOCK O_NDELAY# endif#endif/* We define constants for the way the current system formats filenames; * we assume that the system has some type of path concept. */#if (defined (WIN32)) /* Windows 95/NT */# define PATHSEP ";" /* Separates path components */# define PATHEND '\\' /* Delimits directory and filename */# define PATHFOLD FALSE /* Convert pathvalue to uppercase? */# define NAMEFOLD FALSE /* Convert filenames to uppercase? */# define MSDOS_FILESYSTEM /* MS-DOS derivative */#elif (defined (__MSDOS__)) /* 16-bit Windows, MS-DOS */# define PATHSEP ";"# define PATHEND '\\'# define PATHFOLD TRUE# define NAMEFOLD TRUE# define MSDOS_FILESYSTEM /* MS-DOS derivative */#elif (defined (__VMS__)) /* Digital OpenVMS */# define PATHSEP "," /* We work with POSIX filenames */# define PATHEND '/'# define PATHFOLD TRUE# define NAMEFOLD TRUE#elif (defined (__UNIX__)) /* All UNIXes */# define PATHSEP ":"# define PATHEND '/'# define PATHFOLD FALSE# define NAMEFOLD FALSE#elif (defined (__OS2__)) /* OS/2 using EMX/GCC */# define PATHSEP ";" /* EDM 96/05/28 */# define PATHEND '\\'# define PATHFOLD TRUE# define NAMEFOLD FALSE# define MSDOS_FILESYSTEM /* MS-DOS derivative */#else# error "No definitions for PATH constants"#endif/*- Capability definitions --------------------------------------------------*//* * Defines zero or more of these symbols, for use in any non-portable * code: * * DOES_SOCKETS We can use (at least some) BSD socket functions * DOES_UID We can use (at least some) uid access functions */#if (defined (AF_INET))# define DOES_SOCKETS /* System supports BSD sockets */#else# undef DOES_SOCKETS# define ntohs(x) (x) /* Needs to be correct for the */# define ntohl(x) (x) /* platform as far as possible */# define htons(x) (x)# define htonl(x) (x)#endif#if (defined (__UNIX__) || defined (__VMS__) || defined (__OS2__))# define DOES_UID /* System supports uid functions */#else# undef DOES_UID typedef int gid_t; /* Group id type */ typedef int uid_t; /* User id type */#endif#endif /* Include PRELUDE.H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -