Mercurial > hg > nnchat
view th_util.h @ 33:e49ea6febfeb
Cleanups. Added option to specify/fake "site" where logging in from.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 05 Aug 2008 08:42:57 +0300 |
parents | 323c98360d8b |
children | 8749f6517491 |
line wrap: on
line source
/* * Generic utility-functions, macros and defaults * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2002-2008 Tecnic Software productions (TNSP) * * Please read file 'COPYING' for information on license and distribution. */ #ifndef _TH_UTIL_H #define _TH_UTIL_H #ifdef __cplusplus extern "C" { #endif #include "th_types.h" #include <stdarg.h> #include <stdlib.h> #ifndef HAVE_NO_ASSERT #include <assert.h> #endif #ifdef HAVE_STRING_H #include <string.h> #define HAVE_MEMSET 1 #else #ifdef HAVE_STRINGS_H #include <strings.h> #endif #endif #ifdef HAVE_MEMORY_H #include <memory.h> #endif #ifdef TH_NO_DEFAULTS #define TH_PROG_AUTHOR NULL #define TH_PROG_LICENSE NULL #else #define TH_PROG_AUTHOR "By Matti 'ccr' Hämäläinen (C) Copyright 2008 TNSP" #define TH_PROG_LICENSE "This software is licensed under GNU GPL version 2" #endif /* Replacement for assert() */ #ifdef HAVE_NO_ASSERT # ifdef NDEBUG # define assert(NEXPR) /* stub */ # else # define assert(NEXPR) do { if (!(NEXPR)) { fprintf(stderr, "[%s:%d] assert(" # NEXPR ") failed!\n", __FILE__, __LINE__); abort(); } } while (0) # endif #endif /* Global variables */ extern int th_verbosityLevel; extern char *th_prog_name, *th_prog_fullname, *th_prog_version, *th_prog_author, *th_prog_license; /* Functions */ void th_init(char *progName, char *progFullName, char *progVersion, char *progAuthor, char *progLicense); void THERR(const char *, ...); void THMSG(int, const char *, ...); void THPRINT(int, const char *, ...); void * th_malloc(size_t); void * th_calloc(size_t, size_t); void * th_realloc(void *, size_t); void th_free(void *); #ifdef HAVE_MEMSET #define th_memset memset #else void *th_memset(void *, int, size_t); #endif #ifdef __cplusplus } #endif #endif /* _TH_UTIL_H */