summaryrefslogtreecommitdiffstats
path: root/libusb/error.h
diff options
context:
space:
mode:
authorpancake <pancake@dazo>2007-06-12 15:29:07 +0200
committerpancake <pancake@dazo>2007-06-12 15:29:07 +0200
commitea97ac427eb9ff7ec48baf3a5ab7cc293fc34b70 (patch)
tree271288556a4a431a25746e5da596feb3dd580d64 /libusb/error.h
parenta3af55acb4141cd0d23f53b2ec0c5c1d2434aa22 (diff)
download0xFFFF-ea97ac427eb9ff7ec48baf3a5ab7cc293fc34b70.tar.bz2
* Initial import of the libusb source tree into the flasher - optional, but useful for embedding - avoids gnu autosux problems
Diffstat (limited to 'libusb/error.h')
-rw-r--r--libusb/error.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/libusb/error.h b/libusb/error.h
new file mode 100644
index 0000000..173e6fd
--- /dev/null
+++ b/libusb/error.h
@@ -0,0 +1,31 @@
+#ifndef _ERROR_H_
+#define _ERROR_H_
+
+typedef enum {
+ USB_ERROR_TYPE_NONE = 0,
+ USB_ERROR_TYPE_STRING,
+ USB_ERROR_TYPE_ERRNO,
+} usb_error_type_t;
+
+extern char usb_error_str[1024];
+extern int usb_error_errno;
+extern usb_error_type_t usb_error_type;
+
+#define USB_ERROR(x) \
+ do { \
+ usb_error_type = USB_ERROR_TYPE_ERRNO; \
+ usb_error_errno = x; \
+ return x; \
+ } while (0)
+
+#define USB_ERROR_STR(x, format, args...) \
+ do { \
+ usb_error_type = USB_ERROR_TYPE_STRING; \
+ snprintf(usb_error_str, sizeof(usb_error_str) - 1, format, ## args); \
+ if (usb_debug >= 2) \
+ fprintf(stderr, "USB error: %s\n", usb_error_str); \
+ return x; \
+ } while (0)
+
+#endif /* _ERROR_H_ */
+