LMS 2012
|
Go to the source code of this file.
Data Structures | |
struct | os_time |
Macros | |
#define | os_time_before(a, b) |
#define | os_time_sub(a, b, res) |
Typedefs | |
typedef long | os_time_t |
Functions | |
void | os_sleep (os_time_t sec, os_time_t usec) |
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) |
int | os_daemonize (const char *pid_file) |
void | os_daemonize_terminate (const char *pid_file) |
int | os_get_random (unsigned char *buf, size_t len) |
unsigned long | os_random (void) |
char * | os_rel2abs_path (const char *rel_path) |
int | os_program_init (void) |
void | os_program_deinit (void) |
: Name of the variable | |
os_unsetenv - Delete environent variable Returns: 0 on success, -1 on error This function is only used for wpa_cli action scripts. OS wrapper does not need to implement this if such functionality is not needed. | |
int | os_setenv (const char *name, const char *value, int overwrite) |
int | os_unsetenv (const char *name) |
: Name of the file to read | |
os_readfile - Read a file to an allocated memory buffer : For returning the length of the allocated buffer Returns: Pointer to the allocated buffer or NULL on failure This function allocates memory and reads the given file to this buffer. Both binary and text files can be read with this function. The caller is responsible for freeing the returned buffer with os_free(). | |
#define | os_malloc(s) malloc((s)) |
#define | os_realloc(p, s) realloc((p), (s)) |
#define | os_free(p) free((p)) |
#define | os_strdup(s) strdup(s) |
#define | os_memcpy(d, s, n) memcpy((d), (s), (n)) |
#define | os_memmove(d, s, n) memmove((d), (s), (n)) |
#define | os_memset(s, c, n) memset(s, c, n) |
#define | os_memcmp(s1, s2, n) memcmp((s1), (s2), (n)) |
#define | os_strlen(s) strlen(s) |
#define | os_strcasecmp(s1, s2) strcasecmp((s1), (s2)) |
#define | os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n)) |
#define | os_strchr(s, c) strchr((s), (c)) |
#define | os_strcmp(s1, s2) strcmp((s1), (s2)) |
#define | os_strncmp(s1, s2, n) strncmp((s1), (s2), (n)) |
#define | os_strncpy(d, s, n) strncpy((d), (s), (n)) |
#define | os_strrchr(s, c) strrchr((s), (c)) |
#define | os_strstr(h, n) strstr((h), (n)) |
#define | os_snprintf snprintf |
char * | os_readfile (const char *name, size_t *len) |
void * | os_zalloc (size_t size) |
size_t | os_strlcpy (char *dest, const char *src, size_t siz) |
#define os_strncasecmp | ( | s1, | |
s2, | |||
n | |||
) | strncasecmp((s1), (s2), (n)) |
#define os_time_before | ( | a, | |
b | |||
) |
#define os_time_sub | ( | a, | |
b, | |||
res | |||
) |
int os_daemonize | ( | const char * | pid_file | ) |
void os_daemonize_terminate | ( | const char * | pid_file | ) |
int os_get_random | ( | unsigned char * | buf, |
size_t | len | ||
) |
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 | ||
) |
os_mktime - Convert broken-down time into seconds since 1970-01-01 : Four digit year : Month (1 .. 12) : Day of month (1 .. 31) : Hour (0 .. 23) : Minute (0 .. 59) : Second (0 .. 60) : Buffer for returning calendar time representation (seconds since 1970-01-01 00:00:00) Returns: 0 on success, -1 on failure
Note: The result is in seconds from Epoch, i.e., in UTC, not in local time which is used by POSIX mktime().
void os_program_deinit | ( | void | ) |
os_program_deinit - 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.
int os_program_init | ( | void | ) |
os_program_init - Program initialization (called at start) Returns: 0 on success, -1 on failure
This function is called when a programs starts. If there are any OS specific processing that is needed, it can be placed here. It is also acceptable to just return 0 if not special processing is needed.
unsigned long os_random | ( | void | ) |
char* os_rel2abs_path | ( | const char * | rel_path | ) |
os_rel2abs_path - Get an absolute path for a file : Relative path to a file Returns: Absolute path for the file or NULL on failure
This function tries to convert a relative path of a file to an absolute path in order for the file to be found even if current working directory has changed. The returned value is allocated and caller is responsible for freeing it. It is acceptable to just return the same path in an allocated buffer, e.g., return strdup(rel_path). This function is only used to find configuration files when os_daemonize() may have changed the current working directory and relative path would be pointing to a different location.
int os_setenv | ( | const char * | name, |
const char * | value, | ||
int | overwrite | ||
) |
size_t os_strlcpy | ( | char * | dest, |
const char * | src, | ||
size_t | siz | ||
) |
os_strlcpy - Copy a string with size bound and NUL-termination : Destination : Source : Size of the target buffer Returns: Total length of the target string (length of src) (not including NUL-termination)
This function matches in behavior with the strlcpy(3) function in OpenBSD.