/* Public domain */ /* Macros around compiler attributes. */ #include #include #include #ifdef HAVE_BOUNDED_ATTRIBUTE # define BOUNDED_ATTRIBUTE(t, a, b) __attribute__((__bounded__ (t,a,b))) #else # define BOUNDED_ATTRIBUTE(t, a, b) #endif #ifdef HAVE_FORMAT_ATTRIBUTE # define FORMAT_ATTRIBUTE(t, a, b) __attribute__((__format__ (t,a,b))) #else # define FORMAT_ATTRIBUTE(t, a, b) #endif #ifdef HAVE_NONNULL_ATTRIBUTE # define NONNULL_ATTRIBUTE(a) __attribute__((__nonnull__ (a))) #else # define NONNULL_ATTRIBUTE(a) #endif /* Standard includes for struct definitions and inline functions */ #include #include #include #include #include #include #include #include #include #include /* Preferred program exit codes */ #include #ifdef HAVE_SYSEXITS_H # include # define CGI_EX_OK EX_OK # define CGI_EX_DATAERR EX_DATAERR # define CGI_EX_UNAVAILABLE EX_UNAVAILABLE # define CGI_EX_SOFTWARE EX_SOFTWARE # define CGI_EX_OSERR EX_OSERR # define CGI_EX_OSFILE EX_OSFILE # define CGI_EX_IOERR EX_IOERR # define CGI_EX_TEMPFAIL EX_TEMPFAIL # define CGI_EX_PROTOCOL EX_PROTOCOL # define CGI_EX_NOPERM EX_NOPERM # define CGI_EX_CONFIG EX_CONFIG #else # define CGI_EX_OK 0 # define CGI_EX_DATAERR 65 # define CGI_EX_UNAVAILABLE 69 # define CGI_EX_SOFTWARE 70 # define CGI_EX_OSERR 71 # define CGI_EX_OSFILE 72 # define CGI_EX_IOERR 74 # define CGI_EX_TEMPFAIL 75 # define CGI_EX_PROTOCOL 76 # define CGI_EX_NOPERM 77 # define CGI_EX_CONFIG 78 #endif /* HAVE_SYSEXITS_H */ /* Socket length argument */ #if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) typedef socklen_t CGI_SockLen_t; #else typedef int CGI_SockLen_t; #endif /* C++ compatibility */ #if !defined(__BEGIN_DECLS) || !defined(__END_DECLS) # if defined(__cplusplus) # define __BEGIN_DECLS extern "C" { # define __END_DECLS } # else # define __BEGIN_DECLS # define __END_DECLS # endif #endif /* * Expand "DECLSPEC" to any compiler-specific keywords, as required for proper * visibility of symbols in shared libraries. * See: http://gcc.gnu.org/wiki/Visibility */ #ifndef DECLSPEC # if defined(__BEOS__) # if defined(__GNUC__) # define DECLSPEC __declspec(dllexport) # else # define DECLSPEC __declspec(export) # endif # elif defined(__WIN32__) # ifdef __BORLANDC__ # ifdef _PERCGI_INTERNAL # define DECLSPEC # else # define DECLSPEC __declspec(dllimport) # endif # else # define DECLSPEC __declspec(dllexport) # endif # elif defined(__OS2__) # ifdef __WATCOMC__ # ifdef _PERCGI_INTERNAL # define DECLSPEC __declspec(dllexport) # else # define DECLSPEC # endif # else # define DECLSPEC # endif # else # if defined(__GNUC__) && __GNUC__ >= 4 # define DECLSPEC __attribute__ ((visibility("default"))) # else # define DECLSPEC # endif # endif #endif #ifdef __SYMBIAN32__ # ifndef EKA2 # undef DECLSPEC # define DECLSPEC # elif !defined(__WINS__) # undef DECLSPEC # define DECLSPEC __declspec(dllexport) # endif #endif /* Standard utility routines */ #include #include #if defined(_PERCGI_INTERNAL) || defined(_USE_PERCGI_STD) #define Free(p) CGI_Free((p)) #define Malloc(len) CGI_Malloc((len)) #define TryMalloc(len) CGI_TryMalloc((len)) #define Realloc(p,len) CGI_Realloc((p),(len)) #define TryRealloc(p,len) CGI_TryRealloc((p),(len)) #include #endif /* _PERCGI_INTERNAL or _USE_PERCGI_STD */ /* Internationalization */ #ifdef _PERCGI_INTERNAL # include # ifdef ENABLE_NLS # include # define _(String) dgettext("percgi",String) # ifdef dgettext_noop # define N_(String) dgettext_noop("percgi",String) # else # define N_(String) (String) # endif # else # undef _ # undef N_ # undef ngettext # define _(s) (s) # define N_(s) (s) # define ngettext(Singular,Plural,Number) ((Number==1)?(Singular):(Plural)) # endif /* !ENABLE_NLS */ #endif /* _PERCGI_INTERNAL */