LibDap
This library contains the basic modules that are used in the products of the family DAP
Macros | Enumerations | Functions
dap_common.h File Reference
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>

Go to the source code of this file.

Macros

#define DAP_NEW(a)   ( (a*) malloc(sizeof(a)))
 
#define DAP_NEW_SIZE(a, b)   ( (a*) malloc(b))
 
#define DAP_NEW_Z(a)   ( (a*) calloc(1,sizeof(a)))
 
#define DAP_NEW_Z_SIZE(a, b)   ( (a*) calloc(1,b))
 
#define DAP_DELETE(a)   free(a)
 
#define DAP_DUP(a)   (__typeof(a) ret = memcpy(ret,a,sizeof(*a)) )
 
#define DAP_PROTOCOL_VERSION   21
 
#define log_it(_log_level, ...)   _log_it(LOG_TAG,_log_level,##__VA_ARGS__)
 
#define vlog_it(a_log_level, a_format, a_ap)   _vlog_it(LOG_TAG,a_log_level,a_format,a_ap)
 

Enumerations

enum  log_level {
  L_CRITICAL =5, L_ERROR =4, L_WARNING =3, L_NOTICE =2,
  L_INFO =1, L_DEBUG =0
}
 The log_level enum. More...
 

Functions

int dap_common_init (const char *a_log_file)
 dap_common_init initialise More...
 
void dap_common_deinit (void)
 dap_common_deinit Deinitialise More...
 
void _log_it (const char *log_tag, enum log_level, const char *format,...)
 _log_it Writes information to the log More...
 
void _vlog_it (const char *log_tag, enum log_level, const char *format, va_list ap)
 
const char * log_error (void)
 log_error Error log More...
 
void set_log_level (enum log_level ll)
 set_log_level Sets the logging level More...
 
void dap_set_log_tag_width (size_t width)
 dap_set_log_tag_width Sets the length of the label More...
 
int time_to_rfc822 (char *out, size_t out_size_max, time_t t)
 time_to_rfc822 Convert time_t to string with RFC822 formatted date and time More...
 
int get_select_breaker (void)
 
int send_select_break (void)
 
char * exec_with_ret (const char *a_cmd)
 exec_with_ret Executes a command with result return More...
 
char * exec_with_ret_multistring (const char *a_cmd)
 exec_with_ret_multistring performs a command with a result return in the form of a multistring More...
 
char * dap_random_string_create_alloc (size_t a_length)
 random_string_create Generates a random string More...
 
void dap_random_string_fill (char *str, size_t length)
 random_string_fill Filling a string with random characters More...
 

Macro Definition Documentation

#define DAP_DELETE (   a)    free(a)
#define DAP_DUP (   a)    (__typeof(a) ret = memcpy(ret,a,sizeof(*a)) )
#define DAP_NEW (   a)    ( (a*) malloc(sizeof(a)))
#define DAP_NEW_SIZE (   a,
 
)    ( (a*) malloc(b))
#define DAP_NEW_Z (   a)    ( (a*) calloc(1,sizeof(a)))
#define DAP_NEW_Z_SIZE (   a,
 
)    ( (a*) calloc(1,b))
#define DAP_PROTOCOL_VERSION   21
#define log_it (   _log_level,
  ... 
)    _log_it(LOG_TAG,_log_level,##__VA_ARGS__)
#define vlog_it (   a_log_level,
  a_format,
  a_ap 
)    _vlog_it(LOG_TAG,a_log_level,a_format,a_ap)

Enumeration Type Documentation

enum log_level

The log_level enum.

Enumerator
L_CRITICAL 
L_ERROR 
L_WARNING 
L_NOTICE 
L_INFO 
L_DEBUG 

Function Documentation

void _log_it ( const char *  log_tag,
enum log_level  ll,
const char *  format,
  ... 
)

_log_it Writes information to the log

Parameters
[in]log_tagTag
[in]llLog level
[in]format
void _vlog_it ( const char *  log_tag,
enum  log_level,
const char *  format,
va_list  ap 
)
void dap_common_deinit ( void  )

dap_common_deinit Deinitialise

int dap_common_init ( const char *  a_log_file)

dap_common_init initialise

Parameters
[in]a_log_file
Returns
char* dap_random_string_create_alloc ( size_t  a_length)

random_string_create Generates a random string

Parameters
[in]a_lengthlenght
Returns
a pointer to an array
void dap_random_string_fill ( char *  str,
size_t  length 
)

random_string_fill Filling a string with random characters

Parameters
[out]strA pointer to a char array
[in]lengthThe length of the array or string
void dap_set_log_tag_width ( size_t  width)

dap_set_log_tag_width Sets the length of the label

Parameters
[in]widthLength not more than 99
char* exec_with_ret ( const char *  a_cmd)

exec_with_ret Executes a command with result return

Parameters
[in]a_cmdCommand
Returns
Result
char* exec_with_ret_multistring ( const char *  a_cmd)

exec_with_ret_multistring performs a command with a result return in the form of a multistring

Parameters
[in]a_cmdCoomand
Returns
Return
int get_select_breaker ( void  )
const char* log_error ( void  )

log_error Error log

Returns
int send_select_break ( void  )
void set_log_level ( enum log_level  ll)

set_log_level Sets the logging level

Parameters
[in]lllogging level
int time_to_rfc822 ( char *  out,
size_t  out_size_max,
time_t  t 
)

time_to_rfc822 Convert time_t to string with RFC822 formatted date and time

Parameters
[out]outOutput buffer
[out]out_size_macMaximum size of output buffer
[in]tUNIX time
Returns
Length of resulting string if ok or lesser than zero if not