summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matt Colyer2008-08-20 09:31:32 -0700
committerGravatar Matt Colyer2008-08-20 09:31:32 -0700
commitaecf8d985ea38eceac682f31bbbc92b605c0ab39 (patch)
tree7e3ea2d7480ac71ea89af463f5a28c77f63fc4f8
parentc8cf91eec5e66a5ee9fdaadeba978f079898cb45 (diff)
downloadlibimobiledevice-aecf8d985ea38eceac682f31bbbc92b605c0ab39.tar.gz
libimobiledevice-aecf8d985ea38eceac682f31bbbc92b605c0ab39.tar.bz2
Removed duplicate functions in initconf and fixed build issues.
-rw-r--r--src/Makefile.am6
-rw-r--r--src/initconf.c33
-rw-r--r--src/lockdown.h2
3 files changed, 14 insertions, 27 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index dc32c04..674f19c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,6 @@ bin_PROGRAMS = iphoneclient ifuse libiphone-initconf
5iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c 5iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c
6ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c 6ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c
7 7
8libiphone_initconf_SOURCES = initconf.c userpref.c 8libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c
9libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) 9libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS)
10libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) 10libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS)
diff --git a/src/initconf.c b/src/initconf.c
index 8944ab4..b900f7f 100644
--- a/src/initconf.c
+++ b/src/initconf.c
@@ -25,38 +25,23 @@
25#include <gnutls/gnutls.h> 25#include <gnutls/gnutls.h>
26#include <gnutls/x509.h> 26#include <gnutls/x509.h>
27#include <glib.h> 27#include <glib.h>
28
28#include "userpref.h" 29#include "userpref.h"
30#include "lockdown.h"
29 31
30int debug = 1; 32int debug = 1;
31 33
32int get_rand(int min, int max) { 34/** Generates a 2048 byte key, split into a function so that it can be run in a
33 int retval = (rand() % (max - min)) + min; 35 * thread.
34 return retval; 36 *
35} 37 * @param key The pointer to the desired location of the new key.
36 38 */
37char *lockdownd_generate_hostid() {
38 char *hostid = (char*)malloc(sizeof(char) * 37); // HostID's are just UUID's, and UUID's are 36 characters long
39 const char *chars = "ABCDEF0123456789";
40 srand(time(NULL));
41 int i = 0;
42
43 for (i = 0; i < 36; i++) {
44 if (i == 8 || i == 13 || i == 18 || i == 23) {
45 hostid[i] = '-';
46 continue;
47 } else {
48 hostid[i] = chars[get_rand(0,16)];
49 }
50 }
51 hostid[36] = '\0';
52 return hostid;
53}
54
55void generate_key(gpointer key){ 39void generate_key(gpointer key){
56 gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t*)key), GNUTLS_PK_RSA, 2048, 0); 40 gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t*)key), GNUTLS_PK_RSA, 2048, 0);
57 g_thread_exit(0); 41 g_thread_exit(0);
58} 42}
59 43/** Simple function that generates a spinner until the mutex is released.
44 */
60void progress_bar(gpointer mutex){ 45void progress_bar(gpointer mutex){
61 const char *spinner = "|/-\\|/-\\"; 46 const char *spinner = "|/-\\|/-\\";
62 int i = 0; 47 int i = 0;
diff --git a/src/lockdown.h b/src/lockdown.h
index 56c133d..6b27900 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -22,6 +22,7 @@
22#ifndef LOCKDOWND_H 22#ifndef LOCKDOWND_H
23#define LOCKDOWND_H 23#define LOCKDOWND_H
24 24
25#include "usbmux.h"
25#include "plist.h" 26#include "plist.h"
26 27
27#include <gnutls/gnutls.h> 28#include <gnutls/gnutls.h>
@@ -36,6 +37,7 @@ typedef struct {
36} lockdownd_client; 37} lockdownd_client;
37 38
38int lockdownd_init(iPhone *phone, lockdownd_client **control); 39int lockdownd_init(iPhone *phone, lockdownd_client **control);
40char *lockdownd_generate_hostid();
39 41
40lockdownd_client *new_lockdownd_client(iPhone *phone); 42lockdownd_client *new_lockdownd_client(iPhone *phone);
41int lockdownd_hello(lockdownd_client *control); 43int lockdownd_hello(lockdownd_client *control);