compat.h

Go to the documentation of this file.
00001 /* Essential tools.
00002  *
00003  * PegSoft compatibility library (c) 2004 PegSoft
00004  * Contact us at pegsoft@pegsoft.net
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License version 2 as
00008  * published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software (the COPYING file); if not, write to the
00017  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
00018  * USA.
00019  *
00020  */
00021 
00028 #ifndef SYSTEM_COMPAT_H
00029 #define SYSTEM_COMPAT_H
00030 
00031 /*************************************************************************/
00032 
00033 #include <system/headers.h>
00034 
00035 /*************************************************************************/
00036 
00037 #if !HAVE_INET_ADDR || !HAVE_INET_ATON || !HAVE_INET_NTOA
00038 # if HAVE_SYS_SOCKET_H
00039 #  include <sys/socket.h>
00040 # endif
00041 # if HAVE_NETINET_IN_H
00042 #  include <netinet/in.h>
00043 # endif
00044 #endif
00045 
00046 /*************************************************************************/
00047 
00048 #if defined(__cplusplus)
00049 # define EXT extern "C"
00050 #else
00051 # define EXT extern
00052 #endif
00053 
00054 #if defined(__cplusplus)
00055 namespace std 
00056 {
00057 #endif
00058 
00059 #if !HAVE_SNPRINTF
00060 EXT int compat_snprintf(char *buf, size_t len, const char *format, ...);
00061 # define snprintf compat_snprintf
00062 #endif
00063 
00064 #if !HAVE_VSNPRINTF
00065 EXT int compat_vsnprintf(char *buf, size_t len, const char *format,
00066         va_list ap);
00067 # define vsnprintf compat_vsnprintf
00068 #endif
00069 
00070 #if defined(__cplusplus)
00071 } /* namespace std */
00072 #endif
00073 
00074 #if !HAVE_INET_ADDR
00075 EXT in_addr_t compat_inet_addr(char const *cp);
00076 # define inet_addr compat_inet_addr
00077 #endif
00078 
00079 #if !HAVE_INET_ATON
00080 EXT int compat_inet_aton(const char *cp, struct in_addr *inp);
00081 # define inet_aton compat_inet_aton
00082 #endif
00083 
00084 #if !HAVE_INET_NTOA
00085 EXT char *compat_inet_ntoa(struct in_addr in);
00086 # define inet_ntoa compat_inet_ntoa
00087 #endif
00088 
00089 #if !HAVE_STPCPY
00090 EXT char *compat_stpcpy(char *dest, char const *src);
00091 # define stpcpy compat_stpcpy
00092 #endif
00093 
00094 #if !HAVE_STPNCPY
00095 EXT char *compat_stpncpy(char *dest, char const *src, size_t n);
00096 # define stpncpy compat_stpncpy
00097 #endif
00098 
00099 #if !HAVE_STRCASECMP
00100 EXT int compat_strcasecmp(char const *s1, char const *s2);
00101 # define strcasecmp compat_strcasecmp
00102 #endif
00103 
00104 #if !HAVE_STRCSPN
00105 EXT size_t compat_strcspn(char const *s, char const *reject);
00106 # define strcspn compat_strcspn
00107 #endif
00108 
00109 #if !HAVE_STRDUP
00110 EXT char *compat_strdup(char const *s);
00111 # define strdup compat_strdup
00112 #endif
00113 
00114 #if !HAVE_STRERROR
00115 EXT char *compat_strerror(int errnum);
00116 # define strerror compat_strerror
00117 #endif
00118 
00119 #if !HAVE_STRICMP
00120 # define stricmp strcasecmp
00121 #endif
00122 
00123 #if !HAVE_STRNCASECMP
00124 EXT int compat_strncasecmp(char const *s1, char const *s2, size_t n);
00125 # define strncasecmp compat_strncasecmp
00126 #endif
00127 
00128 #if !HAVE_STRNICMP
00129 # define strnicmp strncasecmp
00130 #endif
00131 
00132 #if !HAVE_STRSIGNAL
00133 EXT char *compat_strsignal(int signum);
00134 # define strsignal compat_strsignal
00135 #endif
00136 
00137 #if !HAVE_STRSPN
00138 EXT size_t compat_strspn(char const *s, char const *accept);
00139 # define strspn compat_strspn
00140 #endif
00141 
00142 #undef EXT
00143 
00144 /*************************************************************************/
00145 
00146 #if !HAVE_GID_T
00147 typedef int gid_t;
00148 #endif
00149 
00150 #if !HAVE_MODE_T
00151 typedef int mode_t;
00152 #endif
00153 
00154 #if !HAVE_OFF_T
00155 typedef long off_t;
00156 #endif
00157 
00158 #if !HAVE_PID_T
00159 typedef int pid_t;
00160 #endif
00161 
00162 #if !HAVE_PTRDIFF_T
00163 typedef signed ptrdiff_t;
00164 #endif
00165 
00166 #if !HAVE_SIZE_T
00167 typedef unsigned size_t;
00168 #endif
00169 
00170 #if !HAVE_SOCKLEN_T
00171 typedef int socklen_t;
00172 #endif
00173 
00174 #if !HAVE_SSIZE_T
00175 typedef signed ssize_t;
00176 #endif
00177 
00178 #if !HAVE_UID_T
00179 typedef int uid_t;
00180 #endif
00181 
00182 /*************************************************************************/
00183 
00184 #if !NO_STDINT
00185 
00186 #if !HAVE_INT8_T || !HAVE_INT16_T || !HAVE_INT32_T || !HAVE_UINT8_T || !HAVE_UINT16_T || !HAVE_UINT32_T
00187 # if SIZEOF_CHAR == 1
00188 #  if !HAVE_INT8_T
00189 typedef signed char int8_t;
00190 #  endif
00191 #  if !HAVE_UINT8_T
00192 typedef unsigned char uint8_t;
00193 #  endif
00194 # endif
00195 # if SIZEOF_CHAR == 2
00196 #  if !HAVE_INT16_T
00197 typedef signed char int16_t;
00198 #   undef HAVE_INT16_T
00199 #   define HAVE_INT16_T 1
00200 #  endif
00201 #  if !HAVE_UINT16_T
00202 typedef unsigned char uint16_t;
00203 #   undef HAVE_UINT16_T
00204 #   define HAVE_UINT16_T 1
00205 #  endif
00206 # endif
00207 # if SIZEOF_SHORT == 2
00208 #  if !HAVE_INT16_T
00209 typedef signed short int16_t;
00210 #   undef HAVE_INT16_T
00211 #   define HAVE_INT16_T 1
00212 #  endif
00213 #  if !HAVE_UINT16_T
00214 typedef unsigned short uint16_t;
00215 #   undef HAVE_UINT16_T
00216 #   define HAVE_UINT16_T 1
00217 #  endif
00218 # endif
00219 # if SIZEOF_SHORT == 4
00220 #  if !HAVE_INT32_T
00221 typedef signed short int32_t;
00222 #   undef HAVE_INT32_T
00223 #   define HAVE_INT32_T 1
00224 #  endif
00225 #  if !HAVE_UINT32_T
00226 typedef unsigned short uint32_t;
00227 #   undef HAVE_UINT32_T
00228 #   define HAVE_UINT32_T 1
00229 #  endif
00230 # endif
00231 # if SIZEOF_INT == 2
00232 #  if !HAVE_INT16_T
00233 typedef signed int int16_t;
00234 #   undef HAVE_INT16_T
00235 #   define HAVE_INT16_T 1
00236 #  endif
00237 #  if !HAVE_UINT16_T
00238 typedef unsigned int uint16_t;
00239 #   undef HAVE_UINT16_T
00240 #   define HAVE_UINT16_T 1
00241 #  endif
00242 # endif
00243 # if SIZEOF_INT == 4
00244 #  if !HAVE_INT32_T
00245 typedef signed int int32_t;
00246 #   undef HAVE_INT32_T
00247 #   define HAVE_INT32_T 1
00248 #  endif
00249 #  if !HAVE_UINT32_T
00250 typedef unsigned int uint32_t;
00251 #   undef HAVE_UINT32_T
00252 #   define HAVE_UINT32_T 1
00253 #  endif
00254 # endif
00255 # if SIZEOF_LONG == 4
00256 #  if !HAVE_INT32_T
00257 typedef signed long int32_t;
00258 #   undef HAVE_INT32_T
00259 #   define HAVE_INT32_T 1
00260 #  endif
00261 #  if !HAVE_UINT32_T
00262 typedef unsigned long uint32_t;
00263 #   undef HAVE_UINT32_T
00264 #   define HAVE_UINT32_T 1
00265 #  endif
00266 # endif
00267 #endif
00268 
00269 #endif
00270 
00271 /*************************************************************************/
00272 
00273 #ifndef NAME_MAX
00274 # define NAME_MAX   255
00275 #endif
00276 
00277 #ifndef PATH_MAX
00278 # define PATH_MAX   4096
00279 #endif
00280 
00281 /*************************************************************************/
00282 
00283 #ifdef __GNUC__
00284 # define FORMAT(type,fmt,start) __attribute__((format(type,fmt,start)))
00285 #else 
00286 # define FORMAT(type,fmt,start)
00287 #endif
00288 
00289 /*************************************************************************/
00290 
00291 #endif /* SYSTEM_COMPAT_H */

Generated on Sun May 20 21:32:13 2007 for Epona API by  doxygen 1.4.6