#include "includes.h"
#include "os.h"
Include dependency graph for os_internal.c:
Go to the source code of this file.
Functions | |
void | os_sleep (os_time_t sec, os_time_t usec) |
Sleep (sec, usec). | |
int | os_get_time (struct os_time *t) |
Get current time (sec, usec). | |
int | os_mktime (int year, int month, int day, int hour, int min, int sec, os_time_t *t) |
Convert broken-down time into seconds since 1970-01-01. | |
int | os_daemonize (const char *pid_file) |
Run in the background (detach from the controlling terminal). | |
void | os_daemonize_terminate (const char *pid_file) |
Stop running in the background (remove pid file). | |
int | os_get_random (unsigned char *buf, size_t len) |
Get cryptographically strong pseudo random data. | |
unsigned long | os_random (void) |
Get pseudo random value (not necessarily very strong). | |
char * | os_rel2abs_path (const char *rel_path) |
Get an absolute path for a file. | |
int | os_program_init (void) |
Program initialization (called at start). | |
void | os_program_deinit (void) |
Program deinitialization (called just before exit). | |
int | os_setenv (const char *name, const char *value, int overwrite) |
Set environment variable. | |
int | os_unsetenv (const char *name) |
Delete environent variable. | |
char * | os_readfile (const char *name, size_t *len) |
Read a file to an allocated memory buffer. | |
void * | os_zalloc (size_t size) |
Allocate and zero memory. | |
void * | os_malloc (size_t size) |
void * | os_realloc (void *ptr, size_t size) |
void | os_free (void *ptr) |
void * | os_memcpy (void *dest, const void *src, size_t n) |
void * | os_memmove (void *dest, const void *src, size_t n) |
void * | os_memset (void *s, int c, size_t n) |
int | os_memcmp (const void *s1, const void *s2, size_t n) |
char * | os_strdup (const char *s) |
size_t | os_strlen (const char *s) |
int | os_strcasecmp (const char *s1, const char *s2) |
int | os_strncasecmp (const char *s1, const char *s2, size_t n) |
char * | os_strchr (const char *s, int c) |
char * | os_strrchr (const char *s, int c) |
int | os_strcmp (const char *s1, const char *s2) |
int | os_strncmp (const char *s1, const char *s2, size_t n) |
char * | os_strncpy (char *dest, const char *src, size_t n) |
char * | os_strstr (const char *haystack, const char *needle) |
int | os_snprintf (char *str, size_t size, const char *format,...) |
Alternatively, this software may be distributed under the terms of BSD license.
See README and COPYING for more details.
This file is an example of operating system specific wrapper functions. This version implements many of the functions internally, so it can be used to fill in missing functions from the target system C libraries.
Some of the functions are using standard C library calls in order to keep this file in working condition to allow the functions to be tested on a Linux target. Please note that OS_NO_C_LIB_DEFINES needs to be defined for this file to work correctly. Note that these implementations are only examples and are not optimized for speed.
Definition in file os_internal.c.
|
Run in the background (detach from the controlling terminal).
Definition at line 74 of file os_internal.c. |
|
Stop running in the background (remove pid file).
Definition at line 93 of file os_internal.c. |
|
Get cryptographically strong pseudo random data.
Definition at line 100 of file os_internal.c. |
|
Get current time (sec, usec).
Definition at line 40 of file os_internal.c. |
|
Convert broken-down time into seconds since 1970-01-01.
Definition at line 51 of file os_internal.c. |
|
Program deinitialization (called just before exit). This function is called just before a program exists. If there are any OS specific processing, e.g., freeing resourced allocated in os_program_init(), it should be done here. It is also acceptable for this function to do nothing. Definition at line 169 of file os_internal.c. |
|
Program initialization (called at start).
Definition at line 163 of file os_internal.c. |
|
Get pseudo random value (not necessarily very strong).
Definition at line 118 of file os_internal.c. |
|
Read a file to an allocated memory buffer.
Definition at line 191 of file os_internal.c. |
|
Get an absolute path for a file.
Definition at line 124 of file os_internal.c. |
|
Set environment variable.
Definition at line 174 of file os_internal.c. |
|
Sleep (sec, usec).
Definition at line 31 of file os_internal.c. |
|
Delete environent variable.
Definition at line 180 of file os_internal.c. |
|
Allocate and zero memory.
Definition at line 217 of file os_internal.c. |