Module Name:    src
Committed By:   christos
Date:           Tue May 31 03:37:02 UTC 2011

Modified Files:
        src/usr.sbin/wsmoused: wsmoused.c

Log Message:
a little undocumented debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/wsmoused/wsmoused.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/wsmoused/wsmoused.c
diff -u src/usr.sbin/wsmoused/wsmoused.c:1.25 src/usr.sbin/wsmoused/wsmoused.c:1.26
--- src/usr.sbin/wsmoused/wsmoused.c:1.25	Sun Jan 18 19:53:15 2009
+++ src/usr.sbin/wsmoused/wsmoused.c	Mon May 30 23:37:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmoused.c,v 1.25 2009/01/19 00:53:15 christos Exp $ */
+/* $NetBSD: wsmoused.c,v 1.26 2011/05/31 03:37:02 christos Exp $ */
 
 /*
  * Copyright (c) 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: wsmoused.c,v 1.25 2009/01/19 00:53:15 christos Exp $");
+__RCSID("$NetBSD: wsmoused.c,v 1.26 2011/05/31 03:37:02 christos Exp $");
 #endif /* not lint */
 
 #include <sys/ioctl.h>
@@ -95,7 +95,7 @@
  * Prototypes for functions private to this module.
  */
 
-static void usage(void);
+static void usage(void) __attribute__((__noreturn__));
 static void open_device(unsigned int);
 static void init_mouse(void);
 static void event_loop(void);
@@ -105,7 +105,8 @@
 static void detach_mode(const char *);
 static void detach_modes(void);
 static void signal_terminate(int);
-int main(int, char **);
+
+static int debug;
 
 /* --------------------------------------------------------------------- */
 
@@ -295,6 +296,11 @@
 
 		if (fds[0].revents & POLLIN) {
 			res = read(Mouse.m_statfd, &event, sizeof(event));
+			if (debug)
+				(void)fprintf(stderr, "event [type=%u,value=%d,"
+				    "time=[%lld,%ld]\n", event.type,
+				    event.value, (long long)event.time.tv_sec,
+				    (long)event.time.tv_nsec);
 			if (res != sizeof(event))
 				log_warn("failed to read from mouse stat");
 
@@ -313,6 +319,11 @@
 			if (res != sizeof(event))
 				log_warn("failed to read from mouse");
 
+			if (debug)
+				(void)fprintf(stderr, "event [type=%u,value=%d,"
+				    "time=[%lld,%ld]\n", event.type,
+				    event.value, (long long)event.time.tv_sec,
+				    (long)event.time.tv_nsec);
 			if (Mouse.m_fifofd >= 0) {
 				res = write(Mouse.m_fifofd, &event,
 				            sizeof(event));
@@ -500,8 +511,11 @@
 	nodaemon = -1;
 
 	/* Parse command line options */
-	while ((opt = getopt(argc, argv, "d:f:m:n")) != -1) {
+	while ((opt = getopt(argc, argv, "Dd:f:m:n")) != -1) {
 		switch (opt) {
+		case 'D':
+			debug++;
+			break;
 		case 'd': /* Mouse device name */
 			Mouse.m_devname = optarg;
 			break;

Reply via email to