]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/portab/portab.h
private strndup() implementation in case libc does not provide it
[ngircd-alex.git] / src / portab / portab.h
index 529d46a078f398ccbd120af47340dc485802d17d..a968a3b9bd924fbbe6e04eee47d1dc5f4f925e21 100644 (file)
@@ -1,29 +1,53 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
- *
- * $Id: portab.h,v 1.10 2002/12/26 13:26:34 alex Exp $
- *
- * Portability functions and declarations (header for libngbportab).
  */
 
-
 #ifndef __PORTAB__
 #define __PORTAB__
 
+/**
+ * @file
+ * Portability functions and declarations (header)
+ */
 
 #include "config.h"
 
+#ifndef DEBUG
+# define NDEBUG
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+# define NGIRC_GOT_INTTYPES
+#else
+# ifdef HAVE_STDINT_H
+#  include <stdint.h>
+#  define NGIRC_GOT_INTTYPES
+# endif
+#endif
+
+#ifdef HAVE_STDDEF_H
+# include <stddef.h>
+#endif
+
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#endif
 
 /* compiler features */
 
-#ifdef __GNUC__
+#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
 # define PUNUSED(x) __attribute__ ((unused)) x
 # define UNUSED     __attribute__ ((unused))
 #else
 #endif
 
 
-/* keywords */
-
-#define EXTERN extern
-#define STATIC static
-#define LOCAL static
-#define CONST const
-#define REGISTER register
-
-
 /* datatypes */
 
 #ifndef PROTOTYPES
 # endif
 #endif
 
-typedef void VOID;
 typedef void POINTER;
 
-typedef signed int INT;
-typedef unsigned int UINT;
-typedef signed long LONG;
-typedef unsigned long ULONG;
-
-typedef signed char INT8;
+#ifdef NGIRC_GOT_INTTYPES
+typedef uint8_t UINT8;
+typedef uint16_t UINT16;
+typedef uint32_t UINT32;
+#else
 typedef unsigned char UINT8;
-typedef signed short INT16;
 typedef unsigned short UINT16;
-typedef signed long INT32;
-typedef unsigned long UINT32;
-
-typedef double DOUBLE;
-typedef float FLOAT;
-
-typedef char CHAR;
-
-typedef UINT8 BOOLEAN;
-
-#undef TRUE
-#define TRUE (BOOLEAN)1
+typedef unsigned int UINT32;
+#endif
 
-#undef FALSE
-#define FALSE (BOOLEAN)0
+#ifndef HAVE_STDBOOL_H
+typedef unsigned char bool;
+#define true (bool)1
+#define false (bool)0
+#endif
 
-#undef NULL
+#ifndef NULL
 #ifdef PROTOTYPES
-# define NULL (VOID *)0
+# define NULL (void *)0
 #else
 # define NULL 0L
 #endif
+#endif
+
+#ifdef NeXT
+#define S_IRUSR 0000400                /* read permission, owner */
+#define S_IWUSR 0000200                /* write permission, owner */
+#define S_IRGRP 0000040                /* read permission, group */
+#define S_IROTH 0000004                /* read permission, other */
+#define ssize_t int
+#endif
 
 #undef GLOBAL
 #define GLOBAL
@@ -98,7 +112,6 @@ typedef UINT8 BOOLEAN;
 
 /* SPLint */
 
-
 #ifdef S_SPLINT_S
 #include "splint.h"
 #endif
@@ -106,43 +119,67 @@ typedef UINT8 BOOLEAN;
 
 /* target constants  */
 
-#ifndef TARGET_OS
-#define TARGET_OS "unknown"
+#ifndef HOST_OS
+#define HOST_OS "unknown"
 #endif
 
-#ifndef TARGET_CPU
-#define TARGET_CPU "unknown"
+#ifndef HOST_CPU
+#define HOST_CPU "unknown"
 #endif
 
-#ifndef TARGET_VENDOR
-#define TARGET_VENDOR "unknown"
+#ifndef HOST_VENDOR
+#define HOST_VENDOR "unknown"
 #endif
 
+#ifdef __HAIKU__
+#define SINGLE_USER_OS
+#endif
 
 /* configure options */
 
 #ifndef HAVE_socklen_t
-#define socklen_t int                  /* u.a. fuer Mac OS X */
-#endif
-
-#if OS_UNIX_AUX
-#define _POSIX_SOURCE                  /* muss unter A/UX definiert sein */
+typedef int socklen_t;                 /* for Mac OS X, amongst others */
 #endif
 
 #ifndef HAVE_SNPRINTF
-EXTERN INT snprintf( CHAR *str, size_t count, CONST CHAR *fmt, ... );
+extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
 #endif
 
 #ifndef HAVE_STRLCAT
-EXTERN size_t strlcat( CHAR *dst, CONST CHAR *src, size_t size );
+extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
 #endif
 
 #ifndef HAVE_STRLCPY
-EXTERN size_t strlcpy( CHAR *dst, CONST CHAR *src, size_t size );
+extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
+#endif
+
+#ifndef HAVE_STRDUP
+extern char * strdup PARAMS(( const char *s ));
+#endif
+
+#ifndef HAVE_STRNDUP
+extern char * strndup PARAMS((const char *s, size_t maxlen));
+#endif
+
+#ifndef HAVE_STRTOK_R
+extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
 #endif
 
 #ifndef HAVE_VSNPRINTF
-EXTERN INT vsnprintf( CHAR *str, size_t count, CONST CHAR *fmt, va_list args );
+#include <stdarg.h>
+extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
+#endif
+
+#ifndef HAVE_GAI_STRERROR
+#define gai_strerror(r) "unknown error"
+#endif
+
+#ifndef PACKAGE_NAME
+#define PACKAGE_NAME PACKAGE
+#endif
+
+#ifndef PACKAGE_VERSION
+#define PACKAGE_VERSION VERSION
 #endif