X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=include%2Fmisc.h;h=24b3d900ba37284588d93f21ec337ef16e1c6c28;hp=5581450c4038b26ef6d6a631a13f38bb40fdafe3;hb=adf99a601d58f213370cef8cd0e5bd9a0f92dc74;hpb=2a6284cf1a380b55f3ad2bf71a63946e2595b812 diff --git a/include/misc.h b/include/misc.h index 5581450..24b3d90 100644 --- a/include/misc.h +++ b/include/misc.h @@ -13,16 +13,18 @@ Header file for miscellaneous defines, typedefs etc. $Log$ - Revision 1.1.1.1.6.1 2001/11/25 23:04:51 short - * new common/misc.c/ - * g{,v}asprintf() - "asprintf()" compatibility emulation - * ARRAY_LEN() - sizeof(x)/sizeof(*x) - * SAFE_STRNCPY{,_SIZEOF}() - strncpy with variable-size autodetection - * G_GNUC_PRINTF - GCC attribute from glib - * N_(x) - missing in localization macros + Revision 1.1.1.1.6.2 2001/11/27 21:18:41 short + Update: orig2001_11_25_22_56 -> orig2001_11_27_05_17 + Branch merged, dead - Revision 1.1.1.1 2001/11/25 21:59:21 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.1.2.1 2001/11/27 04:37:59 short + Update: orig2001_11_25_22_56 -> orig2001_11_27_05_17 + + Revision 1.1.1.2 2001/11/27 04:19:40 short + :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 05:17 CET 2001 + + Revision 1.27 2001/11/26 18:06:08 pkot + Checking for *printf functions, N_(x) for localization, generic ARRAY_LEN, SAFE_STRNCPY, G_GNUC_PRINTF (Jan Kratochvil) Revision 1.26 2001/11/14 10:46:12 pkot Small cleanup with __unices__ @@ -45,34 +47,34 @@ /* Some general defines. */ #ifndef false - #define false (0) +# define false (0) #endif #ifndef true - #define true (!false) +# define true (!false) #endif #ifndef bool - #define bool int +# define bool int #endif -#define ARRAY_LEN(x) (sizeof((x))/sizeof((x)[0])) +#define ARRAY_LEN(x) (sizeof((x)) / sizeof((x)[0])) -#define SAFE_STRNCPY(dest,src,n) do { \ - strncpy((dest),(src),(n)); \ - if ((n)>0) \ - (dest)[(n)-1]='\0'; \ +#define SAFE_STRNCPY(dest, src, n) do { \ + strncpy((dest), (src), (n)); \ + if ((n) > 0) \ + (dest)[(n)-1] = '\0'; \ } while (0) #define SAFE_STRNCPY_SIZEOF(dest,src) \ - SAFE_STRNCPY((dest),(src),sizeof((dest))) + SAFE_STRNCPY((dest), (src), sizeof((dest))) /* Stolen from : */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -#define G_GNUC_PRINTF( format_idx, arg_idx ) \ - __attribute__((format (printf, format_idx, arg_idx))) +# define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((format (printf, format_idx, arg_idx))) #else /* !__GNUC__ */ -#define G_GNUC_PRINTF( format_idx, arg_idx ) +# define G_GNUC_PRINTF( format_idx, arg_idx ) #endif /* !__GNUC__ */ #define GNOKII_MAX(a, b) (((a) > (b)) ? (a) : (b)) @@ -80,122 +82,122 @@ /* A define to make debug printfs neat */ #ifndef DEBUG -#define dprintf(a...) do { } while (0) +# define dprintf(a...) do { } while (0) #else -#define dprintf(a...) do { fprintf(stderr, a); fflush(stderr); } while (0) +# define dprintf(a...) do { fprintf(stderr, a); fflush(stderr); } while (0) #endif /* Use gsprintf instead of sprintf and sprintf */ #ifdef HAVE_SNPRINTF -# define gsprintf(a, b, c...) snprintf(a, b, c) +# define gsprintf(a, b, c...) snprintf(a, b, c) #else -# define gsprintf(a, b, c...) sprintf(a, c) +# define gsprintf(a, b, c...) sprintf(a, c) #endif #ifdef HAVE_VSNPRINTF -# define gvsprintf(a, b, c...) vsnprintf(a, b, c) +# define gvsprintf(a, b, c...) vsnprintf(a, b, c) #else -# define gvsprintf(a, b, c...) vsprintf(a, c) +# define gvsprintf(a, b, c...) vsprintf(a, c) #endif #ifdef HAVE_ASPRINTF -# define gasprintf(a...) asprintf(a) +# define gasprintf(a...) asprintf(a) #else #include -extern int gasprintf(char **destp,const char *fmt,...); +extern int gasprintf(char **destp, const char *fmt,...); #endif #ifdef HAVE_VASPRINTF -# define gvasprintf(a...) vasprintf(a) +# define gvasprintf(a...) vasprintf(a) #else #include -extern int gvasprintf(char **destp,const char *fmt,va_list ap); +extern int gvasprintf(char **destp, const char *fmt, va_list ap); #endif /* Get rid of long defines. Use #if __unices__ */ #define __unices__ defined(__svr4__) || defined(__FreeBSD__) || defined(__bsdi__) #if __unices__ -# include -# include +# include +# include #endif /* This one is for NLS. */ #ifdef USE_NLS - #include - #define _(x) gettext(x) +# include +# define _(x) gettext(x) +# define N_(x) gettext_noop(x) #else - #define _(x) (x) +# define _(x) (x) +# define N_(x) (x) #endif /* USE_NLS */ -#define N_(x) (x) /* Definitions for u8, u16, u32 and u64, borrowed from /usr/src/linux/include/asm-i38/types.h */ #ifndef u8 - typedef unsigned char u8; + typedef unsigned char u8; #endif #ifndef u16 - typedef unsigned short u16; + typedef unsigned short u16; #endif #ifndef u32 - typedef unsigned int u32; + typedef unsigned int u32; #endif #ifndef s32 - typedef int s32; + typedef int s32; #endif #if defined(__GNUC__) && !defined(__STRICT_ANSI__) - #ifndef u64 - typedef unsigned long long u64; - #endif +# ifndef u64 + typedef unsigned long long u64; +# endif - #ifndef s64 - typedef signed long long s64; - #endif +# ifndef s64 + typedef signed long long s64; +# endif #endif /* This one is for FreeBSD and similar systems without __ptr_t_ */ /* FIXME: autoconf should take care of this. */ - #ifndef __ptr_t - typedef void * __ptr_t; + typedef void * __ptr_t; #endif /* __ptr_t */ /* Add here any timer operations which are not supported by libc5 */ #ifndef HAVE_TIMEOPS -#ifdef WIN32 - -#include -#include -#define timersub(a, b, result) - do { - (result)->tv_sec = (a)->time - (b)->time; - (result)->tv_usec = ((a)->millitm - (b)->millitm) * 1000; - if ((result)->tv_usec < 0) { - --(result)->tv_sec; - (result)->tv_usec += 1000000; - } - } while (0) -#define gettimeofday(a, b) _ftime(a) - -#else -#include - -#ifndef timersub -#define timersub(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ - } while (0) -#endif +# ifdef WIN32 + +# include +# include +# define timersub(a, b, result) + do { + (result)->tv_sec = (a)->time - (b)->time; + (result)->tv_usec = ((a)->millitm - (b)->millitm) * 1000; + if ((result)->tv_usec < 0) { + --(result)->tv_sec; + (result)->tv_usec += 1000000; + } + } while (0) +# define gettimeofday(a, b) _ftime(a) + +# else /* !WIN32 */ +# include + +# ifndef timersub +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +# endif /* timersub */ -#endif /* WIN32 */ +# endif /* WIN32 */ #endif /* HAVE_TIMEOPS */ @@ -204,9 +206,9 @@ extern int GetLine(FILE *File, char *Line, int count); /* For models table */ typedef struct { - char *model; - char *number; - int flags; + char *model; + char *number; + int flags; } PhoneModel; #define PM_CALLERGROUP 0x0001