#include "argpar.h"
#include "shash.h"
#include <ctype.h>
#include <errno.h>
#include <libgen.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
|
int | compare_strings (const void *a, const void *b) |
|
int | argpar_clean (argpar *p) |
|
int | argpar_parse_args (argpar *p, unsigned argc, char *argv[], unsigned flags, unsigned *end_index, void *input) |
|
int | argpar_parse_file (argpar *p, const char *path, unsigned flags, void *input) |
|
const char * | argpar_version () |
|
char ** | argpar_split_str (char *str, const char *delim) |
|
char ** | argpar_split_trim (char *str, const char *delim) |
|
int * | argpar_split_int (char *str, const char *delim) |
|
double * | argpar_split_dbl (char *str, const char *delim) |
|
◆ ARGPAR_API_VERSION
#define ARGPAR_API_VERSION 2001000 |
◆ ARGPAR_API_VERSION_STR
#define ARGPAR_API_VERSION_STR "2.1.0" |
◆ ARGPAR_IMPLEMENTATION
#define ARGPAR_IMPLEMENTATION 2001001 |
◆ ARGPAR_IMPLEMENTATION_STR
#define ARGPAR_IMPLEMENTATION_STR "2.1.1" |
◆ argpar_clean()
int argpar_clean |
( |
argpar * |
p | ) |
|
Free any space consumed by argpar for parfiles.
- Parameters
-
[in] | p | argpar structure to clean up. |
- Returns
- 0 on success.
Definition at line 649 of file argpar.c.
◆ argpar_parse_args()
int argpar_parse_args |
( |
argpar * |
p, |
|
|
unsigned |
argc, |
|
|
char * |
argv[], |
|
|
unsigned |
flags, |
|
|
unsigned * |
end_index, |
|
|
void * |
input |
|
) |
| |
Parse an array of key=value pairs and/or key arguments.
- Parameters
-
[in] | p | argpar object to use to parse file |
[in] | argc | Number of arguments to parse. |
[in] | argv | Array of key=value pairs and/or key arguments, starting at index 1. The first element is assumed to be the calling program's name. |
[in] | flags | Flags to modify the behavior of the parser. |
[out] | end_index | Set to the last index parsed. |
[in] | input | Pointer to pass to the configured parser callback. |
- Returns
- 0 when the parsing is completed or the return value of the callback function if it bailed out early.
- See also
- ARGPAR_CAST_ARGS
Definition at line 679 of file argpar.c.
◆ argpar_parse_file()
int argpar_parse_file |
( |
argpar * |
p, |
|
|
const char * |
path, |
|
|
unsigned |
flags, |
|
|
void * |
input |
|
) |
| |
Parse a key=value store file.
- Parameters
-
[in] | p | argpar object to use to parse file |
[in] | path | Path of file, absolute or relative to the current directory. |
[in] | flags | Flags to modify the behavior of the parser. |
[in] | input | Pointer to pass to the configured parser callback. |
- Returns
- 0 when the parsing is completed or the return value of the callback function if it bailed out early.
- See also
- ARGPAR_CAST_ARGS
Definition at line 730 of file argpar.c.
◆ argpar_split_dbl()
double* argpar_split_dbl |
( |
char * |
str, |
|
|
const char * |
delim |
|
) |
| |
Splits a string on a delimiter, returning a NAN-terminated list of doubles.
- Parameters
-
[in] | str | String on which to split. This string is modified, replacing delimiters with '\0'. Return pointers are points to within this string. |
[in] | delim | Delimiters on which to split (each character is a separate delimiter). |
- Returns
- NULL on failure, malloc'd array of doubles ending in NULL on success. Compare to INFINITY for empty strings. Conversion errors result in total failure (returning NULL). (N.B., the proper way to perform these comparisons are the macros isinf and isnan.)
Definition at line 809 of file argpar.c.
◆ argpar_split_int()
int* argpar_split_int |
( |
char * |
str, |
|
|
const char * |
delim |
|
) |
| |
Splits a string on a delimiter, returning a NULL_INT-terminated list of ints.
- Parameters
-
[in] | str | String on which to split. This string is modified, replacing delimiters with '\0'. Return pointers are points to within this string. |
[in] | delim | Delimiters on which to split (each character is a separate delimiter). |
- Returns
- NULL on failure, malloc'd array of ints ending in NULL_INT on success. Compare to EMPTY_INT for empty strings. Conversion errors result in total failure (returning NULL).
Definition at line 785 of file argpar.c.
◆ argpar_split_str()
char** argpar_split_str |
( |
char * |
str, |
|
|
const char * |
delim |
|
) |
| |
Splits a string on a delimiter, returning a NULL-terminated list of strings.
- Parameters
-
[in] | str | String on which to split. This string is modified, replacing delimiters with '\0'. Return pointers are points to within this string. |
[in] | delim | Delimiters on which to split (each character is a separate delimiter). |
- Returns
- NULL on failure, malloc'd array of strings ending in NULL on success.
Definition at line 744 of file argpar.c.
◆ argpar_split_trim()
char** argpar_split_trim |
( |
char * |
str, |
|
|
const char * |
delim |
|
) |
| |
Splits a string on a delimiter, returning a NULL-terminated list of strings, trimming left and right whitespace from each string.
- Parameters
-
[in] | str | String on which to split. This string is modified, replacing delimiters with '\0'. Return pointers are points to within this string. |
[in] | delim | Delimiters on which to split (each character is a separate delimiter). |
- Returns
- NULL on failure, malloc'd array of strings ending in NULL on success.
Definition at line 769 of file argpar.c.
◆ argpar_version()
const char* argpar_version |
( |
| ) |
|
Returns the source code version and the implemented API version.
No assumptions are made about the format of the return value.
Definition at line 740 of file argpar.c.
◆ compare_strings()
int compare_strings |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
◆ argpar_program_version
const char* argpar_program_version |
Used as the program version string. If set, a version=1 option is automatically added. argpar_program_version_hook takes precedence.
Definition at line 19 of file argpar.c.
◆ argpar_program_version_hook
Called to print the version string. If set, a version=1 option is automatically added.
Definition at line 20 of file argpar.c.