From e1b22c51edd2c3b416d111a63e1a84ab3ba7817e Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Mon, 11 Aug 2008 22:32:01 +0200 Subject: first shot at setting up a library --- autogen.sh | 1 + configure.ac | 3 +++ include/libiphone/libiphone.h | 46 +++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 12 +++++++++-- src/iphone.c | 4 ++-- src/iphone.h | 3 +-- src/lockdown.c | 2 +- src/lockdown.h | 5 ++++- 8 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 include/libiphone/libiphone.h diff --git a/autogen.sh b/autogen.sh index 8593f86..c17ea96 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,5 +1,6 @@ #!/bin/sh aclocal +libtoolize autoheader automake --add-missing autoconf diff --git a/configure.ac b/configure.ac index 03c7925..28b6138 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,9 @@ AM_INIT_AUTOMAKE(libiphone, 0.1.0) AC_CONFIG_SRCDIR([src/]) AC_CONFIG_HEADER([config.h]) +AC_PROG_LIBTOOL + + # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h new file mode 100644 index 0000000..9e559a1 --- /dev/null +++ b/include/libiphone/libiphone.h @@ -0,0 +1,46 @@ +/* + * libiphone.h + * Main include of libiphone + * + * 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 + */ + +#ifndef LIBIPHONE_H +#define LIBIPHONE_H + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +typedef struct iPhone *iPhone_t; +typedef struct lockdownd_client *lockdownd_client_t; + + +void free_iPhone(iPhone_t victim); +iPhone_t get_iPhone(); +int lockdownd_init(iPhone_t phone, lockdownd_client_t *control); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/Makefile.am b/src/Makefile.am index e225512..f26deb1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,19 @@ +INCLUDES = -I$(top_srcdir)/include + AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libfuse_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) -g AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libfuse_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) bin_PROGRAMS = iphoneclient ifuse libiphone-initconf -iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c -ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c +iphoneclient_SOURCES = main.c +iphoneclient_LDADD = libiphone.la libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS) libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS) +ifuse_SOURCES = ifuse.c +ifuse_LDADD = libiphone.la + +lib_LTLIBRARIES = libiphone.la +libiphone_la_SOURCES = usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c + diff --git a/src/iphone.c b/src/iphone.c index d8bb9ae..e0e150f 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -34,7 +34,7 @@ extern int debug; * @return A structure with data on the first iPhone it finds. (Or NULL, on * error) */ -iPhone *get_iPhone() { +iPhone_t get_iPhone() { iPhone *phone = (iPhone*)malloc(sizeof(iPhone)); struct usb_bus *bus, *busses; struct usb_device *dev; @@ -129,7 +129,7 @@ iPhone *get_iPhone() { * * @param phone A pointer to an iPhone structure. */ -void free_iPhone(iPhone *phone) { +void free_iPhone(iPhone_t phone) { if (phone->buffer) free(phone->buffer); if (phone->device) { usb_release_interface(phone->device, 1); diff --git a/src/iphone.h b/src/iphone.h index ec5e70d..746941f 100644 --- a/src/iphone.h +++ b/src/iphone.h @@ -28,6 +28,7 @@ #endif #include +#include #define BULKIN 0x85 #define BULKOUT 0x04 @@ -39,8 +40,6 @@ typedef struct { } iPhone; // Function definitions -void free_iPhone(iPhone *victim); -iPhone *get_iPhone(); int send_to_phone(iPhone *phone, char *data, int datalen); int recv_from_phone(iPhone *phone, char *data, int datalen); #endif diff --git a/src/lockdown.c b/src/lockdown.c index c8275eb..452ee0e 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -307,7 +307,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key * * @return 1 on success and 0 on failure */ -int lockdownd_init(iPhone *phone, lockdownd_client **control) +int lockdownd_init(iPhone_t phone, lockdownd_client_t *control) { int ret = 0; char *host_id = NULL; diff --git a/src/lockdown.h b/src/lockdown.h index c542d65..a16e148 100644 --- a/src/lockdown.h +++ b/src/lockdown.h @@ -27,6 +27,10 @@ #include #include +#include + + + typedef struct { usbmux_connection *connection; @@ -36,7 +40,6 @@ typedef struct { int gtls_buffer_hack_len; } lockdownd_client; -int lockdownd_init(iPhone *phone, lockdownd_client **control); char *lockdownd_generate_hostid(); lockdownd_client *new_lockdownd_client(iPhone *phone); -- cgit v1.1-32-gdbae