usb/183728: libusb20 examples filenames cause problems on windows.
Alfred Emanuel Perlstein
alfred at FreeBSD.org
Wed Nov 6 20:30:00 UTC 2013
>Number: 183728
>Category: usb
>Synopsis: libusb20 examples filenames cause problems on windows.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-usb
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 06 20:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Alfred Emanuel Perlstein
>Release: 11-current
>Organization:
freebsd
>Environment:
Microsoft Windows [Version 6.1.7600]
>Description:
The file "aux.*" can't be made on a windows machine. This patch renames those files.
>How-To-Repeat:
Try to checkout on a windows filesystem.
>Fix:
https://github.com/alfredperlstein/freebsd/compare/libusb_aux_names
diff --git a/share/examples/libusb20/Makefile b/share/examples/libusb20/Makefile
index 6f870a1..a27588a 100644
--- a/share/examples/libusb20/Makefile
+++ b/share/examples/libusb20/Makefile
@@ -3,11 +3,11 @@ TARGETS= bulk control
all: $(TARGETS)
-bulk: bulk.o aux.o
- $(CC) $(CFLAGS) -o bulk bulk.o aux.o -lusb
+bulk: bulk.o extras.o
+ $(CC) $(CFLAGS) -o bulk bulk.o extras.o -lusb
-control: control.o aux.o
- $(CC) $(CFLAGS) -o control control.o aux.o -lusb
+control: control.o extras.o
+ $(CC) $(CFLAGS) -o control control.o extras.o -lusb
clean:
rm -f $(TARGETS) *.o *~
diff --git a/share/examples/libusb20/aux.c b/share/examples/libusb20/aux.c
deleted file mode 100644
index 434972a..0000000
--- a/share/examples/libusb20/aux.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42) (by Poul-Henning Kamp):
- * <joerg at FreeBSD.ORG> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- */
-
-/*
- * Helper functions common to all examples
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <libusb20.h>
-#include <libusb20_desc.h>
-
-#include "aux.h"
-
-/*
- * Return a textual description for error "r".
- */
-const char *
-usb_error(enum libusb20_error r)
-{
- const char *msg = "UNKNOWN";
-
- switch (r)
- {
- case LIBUSB20_SUCCESS:
- msg = "success";
- break;
-
- case LIBUSB20_ERROR_IO:
- msg = "IO error";
- break;
-
- case LIBUSB20_ERROR_INVALID_PARAM:
- msg = "Invalid parameter";
- break;
-
- case LIBUSB20_ERROR_ACCESS:
- msg = "Access denied";
- break;
-
- case LIBUSB20_ERROR_NO_DEVICE:
- msg = "No such device";
- break;
-
- case LIBUSB20_ERROR_NOT_FOUND:
- msg = "Entity not found";
- break;
-
- case LIBUSB20_ERROR_BUSY:
- msg = "Resource busy";
- break;
-
- case LIBUSB20_ERROR_TIMEOUT:
- msg = "Operation timed out";
- break;
-
- case LIBUSB20_ERROR_OVERFLOW:
- msg = "Overflow";
- break;
-
- case LIBUSB20_ERROR_PIPE:
- msg = "Pipe error";
- break;
-
- case LIBUSB20_ERROR_INTERRUPTED:
- msg = "System call interrupted";
- break;
-
- case LIBUSB20_ERROR_NO_MEM:
- msg = "Insufficient memory";
- break;
-
- case LIBUSB20_ERROR_NOT_SUPPORTED:
- msg = "Operation not supported";
- break;
-
- case LIBUSB20_ERROR_OTHER:
- msg = "Other error";
- break;
- }
-
- return msg;
-}
-
-/*
- * Print "len" bytes from "buf" in hex, followed by an ASCII
- * representation (somewhat resembling the output of hd(1)).
- */
-void
-print_formatted(uint8_t *buf, uint32_t len)
-{
- int i, j;
-
- for (j = 0; j < len; j += 16)
- {
- printf("%02x: ", j);
-
- for (i = 0; i < 16 && i + j < len; i++)
- printf("%02x ", buf[i + j]);
- printf(" ");
- for (i = 0; i < 16 && i + j < len; i++)
- {
- uint8_t c = buf[i + j];
- if(c >= ' ' && c <= '~')
- printf("%c", (char)c);
- else
- putchar('.');
- }
- putchar('\n');
- }
-}
diff --git a/share/examples/libusb20/aux.h b/share/examples/libusb20/aux.h
deleted file mode 100644
index d43ea4e..0000000
--- a/share/examples/libusb20/aux.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42) (by Poul-Henning Kamp):
- * <joerg at FreeBSD.ORG> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- */
-
-#include <stdint.h>
-#include <libusb20.h>
-
-const char *usb_error(enum libusb20_error r);
-void print_formatted(uint8_t *buf, uint32_t len);
diff --git a/share/examples/libusb20/bulk.c b/share/examples/libusb20/bulk.c
index 7b6b02c..7e6044a 100644
--- a/share/examples/libusb20/bulk.c
+++ b/share/examples/libusb20/bulk.c
@@ -41,7 +41,7 @@
#include <libusb20.h>
#include <libusb20_desc.h>
-#include "aux.h"
+#include "extras.h"
/*
* If you want to see the details of the internal datastructures
diff --git a/share/examples/libusb20/control.c b/share/examples/libusb20/control.c
index 0a9d152..79a3115 100644
--- a/share/examples/libusb20/control.c
+++ b/share/examples/libusb20/control.c
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
#include <sysexits.h>
#include <unistd.h>
@@ -44,6 +45,8 @@
#include <sys/queue.h>
+#include "extras.h"
+
/*
* If you want to see the details of the internal datastructures
* in the debugger, unifdef the following.
diff --git a/share/examples/libusb20/extras.c b/share/examples/libusb20/extras.c
new file mode 100644
index 0000000..3301e80
--- /dev/null
+++ b/share/examples/libusb20/extras.c
@@ -0,0 +1,120 @@
+/* ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42) (by Poul-Henning Kamp):
+ * <joerg at FreeBSD.ORG> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
+ * ----------------------------------------------------------------------------
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Helper functions common to all examples
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <libusb20.h>
+#include <libusb20_desc.h>
+
+#include "extras.h"
+
+/*
+ * Return a textual description for error "r".
+ */
+const char *
+usb_error(enum libusb20_error r)
+{
+ const char *msg = "UNKNOWN";
+
+ switch (r)
+ {
+ case LIBUSB20_SUCCESS:
+ msg = "success";
+ break;
+
+ case LIBUSB20_ERROR_IO:
+ msg = "IO error";
+ break;
+
+ case LIBUSB20_ERROR_INVALID_PARAM:
+ msg = "Invalid parameter";
+ break;
+
+ case LIBUSB20_ERROR_ACCESS:
+ msg = "Access denied";
+ break;
+
+ case LIBUSB20_ERROR_NO_DEVICE:
+ msg = "No such device";
+ break;
+
+ case LIBUSB20_ERROR_NOT_FOUND:
+ msg = "Entity not found";
+ break;
+
+ case LIBUSB20_ERROR_BUSY:
+ msg = "Resource busy";
+ break;
+
+ case LIBUSB20_ERROR_TIMEOUT:
+ msg = "Operation timed out";
+ break;
+
+ case LIBUSB20_ERROR_OVERFLOW:
+ msg = "Overflow";
+ break;
+
+ case LIBUSB20_ERROR_PIPE:
+ msg = "Pipe error";
+ break;
+
+ case LIBUSB20_ERROR_INTERRUPTED:
+ msg = "System call interrupted";
+ break;
+
+ case LIBUSB20_ERROR_NO_MEM:
+ msg = "Insufficient memory";
+ break;
+
+ case LIBUSB20_ERROR_NOT_SUPPORTED:
+ msg = "Operation not supported";
+ break;
+
+ case LIBUSB20_ERROR_OTHER:
+ msg = "Other error";
+ break;
+ }
+
+ return msg;
+}
+
+/*
+ * Print "len" bytes from "buf" in hex, followed by an ASCII
+ * representation (somewhat resembling the output of hd(1)).
+ */
+void
+print_formatted(uint8_t *buf, uint32_t len)
+{
+ int i, j;
+
+ for (j = 0; j < len; j += 16)
+ {
+ printf("%02x: ", j);
+
+ for (i = 0; i < 16 && i + j < len; i++)
+ printf("%02x ", buf[i + j]);
+ printf(" ");
+ for (i = 0; i < 16 && i + j < len; i++)
+ {
+ uint8_t c = buf[i + j];
+ if(c >= ' ' && c <= '~')
+ printf("%c", (char)c);
+ else
+ putchar('.');
+ }
+ putchar('\n');
+ }
+}
diff --git a/share/examples/libusb20/extras.h b/share/examples/libusb20/extras.h
new file mode 100644
index 0000000..d43ea4e
--- /dev/null
+++ b/share/examples/libusb20/extras.h
@@ -0,0 +1,15 @@
+/* ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42) (by Poul-Henning Kamp):
+ * <joerg at FreeBSD.ORG> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
+ * ----------------------------------------------------------------------------
+ *
+ * $FreeBSD$
+ */
+
+#include <stdint.h>
+#include <libusb20.h>
+
+const char *usb_error(enum libusb20_error r);
+void print_formatted(uint8_t *buf, uint32_t len);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-usb
mailing list