1 #ifndef _PROJENT_UTIL_H
   2 #define _PROJENT_UTIL_H
   3 
   4 #include <sys/types.h>
   5 #include <regex.h>
   6 #include <sys/varargs.h>
   7 
   8 #include "lst.h"
   9 
  10 #ifdef  __cplusplus
  11 extern "C" {
  12 #endif
  13 
  14 /* UTIL_STR_APPEND */
  15 #define UTIL_STR_APPEND1(S, S1)         util_str_append((S), 1, (S1))
  16 #define UTIL_STR_APPEND2(S, S1, S2)     util_str_append((S), 2, (S1), (S2))
  17 
  18 /* UTIL_FREE_SNULL */
  19 #define UTIL_FREE_SNULL(ptr) {  \
  20         free(ptr);              \
  21         ptr = NULL;             \
  22 }
  23 
  24 #define UNKWN_SCALE     0
  25 #define BYTES_SCALE     1
  26 #define SCNDS_SCALE     2
  27 #define COUNT_SCALE     3
  28 
  29 
  30 extern char *util_safe_strdup(char *);
  31 extern void *util_safe_realloc(void*, size_t);
  32 extern void *util_safe_malloc(size_t);
  33 extern void *util_safe_zmalloc(size_t);
  34 extern char **util_tokenize(char *, lst_t *);
  35 extern void util_free_tokens(char **);
  36 extern char *util_substr(regex_t *, regmatch_t *, char *, int);
  37 extern char *util_str_append(char *, int, ...);
  38 extern int util_val2num(char *, int, lst_t *, char **, char **, char **);
  39 extern void util_add_errmsg(lst_t *, char *format, ...);
  40 extern void util_print_errmsgs(lst_t *);
  41 
  42 #ifdef  __cplusplus
  43 }
  44 #endif
  45 #endif /* _PROJENT_UTIL_H */