summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-01-29 19:26:15 +0100
committerGravatar Jonathan Beck2009-01-29 19:26:15 +0100
commit296a38509d12306e423800ed2c583a94a31eddff (patch)
treeeab14f9e63eb03dc89607a7d4c1aa2ef00046a0f
parent8c2751f8c7e696fca895aebfafc7e668f3afe85c (diff)
downloadlibplist-296a38509d12306e423800ed2c583a94a31eddff.tar.gz
libplist-296a38509d12306e423800ed2c583a94a31eddff.tar.bz2
Clean some old stuff.
-rw-r--r--plutil/plutil.c2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/bplist.c11
-rw-r--r--src/plist.c2
-rw-r--r--src/plist.h3
-rw-r--r--src/utils.c77
-rw-r--r--src/utils.h30
-rw-r--r--src/xplist.c2
8 files changed, 2 insertions, 127 deletions
diff --git a/plutil/plutil.c b/plutil/plutil.c
index ef22a77..27932d1 100644
--- a/plutil/plutil.c
+++ b/plutil/plutil.c
@@ -38,8 +38,6 @@ int main(int argc, char *argv[])
38 return 0; 38 return 0;
39 } 39 }
40 40
41 iphone_set_debug(options->debug);
42
43 //read input file 41 //read input file
44 FILE *iplist = fopen(options->in_file, "r"); 42 FILE *iplist = fopen(options->in_file, "r");
45 if (!iplist) 43 if (!iplist)
diff --git a/src/Makefile.am b/src/Makefile.am
index eb9cd08..87b5a20 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,4 +4,4 @@ AM_CFLAGS = $(GLOBAL_CFLAGS) $(libxml2_CFLAGS) $(libglib2_CFLAGS)
4AM_LDFLAGS = $(libxml2_LIBS) $(libglib2_LIBS) 4AM_LDFLAGS = $(libxml2_LIBS) $(libglib2_LIBS)
5 5
6lib_LTLIBRARIES = libplist.la 6lib_LTLIBRARIES = libplist.la
7libplist_la_SOURCES = plist.c bplist.c xplist.c utils.c 7libplist_la_SOURCES = plist.c bplist.c xplist.c
diff --git a/src/bplist.c b/src/bplist.c
index 78bbe4a..d05c2e5 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -380,12 +380,6 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
380 uint64_t root_object = be64dec(trailer + BPLIST_TRL_ROOTOBJ_IDX); 380 uint64_t root_object = be64dec(trailer + BPLIST_TRL_ROOTOBJ_IDX);
381 uint64_t offset_table_index = be64dec(trailer + BPLIST_TRL_OFFTAB_IDX); 381 uint64_t offset_table_index = be64dec(trailer + BPLIST_TRL_OFFTAB_IDX);
382 382
383 log_debug_msg("Offset size: %i\n", offset_size);
384 log_debug_msg("Ref size: %i\n", dict_param_size);
385 log_debug_msg("Number of objects: %lli\n", num_objects);
386 log_debug_msg("Root object index: %lli\n", root_object);
387 log_debug_msg("Offset table index: %lli\n", offset_table_index);
388
389 if (num_objects == 0) 383 if (num_objects == 0)
390 return; 384 return;
391 385
@@ -403,10 +397,8 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
403 for (i = 0; i < num_objects; i++) { 397 for (i = 0; i < num_objects; i++) {
404 current_offset = UINT_TO_HOST(offset_table + i * offset_size, offset_size); 398 current_offset = UINT_TO_HOST(offset_table + i * offset_size, offset_size);
405 399
406 log_debug_msg("parse_nodes: current_offset = %i\n", current_offset);
407 char *obj = plist_bin + current_offset; 400 char *obj = plist_bin + current_offset;
408 nodeslist[i] = parse_bin_node(obj, dict_param_size, &obj); 401 nodeslist[i] = parse_bin_node(obj, dict_param_size, &obj);
409 log_debug_msg("parse_nodes: parse_raw_node done\n");
410 } 402 }
411 403
412 //setup children for structured types 404 //setup children for structured types
@@ -415,12 +407,10 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
415 407
416 for (i = 0; i < num_objects; i++) { 408 for (i = 0; i < num_objects; i++) {
417 409
418 log_debug_msg("parse_nodes: on node %i\n", i);
419 plist_data_t data = plist_get_data(nodeslist[i]); 410 plist_data_t data = plist_get_data(nodeslist[i]);
420 411
421 switch (data->type) { 412 switch (data->type) {
422 case PLIST_DICT: 413 case PLIST_DICT:
423 log_debug_msg("parse_nodes: dictionary found\n");
424 for (j = 0; j < data->length; j++) { 414 for (j = 0; j < data->length; j++) {
425 str_i = j * dict_param_size; 415 str_i = j * dict_param_size;
426 str_j = (j + data->length) * dict_param_size; 416 str_j = (j + data->length) * dict_param_size;
@@ -450,7 +440,6 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
450 break; 440 break;
451 441
452 case PLIST_ARRAY: 442 case PLIST_ARRAY:
453 log_debug_msg("parse_nodes: array found\n");
454 for (j = 0; j < data->length; j++) { 443 for (j = 0; j < data->length; j++) {
455 str_j = j * dict_param_size; 444 str_j = j * dict_param_size;
456 index1 = UINT_TO_HOST(data->buff + str_j, dict_param_size); 445 index1 = UINT_TO_HOST(data->buff + str_j, dict_param_size);
diff --git a/src/plist.c b/src/plist.c
index f315e7e..0f6d741 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -22,7 +22,6 @@
22 22
23#include <string.h> 23#include <string.h>
24#include <assert.h> 24#include <assert.h>
25#include "utils.h"
26#include "plist.h" 25#include "plist.h"
27#include <stdlib.h> 26#include <stdlib.h>
28#include <stdio.h> 27#include <stdio.h>
@@ -118,6 +117,7 @@ static plist_t plist_add_sub_element(plist_t node, plist_type type, const void *
118 } else 117 } else
119 return NULL; 118 return NULL;
120 } 119 }
120 return NULL;
121} 121}
122 122
123void plist_free(plist_t plist) 123void plist_free(plist_t plist)
diff --git a/src/plist.h b/src/plist.h
index 33f6c20..830da75 100644
--- a/src/plist.h
+++ b/src/plist.h
@@ -30,9 +30,6 @@
30#include <sys/stat.h> 30#include <sys/stat.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <glib.h> 32#include <glib.h>
33#include "utils.h"
34
35
36 33
37 34
38struct plist_data_s { 35struct plist_data_s {
diff --git a/src/utils.c b/src/utils.c
deleted file mode 100644
index 920b347..0000000
--- a/src/utils.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * utils.c
3 * contains utilitary methos for logging and debugging
4 *
5 * Copyright (c) 2008 Jonathan Beck All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21#include <stdarg.h>
22#include <stdio.h>
23#include "utils.h"
24
25int toto_debug = 0;
26
27/**
28 * Sets the level of debugging. Currently the only acceptable values are 0 and
29 * 1.
30 *
31 * @param level Set to 0 for no debugging or 1 for debugging.
32 */
33void iphone_set_debug(int level)
34{
35 toto_debug = level;
36}
37
38void log_debug_msg(const char *format, ...)
39{
40#ifndef STRIP_DEBUG_CODE
41
42 va_list args;
43 /* run the real fprintf */
44 va_start(args, format);
45
46 if (toto_debug)
47 vfprintf(stderr, format, args);
48
49 va_end(args);
50
51#endif
52}
53
54inline void log_debug_buffer(const char *data, const int length)
55{
56#ifndef STRIP_DEBUG_CODE
57
58 /* run the real fprintf */
59 if (toto_debug)
60 fwrite(data, 1, length, stderr);
61#endif
62}
63
64inline void dump_debug_buffer(const char *file, const char *data, const int length)
65{
66#ifndef STRIP_DEBUG_CODE
67
68 /* run the real fprintf */
69 if (toto_debug) {
70 FILE *my_ssl_packet = fopen(file, "w+");
71 fwrite(data, 1, length, my_ssl_packet);
72 fflush(my_ssl_packet);
73 fprintf(stderr, "Wrote SSL packet to drive, too.\n");
74 fclose(my_ssl_packet);
75 }
76#endif
77}
diff --git a/src/utils.h b/src/utils.h
deleted file mode 100644
index 489f610..0000000
--- a/src/utils.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * utils.h
3 * contains utilitary methos for logging and debugging
4 *
5 * Copyright (c) 2008 Jonathan Beck All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef UTILS_H
23#define UTILS_H
24
25#include "libiphone/libiphone.h"
26
27inline void log_debug_msg(const char *format, ...);
28inline void log_debug_buffer(const char *data, const int length);
29inline void dump_debug_buffer(const char *file, const char *data, const int length);
30#endif
diff --git a/src/xplist.c b/src/xplist.c
index f9670f1..0c1a6b9 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -29,8 +29,6 @@
29#include <libxml/parser.h> 29#include <libxml/parser.h>
30#include <libxml/tree.h> 30#include <libxml/tree.h>
31 31
32#include <plist/plist.h>
33#include "utils.h"
34#include "plist.h" 32#include "plist.h"
35 33
36#define XPLIST_TEXT BAD_CAST("text") 34#define XPLIST_TEXT BAD_CAST("text")