summaryrefslogtreecommitdiffstats
path: root/plistutil
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-12-13 00:44:17 +0100
committerGravatar Nikias Bassen2013-12-13 00:44:17 +0100
commita798afc8b5b00a43f4b121168e0419df2d398338 (patch)
treec178d7a149028944254511d03f91266ca43cfcbd /plistutil
parent3b7647499474619b3e24bf01105b6b037887a0ed (diff)
downloadlibplist-a798afc8b5b00a43f4b121168e0419df2d398338.tar.gz
libplist-a798afc8b5b00a43f4b121168e0419df2d398338.tar.bz2
change build system to autotools
Diffstat (limited to 'plistutil')
-rw-r--r--plistutil/CMakeLists.txt9
-rw-r--r--plistutil/plistutil.c164
-rw-r--r--plistutil/plistutil.h29
3 files changed, 0 insertions, 202 deletions
diff --git a/plistutil/CMakeLists.txt b/plistutil/CMakeLists.txt
deleted file mode 100644
index 68382ee..0000000
--- a/plistutil/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
1
2SET(plistutil_SRC
3 plistutil.c)
4
5ADD_EXECUTABLE(plistutil ${plistutil_SRC})
6TARGET_LINK_LIBRARIES(plistutil plist)
7SET_TARGET_PROPERTIES( plistutil PROPERTIES VERSION ${PLISTUTIL_VERSION} )
8
9INSTALL( TARGETS plistutil RUNTIME DESTINATION bin COMPONENT plistutil )
diff --git a/plistutil/plistutil.c b/plistutil/plistutil.c
deleted file mode 100644
index 3e09bb2..0000000
--- a/plistutil/plistutil.c
+++ /dev/null
@@ -1,164 +0,0 @@
1/*
2 * plistutil.c
3 * source for plist convertion tool
4 *
5 * Copyright (c) 2008 Zach C. 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
23#include "plist/plist.h"
24#include "plistutil.h"
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <sys/stat.h>
30
31#ifdef _MSC_VER
32#pragma warning(disable:4996)
33#endif
34
35
36int main(int argc, char *argv[])
37{
38 FILE *iplist = NULL;
39 plist_t root_node = NULL;
40 char *plist_out = NULL;
41 uint32_t size = 0;
42 int read_size = 0;
43 char *plist_entire = NULL;
44 struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
45 Options *options = parse_arguments(argc, argv);
46
47 if (!options)
48 {
49 print_usage();
50 free(filestats);
51 return 0;
52 }
53 //read input file
54 iplist = fopen(options->in_file, "rb");
55 if (!iplist)
56 return 1;
57 stat(options->in_file, filestats);
58 plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1));
59 read_size = fread(plist_entire, sizeof(char), filestats->st_size, iplist);
60 fclose(iplist);
61
62
63 //convert one format to another
64
65
66 if (memcmp(plist_entire, "bplist00", 8) == 0)
67 {
68 plist_from_bin(plist_entire, read_size, &root_node);
69 plist_to_xml(root_node, &plist_out, &size);
70 }
71 else
72 {
73 plist_from_xml(plist_entire, read_size, &root_node);
74 plist_to_bin(root_node, &plist_out, &size);
75 }
76 plist_free(root_node);
77 free(plist_entire);
78 free(filestats);
79
80 if (plist_out)
81 {
82 if (options->out_file != NULL)
83 {
84 FILE *oplist = fopen(options->out_file, "wb");
85 if (!oplist)
86 return 1;
87 fwrite(plist_out, size, sizeof(char), oplist);
88 fclose(oplist);
89 }
90 //if no output file specified, write to stdout
91 else
92 fwrite(plist_out, size, sizeof(char), stdout);
93
94 free(plist_out);
95 }
96 else
97 printf("ERROR\n");
98
99 free(options);
100 return 0;
101}
102
103Options *parse_arguments(int argc, char *argv[])
104{
105 int i = 0;
106
107 Options *options = (Options *) malloc(sizeof(Options));
108 memset(options, 0, sizeof(Options));
109
110 for (i = 1; i < argc; i++)
111 {
112 if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i"))
113 {
114 if ((i + 1) == argc)
115 {
116 free(options);
117 return NULL;
118 }
119 options->in_file = argv[i + 1];
120 i++;
121 continue;
122 }
123
124 if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o"))
125 {
126 if ((i + 1) == argc)
127 {
128 free(options);
129 return NULL;
130 }
131 options->out_file = argv[i + 1];
132 i++;
133 continue;
134 }
135
136 if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v"))
137 {
138 options->debug = 1;
139 }
140
141 if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
142 {
143 free(options);
144 return NULL;
145 }
146 }
147
148 if (!options->in_file /*|| !options->out_file */ )
149 {
150 free(options);
151 return NULL;
152 }
153
154 return options;
155}
156
157void print_usage()
158{
159 printf("Usage: plistutil -i|--infile in_file.plist -o|--outfile out_file.plist [--debug]\n");
160 printf("\n");
161 printf("\t-i or --infile: The file to read in.\n");
162 printf("\t-o or --outfile: The file to convert to.\n");
163 printf("\t-d, -v or --debug: Provide extended debug information.\n\n");
164}
diff --git a/plistutil/plistutil.h b/plistutil/plistutil.h
deleted file mode 100644
index 40421a3..0000000
--- a/plistutil/plistutil.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * plistutil.h
3 * header for plist convertion tool
4 *
5 * Copyright (c) 2008 Zach C. 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
22typedef struct _options
23{
24 char *in_file, *out_file;
25 uint8_t debug, in_fmt, out_fmt;
26} Options;
27
28Options *parse_arguments(int argc, char *argv[]);
29void print_usage();