Mercurial > hg > nnchat
diff th_util.c @ 81:69aed051f84d
Synced th-libs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 20 Apr 2009 22:02:37 +0300 |
parents | dd59868059d5 |
children | 0313fabd8049 |
line wrap: on
line diff
--- a/th_util.c Fri Jan 30 01:54:51 2009 +0200 +++ b/th_util.c Mon Apr 20 22:02:37 2009 +0300 @@ -13,35 +13,35 @@ /* Default settings */ -static BOOL th_initialized = FALSE; -int th_verbosityLevel = 2; -char *th_prog_name = NULL, - *th_prog_fullname = NULL, - *th_prog_version = NULL, - *th_prog_author = NULL, - *th_prog_license = NULL; +static BOOL th_initialized = FALSE; +int th_verbosityLevel = 2; +char *th_prog_name = NULL, + *th_prog_fullname = NULL, + *th_prog_version = NULL, + *th_prog_author = NULL, + *th_prog_license = NULL; /* Initialize th_util-library and global variables */ void th_init(char *progName, char *progFullName, char *progVersion, - char *progAuthor, char *progLicense) + char *progAuthor, char *progLicense) { - th_prog_name = progName; - th_prog_fullname = progFullName; - th_prog_version = progVersion; + th_prog_name = progName; + th_prog_fullname = progFullName; + th_prog_version = progVersion; - if (progAuthor) - th_prog_author = progAuthor; - else - th_prog_author = TH_PROG_AUTHOR; + if (progAuthor) + th_prog_author = progAuthor; + else + th_prog_author = TH_PROG_AUTHOR; - if (progLicense) - th_prog_license = progLicense; - else - th_prog_license = TH_PROG_LICENSE; + if (progLicense) + th_prog_license = progLicense; + else + th_prog_license = TH_PROG_LICENSE; - th_initialized = TRUE; + th_initialized = TRUE; } @@ -50,42 +50,42 @@ */ void THERR(const char *pcFormat, ...) { - va_list ap; - assert(th_initialized); + va_list ap; + assert(th_initialized); - va_start(ap, pcFormat); - fprintf(stderr, "%s: ", th_prog_name); - vfprintf(stderr, pcFormat, ap); - va_end(ap); + va_start(ap, pcFormat); + fprintf(stderr, "%s: ", th_prog_name); + vfprintf(stderr, pcFormat, ap); + va_end(ap); } void THMSG(int verbLevel, const char *pcFormat, ...) { - va_list ap; - assert(th_initialized); + va_list ap; + assert(th_initialized); - /* Check if the current verbosity level is enough */ - if (th_verbosityLevel >= verbLevel) { - va_start(ap, pcFormat); - fprintf(stderr, "%s: ", th_prog_name); - vfprintf(stderr, pcFormat, ap); - va_end(ap); - } + /* Check if the current verbosity level is enough */ + if (th_verbosityLevel >= verbLevel) { + va_start(ap, pcFormat); + fprintf(stderr, "%s: ", th_prog_name); + vfprintf(stderr, pcFormat, ap); + va_end(ap); + } } void THPRINT(int verbLevel, const char *pcFormat, ...) { - va_list ap; - assert(th_initialized); + va_list ap; + assert(th_initialized); - /* Check if the current verbosity level is enough */ - if (th_verbosityLevel >= verbLevel) { - va_start(ap, pcFormat); - vfprintf(stderr, pcFormat, ap); - va_end(ap); - } + /* Check if the current verbosity level is enough */ + if (th_verbosityLevel >= verbLevel) { + va_start(ap, pcFormat); + vfprintf(stderr, pcFormat, ap); + va_end(ap); + } } @@ -93,39 +93,39 @@ */ void *th_malloc(size_t l) { - return malloc(l); + return malloc(l); } void *th_calloc(size_t n, size_t l) { - return calloc(n, l); + return calloc(n, l); } void *th_realloc(void *p, size_t l) { - return realloc(p, l); + return realloc(p, l); } void th_free(void *p) { - /* Check for NULL pointers for portability due to some libc - * implementations not handling free(NULL) too well. - */ - if (p) free(p); + /* Check for NULL pointers for portability due to some libc + * implementations not handling free(NULL) too well. + */ + if (p) free(p); } #ifndef HAVE_MEMSET void *th_memset(void *p, int c, size_t n) { - unsigned char *dp = (unsigned char *) p; - - while (n--) - *(dp++) = c; + unsigned char *dp = (unsigned char *) p; + + while (n--) + *(dp++) = c; - return p; + return p; } #endif