1 /* $Header: /home/yav/catty/fkiss/RCS/headers.h,v 1.12 2000/10/17 05:00:44 yav Exp $ 2 * fkiss header files and macros for portability 3 * written by yav <yav@bigfoot.com> 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 2 of the License, or 8 * (at your option) 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 #ifdef STDC_HEADERS 21 # include <stdlib.h> 22 # include <string.h> 23 #else 24 # ifdef HAVE_STRINGS_H 25 # include <strings.h> 26 # endif 27 #endif 28 29 #ifndef HAVE_INDEX 30 # define index strchr 31 #endif 32 #ifndef HAVE_RINDEX 33 # define rindex strrchr 34 #endif 35 #ifndef HAVE_BCOPY 36 # define bcopy(src,dst,len) memcpy((dst),(src),(len)) 37 #endif 38 #ifndef HAVE_BCMP 39 # define bcmp(dst,src,len) memcmp((dst),(src),(len)) 40 #endif 41 #ifndef HAVE_BZERO 42 # define bzero(dst,len) memset((dst),0,(len)) 43 #endif 44 45 #ifndef MAXPATH 46 # ifdef MAXPATHLEN 47 # define MAXPATH MAXPATHLEN 48 # else 49 # define MAXPATH 1024 50 # endif 51 #endif 52 53 /* for (void *) not supported C-compiler */ 54 #ifdef __STDC__ 55 typedef void *VOIDPTR; 56 #else 57 typedef char *VOIDPTR; 58 #endif 59 60 /* get signed short value (little-endian byte order) */ 61 #define GET_SHORT(p) (*((unsigned char *)p)|(*(((char *)p)+1) << 8)) 62 63 /* variable arguments */ 64 65 #ifndef USE_STDARG 66 #ifndef USE_VARARGS 67 # if HAVE_STDARG_H 68 # define USE_STDARG 1 69 # else 70 # if HAVE_VARARGS_H 71 # define USE_VARARGS 1 72 # endif 73 # endif 74 #endif 75 #endif 76 77 #if USE_STDARG 78 # if HAVE_STDARG_H 79 # include <stdarg.h> 80 # endif 81 #endif 82 #if USE_VARARGS 83 # if HAVE_VARARGS_H 84 # include <varargs.h> 85 # endif 86 #endif 87 88 /* directory access routine */ 89 #ifndef USE_BSD_DIRLIB 90 # ifndef HAVE_DIRENT_H 91 # ifndef HAVE_SYS_NDIR_H 92 # ifndef HAVE_SYS_DIR_H 93 # ifndef HAVE_NDIR_H 94 # define USE_BSD_DIRLIB 0 95 # endif 96 # endif 97 # endif 98 # endif 99 # ifndef USE_BSD_DIRLIB 100 # define USE_BSD_DIRLIB 1 101 # endif 102 #endif 103 104 /* 105 * If your system have ctype.h header 106 * and library functions conformins to ISO 9899 ("ISO C"), 107 * uncomment following. 108 */ 109 /* #define HAVE_CTYPE_H 1 */ 110 111 #ifdef HAVE_CTYPE_H 112 # define is_digit(c) isdigit(c) 113 # define is_lower(c) islower(c) 114 # define is_upper(c) isupper(c) 115 # define is_alpha(c) isalpha(c) 116 # define is_alnum(c) isalnum(c) 117 # define to_lower(c) tolower(c) 118 #else /* HAVE_CTYPE_H */ 119 /* (for ASCII character set only) */ 120 # define is_digit(c) ('0'<=(c)&&(c)<='9') 121 # define is_lower(c) ('a'<=(c)&&(c)<='z') 122 # define is_upper(c) ('A'<=(c)&&(c)<='Z') 123 # define is_alpha(c) (is_lower(c)||is_upper(c)) 124 # define is_alnum(c) (is_alpha(c)||is_digit(c)) 125 # define to_lower(c) (is_upper(c) ? ((c) + 0x20) : (c)) 126 #endif /* HAVE_CTYPE_H */ 127 128 129 #ifndef USE_UNAME 130 # ifdef HAVE_UNAME 131 # ifdef HAVE_SYS_UTSNAME_H 132 # define USE_UNAME 1 133 # else 134 # define USE_UNAME 0 135 # endif 136 # else 137 # define USE_UNAME 0 138 # endif 139 #endif /* USE_UNAME */ 140 141 142 /* End of file */ 143