|
myMPD
Internal API documentation
|
State file implementation. More...
#include "compile_time.h"#include "src/lib/state_files.h"#include "src/lib/convert.h"#include "src/lib/filehandler.h"#include "src/lib/log.h"#include "src/lib/sds_extras.h"#include "src/lib/utility.h"#include "src/lib/validate.h"#include <ctype.h>#include <dirent.h>#include <errno.h>#include <inttypes.h>#include <string.h>
Functions | |
| bool | check_partition_state_dir (sds workdir, sds partition) |
| sds | camel_to_snake (sds text) |
| 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) |
| enum mpd_tag_type | state_file_rw_tag (sds workdir, const char *dir, const char *name, enum mpd_tag_type 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) |
| bool | state_file_write (sds workdir, const char *subdir, const char *filename, const char *value) |
State file implementation.
| sds camel_to_snake | ( | sds | text | ) |
Converts camel case to snake notation
| text | string to convert |
| bool check_partition_state_dir | ( | sds | workdir, |
| sds | partition | ||
| ) |
Checks if the state dir for a partition exists
| workdir | myMPD working directory |
| partition | partition name |
| 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
| workdir | mympd working directory |
| dir | subdir |
| name | filename to read/write |
| def_value | default value |
| write | if true create the file if not exists |
| 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
| 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 |
| 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
| 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 |
| 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.
| 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 |
| 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
| 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 |
| 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
| 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 |
| bool state_file_write | ( | sds | workdir, |
| const char * | subdir, | ||
| const char * | filename, | ||
| const char * | value | ||
| ) |
Writes the statefile
| workdir | mympd working directory |
| subdir | subdir |
| filename | filename to write |
| value | value to write fo file |