+ 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.
This commit is contained in:
ppokorny
2001-05-25 03:14:27 +00:00
parent 211a3a4b04
commit 00cc9fca23
48 changed files with 222 additions and 223 deletions
+1
View File
@@ -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)
+1 -1
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include <string.h>
#include "../shared/debug.h"
#include "shared/debug.h"
#include "client_data.h"
#include "screen.h"
+1 -1
View File
@@ -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
+60 -54
View File
@@ -15,8 +15,8 @@
#include <ctype.h>
#include <errno.h>
#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;
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
+4 -3
View File
@@ -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[];
+1 -1
View File
@@ -18,7 +18,7 @@
#include "clients.h"
#include "client_data.h"
#include "../shared/debug.h"
#include "shared/debug.h"
LL *clients;
+1 -1
View File
@@ -2,7 +2,7 @@
#define CLIENTS_H
#include "client_data.h"
#include "../shared/LL.h"
#include "shared/LL.h"
typedef struct client {
int sock;
+8 -6
View File
@@ -5,15 +5,17 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#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 {
+5
View File
@@ -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)
+7 -4
View File
@@ -5,13 +5,16 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#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;
+1 -2
View File
@@ -10,7 +10,7 @@
#include <termios.h>
#include <fcntl.h>
#include <string.h>
#include <sys/errno.h>
#include <errno.h>
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -26,7 +26,6 @@
# endif
#endif
#ifdef SOLARIS
# include <errno.h>
# include <strings.h>
#endif
#include "lcd.h"
+1 -1
View File
@@ -15,7 +15,7 @@
#include <curses.h>
#endif
#include "../../shared/str.h"
#include "shared/str.h"
#include "lcd.h"
#include "curses_drv.h"
+4 -8
View File
@@ -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 ;
+6 -8
View File
@@ -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 ;
+1 -1
View File
@@ -39,7 +39,7 @@
#include "hd44780-4bit.h"
#include "port.h"
#include "../../shared/str.h"
#include "shared/str.h"
#include <sys/perm.h>
#include <stdio.h>
#include <string.h>
+1 -1
View File
@@ -35,7 +35,7 @@
#include "hd44780-winamp.h"
#include "port.h"
#include "../../shared/str.h"
#include "shared/str.h"
#include <sys/perm.h>
#include <stdio.h>
#include <string.h>
+1 -1
View File
@@ -66,7 +66,7 @@
# include <time.h>
#endif
#include "../../shared/str.h"
#include "shared/str.h"
#include "lcd.h"
#include "hd44780.h"
+2 -2
View File
@@ -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
+2 -2
View File
@@ -10,8 +10,8 @@
#include <linux/joystick.h>
#include "../../shared/debug.h"
#include "../../shared/str.h"
#include "shared/debug.h"
#include "shared/str.h"
#define NAME_LENGTH 128
+11 -10
View File
@@ -5,22 +5,23 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "../../shared/str.h"
#ifdef HAVE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
#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 {
+1 -1
View File
@@ -10,7 +10,7 @@
#include "config.h"
#endif
#include "../../shared/LL.h"
#include "shared/LL.h"
#include "lcd.h"
+2 -2
View File
@@ -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
+1 -1
View File
@@ -26,7 +26,7 @@
#include <vga.h>
#include <vgagl.h>
#include "../../shared/str.h"
#include "shared/str.h"
#include "lcd.h"
#include "svgalib_drv.h"
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -28,8 +28,8 @@
#include <stdio.h>
#include <string.h>
#include "../shared/sockets.h"
#include "../shared/debug.h"
#include "shared/sockets.h"
#include "shared/debug.h"
#include "drivers/lcd.h"
+1 -1
View File
@@ -19,7 +19,7 @@
#include <signal.h>
#include <unistd.h>
#include "../shared/debug.h"
#include "shared/debug.h"
#include "drivers/lcd.h"
#include "sock.h"
+1 -1
View File
@@ -14,7 +14,7 @@
#include <stdio.h>
#include <unistd.h>
#include "../shared/debug.h"
#include "shared/debug.h"
#include "drivers/lcd.h"
+3 -3
View File
@@ -13,9 +13,9 @@
#include <stdio.h>
#include <string.h>
#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"
+2 -2
View File
@@ -16,8 +16,8 @@
#include <string.h>
#include <stdio.h>
#include "../shared/debug.h"
#include "../shared/LL.h"
#include "shared/debug.h"
#include "shared/LL.h"
#include "drivers/lcd.h"
+6 -4
View File
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
#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);
+2 -1
View File
@@ -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;
+3 -3
View File
@@ -1,9 +1,9 @@
#include <stdlib.h>
#include <stdio.h>
#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"
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef SOCKETS_H
#define SOCKETS_H
#include "../shared/sockets.h"
#include "shared/sockets.h"
typedef struct sockaddr_in sockaddr_in;
+2 -23
View File
@@ -2,8 +2,8 @@
#include <stdio.h>
#include <string.h>
#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 *
-1
View File
@@ -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