/* ************************************************************* RWhois Software Copyright (c) 1994 Scott Williamson and Mark Kosters Copyright (c) 1996-2000 Network Solutions, Inc. See the file LICENSE for conditions of use and distribution. **************************************************************** */ /* This header file describes common macros and defines for cross-platform support */ #ifndef _COMMON_H_ #define _COMMON_H_ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif /* system includes -- all files should just include this file, rather than include stdio.h, et al. themselves. */ /* I guess that everyonse has these... */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* we use assertions */ #include #ifdef HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #ifdef HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #ifdef TIME_WITH_SYS_TIME #include #endif /* TIME_WITH_SYS_TIME */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_FCNTL_H #include #endif /* HAVE_FCNTL_H */ #ifdef HAVE_SYS_FILE_H #include #endif /* HAVE_SYS_FILE_H */ /* some nice convenient macros */ /* NOTE: the variables passed to this routine must be legal (i.e., terminated) C strings */ #ifndef STR_EQ #define STR_EQ(str1,str2) \ (strcasecmp((char *)(str1), (char *)(str2)) ? FALSE : TRUE) #endif /* ! STR_EQ */ #ifndef STRN_EQ #define STRN_EQ(str1,str2,size) \ (strncasecmp((char *)(str1), (char *)(str2), (size)) ? FALSE : TRUE) #endif /* ! STRN_EQ */ #ifndef STR_EXISTS #define STR_EXISTS(str) ((str) && *(str)) #endif /* ! STR_EXISTS */ #ifndef NOT_STR_EXISTS #define NOT_STR_EXISTS(str) (!(str) || !*(str)) #endif /* ! NOT_STR_EXISTS */ /* NOTE: the 'str' variable must be a literal string or locally defined character array. */ #define STR_COPY(str,val) \ strncpy((char *)(str), (char *)(val), sizeof(str) - 1) #define SAFE_STR(str,def) \ (str ? str : def) #define SAFE_STR_NONE(str) \ SAFE_STR(str, "none") #endif /* _COMMON_H_ */