summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-04 22:31:43 +0200
committerGravatar Matt Colyer2008-08-05 23:28:10 -0700
commit4b558a53f61005b0ca49665d2da92303f6e14872 (patch)
tree3631ebdcfbf681a239bde3192172d3014b56322b /src/plist.c
parent20a6f8797add1a44aa6ea2cc1d089122d1f39be3 (diff)
downloadlibimobiledevice-4b558a53f61005b0ca49665d2da92303f6e14872.tar.gz
libimobiledevice-4b558a53f61005b0ca49665d2da92303f6e14872.tar.bz2
Store certificates and private keys as PEM files instead of storing them in config file. Added functions to generate proper pairing request.
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/plist.c b/src/plist.c
index 2d2a832..73cdffc 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -29,6 +29,29 @@ const char *plist_base = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
29<plist version=\"1.0\">\n\ 29<plist version=\"1.0\">\n\
30</plist>\0"; 30</plist>\0";
31 31
32char* format_string(char* buf, int cols, int depth)
33{
34 int colw = depth + cols + 1; //new buf cols width
35 int len = strlen(buf);
36 //int nlines = ceil((float)len / (float)cols);
37 int nlines = len / cols + 1;
38 char* new_buf = (char*)malloc(nlines * colw + depth + 1);
39 int i = 0;
40 int j = 0;
41 for (i = 0; i < nlines; i++){
42 new_buf[i * colw] = '\n';
43 for (j = 0; j < depth; j++)
44 new_buf[i * colw + 1 + j] = '\t';
45 memcpy(new_buf + i * colw + 1 + depth, buf + i * cols, cols);
46 }
47 new_buf[len+(1+depth)*nlines] = '\n';
48 for (j = 0; j < depth; j++)
49 new_buf[len+(1+depth)*nlines + 1 + j] = '\t';
50 new_buf[len+(1+depth)*nlines+depth+1] = '\0';
51 free(buf);
52 return new_buf;
53}
54
32xmlDocPtr new_plist() { 55xmlDocPtr new_plist() {
33 char *plist = strdup(plist_base); 56 char *plist = strdup(plist_base);
34 xmlDocPtr plist_xml = xmlReadMemory(plist, strlen(plist), NULL, NULL, 0); 57 xmlDocPtr plist_xml = xmlReadMemory(plist, strlen(plist), NULL, NULL, 0);
@@ -62,10 +85,17 @@ xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode *dict, const char *ke
62 return keyPtr; 85 return keyPtr;
63} 86}
64 87
88xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth) {
89 xmlNode *child;
90 add_child_to_plist(plist, "key", key, dict, depth);
91 child = add_child_to_plist(plist, "dict", value, dict, depth);
92 return child;
93}
94
65xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth) { 95xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth) {
66 xmlNode *keyPtr; 96 xmlNode *keyPtr;
67 keyPtr = add_child_to_plist(plist, "key", key, dict, depth); 97 keyPtr = add_child_to_plist(plist, "key", key, dict, depth);
68 add_child_to_plist(plist, "data", value, dict, depth); 98 add_child_to_plist(plist, "data", format_string(value, 60, depth), dict, depth);
69 return keyPtr; 99 return keyPtr;
70} 100}
71 101