|
libcfe
0.12.1
some useful C-functions
|
#include "config.h"#include "config_files.h"#include <stdlib.h>#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <pwd.h>#include <fcntl.h>#include <errno.h>#include <unistd.h>#include <envz.h>#include "check_path_exists.h"#include "len.h"Go to the source code of this file.
Macros | |
| #define | ROUNDUP(a, b) (((a) & ~((b)-1)) + (b)) |
Functions | |
| int | add_config_file (char **list, size_t *list_len, size_t *list_size, unsigned char id, char *file, size_t file_len, unsigned int check_path) |
| char * | get_config_file (char *list, size_t list_size, unsigned char id) |
Definition at line 18 of file config_files.c.
| int add_config_file | ( | char ** | list, |
| size_t * | list_len, | ||
| size_t * | list_size, | ||
| unsigned char | id, | ||
| char * | file, | ||
| size_t | file_len, | ||
| unsigned int | check_path | ||
| ) |
Create a path relative to the current users home dir and store this path in a list. Before the path is stored it is checked if it exists (if CREATE_PATH is specified it is created) and has at least the requested permissions. This function sets errno on failure (return value -1).
| [in,out] | list | Pointer to a pointer to the list. |
| [in,out] | list_len | Pointer to the length of this list, that means the amount of really used bytes in the list. |
| [in,out] | list_size | Pointer to the size of this list, that means the total amount of bytes allocated for the list. |
| [in] | id | The identifing byte, used to indentify this path. 0 < id < 256. |
| [in] | file | Pointer to the string that needs to be added to the users home dir to construct the requested path, may start with a '/', but not neseccarily. |
| [in] | file_len | Number of characters/bytes used from file. |
| [in] | check_path | valid values (maybe OR-ed):
|
Definition at line 20 of file config_files.c.
| char* get_config_file | ( | char * | list, |
| size_t | list_size, | ||
| unsigned char | id | ||
| ) |
Get a pointer to the file associated with the given identifier.
| [in] | list | Pointer to the list. |
| [in] | list_size | Size of this list, that means the total amount of bytes allocated for the list. |
| [in] | id | The identifing byte, used to indentify this path. 0 < id < 256. |
Definition at line 113 of file config_files.c.