summaryrefslogtreecommitdiffstats
path: root/src/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/conf.c b/src/conf.c
index f211d99..2e6c97f 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -39,6 +39,9 @@
#include <shlobj.h>
#endif
+#include <libimobiledevice-glue/utils.h>
+#include <plist/plist.h>
+
#include "conf.h"
#include "utils.h"
#include "log.h"
@@ -132,7 +135,7 @@ const char *config_get_config_dir()
__config_dir = string_concat(base_config_dir, DIR_SEP_S, CONFIG_DIR, NULL);
if (__config_dir) {
- int i = strlen(__config_dir)-1;
+ int i = strlen(__config_dir)-1;
while ((i > 0) && (__config_dir[i] == DIR_SEP)) {
__config_dir[i--] = '\0';
}
@@ -140,7 +143,7 @@ const char *config_get_config_dir()
free(base_config_dir);
- usbmuxd_log(LL_DEBUG, "initialized config_dir to %s", __config_dir);
+ usbmuxd_log(LL_DEBUG, "Initialized config_dir to %s", __config_dir);
return __config_dir;
}
@@ -160,7 +163,7 @@ static int mkdir_with_parents(const char *dir, int mode)
if (__mkdir(dir, mode) == 0) {
return 0;
} else {
- if (errno == EEXIST) return 0;
+ if (errno == EEXIST) return 0;
}
int res;
char *parent = strdup(dir);
@@ -230,7 +233,7 @@ static int internal_set_value(const char *config_file, const char *key, plist_t
/* read file into plist */
plist_t config = NULL;
- plist_read_from_filename(&config, config_file);
+ plist_read_from_file(config_file, &config, NULL);
if (!config) {
config = plist_new_dict();
plist_dict_set_item(config, key, value);
@@ -247,14 +250,14 @@ static int internal_set_value(const char *config_file, const char *key, plist_t
char *value_string = NULL;
if (plist_get_node_type(value) == PLIST_STRING) {
plist_get_string_val(value, &value_string);
- usbmuxd_log(LL_DEBUG, "setting key %s to %s in config_file %s", key, value_string, config_file);
+ usbmuxd_log(LL_DEBUG, "Setting key %s to %s in config file %s", key, value_string, config_file);
if (value_string)
free(value_string);
} else {
- usbmuxd_log(LL_DEBUG, "setting key %s in config_file %s", key, config_file);
+ usbmuxd_log(LL_DEBUG, "Setting key %s in config file %s", key, config_file);
}
- int res = plist_write_to_filename(config, config_file, PLIST_FORMAT_XML);
+ int res = (plist_write_to_file(config, config_file, PLIST_FORMAT_XML, 0) == PLIST_ERR_SUCCESS);
plist_free(config);
@@ -274,7 +277,7 @@ static int config_set_value(const char *key, plist_t value)
int result = internal_set_value(config_file, key, value);
if (!result) {
- usbmuxd_log(LL_ERROR, "ERROR: Failed to write to '%s': %s", config_file, strerror(errno));
+ usbmuxd_log(LL_ERROR, "ERROR: Failed to write to '%s'", config_file);
}
free(config_file);
@@ -288,8 +291,8 @@ static int internal_get_value(const char* config_file, const char *key, plist_t
/* now parse file to get the SystemBUID */
plist_t config = NULL;
- if (plist_read_from_filename(&config, config_file)) {
- usbmuxd_log(LL_DEBUG, "reading key %s from config_file %s", key, config_file);
+ if (plist_read_from_file(config_file, &config, NULL) == PLIST_ERR_SUCCESS) {
+ usbmuxd_log(LL_DEBUG, "Reading key %s from config file %s", key, config_file);
plist_t n = plist_dict_get_item(config, key);
if (n) {
*value = plist_copy(n);
@@ -371,7 +374,7 @@ void config_get_system_buid(char **system_buid)
if (value && (plist_get_node_type(value) == PLIST_STRING)) {
plist_get_string_val(value, system_buid);
- usbmuxd_log(LL_DEBUG, "got %s %s", CONFIG_SYSTEM_BUID_KEY, *system_buid);
+ usbmuxd_log(LL_DEBUG, "Got %s %s", CONFIG_SYSTEM_BUID_KEY, *system_buid);
}
if (value)
@@ -379,14 +382,14 @@ void config_get_system_buid(char **system_buid)
if (!*system_buid) {
/* no config, generate system_buid */
- usbmuxd_log(LL_DEBUG, "no previous %s found", CONFIG_SYSTEM_BUID_KEY);
+ usbmuxd_log(LL_DEBUG, "No previous %s found", CONFIG_SYSTEM_BUID_KEY);
*system_buid = config_generate_system_buid();
if (!config_set_system_buid(*system_buid)) {
usbmuxd_log(LL_WARNING, "WARNING: Failed to store SystemBUID, this might be a problem");
}
}
- usbmuxd_log(LL_DEBUG, "using %s as %s", *system_buid, CONFIG_SYSTEM_BUID_KEY);
+ usbmuxd_log(LL_DEBUG, "Using %s as %s", *system_buid, CONFIG_SYSTEM_BUID_KEY);
}
/**
@@ -428,8 +431,8 @@ int config_set_device_record(const char *udid, char* record_data, uint64_t recor
remove(device_record_file);
/* store file */
- if (!plist_write_to_filename(plist, device_record_file, PLIST_FORMAT_XML)) {
- usbmuxd_log(LL_DEBUG, "could not open '%s' for writing: %s", device_record_file, strerror(errno));
+ if (!plist_write_to_file(plist, device_record_file, PLIST_FORMAT_XML, 0)) {
+ usbmuxd_log(LL_DEBUG, "Could not open '%s' for writing: %s", device_record_file, strerror(errno));
res = -ENOENT;
}
free(device_record_file);
@@ -464,7 +467,7 @@ int config_get_device_record(const char *udid, char **record_data, uint64_t *rec
/* read file */
buffer_read_from_filename(device_record_file, record_data, record_size);
if (!*record_data) {
- usbmuxd_log(LL_ERROR, "%s: failed to read '%s': %s", __func__, device_record_file, strerror(errno));
+ usbmuxd_log(LL_ERROR, "ERROR: Failed to read '%s': %s", device_record_file, strerror(errno));
res = -ENOENT;
}
free(device_record_file);
@@ -490,7 +493,7 @@ int config_remove_device_record(const char *udid)
/* remove file */
if (remove(device_record_file) != 0) {
res = -errno;
- usbmuxd_log(LL_DEBUG, "could not remove %s: %s", device_record_file, strerror(errno));
+ usbmuxd_log(LL_DEBUG, "Could not remove %s: %s", device_record_file, strerror(errno));
}
free(device_record_file);
@@ -527,6 +530,6 @@ void config_device_record_get_host_id(const char *udid, char **host_id)
plist_free(value);
if (!*host_id) {
- usbmuxd_log(LL_ERROR, "%s: ERROR couldn't get HostID from pairing record for udid %s", __func__, udid);
+ usbmuxd_log(LL_ERROR, "ERROR: Could not get HostID from pairing record for udid %s", udid);
}
}