42 #define os_time_before(a, b) \
43 ((a)->sec < (b)->sec || \
44 ((a)->sec == (b)->sec && (a)->usec < (b)->usec))
46 #define os_time_sub(a, b, res) do { \
47 (res)->sec = (a)->sec - (b)->sec; \
48 (res)->usec = (a)->usec - (b)->usec; \
49 if ((res)->usec < 0) { \
51 (res)->usec += 1000000; \
70 int os_mktime(
int year,
int month,
int day,
int hour,
int min,
int sec,
146 int os_setenv(
const char *name,
const char *value,
int overwrite);
196 #ifdef OS_NO_C_LIB_DEFINES
235 void *
os_memcpy(
void *dest,
const void *src,
size_t n);
246 void *
os_memmove(
void *dest,
const void *src,
size_t n);
255 void *
os_memset(
void *s,
int c,
size_t n);
266 int os_memcmp(
const void *s1,
const void *s2,
size_t n);
327 int os_strcmp(
const char *s1,
const char *s2);
338 int os_strncmp(
const char *s1,
const char *s2,
size_t n);
347 char *
os_strncpy(
char *dest,
const char *src,
size_t n);
355 char *
os_strstr(
const char *haystack,
const char *needle);
378 int os_snprintf(
char *str,
size_t size,
const char *format, ...);
389 #define os_malloc(s) malloc((s))
392 #define os_realloc(p, s) realloc((p), (s))
395 #define os_free(p) free((p))
399 #define os_strdup(s) _strdup(s)
401 #define os_strdup(s) strdup(s)
407 #define os_memcpy(d, s, n) memcpy((d), (s), (n))
410 #define os_memmove(d, s, n) memmove((d), (s), (n))
413 #define os_memset(s, c, n) memset(s, c, n)
416 #define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
420 #define os_strlen(s) strlen(s)
422 #ifndef os_strcasecmp
424 #define os_strcasecmp(s1, s2) _stricmp((s1), (s2))
426 #define os_strcasecmp(s1, s2) strcasecmp((s1), (s2))
429 #ifndef os_strncasecmp
431 #define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
433 #define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
437 #define os_strchr(s, c) strchr((s), (c))
440 #define os_strcmp(s1, s2) strcmp((s1), (s2))
443 #define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
446 #define os_strncpy(d, s, n) strncpy((d), (s), (n))
449 #define os_strrchr(s, c) strrchr((s), (c))
452 #define os_strstr(h, n) strstr((h), (n))
457 #define os_snprintf _snprintf
459 #define os_snprintf snprintf
476 size_t os_strlcpy(
char *dest,
const char *src,
size_t siz);
479 #ifdef OS_REJECT_C_LIB_FUNCTIONS
480 #define malloc OS_DO_NOT_USE_malloc
481 #define realloc OS_DO_NOT_USE_realloc
482 #define free OS_DO_NOT_USE_free
483 #define memcpy OS_DO_NOT_USE_memcpy
484 #define memmove OS_DO_NOT_USE_memmove
485 #define memset OS_DO_NOT_USE_memset
486 #define memcmp OS_DO_NOT_USE_memcmp
488 #define strdup OS_DO_NOT_USE_strdup
489 #define strlen OS_DO_NOT_USE_strlen
490 #define strcasecmp OS_DO_NOT_USE_strcasecmp
491 #define strncasecmp OS_DO_NOT_USE_strncasecmp
493 #define strchr OS_DO_NOT_USE_strchr
495 #define strcmp OS_DO_NOT_USE_strcmp
497 #define strncmp OS_DO_NOT_USE_strncmp
499 #define strncpy OS_DO_NOT_USE_strncpy
500 #define strrchr OS_DO_NOT_USE_strrchr
501 #define strstr OS_DO_NOT_USE_strstr
503 #define snprintf OS_DO_NOT_USE_snprintf
505 #define strcpy OS_DO_NOT_USE_strcpy
char * os_readfile(const char *name, size_t *len)
void os_sleep(os_time_t sec, os_time_t usec)
int os_program_init(void)
#define os_memset(s, c, n)
void * os_zalloc(size_t size)
int os_get_random(unsigned char *buf, size_t len)
#define os_strcmp(s1, s2)
#define os_strncmp(s1, s2, n)
#define os_strncasecmp(s1, s2, n)
void os_daemonize_terminate(const char *pid_file)
void os_program_deinit(void)
#define os_strcasecmp(s1, s2)
int os_get_time(struct os_time *t)
int os_mktime(int year, int month, int day, int hour, int min, int sec, os_time_t *t)
#define os_memcpy(d, s, n)
int os_daemonize(const char *pid_file)
size_t os_strlcpy(char *dest, const char *src, size_t siz)
#define os_memmove(d, s, n)
#define os_strncpy(d, s, n)
int os_setenv(const char *name, const char *value, int overwrite)
int os_unsetenv(const char *name)
char * os_rel2abs_path(const char *rel_path)
#define os_memcmp(s1, s2, n)
unsigned long os_random(void)