Mercurial > hg > nnchat
comparison th_util.h @ 0:728243125263
Import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 20 Mar 2008 00:15:03 +0000 |
parents | |
children | 323c98360d8b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:728243125263 |
---|---|
1 /* | |
2 * Generic utility-functions, macros and defaults | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2002-2008 Tecnic Software productions (TNSP) | |
5 * | |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
8 #ifndef _TH_UTIL_H | |
9 #define _TH_UTIL_H | |
10 | |
11 #ifdef __cplusplus | |
12 extern "C" { | |
13 #endif | |
14 | |
15 #include "th_types.h" | |
16 #include <stdarg.h> | |
17 #include <stdlib.h> | |
18 #ifndef HAVE_NO_ASSERT | |
19 #include <assert.h> | |
20 #endif | |
21 | |
22 #ifdef HAVE_STRING_H | |
23 #include <string.h> | |
24 #define HAVE_MEMSET 1 | |
25 #else | |
26 #ifdef HAVE_STRINGS_H | |
27 #include <strings.h> | |
28 #endif | |
29 #endif | |
30 | |
31 #ifdef HAVE_MEMORY_H | |
32 #include <memory.h> | |
33 #endif | |
34 | |
35 | |
36 /* Replacement for assert() */ | |
37 #ifdef HAVE_NO_ASSERT | |
38 # ifdef NDEBUG | |
39 # define assert(NEXPR) /* stub */ | |
40 # else | |
41 # define assert(NEXPR) do { if (!(NEXPR)) { fprintf(stderr, "[%s:%d] assert(" # NEXPR ") failed!\n", __FILE__, __LINE__); abort(); } } while (0) | |
42 # endif | |
43 #endif | |
44 | |
45 /* Global variables | |
46 */ | |
47 extern int th_verbosityLevel; | |
48 extern char *th_prog_name, | |
49 *th_prog_fullname, | |
50 *th_prog_version, | |
51 *th_prog_author, | |
52 *th_prog_license; | |
53 | |
54 /* Functions | |
55 */ | |
56 void th_init(char *progName, char *progFullName, char *progVersion, | |
57 char *progAuthor, char *progLicense); | |
58 void THERR(const char *, ...); | |
59 void THMSG(int, const char *, ...); | |
60 void THPRINT(int, const char *, ...); | |
61 | |
62 void * th_malloc(size_t); | |
63 void * th_calloc(size_t, size_t); | |
64 void * th_realloc(void *, size_t); | |
65 void th_free(void *); | |
66 | |
67 #ifdef HAVE_MEMSET | |
68 #define th_memset memset | |
69 #else | |
70 void *th_memset(void *, int, size_t); | |
71 #endif | |
72 | |
73 #ifdef __cplusplus | |
74 } | |
75 #endif | |
76 #endif /* _TH_UTIL_H */ |