diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Makefile.am | 6 | ||||
| -rw-r--r-- | dev/plutil.c | 118 | ||||
| -rw-r--r-- | dev/plutil.h | 13 |
3 files changed, 1 insertions, 136 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am index 95b4d61..d116581 100644 --- a/dev/Makefile.am +++ b/dev/Makefile.am | |||
| @@ -3,7 +3,7 @@ INCLUDES = -I$(top_srcdir)/include | |||
| 3 | AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g | 3 | AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g |
| 4 | AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) | 4 | AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) |
| 5 | 5 | ||
| 6 | bin_PROGRAMS = iphoneclient lckd-client afccheck plutil | 6 | bin_PROGRAMS = iphoneclient lckd-client afccheck |
| 7 | 7 | ||
| 8 | iphoneclient_SOURCES = main.c | 8 | iphoneclient_SOURCES = main.c |
| 9 | iphoneclient_LDADD = ../src/libiphone.la | 9 | iphoneclient_LDADD = ../src/libiphone.la |
| @@ -18,7 +18,3 @@ afccheck_CFLAGS = $(AM_CFLAGS) | |||
| 18 | afccheck_LDFLAGS = $(AM_LDFLAGS) | 18 | afccheck_LDFLAGS = $(AM_LDFLAGS) |
| 19 | afccheck_LDADD = ../src/libiphone.la | 19 | afccheck_LDADD = ../src/libiphone.la |
| 20 | 20 | ||
| 21 | plutil_SOURCES = plutil.c | ||
| 22 | plutil_CFLAGS = $(AM_CFLAGS) | ||
| 23 | plutil_LDFLAGS = $(AM_LDFLAGS) | ||
| 24 | plutil_LDADD = ../src/libiphone.la | ||
diff --git a/dev/plutil.c b/dev/plutil.c deleted file mode 100644 index 3d93797..0000000 --- a/dev/plutil.c +++ /dev/null | |||
| @@ -1,118 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * main.c for plistutil | ||
| 3 | * right now just prints debug shit | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include "../src/plist.h" | ||
| 7 | #include "plutil.h" | ||
| 8 | #include <glib.h> | ||
| 9 | #include <string.h> | ||
| 10 | #include <stdio.h> | ||
| 11 | #include <stdlib.h> | ||
| 12 | |||
| 13 | |||
| 14 | int main(int argc, char *argv[]) | ||
| 15 | { | ||
| 16 | struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); | ||
| 17 | Options *options = parse_arguments(argc, argv); | ||
| 18 | |||
| 19 | if (!options) { | ||
| 20 | print_usage(); | ||
| 21 | return 0; | ||
| 22 | } | ||
| 23 | |||
| 24 | iphone_set_debug(options->debug); | ||
| 25 | |||
| 26 | //read input file | ||
| 27 | FILE *iplist = fopen(options->in_file, "r"); | ||
| 28 | if (!iplist) | ||
| 29 | return 1; | ||
| 30 | stat(options->in_file, filestats); | ||
| 31 | char *plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1)); | ||
| 32 | fread(plist_entire, sizeof(char), filestats->st_size, iplist); | ||
| 33 | fclose(iplist); | ||
| 34 | |||
| 35 | |||
| 36 | //convert one format to another | ||
| 37 | plist_t root_node = NULL; | ||
| 38 | char *plist_out = NULL; | ||
| 39 | int size = 0; | ||
| 40 | |||
| 41 | if (memcmp(plist_entire, "bplist00", 8) == 0) { | ||
| 42 | bin_to_plist(plist_entire, filestats->st_size, &root_node); | ||
| 43 | plist_to_xml(root_node, &plist_out, &size); | ||
| 44 | } else { | ||
| 45 | xml_to_plist(plist_entire, filestats->st_size, &root_node); | ||
| 46 | plist_to_bin(root_node, &plist_out, &size); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (plist_out) { | ||
| 50 | if (options->out_file != NULL) { | ||
| 51 | FILE *oplist = fopen(options->out_file, "wb"); | ||
| 52 | if (!oplist) | ||
| 53 | return 1; | ||
| 54 | fwrite(plist_out, size, sizeof(char), oplist); | ||
| 55 | fclose(oplist); | ||
| 56 | } | ||
| 57 | //if no output file specified, write to stdout | ||
| 58 | else | ||
| 59 | fwrite(plist_out, size, sizeof(char), stdout); | ||
| 60 | } else | ||
| 61 | printf("ERROR\n"); | ||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | Options *parse_arguments(int argc, char *argv[]) | ||
| 66 | { | ||
| 67 | int i = 0; | ||
| 68 | |||
| 69 | Options *options = (Options *) malloc(sizeof(Options)); | ||
| 70 | memset(options, 0, sizeof(Options)); | ||
| 71 | |||
| 72 | for (i = 1; i < argc; i++) { | ||
| 73 | if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i")) { | ||
| 74 | if ((i + 1) == argc) { | ||
| 75 | free(options); | ||
| 76 | return NULL; | ||
| 77 | } | ||
| 78 | options->in_file = argv[i + 1]; | ||
| 79 | i++; | ||
| 80 | continue; | ||
| 81 | } | ||
| 82 | |||
| 83 | if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o")) { | ||
| 84 | if ((i + 1) == argc) { | ||
| 85 | free(options); | ||
| 86 | return NULL; | ||
| 87 | } | ||
| 88 | options->out_file = argv[i + 1]; | ||
| 89 | i++; | ||
| 90 | continue; | ||
| 91 | } | ||
| 92 | |||
| 93 | if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v")) { | ||
| 94 | options->debug = 1; | ||
| 95 | } | ||
| 96 | |||
| 97 | if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { | ||
| 98 | free(options); | ||
| 99 | return NULL; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | if (!options->in_file /*|| !options->out_file */ ) { | ||
| 104 | free(options); | ||
| 105 | return NULL; | ||
| 106 | } | ||
| 107 | |||
| 108 | return options; | ||
| 109 | } | ||
| 110 | |||
| 111 | void print_usage() | ||
| 112 | { | ||
| 113 | printf("Usage: plistutil -i|--infile in_file.plist -o|--outfile out_file.plist [--debug]\n"); | ||
| 114 | printf("\n"); | ||
| 115 | printf("\t-i or --infile: The file to read in.\n"); | ||
| 116 | printf("\t-o or --outfile: The file to convert to.\n"); | ||
| 117 | printf("\t-d, -v or --debug: Provide extended debug information.\n\n"); | ||
| 118 | } | ||
diff --git a/dev/plutil.h b/dev/plutil.h deleted file mode 100644 index 2146307..0000000 --- a/dev/plutil.h +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | |||
| 2 | /* | ||
| 3 | * main.h - header for plistutil | ||
| 4 | * Written by FxChiP | ||
| 5 | */ | ||
| 6 | |||
| 7 | typedef struct _options { | ||
| 8 | char *in_file, *out_file; | ||
| 9 | uint8_t debug, in_fmt, out_fmt; | ||
| 10 | } Options; | ||
| 11 | |||
| 12 | Options *parse_arguments(int argc, char *argv[]); | ||
| 13 | void print_usage(); | ||
