Commit 18d1ee3b authored by Jonathan Beck's avatar Jonathan Beck

move stuff around to make code more organized.

parent cd95e9bc
...@@ -6,10 +6,10 @@ AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $ ...@@ -6,10 +6,10 @@ AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $
bin_PROGRAMS = libiphone-initconf bin_PROGRAMS = libiphone-initconf
libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c utils.c libiphone_initconf_SOURCES = initconf.c userpref.c utils.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)
lib_LTLIBRARIES = libiphone.la lib_LTLIBRARIES = libiphone.la
libiphone_la_SOURCES = usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c utils.c libiphone_la_SOURCES = usbmux.c iphone.c plist.c bplist.c xplist.c lockdown.c AFC.c userpref.c utils.c
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "libiphone/libiphone.h" #include "libiphone/libiphone.h"
#include "userpref.h" #include "userpref.h"
#include "lockdown.h"
#include "utils.h" #include "utils.h"
/** Generates a 2048 byte key, split into a function so that it can be run in a /** Generates a 2048 byte key, split into a function so that it can be run in a
...@@ -60,6 +59,35 @@ void progress_bar(gpointer mutex) ...@@ -60,6 +59,35 @@ void progress_bar(gpointer mutex)
g_thread_exit(0); g_thread_exit(0);
} }
int get_rand(int min, int max)
{
int retval = (rand() % (max - min)) + min;
return retval;
}
/** Generates a valid HostID (which is actually a UUID).
*
* @param A null terminated string containing a valid HostID.
*/
char *lockdownd_generate_hostid()
{
char *hostid = (char *) malloc(sizeof(char) * 37); // HostID's are just UUID's, and UUID's are 36 characters long
const char *chars = "ABCDEF0123456789";
srand(time(NULL));
int i = 0;
for (i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
hostid[i] = '-';
continue;
} else {
hostid[i] = chars[get_rand(0, 16)];
}
}
hostid[36] = '\0'; // make it a real string
return hostid;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
GThread *progress_thread, *key_thread; GThread *progress_thread, *key_thread;
......
...@@ -39,34 +39,7 @@ const ASN1_ARRAY_TYPE pkcs1_asn1_tab[] = { ...@@ -39,34 +39,7 @@ const ASN1_ARRAY_TYPE pkcs1_asn1_tab[] = {
{0, 0, 0} {0, 0, 0}
}; };
int get_rand(int min, int max)
{
int retval = (rand() % (max - min)) + min;
return retval;
}
/** Generates a valid HostID (which is actually a UUID).
*
* @param A null terminated string containing a valid HostID.
*/
char *lockdownd_generate_hostid()
{
char *hostid = (char *) malloc(sizeof(char) * 37); // HostID's are just UUID's, and UUID's are 36 characters long
const char *chars = "ABCDEF0123456789";
srand(time(NULL));
int i = 0;
for (i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
hostid[i] = '-';
continue;
} else {
hostid[i] = chars[get_rand(0, 16)];
}
}
hostid[36] = '\0'; // make it a real string
return hostid;
}
/** Creates a lockdownd client for the give iPhone. /** Creates a lockdownd client for the give iPhone.
* *
......
...@@ -40,8 +40,6 @@ struct iphone_lckd_client_int { ...@@ -40,8 +40,6 @@ struct iphone_lckd_client_int {
int gtls_buffer_hack_len; int gtls_buffer_hack_len;
}; };
char *lockdownd_generate_hostid();
iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone); iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone);
iphone_error_t lockdownd_hello(iphone_lckd_client_t control); iphone_error_t lockdownd_hello(iphone_lckd_client_t control);
iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, char *req_string, char **value); iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, char *req_string, char **value);
......
This diff is collapsed.
...@@ -47,6 +47,20 @@ typedef enum { ...@@ -47,6 +47,20 @@ typedef enum {
} plist_type; } plist_type;
struct plist_data {
union {
char boolval;
uint64_t intval;
double realval;
char *strval;
wchar_t *unicodeval;
char *buff;
};
uint64_t length;
plist_type type;
};
typedef GNode *plist_t; typedef GNode *plist_t;
typedef GNode *dict_t; typedef GNode *dict_t;
...@@ -67,4 +81,5 @@ void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist); ...@@ -67,4 +81,5 @@ void bin_to_plist(const char *plist_bin, uint32_t length, plist_t * plist);
GNode *find_query_node(plist_t plist, char *key, char *request); GNode *find_query_node(plist_t plist, char *key, char *request);
GNode *find_node(plist_t plist, plist_type type, void *value); GNode *find_node(plist_t plist, plist_type type, void *value);
void get_type_and_value(GNode * node, plist_type * type, void *value); void get_type_and_value(GNode * node, plist_type * type, void *value);
#endif #endif
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