#define _XOPEN_SOURCE 600 #define _GNU_SOURCE 1 #define _BSD_SOURCE 1 #define _ISOC99_SOURCE 1 #include /* memcpy(), etc. */ #include /* htonl(), etc. */ /* Linux does not have these 'errno' values */ #define EFTYPE EINVAL #define EPROGMISMATCH EINVAL #define LLONG_MAX 9223372036854775807LL #define LLONG_MIN (-LLONG_MAX - 1LL) #define INFTIM (-1) #define REG_STARTEND 0 #define ALIGNBYTES (sizeof(size_t) - 1) /* ?? */ #define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) #define mergesort(a,b,c,d) (qsort(a,b,c,d), 0) #define strlcpy(dst, src, size) snprintf(dst, size, "%s", src) #define strlcat(dst, src, size) snprintf((dst) + strlen(dst), \ (size) - strlen(dst), "%s", src) #include #define funopen1(c, m, rf, wf, sf, cf) \ fopencookie(c, m, \ ({ \ _IO_cookie_io_functions_t _funcs; \ _funcs.read = (cookie_read_function_t *)(rf); \ _funcs.write = (cookie_write_function_t *)(wf); \ _funcs.seek = (cookie_seek_function_t *)(sf); \ _funcs.close = (cookie_close_function_t *)(cf); \ _funcs; \ })) #define funopen(c, rf, wf, sf, cf) \ funopen1(c, "r+", rf, wf, sf, cf) #define fropen(c, rf) funopen1(c, "r", rf, NULL, NULL, NULL) #define fwopen(c, rf) funopen1(c, "w", NULL, wf, NULL, NULL)