LibDap
This library contains the basic modules that are used in the products of the family DAP
Macros | Functions | Variables
dap_common.c File Reference
#include <unistd.h>
#include <pthread.h>
#include <syslog.h>
#include <time.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "dap_common.h"

Macros

#define LAST_ERROR_MAX   255
 
#define LOG_TAG   "dap_common"
 
#define INT_DIGITS   19 /* enough for 64 bit integer */
 

Functions

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 dap_common_init (const char *a_log_file)
 dap_common_init initialise More...
 
void dap_common_deinit ()
 dap_common_deinit Deinitialise More...
 
void _log_it (const char *log_tag, enum log_level ll, const char *format,...)
 _log_it Writes information to the log More...
 
void _vlog_it (const char *log_tag, enum log_level ll, const char *format, va_list ap)
 
const char * log_error ()
 log_error Error log More...
 
char * itoa (int i)
 itoa The function converts an integer num to a string equivalent and places the result in a string 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 ()
 
int send_select_break ()
 
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...
 
void dap_random_string_fill (char *str, size_t length)
 random_string_fill Filling a string with random characters More...
 
char * dap_random_string_create_alloc (size_t a_length)
 random_string_create Generates a random string More...
 

Variables

static char last_error [LAST_ERROR_MAX] = {0}
 
static enum log_level log_level = L_DEBUG
 
static FILE * s_log_file = NULL
 
static char log_tag_fmt_str [10]
 
static int breaker_set [2] = { -1, -1 }
 
static int initialized = 0
 
static struct timespec break_latency = {0, 1 * 1000 * 1000 }
 
static const char l_possible_chars [] ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
 

Macro Definition Documentation

#define INT_DIGITS   19 /* enough for 64 bit integer */
#define LAST_ERROR_MAX   255
#define LOG_TAG   "dap_common"

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  ll,
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  )
char* itoa ( int  i)

itoa The function converts an integer num to a string equivalent and places the result in a string

Parameters
[in]inumber
Returns
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

Variable Documentation

struct timespec break_latency = {0, 1 * 1000 * 1000 }
static
int breaker_set[2] = { -1, -1 }
static
int initialized = 0
static
const char l_possible_chars[] ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
static
char last_error[LAST_ERROR_MAX] = {0}
static
enum log_level log_level = L_DEBUG
static
char log_tag_fmt_str[10]
static
FILE* s_log_file = NULL
static