headers of functions for control file handling
More...
#include <sys/types.h>
Go to the source code of this file.
Typedefs |
|
typedef int(* | checkfunc )(const char *) |
Functions |
| size_t | lloadfilefd (int, char **, const int striptab) |
| int | loadintfd (int, unsigned long *, const unsigned long def) |
| size_t | loadoneliner (const char *, char **, const int optional) |
| size_t | loadonelinerfd (int fd, char **buf) |
| int | loadlistfd (int, char **, char ***, checkfunc) |
| int | finddomainfd (int, const char *, const int) |
| int | finddomainmm (const char *, const off_t, const char *) |
Detailed Description
headers of functions for control file handling
Function Documentation
| int finddomainfd |
( |
int |
fd, |
|
|
const char * |
domain, |
|
|
const int |
cl |
|
) |
| |
mmap a file and search a domain entry in it
- Parameters:
-
| fd | file descriptor |
| domain | domain name to find |
| cl | close fd or not |
- Return values:
-
| 1 | on match |
| 0 | if none |
| -1 | on error |
trainling spaces and tabs in a line are ignored, lines beginning with '#' are ignored, CR in file will cause trouble
| int finddomainmm |
( |
const char * |
map, |
|
|
const off_t |
size, |
|
|
const char * |
domain |
|
) |
| |
search a domain entry in a mmaped memory area
- Parameters:
-
| map | memory region where file ist mmapped to |
| size | size of mmapped area |
| domain | domain name to find |
- Return values:
-
| 1 | on match |
| 0 | if none |
| -1 | on error |
trailing spaces and tabs in a line are ignored, lines beginning with '#' are ignored, CR in file will cause trouble
| size_t lloadfilefd |
( |
int |
fd, |
|
|
char ** |
buf, |
|
|
const int |
striptab |
|
) |
| |
load a text file into a buffer using locked IO
- Parameters:
-
| fd | file descriptor of the file to load |
| buf | the contents of the file will go here, memory will be malloced |
| striptab | 2: strip trailing whitespace 1: compact {'\0'}* to a single '\0' 0: do nothing but load the file into the buffer |
- Returns:
- length of buffer
- Return values:
-
| -1 | on error (errno is set) |
if the file is empty (size 0 or only comments and blank lines) 0 is returned and buf is set to NULL
- Warning:
- if lloadfilefd can't get a lock on the input file (e.g. currently opened for writing by another process) the file is treated as non existent
The input file will be closed before this function returns.
striptab == 2 means: the only whitespace in a non-comment line may be immediately before the line break, in any amount.
| int loadintfd |
( |
int |
fd, |
|
|
unsigned long * |
result, |
|
|
const unsigned long |
def |
|
) |
| |
read a control file containing a single integer
- Parameters:
-
| fd | file descriptor to read from (will be closed) |
| result | value will be stored here |
| def | default value if file does not exist |
- Return values:
-
| 0 | on success |
| -1 | on error, parse errors in the file will set errno to EINVAL |
| int loadlistfd |
( |
int |
fd, |
|
|
char ** |
buf, |
|
|
char *** |
bufa, |
|
|
checkfunc |
cf |
|
) |
| |
read a list from config file and validate entries
- Parameters:
-
| fd | file descriptor to read from (is closed on exit!) |
| buf | the buffer where the data should be stored (memory will be malloced) |
| bufa | array to be build from buf (memory will be malloced) |
| cf | function to check if an entry is valid or NULL if not to |
- Return values:
-
if the file does not exist or has no content *buf and *bufa will be set to NULL
| size_t loadoneliner |
( |
const char * |
filename, |
|
|
char ** |
buf, |
|
|
const int |
optional |
|
) |
| |
read a configuration file that only may contain one line
- Parameters:
-
| filename | don't know what this can ever mean ;) |
| buf | the buffer where the contents of the file will go, memory will be malloced |
| optional | if set to 0 write an error message to syslog if the file does not exist |
- Returns:
- length of the string
- Return values:
-
read a configuration file that only may contain one line
- Parameters:
-
| fd | opened file descriptor |
| buf | the buffer where the contents of the file will go, memory will be malloced |
- Returns:
- length of the string
- Return values:
-
fd will be closed.