summaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-05-06 11:56:29 +0200
committerGravatar Nikias Bassen2014-05-06 11:56:29 +0200
commitb27e6ffe7233123fc99a26723443705595e925de (patch)
treef7c11e64cba9479042965f8bd3419cf706d73100 /src/utils.c
parentc24463ee5f4ebd3cabb279c2a37e35b1777f4dd9 (diff)
downloadusbmuxd-b27e6ffe7233123fc99a26723443705595e925de.tar.gz
usbmuxd-b27e6ffe7233123fc99a26723443705595e925de.tar.bz2
utils: Add missing plist_read_from_filename() helper
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 4218758..af8fc78 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -252,6 +252,31 @@ void buffer_write_to_filename(const char *filename, const char *buffer, uint64_t
}
}
+int plist_read_from_filename(plist_t *plist, const char *filename)
+{
+ char *buffer = NULL;
+ uint64_t length;
+
+ if (!filename)
+ return 0;
+
+ buffer_read_from_filename(filename, &buffer, &length);
+
+ if (!buffer) {
+ return 0;
+ }
+
+ if ((length > 8) && (memcmp(buffer, "bplist00", 8) == 0)) {
+ plist_from_bin(buffer, length, plist);
+ } else {
+ plist_from_xml(buffer, length, plist);
+ }
+
+ free(buffer);
+
+ return 1;
+}
+
int plist_write_to_filename(plist_t plist, const char *filename, enum plist_format_t format)
{
char *buffer = NULL;