From 00cc9fca23f538179c839c5644060a69bc2a11b0 Mon Sep 17 00:00:00 2001 From: ppokorny Date: Fri, 25 May 2001 03:14:27 +0000 Subject: [PATCH] + Changed protocol to 0.3 because we now accept both -foo and foo as argument introducers. in 0.4-pre10, these were changed from foo to -foo and this broke many clients. This change should fix that and be backward/forward compatible. + Added a noop function to the protocol. This is useful for writing shell script clients of LCDproc. + Changed the shared sock_send_string function to NOT send the ending NUL ('\0') byte with the string. This was confusing in Perl clients which saw NUL's as the first character of each reply. WARNING: The LCDPROC client depended on this behavior, your client may too. Use the newline instead. See the code in clients/lcdproc/main.c (look for "switch(buf[i])") to see one way to handle this. This should allow new clients to connect to old servers and vice-versa. + Messed with include structure in .c files. It should no longer be necessary to specify ../.. to get to shared code headers. Also, since we are using automake, the global config.h can be found with just #include "config.h" as it's location is included in a -I to the compilers. As a result "make distcheck" now works. --- ChangeLog | 39 ++++++++--- clients/lcdproc/Makefile.am | 1 + clients/lcdproc/batt.c | 2 +- clients/lcdproc/cpu.c | 4 +- clients/lcdproc/cpu_smp.c | 4 +- clients/lcdproc/disk.c | 2 +- clients/lcdproc/main.c | 36 +++++----- clients/lcdproc/mem.c | 11 ++- clients/lcdproc/mode.c | 1 - clients/metar/lcdmetar.pl | 31 ++------- configure.in | 4 +- server/Makefile.am | 1 + server/client_data.c | 2 +- server/client_data.h | 2 +- server/client_functions.c | 114 +++++++++++++++++--------------- server/client_functions.h | 7 +- server/clients.c | 2 +- server/clients.h | 2 +- server/drivers/CFontz.c | 14 ++-- server/drivers/Makefile.am | 5 ++ server/drivers/MtxOrb.c | 11 +-- server/drivers/bayrad.c | 3 +- server/drivers/curses_drv.c | 2 +- server/drivers/glk.c | 12 ++-- server/drivers/glkproto.c | 14 ++-- server/drivers/hd44780-4bit.c | 2 +- server/drivers/hd44780-winamp.c | 2 +- server/drivers/hd44780.c | 2 +- server/drivers/irmanin.c | 4 +- server/drivers/joy.c | 4 +- server/drivers/lb216.c | 21 +++--- server/drivers/lcd.c | 2 +- server/drivers/lircin.c | 4 +- server/drivers/svgalib_drv.c | 2 +- server/drivers/wirz-sli.c | 4 +- server/input.c | 4 +- server/main.c | 2 +- server/menus.c | 2 +- server/parse.c | 6 +- server/render.c | 4 +- server/screen.c | 10 +-- server/screen.h | 3 +- server/screenlist.c | 6 +- server/sock.h | 2 +- server/widget.c | 25 +------ server/widget.h | 1 - shared/debug.h | 4 +- shared/sockets.c | 3 +- 48 files changed, 222 insertions(+), 223 deletions(-) diff --git a/ChangeLog b/ChangeLog index 787a3da..26f977a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,23 +11,44 @@ Coming soon: (?) (my list of stuff to do soon...) * Better syntax for driver parameters * Dynamically-loaded driver system -v0.4-????: +v0.4.1: + + Changed protocol to 0.3 because we now accept both -foo and foo + as argument introducers. in 0.4-pre10, these were changed + from foo to -foo and this broke many clients. This change + should fix that and be backward/forward compatible. + + Added a noop function to the protocol. This is useful for writing + shell script clients of LCDproc. + + Changed the shared sock_send_string function to NOT send the + ending NUL ('\0') byte with the string. This was confusing + in Perl clients which saw NUL's as the first character of + each reply. WARNING: The LCDPROC client depended on this + behavior, your client may too. Use the newline instead. + See the code in clients/lcdproc/main.c (look for "switch(buf[i])") + to see one way to handle this. This should allow new clients + to connect to old servers and vice-versa. + + Messed with include structure in .c files. It should no longer + be necessary to specify ../.. to get to shared code headers. + Also, since we are using automake, the global config.h can be + found with just #include "config.h" as it's location is included + in a -I to the compilers. As a result "make distcheck" now works. + Added support for client_add_key and friends. Clients MUST now request keys to get notified. Keys are NO LONGER broadcast to all - clients. Keys are now tied to a SCREEN. (We should probably rename - the command to screen_add_key huh...) If the current screen is - has requested the key just pressed, the client gets the key and no - other client gets it. Clients only get one key notification even - if they have multiple screens requesting a given key. + clients. Keys are now tied to a SCREEN and CLIENT. There are new + commands (screen_add_key, screen_del_key) to bind keys to a + screen. If the current screen has requested the key just pressed, + the client gets the key and no other client gets it. If the current + screen has not requested the current key, then the key is broadcast + to all clients who requested that key with client_add_key. Clients + might want to request a "hotkey" with client_add_key so they will + be notified of that key no matter what screen is currently on the + display, and then request whatever other keys a screen uses with + screen_add_key. + Added driver for Matrix Orbital GLK12232-25 graphical display. Display is run in text mode since there isn't enough information in the widgets. If we knew the max width/height of an hbar/vbar, we could use graphical vbar/hbar's. Oh well. BigNums' look really cool though. You'll need some additional characters in the "Small Font" font (and the BigNumbers font) for this to work. - + Left the client_add_key routines alone and created new screen_add_key - and screen_del_key to allow per screen keystrokes. If someone else - implements a global client_key function, they can do that. + Rewrote Big Number Clock function in chrono.c. Many problems with it have been fixed. It now uses number value 10 to display a colon in between the digits. Don't know what this will do on a the MtxOrb diff --git a/clients/lcdproc/Makefile.am b/clients/lcdproc/Makefile.am index 9f8a4b2..28d1e52 100644 --- a/clients/lcdproc/Makefile.am +++ b/clients/lcdproc/Makefile.am @@ -1,3 +1,4 @@ bin_PROGRAMS = lcdproc lcdproc_SOURCES = main.c main.h mode.c mode.h batt.c batt.h chrono.c chrono.h cpu.c cpu.h cpu_smp.c cpu_smp.h disk.c disk.h load.c load.h mem.c mem.h lcdproc_LDADD = ../../shared/libLCDstuff.a +INCLUDES = -I$(top_srcdir) diff --git a/clients/lcdproc/batt.c b/clients/lcdproc/batt.c index 350d735..e49eb7c 100644 --- a/clients/lcdproc/batt.c +++ b/clients/lcdproc/batt.c @@ -5,7 +5,7 @@ #include #include -#include "../../shared/sockets.h" +#include "shared/sockets.h" #include "main.h" #include "mode.h" diff --git a/clients/lcdproc/cpu.c b/clients/lcdproc/cpu.c index 9a09d0c..82944ba 100644 --- a/clients/lcdproc/cpu.c +++ b/clients/lcdproc/cpu.c @@ -5,8 +5,8 @@ #include -#include "../../shared/sockets.h" -#include "../../shared/debug.h" +#include "shared/sockets.h" +#include "shared/debug.h" #include "main.h" #include "mode.h" diff --git a/clients/lcdproc/cpu_smp.c b/clients/lcdproc/cpu_smp.c index 62df1e9..673ef42 100644 --- a/clients/lcdproc/cpu_smp.c +++ b/clients/lcdproc/cpu_smp.c @@ -49,8 +49,8 @@ #include #include -#include "../../shared/sockets.h" -#include "../../shared/debug.h" +#include "shared/sockets.h" +#include "shared/debug.h" #include "main.h" #include "mode.h" diff --git a/clients/lcdproc/disk.c b/clients/lcdproc/disk.c index e27b7e8..b8ff96e 100644 --- a/clients/lcdproc/disk.c +++ b/clients/lcdproc/disk.c @@ -27,7 +27,7 @@ #include #endif -#include "../../shared/sockets.h" +#include "shared/sockets.h" #include "main.h" #include "mode.h" diff --git a/clients/lcdproc/main.c b/clients/lcdproc/main.c index 0dc37fc..d53193a 100644 --- a/clients/lcdproc/main.c +++ b/clients/lcdproc/main.c @@ -230,25 +230,21 @@ main_loop (mode * sequence) argc = 0; newtoken = 1; for (i = 0; i < len; i++) { - if (buf[i]) // For regular letters, keep tokenizing... - { - switch (buf[i]) { - case ' ': - newtoken = 1; - buf[i] = 0; - break; - case '\n': - buf[i] = 0; - default: - if (newtoken) { - argv[argc] = buf + i; - argc++; - } - newtoken = 0; - break; + switch (buf[i]) { + case ' ': + newtoken = 1; + buf[i] = 0; + break; + default: // regular chars, keep tokenizing + if (newtoken) { + argv[argc] = buf + i; + argc++; } - } else // If we've got a zero, it's the end of a string... - { + newtoken = 0; + break; + case '\0': + case '\n': + buf[i] = 0; if (argc > 0) { //printf("%s %s\n", argv[0], argv[1]); if (0 == strcmp (argv[0], "listen")) { @@ -293,9 +289,11 @@ main_loop (mode * sequence) } } + // Restart tokenizing argc = 0; newtoken = 1; - } + break ; + } // switch( buf[i] ) } len = sock_recv (sock, buf, 8000); diff --git a/clients/lcdproc/mem.c b/clients/lcdproc/mem.c index d142db1..8b73f6b 100644 --- a/clients/lcdproc/mem.c +++ b/clients/lcdproc/mem.c @@ -8,8 +8,8 @@ #include #include -#include "../../shared/sockets.h" -#include "../../shared/LL.h" +#include "shared/sockets.h" +#include "shared/LL.h" #include "main.h" #include "mode.h" @@ -19,7 +19,12 @@ #include #include #include -#include +#ifdef HAVE_SYS_PROCFS_H +# include +#endif +#ifdef HAVE_PROCFS_H +# include +#endif #endif diff --git a/clients/lcdproc/mode.c b/clients/lcdproc/mode.c index d82de95..31005f5 100644 --- a/clients/lcdproc/mode.c +++ b/clients/lcdproc/mode.c @@ -9,7 +9,6 @@ #include #include #include - #include #ifdef HAVE_CONFIG_H diff --git a/clients/metar/lcdmetar.pl b/clients/metar/lcdmetar.pl index e35dfee..e47183d 100755 --- a/clients/metar/lcdmetar.pl +++ b/clients/metar/lcdmetar.pl @@ -75,29 +75,11 @@ print $remote "widget_add metar cloud string\n"; print $remote "widget_add metar wind string\n"; # set metar source - my $ua = new LWP::UserAgent; my $req = new HTTP::Request GET => "http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=$site_code"; -# fork data collector from socket handling - -$kidpid = fork(); - -# Parent -if ($kidpid) { - -while (1==1) { - # read socket - my $lcdconnect = <$remote>; -} - -# child - -} else -{ - # fetch weather information while (1==1) { @@ -136,13 +118,13 @@ while (1==1) { my $metartime = $m->TIME; my $c_dew = $m->C_DEW; my $f_temp = $m->F_TEMP; - my $wind_dir_eng = $m->WIND_DIR_DEG; - my $wind_mph = $m->WIND_MPH; + my $wind_dir_eng = $m->WIND_DIR_ENG; + my $wind_mph = int($m->WIND_MPH); my $sky = $m->SKY; my $time = localtime(time); - print $remote "widget_set metar title {Weather LOWG " . $metartime . "}\n"; - print $remote "widget_set metar temp 1 2 {Temp " .$c_temp. "C (" .$c_dew. "C Dew)}\n"; - print $remote "widget_set metar wind 1 3 {Wind " .$wind_dir_eng. "G, " .$wind_mph. "mph}\n"; + print $remote "widget_set metar title {Weather $site_code $metartime}\n"; + print $remote "widget_set metar temp 1 2 {Temp ${c_temp}C (${c_dew}C Dew)}\n"; + print $remote "widget_set metar wind 1 3 {Wind ${wind_dir_eng}, ${wind_mph}mph}\n"; print $remote "widget_set metar cloud 1 4 {Sky " . join(',', @{$m->{sky}}) . "}\n"; # print "The temperature at $site_code is $c_temp C as of $time.\n"; # print "The wind blows to $wind_dir_eng, speed $wind_mph mph\n"; @@ -150,13 +132,12 @@ while (1==1) { } # end else # eat all input from LCDd while(defined($input = <$remote>)) { - if ( $input =~ /^success$/ ) next; + next if ( $input =~ /^success$/ ); #print $input; } print "Sleeping 15 minutes.\n"; sleep 900; } -} close($remote); exit; diff --git a/configure.in b/configure.in index 66a5c37..eaeaaa8 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(clients/lcdproc/batt.c) -AM_INIT_AUTOMAKE(lcdproc, 0.4-pre9) +AM_INIT_AUTOMAKE(lcdproc, 0.4.1) AM_CONFIG_HEADER(config.h) AC_CANONICAL_HOST @@ -110,7 +110,7 @@ AC_ARG_WITH(lcdport, ) AC_DEFINE_UNQUOTED(LCDPORT, $LCDPORT) -AC_DEFINE_UNQUOTED(PROTOCOL_VERSION, "0.2") +AC_DEFINE_UNQUOTED(PROTOCOL_VERSION, "0.3") AC_ARG_WITH(loadmax, diff --git a/server/Makefile.am b/server/Makefile.am index 214dcf5..941de2d 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -2,3 +2,4 @@ SUBDIRS=drivers sbin_PROGRAMS=LCDd LCDd_SOURCES= client_data.c client_data.h client_functions.c client_functions.h client_menu.h clients.c clients.h input.c input.h main.c main.h menu.c menu.h menus.c menus.h parse.c parse.h render.c render.h screen.c screen.h screenlist.c screenlist.h serverscreens.c serverscreens.h sock.c sock.h widget.c widget.h LCDd_LDADD = drivers/libLCDdrivers.a ../shared/libLCDstuff.a @LIBCURSES@ @LIBIRMAN@ @LIBLIRC_CLIENT@ +INCLUDES = -I$(top_srcdir) diff --git a/server/client_data.c b/server/client_data.c index 0cd42d4..c442a6c 100644 --- a/server/client_data.c +++ b/server/client_data.c @@ -10,7 +10,7 @@ #include #include -#include "../shared/debug.h" +#include "shared/debug.h" #include "client_data.h" #include "screen.h" diff --git a/server/client_data.h b/server/client_data.h index 6951e9c..30209ab 100644 --- a/server/client_data.h +++ b/server/client_data.h @@ -1,7 +1,7 @@ #ifndef CLIENT_DATA_H #define CLIENT_DATA_H -#include "../shared/LL.h" +#include "shared/LL.h" #define CLIENT_NAME_SIZE 256 diff --git a/server/client_functions.c b/server/client_functions.c index 9527bda..f961e8b 100644 --- a/server/client_functions.c +++ b/server/client_functions.c @@ -15,8 +15,8 @@ #include #include -#include "../shared/debug.h" -#include "../shared/sockets.h" +#include "shared/debug.h" +#include "shared/sockets.h" #include "drivers/lcd.h" @@ -45,13 +45,13 @@ client_function commands[] = { {"menu_add", menu_add_func}, {"menu_del", menu_del_func}, {"menu_set", menu_set_func}, - // TODO: Adhere these to the naming convention? - {"menu_item_add", menu_item_add_func}, - {"menu_item_del", menu_item_del_func}, - {"menu_item_set", menu_item_set_func}, + {"menu_add_item", menu_add_item_func}, + {"menu_del_item", menu_del_item_func}, + {"menu_set_item", menu_set_item_func}, // Misc stuff... {"backlight", backlight_func}, {"output", output_func}, + {"noop", noop_func}, {NULL, NULL}, }; @@ -110,7 +110,8 @@ client_set_func (client * c, int argc, char **argv) for (i = 1; i < argc; i++) { // Handle the "name" parameter - if (0 == strcmp (argv[i], "-name")) { + if (0 == strcmp (argv[i], "-name") + || 0 == strcmp (argv[i], "name")) { if (argc > i + 1) { i++; debug ("client_set: name=\"%s\"\n", argv[i]); @@ -272,40 +273,26 @@ screen_add_key_func (client * c, int argc, char **argv) sock_send_string (c->sock, "huh? Invalid screen id\n"); return 0; } - // Find the keys widget - w = widget_find( s, KEYS_WIDGETID ); - if (!w) { - int err ; - // No keys widget, create a new one - err = widget_add (s, KEYS_WIDGETID, types[WID_KEYS], NULL, c->sock); - if (err < 0) { - fprintf (stderr, "screen_add_key: Error creating keys widget\n"); - } else { - w = widget_find (s, KEYS_WIDGETID ); - } - }; - if (w) { - // Have a widget - if (!w->text) { - // Save supplied key list - w->text = strdup( keys ); - } else { - // Add supplied keys to existing list - // NOTE: There could be duplicates in the resulting list - // That's OK, it's the existence of the key in the list - // that's important. We'll be more careful in the delete - // key function. - char * new ; - new = realloc( w->text, strlen(w->text) + strlen(keys) +1 ); - if( new ) { - w->text = new ; - strcat( new, keys ); - } + // Save the keys + if (!s->keys) { + // Save supplied key list + s->keys = strdup( keys ); + } else { + // Add supplied keys to existing list + // NOTE: There could be duplicates in the resulting list + // That's OK, it's the existence of the key in the list + // that's important. We'll be more careful in the delete + // key function. + char * new ; + new = realloc( s->keys, strlen(s->keys) + strlen(keys) +1 ); + if( new ) { + s->keys = new ; + strcat( new, keys ); } } - if (!w) { + if (!s->keys) { sock_send_string(c->sock, "huh? failed\n"); } else sock_send_string(c->sock, "success\n"); @@ -349,18 +336,17 @@ screen_del_key_func (client * c, int argc, char **argv) sock_send_string (c->sock, "huh? Invalid screen id\n"); return 0; } - // Find the keys widget - w = widget_find( s, KEYS_WIDGETID ); - if (w && w->text) { - // Got the widget, remove keys from the text member + // Do we have keys? + if (s->keys) { + // Have keys, remove keys from the list // NOTE: We let malloc/realloc remember the length // of the allocated storage. If keys are later // added, realloc (in add_key above) will make - // sure there is enough space at w->text + // sure there is enough space at s->keys char * from ; char * to ; - to = from = w->text ; + to = from = s->keys ; while( *from ) { // Is this key to be deleted from the list? if( strchr( keys, *from ) ) { @@ -482,7 +468,8 @@ screen_set_func (client * c, int argc, char **argv) // Handle the rest of the parameters for (i = 2; i < argc; i++) { // Handle the "name" parameter - if (0 == strcmp (argv[i], "-name")) { + if (0 == strcmp (argv[i], "-name") + || 0 == strcmp (argv[i], "name")) { if (argc > i + 1) { i++; debug ("screen_set: name=\"%s\"\n", argv[i]); @@ -497,7 +484,8 @@ screen_set_func (client * c, int argc, char **argv) } } // Handle the "priority" parameter - else if (0 == strcmp (argv[i], "-priority")) { + else if (0 == strcmp (argv[i], "-priority") + || 0 == strcmp (argv[i], "priority")) { if (argc > i + 1) { i++; debug ("screen_set: priority=\"%s\"\n", argv[i]); @@ -512,7 +500,8 @@ screen_set_func (client * c, int argc, char **argv) } } // Handle the "duration" parameter - else if (0 == strcmp (argv[i], "-duration")) { + else if (0 == strcmp (argv[i], "-duration") + || 0 == strcmp (argv[i], "duration")) { if (argc > i + 1) { i++; debug ("screen_set: duration=\"%s\"\n", argv[i]); @@ -527,7 +516,8 @@ screen_set_func (client * c, int argc, char **argv) } } // Handle the "heartbeat" parameter - else if (0 == strcmp (argv[i], "-heartbeat")) { + else if (0 == strcmp (argv[i], "-heartbeat") + || 0 == strcmp (argv[i], "heartbeat")) { if (argc > i + 1) { i++; debug ("screen_set: heartbeat=\"%s\"\n", argv[i]); @@ -553,7 +543,8 @@ screen_set_func (client * c, int argc, char **argv) } } // Handle the "wid" parameter - else if (0 == strcmp (argv[i], "-wid")) { + else if (0 == strcmp (argv[i], "-wid") + || 0 == strcmp (argv[i], "wid")) { if (argc > i + 1) { i++; debug ("screen_set: wid=\"%s\"\n", argv[i]); @@ -568,7 +559,8 @@ screen_set_func (client * c, int argc, char **argv) } } // Handle the "hgt" parameter - else if (0 == strcmp (argv[i], "-hgt")) { + else if (0 == strcmp (argv[i], "-hgt") + || 0 == strcmp (argv[i], "hgt")) { if (argc > i + 1) { i++; debug ("screen_set: hgt=\"%s\"\n", argv[i]); @@ -637,8 +629,9 @@ widget_add_func (client * c, int argc, char **argv) // Check for additional flags... if (argc > 4) { - // Handle the "-in" flag to place widgets in a container... - if (0 == strcmp (argv[4], "-in")) { + // Handle the "in" flag to place widgets in a container... + if (0 == strcmp (argv[4], "-in") + || 0 == strcmp (argv[4], "in")) { if (argc < 6) { sock_send_string (c->sock, "huh? Specify a frame to place widget in\n"); return 0; @@ -1020,7 +1013,7 @@ menu_set_func (client * c, int argc, char **argv) // Adds an item to a menu // int -menu_item_add_func (client * c, int argc, char **argv) +menu_add_item_func (client * c, int argc, char **argv) { if (!c->data->ack) @@ -1035,7 +1028,7 @@ menu_item_add_func (client * c, int argc, char **argv) // Deletes an item from a menu // int -menu_item_del_func (client * c, int argc, char **argv) +menu_del_item_func (client * c, int argc, char **argv) { if (!c->data->ack) @@ -1052,7 +1045,7 @@ menu_item_del_func (client * c, int argc, char **argv) // For example, text displayed, widget type, value, etc... // int -menu_item_set_func (client * c, int argc, char **argv) +menu_set_item_func (client * c, int argc, char **argv) { if (!c->data->ack) @@ -1154,6 +1147,19 @@ output_func (client * c, int argc, char **argv) return 0; } +/////////////////////////////////////////////////////////////////////////// +// Does nothing, returns "noop complete" message +// +// This is useful for shell scripts or programs that want to talk +// with LCDproc and not get deadlocked. Send a noop after each +// command and look for the "noop complete" message. +int +noop_func (client * c, int argc, char **argv) +{ + sock_send_string (c->sock, "noop complete\n"); + return 0; +} + /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// diff --git a/server/client_functions.h b/server/client_functions.h index 879be6e..960a7cf 100644 --- a/server/client_functions.h +++ b/server/client_functions.h @@ -28,11 +28,12 @@ int widget_set_func (client * c, int argc, char **argv); int menu_add_func (client * c, int argc, char **argv); int menu_del_func (client * c, int argc, char **argv); int menu_set_func (client * c, int argc, char **argv); -int menu_item_add_func (client * c, int argc, char **argv); -int menu_item_del_func (client * c, int argc, char **argv); -int menu_item_set_func (client * c, int argc, char **argv); +int menu_add_item_func (client * c, int argc, char **argv); +int menu_del_item_func (client * c, int argc, char **argv); +int menu_set_item_func (client * c, int argc, char **argv); int backlight_func (client * c, int argc, char **argv); int output_func (client * c, int argc, char **argv); +int noop_func (client * c, int argc, char **argv); extern client_function commands[]; diff --git a/server/clients.c b/server/clients.c index c777f07..0bbe84c 100644 --- a/server/clients.c +++ b/server/clients.c @@ -18,7 +18,7 @@ #include "clients.h" #include "client_data.h" -#include "../shared/debug.h" +#include "shared/debug.h" LL *clients; diff --git a/server/clients.h b/server/clients.h index 9b2d15d..92eaad7 100644 --- a/server/clients.h +++ b/server/clients.h @@ -2,7 +2,7 @@ #define CLIENTS_H #include "client_data.h" -#include "../shared/LL.h" +#include "shared/LL.h" typedef struct client { int sock; diff --git a/server/drivers/CFontz.c b/server/drivers/CFontz.c index 5d7d4cb..29fb5b1 100644 --- a/server/drivers/CFontz.c +++ b/server/drivers/CFontz.c @@ -5,15 +5,17 @@ #include #include #include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "lcd.h" #include "CFontz.h" #include "drv_base.h" - -#include "../render.h" - -#include "../../shared/debug.h" -#include "../../shared/str.h" -#include "../../config.h" +#include "render.h" +#include "shared/debug.h" +#include "shared/str.h" static int custom = 0; typedef enum { diff --git a/server/drivers/Makefile.am b/server/drivers/Makefile.am index 417a5aa..6755353 100644 --- a/server/drivers/Makefile.am +++ b/server/drivers/Makefile.am @@ -14,3 +14,8 @@ EXTRA_libLCDdrivers_a_SOURCES = MtxOrb.c MtxOrb.h text.c text.h \ glk.c glk.h glkproto.c glkproto.h libLCDdrivers_a_DEPENDENCIES = @DRIVERS@ libLCDdrivers_a_LIBADD = @DRIVERS@ +# NOTE: $(srcdir)/.. is to get .h files from the server directory +# $(top_srcdir) is to get .h files from shared/... +# These are necessary because a VPATH build has split source and build +# directories and these files are in the VPATH'd source area. +INCLUDES = -I$(srcdir)/.. -I$(top_srcdir) diff --git a/server/drivers/MtxOrb.c b/server/drivers/MtxOrb.c index 71cd827..b2bf189 100644 --- a/server/drivers/MtxOrb.c +++ b/server/drivers/MtxOrb.c @@ -5,13 +5,16 @@ #include #include #include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "lcd.h" #include "MtxOrb.h" #include "drv_base.h" - -#include "../../shared/debug.h" -#include "../../shared/str.h" -#include "../../config.h" +#include "shared/debug.h" +#include "shared/str.h" static int custom = 0; static enum {MTXORB_LCD, MTXORB_LKD, MTXORB_VFD, MTXORB_VKD} MtxOrb_type; diff --git a/server/drivers/bayrad.c b/server/drivers/bayrad.c index 646ce8f..e6969bf 100644 --- a/server/drivers/bayrad.c +++ b/server/drivers/bayrad.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #ifdef HAVE_CONFIG_H # include "config.h" @@ -26,7 +26,6 @@ # endif #endif #ifdef SOLARIS -# include # include #endif #include "lcd.h" diff --git a/server/drivers/curses_drv.c b/server/drivers/curses_drv.c index bb89207..8b65634 100644 --- a/server/drivers/curses_drv.c +++ b/server/drivers/curses_drv.c @@ -15,7 +15,7 @@ #include #endif -#include "../../shared/str.h" +#include "shared/str.h" #include "lcd.h" #include "curses_drv.h" diff --git a/server/drivers/glk.c b/server/drivers/glk.c index 25b241e..c1dd821 100644 --- a/server/drivers/glk.c +++ b/server/drivers/glk.c @@ -355,18 +355,13 @@ int glk_contrast(int contrast) // void glk_backlight(int on) { - /* - if(on) - { + if(on) { // printf("Backlight ON\n"); glkputl( PortFD, GLKCommand, 0x42, 0, EOF ); - } - else - { + } else { // printf("Backlight OFF\n"); glkputl( PortFD, GLKCommand, 0x46, EOF ); } - */ } ////////////////////////////////////////////////////////////////////// @@ -638,7 +633,7 @@ char glk_getkey() msec_diff = (now.tv_sec - lastkey.tv_sec) * 1000 ; msec_diff += (now.tv_usec - lastkey.tv_usec) / 1000 ; // printf( "KEY %c down for %d msec\n", key, msec_diff ); - if( msec_diff > 2000 ) { + if( msec_diff > 1000 ) { /* Generate repeat event */ c = key | 0x20 ; /* Upper case to lower case */ ++lastkey.tv_sec ; /* HACK HACK. repeat at 1 sec intervals */ @@ -656,6 +651,7 @@ char glk_getkey() case 'L' : c = 'D' ; break ; /* Menu/Exit */ case 'U' : c = 'E' ; break ; /* Up */ case 'K' : c = 'F' ; break ; /* Down */ + case 'v' : c = 'N' ; break ; case 'p' : c = 'O' ; break ; case 'q' : c = 'P' ; break ; diff --git a/server/drivers/glkproto.c b/server/drivers/glkproto.c index 84e1e99..84b11d6 100644 --- a/server/drivers/glkproto.c +++ b/server/drivers/glkproto.c @@ -81,14 +81,12 @@ GLKDisplay * * framing errors incase the module transmits back * to back with only one stop bit. */ -#ifndef IRIX -#ifndef SOLARIS - cfmakeraw( &new ); /* Sets CS8 */ -#endif -#endif - new.c_iflag |= IGNPAR ; /* Ignore framing/parity errors */ - new.c_cflag &= ~(CBAUD | CRTSCTS ) ; - new.c_cflag |= speed | CREAD | CLOCAL | CSTOPB ; + new.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | IGNPAR | ISTRIP + | INLCR | IGNCR | ICRNL | IXON ); + new.c_oflag &= ~OPOST; + new.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); + new.c_cflag &= ~( CBAUD | CSIZE | PARENB | CRTSCTS ); + new.c_cflag |= speed | CS8 | CREAD | CLOCAL | CSTOPB ; new.c_cc[VMIN] = 0 ; new.c_cc[VTIME] = GLK_TIMEOUT ; diff --git a/server/drivers/hd44780-4bit.c b/server/drivers/hd44780-4bit.c index 49cdc93..bedf7e6 100644 --- a/server/drivers/hd44780-4bit.c +++ b/server/drivers/hd44780-4bit.c @@ -39,7 +39,7 @@ #include "hd44780-4bit.h" #include "port.h" -#include "../../shared/str.h" +#include "shared/str.h" #include #include #include diff --git a/server/drivers/hd44780-winamp.c b/server/drivers/hd44780-winamp.c index 2602896..6c4b708 100644 --- a/server/drivers/hd44780-winamp.c +++ b/server/drivers/hd44780-winamp.c @@ -35,7 +35,7 @@ #include "hd44780-winamp.h" #include "port.h" -#include "../../shared/str.h" +#include "shared/str.h" #include #include #include diff --git a/server/drivers/hd44780.c b/server/drivers/hd44780.c index 36fc7c2..a2203f5 100644 --- a/server/drivers/hd44780.c +++ b/server/drivers/hd44780.c @@ -66,7 +66,7 @@ # include #endif -#include "../../shared/str.h" +#include "shared/str.h" #include "lcd.h" #include "hd44780.h" diff --git a/server/drivers/irmanin.c b/server/drivers/irmanin.c index 00384e6..ce8d3e9 100644 --- a/server/drivers/irmanin.c +++ b/server/drivers/irmanin.c @@ -17,8 +17,8 @@ #define __u32 unsigned int #define __u8 unsigned char -#include "../../shared/debug.h" -#include "../../shared/str.h" +#include "shared/debug.h" +#include "shared/str.h" #define NAME_LENGTH 128 diff --git a/server/drivers/joy.c b/server/drivers/joy.c index bdd2573..125d008 100644 --- a/server/drivers/joy.c +++ b/server/drivers/joy.c @@ -10,8 +10,8 @@ #include -#include "../../shared/debug.h" -#include "../../shared/str.h" +#include "shared/debug.h" +#include "shared/str.h" #define NAME_LENGTH 128 diff --git a/server/drivers/lb216.c b/server/drivers/lb216.c index fdcd6b5..2950752 100644 --- a/server/drivers/lb216.c +++ b/server/drivers/lb216.c @@ -5,22 +5,23 @@ #include #include #include -#ifdef HAVE_NCURSES_H -#include -#else -#include + +#ifdef HAVE_CONFIG_H +# include "config.h" #endif -#include "../../shared/str.h" +#ifdef HAVE_NCURSES_H +# include +#else +# include +#endif +#include "shared/str.h" +#include "shared/debug.h" #include "lcd.h" #include "lb216.h" #include "drv_base.h" - -#include "../render.h" - -#include "../../shared/debug.h" -#include "../../config.h" +#include "render.h" static int custom=0; typedef enum { diff --git a/server/drivers/lcd.c b/server/drivers/lcd.c index 9b229a0..8b30cd4 100644 --- a/server/drivers/lcd.c +++ b/server/drivers/lcd.c @@ -10,7 +10,7 @@ #include "config.h" #endif -#include "../../shared/LL.h" +#include "shared/LL.h" #include "lcd.h" diff --git a/server/drivers/lircin.c b/server/drivers/lircin.c index a630bd9..28ac1ac 100644 --- a/server/drivers/lircin.c +++ b/server/drivers/lircin.c @@ -17,8 +17,8 @@ #define __u32 unsigned int #define __u8 unsigned char -#include "../../shared/debug.h" -#include "../../shared/str.h" +#include "shared/debug.h" +#include "shared/str.h" #define NAME_LENGTH 128 diff --git a/server/drivers/svgalib_drv.c b/server/drivers/svgalib_drv.c index da97b00..e76e2eb 100644 --- a/server/drivers/svgalib_drv.c +++ b/server/drivers/svgalib_drv.c @@ -26,7 +26,7 @@ #include #include -#include "../../shared/str.h" +#include "shared/str.h" #include "lcd.h" #include "svgalib_drv.h" diff --git a/server/drivers/wirz-sli.c b/server/drivers/wirz-sli.c index f931042..85513e1 100644 --- a/server/drivers/wirz-sli.c +++ b/server/drivers/wirz-sli.c @@ -15,8 +15,8 @@ #include "wirz-sli.h" #include "drv_base.h" -#include "../../shared/debug.h" -#include "../../shared/str.h" +#include "shared/debug.h" +#include "shared/str.h" static int custom = 0; typedef enum { diff --git a/server/input.c b/server/input.c index 486f7f0..06b7d51 100644 --- a/server/input.c +++ b/server/input.c @@ -28,8 +28,8 @@ #include #include -#include "../shared/sockets.h" -#include "../shared/debug.h" +#include "shared/sockets.h" +#include "shared/debug.h" #include "drivers/lcd.h" diff --git a/server/main.c b/server/main.c index c1d8151..882773a 100644 --- a/server/main.c +++ b/server/main.c @@ -19,7 +19,7 @@ #include #include -#include "../shared/debug.h" +#include "shared/debug.h" #include "drivers/lcd.h" #include "sock.h" diff --git a/server/menus.c b/server/menus.c index 6f0ac56..03e3b45 100644 --- a/server/menus.c +++ b/server/menus.c @@ -14,7 +14,7 @@ #include #include -#include "../shared/debug.h" +#include "shared/debug.h" #include "drivers/lcd.h" diff --git a/server/parse.c b/server/parse.c index 7d3596b..cd01090 100644 --- a/server/parse.c +++ b/server/parse.c @@ -13,9 +13,9 @@ #include #include -#include "../shared/LL.h" -#include "../shared/sockets.h" -#include "../shared/debug.h" +#include "shared/LL.h" +#include "shared/sockets.h" +#include "shared/debug.h" #include "clients.h" #include "client_functions.h" #include "parse.h" diff --git a/server/render.c b/server/render.c index 7ce2226..eb00d9c 100644 --- a/server/render.c +++ b/server/render.c @@ -16,8 +16,8 @@ #include #include -#include "../shared/debug.h" -#include "../shared/LL.h" +#include "shared/debug.h" +#include "shared/LL.h" #include "drivers/lcd.h" diff --git a/server/screen.c b/server/screen.c index b23df7f..7895c31 100644 --- a/server/screen.c +++ b/server/screen.c @@ -2,7 +2,7 @@ #include #include -#include "../shared/debug.h" +#include "shared/debug.h" #include "drivers/lcd.h" @@ -25,12 +25,12 @@ screen_create () s->id = NULL; s->name = NULL; - s->priority = 128; - // TODO: Make the screen duration configurable! - s->duration = 32; + s->priority = 128; // Default priority + s->duration = 32; // Default duration (~ 8 seconds) s->heartbeat = 1; s->wid = lcd.wid; s->hgt = lcd.hgt; + s->keys = NULL; s->parent = NULL; s->widgets = NULL; @@ -63,6 +63,8 @@ screen_destroy (screen * s) free (s->id); if (s->name) free (s->name); + if (s->keys) + free (s->keys); free (s); diff --git a/server/screen.h b/server/screen.h index 4056d07..d846731 100644 --- a/server/screen.h +++ b/server/screen.h @@ -1,7 +1,7 @@ #ifndef SCREEN_H #define SCREEN_H -#include "../shared/LL.h" +#include "shared/LL.h" #include "clients.h" typedef struct screen { @@ -11,6 +11,7 @@ typedef struct screen { int priority; int duration; int heartbeat; + char *keys; LL *widgets; client *parent; } screen; diff --git a/server/screenlist.c b/server/screenlist.c index 1894fa5..8409a65 100644 --- a/server/screenlist.c +++ b/server/screenlist.c @@ -1,9 +1,9 @@ #include #include -#include "../shared/LL.h" -#include "../shared/sockets.h" -#include "../shared/debug.h" +#include "shared/LL.h" +#include "shared/sockets.h" +#include "shared/debug.h" #include "screenlist.h" #include "screen.h" #include "clients.h" diff --git a/server/sock.h b/server/sock.h index 26fb5b6..260dd86 100644 --- a/server/sock.h +++ b/server/sock.h @@ -1,7 +1,7 @@ #ifndef SOCKETS_H #define SOCKETS_H -#include "../shared/sockets.h" +#include "shared/sockets.h" typedef struct sockaddr_in sockaddr_in; diff --git a/server/widget.c b/server/widget.c index 7c4a514..b192529 100644 --- a/server/widget.c +++ b/server/widget.c @@ -2,8 +2,8 @@ #include #include -#include "../shared/sockets.h" -#include "../shared/debug.h" +#include "shared/sockets.h" +#include "shared/debug.h" #include "screen.h" #include "widget.h" @@ -17,7 +17,6 @@ char *types[] = { "none", "scroller", "frame", "num", - "keys", //"", NULL, }; @@ -107,26 +106,6 @@ widget_find (screen * s, char *id) debug ("widget_find(%s)\n", id); return widget_finder (s->widgets, id); -/* - LL_Rewind(s->widgets); - do { - w = LL_Get(s->widgets); - if( (w) && (0 == strcmp(w->id, id))) - { - debug("widget_find: Found %s\n", id); - return w; - } - // TODO: Search kids too! - if( w->type == WID_FRAME ) - { - err = widget_finder(w->kids, id); - if(err) return err; - } - - } while(LL_Next(s->widgets) == 0); - - return NULL; -*/ } widget * diff --git a/server/widget.h b/server/widget.h index 9939fac..7056f87 100644 --- a/server/widget.h +++ b/server/widget.h @@ -26,7 +26,6 @@ typedef struct widget { #define WID_SCROLLER 6 #define WID_FRAME 7 #define WID_NUM 8 -#define WID_KEYS 9 #define WID_MAX_DIR 4 diff --git a/shared/debug.h b/shared/debug.h index 4bffa75..cefb944 100644 --- a/shared/debug.h +++ b/shared/debug.h @@ -1,7 +1,9 @@ #ifndef DEBUG_H #define DEBUG_H -#include "../config.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #ifdef DEBUG diff --git a/shared/sockets.c b/shared/sockets.c index 98c0229..550180b 100644 --- a/shared/sockets.c +++ b/shared/sockets.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -96,7 +95,7 @@ sock_send_string (int fd, char *string) if (!string) return -1; - len = strlen (string) + 1; + len = strlen (string) ; while (offset != len) { // write isn't guaranteed to send the entire string at once, // so we have to sent it in a loop like this