From ff1fa73f33e9223e69cbb71e70b084e3482dce3f Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Thu, 29 Jan 2009 22:20:48 +0100 Subject: Fix indent. --- Makefile.am | 2 +- include/plist/plist.h | 93 ++++++++++++++++++++++++++------------------------- plutil/plutil.c | 1 - src/bplist.c | 12 +++---- src/plist.c | 24 ++++++------- src/xplist.c | 11 +++--- 6 files changed, 71 insertions(+), 72 deletions(-) diff --git a/Makefile.am b/Makefile.am index 830abe2..6824a32 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,4 +9,4 @@ doc: doxygen doxygen.cfg indent: - indent -kr -ut -ts4 -l120 src/*.c src/*.h plutil/*.c + indent -kr -ut -ts4 -l120 src/*.c src/*.h plutil/*.c include/plist/*.h diff --git a/include/plist/plist.h b/include/plist/plist.h index 2c0df11..9f82cb8 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -39,24 +39,27 @@ extern "C" { /** * The basic plist abstract data type. */ -typedef void* plist_t; + typedef void *plist_t; /** * The enumeration of plist node types. */ -typedef enum { - PLIST_BOOLEAN, /**< Boolean, scalar type */ - PLIST_UINT, /**< Unsigned integer, scalar type */ - PLIST_REAL, /**< Real, scalar type */ - PLIST_STRING, /**< ASCII string, scalar type */ - PLIST_UNICODE, /**< Unicode strin, scalar type */ - PLIST_ARRAY, /**< Ordered array, structured type */ - PLIST_DICT, /**< Unordered dictionary (key/value pair), structured type */ - PLIST_DATE, /**< Date, scalar type */ - PLIST_DATA, /**< Binary data, scalar type */ - PLIST_KEY, /**< Key in dictionaries (ASCII String), scalar type */ - PLIST_NONE /**< No type */ -} plist_type; + typedef enum { + PLIST_BOOLEAN, + /**< Boolean, scalar type */ + PLIST_UINT, /**< Unsigned integer, scalar type */ + PLIST_REAL, /**< Real, scalar type */ + PLIST_STRING, + /**< ASCII string, scalar type */ + PLIST_UNICODE, + /**< Unicode strin, scalar type */ + PLIST_ARRAY,/**< Ordered array, structured type */ + PLIST_DICT, /**< Unordered dictionary (key/value pair), structured type */ + PLIST_DATE, /**< Date, scalar type */ + PLIST_DATA, /**< Binary data, scalar type */ + PLIST_KEY, /**< Key in dictionaries (ASCII String), scalar type */ + PLIST_NONE /**< No type */ + } plist_type; /******************************************** @@ -71,7 +74,7 @@ typedef enum { * @return the created plist * @sa #plist_type */ -plist_t plist_new_dict(); + plist_t plist_new_dict(); /** * Create a new root plist_t type #PLIST_ARRAY @@ -79,14 +82,14 @@ plist_t plist_new_dict(); * @return the created plist * @sa #plist_type */ -plist_t plist_new_array(); + plist_t plist_new_array(); /** * Destruct a plist_t node and all its children recursively * * @param plist the plist to free */ -void plist_free(plist_t plist); + void plist_free(plist_t plist); /******************************************** * * @@ -99,7 +102,7 @@ void plist_free(plist_t plist); * * @param node the first child */ -plist_t plist_get_first_child(plist_t node); + plist_t plist_get_first_child(plist_t node); /** @@ -107,7 +110,7 @@ plist_t plist_get_first_child(plist_t node); * * @param node the next sibling */ -plist_t plist_get_next_sibling(plist_t node); + plist_t plist_get_next_sibling(plist_t node); /** @@ -115,7 +118,7 @@ plist_t plist_get_next_sibling(plist_t node); * * @param node the previous sibling */ -plist_t plist_get_prev_sibling(plist_t node); + plist_t plist_get_prev_sibling(plist_t node); /******************************************** * * @@ -131,7 +134,7 @@ plist_t plist_get_prev_sibling(plist_t node); * @param node the node to add a children to * @param subnode the children node */ -void plist_add_sub_node(plist_t node, plist_t subnode); + void plist_add_sub_node(plist_t node, plist_t subnode); /** * Add a subnode of type #PLIST_KEY to a node. The node must be of a structured type @@ -140,7 +143,7 @@ void plist_add_sub_node(plist_t node, plist_t subnode); * @param node the node to add a children to * @param val the key value encoded as an ASCII string (must be null terminated) */ -void plist_add_sub_key_el(plist_t node, const char* val); + void plist_add_sub_key_el(plist_t node, const char *val); /** * Add a subnode of type #PLIST_STRING to a node. The node must be of a structured type @@ -149,7 +152,7 @@ void plist_add_sub_key_el(plist_t node, const char* val); * @param node the node to add a children to * @param val the string value encoded as an ASCII string (must be null terminated) */ -void plist_add_sub_string_el(plist_t node, const char* val); + void plist_add_sub_string_el(plist_t node, const char *val); /** * Add a subnode of type #PLIST_BOOLEAN to a node. The node must be of a structured type @@ -158,7 +161,7 @@ void plist_add_sub_string_el(plist_t node, const char* val); * @param node the node to add a children to * @param val the boolean value (TRUE or FALSE) */ -void plist_add_sub_bool_el(plist_t node, uint8_t val); + void plist_add_sub_bool_el(plist_t node, uint8_t val); /** * Add a subnode of type #PLIST_UINT to a node. The node must be of a structured type @@ -167,7 +170,7 @@ void plist_add_sub_bool_el(plist_t node, uint8_t val); * @param node the node to add a children to * @param val the unsigned integer value */ -void plist_add_sub_uint_el(plist_t node, uint64_t val); + void plist_add_sub_uint_el(plist_t node, uint64_t val); /** * Add a subnode of type #PLIST_REAL to a node. The node must be of a structured type @@ -176,7 +179,7 @@ void plist_add_sub_uint_el(plist_t node, uint64_t val); * @param node the node to add a children to * @param val the real value */ -void plist_add_sub_real_el(plist_t node, double val); + void plist_add_sub_real_el(plist_t node, double val); /** * Add a subnode of type #PLIST_DATA to a node. The node must be of a structured type @@ -186,7 +189,7 @@ void plist_add_sub_real_el(plist_t node, double val); * @param val the binary buffer * @param length the length of the buffer */ -void plist_add_sub_data_el(plist_t node, const char* val, uint64_t length); + void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length); /** * Add a subnode of type #PLIST_UNICODE to a node. The node must be of a structured type @@ -195,7 +198,7 @@ void plist_add_sub_data_el(plist_t node, const char* val, uint64_t length); * @param node the node to add a children to * @param val the unicode string encoded in UTF-8 (must be null terminated) */ -void plist_add_sub_unicode_el(plist_t node, const char* val); + void plist_add_sub_unicode_el(plist_t node, const char *val); /** * Add a subnode of type #PLIST_DATE to a node. The node must be of a structured type @@ -205,7 +208,7 @@ void plist_add_sub_unicode_el(plist_t node, const char* val); * @param sec the number of seconds since 01/01/2001 * @param usec the number of microseconds */ -void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); + void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); /******************************************** @@ -220,7 +223,7 @@ void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); * @param node the node * @return the type of the node */ -plist_type plist_get_node_type(plist_t node); + plist_type plist_get_node_type(plist_t node); /** * Get the value of a #PLIST_KEY node. @@ -230,7 +233,7 @@ plist_type plist_get_node_type(plist_t node); * @param val a pointer to a C-string. This function allocates the memory, * caller is responsible for freeing it. */ -void plist_get_key_val(plist_t node, char** val); + void plist_get_key_val(plist_t node, char **val); /** * Get the value of a #PLIST_STRING node. @@ -240,7 +243,7 @@ void plist_get_key_val(plist_t node, char** val); * @param val a pointer to a C-string. This function allocates the memory, * caller is responsible for freeing it. */ -void plist_get_string_val(plist_t node, char** val); + void plist_get_string_val(plist_t node, char **val); /** * Get the value of a #PLIST_BOOLEAN node. @@ -249,7 +252,7 @@ void plist_get_string_val(plist_t node, char** val); * @param node the node * @param val a pointer to a uint8_t variable. */ -void plist_get_bool_val(plist_t node, uint8_t* val); + void plist_get_bool_val(plist_t node, uint8_t * val); /** * Get the value of a #PLIST_UINT node. @@ -258,7 +261,7 @@ void plist_get_bool_val(plist_t node, uint8_t* val); * @param node the node * @param val a pointer to a uint64_t variable. */ -void plist_get_uint_val(plist_t node, uint64_t* val); + void plist_get_uint_val(plist_t node, uint64_t * val); /** * Get the value of a #PLIST_REAL node. @@ -267,7 +270,7 @@ void plist_get_uint_val(plist_t node, uint64_t* val); * @param node the node * @param val a pointer to a double variable. */ -void plist_get_real_val(plist_t node, double* val); + void plist_get_real_val(plist_t node, double *val); /** * Get the value of a #PLIST_DATA node. @@ -277,7 +280,7 @@ void plist_get_real_val(plist_t node, double* val); * @param val a pointer to an unallocated char buffer. This function allocates the memory, * caller is responsible for freeing it. */ -void plist_get_data_val(plist_t node, char** val, uint64_t* length); + void plist_get_data_val(plist_t node, char **val, uint64_t * length); /** * Get the value of a #PLIST_UNICODE node. @@ -287,7 +290,7 @@ void plist_get_data_val(plist_t node, char** val, uint64_t* length); * @param val a pointer to a C-string. This function allocates the memory, * caller is responsible for freeing it. Data is UTF-8 encoded. */ -void plist_get_unicode_val(plist_t node, char** val); + void plist_get_unicode_val(plist_t node, char **val); /** * Get the value of a #PLIST_DATE node. @@ -297,7 +300,7 @@ void plist_get_unicode_val(plist_t node, char** val); * @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001. * @param usec a pointer to an int32_t variable. Represents the number of microseconds */ -void plist_get_date_val(plist_t node, int32_t* sec, int32_t* usec); + void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec); @@ -315,7 +318,7 @@ void plist_get_date_val(plist_t node, int32_t* sec, int32_t* usec); * caller is responsible for freeing it. Data is UTF-8 encoded. * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer. */ -void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); + void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); /** * Export the #plist_t structure to binary format. @@ -325,7 +328,7 @@ void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); * caller is responsible for freeing it. * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer. */ -void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); + void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); /** * Import the #plist_t structure from XML format. @@ -334,7 +337,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); * @param length length of the buffer to read. * @param plist a pointer to the imported plist. */ -void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist); + void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist); /** * Import the #plist_t structure from binary format. @@ -343,7 +346,7 @@ void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist); * @param length length of the buffer to read. * @param plist a pointer to the imported plist. */ -void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist); + void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist); @@ -360,7 +363,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist); * @param plist the root node of the plist structure. * @param value the ASCII Key to match. */ -plist_t plist_find_node_by_key(plist_t plist, const char *value); + plist_t plist_find_node_by_key(plist_t plist, const char *value); /** * Find the first encountered #PLIST_STRING node mathing that string. @@ -369,7 +372,7 @@ plist_t plist_find_node_by_key(plist_t plist, const char *value); * @param plist the root node of the plist structure. * @param value the ASCII String to match. */ -plist_t plist_find_node_by_string(plist_t plist, const char *value); + plist_t plist_find_node_by_string(plist_t plist, const char *value); /*@}*/ @@ -378,6 +381,4 @@ plist_t plist_find_node_by_string(plist_t plist, const char *value); #ifdef __cplusplus } #endif - #endif - diff --git a/plutil/plutil.c b/plutil/plutil.c index 27932d1..0431dc6 100644 --- a/plutil/plutil.c +++ b/plutil/plutil.c @@ -37,7 +37,6 @@ int main(int argc, char *argv[]) print_usage(); return 0; } - //read input file FILE *iplist = fopen(options->in_file, "r"); if (!iplist) diff --git a/src/bplist.c b/src/bplist.c index 50840c2..6e00f39 100644 --- a/src/bplist.c +++ b/src/bplist.c @@ -343,7 +343,7 @@ static gpointer copy_plist_data(gconstpointer src, gpointer data) dstdata->strval = strdup(srcdata->strval); break; case PLIST_UNICODE: - dstdata->unicodeval = (gunichar2*) malloc(srcdata->length * sizeof(gunichar2)); + dstdata->unicodeval = (gunichar2 *) malloc(srcdata->length * sizeof(gunichar2)); memcpy(dstdata->unicodeval, srcdata->unicodeval, srcdata->length * sizeof(gunichar2)); break; case PLIST_DATA: @@ -542,7 +542,7 @@ static gboolean plist_data_compare(gconstpointer a, gconstpointer b) else return FALSE; case PLIST_UNICODE: - if (!memcmp(val_a->unicodeval, val_b->unicodeval,val_a->length)) + if (!memcmp(val_a->unicodeval, val_b->unicodeval, val_a->length)) return TRUE; else return FALSE; @@ -557,7 +557,7 @@ static gboolean plist_data_compare(gconstpointer a, gconstpointer b) return FALSE; break; case PLIST_DATE: - if (!memcmp(&(val_a->timeval), &(val_b->timeval),sizeof(GTimeVal))) + if (!memcmp(&(val_a->timeval), &(val_b->timeval), sizeof(GTimeVal))) return TRUE; else return FALSE; @@ -664,11 +664,11 @@ static void write_string(GByteArray * bplist, char *val) write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size); } -static void write_unicode(GByteArray * bplist, gunichar2 *val, uint64_t size) +static void write_unicode(GByteArray * bplist, gunichar2 * val, uint64_t size) { uint64_t i = 0; uint64_t size2 = size * sizeof(gunichar2); - uint8_t* buff = (uint8_t*) malloc(size2); + uint8_t *buff = (uint8_t *) malloc(size2); memcpy(buff, val, size2); for (i = 0; i < size; i++) byte_convert(buff + i * sizeof(gunichar2), sizeof(gunichar2)); @@ -830,7 +830,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) } //experimental pad to reflect apple's files - uint8_t pad[6] = {0, 0, 0, 0, 0, 0}; + uint8_t pad[6] = { 0, 0, 0, 0, 0, 0 }; g_byte_array_append(bplist_buff, pad, 6); //setup trailer diff --git a/src/plist.c b/src/plist.c index 71059e4..758fe53 100644 --- a/src/plist.c +++ b/src/plist.c @@ -102,16 +102,16 @@ static plist_t plist_add_sub_element(plist_t node, plist_type type, const void * data->strval = strdup((char *) value); break; case PLIST_UNICODE: - len = strlen((char*)value); - data->unicodeval = g_utf8_to_utf16((char*) value, len, &items_read, &items_written, &error); + len = strlen((char *) value); + data->unicodeval = g_utf8_to_utf16((char *) value, len, &items_read, &items_written, &error); data->length = items_written; break; case PLIST_DATA: memcpy(data->buff, value, length); break; case PLIST_DATE: - data->timeval.tv_sec = ((GTimeVal*)value)->tv_sec; - data->timeval.tv_usec = ((GTimeVal*)value)->tv_usec; + data->timeval.tv_sec = ((GTimeVal *) value)->tv_sec; + data->timeval.tv_usec = ((GTimeVal *) value)->tv_usec; break; case PLIST_ARRAY: case PLIST_DICT: @@ -250,13 +250,13 @@ static void plist_get_type_and_value(plist_t node, plist_type * type, void *valu *((char **) value) = g_utf16_to_utf8(data->unicodeval, len, &items_read, &items_written, &error); break; case PLIST_DATA: - *((uint8_t**) value) = (uint8_t*) malloc( *length * sizeof(uint8_t)); + *((uint8_t **) value) = (uint8_t *) malloc(*length * sizeof(uint8_t)); memcpy(value, data->buff, *length * sizeof(uint8_t)); break; case PLIST_DATE: //exception : here we use memory on the stack since it is just a temporary buffer - (*((GTimeVal**) value))->tv_sec = data->timeval.tv_sec; - (*((GTimeVal**) value))->tv_usec = data->timeval.tv_usec; + (*((GTimeVal **) value))->tv_sec = data->timeval.tv_sec; + (*((GTimeVal **) value))->tv_usec = data->timeval.tv_usec; break; case PLIST_ARRAY: case PLIST_DICT: @@ -314,14 +314,14 @@ void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length) plist_add_sub_element(node, PLIST_DATA, val, length); } -void plist_add_sub_unicode_el(plist_t node, const char* val) +void plist_add_sub_unicode_el(plist_t node, const char *val) { plist_add_sub_element(node, PLIST_UNICODE, val, strlen(val)); } void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec) { - GTimeVal val = {sec, usec}; + GTimeVal val = { sec, usec }; plist_add_sub_element(node, PLIST_UNICODE, &val, sizeof(GTimeVal)); } @@ -377,7 +377,7 @@ void plist_get_data_val(plist_t node, char **val, uint64_t * length) plist_get_type_and_value(node, &type, (void *) val, length); } -void plist_get_unicode_val(plist_t node, char** val) +void plist_get_unicode_val(plist_t node, char **val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; @@ -386,11 +386,11 @@ void plist_get_unicode_val(plist_t node, char** val) assert(length == strlen(*val)); } -void plist_get_date_val(plist_t node, int32_t* sec, int32_t* usec) +void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec) { plist_type type = plist_get_node_type(node); uint64_t length = 0; - GTimeVal val = {0, 0}; + GTimeVal val = { 0, 0 }; if (PLIST_DATE == type) plist_get_type_and_value(node, &type, (void *) &val, &length); assert(length == sizeof(GTimeVal)); diff --git a/src/xplist.c b/src/xplist.c index 0c1a6b9..20b2795 100644 --- a/src/xplist.c +++ b/src/xplist.c @@ -289,19 +289,18 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) if (!xmlStrcmp(node->name, XPLIST_STRING)) { - unsigned char *tmp = xmlNodeGetContent(node); - glong len = strlen((char*)tmp); + unsigned char *tmp = xmlNodeGetContent(node); + glong len = strlen((char *) tmp); glong items_read = 0; glong items_written = 0; GError *error = NULL; int type = xmlDetectCharEncoding(tmp, len); - if (XML_CHAR_ENCODING_UTF8 == type) { - data->unicodeval = g_utf8_to_utf16((char*) tmp, len, &items_read, &items_written, &error); + if (XML_CHAR_ENCODING_UTF8 == type) { + data->unicodeval = g_utf8_to_utf16((char *) tmp, len, &items_read, &items_written, &error); data->type = PLIST_UNICODE; data->length = items_written; - } - else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) { + } else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) { data->strval = strdup((char *) xmlNodeGetContent(node)); data->type = PLIST_STRING; data->length = strlen(data->strval); -- cgit v1.1-32-gdbae