summaryrefslogtreecommitdiffstats
path: root/src/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-05-13 08:58:46 -0400
committerGravatar Joshua Hill2010-05-13 08:58:46 -0400
commit520c99d33e18009660f30bd38b31a2f1cd432fe6 (patch)
tree554dcde9de73f69a1cc34de0e4c7819fd148a5e8 /src/libirecovery.c
parent5bbd277ce71521a3898697e4c8cb25ed65990f9c (diff)
downloadlibirecovery-520c99d33e18009660f30bd38b31a2f1cd432fe6.tar.gz
libirecovery-520c99d33e18009660f30bd38b31a2f1cd432fe6.tar.bz2
Implemented command line argument parsing and irecv_command() function.
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r--src/libirecovery.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index a5b5c84..85967ec 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -23,14 +23,13 @@
#include "libirecovery.h"
-static unsigned int debug = 1;
+static unsigned int irecv_debug = 0;
int irecv_init(irecv_device** p_device) {
struct libusb_context* usb_context = NULL;
libusb_init(&usb_context);
- if (debug)
- libusb_set_debug(usb_context, 3);
+ if (irecv_debug) libusb_set_debug(usb_context, 3);
irecv_device* device = (irecv_device*) malloc(sizeof(irecv_device));
if (device == NULL) {
@@ -60,7 +59,7 @@ int irecv_open(irecv_device* device) {
for (i = 0; i < usb_device_count; i++) {
usb_device = usb_device_list[i];
libusb_get_device_descriptor(usb_device, &usb_descriptor);
- if (usb_descriptor.idVendor == kAppleVendorId) {
+ if (usb_descriptor.idVendor == kAppleId) {
libusb_open(usb_device, &usb_handle);
if (usb_handle == NULL) {
@@ -115,3 +114,30 @@ int irecv_exit(irecv_device* device) {
return IRECV_SUCCESS;
}
+
+void irecv_set_debug(int level) {
+ printf("Debug has been set to %d\n", level);
+ irecv_debug = level;
+}
+
+int irecv_command(irecv_device* device, const char* command) {
+ if(device == NULL || device->handle == NULL) {
+ return IRECV_ERROR_NO_DEVICE;
+ }
+
+ ssize_t length = strlen(command);
+ if(length >= 0x100) {
+ return IRECV_ERROR_INVALID_INPUT;
+ }
+
+ int ret = libusb_control_transfer(device->handle, 0x40, 0, 0, 0, (unsigned char*) command, length+1, 100);
+ if(ret < 0) {
+ return IRECV_ERROR_UNKNOWN;
+ }
+
+ return IRECV_SUCCESS;
+}
+
+int irecv_upload(irecv_device* device, const char* filename) {
+ return IRECV_SUCCESS;
+}