summaryrefslogtreecommitdiffstats
path: root/src/lockdown.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-21 21:34:59 +0200
committerGravatar Jonathan Beck2008-08-21 21:34:59 +0200
commit6b706ced7bea4223cce3b83f25268130226a9756 (patch)
tree3ffbeaafaa6f120ab138709df5bd0c4b998d005f /src/lockdown.c
parentbb496ff039679ad44d2a9dbfb4224b2fcd54c7e2 (diff)
downloadlibplist-6b706ced7bea4223cce3b83f25268130226a9756.tar.gz
libplist-6b706ced7bea4223cce3b83f25268130226a9756.tar.bz2
add get_device_uid function
Conflicts:
Diffstat (limited to 'src/lockdown.c')
-rw-r--r--src/lockdown.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index def62ea..6ba7e18 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -214,13 +214,16 @@ int lockdownd_hello(lockdownd_client *control) {
free_dictionary(dictionary);
return 0;
}
-/** Askes for the device's public key. Part of the lockdownd handshake.
+
+/** Generic function to handle simple (key, value) requests.
*
- * @note You most likely want lockdownd_init unless you are doing something special.
+ * @param control an initialized lockdownd client.
+ * @param key the key to request
+ * @param value a pointer to the requested value
*
* @return 1 on success and 0 on failure.
*/
-int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key)
+int lockdownd_generic_get_value(lockdownd_client *control, char *req_key, char **value)
{
xmlDocPtr plist = new_plist();
xmlNode *dict = NULL;
@@ -232,7 +235,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
/* Setup DevicePublicKey request plist */
dict = add_child_to_plist(plist, "dict", "\n", NULL, 0);
- key = add_key_str_dict_element(plist, dict, "Key", "DevicePublicKey", 1);
+ key = add_key_str_dict_element(plist, dict, "Key", req_key, 1);
key = add_key_str_dict_element(plist, dict, "Request", "GetValue", 1);
xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
@@ -264,7 +267,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
success = 1;
}
if (!strcmp(dictionary[i], "Value")) {
- *public_key = strdup(dictionary[i+1]);
+ *value = strdup(dictionary[i+1]);
}
}
@@ -275,6 +278,28 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
return success;
}
+/** Askes for the device's unique id. Part of the lockdownd handshake.
+ *
+ * @note You most likely want lockdownd_init unless you are doing something special.
+ *
+ * @return 1 on success and 0 on failure.
+ */
+int lockdownd_get_device_uid(lockdownd_client *control, char **uid)
+{
+ return lockdownd_generic_get_value(control, "UniqueDeviceID", uid);
+}
+
+/** Askes for the device's public key. Part of the lockdownd handshake.
+ *
+ * @note You most likely want lockdownd_init unless you are doing something special.
+ *
+ * @return 1 on success and 0 on failure.
+ */
+int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key)
+{
+ return lockdownd_generic_get_value(control, "DevicePublicKey", public_key);
+}
+
/** Completes the entire lockdownd handshake.
*
* @param phone The iPhone