/* JOE global header file */ #include "config.h" /* Common header files */ #include #include #include #include #ifdef HAVE_SYS_TYPES_H #include #else typedef int pid_t; #endif #ifdef HAVE_SIGNAL_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_TIME_H #include #endif #define joe_gettext(s) my_gettext((unsigned char *)(s)) /* #ifdef ENABLE_NLS #include #define joe_gettext(s) (unsigned char *)gettext((char *)(s)) #else #define joe_gettext(s) ((unsigned char *)(s)) #endif */ /* Strings needing translation are marked with this macro */ #define _(s) (s) /* Global Defines */ /* Prefix to make string constants unsigned */ #define USTR (unsigned char *) /* Doubly-linked list node */ #define LINK(type) struct { type *next; type *prev; } #ifdef HAVE_SNPRINTF #define joe_snprintf_0(buf,len,fmt) snprintf((char *)(buf),(len),(char *)(fmt)) #define joe_snprintf_1(buf,len,fmt,a) snprintf((char *)(buf),(len),(char *)(fmt),(a)) #define joe_snprintf_2(buf,len,fmt,a,b) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b)) #define joe_snprintf_3(buf,len,fmt,a,b,c) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c)) #define joe_snprintf_4(buf,len,fmt,a,b,c,d) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d)) #define joe_snprintf_5(buf,len,fmt,a,b,c,d,e) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d),(e)) #define joe_snprintf_6(buf,len,fmt,a,b,c,d,e,f) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d),(e),(f)) #define joe_snprintf_7(buf,len,fmt,a,b,c,d,e,f,g) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g)) #define joe_snprintf_8(buf,len,fmt,a,b,c,d,e,f,g,h) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g),(h)) #define joe_snprintf_9(buf,len,fmt,a,b,c,d,e,f,g,h,i) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g),(h),(i)) #define joe_snprintf_10(buf,len,fmt,a,b,c,d,e,f,g,h,i,j) snprintf((char *)(buf),(len),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j)) #define i_printf_0(fmt) (snprintf((char *)(i_msg),sizeof(i_msg),(char *)(fmt)), internal_msg(i_msg)) #define i_printf_1(fmt,a) (snprintf((char *)(i_msg),sizeof(i_msg),(char *)(fmt),(a)), internal_msg(i_msg)) #define i_printf_2(fmt,a,b) (snprintf((char *)(i_msg),sizeof(i_msg),(char *)(fmt),(a),(b)), internal_msg(i_msg)) #define i_printf_3(fmt,a,b,c) (snprintf((char *)(i_msg),sizeof(i_msg),(char *)(fmt),(a),(b),(c)), internal_msg(i_msg)) #define i_printf_4(fmt,a,b,c,d) (snprintf((char *)(i_msg),sizeof(i_msg),(char *)(fmt),(a),(b),(c),(d)), internal_msg(i_msg)) #else #define joe_snprintf_0(buf,len,fmt) sprintf((char *)(buf),(char *)(fmt)) #define joe_snprintf_1(buf,len,fmt,a) sprintf((char *)(buf),(char *)(fmt),(a)) #define joe_snprintf_2(buf,len,fmt,a,b) sprintf((char *)(buf),(char *)(fmt),(a),(b)) #define joe_snprintf_3(buf,len,fmt,a,b,c) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c)) #define joe_snprintf_4(buf,len,fmt,a,b,c,d) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d)) #define joe_snprintf_5(buf,len,fmt,a,b,c,d,e) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d),(e)) #define joe_snprintf_6(buf,len,fmt,a,b,c,d,e,f) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d),(e),(f)) #define joe_snprintf_7(buf,len,fmt,a,b,c,d,e,f,g) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g)) #define joe_snprintf_8(buf,len,fmt,a,b,c,d,e,f,g,h) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g),(h)) #define joe_snprintf_9(buf,len,fmt,a,b,c,d,e,f,g,h,i) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g),(h),(i)) #define joe_snprintf_10(buf,len,fmt,a,b,c,d,e,f,g,h,i,j) sprintf((char *)(buf),(char *)(fmt),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j)) #define i_printf_0(fmt) (sprintf((char *)(i_msg),(char *)(fmt)), internal_msg(i_msg)) #define i_printf_1(fmt,a) (sprintf((char *)(i_msg),(char *)(fmt),(a)), internal_msg(i_msg)) #define i_printf_2(fmt,a,b) (sprintf((char *)(i_msg),(char *)(fmt),(a),(b)), internal_msg(i_msg)) #define i_printf_3(fmt,a,b,c) (sprintf((char *)(i_msg),(char *)(fmt),(a),(b),(c)), internal_msg(i_msg)) #define i_printf_4(fmt,a,b,c,d) (sprintf((char *)(i_msg),(char *)(fmt),(a),(b),(c),(d)), internal_msg(i_msg)) #endif /* Largest signed integer */ #define MAXINT ((((unsigned int)-1)/2)-1) /* Largest signed long */ #define MAXLONG ((((unsigned long)-1L)/2)-1) /* Largest signed long long */ #define MAXLONGLONG ((((unsigned long long)-1L)/2)-1) /* Largest off_t */ /* BSD provides a correct OFF_MAX macro, but AIX provides a broken one, so do it ourselves. */ #if (SIZEOF_OFF_T == SIZEOF_INT) #define MAXOFF MAXINT #elif (SIZEOF_OFF_T == SIZEOF_LONG) #define MAXOFF MAXLONG #elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) #define MAXOFF MAXLONGLONG #else #error off_t is not an int, long, or long long? #endif #include #ifndef EOF #define EOF -1 #endif #define NO_MORE_DATA EOF #if defined __MSDOS__ && SIZEOF_INT == 2 /* real mode ms-dos compilers */ #if SIZEOF_VOID_P == 4 /* real mode ms-dos compilers with 'far' memory model or something like that */ #define physical(a) (((unsigned long)(a)&0xFFFF)+(((unsigned long)(a)&0xFFFF0000)>>12)) #define normalize(a) ((void *)(((unsigned long)(a)&0xFFFF000F)+(((unsigned long)(a)&0x0000FFF0)<<12))) #else #define physical(a) ((unsigned long)(a)) #define normalize(a) (a) #endif /* sizeof(void *) == 4 */ #define SEGSIZ 1024 #define PGSIZE 1024 #define LPGSIZE 10 #define ILIMIT (PGSIZE*96L) #define HTSIZE 128 #else /* not real mode ms-dos */ #define physical(a) ((unsigned long)(a)) #define normalize(a) (a) /* Log2 of page size */ #define LPGSIZE 12 /* No. bytes in page */ #define PGSIZE (1<