cu
util.h
Go to the documentation of this file.
1 #ifndef CU_UTIL_H_
2 #define CU_UTIL_H_
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <pthread.h>
7 
19 #define memmove(D, S, N) void *err = memmove(D, S, N); \
20  if (err != D) { \
21  perror("memmove"); \
22  exit(EXIT_FAILURE); \
23  }
24 
31 #define calloc(NM, S) ({ \
32  void *ptr = calloc(NM, S); \
33  if (ptr == NULL) { \
34  perror("calloc"); \
35  exit(EXIT_FAILURE); \
36  } \
37  ptr; \
38  })
39 
45 #define malloc(S) ( \
46  {calloc(1, S); } \
47  )
48 
52 enum log {
53  ALL,
54  INFO,
55  WARNING,
56  ERROR,
57  FATAL
58 };
59 
60 
65 extern void cu_log_target(FILE *fd);
66 
67 
72 extern void cu_log_level(enum log level);
73 
74 
80 extern void cu_log(enum log level, const char *msg);
81 
86 extern void cu_init(void (*delfn)());
87 
88 #endif /* CU_UTIL_H_ */
void cu_log(enum log level, const char *msg)
Print a log to target.
void cu_log_target(FILE *fd)
Set the logging target.
void cu_init(void(*delfn)())
initializing function for cu internals
log
Levels of Logging.
Definition: util.h:52
void cu_log_level(enum log level)
Set the logging Level.