Mercurial > hg > nnchat
annotate th_util.h @ 110:8af4072dc31a
Fix Win32/MinGW/PDcurses issues.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 24 Oct 2010 18:28:22 +0300 |
parents | 0313fabd8049 |
children | 4ec36204d34e |
rev | line source |
---|---|
0 | 1 /* |
2 * Generic utility-functions, macros and defaults | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
80 | 4 * (C) Copyright 2002-2009 Tecnic Software productions (TNSP) |
0 | 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 | |
20 | 36 #ifdef TH_NO_DEFAULTS |
37 | 37 #define TH_PROG_AUTHOR NULL |
38 #define TH_PROG_LICENSE NULL | |
20 | 39 #else |
80 | 40 #define TH_PROG_AUTHOR "By Matti 'ccr' Hämäläinen (C) Copyright 2009 TNSP" |
37 | 41 #define TH_PROG_LICENSE "This software is licensed under GNU GPL version 2" |
20 | 42 #endif |
43 | |
44 | |
0 | 45 /* Replacement for assert() */ |
46 #ifdef HAVE_NO_ASSERT | |
47 # ifdef NDEBUG | |
48 # define assert(NEXPR) /* stub */ | |
49 # else | |
50 # define assert(NEXPR) do { if (!(NEXPR)) { fprintf(stderr, "[%s:%d] assert(" # NEXPR ") failed!\n", __FILE__, __LINE__); abort(); } } while (0) | |
51 # endif | |
52 #endif | |
53 | |
54 /* Global variables | |
55 */ | |
81 | 56 extern int th_verbosityLevel; |
37 | 57 extern char *th_prog_name, |
58 *th_prog_fullname, | |
59 *th_prog_version, | |
60 *th_prog_author, | |
61 *th_prog_license; | |
0 | 62 |
63 /* Functions | |
64 */ | |
37 | 65 void th_init(char *progName, char *progFullName, char *progVersion, |
66 char *progAuthor, char *progLicense); | |
67 void THERR(const char *, ...); | |
68 void THMSG(int, const char *, ...); | |
69 void THPRINT(int, const char *, ...); | |
0 | 70 |
99
0313fabd8049
Added varargs versions of some functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
71 void THERR_V(const char *, va_list); |
0313fabd8049
Added varargs versions of some functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
72 void THMSG_V(int, const char *, va_list); |
0313fabd8049
Added varargs versions of some functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
73 void THPRINT_V(int, const char *, va_list); |
0313fabd8049
Added varargs versions of some functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
74 |
37 | 75 void *th_malloc(size_t); |
76 void *th_calloc(size_t, size_t); | |
77 void *th_realloc(void *, size_t); | |
78 void th_free(void *); | |
0 | 79 |
80 #ifdef HAVE_MEMSET | |
37 | 81 #define th_memset memset |
0 | 82 #else |
37 | 83 void *th_memset(void *, int, size_t); |
0 | 84 #endif |
85 | |
86 #ifdef __cplusplus | |
87 } | |
88 #endif | |
89 #endif /* _TH_UTIL_H */ |