From 05be49f1f5af33f9487c4d99ef3605902cd24cc4 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 16 Jun 2008 01:24:42 +0000 Subject: [PATCH] sanitise "opened" --- hostside/evdev-manip.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hostside/evdev-manip.c b/hostside/evdev-manip.c index c4d46f3..023bbde 100644 --- a/hostside/evdev-manip.c +++ b/hostside/evdev-manip.c @@ -90,6 +90,7 @@ struct ModeInfo { void (*evdev_synch)(Device *d, struct timeval tv); void (*hiddev_event)(Device *d, const struct hiddev_usage_ref *ur); int (*hiddev_xflags)(void); + void (*opened)(Device *d); void (*redacted)(Device *d, int nstrs, const char *strs[nstrs], int value); void (*died)(Device *d, int revents, int readr, int readc, int e) __attribute__((noreturn)); @@ -315,8 +316,9 @@ static void evdev_prepare(Device *d) { r= ioctl(d->fd, EVIOCGID, &iid); if (r) diee("%s: failed to get id",d->path); - - printf("device %s bustype ", d->path); + + mode->opened(d); + printf(" bustype "); PR_TABLE_STR(bus, iid.bustype); DUMP_VPV(iid); putchar('\n'); @@ -484,7 +486,8 @@ static void hiddev_prepare(Device *d) { r= ioctl(d->fd, HIDIOCGDEVINFO, &di); if (r) diee("hiddev %s: ioctl HIDIOCGDEVINFO", d->path); - printf("device %s bustype ", d->path); + mode->opened(d); + printf(" bustype "); PR_TABLE_STR(bus, di.bustype); printf(" bus %d dev %d if %d", di.busnum, di.devnum, di.ifnum); DUMP_VPV(di); @@ -512,6 +515,10 @@ static void dump_died(Device *d, int revents, int readr, int readc, int e) { exit(0); } +static void dump_opened(Device *d) { + printf("device %s", d->path); +} + static void mainloop(void) { struct pollfd *polls; int i, r, npolls; @@ -567,7 +574,7 @@ static void mainloop(void) { static const ModeInfo mode_dump= { evdev_dump, evdev_readable_dump, evdev_synch_dump, hiddev_dump, hiddev_xflags_dump, - 0, dump_died, mainloop + dump_opened, 0, dump_died, mainloop }; /*---------- mode redact ----------*/ @@ -613,10 +620,14 @@ static void redact_redacted(Device *d, int nstrs, const char *strs[nstrs], putchar('\n'); } +static void redact_opened(Device *d) { + printf("%s opened", d->label); +} + static const ModeInfo mode_redact= { evdev_redact, 0, 0, hiddev_redact, 0, - redact_redacted, dump_died, mainloop + redact_opened, redact_redacted, dump_died, mainloop }; static void redaction(const char ***argv) { -- 2.30.2