summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;