#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
- Author
- Joachim Wiberg
- Date
- 2015-2021
- Copyright
- ISC License
◆ fgetint()
int fgetint |
( |
const char * |
file, |
|
|
const char * |
sep, |
|
|
const char * |
key |
|
) |
| |
Find the integer value for key in a file.
- Parameters
-
file | File to search for key |
sep | Separator for tokens in file |
key | Key to look for in file |
This is a convenience wrapper for lfopen(), lfgetint(), and lfclose().
- Returns
- The positive integer value for key, or -1 if not found.
◆ lfclose()
Close a parser context.
- Parameters
-
lf | Pointer to lfile_t parser context from lfopen() |
◆ lfgetint()
int lfgetint |
( |
lfile_t * |
lf, |
|
|
const char * |
key |
|
) |
| |
Same as lfgetkey() but returns an integer.
- Parameters
-
lf | Pointer to lfile_t parser context from lfopen() |
key | Key to look for |
This function is the same as lfgetkey() but returns the positive integer value for the matching key, if found.
- Returns
- The positive integer value for key, or -1 if not found.
◆ lfgetkey()
char* lfgetkey |
( |
lfile_t * |
lf, |
|
|
const char * |
key |
|
) |
| |
Find key in file.
- Parameters
-
lf | Pointer to lfile_t parser context from lfopen() |
key | Key to look for |
Locate key from the current position in the file parser context returned from lfopen(). Please note, the search for key does not start from the beginning of the file, it searches from the current position. To restart search from the beginning use rewind() on the lf->fp.
- Returns
- The value to key, or
NULL
if not found.
◆ lfopen()
lfile_t* lfopen |
( |
const char * |
file, |
|
|
const char * |
sep |
|
) |
| |
Open file and return parsing context.
- Parameters
-
file | File to parse |
sep | Separator(s) to use in lftok() |
- Returns
- Pointer to an lfile_t parser context, or
NULL
on error.
◆ lftok()
Get next token in file.
- Parameters
-
lf | Pointer to lfile_t parser context from lfopen() |
- Returns
- Next token, read from file previously opened with lfopen(), or
NULL
if EOF.