chiark / gitweb /
hostside: utils: new dumphex function, moved from hidraw-ioctl.c
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 30 Jan 2011 17:54:10 +0000 (17:54 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 30 Jan 2011 19:22:06 +0000 (19:22 +0000)
hostside/common.h
hostside/hiddev-ioctl.c
hostside/hidraw-ioctl.c
hostside/utils.c

index d2dcf736ab9dbca6fa29daa780f694ed186b4b8e..2afc8cdf113a30e7911657fd7dc6f657969b4a06 100644 (file)
@@ -139,6 +139,7 @@ void mwaitpid(pid_t child, const char *what);
 void mflushstdout(void);
 
 void badusage(const char *why) __attribute__((noreturn));
+void dumphex(FILE *f, const void *pu, int l); /* caller must check ferror */
 
 #define massert(x) ((x) ? (void)0 : diem())
 
index d6fd11cb3491f4e60980305551abad147edad3b3..dcd748a5eb0042f768c437c5d8846db0bd0efce7 100644 (file)
 
 #include "common.h"
 
-#if 0
-static void dump(const void *pu, int l) {
-  const uint8_t *p= pu;
-  while (l>0) {
-    printf("%02x",*p++);
-    l--;
-  }
-  putchar(' ');
-}
-#endif
-
 static void report_scan(const char *which, int type) {
   struct hiddev_report_info rinfo;
   int r, i, j;
index e5ac44aca4eff51428f8c97f983fd2086e647a6d..027e953e66fd677982aa09b9742d25d1b53d6294 100644 (file)
 
 #include "common.h"
 
-static void dump(const void *pu, int l) {
-  const uint8_t *p= pu;
-  while (l>0) {
-    printf("%02x",*p++);
-    l--;
-  }
-  putchar(' ');
-}
-
 int main(int argc, char **argv) {
   int r, descsz;
 
index c7a37715d286a73f70117914f4ffd0c48763535e..e6dd50bce7f575f62f326856c93961775b9efdba 100644 (file)
@@ -98,3 +98,12 @@ void mwaitpid(pid_t child, const char *what) {
 void mflushstdout(void) {
   if (ferror(stdout) || fflush(stdout)) diee("write to stdout");
 }
+
+void dumphex(FILE *f, const void *pu, int l) {
+  const uint8_t *p= pu;
+  while (l>0) {
+    fprintf(f,"%02x",*p++);
+    l--;
+  }
+  putc(' ',f);
+}