State file implementation.
More...
#include "dist/sds/sds.h"
#include "src/lib/mpdclient.h"
#include "src/lib/validate.h"
#include <stdbool.h>
Go to the source code of this file.
|
| bool | check_partition_state_dir (sds workdir, sds partition) |
| |
| sds | state_file_rw_string_sds (sds workdir, const char *dir, const char *name, sds def_value, validate_callback vcb, bool write) |
| |
| sds | state_file_rw_string (sds workdir, const char *dir, const char *name, const char *def_value, validate_callback vcb, bool write) |
| |
| bool | state_file_rw_bool (sds workdir, const char *dir, const char *name, bool def_value, bool write) |
| |
| int | state_file_rw_int (sds workdir, const char *dir, const char *name, int def_value, int min, int max, bool write) |
| |
| unsigned | state_file_rw_uint (sds workdir, const char *dir, const char *name, unsigned def_value, unsigned min, unsigned max, bool write) |
| |
| enum mpd_tag_type | state_file_rw_tag (sds workdir, const char *dir, const char *name, enum mpd_tag_type def_value, bool write) |
| |
| bool | state_file_write (sds workdir, const char *subdir, const char *filename, const char *value) |
| |
| sds | camel_to_snake (sds text) |
| |
State file implementation.
◆ camel_to_snake()
| sds camel_to_snake |
( |
sds |
text | ) |
|
Converts camel case to snake notation
- Parameters
-
- Returns
- newly allocated sds string in snake notation
◆ check_partition_state_dir()
| bool check_partition_state_dir |
( |
sds |
workdir, |
|
|
sds |
partition |
|
) |
| |
Checks if the state dir for a partition exists
- Parameters
-
| workdir | myMPD working directory |
| partition | partition name |
- Returns
- true on success, else false
◆ state_file_rw_bool()
| bool state_file_rw_bool |
( |
sds |
workdir, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
bool |
def_value, |
|
|
bool |
write |
|
) |
| |
Reads a bool from a file or writes the file with a default value if not exists or value is invalid
- Parameters
-
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value |
| write | if true create the file if not exists |
- Returns
- newly allocated sds string
◆ state_file_rw_int()
| int state_file_rw_int |
( |
sds |
workdir, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
int |
def_value, |
|
|
int |
min, |
|
|
int |
max, |
|
|
bool |
write |
|
) |
| |
Reads an int value from a file or writes the file with a default value if not exists or value is invalid
- Parameters
-
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value as sds string (is freed by this function) |
| min | minimum value |
| max | maximum value |
| write | if true create the file if not exists |
- Returns
- newly allocated sds string
◆ state_file_rw_string()
| sds state_file_rw_string |
( |
sds |
workdir, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
const char * |
def_value, |
|
|
validate_callback |
vcb, |
|
|
bool |
write |
|
) |
| |
Reads a string from a file or writes the file with a default value if not exists or value is invalid
- Parameters
-
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value as c string |
| vcb | validation callback from validate.h |
| write | if true create the file if not exists |
- Returns
- newly allocated sds string
◆ state_file_rw_string_sds()
| sds state_file_rw_string_sds |
( |
sds |
workdir, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
sds |
def_value, |
|
|
validate_callback |
vcb, |
|
|
bool |
write |
|
) |
| |
Reads a string from a file or writes the file with a default value if not exists or value is invalid Frees the default value.
- Parameters
-
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value as sds string (is freed by this function) |
| vcb | validation callback from validate.h |
| write | if true create the file if not exists |
- Returns
- newly allocated sds string
◆ state_file_rw_tag()
| enum mpd_tag_type state_file_rw_tag |
( |
sds |
workdir, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
enum mpd_tag_type |
def_value, |
|
|
bool |
write |
|
) |
| |
Reads a tag name from a file, parses it to a mpd_tag_type or writes the file with a default value if not exists or value is invalid
- Parameters
-
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value as mpd_tag_type |
| write | if true create the file if not exists |
- Returns
- parsed string as mpd_tag_type
◆ state_file_rw_uint()
| unsigned state_file_rw_uint |
( |
sds |
workdir, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
unsigned |
def_value, |
|
|
unsigned |
min, |
|
|
unsigned |
max, |
|
|
bool |
write |
|
) |
| |
Reads an unsigned value from a file or writes the file with a default value if not exists or value is invalid
- Parameters
-
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value as sds string (is freed by this function) |
| min | minimum value |
| max | maximum value |
| write | if true create the file if not exists |
- Returns
- newly allocated sds string
◆ state_file_write()
| bool state_file_write |
( |
sds |
workdir, |
|
|
const char * |
subdir, |
|
|
const char * |
filename, |
|
|
const char * |
value |
|
) |
| |
Writes the statefile
- Parameters
-
| workdir | mympd working directory |
| subdir | subdir |
| filename | filename to write |
| value | value to write fo file |
- Returns
- true on success else false