Commit e1b22c51 authored by Jonathan Beck's avatar Jonathan Beck

first shot at setting up a library

parent de4b2790
#!/bin/sh #!/bin/sh
aclocal aclocal
libtoolize
autoheader autoheader
automake --add-missing automake --add-missing
autoconf autoconf
...@@ -7,6 +7,9 @@ AM_INIT_AUTOMAKE(libiphone, 0.1.0) ...@@ -7,6 +7,9 @@ AM_INIT_AUTOMAKE(libiphone, 0.1.0)
AC_CONFIG_SRCDIR([src/]) AC_CONFIG_SRCDIR([src/])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
AC_PROG_LIBTOOL
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O AM_PROG_CC_C_O
......
/*
* 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
INCLUDES = -I$(top_srcdir)/include
AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libfuse_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) -g 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) AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libfuse_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS)
bin_PROGRAMS = iphoneclient ifuse libiphone-initconf bin_PROGRAMS = iphoneclient ifuse libiphone-initconf
iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c iphoneclient_SOURCES = main.c
ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c iphoneclient_LDADD = libiphone.la
libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c
libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS) libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS)
libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS) 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
...@@ -34,7 +34,7 @@ extern int debug; ...@@ -34,7 +34,7 @@ extern int debug;
* @return A structure with data on the first iPhone it finds. (Or NULL, on * @return A structure with data on the first iPhone it finds. (Or NULL, on
* error) * error)
*/ */
iPhone *get_iPhone() { iPhone_t get_iPhone() {
iPhone *phone = (iPhone*)malloc(sizeof(iPhone)); iPhone *phone = (iPhone*)malloc(sizeof(iPhone));
struct usb_bus *bus, *busses; struct usb_bus *bus, *busses;
struct usb_device *dev; struct usb_device *dev;
...@@ -129,7 +129,7 @@ iPhone *get_iPhone() { ...@@ -129,7 +129,7 @@ iPhone *get_iPhone() {
* *
* @param phone A pointer to an iPhone structure. * @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->buffer) free(phone->buffer);
if (phone->device) { if (phone->device) {
usb_release_interface(phone->device, 1); usb_release_interface(phone->device, 1);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#endif #endif
#include <usb.h> #include <usb.h>
#include <libiphone/libiphone.h>
#define BULKIN 0x85 #define BULKIN 0x85
#define BULKOUT 0x04 #define BULKOUT 0x04
...@@ -39,8 +40,6 @@ typedef struct { ...@@ -39,8 +40,6 @@ typedef struct {
} iPhone; } iPhone;
// Function definitions // Function definitions
void free_iPhone(iPhone *victim);
iPhone *get_iPhone();
int send_to_phone(iPhone *phone, char *data, int datalen); int send_to_phone(iPhone *phone, char *data, int datalen);
int recv_from_phone(iPhone *phone, char *data, int datalen); int recv_from_phone(iPhone *phone, char *data, int datalen);
#endif #endif
...@@ -307,7 +307,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key ...@@ -307,7 +307,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
* *
* @return 1 on success and 0 on failure * @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; int ret = 0;
char *host_id = NULL; char *host_id = NULL;
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include <gnutls/gnutls.h> #include <gnutls/gnutls.h>
#include <string.h> #include <string.h>
#include <libiphone/libiphone.h>
typedef struct { typedef struct {
usbmux_connection *connection; usbmux_connection *connection;
...@@ -36,7 +40,6 @@ typedef struct { ...@@ -36,7 +40,6 @@ typedef struct {
int gtls_buffer_hack_len; int gtls_buffer_hack_len;
} lockdownd_client; } lockdownd_client;
int lockdownd_init(iPhone *phone, lockdownd_client **control);
char *lockdownd_generate_hostid(); char *lockdownd_generate_hostid();
lockdownd_client *new_lockdownd_client(iPhone *phone); lockdownd_client *new_lockdownd_client(iPhone *phone);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment