cu
util.h File Reference

Contains various helper functions. More...

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

Go to the source code of this file.

Macros

#define memmove(D, S, N)
 wraper for memmove More...
 
#define calloc(NM, S)
 wrapper for calloc More...
 
#define malloc(S)
 wrapper for malloc More...
 

Enumerations

enum  log {
  ALL, INFO, WARNING, ERROR,
  FATAL
}
 Levels of Logging.
 

Functions

void cu_log_target (FILE *fd)
 Set the logging target. More...
 
void cu_log_level (enum log level)
 Set the logging Level. More...
 
void cu_log (enum log level, const char *msg)
 Print a log to target. More...
 
void cu_init (void(*delfn)())
 initializing function for cu internals More...
 

Detailed Description

Contains various helper functions.

Macro Definition Documentation

#define calloc (   NM,
 
)
Value:
({ \
void *ptr = calloc(NM, S); \
if (ptr == NULL) { \
perror("calloc"); \
exit(EXIT_FAILURE); \
} \
ptr; \
})
#define calloc(NM, S)
wrapper for calloc
Definition: util.h:31

wrapper for calloc

Parameters
NMobject count
Ssize
Returns
pointer to allocated memory
#define malloc (   S)
Value:
( \
{calloc(1, S); } \
)
#define calloc(NM, S)
wrapper for calloc
Definition: util.h:31

wrapper for malloc

Parameters
Ssize
Returns
pointer to allocated memory
#define memmove (   D,
  S,
 
)
Value:
void *err = memmove(D, S, N); \
if (err != D) { \
perror("memmove"); \
exit(EXIT_FAILURE); \
}
#define memmove(D, S, N)
wraper for memmove
Definition: util.h:19

wraper for memmove

Parameters
Ddestination
Ssource
Nsize

Function Documentation

void cu_init ( void(*)()  delfn)

initializing function for cu internals

Parameters
delfnfunction which shall be called by atexit()
void cu_log ( enum log  level,
const char *  msg 
)

Print a log to target.

Parameters
levelLevel of the Message
msgMessage to print
void cu_log_level ( enum log  level)

Set the logging Level.

Parameters
levelDesired logging level
void cu_log_target ( FILE *  fd)

Set the logging target.

Parameters
fdTarget File Descriptor