summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-11 22:32:01 +0200
committerGravatar Jonathan Beck2008-08-31 19:27:19 +0200
commite1b22c51edd2c3b416d111a63e1a84ab3ba7817e (patch)
tree5c22a2f6ab33927ab61b9e43c9382e0a2ffd8734
parentde4b279089d40131346cbd28e4f27b6e9716fab9 (diff)
downloadlibimobiledevice-e1b22c51edd2c3b416d111a63e1a84ab3ba7817e.tar.gz
libimobiledevice-e1b22c51edd2c3b416d111a63e1a84ab3ba7817e.tar.bz2
first shot at setting up a library
-rwxr-xr-xautogen.sh1
-rw-r--r--configure.ac3
-rw-r--r--include/libiphone/libiphone.h46
-rw-r--r--src/Makefile.am12
-rw-r--r--src/iphone.c4
-rw-r--r--src/iphone.h3
-rw-r--r--src/lockdown.c2
-rw-r--r--src/lockdown.h5
8 files changed, 68 insertions, 8 deletions
diff --git a/autogen.sh b/autogen.sh
index 8593f86..c17ea96 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,5 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2aclocal 2aclocal
3libtoolize
3autoheader 4autoheader
4automake --add-missing 5automake --add-missing
5autoconf 6autoconf
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)
7AC_CONFIG_SRCDIR([src/]) 7AC_CONFIG_SRCDIR([src/])
8AC_CONFIG_HEADER([config.h]) 8AC_CONFIG_HEADER([config.h])
9 9
10AC_PROG_LIBTOOL
11
12
10# Checks for programs. 13# Checks for programs.
11AC_PROG_CC 14AC_PROG_CC
12AM_PROG_CC_C_O 15AM_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 @@
1/*
2 * libiphone.h
3 * Main include of libiphone
4 *
5 * Copyright (c) 2008 Jonathan Beck 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#ifndef LIBIPHONE_H
23#define LIBIPHONE_H
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29
30
31
32
33typedef struct iPhone *iPhone_t;
34typedef struct lockdownd_client *lockdownd_client_t;
35
36
37void free_iPhone(iPhone_t victim);
38iPhone_t get_iPhone();
39int lockdownd_init(iPhone_t phone, lockdownd_client_t *control);
40
41#ifdef __cplusplus
42}
43#endif
44
45#endif
46
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 @@
1INCLUDES = -I$(top_srcdir)/include
2
1AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libfuse_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) -g 3AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libfuse_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) -g
2AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libfuse_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) 4AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libfuse_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS)
3 5
4bin_PROGRAMS = iphoneclient ifuse libiphone-initconf 6bin_PROGRAMS = iphoneclient ifuse libiphone-initconf
5iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c 7iphoneclient_SOURCES = main.c
6ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c 8iphoneclient_LDADD = libiphone.la
7 9
8libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c 10libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c
9libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS) 11libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS)
10libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS) 12libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS)
11 13
14ifuse_SOURCES = ifuse.c
15ifuse_LDADD = libiphone.la
16
17lib_LTLIBRARIES = libiphone.la
18libiphone_la_SOURCES = usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c
19
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;
34 * @return A structure with data on the first iPhone it finds. (Or NULL, on 34 * @return A structure with data on the first iPhone it finds. (Or NULL, on
35 * error) 35 * error)
36 */ 36 */
37iPhone *get_iPhone() { 37iPhone_t get_iPhone() {
38 iPhone *phone = (iPhone*)malloc(sizeof(iPhone)); 38 iPhone *phone = (iPhone*)malloc(sizeof(iPhone));
39 struct usb_bus *bus, *busses; 39 struct usb_bus *bus, *busses;
40 struct usb_device *dev; 40 struct usb_device *dev;
@@ -129,7 +129,7 @@ iPhone *get_iPhone() {
129 * 129 *
130 * @param phone A pointer to an iPhone structure. 130 * @param phone A pointer to an iPhone structure.
131 */ 131 */
132void free_iPhone(iPhone *phone) { 132void free_iPhone(iPhone_t phone) {
133 if (phone->buffer) free(phone->buffer); 133 if (phone->buffer) free(phone->buffer);
134 if (phone->device) { 134 if (phone->device) {
135 usb_release_interface(phone->device, 1); 135 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 @@
28#endif 28#endif
29 29
30#include <usb.h> 30#include <usb.h>
31#include <libiphone/libiphone.h>
31 32
32#define BULKIN 0x85 33#define BULKIN 0x85
33#define BULKOUT 0x04 34#define BULKOUT 0x04
@@ -39,8 +40,6 @@ typedef struct {
39} iPhone; 40} iPhone;
40 41
41// Function definitions 42// Function definitions
42void free_iPhone(iPhone *victim);
43iPhone *get_iPhone();
44int send_to_phone(iPhone *phone, char *data, int datalen); 43int send_to_phone(iPhone *phone, char *data, int datalen);
45int recv_from_phone(iPhone *phone, char *data, int datalen); 44int recv_from_phone(iPhone *phone, char *data, int datalen);
46#endif 45#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
307 * 307 *
308 * @return 1 on success and 0 on failure 308 * @return 1 on success and 0 on failure
309 */ 309 */
310int lockdownd_init(iPhone *phone, lockdownd_client **control) 310int lockdownd_init(iPhone_t phone, lockdownd_client_t *control)
311{ 311{
312 int ret = 0; 312 int ret = 0;
313 char *host_id = NULL; 313 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 @@
27 27
28#include <gnutls/gnutls.h> 28#include <gnutls/gnutls.h>
29#include <string.h> 29#include <string.h>
30#include <libiphone/libiphone.h>
31
32
33
30 34
31typedef struct { 35typedef struct {
32 usbmux_connection *connection; 36 usbmux_connection *connection;
@@ -36,7 +40,6 @@ typedef struct {
36 int gtls_buffer_hack_len; 40 int gtls_buffer_hack_len;
37} lockdownd_client; 41} lockdownd_client;
38 42
39int lockdownd_init(iPhone *phone, lockdownd_client **control);
40char *lockdownd_generate_hostid(); 43char *lockdownd_generate_hostid();
41 44
42lockdownd_client *new_lockdownd_client(iPhone *phone); 45lockdownd_client *new_lockdownd_client(iPhone *phone);