summaryrefslogtreecommitdiffstats
path: root/src/initconf.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-12-11 23:03:21 +0100
committerGravatar Jonathan Beck2008-12-11 23:03:21 +0100
commit18d1ee3b0f17325fdffe0cf3e2770a3f0f45a1b9 (patch)
tree87a08a825b7a75bc0b0ce43de4801b1b7fd546cb /src/initconf.c
parentcd95e9bc6e23949b5cef3996132b79bd8803467a (diff)
downloadlibimobiledevice-18d1ee3b0f17325fdffe0cf3e2770a3f0f45a1b9.tar.gz
libimobiledevice-18d1ee3b0f17325fdffe0cf3e2770a3f0f45a1b9.tar.bz2
move stuff around to make code more organized.
Diffstat (limited to 'src/initconf.c')
-rw-r--r--src/initconf.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/initconf.c b/src/initconf.c
index 8aca2a6..00d78e2 100644
--- a/src/initconf.c
+++ b/src/initconf.c
@@ -28,7 +28,6 @@
#include "libiphone/libiphone.h"
#include "userpref.h"
-#include "lockdown.h"
#include "utils.h"
/** 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)
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[])
{
GThread *progress_thread, *key_thread;