From: Ian Jackson Date: Sun, 30 Jan 2011 17:54:10 +0000 (+0000) Subject: hostside: utils: new dumphex function, moved from hidraw-ioctl.c X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=1b69e56458dffae981cc15cea7c862e23602b574;p=trains.git hostside: utils: new dumphex function, moved from hidraw-ioctl.c --- diff --git a/hostside/common.h b/hostside/common.h index d2dcf73..2afc8cd 100644 --- a/hostside/common.h +++ b/hostside/common.h @@ -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()) diff --git a/hostside/hiddev-ioctl.c b/hostside/hiddev-ioctl.c index d6fd11c..dcd748a 100644 --- a/hostside/hiddev-ioctl.c +++ b/hostside/hiddev-ioctl.c @@ -14,17 +14,6 @@ #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; diff --git a/hostside/hidraw-ioctl.c b/hostside/hidraw-ioctl.c index e5ac44a..027e953 100644 --- a/hostside/hidraw-ioctl.c +++ b/hostside/hidraw-ioctl.c @@ -15,15 +15,6 @@ #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; diff --git a/hostside/utils.c b/hostside/utils.c index c7a3771..e6dd50b 100644 --- a/hostside/utils.c +++ b/hostside/utils.c @@ -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); +}