summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-02-19 09:54:35 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-02-19 09:54:35 +0000
commit7fa130165bfea34dc8306d5776d8496b001813e4 (patch)
tree15068a108259c6a408dde7916be1659c2d811eef /gpsmon.c
parent744a39384961046e4046a160e5550ec527d61cb8 (diff)
downloadgpsd-7fa130165bfea34dc8306d5776d8496b001813e4.tar.gz
Simplify the packet-monitor driver interface.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/gpsmon.c b/gpsmon.c
index ebc06c45..8834b3cd 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -448,47 +448,46 @@ int main (int argc, char **argv)
(void)wattrset(statwin, A_NORMAL);
(void)wmove(cmdwin, 0,0);
- /* get a packet -- calls gpsd_poll */
+ /* get a packet -- calls gpsd_poll() */
if ((len = readpkt()) > 0 && session.packet.outbuflen > 0) {
- (void)wprintw(packetwin, "(%d) ", session.packet.outbuflen);
- packet_dump((char *)session.packet.outbuffer,session.packet.outbuflen);
- }
-
- /* switch types on packet receipt */
- if (session.packet.type != last_type) {
- const struct monitor_object_t **trial, **newobject;
- last_type = session.packet.type;
- newobject = NULL;
- for (trial = monitor_objects; *trial; trial++)
- if ((*trial)->driver == session.device_type)
- newobject = trial;
- if (newobject) {
- if (active != NULL) {
- (*active)->wrap();
- (void)delwin(devicewin);
+ /* switch types on packet receipt */
+ if (session.packet.type != last_type) {
+ const struct monitor_object_t **trial, **newobject;
+ last_type = session.packet.type;
+ newobject = NULL;
+ for (trial = monitor_objects; *trial; trial++)
+ if ((*trial)->driver == session.device_type)
+ newobject = trial;
+ if (newobject) {
+ if (active != NULL) {
+ (*active)->wrap();
+ (void)delwin(devicewin);
+ }
+ active = newobject;
+ devicewin = newwin((*active)->min_y+1, (*active)->min_x+1,1,0);
+ if (!(*active)->initialize())
+ goto quit;
+ (void)wresize(packetwin, LINES-(*active)->min_y-1, 80);
+ (void)mvwin(packetwin, (*active)->min_y+1, 0);
+ (void)wsetscrreg(packetwin, 0, LINES-(*active)->min_y-2);
}
- active = newobject;
- devicewin = newwin((*active)->min_y+1, (*active)->min_x+1,1,0);
- if (!(*active)->initialize())
- goto quit;
- (void)wresize(packetwin, LINES-(*active)->min_y-1, 80);
- (void)mvwin(packetwin, (*active)->min_y+1, 0);
- (void)wsetscrreg(packetwin, 0, LINES-(*active)->min_y-2);
}
- }
- /* refresh all windows */
- (void)wprintw(cmdwin, type_name);
- (void)wprintw(cmdwin, "> ");
- (void)wclrtoeol(cmdwin);
- if (active != NULL)
- (*active)->update((size_t)len);
- (void)wnoutrefresh(statwin);
- (void)wnoutrefresh(cmdwin);
- if (devicewin != 0)
- (void)wnoutrefresh(devicewin);
- (void)wnoutrefresh(packetwin);
- (void)doupdate();
+ /* refresh all windows */
+ (void)wprintw(cmdwin, type_name);
+ (void)wprintw(cmdwin, "> ");
+ (void)wclrtoeol(cmdwin);
+ if (active != NULL && len > 0 && session.packet.outbuflen > 0)
+ (*active)->update();
+ (void)wprintw(packetwin, "(%d) ", session.packet.outbuflen);
+ packet_dump((char *)session.packet.outbuffer,session.packet.outbuflen);
+ (void)wnoutrefresh(statwin);
+ (void)wnoutrefresh(cmdwin);
+ if (devicewin != 0)
+ (void)wnoutrefresh(devicewin);
+ (void)wnoutrefresh(packetwin);
+ (void)doupdate();
+ }
/* rest of this invoked only if user has pressed a key */
FD_SET(0,&select_set);