iceWing
|
#include <sys/types.h>
#include <limits.h>
#include <glib.h>
Go to the source code of this file.
Macros | |
#define | ICEWING_NAME_D "iceWing" |
#define | IW_TIME_MESSURE |
#define | __FUNCTION__ __FILE__ |
#define | FALSE 0 |
#define | TRUE 1 |
#define | false FALSE |
#define | true TRUE |
#define | PATH_MAX 256 |
#define | IW_TIME_DIFF(t1, t2) |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
#define | CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) |
#define | G_PI 3.14159265358979323846 |
#define | G_PI_2 1.57079632679489661923 |
#define | G_PI_4 0.78539816339744830962 |
#define | G_GINT64_FORMAT "li" |
#define | GINT64_PRINTTYPE long |
#define | IW_ARG_NO_NUMBER ((void*)G_MININT) |
#define | iw_error_1(a1) iw_error_x (__FUNCTION__,__LINE__,a1) |
#define | iw_error_2(a1, a2) iw_error_x (__FUNCTION__,__LINE__,a1,a2) |
#define | iw_error_3(a1, a2, a3) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3) |
#define | iw_error_4(a1, a2, a3, a4) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4) |
#define | iw_error_5(a1, a2, a3, a4, a5) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5) |
#define | iw_error_6(a1, a2, a3, a4, a5, a6) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6) |
#define | iw_warning_1(a1) iw_warning_x (__FUNCTION__,__LINE__,a1) |
#define | iw_warning_2(a1, a2) iw_warning_x (__FUNCTION__,__LINE__,a1,a2) |
#define | iw_warning_3(a1, a2, a3) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3) |
#define | iw_warning_4(a1, a2, a3, a4) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4) |
#define | iw_warning_5(a1, a2, a3, a4, a5) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5) |
#define | iw_warning_6(a1, a2, a3, a4, a5, a6) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6) |
#define | iw_debug_1(t, a1) |
#define | iw_debug_2(t, a1, a2) |
#define | iw_debug_3(t, a1, a2, a3) |
#define | iw_debug_4(t, a1, a2, a3, a4) |
#define | iw_debug_5(t, a1, a2, a3, a4, a5) |
#define | iw_debug_6(t, a1, a2, a3, a4, a5, a6) |
#define | iw_debug_7(t, a1, a2, a3, a4, a5, a6, a7) |
#define | iw_debug_8(t, a1, a2, a3, a4, a5, a6, a7, a8) |
#define | iw_debug_9(t, a1, a2, a3, a4, a5, a6, a7, a8, a9) |
#define | iw_debug_10(t, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) |
#define | iw_assert_1(ex, a1) |
#define | iw_assert_2(ex, a1, a2) |
#define | iw_assert_3(ex, a1, a2, a3) |
#define | iw_assert_4(ex, a1, a2, a3, a4) |
#define | iw_assert_5(ex, a1, a2, a3, a4, a5) |
#define | iw_time_add_static(number, name) |
#define | iw_time_add_static2(number, name, number2, name2) |
#define | iw_time_add_static3(number, name, number2, name2, number3, name3) |
Typedefs | |
typedef int | BOOL |
Functions | |
void | iw_error (const char *str,...) |
void | iw_warning (const char *str,...) |
void | iw_error_errno (const char *str,...) |
void | iw_warning_errno (const char *str,...) |
void * | iw_malloc (size_t size, const char *err) |
void * | iw_malloc0 (size_t size, const char *err) |
void * | iw_realloc (void *ptr, size_t size, const char *err) |
void * | iw_malloc_align (size_t size, const char *err) |
void | iw_free_align (void *ptr) |
void | iw_string_split (char *str, int *array_len, char ***array) |
char | iw_parse_args (int argc, char **argv, int *nr, void **arg, const char *pattern) |
BOOL | iw_load_args (char *args, int argc, char **argv, int *nargc, char ***nargv) |
void | iw_usleep (unsigned long usec) |
void | iw_showtid (int level, const char *str) |
int | iw_time_add (const char *name) |
void | iw_time_set_enabled (BOOL enabled) |
void | iw_time_init (int nr) |
void | iw_time_init_all (void) |
void | iw_time_start (int nr) |
long | iw_time_stop (int nr, BOOL show) |
void | iw_time_show (void) |
void | iw_error_x (const char *proc, int line, const char *str,...) G_GNUC_PRINTF(3 |
void void | iw_warning_x (const char *proc, int line, const char *str,...) G_GNUC_PRINTF(3 |
void void void | iw_error_errno_x (const char *proc, int line, const char *str,...) G_GNUC_PRINTF(3 |
void void void void | iw_warning_errno_x (const char *proc, int line, const char *str,...) G_GNUC_PRINTF(3 |
void void void void void | iw_debug_set_level (int level) |
Variables | |
char * | ICEWING_NAME |
char * | ICEWING_VERSION |
#define ICEWING_NAME_D "iceWing" |
#define IW_TIME_MESSURE |
Should the time measurement be performed ?
#define __FUNCTION__ __FILE__ |
#define FALSE 0 |
#define TRUE 1 |
#define false FALSE |
#define true TRUE |
#define PATH_MAX 256 |
#define IW_TIME_DIFF | ( | t1, | |
t2 | |||
) |
Return the difference in ms between the timeval's t1 and t2
#define MIN | ( | a, | |
b | |||
) | ((a) < (b) ? (a) : (b)) |
#define MAX | ( | a, | |
b | |||
) | ((a) > (b) ? (a) : (b)) |
#define CLAMP | ( | x, | |
low, | |||
high | |||
) | (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) |
#define G_PI 3.14159265358979323846 |
Somehow in the wrong file ...
#define G_PI_2 1.57079632679489661923 |
#define G_PI_4 0.78539816339744830962 |
#define G_GINT64_FORMAT "li" |
#define GINT64_PRINTTYPE long |
#define IW_ARG_NO_NUMBER ((void*)G_MININT) |
Indicator for "no number given" for optional options in parse_args()
#define iw_error_1 | ( | a1 | ) | iw_error_x (__FUNCTION__,__LINE__,a1) |
#define iw_error_2 | ( | a1, | |
a2 | |||
) | iw_error_x (__FUNCTION__,__LINE__,a1,a2) |
#define iw_error_3 | ( | a1, | |
a2, | |||
a3 | |||
) | iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3) |
#define iw_error_4 | ( | a1, | |
a2, | |||
a3, | |||
a4 | |||
) | iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4) |
#define iw_error_5 | ( | a1, | |
a2, | |||
a3, | |||
a4, | |||
a5 | |||
) | iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5) |
#define iw_error_6 | ( | a1, | |
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6 | |||
) | iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6) |
#define iw_warning_1 | ( | a1 | ) | iw_warning_x (__FUNCTION__,__LINE__,a1) |
#define iw_warning_2 | ( | a1, | |
a2 | |||
) | iw_warning_x (__FUNCTION__,__LINE__,a1,a2) |
#define iw_warning_3 | ( | a1, | |
a2, | |||
a3 | |||
) | iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3) |
#define iw_warning_4 | ( | a1, | |
a2, | |||
a3, | |||
a4 | |||
) | iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4) |
#define iw_warning_5 | ( | a1, | |
a2, | |||
a3, | |||
a4, | |||
a5 | |||
) | iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5) |
#define iw_warning_6 | ( | a1, | |
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6 | |||
) | iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6) |
#define iw_debug_1 | ( | t, | |
a1 | |||
) |
#define iw_debug_2 | ( | t, | |
a1, | |||
a2 | |||
) |
#define iw_debug_3 | ( | t, | |
a1, | |||
a2, | |||
a3 | |||
) |
#define iw_debug_4 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4 | |||
) |
#define iw_debug_5 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5 | |||
) |
#define iw_debug_6 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6 | |||
) |
#define iw_debug_7 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6, | |||
a7 | |||
) |
#define iw_debug_8 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6, | |||
a7, | |||
a8 | |||
) |
#define iw_debug_9 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6, | |||
a7, | |||
a8, | |||
a9 | |||
) |
#define iw_debug_10 | ( | t, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5, | |||
a6, | |||
a7, | |||
a8, | |||
a9, | |||
a10 | |||
) |
#define iw_assert_1 | ( | ex, | |
a1 | |||
) |
#define iw_assert_2 | ( | ex, | |
a1, | |||
a2 | |||
) |
#define iw_assert_3 | ( | ex, | |
a1, | |||
a2, | |||
a3 | |||
) |
#define iw_assert_4 | ( | ex, | |
a1, | |||
a2, | |||
a3, | |||
a4 | |||
) |
#define iw_assert_5 | ( | ex, | |
a1, | |||
a2, | |||
a3, | |||
a4, | |||
a5 | |||
) |
#define iw_time_add_static | ( | number, | |
name | |||
) |
#define iw_time_add_static2 | ( | number, | |
name, | |||
number2, | |||
name2 | |||
) |
#define iw_time_add_static3 | ( | number, | |
name, | |||
number2, | |||
name2, | |||
number3, | |||
name3 | |||
) |
typedef int BOOL |
void iw_error | ( | const char * | str, |
... | |||
) |
void iw_warning | ( | const char * | str, |
... | |||
) |
void iw_error_errno | ( | const char * | str, |
... | |||
) |
void iw_warning_errno | ( | const char * | str, |
... | |||
) |
void* iw_malloc | ( | size_t | size, |
const char * | err | ||
) |
Call malloc() / calloc() / realloc().
If err!=NULL and memory could not be allocated, exit with
'out of memory: "err"' by calling iw_error().
void* iw_malloc0 | ( | size_t | size, |
const char * | err | ||
) |
void* iw_realloc | ( | void * | ptr, |
size_t | size, | ||
const char * | err | ||
) |
void* iw_malloc_align | ( | size_t | size, |
const char * | err | ||
) |
Allocate 16 byte aligned memory. Must be freed with iw_free_align().
If err!=NULL and memory could not be allocated, exit with
'out of memory: "err"' by calling iw_error().
void iw_free_align | ( | void * | ptr | ) |
void iw_string_split | ( | char * | str, |
int * | array_len, | ||
char *** | array | ||
) |
Return in 'array' a NULL terminated array of strings pointing to
the parts of 'str', which are separated by spaces. In 'str' '\0'
are inserted. In 'array_len' the number of entries in 'array' is
returned.
char iw_parse_args | ( | int | argc, |
char ** | argv, | ||
int * | nr, | ||
void ** | arg, | ||
const char * | pattern | ||
) |
Checks if argv[nr] can be found in pattern, the check is case
insensitive. Increment nr afterwards. Format of pattern in EBNF:
{ "-" token ":" ch ["r"|"ro"|"i"|"io"|"f"|"fo"|"c"] " " }
token: string without " " and without ":"
ch : Any character, given back if -token is found
"r" : Argument is required -> returned in *arg
"i" : Int argument is required -> returned in *arg
"f" : Float argument is required -> returned in *arg
"c" : Token can be continued in any way -> returned in *arg
"o" : Argument is optional
Example: "-i:Ii -s:Sr -h:H -help:H --help:H"
On error, print an error message on stderr and return '\0'.
BOOL iw_load_args | ( | char * | args, |
int | argc, | ||
char ** | argv, | ||
int * | nargc, | ||
char *** | nargv | ||
) |
PRIVATE: If args, split args, otherwise use argv. Check for any
'@file', load the file, exchange '@file' with the args from the
file, and expand any vars, commands, and wildcards. nargv is newly
allocated.
void iw_usleep | ( | unsigned long | usec | ) |
Wrapper for usleep() for enhanced portability (the OSF alpha
version is really strange).
void iw_showtid | ( | int | level, |
const char * | str | ||
) |
On linux: Show the thread ID as a debug output via gettid().
int iw_time_add | ( | const char * | name | ) |
Add a new timer and return its number (must be passed to the other
time_...() functions). 'name' describes the new timer.
void iw_time_set_enabled | ( | BOOL | enabled | ) |
Enable/Disable time_start(), time_stop(), and time_show().
void iw_time_init | ( | int | nr | ) |
Reset time measurement number nr (-> set mean value, count to 0).
void iw_time_init_all | ( | void | ) |
Reset all timer, i.e. call iw_time_init() for all added timers.
void iw_time_start | ( | int | nr | ) |
Start the timer nr (which was added before with iw_time_add()).
long iw_time_stop | ( | int | nr, |
BOOL | show | ||
) |
Stop the timer number nr.
show==TRUE: Print time and average time for number nr on stdout.
Return the elapsed real time in ms.
void iw_time_show | ( | void | ) |
Print average time for all registered timers on stdout, for which
at least one time time_stop() was called.
void iw_error_x | ( | const char * | proc, |
int | line, | ||
const char * | str, | ||
... | |||
) |
Output passed arguments (including a short header) on stderr and
terminate the program.
void void iw_warning_x | ( | const char * | proc, |
int | line, | ||
const char * | str, | ||
... | |||
) |
Output passed arguments (including a short header) on stderr.
void void void iw_error_errno_x | ( | const char * | proc, |
int | line, | ||
const char * | str, | ||
... | |||
) |
Output passed arguments (including a short header) on stderr,
append ': 'strerror(errno) and terminate the program.
void void void void iw_warning_errno_x | ( | const char * | proc, |
int | line, | ||
const char * | str, | ||
... | |||
) |
Output passed arguments (including a short header) on stderr and
append ': 'strerror(errno).
void void void void void iw_debug_set_level | ( | int | level | ) |
Initialize the talklevel for following debug() calls. Debug
messages are only given out if there level < talklevel.
char* ICEWING_NAME |
== "iceWing"
char* ICEWING_VERSION |
iceWing version string