summary refs log tree commit diff
path: root/src/portab
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2005-03-19 18:43:48 +0000
committerFlorian Westphal <fw@strlen.de>2005-03-19 18:43:48 +0000
commit8adff5922376676c2eeb49de1cbab86cc345b887 (patch)
treef08c4c54b987b83436dfce2cfe5af829c8ccf689 /src/portab
parent27d93d7d8c1dacb3a9874084a67629df26f96bb1 (diff)
downloadngircd-8adff5922376676c2eeb49de1cbab86cc345b887.tar.gz
ngircd-8adff5922376676c2eeb49de1cbab86cc345b887.zip
Remove INT, LONG, BOOLEAN, STATIC, CONST, CHAR datatypes.
use stdbool.h / inttypes.h if available.
Diffstat (limited to 'src/portab')
-rw-r--r--src/portab/portab.h72
-rw-r--r--src/portab/portabtest.c17
-rw-r--r--src/portab/strlcpy.c6
3 files changed, 47 insertions, 48 deletions
diff --git a/src/portab/portab.h b/src/portab/portab.h
index cb50bbd6..d1480589 100644
--- a/src/portab/portab.h
+++ b/src/portab/portab.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: portab.h,v 1.17 2004/03/15 19:26:39 alex Exp $
+ * $Id: portab.h,v 1.18 2005/03/19 18:43:50 fw Exp $
  *
  * Portability functions and declarations (header for libngbportab).
  */
@@ -24,6 +24,23 @@
 # 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 */
 
@@ -45,13 +62,7 @@
 
 
 /* keywords */
-
-#define EXTERN extern
-#define STATIC static
 #define LOCAL static
-#define CONST const
-#define REGISTER register
-
 
 /* datatypes */
 
@@ -61,40 +72,31 @@
 # 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
 
 #undef GLOBAL
 #define GLOBAL
@@ -130,20 +132,20 @@ typedef UINT8 BOOLEAN;
 #endif
 
 #ifndef HAVE_SNPRINTF
-EXTERN INT snprintf PARAMS(( 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 PARAMS(( 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 PARAMS(( CHAR *dst, CONST CHAR *src, size_t size ));
+extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
 #endif
 
 #ifndef HAVE_VSNPRINTF
 #include <stdarg.h>
-EXTERN INT vsnprintf PARAMS(( CHAR *str, size_t count, CONST CHAR *fmt, va_list args ));
+extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
 #endif
 
 #ifndef PACKAGE_NAME
diff --git a/src/portab/portabtest.c b/src/portab/portabtest.c
index 055799ea..d9bea61f 100644
--- a/src/portab/portabtest.c
+++ b/src/portab/portabtest.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: portabtest.c,v 1.11 2003/01/04 10:40:01 alex Exp $";
+static char UNUSED id[] = "$Id: portabtest.c,v 1.12 2005/03/19 18:43:50 fw Exp $";
 
 #include "imp.h"
 #include <stdarg.h>
@@ -25,20 +25,17 @@ static char UNUSED id[] = "$Id: portabtest.c,v 1.11 2003/01/04 10:40:01 alex Exp
 #include "exp.h"
 
 
-LOCAL VOID Panic PARAMS (( CHAR *Reason, INT Code ));
+LOCAL void Panic PARAMS (( char *Reason, int Code ));
 
 
 GLOBAL int
-main( VOID )
+main( void )
 {
 	/* validate datatypes */
-	if( FALSE != 0 ) Panic( "FALSE", 1 );
-	if( TRUE != 1 ) Panic( "TRUE", 1 );
-	if( sizeof( INT8 ) != 1 ) Panic( "INT8", 1 );
+	if( false != 0 ) Panic( "false", 1 );
+	if( true != 1 ) Panic( "true", 1 );
 	if( sizeof( UINT8 ) != 1 ) Panic( "UINT8", 1 );
-	if( sizeof( INT16 ) != 2 ) Panic( "INT16", 1 );
 	if( sizeof( UINT16 ) != 2 ) Panic( "UINT16", 1 );
-	if( sizeof( INT32 ) != 4 ) Panic( "INT32", 1 );
 	if( sizeof( UINT32 ) != 4 ) Panic( "UINT32", 1 );
 
 #ifdef PROTOTYPES
@@ -54,8 +51,8 @@ main( VOID )
 } /* portab_check_types */
 
 
-LOCAL VOID
-Panic( CHAR *Reason, INT Code )
+LOCAL void
+Panic( char *Reason, int Code )
 {
 	/* Oops, something failed!? */
 	fprintf( stderr, "Oops, test for %s failed!?", Reason );
diff --git a/src/portab/strlcpy.c b/src/portab/strlcpy.c
index 5e2c7222..ee93d1d6 100644
--- a/src/portab/strlcpy.c
+++ b/src/portab/strlcpy.c
@@ -19,7 +19,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: strlcpy.c,v 1.4 2005/02/27 09:29:13 alex Exp $";
+static char UNUSED id[] = "$Id: strlcpy.c,v 1.5 2005/03/19 18:43:50 fw Exp $";
 
 #include "imp.h"
 #include <string.h>
@@ -31,7 +31,7 @@ static char UNUSED id[] = "$Id: strlcpy.c,v 1.4 2005/02/27 09:29:13 alex Exp $";
 #ifndef HAVE_STRLCAT
 
 GLOBAL size_t
-strlcat( CHAR *dst, CONST CHAR *src, size_t size )
+strlcat( char *dst, const char *src, size_t size )
 {
 	/* Like strncat() but does not 0 fill the buffer and
 	 * always null terminates. */
@@ -55,7 +55,7 @@ strlcat( CHAR *dst, CONST CHAR *src, size_t size )
 #ifndef HAVE_STRLCPY
 
 GLOBAL size_t
-strlcpy( CHAR *dst, CONST CHAR *src, size_t size )
+strlcpy( char *dst, const char *src, size_t size )
 {
 	/* Like strncpy but does not 0 fill the buffer and
 	 * always null terminates. */