diff options
| author | 2008-12-13 12:21:03 +0100 | |
|---|---|---|
| committer | 2008-12-13 12:21:03 +0100 | |
| commit | 3fdd24aea06a9bf38d9d34fb8bccbb7023ed3100 (patch) | |
| tree | 1080d26eca01c885efb33f3f98821a981a25e8b4 /dev | |
| parent | 3d8ba053deeacd74e621469d3d45d1db38ee411a (diff) | |
| download | libplist-3fdd24aea06a9bf38d9d34fb8bccbb7023ed3100.tar.gz libplist-3fdd24aea06a9bf38d9d34fb8bccbb7023ed3100.tar.bz2  | |
Fork libiphone and remove anything non plist specific.
Update library and make related files acordingly .
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Makefile.am | 24 | ||||
| -rw-r--r-- | dev/afccheck.c | 134 | ||||
| -rw-r--r-- | dev/lckdclient.c | 101 | ||||
| -rw-r--r-- | dev/main.c | 154 | ||||
| -rw-r--r-- | dev/plutil.c | 118 | ||||
| -rw-r--r-- | dev/plutil.h | 13 | 
6 files changed, 0 insertions, 544 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am deleted file mode 100644 index 95b4d61..0000000 --- a/dev/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -INCLUDES = -I$(top_srcdir)/include - -AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g -AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) - -bin_PROGRAMS = iphoneclient lckd-client afccheck plutil - -iphoneclient_SOURCES = main.c -iphoneclient_LDADD = ../src/libiphone.la - -lckd_client_SOURCES = lckdclient.c -lckd_client_CFLAGS = $(AM_CFLAGS) -lckd_client_LDFLAGS = -lreadline $(AM_LDFLAGS) -lckd_client_LDADD = ../src/libiphone.la - -afccheck_SOURCES = afccheck.c -afccheck_CFLAGS = $(AM_CFLAGS) -afccheck_LDFLAGS = $(AM_LDFLAGS) -afccheck_LDADD = ../src/libiphone.la - -plutil_SOURCES = plutil.c -plutil_CFLAGS = $(AM_CFLAGS) -plutil_LDFLAGS = $(AM_LDFLAGS) -plutil_LDADD = ../src/libiphone.la diff --git a/dev/afccheck.c b/dev/afccheck.c deleted file mode 100644 index 0ff420a..0000000 --- a/dev/afccheck.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * afccheck.c - * creates threads and check communication through AFC is done rigth - * - * Copyright (c) 2008 Jonathan Beck All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - *  - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * Lesser General Public License for more details. - *  - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA  - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <glib.h> - -#include <libiphone/libiphone.h> - -#define BUFFER_SIZE 20000 -#define NB_THREADS 10 - - -typedef struct { -	iphone_afc_client_t afc; -	int id; -} param; - - -void check_afc(gpointer data) -{ -	//prepare a buffer -	int buffersize = BUFFER_SIZE * sizeof(int); -	int *buf = (int *) malloc(buffersize); -	int *buf2 = (int *) malloc(buffersize); -	int bytes = 0; -	//fill buffer -	int i = 0; -	for (i = 0; i < BUFFER_SIZE; i++) { -		buf[i] = ((param *) data)->id * i; -	} - -	//now  writes buffer on iphone -	iphone_afc_file_t file = NULL; -	char path[50]; -	sprintf(path, "/Buf%i", ((param *) data)->id); -	iphone_afc_open_file(((param *) data)->afc, path, IPHONE_AFC_FILE_WRITE, &file); -	iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); -	iphone_afc_close_file(((param *) data)->afc, file); -	file = NULL; -	if (bytes != buffersize) -		printf("Write operation failed\n"); - -	//now read it -	bytes = 0; -	iphone_afc_open_file(((param *) data)->afc, path, IPHONE_AFC_FILE_READ, &file); -	iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); -	iphone_afc_close_file(((param *) data)->afc, file); -	if (bytes != buffersize) -		printf("Read operation failed\n"); - -	//compare buffers -	for (i = 0; i < BUFFER_SIZE; i++) { -		if (buf[i] != buf2[i]) { -			printf("Buffers are differents, stream corrupted\n"); -			break; -		} -	} - -	//cleanup -	iphone_afc_delete_file(((param *) data)->afc, path); -	g_thread_exit(0); -} - -int main(int argc, char *argv[]) -{ -	iphone_lckd_client_t control = NULL; -	iphone_device_t phone = NULL; -	GError *err; -	int port = 0; -	iphone_afc_client_t afc = NULL; - -	if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { -		printf("No iPhone found, is it plugged in?\n"); -		return 1; -	} - -	if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { -		iphone_free_device(phone); -		return 1; -	} - -	if (IPHONE_E_SUCCESS == iphone_lckd_start_service(control, "com.apple.afc", &port) && !port) { -		iphone_lckd_free_client(control); -		iphone_free_device(phone); -		fprintf(stderr, "Something went wrong when starting AFC."); -		return 1; -	} - -	iphone_afc_new_client(phone, 3432, port, &afc); - -	//makes sure thread environment is available -	if (!g_thread_supported()) -		g_thread_init(NULL); - -	GThread *threads[NB_THREADS]; -	param data[NB_THREADS]; - -	int i = 0; -	for (i = 0; i < NB_THREADS; i++) { -		data[i].afc = afc; -		data[i].id = i + 1; -		threads[i] = g_thread_create((GThreadFunc) check_afc, data + i, TRUE, &err); -	} - -	for (i = 0; i < NB_THREADS; i++) { -		g_thread_join(threads[i]); -	} - - -	iphone_lckd_free_client(control); -	iphone_free_device(phone); - -	return 0; -} diff --git a/dev/lckdclient.c b/dev/lckdclient.c deleted file mode 100644 index c96f052..0000000 --- a/dev/lckdclient.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * lckdclient.c - * Rudimentary command line interface to the Lockdown protocol - * - * Copyright (c) 2008 Jonathan Beck All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - *  - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * Lesser General Public License for more details. - *  - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA  - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> -#include <readline/readline.h> -#include <readline/history.h> - -#include <libiphone/libiphone.h> - - -int main(int argc, char *argv[]) -{ -	int bytes = 0, port = 0, i = 0; -	iphone_lckd_client_t control = NULL; -	iphone_device_t phone = NULL; - -	iphone_set_debug(1); - -	if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { -		printf("No iPhone found, is it plugged in?\n"); -		return -1; -	} - -	if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { -		iphone_free_device(phone); -		return -1; -	} - -	char *uid = NULL; -	if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) { -		printf("DeviceUniqueID : %s\n", uid); -		free(uid); -	} - -	using_history(); -	int loop = TRUE; -	while (loop) { -		char *cmd = readline("> "); -		if (cmd) { - -			gchar **args = g_strsplit(cmd, " ", 0); - -			int len = 0; -			if (args) { -				while (*(args + len)) { -					g_strstrip(*(args + len)); -					len++; -				} -			} - -			if (len > 0) { -				add_history(cmd); -				if (!strcmp(*args, "quit")) -					loop = FALSE; - -				if (!strcmp(*args, "get") && len == 3) { -					char *value = NULL; -					if (IPHONE_E_SUCCESS == lockdownd_generic_get_value(control, *(args + 1), *(args + 2), &value)) -						printf("Success : value = %s\n", value); -					else -						printf("Error\n"); -				} - -				if (!strcmp(*args, "start") && len == 2) { -					int port = 0; -					iphone_lckd_start_service(control, *(args + 1), &port); -					printf("%i\n", port); -				} -			} -			g_strfreev(args); -		} -		free(cmd); -		cmd = NULL; -	} -	clear_history(); -	iphone_lckd_free_client(control); -	iphone_free_device(phone); - -	return 0; -} diff --git a/dev/main.c b/dev/main.c deleted file mode 100644 index 4974eef..0000000 --- a/dev/main.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * main.c - * Rudimentary interface to the iPhone - * - * Copyright (c) 2008 Zach C. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - *  - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * Lesser General Public License for more details. - *  - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA  - */ - -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <usb.h> - -#include <libxml/parser.h> -#include <libxml/tree.h> - -#include <libiphone/libiphone.h> - - -int main(int argc, char *argv[]) -{ -	int bytes = 0, port = 0, i = 0; -	iphone_lckd_client_t control = NULL; -	iphone_device_t phone = NULL; - -	if (argc > 1 && !strcasecmp(argv[1], "--debug")) { -		iphone_set_debug(1); -	} else { -		iphone_set_debug(0); -	} - -	if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { -		printf("No iPhone found, is it plugged in?\n"); -		return -1; -	} - -	if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { -		iphone_free_device(phone); -		return -1; -	} - -	char *uid = NULL; -	if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) { -		printf("DeviceUniqueID : %s\n", uid); -		free(uid); -	} - -	iphone_lckd_start_service(control, "com.apple.afc", &port); - -	if (port) { -		iphone_afc_client_t afc = NULL; -		iphone_afc_new_client(phone, 3432, port, &afc); -		if (afc) { -			char **dirs = NULL; -			iphone_afc_get_dir_list(afc, "/eafaedf", &dirs); -			if (!dirs) -				iphone_afc_get_dir_list(afc, "/", &dirs); -			printf("Directory time.\n"); -			for (i = 0; dirs[i]; i++) { -				printf("/%s\n", dirs[i]); -			} - -			g_strfreev(dirs); -			iphone_afc_get_devinfo(afc, &dirs); -			if (dirs) { -				for (i = 0; dirs[i]; i += 2) { -					printf("%s: %s\n", dirs[i], dirs[i + 1]); -				} -			} -			g_strfreev(dirs); - -			iphone_afc_file_t my_file = NULL; -			struct stat stbuf; -			iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); -			if (IPHONE_E_SUCCESS == -				iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { -				printf("A file size: %i\n", (int) stbuf.st_size); -				char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); -				iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); -				if (bytes >= 0) { -					printf("The file's data:\n"); -					fwrite(file_data, 1, bytes, stdout); -				} -				printf("\nClosing my file.\n"); -				iphone_afc_close_file(afc, my_file); -				free(file_data); -			} else -				printf("couldn't open a file\n"); - -			iphone_afc_open_file(afc, "/readme.libiphone.fx", IPHONE_AFC_FILE_WRITE, &my_file); -			if (my_file) { -				char *outdatafile = strdup("this is a bitchin text file\n"); -				iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); -				free(outdatafile); -				if (bytes > 0) -					printf("Wrote a surprise. ;)\n"); -				else -					printf("I wanted to write a surprise, but... :(\n"); -				iphone_afc_close_file(afc, my_file); -			} -			printf("Deleting a file...\n"); -			bytes = iphone_afc_delete_file(afc, "/delme"); -			if (bytes) -				printf("Success.\n"); -			else -				printf("Failure. (expected unless you have a /delme file on your phone)\n"); - -			printf("Renaming a file...\n"); -			bytes = iphone_afc_rename_file(afc, "/renme", "/renme2"); -			if (bytes > 0) -				printf("Success.\n"); -			else -				printf("Failure. (expected unless you have a /renme file on your phone)\n"); - -			printf("Seek & read\n"); -			iphone_afc_open_file(afc, "/readme.libiphone.fx", IPHONE_AFC_FILE_READ, &my_file); -			if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5)) -				printf("WARN: SEEK DID NOT WORK\n"); -			char *threeletterword = (char *) malloc(sizeof(char) * 5); -			iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes); -			threeletterword[3] = '\0'; -			if (bytes > 0) -				printf("Result: %s\n", threeletterword); -			else -				printf("Couldn't read!\n"); -			free(threeletterword); -			iphone_afc_close_file(afc, my_file); - -		} -		iphone_afc_free_client(afc); -	} else { -		printf("Start service failure.\n"); -	} - -	printf("All done.\n"); - -	iphone_lckd_free_client(control); -	iphone_free_device(phone); - -	return 0; -} 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 @@ -/* - * main.c for plistutil - * right now just prints debug shit - */ - -#include "../src/plist.h" -#include "plutil.h" -#include <glib.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - - -int main(int argc, char *argv[]) -{ -	struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); -	Options *options = parse_arguments(argc, argv); - -	if (!options) { -		print_usage(); -		return 0; -	} - -	iphone_set_debug(options->debug); - -	//read input file -	FILE *iplist = fopen(options->in_file, "r"); -	if (!iplist) -		return 1; -	stat(options->in_file, filestats); -	char *plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1)); -	fread(plist_entire, sizeof(char), filestats->st_size, iplist); -	fclose(iplist); - - -	//convert one format to another -	plist_t root_node = NULL; -	char *plist_out = NULL; -	int size = 0; - -	if (memcmp(plist_entire, "bplist00", 8) == 0) { -		bin_to_plist(plist_entire, filestats->st_size, &root_node); -		plist_to_xml(root_node, &plist_out, &size); -	} else { -		xml_to_plist(plist_entire, filestats->st_size, &root_node); -		plist_to_bin(root_node, &plist_out, &size); -	} - -	if (plist_out) { -		if (options->out_file != NULL) { -			FILE *oplist = fopen(options->out_file, "wb"); -			if (!oplist) -				return 1; -			fwrite(plist_out, size, sizeof(char), oplist); -			fclose(oplist); -		} -		//if no output file specified, write to stdout -		else -			fwrite(plist_out, size, sizeof(char), stdout); -	} else -		printf("ERROR\n"); -	return 0; -} - -Options *parse_arguments(int argc, char *argv[]) -{ -	int i = 0; - -	Options *options = (Options *) malloc(sizeof(Options)); -	memset(options, 0, sizeof(Options)); - -	for (i = 1; i < argc; i++) { -		if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i")) { -			if ((i + 1) == argc) { -				free(options); -				return NULL; -			} -			options->in_file = argv[i + 1]; -			i++; -			continue; -		} - -		if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o")) { -			if ((i + 1) == argc) { -				free(options); -				return NULL; -			} -			options->out_file = argv[i + 1]; -			i++; -			continue; -		} - -		if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v")) { -			options->debug = 1; -		} - -		if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { -			free(options); -			return NULL; -		} -	} - -	if (!options->in_file /*|| !options->out_file */ ) { -		free(options); -		return NULL; -	} - -	return options; -} - -void print_usage() -{ -	printf("Usage: plistutil -i|--infile in_file.plist -o|--outfile out_file.plist [--debug]\n"); -	printf("\n"); -	printf("\t-i or --infile: The file to read in.\n"); -	printf("\t-o or --outfile: The file to convert to.\n"); -	printf("\t-d, -v or --debug: Provide extended debug information.\n\n"); -} 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 @@ - -/*  - * main.h - header for plistutil - * Written by FxChiP - */ - -typedef struct _options { -	char *in_file, *out_file; -	uint8_t debug, in_fmt, out_fmt; -} Options; - -Options *parse_arguments(int argc, char *argv[]); -void print_usage();  | 
