annotate th_util.h @ 81:69aed051f84d

Synced th-libs.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 20 Apr 2009 22:02:37 +0300
parents 335b5a74c22e
children 0313fabd8049
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Generic utility-functions, macros and defaults
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
80
335b5a74c22e Updatec copyrights to 2009.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
4 * (C) Copyright 2002-2009 Tecnic Software productions (TNSP)
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #ifndef _TH_UTIL_H
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #define _TH_UTIL_H
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #ifdef __cplusplus
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 extern "C" {
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #include "th_types.h"
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 #include <stdarg.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #include <stdlib.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 #ifndef HAVE_NO_ASSERT
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 #include <assert.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 #ifdef HAVE_STRING_H
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 #include <string.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #define HAVE_MEMSET 1
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 #else
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 #ifdef HAVE_STRINGS_H
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #include <strings.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #ifdef HAVE_MEMORY_H
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <memory.h>
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
20
323c98360d8b Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
36 #ifdef TH_NO_DEFAULTS
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
37 #define TH_PROG_AUTHOR NULL
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
38 #define TH_PROG_LICENSE NULL
20
323c98360d8b Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
39 #else
80
335b5a74c22e Updatec copyrights to 2009.
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
40 #define TH_PROG_AUTHOR "By Matti 'ccr' Hämäläinen (C) Copyright 2009 TNSP"
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
41 #define TH_PROG_LICENSE "This software is licensed under GNU GPL version 2"
20
323c98360d8b Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
42 #endif
323c98360d8b Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
43
323c98360d8b Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 /* Replacement for assert() */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 #ifdef HAVE_NO_ASSERT
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 # ifdef NDEBUG
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 # define assert(NEXPR) /* stub */
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 # else
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 # define assert(NEXPR) do { if (!(NEXPR)) { fprintf(stderr, "[%s:%d] assert(" # NEXPR ") failed!\n", __FILE__, __LINE__); abort(); } } while (0)
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 # endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 /* Global variables
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 */
81
69aed051f84d Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
56 extern int th_verbosityLevel;
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
57 extern char *th_prog_name,
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
58 *th_prog_fullname,
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
59 *th_prog_version,
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
60 *th_prog_author,
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
61 *th_prog_license;
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 /* Functions
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 */
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
65 void th_init(char *progName, char *progFullName, char *progVersion,
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
66 char *progAuthor, char *progLicense);
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
67 void THERR(const char *, ...);
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
68 void THMSG(int, const char *, ...);
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
69 void THPRINT(int, const char *, ...);
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
71 void *th_malloc(size_t);
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
72 void *th_calloc(size_t, size_t);
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
73 void *th_realloc(void *, size_t);
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
74 void th_free(void *);
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 #ifdef HAVE_MEMSET
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
77 #define th_memset memset
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 #else
37
8749f6517491 Synced th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
79 void *th_memset(void *, int, size_t);
0
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 #ifdef __cplusplus
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 }
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 #endif
728243125263 Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 #endif /* _TH_UTIL_H */