recognize the HuaeiNewMode and StandardEject options
[project/usbmode.git] / main.c
diff --git a/main.c b/main.c
index fca2a37cacd72f7b4d7e7bc83a1988e503e532d9..22e17052e7107069816a6ccfcce05c0b111a53df 100644 (file)
--- a/main.c
+++ b/main.c
@@ -19,13 +19,13 @@ static int verbose = 0;
 static const char *config_file = DEFAULT_CONFIG;
 static struct blob_buf conf;
 
-struct blob_attr **messages = NULL;
+char **messages = NULL;
 int *message_len;
 int n_messages = 0;
 
 static struct avl_tree devices;
 
-static struct libusb_context *usb;
+struct libusb_context *usb;
 static struct libusb_device **usbdevs;
 static int n_usbdevs;
 
@@ -127,7 +127,7 @@ static int parse_config(void)
                }
 
                message_len[n_messages] = len;
-               messages[n_messages++] = cur;
+               messages[n_messages++] = blobmsg_data(cur);
        }
 
        blobmsg_for_each_attr(cur, tb[CONF_DEVICES], rem) {
@@ -280,7 +280,8 @@ static void iterate_devs(cmd_cb_t cb)
                if (data.config)
                        libusb_free_config_descriptor(data.config);
 
-               libusb_close(data.devh);
+               if (data.devh)
+                       libusb_close(data.devh);
        }
 }