From f4c4b783c8dbe2fe8e7e6f6b5f19f0d44b489c9a Mon Sep 17 00:00:00 2001 From: Zach C Date: Sun, 31 Aug 2008 11:25:22 -0700 Subject: Added binary-plist support (tweaked slightly to move stuff around) Signed-off-by: Matt Colyer fix makefile to take correct main function into account --- src/plist.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index b27a0c5..98c7d91 100644 --- a/src/plist.h +++ b/src/plist.h @@ -24,6 +24,12 @@ #include #include +#include +#include + +#include +#include +#include xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); @@ -35,4 +41,36 @@ xmlDocPtr new_plist(); char **read_dict_element_strings(xmlNode * dict); void free_dictionary(char **dictionary); + +/* Binary plist stuff */ + +enum { + BPLIST_TRUE = 0x08, + BPLIST_FALSE = 0x09, + BPLIST_FILL = 0x0F, /* will be used for length grabbing */ + BPLIST_INT = 0x10, + BPLIST_REAL = 0x20, + BPLIST_DATE = 0x33, + BPLIST_DATA = 0x40, + BPLIST_STRING = 0x50, + BPLIST_UNICODE = 0x60, + BPLIST_UID = 0x70, + BPLIST_ARRAY = 0xA0, + BPLIST_SET = 0xC0, + BPLIST_DICT = 0xD0, + BPLIST_MASK = 0xF0 +}; + +typedef struct _bplist_node { + struct _bplist_node *next, **subnodes; // subnodes is for arrays, dicts and (potentially) sets. + uint64_t length, intval64; + uint32_t intval32; // length = subnodes + uint16_t intval16; + uint8_t intval8; + uint8_t type, *indexes; // indexes for array-types; essentially specify the order in which to access for key => value pairs + char *strval; + double realval; + wchar_t *unicodeval; +} bplist_node; + #endif -- cgit v1.1-32-gdbae From aed2c025f6e47dc769675e564cc574adc496a88a Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Tue, 25 Nov 2008 19:14:27 +0100 Subject: fix some warnings and indent --- src/plist.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index 98c7d91..5f31281 100644 --- a/src/plist.h +++ b/src/plist.h @@ -31,6 +31,7 @@ #include #include +char *format_string(const char *buf, int cols, int depth); xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); @@ -47,7 +48,7 @@ void free_dictionary(char **dictionary); enum { BPLIST_TRUE = 0x08, BPLIST_FALSE = 0x09, - BPLIST_FILL = 0x0F, /* will be used for length grabbing */ + BPLIST_FILL = 0x0F, /* will be used for length grabbing */ BPLIST_INT = 0x10, BPLIST_REAL = 0x20, BPLIST_DATE = 0x33, @@ -62,15 +63,17 @@ enum { }; typedef struct _bplist_node { - struct _bplist_node *next, **subnodes; // subnodes is for arrays, dicts and (potentially) sets. + struct _bplist_node *next, **subnodes; // subnodes is for arrays, dicts and (potentially) sets. uint64_t length, intval64; - uint32_t intval32; // length = subnodes + uint32_t intval32; // length = subnodes uint16_t intval16; uint8_t intval8; - uint8_t type, *indexes; // indexes for array-types; essentially specify the order in which to access for key => value pairs + uint8_t type, *indexes; // indexes for array-types; essentially specify the order in which to access for key => value pairs char *strval; double realval; wchar_t *unicodeval; } bplist_node; +bplist_node *parse_nodes(const char *bpbuffer, uint32_t bplength, uint32_t * position); + #endif -- cgit v1.1-32-gdbae From 5811f92943fa81b6266e0b57d95824d1efa17120 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Fri, 28 Nov 2008 23:19:17 +0100 Subject: Start an abstraction of xml and binary plist --- src/plist.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index 5f31281..4586d6f 100644 --- a/src/plist.h +++ b/src/plist.h @@ -30,6 +30,7 @@ #include #include #include +#include char *format_string(const char *buf, int cols, int depth); xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); @@ -76,4 +77,38 @@ typedef struct _bplist_node { bplist_node *parse_nodes(const char *bpbuffer, uint32_t bplength, uint32_t * position); +typedef enum { + PLIST_BOOLEAN, + PLIST_UINT8, + PLIST_UINT16, + PLIST_UINT32, + PLIST_UINT64, + PLIST_FLOAT32, + PLIST_FLOAT64, + PLIST_STRING, + PLIST_UNICODE, + PLIST_ARRAY, + PLIST_DICT, + PLIST_DATE, + PLIST_DATA, + PLIST_PLIST, + PLIST_KEY, +} plist_type; + + +typedef GNode *plist_t; +typedef GNode *dict_t; +typedef GNode *array_t; + +void plist_new_plist(plist_t* plist); +void plist_new_dict_in_plist(plist_t plist, dict_t* dict); +void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void** values, array_t* array); +void plist_add_dict_element(dict_t dict, char* key, plist_type type, void* value); +void plist_free(plist_t plist); + +void plist_to_xml(plist_t plist, char** plist_xml); +void plist_to_bin(plist_t plist, char** plist_bin); + +void xml_to_plist(const char* plist_xml, plist_t* plist); +void bin_to_plist(const char* plist_bin, plist_t* plist); #endif -- cgit v1.1-32-gdbae From 889cb32a1231c41762d7e2bbe6c891bd3a6c9a7d Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sun, 30 Nov 2008 16:36:18 +0100 Subject: Continue abstraction of xml and binary plist. --- src/plist.h | 48 +++++++++--------------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index 4586d6f..1ca55f9 100644 --- a/src/plist.h +++ b/src/plist.h @@ -46,38 +46,8 @@ void free_dictionary(char **dictionary); /* Binary plist stuff */ -enum { - BPLIST_TRUE = 0x08, - BPLIST_FALSE = 0x09, - BPLIST_FILL = 0x0F, /* will be used for length grabbing */ - BPLIST_INT = 0x10, - BPLIST_REAL = 0x20, - BPLIST_DATE = 0x33, - BPLIST_DATA = 0x40, - BPLIST_STRING = 0x50, - BPLIST_UNICODE = 0x60, - BPLIST_UID = 0x70, - BPLIST_ARRAY = 0xA0, - BPLIST_SET = 0xC0, - BPLIST_DICT = 0xD0, - BPLIST_MASK = 0xF0 -}; -typedef struct _bplist_node { - struct _bplist_node *next, **subnodes; // subnodes is for arrays, dicts and (potentially) sets. - uint64_t length, intval64; - uint32_t intval32; // length = subnodes - uint16_t intval16; - uint8_t intval8; - uint8_t type, *indexes; // indexes for array-types; essentially specify the order in which to access for key => value pairs - char *strval; - double realval; - wchar_t *unicodeval; -} bplist_node; - -bplist_node *parse_nodes(const char *bpbuffer, uint32_t bplength, uint32_t * position); - -typedef enum { +typedef enum { PLIST_BOOLEAN, PLIST_UINT8, PLIST_UINT16, @@ -100,15 +70,15 @@ typedef GNode *plist_t; typedef GNode *dict_t; typedef GNode *array_t; -void plist_new_plist(plist_t* plist); -void plist_new_dict_in_plist(plist_t plist, dict_t* dict); -void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void** values, array_t* array); -void plist_add_dict_element(dict_t dict, char* key, plist_type type, void* value); +void plist_new_plist(plist_t * plist); +void plist_new_dict_in_plist(plist_t plist, dict_t * dict); +void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void **values, array_t * array); +void plist_add_dict_element(dict_t dict, char *key, plist_type type, void *value); void plist_free(plist_t plist); -void plist_to_xml(plist_t plist, char** plist_xml); -void plist_to_bin(plist_t plist, char** plist_bin); +void plist_to_xml(plist_t plist, char **plist_xml); +void plist_to_bin(plist_t plist, char **plist_bin, int *length); -void xml_to_plist(const char* plist_xml, plist_t* plist); -void bin_to_plist(const char* plist_bin, plist_t* plist); +void xml_to_plist(const char *plist_xml, plist_t * plist); +void bin_to_plist(const char *plist_bin, int length, plist_t * plist); #endif -- cgit v1.1-32-gdbae From d560cf5a15d1aef74e95b208ed69b7d324d94354 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sun, 30 Nov 2008 21:49:56 +0100 Subject: complete xml plist abstraction and migrate lockdownd_hello to new plist API. --- src/plist.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index 1ca55f9..ffc00e4 100644 --- a/src/plist.h +++ b/src/plist.h @@ -70,15 +70,19 @@ typedef GNode *plist_t; typedef GNode *dict_t; typedef GNode *array_t; + void plist_new_plist(plist_t * plist); void plist_new_dict_in_plist(plist_t plist, dict_t * dict); void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void **values, array_t * array); void plist_add_dict_element(dict_t dict, char *key, plist_type type, void *value); void plist_free(plist_t plist); -void plist_to_xml(plist_t plist, char **plist_xml); -void plist_to_bin(plist_t plist, char **plist_bin, int *length); +void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); +void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); + +void xml_to_plist(const char *plist_xml, uint32_t length, plist_t * plist); +void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); -void xml_to_plist(const char *plist_xml, plist_t * plist); -void bin_to_plist(const char *plist_bin, int length, plist_t * plist); +GNode *find_query_node(plist_t plist, char *key, char *request); +void get_type_and_value(GNode * node, plist_type * type, void *value); #endif -- cgit v1.1-32-gdbae From 505c97582b53ed406169f931a49ee6f678b19b52 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Mon, 1 Dec 2008 20:25:12 +0100 Subject: continue migration to new plist API. --- src/plist.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index ffc00e4..34e3934 100644 --- a/src/plist.h +++ b/src/plist.h @@ -84,5 +84,6 @@ void xml_to_plist(const char *plist_xml, uint32_t length, plist_t * plist); void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); GNode *find_query_node(plist_t plist, char *key, char *request); +GNode *find_node(plist_t plist, plist_type type, void *value); void get_type_and_value(GNode * node, plist_type * type, void *value); #endif -- cgit v1.1-32-gdbae From 7563917755cf58cee80fbd5bc56a1ab0f563963a Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Mon, 1 Dec 2008 21:23:58 +0100 Subject: cleanup unused functions. --- src/plist.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index 34e3934..ed3d2b2 100644 --- a/src/plist.h +++ b/src/plist.h @@ -22,8 +22,6 @@ #ifndef PLIST_H #define PLIST_H -#include -#include #include #include @@ -33,16 +31,7 @@ #include char *format_string(const char *buf, int cols, int depth); -xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); -xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); -xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode * dict, const char *key, const char *value, int depth); -xmlNode *add_child_to_plist(xmlDocPtr plist, const char *name, const char *content, xmlNode * to_node, int depth); -void free_plist(xmlDocPtr plist); -xmlDocPtr new_plist(); - -char **read_dict_element_strings(xmlNode * dict); -void free_dictionary(char **dictionary); /* Binary plist stuff */ @@ -70,7 +59,6 @@ typedef GNode *plist_t; typedef GNode *dict_t; typedef GNode *array_t; - void plist_new_plist(plist_t * plist); void plist_new_dict_in_plist(plist_t plist, dict_t * dict); void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void **values, array_t * array); -- cgit v1.1-32-gdbae From 1a06347d27ca51283de3a9ff21e138a3ea9ba9b6 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Mon, 8 Dec 2008 22:47:02 +0100 Subject: cleanup binary parsing and move stuff around. --- src/plist.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index ed3d2b2..df1d3e4 100644 --- a/src/plist.h +++ b/src/plist.h @@ -35,7 +35,7 @@ char *format_string(const char *buf, int cols, int depth); /* Binary plist stuff */ - +/* typedef enum { PLIST_BOOLEAN, PLIST_UINT8, @@ -53,6 +53,22 @@ typedef enum { PLIST_PLIST, PLIST_KEY, } plist_type; +*/ + +typedef enum { + PLIST_BOOLEAN, + PLIST_UINT, + PLIST_REAL, + PLIST_STRING, + PLIST_UNICODE, + PLIST_ARRAY, + PLIST_DICT, + PLIST_DATE, + PLIST_DATA, + PLIST_PLIST, + PLIST_KEY, +} plist_type; + typedef GNode *plist_t; -- cgit v1.1-32-gdbae From 625633203a27f569bea8890cb269132fea83b497 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Wed, 10 Dec 2008 23:22:12 +0100 Subject: add bplist writting capability. --- src/plist.h | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index df1d3e4..63f67f7 100644 --- a/src/plist.h +++ b/src/plist.h @@ -33,28 +33,6 @@ char *format_string(const char *buf, int cols, int depth); -/* Binary plist stuff */ - -/* -typedef enum { - PLIST_BOOLEAN, - PLIST_UINT8, - PLIST_UINT16, - PLIST_UINT32, - PLIST_UINT64, - PLIST_FLOAT32, - PLIST_FLOAT64, - PLIST_STRING, - PLIST_UNICODE, - PLIST_ARRAY, - PLIST_DICT, - PLIST_DATE, - PLIST_DATA, - PLIST_PLIST, - PLIST_KEY, -} plist_type; -*/ - typedef enum { PLIST_BOOLEAN, PLIST_UINT, @@ -65,7 +43,6 @@ typedef enum { PLIST_DICT, PLIST_DATE, PLIST_DATA, - PLIST_PLIST, PLIST_KEY, } plist_type; -- cgit v1.1-32-gdbae From 18d1ee3b0f17325fdffe0cf3e2770a3f0f45a1b9 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Thu, 11 Dec 2008 23:03:21 +0100 Subject: move stuff around to make code more organized. --- src/plist.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index 63f67f7..e3f3f59 100644 --- a/src/plist.h +++ b/src/plist.h @@ -47,6 +47,20 @@ typedef enum { } plist_type; +struct plist_data { + union { + char boolval; + uint64_t intval; + double realval; + char *strval; + wchar_t *unicodeval; + char *buff; + }; + uint64_t length; + plist_type type; +}; + + typedef GNode *plist_t; typedef GNode *dict_t; @@ -67,4 +81,5 @@ void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); GNode *find_query_node(plist_t plist, char *key, char *request); GNode *find_node(plist_t plist, plist_type type, void *value); void get_type_and_value(GNode * node, plist_type * type, void *value); + #endif -- cgit v1.1-32-gdbae From 9ca887308d59e6cb5bf684f9f3bd968118e8014f Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Fri, 12 Dec 2008 22:05:44 +0100 Subject: Fix some bugs in binary plist generation. --- src/plist.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index e3f3f59..ff4bdbf 100644 --- a/src/plist.h +++ b/src/plist.h @@ -30,8 +30,6 @@ #include #include -char *format_string(const char *buf, int cols, int depth); - typedef enum { PLIST_BOOLEAN, @@ -44,6 +42,7 @@ typedef enum { PLIST_DATE, PLIST_DATA, PLIST_KEY, + PLIST_NONE } plist_type; @@ -63,13 +62,12 @@ struct plist_data { typedef GNode *plist_t; -typedef GNode *dict_t; -typedef GNode *array_t; -void plist_new_plist(plist_t * plist); -void plist_new_dict_in_plist(plist_t plist, dict_t * dict); -void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void **values, array_t * array); -void plist_add_dict_element(dict_t dict, char *key, plist_type type, void *value); + +void plist_new_dict(plist_t * plist); +void plist_new_array(plist_t * plist); +void plist_new_dict_in_plist(plist_t plist, plist_t * dict); +void plist_add_dict_element(plist_t dict, char *key, plist_type type, void *value); void plist_free(plist_t plist); void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); @@ -78,8 +76,8 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); void xml_to_plist(const char *plist_xml, uint32_t length, plist_t * plist); void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); -GNode *find_query_node(plist_t plist, char *key, char *request); -GNode *find_node(plist_t plist, plist_type type, void *value); -void get_type_and_value(GNode * node, plist_type * type, void *value); +plist_t find_query_node(plist_t plist, char *key, char *request); +plist_t find_node(plist_t plist, plist_type type, void *value); +void get_type_and_value(plist_t node, plist_type * type, void *value); #endif -- cgit v1.1-32-gdbae From 3d8ba053deeacd74e621469d3d45d1db38ee411a Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Fri, 12 Dec 2008 23:39:33 +0100 Subject: Change from Base64 encoded buffers to real buffers. Base64 decoding/encoding only happens in xml plists. --- src/plist.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h index ff4bdbf..1dc464a 100644 --- a/src/plist.h +++ b/src/plist.h @@ -67,7 +67,7 @@ typedef GNode *plist_t; void plist_new_dict(plist_t * plist); void plist_new_array(plist_t * plist); void plist_new_dict_in_plist(plist_t plist, plist_t * dict); -void plist_add_dict_element(plist_t dict, char *key, plist_type type, void *value); +void plist_add_dict_element(plist_t dict, char *key, plist_type type, void *value, uint64_t length); void plist_free(plist_t plist); void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); @@ -78,6 +78,6 @@ void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); plist_t find_query_node(plist_t plist, char *key, char *request); plist_t find_node(plist_t plist, plist_type type, void *value); -void get_type_and_value(plist_t node, plist_type * type, void *value); +void get_type_and_value(plist_t node, plist_type * type, void *value, uint64_t * length); #endif -- cgit v1.1-32-gdbae From 4301ef9bb8e9d06ffa4e9172191d58ede5e16f5d Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sat, 13 Dec 2008 18:12:46 +0100 Subject: fork out plist stuff in libplist and migrate libiphone to use it. --- src/plist.h | 83 ------------------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/plist.h (limited to 'src/plist.h') diff --git a/src/plist.h b/src/plist.h deleted file mode 100644 index 1dc464a..0000000 --- a/src/plist.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * plist.h - * contains structures and the like for plists - * - * Copyright (c) 2008 Zach C. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef PLIST_H -#define PLIST_H - -#include -#include - -#include -#include -#include -#include - - -typedef enum { - PLIST_BOOLEAN, - PLIST_UINT, - PLIST_REAL, - PLIST_STRING, - PLIST_UNICODE, - PLIST_ARRAY, - PLIST_DICT, - PLIST_DATE, - PLIST_DATA, - PLIST_KEY, - PLIST_NONE -} plist_type; - - -struct plist_data { - union { - char boolval; - uint64_t intval; - double realval; - char *strval; - wchar_t *unicodeval; - char *buff; - }; - uint64_t length; - plist_type type; -}; - - - -typedef GNode *plist_t; - - -void plist_new_dict(plist_t * plist); -void plist_new_array(plist_t * plist); -void plist_new_dict_in_plist(plist_t plist, plist_t * dict); -void plist_add_dict_element(plist_t dict, char *key, plist_type type, void *value, uint64_t length); -void plist_free(plist_t plist); - -void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); -void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); - -void xml_to_plist(const char *plist_xml, uint32_t length, plist_t * plist); -void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); - -plist_t find_query_node(plist_t plist, char *key, char *request); -plist_t find_node(plist_t plist, plist_type type, void *value); -void get_type_and_value(plist_t node, plist_type * type, void *value, uint64_t * length); - -#endif -- cgit v1.1-32-gdbae