* coding style harmonization in servers/

- explicitely declare void arguments
  - make a few string args const
* better support for shorter displays in server screen
* make target to create top level tag file
This commit is contained in:
marschap
2007-04-02 21:29:53 +00:00
parent a63ae89eb7
commit 6a1511bb72
100 changed files with 2180 additions and 2170 deletions
+4
View File
@@ -22,4 +22,8 @@ install-html-userguide:
dox: dox:
$(MAKE) -C docs $@ $(MAKE) -C docs $@
topleveltags:
$(CTAGS) --format=1 -f - --languages=C --c-kinds=f --recurse=yes server shared clients \
| perl -p -e 's/^([^\t]+)\t[^\t]+\/([^\t\/]+)\t(.*)$/$1\t$2\t$3/' > tags
## EOF ## EOF
+1 -1
View File
@@ -999,7 +999,7 @@ diff --exclude='*.wanjet' --exclude='.??*' --exclude=config.h --exclude='*.orig'
+ * and every screen add... + * and every screen add...
+ */ + */
+ if( s == server_screen ) { + if( s == server_screen ) {
+ update_server_screen (timer); + update_server_screen();
+ } + }
+ render_screen (s, timer); + render_screen (s, timer);
+ +
+54 -54
View File
@@ -25,16 +25,16 @@
#include "shared/report.h" #include "shared/report.h"
#include "shared/LL.h" #include "shared/LL.h"
Client * client_create (int sock) Client *client_create(int sock)
{ {
Client *c; Client *c;
debug (RPT_DEBUG, "%s( sock=%i )", __FUNCTION__, sock); debug(RPT_DEBUG, "%s(sock=%i)", __FUNCTION__, sock);
/* Allocate new client...*/ /* Allocate new client...*/
c = malloc (sizeof (Client)); c = malloc(sizeof(Client));
if (!c) { if (!c) {
report (RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
return NULL; return NULL;
} }
/* Init struct members*/ /* Init struct members*/
@@ -44,10 +44,10 @@ Client * client_create (int sock)
c->heartbeat = HEARTBEAT_OPEN; c->heartbeat = HEARTBEAT_OPEN;
/*Set up message list...*/ /*Set up message list...*/
c->messages = LL_new (); c->messages = LL_new();
if (!c->messages) { if (!c->messages) {
report (RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
free (c); free(c);
return NULL; return NULL;
} }
@@ -58,79 +58,79 @@ Client * client_create (int sock)
c->screenlist = LL_new(); c->screenlist = LL_new();
if (!c->screenlist) { if (!c->screenlist) {
report( RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
return NULL; return NULL;
} }
return c; return c;
} }
int int
client_destroy (Client * c) client_destroy(Client *c)
{ {
Screen *s; Screen *s;
char * str; char *str;
if (!c) if (!c)
return -1; return -1;
debug (RPT_DEBUG, "%s( c=[%d] )", __FUNCTION__, c->sock ); debug(RPT_DEBUG, "%s(c=[%d])", __FUNCTION__, c->sock);
/* Close the socket */ /* Close the socket */
close (c->sock); close(c->sock);
/* Eat messages */ /* Eat messages */
while ((str = client_get_message (c))) { while ((str = client_get_message(c))) {
free (str); free(str);
} }
LL_Destroy( c->messages ); LL_Destroy(c->messages);
/* Clean up the screenlist...*/ /* Clean up the screenlist...*/
debug( RPT_DEBUG, "%s: Cleaning screenlist", __FUNCTION__); debug(RPT_DEBUG, "%s: Cleaning screenlist", __FUNCTION__);
for( s=LL_GetFirst (c->screenlist); s; s=LL_GetNext(c->screenlist) ) { for (s = LL_GetFirst(c->screenlist); s; s = LL_GetNext(c->screenlist)) {
/* Free its memory...*/ /* Free its memory...*/
screen_destroy (s); screen_destroy(s);
/* Note that the screen is not removed from the list because /* Note that the screen is not removed from the list because
* the list will be destroyed anyway... * the list will be destroyed anyway...
*/ */
} }
LL_Destroy( c->screenlist); LL_Destroy(c->screenlist);
/* Destroy the client's menu, if it exists */ /* Destroy the client's menu, if it exists */
if (c->menu) { if (c->menu) {
menuscreen_inform_item_destruction (c->menu); menuscreen_inform_item_destruction(c->menu);
menu_remove_item (c->menu->parent, c->menu); menu_remove_item(c->menu->parent, c->menu);
menuscreen_inform_item_modified (c->menu->parent); menuscreen_inform_item_modified(c->menu->parent);
menuitem_destroy (c->menu); menuitem_destroy(c->menu);
} }
/* Forget client's key reservations */ /* Forget client's key reservations */
input_release_client_keys (c); input_release_client_keys(c);
/* Free client's other data */ /* Free client's other data */
c->ack = 0; c->ack = 0;
/* Clean up the name...*/ /* Clean up the name...*/
if (c->name) if (c->name)
free (c->name); free(c->name);
/* Remove structure */ /* Remove structure */
free (c); free(c);
debug( RPT_DEBUG, "%s: Client data removed", __FUNCTION__); debug(RPT_DEBUG, "%s: Client data removed", __FUNCTION__);
return 0; return 0;
} }
/*Add and remove messages from the client's queue...*/ /*Add and remove messages from the client's queue...*/
int int
client_add_message (Client * c, char *message) client_add_message(Client *c, char *message)
{ {
int err = 0; int err = 0;
char *dup; char *dup;
char *str, *cp; char *str, *cp;
char delimiters[] = "\n\r\0"; char delimiters[] = "\n\r\0";
debug(RPT_DEBUG, "%s( c=[%d], message=\"%s\" )", __FUNCTION__, c->sock, message); debug(RPT_DEBUG, "%s(c=[%d], message=\"%s\")", __FUNCTION__, c->sock, message);
if (!c) if (!c)
return -1; return -1;
@@ -138,19 +138,19 @@ client_add_message (Client * c, char *message)
return -1; return -1;
/* Copy the string to avoid overwriting the original...*/ /* Copy the string to avoid overwriting the original...*/
dup = strdup (message); dup = strdup(message);
if (!dup) { if (!dup) {
report(RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
return -1; return -1;
} }
/* Now split the string into lines and enqueue each one...*/ /* Now split the string into lines and enqueue each one...*/
for (str = strtok (dup, delimiters); str; str = strtok (NULL, delimiters)) { for (str = strtok(dup, delimiters); str; str = strtok(NULL, delimiters)) {
cp = strdup (str); cp = strdup(str);
debug (RPT_DEBUG, "%s: Queued message: \"%s\"", __FUNCTION__, cp); debug(RPT_DEBUG, "%s: Queued message: \"%s\"", __FUNCTION__, cp);
err += LL_Enqueue (c->messages, (void *) cp); err += LL_Enqueue(c->messages, (void *) cp);
} }
free (dup); free(dup);
/* Err is the number of errors encountered...*/ /* Err is the number of errors encountered...*/
return err; return err;
@@ -158,23 +158,23 @@ client_add_message (Client * c, char *message)
/* Woo-hoo! A simple function. :)*/ /* Woo-hoo! A simple function. :)*/
char * char *
client_get_message (Client * c) client_get_message(Client *c)
{ {
char *str; char *str;
debug(RPT_DEBUG, "%s( c=[%d] )", __FUNCTION__, c->sock); debug(RPT_DEBUG, "%s(c=[%d])", __FUNCTION__, c->sock);
if (!c) if (!c)
return NULL; return NULL;
str = (char *) LL_Dequeue (c->messages); str = (char *) LL_Dequeue(c->messages);
return str; return str;
} }
Screen * Screen *
client_find_screen (Client * c, char *id) client_find_screen(Client *c, char *id)
{ {
Screen *s; Screen *s;
@@ -183,58 +183,58 @@ client_find_screen (Client * c, char *id)
if (!id) if (!id)
return NULL; return NULL;
debug (RPT_DEBUG, "%s( c=[%d], id=\"%s\" )", __FUNCTION__, c->sock, id); debug(RPT_DEBUG, "%s(c=[%d], id=\"%s\")", __FUNCTION__, c->sock, id);
LL_Rewind (c->screenlist); LL_Rewind(c->screenlist);
do { do {
s = LL_Get (c->screenlist); s = LL_Get(c->screenlist);
if ((s) && (0 == strcmp (s->id, id))) { if ((s) && (0 == strcmp(s->id, id))) {
debug (RPT_DEBUG, "%s: Found %s", __FUNCTION__, id); debug(RPT_DEBUG, "%s: Found %s", __FUNCTION__, id);
return s; return s;
} }
} while (LL_Next (c->screenlist) == 0); } while (LL_Next(c->screenlist) == 0);
return NULL; return NULL;
} }
int int
client_add_screen (Client * c, Screen * s) client_add_screen(Client *c, Screen *s)
{ {
if (!c) if (!c)
return -1; return -1;
if (!s) if (!s)
return -1; return -1;
debug (RPT_DEBUG, "%s( c=[%d], s=[%s] )", __FUNCTION__, c->sock, s->id); debug(RPT_DEBUG, "%s(c=[%d], s=[%s])", __FUNCTION__, c->sock, s->id);
LL_Push (c->screenlist, (void *) s); LL_Push(c->screenlist, (void *) s);
/* Now, add it to the screenlist...*/ /* Now, add it to the screenlist...*/
screenlist_add (s); screenlist_add(s);
return 0; return 0;
} }
int int
client_remove_screen (Client * c, Screen * s) client_remove_screen(Client *c, Screen *s)
{ {
if (!c) if (!c)
return -1; return -1;
if (!s) if (!s)
return -1; return -1;
debug (RPT_DEBUG, "%s( c=[%d], s=[%s] )", __FUNCTION__, c->sock, s->id); debug(RPT_DEBUG, "%s(c=[%d], s=[%s])", __FUNCTION__, c->sock, s->id);
/* TODO: Check for errors here?*/ /* TODO: Check for errors here?*/
LL_Remove (c->screenlist, (void *) s); LL_Remove(c->screenlist, (void *) s);
/* Now, remove it from the screenlist...*/ /* Now, remove it from the screenlist...*/
screenlist_remove (s); screenlist_remove(s);
return 0; return 0;
} }
int client_screen_count (Client * c) int client_screen_count(Client *c)
{ {
return LL_Length(c->screenlist); return LL_Length(c->screenlist);
} }
+10 -10
View File
@@ -37,35 +37,35 @@ typedef struct Client {
LinkedList *screenlist; LinkedList *screenlist;
/* Maybe it has created a menu */ /* Maybe it has created a menu */
Menu * menu; Menu *menu;
} Client; } Client;
#include "screen.h" #include "screen.h"
/* When a new client connects, set up a new client data struct */ /* When a new client connects, set up a new client data struct */
Client * client_create (int sock); Client *client_create(int sock);
/* Destroys the client data */ /* Destroys the client data */
int client_destroy (Client * c); int client_destroy(Client *c);
/* Close the socket */ /* Close the socket */
void client_close_sock (Client * c); void client_close_sock(Client *c);
/* Add message to the client's queue...*/ /* Add message to the client's queue...*/
int client_add_message (Client * c, char *message); int client_add_message(Client *c, char *message);
/* Get message from queue */ /* Get message from queue */
char * client_get_message (Client * c); char *client_get_message(Client *c);
/* Find a named screen for the client */ /* Find a named screen for the client */
Screen * client_find_screen (Client * c, char *id); Screen *client_find_screen(Client *c, char *id);
int client_add_screen (Client * c, Screen * s); int client_add_screen(Client *c, Screen *s);
int client_remove_screen (Client * c, Screen * s); int client_remove_screen(Client *c, Screen *s);
int client_screen_count (Client * c); int client_screen_count(Client *c);
#endif #endif
+26 -26
View File
@@ -29,13 +29,13 @@ LinkedList *clientlist = NULL;
/* Initialize and kill client list...*/ /* Initialize and kill client list...*/
int int
clients_init () clients_init(void)
{ {
debug(RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
clientlist = LL_new (); clientlist = LL_new();
if (!clientlist) { if (!clientlist) {
report( RPT_ERR, "%s: Unable to create client list", __FUNCTION__); report(RPT_ERR, "%s: Unable to create client list", __FUNCTION__);
return -1; return -1;
} }
@@ -43,68 +43,68 @@ clients_init ()
} }
int int
clients_shutdown () clients_shutdown(void)
{ {
Client *c; Client *c;
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
if( !clientlist ) { if (!clientlist) {
/* Program shutdown before completed startup */ /* Program shutdown before completed startup */
return -1; return -1;
} }
/* Free all client structures... */ /* Free all client structures... */
for (c=LL_GetFirst (clientlist); c; c=LL_GetNext (clientlist) ) { for (c = LL_GetFirst(clientlist); c; c = LL_GetNext(clientlist)) {
debug (RPT_DEBUG, "%s: ...", __FUNCTION__); debug(RPT_DEBUG, "%s: ...", __FUNCTION__);
if (c) { if (c) {
debug (RPT_DEBUG, "%s: ... %i ...", __FUNCTION__, c->sock); debug(RPT_DEBUG, "%s: ... %i ...", __FUNCTION__, c->sock);
if (client_destroy (c) != 0) { if (client_destroy(c) != 0) {
report (RPT_ERR, "%s: Error freeing client", __FUNCTION__); report(RPT_ERR, "%s: Error freeing client", __FUNCTION__);
} else { } else {
debug (RPT_DEBUG, "%s: Freed client...", __FUNCTION__); debug(RPT_DEBUG, "%s: Freed client...", __FUNCTION__);
} }
} else { } else {
debug (RPT_DEBUG, "%s: No client!", __FUNCTION__); debug(RPT_DEBUG, "%s: No client!", __FUNCTION__);
} }
} }
/* Then, free the list...*/ /* Then, free the list...*/
LL_Destroy (clientlist); LL_Destroy(clientlist);
debug (RPT_DEBUG, "%s: done", __FUNCTION__); debug(RPT_DEBUG, "%s: done", __FUNCTION__);
return 0; return 0;
} }
int int
clients_add_client (Client *c) clients_add_client(Client *c)
{ {
/* Add the client to the clients list... */ /* Add the client to the clients list... */
return LL_Push (clientlist, c); return LL_Push(clientlist, c);
} }
int int
clients_remove_client (Client *c) clients_remove_client(Client *c)
{ {
/* Remove the client from the clients list... */ /* Remove the client from the clients list... */
return (LL_Remove (clientlist, c) == NULL)?-1:0; return(LL_Remove(clientlist, c) == NULL)?-1:0;
} }
Client * Client *
clients_getfirst () clients_getfirst(void)
{ {
return (Client *) LL_GetFirst(clientlist); return (Client *) LL_GetFirst(clientlist);
} }
Client * Client *
clients_getnext () clients_getnext(void)
{ {
return (Client *) LL_GetNext(clientlist); return (Client *) LL_GetNext(clientlist);
} }
int int
clients_client_count () clients_client_count(void)
{ {
return LL_Length(clientlist); return LL_Length(clientlist);
} }
@@ -115,19 +115,19 @@ clients_client_count ()
*/ */
Client * Client *
clients_find_client_by_sock (int sock) clients_find_client_by_sock(int sock)
{ {
Client *c; Client *c;
debug(RPT_DEBUG, "%s( sock=%i )", __FUNCTION__, sock); debug(RPT_DEBUG, "%s(sock=%i)", __FUNCTION__, sock);
for( c=LL_GetFirst(clientlist); c; c=LL_GetNext(clientlist) ) { for (c = LL_GetFirst(clientlist); c; c = LL_GetNext(clientlist)) {
if (c->sock == sock) { if (c->sock == sock) {
return c; return c;
} }
} }
debug (RPT_ERR, "%s: failed", __FUNCTION__); debug(RPT_ERR, "%s: failed", __FUNCTION__);
return NULL; return NULL;
} }
+8 -8
View File
@@ -18,19 +18,19 @@
/* extern LinkedList *clientlist; Not needed outside ? */ /* extern LinkedList *clientlist; Not needed outside ? */
/* Initialize and kill client list...*/ /* Initialize and kill client list...*/
int clients_init (); int clients_init(void);
int clients_shutdown (); int clients_shutdown(void);
/* Add/remove clients (return -1 for error) */ /* Add/remove clients (return -1 for error) */
int clients_add_client (Client *c); int clients_add_client(Client *c);
int clients_remove_client (Client *c); int clients_remove_client(Client *c);
/* List functions */ /* List functions */
Client * clients_getfirst (); Client *clients_getfirst(void);
Client * clients_getnext (); Client *clients_getnext(void);
int clients_client_count (); int clients_client_count(void);
/* Search for a client with a particular filedescriptor...*/ /* Search for a client with a particular filedescriptor...*/
Client * clients_find_client_by_sock (int sock); Client * clients_find_client_by_sock(int sock);
#endif #endif
+142 -142
View File
@@ -41,202 +41,202 @@
typedef struct driver_symbols { typedef struct driver_symbols {
char *name; const char *name;
short offset; /* offset in Driver structure */ short offset; /* offset in Driver structure */
short required; short required;
} DriverSymbols; } DriverSymbols;
DriverSymbols driver_symbols[] = { DriverSymbols driver_symbols[] = {
{ "api_version", offsetof(Driver, api_version), 1 }, { "api_version", offsetof(Driver, api_version), 1 },
{ "stay_in_foreground", offsetof(Driver, stay_in_foreground), 1 }, { "stay_in_foreground", offsetof(Driver, stay_in_foreground), 1 },
{ "supports_multiple", offsetof(Driver, supports_multiple), 1 }, { "supports_multiple", offsetof(Driver, supports_multiple), 1 },
{ "symbol_prefix", offsetof(Driver, symbol_prefix), 1 }, { "symbol_prefix", offsetof(Driver, symbol_prefix), 1 },
{ "init", offsetof(Driver, init), 1 }, { "init", offsetof(Driver, init), 1 },
{ "close", offsetof(Driver, close), 1 }, { "close", offsetof(Driver, close), 1 },
{ "width", offsetof(Driver, width), 0 }, { "width", offsetof(Driver, width), 0 },
{ "height", offsetof(Driver, height), 0 }, { "height", offsetof(Driver, height), 0 },
{ "clear", offsetof(Driver, clear), 0 }, { "clear", offsetof(Driver, clear), 0 },
{ "flush", offsetof(Driver, flush), 0 }, { "flush", offsetof(Driver, flush), 0 },
{ "string", offsetof(Driver, string), 0 }, { "string", offsetof(Driver, string), 0 },
{ "chr", offsetof(Driver, chr), 0 }, { "chr", offsetof(Driver, chr), 0 },
{ "vbar", offsetof(Driver, vbar), 0 }, { "vbar", offsetof(Driver, vbar), 0 },
{ "hbar", offsetof(Driver, hbar), 0 }, { "hbar", offsetof(Driver, hbar), 0 },
{ "num", offsetof(Driver, num), 0 }, { "num", offsetof(Driver, num), 0 },
{ "heartbeat", offsetof(Driver, heartbeat), 0 }, { "heartbeat", offsetof(Driver, heartbeat), 0 },
{ "icon", offsetof(Driver, icon), 0 }, { "icon", offsetof(Driver, icon), 0 },
{ "cursor", offsetof(Driver, cursor), 0 }, { "cursor", offsetof(Driver, cursor), 0 },
{ "set_char", offsetof(Driver, set_char), 0 }, { "set_char", offsetof(Driver, set_char), 0 },
{ "get_free_chars", offsetof(Driver, get_free_chars), 0 }, { "get_free_chars", offsetof(Driver, get_free_chars), 0 },
{ "cellwidth", offsetof(Driver, cellwidth), 0 }, { "cellwidth", offsetof(Driver, cellwidth), 0 },
{ "cellheight", offsetof(Driver, cellheight), 0 }, { "cellheight", offsetof(Driver, cellheight), 0 },
{ "get_contrast", offsetof(Driver, get_contrast), 0 }, { "get_contrast", offsetof(Driver, get_contrast), 0 },
{ "set_contrast", offsetof(Driver, set_contrast), 0 }, { "set_contrast", offsetof(Driver, set_contrast), 0 },
{ "get_brightness", offsetof(Driver, get_brightness), 0 }, { "get_brightness", offsetof(Driver, get_brightness), 0 },
{ "set_brightness", offsetof(Driver, set_brightness), 0 }, { "set_brightness", offsetof(Driver, set_brightness), 0 },
{ "backlight", offsetof(Driver, backlight), 0 }, { "backlight", offsetof(Driver, backlight), 0 },
{ "output", offsetof(Driver, output), 0 }, { "output", offsetof(Driver, output), 0 },
{ "get_key", offsetof(Driver, get_key), 0 }, { "get_key", offsetof(Driver, get_key), 0 },
{ "get_info", offsetof(Driver, get_info), 0 }, { "get_info", offsetof(Driver, get_info), 0 },
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
/* Functions for the driver */ /* Functions for the driver */
static int request_display_width(); static int request_display_width(void);
static int request_display_height(); static int request_display_height(void);
static int driver_store_private_ptr(Driver * driver, void * private_data); static int driver_store_private_ptr(Driver *driver, void *private_data);
Driver * Driver *
driver_load( char * name, char * filename ) driver_load(const char *name, const char *filename)
{ {
Driver * driver = NULL; Driver *driver = NULL;
int res; int res;
report( RPT_DEBUG, "%s( name=\"%.40s\", filename=\"%.80s\")", __FUNCTION__, name, filename ); report(RPT_DEBUG, "%s(name=\"%.40s\", filename=\"%.80s\")", __FUNCTION__, name, filename);
/* Allocate memory for new driver struct */ /* Allocate memory for new driver struct */
driver = malloc( sizeof( Driver )); driver = malloc(sizeof(Driver));
memset( driver, 0, sizeof (Driver)); memset(driver, 0, sizeof(Driver));
/* And store its name and filename */ /* And store its name and filename */
driver->name = malloc( strlen( name ) + 1 ); driver->name = malloc(strlen(name) + 1);
strcpy( driver->name, name ); strcpy(driver->name, name);
driver->filename = malloc( strlen( filename ) + 1 ); driver->filename = malloc(strlen(filename) + 1);
strcpy( driver->filename, filename ); strcpy(driver->filename, filename);
/* Load and bind the driver module and locate the symbols */ /* Load and bind the driver module and locate the symbols */
if( driver_bind_module( driver ) < 0 ) { if (driver_bind_module(driver) < 0) {
report( RPT_ERR, "Driver [%.40s] binding failed", name ); report(RPT_ERR, "Driver [%.40s] binding failed", name);
free( driver->name ); free(driver->name);
free( driver->filename ); free(driver->filename);
free( driver ); free(driver);
return NULL; return NULL;
} }
/* Check module version */ /* Check module version */
if( strcmp( *(driver->api_version), API_VERSION ) != 0 ) { if (strcmp(*(driver->api_version), API_VERSION) != 0) {
report( RPT_ERR, "Driver [%.40s] is of an incompatible version", name ); report(RPT_ERR, "Driver [%.40s] is of an incompatible version", name);
driver_unbind_module( driver ); driver_unbind_module(driver);
free( driver->name ); free(driver->name);
free( driver->filename ); free(driver->filename);
free( driver ); free(driver);
return NULL; return NULL;
} }
/* Call the init function */ /* Call the init function */
debug( RPT_DEBUG, "%s: Calling driver [%.40s] init function", __FUNCTION__, driver->name ); debug(RPT_DEBUG, "%s: Calling driver [%.40s] init function", __FUNCTION__, driver->name);
res = driver->init( driver ); res = driver->init(driver);
if( res < 0 ) { if (res < 0) {
report( RPT_ERR, "Driver [%.40s] init failed, return code < 0", driver->name ); report(RPT_ERR, "Driver [%.40s] init failed, return code < 0", driver->name);
/* Driver load failed, driver should not be added to list /* Driver load failed, driver should not be added to list
* Free driver structure again * Free driver structure again
*/ */
driver_unbind_module( driver ); driver_unbind_module(driver);
free( driver->name ); free(driver->name);
free( driver->filename ); free(driver->filename);
free( driver ); free(driver);
return NULL; return NULL;
} }
debug( RPT_NOTICE, "Driver [%.40s] loaded", driver->name ); debug(RPT_NOTICE, "Driver [%.40s] loaded", driver->name);
return driver; return driver;
} }
int int
driver_unload( Driver * driver ) driver_unload(Driver *driver)
{ {
debug( RPT_NOTICE, "Closing driver [%.40s]", driver->name ); debug(RPT_NOTICE, "Closing driver [%.40s]", driver->name);
if( driver->close ) if (driver->close)
driver->close (driver); driver->close(driver);
/* Unlaod the module */ /* Unlaod the module */
driver_unbind_module( driver ); driver_unbind_module(driver);
/* Free its data */ /* Free its data */
free( driver->filename ); free(driver->filename);
free( driver->name ); free(driver->name);
free( driver ); free(driver);
debug( RPT_DEBUG, "%s: Driver unloaded", __FUNCTION__ ); debug(RPT_DEBUG, "%s: Driver unloaded", __FUNCTION__);
return 0; return 0;
} }
int int
driver_bind_module( Driver * driver ) driver_bind_module(Driver *driver)
{ {
int i; int i;
int missing_symbols = 0; int missing_symbols = 0;
debug( RPT_DEBUG, "%s( driver=[%.40s] )", __FUNCTION__, driver->name ); debug(RPT_DEBUG, "%s(driver=[%.40s])", __FUNCTION__, driver->name);
/* Load the module */ /* Load the module */
#ifndef WIN32 #ifndef WIN32
driver->module_handle = dlopen( driver->filename, RTLD_NOW ); driver->module_handle = dlopen(driver->filename, RTLD_NOW);
#else #else
driver->module_handle = LoadLibraryEx( (driver->filename), NULL, 0 ); driver->module_handle = LoadLibraryEx((driver->filename), NULL, 0);
#endif #endif
if( driver->module_handle == NULL ) { if (driver->module_handle == NULL) {
#ifndef WIN32 #ifndef WIN32
report( RPT_ERR, "Could not open driver module %.40s: %s", driver->filename, dlerror() ); report(RPT_ERR, "Could not open driver module %.40s: %s", driver->filename, dlerror());
#else #else
/* REVISIT: replace dlerror() */ /* REVISIT: replace dlerror() */
report( RPT_ERR, "Could not open driver module %.40s.", driver->filename ); report(RPT_ERR, "Could not open driver module %.40s.", driver->filename);
#endif #endif
return -1; return -1;
} }
/* And locate the symbols */ /* And locate the symbols */
for( i=0; driver_symbols[i].name; i++ ) { for (i = 0; driver_symbols[i].name; i++) {
void (**p)(); void (**p)();
p = (void(**)() ) ((size_t)driver + (driver_symbols[i].offset)); p = (void(**)()) ((size_t)driver + (driver_symbols[i].offset));
*p = NULL; *p = NULL;
/* Add the symbol_prefix */ /* Add the symbol_prefix */
if( driver->symbol_prefix ) { if (driver->symbol_prefix) {
char *s = malloc( strlen( *(driver->symbol_prefix) ) + strlen( driver_symbols[i].name ) + 1 ); char *s = malloc(strlen(*(driver->symbol_prefix)) + strlen(driver_symbols[i].name) + 1);
strcpy( s, *(driver->symbol_prefix) ) ; strcpy(s, *(driver->symbol_prefix));
strcat( s, driver_symbols[i].name ); strcat(s, driver_symbols[i].name);
debug( RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, s ); debug(RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, s);
#ifndef WIN32 #ifndef WIN32
*p = dlsym( driver->module_handle, s ); *p = dlsym(driver->module_handle, s);
#else #else
*p = (void(*)()) (GetProcAddress( driver->module_handle, s )); *p = (void(*)()) (GetProcAddress(driver->module_handle, s));
#endif #endif
free( s ); free(s);
} }
/* Retrieve the symbol */ /* Retrieve the symbol */
if( !*p ) { if (!*p) {
debug( RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, driver_symbols[i].name ); debug(RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, driver_symbols[i].name);
#ifndef WIN32 #ifndef WIN32
*p = dlsym( driver->module_handle, driver_symbols[i].name ); *p = dlsym(driver->module_handle, driver_symbols[i].name);
#else #else
*p = (void(*)()) (GetProcAddress( driver->module_handle, driver_symbols[i].name )); *p = (void(*)()) (GetProcAddress(driver->module_handle, driver_symbols[i].name));
#endif #endif
} }
if( *p ) { if (*p) {
debug( RPT_DEBUG, "%s: found symbol at: %p", __FUNCTION__, *p ); debug(RPT_DEBUG, "%s: found symbol at: %p", __FUNCTION__, *p);
} }
/* Was the symbol required but not found ? */ /* Was the symbol required but not found ? */
if( !*p && driver_symbols[i].required ) { if (!*p && driver_symbols[i].required) {
report( RPT_ERR, "Driver [%.40s] does not have required symbol: %s", driver->name, driver_symbols[i].name ); report(RPT_ERR, "Driver [%.40s] does not have required symbol: %s", driver->name, driver_symbols[i].name);
missing_symbols = 1; missing_symbols = 1;
} }
} }
/* If errors, leave now while we can :) */ /* If errors, leave now while we can :) */
if( missing_symbols ) { if (missing_symbols) {
report( RPT_ERR, "Driver [%.40s] does not have all obligatory symbols", driver->name ); report(RPT_ERR, "Driver [%.40s] does not have all obligatory symbols", driver->name);
#ifndef WIN32 #ifndef WIN32
dlclose( driver->module_handle ); dlclose(driver->module_handle);
#else #else
FreeLibrary( driver->module_handle ); FreeLibrary(driver->module_handle);
#endif #endif
return -1; return -1;
} }
@@ -267,14 +267,14 @@ driver_bind_module( Driver * driver )
int int
driver_unbind_module( Driver * driver ) driver_unbind_module(Driver *driver)
{ {
debug( RPT_DEBUG, "%s( driver=[%.40s] )", __FUNCTION__, driver->name ); debug(RPT_DEBUG, "%s(driver=[%.40s])", __FUNCTION__, driver->name);
#ifndef WIN32 #ifndef WIN32
dlclose( driver->module_handle ); dlclose(driver->module_handle);
#else #else
FreeLibrary( driver->module_handle ); FreeLibrary(driver->module_handle);
#endif #endif
return 0; return 0;
@@ -282,7 +282,7 @@ driver_unbind_module( Driver * driver )
bool bool
driver_does_output( Driver * driver ) driver_does_output(Driver *driver)
{ {
return (driver->width != NULL return (driver->width != NULL
|| driver->height != NULL || driver->height != NULL
@@ -293,30 +293,30 @@ driver_does_output( Driver * driver )
bool bool
driver_does_input( Driver * driver ) driver_does_input(Driver *driver)
{ {
return (driver->get_key != NULL) ? 1 : 0; return (driver->get_key != NULL) ? 1 : 0;
} }
bool bool
driver_stay_in_foreground( Driver * driver ) driver_stay_in_foreground(Driver *driver)
{ {
return *driver->stay_in_foreground; return *driver->stay_in_foreground;
} }
bool bool
driver_supports_multiple( Driver * driver ) driver_supports_multiple(Driver *driver)
{ {
return *driver->supports_multiple; return *driver->supports_multiple;
} }
static int static int
driver_store_private_ptr(Driver * driver, void * private_data) driver_store_private_ptr(Driver *driver, void *private_data)
{ {
debug( RPT_DEBUG, "%s( driver=[%.40s], ptr=%p )", __FUNCTION__, driver->name, private_data ); debug(RPT_DEBUG, "%s(driver=[%.40s], ptr=%p)", __FUNCTION__, driver->name, private_data);
driver->private_data = private_data; driver->private_data = private_data;
return 0; return 0;
@@ -324,33 +324,33 @@ driver_store_private_ptr(Driver * driver, void * private_data)
static int static int
request_display_width() request_display_width(void)
{ {
if( !display_props ) if (!display_props)
return 0; return 0;
return display_props->width; return display_props->width;
} }
static int static int
request_display_height() request_display_height(void)
{ {
if( !display_props ) if (!display_props)
return 0; return 0;
return display_props->height; return display_props->height;
} }
void void
driver_alt_vbar( Driver * drv, int x, int y, int len, int promille, int pattern ) driver_alt_vbar(Driver *drv, int x, int y, int len, int promille, int pattern)
{ {
int pos; int pos;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, len=%d, promille=%d, pattern=%d )", __FUNCTION__, drv->name, x, y, len, promille, pattern); debug(RPT_DEBUG, "%s(drv=[%.40s], x=%d, y=%d, len=%d, promille=%d, pattern=%d)", __FUNCTION__, drv->name, x, y, len, promille, pattern);
if (!drv->chr) if (!drv->chr)
return; return;
for ( pos=0; pos<len; pos++ ) { for (pos = 0; pos < len; pos++) {
if( 2 * pos < ((long) promille * len / 500 + 1) ) { if (2 * pos < ((long) promille * len / 500 + 1)) {
drv->chr (drv, x, y-pos, '|'); drv->chr(drv, x, y-pos, '|');
} else { } else {
; /* print nothing */ ; /* print nothing */
} }
@@ -358,18 +358,18 @@ driver_alt_vbar( Driver * drv, int x, int y, int len, int promille, int pattern
} }
void void
driver_alt_hbar( Driver * drv, int x, int y, int len, int promille, int pattern ) driver_alt_hbar(Driver *drv, int x, int y, int len, int promille, int pattern)
{ {
int pos; int pos;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, len=%d, promille=%d, pattern=%d )", __FUNCTION__, drv->name, x, y, len, promille, pattern); debug(RPT_DEBUG, "%s(drv=[%.40s], x=%d, y=%d, len=%d, promille=%d, pattern=%d)", __FUNCTION__, drv->name, x, y, len, promille, pattern);
if (!drv->chr) if (!drv->chr)
return; return;
for ( pos=0; pos<len; pos++ ) { for (pos = 0; pos < len; pos++) {
if( 2 * pos < ((long) promille * len / 500 + 1) ) { if (2 * pos < ((long) promille * len / 500 + 1)) {
drv->chr (drv, x+pos, y, '-'); drv->chr(drv, x+pos, y, '-');
} else { } else {
; /* print nothing */ ; /* print nothing */
} }
@@ -377,7 +377,7 @@ driver_alt_hbar( Driver * drv, int x, int y, int len, int promille, int pattern
} }
void void
driver_alt_num( Driver * drv, int x, int num ) driver_alt_num(Driver *drv, int x, int num)
{ {
/* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/ /* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/
/* Moved to driver.c by Joris Robijn */ /* Moved to driver.c by Joris Robijn */
@@ -443,7 +443,7 @@ driver_alt_num( Driver * drv, int x, int num )
int y, dx; int y, dx;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, num=%d )", __FUNCTION__, drv->name, x, num); debug(RPT_DEBUG, "%s(drv=[%.40s], x=%d, num=%d)", __FUNCTION__, drv->name, x, num);
if ((num < 0) || (num > 10)) if ((num < 0) || (num > 10))
return; return;
@@ -452,15 +452,15 @@ driver_alt_num( Driver * drv, int x, int num )
for (y = 0; y < 4; y++) for (y = 0; y < 4; y++)
for (dx = 0; num_map[num][y][dx] != '\0'; dx++) for (dx = 0; num_map[num][y][dx] != '\0'; dx++)
drv->chr (drv, x + dx, y+1, num_map[num][y][dx]); drv->chr(drv, x + dx, y+1, num_map[num][y][dx]);
} }
void void
driver_alt_heartbeat( Driver * drv, int state ) driver_alt_heartbeat(Driver *drv, int state)
{ {
int icon; int icon;
debug (RPT_DEBUG, "%s( drv=[%.40s], state=%d )", __FUNCTION__, drv->name, state); debug(RPT_DEBUG, "%s(drv=[%.40s], state=%d)", __FUNCTION__, drv->name, state);
if (state == HEARTBEAT_OFF) if (state == HEARTBEAT_OFF)
return; return;
@@ -475,18 +475,18 @@ driver_alt_heartbeat( Driver * drv, int state )
icon = (timer & 5) ? ICON_HEART_FILLED : ICON_HEART_OPEN; icon = (timer & 5) ? ICON_HEART_FILLED : ICON_HEART_OPEN;
if (drv->icon) if (drv->icon)
drv->icon( drv, drv->width(drv), 1, icon); drv->icon(drv, drv->width(drv), 1, icon);
else else
driver_alt_icon( drv, drv->width(drv), 1, icon); driver_alt_icon(drv, drv->width(drv), 1, icon);
} }
void void
driver_alt_icon( Driver * drv, int x, int y, int icon ) driver_alt_icon(Driver *drv, int x, int y, int icon)
{ {
char ch1 = '?'; char ch1 = '?';
char ch2 = 0; char ch2 = '\0';
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, icon=ICON_%s )", __FUNCTION__, drv->name, x, y, widget_icon_to_iconname (icon) ); debug(RPT_DEBUG, "%s(drv=[%.40s], x=%d, y=%d, icon=ICON_%s)", __FUNCTION__, drv->name, x, y, widget_icon_to_iconname(icon));
if (!drv->chr) if (!drv->chr)
return; return;
@@ -515,31 +515,31 @@ driver_alt_icon( Driver * drv, int x, int y, int icon )
case ICON_PREV: ch1 = '|'; ch2 = '<'; break; case ICON_PREV: ch1 = '|'; ch2 = '<'; break;
case ICON_REC: ch1 = '('; ch2 = ')'; break; case ICON_REC: ch1 = '('; ch2 = ')'; break;
} }
drv->chr( drv, x, y, ch1); drv->chr(drv, x, y, ch1);
if (ch2) if (ch2)
drv->chr( drv, x+1, y, ch2); drv->chr(drv, x+1, y, ch2);
} }
void driver_alt_cursor( Driver * drv, int x, int y, int state ) void driver_alt_cursor(Driver *drv, int x, int y, int state)
{ {
/* Same question about timer in this function... */ /* Same question about timer in this function... */
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, state=%d )", __FUNCTION__, drv->name, x, y, state); debug(RPT_DEBUG, "%s(drv=[%.40s], x=%d, y=%d, state=%d)", __FUNCTION__, drv->name, x, y, state);
switch( state ) { switch (state) {
case CURSOR_BLOCK: case CURSOR_BLOCK:
case CURSOR_DEFAULT_ON: case CURSOR_DEFAULT_ON:
if (timer & 2 && drv->chr) { if (timer & 2 && drv->chr) {
if (drv->icon) { if (drv->icon) {
drv->icon( drv, x, y, ICON_BLOCK_FILLED); drv->icon(drv, x, y, ICON_BLOCK_FILLED);
} else { } else {
driver_alt_icon( drv, x, y, ICON_BLOCK_FILLED ); driver_alt_icon(drv, x, y, ICON_BLOCK_FILLED);
} }
} }
break; break;
case CURSOR_UNDER: case CURSOR_UNDER:
if (timer & 2 && drv->chr) { if (timer & 2 && drv->chr) {
drv->chr( drv, x, y, '_'); drv->chr(drv, x, y, '_');
} }
break; break;
} }
+14 -14
View File
@@ -21,42 +21,42 @@
#endif #endif
Driver * Driver *
driver_load( char * name, char * filename ); driver_load(const char *name, const char *filename);
int int
driver_unload( Driver * driver ); driver_unload(Driver *driver);
int int
driver_bind_module( Driver * driver ); driver_bind_module(Driver *driver);
int int
driver_unbind_module( Driver * driver ); driver_unbind_module(Driver *driver);
bool bool
driver_does_output( Driver * driver ); driver_does_output(Driver *driver);
bool bool
driver_does_input( Driver * driver ); driver_does_input(Driver *driver);
bool bool
driver_support_multiple( Driver * driver ); driver_support_multiple(Driver *driver);
bool bool
driver_stay_in_foreground( Driver * driver ); driver_stay_in_foreground(Driver *driver);
/* Alternative functions for all extended functions */ /* Alternative functions for all extended functions */
void driver_alt_vbar( Driver * drv, int x, int y, int len, int promille, int pattern ); void driver_alt_vbar(Driver *drv, int x, int y, int len, int promille, int pattern);
void driver_alt_hbar( Driver * drv, int x, int y, int len, int promille, int pattern ); void driver_alt_hbar(Driver *drv, int x, int y, int len, int promille, int pattern);
void driver_alt_num( Driver * drv, int x, int num ); void driver_alt_num(Driver *drv, int x, int num);
void driver_alt_heartbeat( Driver * drv, int state ); void driver_alt_heartbeat(Driver *drv, int state);
void driver_alt_icon( Driver * drv, int x, int y, int icon ); void driver_alt_icon(Driver *drv, int x, int y, int icon);
void driver_alt_cursor( Driver * drv, int x, int y, int state ); void driver_alt_cursor(Driver *drv, int x, int y, int state);
#endif #endif
+115 -115
View File
@@ -5,7 +5,7 @@
* This file is released under the GNU General Public License. Refer to the * This file is released under the GNU General Public License. Refer to the
* COPYING file distributed with this package. * COPYING file distributed with this package.
* *
* Copyright (c) 2001, Joris Robijn * Copyright(c) 2001, Joris Robijn
* *
* *
* This code manages the lists of loaded drivers and does actions on all drivers. * This code manages the lists of loaded drivers and does actions on all drivers.
@@ -33,10 +33,10 @@
/* lcd.h is used for the driver API definition */ /* lcd.h is used for the driver API definition */
LinkedList * loaded_drivers = NULL; LinkedList *loaded_drivers = NULL;
DisplayProps * display_props = NULL; DisplayProps *display_props = NULL;
#define ForAllDrivers(drv) for( drv = LL_GetFirst(loaded_drivers); drv; drv = LL_GetNext(loaded_drivers) ) #define ForAllDrivers(drv) for (drv = LL_GetFirst(loaded_drivers); drv; drv = LL_GetNext(loaded_drivers))
/** /**
@@ -49,84 +49,84 @@ DisplayProps * display_props = NULL;
* 2: ok, driver is an output driver that needs to run in the foreground. * 2: ok, driver is an output driver that needs to run in the foreground.
*/ */
int int
drivers_load_driver( char * name ) drivers_load_driver(const char *name)
{ {
Driver * driver; Driver *driver;
const char * s; const char *s;
char * driverpath; char *driverpath;
char * filename; char *filename;
debug( RPT_DEBUG, "%s( name=\"%.40s\")", __FUNCTION__, name ); debug(RPT_DEBUG, "%s(name=\"%.40s\")", __FUNCTION__, name);
/* First driver ? */ /* First driver ? */
if( !loaded_drivers ) { if (!loaded_drivers) {
/* Create linked list */ /* Create linked list */
loaded_drivers = LL_new (); loaded_drivers = LL_new();
if( !loaded_drivers ) { if (!loaded_drivers) {
report( RPT_ERR, "Error allocating driver list." ); report(RPT_ERR, "Error allocating driver list.");
return -1; return -1;
} }
} }
/* Retrieve data from config file */ /* Retrieve data from config file */
s = config_get_string( "server", "DriverPath", 0, "" ); s = config_get_string("server", "DriverPath", 0, "");
driverpath = malloc( strlen(s) + 1 ); driverpath = malloc(strlen(s) + 1);
strcpy( driverpath, s ); strcpy(driverpath, s);
s = config_get_string( name, "File", 0, NULL ); s = config_get_string(name, "File", 0, NULL);
if( s ) { if (s) {
filename = malloc( strlen(driverpath) + strlen(s) + 1 ); filename = malloc(strlen(driverpath) + strlen(s) + 1);
strcpy( filename, driverpath ); strcpy(filename, driverpath);
strcat( filename, s ); strcat(filename, s);
} else { } else {
filename = malloc( strlen(driverpath) + strlen(name) + strlen(MODULE_EXTENSION) + 1 ); filename = malloc(strlen(driverpath) + strlen(name) + strlen(MODULE_EXTENSION) + 1);
strcpy( filename, driverpath ); strcpy(filename, driverpath);
strcat( filename, name ); strcat(filename, name);
strcat( filename, MODULE_EXTENSION ); strcat(filename, MODULE_EXTENSION);
} }
/* Load the module */ /* Load the module */
driver = driver_load( name, filename ); driver = driver_load(name, filename);
if( driver == NULL ) { if (driver == NULL) {
/* It failed. The message has already been given by driver_load() */ /* It failed. The message has already been given by driver_load() */
report( RPT_INFO, "Module %.40s could not be loaded", filename ); report(RPT_INFO, "Module %.40s could not be loaded", filename);
free( driverpath ); free(driverpath);
free( filename ); free(filename);
return -1; return -1;
} }
/* Add driver to list */ /* Add driver to list */
LL_Push( loaded_drivers, driver ); LL_Push(loaded_drivers, driver);
free( driverpath ); free(driverpath);
free( filename ); free(filename);
/* If first driver, store display properties */ /* If first driver, store display properties */
if( driver_does_output(driver) && !display_props ) { if (driver_does_output(driver) && !display_props) {
if( driver->width(driver) <= 0 || driver->width(driver) > LCD_MAX_WIDTH if (driver->width(driver) <= 0 || driver->width(driver) > LCD_MAX_WIDTH
|| driver->height(driver) <= 0 || driver->height(driver) > LCD_MAX_HEIGHT ) { || driver->height(driver) <= 0 || driver->height(driver) > LCD_MAX_HEIGHT) {
report( RPT_ERR, "Driver [%.40s] has invalid display size", driver->name ); report(RPT_ERR, "Driver [%.40s] has invalid display size", driver->name);
} }
/* Allocate new DisplayProps structure */ /* Allocate new DisplayProps structure */
display_props = malloc( sizeof( DisplayProps )); display_props = malloc(sizeof(DisplayProps));
display_props->width = driver->width(driver); display_props->width = driver->width(driver);
display_props->height = driver->height(driver); display_props->height = driver->height(driver);
if( driver->cellwidth != NULL && display_props->cellwidth > 0 ) if (driver->cellwidth != NULL && display_props->cellwidth > 0)
display_props->cellwidth = driver->cellwidth(driver); display_props->cellwidth = driver->cellwidth(driver);
else else
display_props->cellwidth = LCD_DEFAULT_CELLWIDTH; display_props->cellwidth = LCD_DEFAULT_CELLWIDTH;
if( driver->cellheight != NULL && driver->cellheight(driver) > 0 ) if (driver->cellheight != NULL && driver->cellheight(driver) > 0)
display_props->cellheight = driver->cellheight(driver); display_props->cellheight = driver->cellheight(driver);
else else
display_props->cellheight = LCD_DEFAULT_CELLHEIGHT; display_props->cellheight = LCD_DEFAULT_CELLHEIGHT;
} }
/* Return the driver type */ /* Return the driver type */
if( driver_does_output(driver) ) { if (driver_does_output(driver)) {
if( driver_stay_in_foreground(driver) ) if (driver_stay_in_foreground(driver))
return 2; return 2;
else else
return 1; return 1;
@@ -140,14 +140,14 @@ drivers_load_driver( char * name )
* \return 0. * \return 0.
*/ */
int int
drivers_unload_all() drivers_unload_all(void)
{ {
Driver * driver; Driver *driver;
debug( RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
while( (driver = LL_Pop( loaded_drivers )) != NULL ) { while ((driver = LL_Pop(loaded_drivers)) != NULL) {
driver_unload( driver ); driver_unload(driver);
} }
return 0; return 0;
@@ -157,18 +157,18 @@ drivers_unload_all()
/** /**
* Get information from loaded drivers. * Get information from loaded drivers.
* \return Information string of 1st driver with get_info() function defined, * \return Information string of 1st driver with get_info() function defined,
* or "" (empty string) if no driver has a get_info() function. * or ""(empty string) if no driver has a get_info() function.
*/ */
const char * const char *
drivers_get_info() drivers_get_info(void)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->get_info ) { if (drv->get_info) {
return drv->get_info( drv ); return drv->get_info(drv);
} }
} }
return ""; return "";
@@ -180,15 +180,15 @@ drivers_get_info()
* Call clear() function of all loaded drivers that have a clear() function defined. * Call clear() function of all loaded drivers that have a clear() function defined.
*/ */
void void
drivers_clear() drivers_clear(void)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->clear ) if (drv->clear)
drv->clear( drv ); drv->clear(drv);
} }
} }
@@ -198,53 +198,53 @@ drivers_clear()
* Call flush() function of all loaded drivers that have a flush() function defined. * Call flush() function of all loaded drivers that have a flush() function defined.
*/ */
void void
drivers_flush() drivers_flush(void)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->flush ) if (drv->flush)
drv->flush( drv ); drv->flush(drv);
} }
} }
void void
drivers_string( int x, int y, char * string ) drivers_string(int x, int y, const char *string)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, y=%d, string=\"%.40s\" )", __FUNCTION__, x, y, string ); debug(RPT_DEBUG, "%s(x=%d, y=%d, string=\"%.40s\")", __FUNCTION__, x, y, string);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->string ) if (drv->string)
drv->string( drv, x, y, string ); drv->string(drv, x, y, string);
} }
} }
void void
drivers_chr( int x, int y, char c ) drivers_chr(int x, int y, char c)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, y=%d, c='%c' )", __FUNCTION__, x, y, c ); debug(RPT_DEBUG, "%s(x=%d, y=%d, c='%c')", __FUNCTION__, x, y, c);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->chr ) if (drv->chr)
drv->chr( drv, x, y, c ); drv->chr(drv, x, y, c);
} }
} }
void void
drivers_vbar( int x, int y, int len, int promille, int pattern ) drivers_vbar(int x, int y, int len, int promille, int pattern)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, y=%d, len=%d, promille=%d, pattern=%d )", __FUNCTION__, x, y, len, promille, pattern ); debug(RPT_DEBUG, "%s(x=%d, y=%d, len=%d, promille=%d, pattern=%d)", __FUNCTION__, x, y, len, promille, pattern);
/* NEW FUNCTIONS /* NEW FUNCTIONS
* *
@@ -253,141 +253,141 @@ drivers_vbar( int x, int y, int len, int promille, int pattern )
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->vbar ) if (drv->vbar)
drv->vbar( drv, x, y, len, promille, pattern ); drv->vbar(drv, x, y, len, promille, pattern);
else else
driver_alt_vbar( drv, x, y, len, promille, pattern ); driver_alt_vbar(drv, x, y, len, promille, pattern);
} }
} }
void void
drivers_hbar( int x, int y, int len, int promille, int pattern ) drivers_hbar(int x, int y, int len, int promille, int pattern)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, y=%d, len=%d, promille=%d, pattern=%d )", __FUNCTION__, x, y, len, promille, pattern ); debug(RPT_DEBUG, "%s(x=%d, y=%d, len=%d, promille=%d, pattern=%d)", __FUNCTION__, x, y, len, promille, pattern);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->hbar ) if (drv->hbar)
drv->hbar( drv, x, y, len, promille, pattern ); drv->hbar(drv, x, y, len, promille, pattern);
else else
driver_alt_hbar( drv, x, y, len, promille, pattern ); driver_alt_hbar(drv, x, y, len, promille, pattern);
} }
} }
void void
drivers_num( int x, int num ) drivers_num(int x, int num)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, num=%d )", __FUNCTION__, x, num ); debug(RPT_DEBUG, "%s(x=%d, num=%d)", __FUNCTION__, x, num);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->num ) if (drv->num)
drv->num( drv, x, num ); drv->num(drv, x, num);
else else
driver_alt_num( drv, x, num ); driver_alt_num(drv, x, num);
} }
} }
void void
drivers_heartbeat( int state ) drivers_heartbeat(int state)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( state=%d )", __FUNCTION__, state ); debug(RPT_DEBUG, "%s(state=%d)", __FUNCTION__, state);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->heartbeat ) if (drv->heartbeat)
drv->heartbeat( drv, state ); drv->heartbeat(drv, state);
else else
driver_alt_heartbeat( drv, state ); driver_alt_heartbeat(drv, state);
} }
} }
void void
drivers_icon( int x, int y, int icon ) drivers_icon(int x, int y, int icon)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, y=%d, icon=ICON_%s )", __FUNCTION__, x, y, widget_icon_to_iconname (icon) ); debug(RPT_DEBUG, "%s(x=%d, y=%d, icon=ICON_%s)", __FUNCTION__, x, y, widget_icon_to_iconname(icon));
ForAllDrivers(drv) { ForAllDrivers(drv) {
/* Does the driver have the icon function ? */ /* Does the driver have the icon function ? */
if( drv->icon ) { if (drv->icon) {
/* Try driver call */ /* Try driver call */
if (drv->icon( drv, x, y, icon ) == -1) { if (drv->icon(drv, x, y, icon) == -1) {
/* do alternative call if driver's function does not know the icon */ /* do alternative call if driver's function does not know the icon */
driver_alt_icon( drv, x, y, icon ); driver_alt_icon(drv, x, y, icon);
} }
} else { } else {
/* Also do alternative call if the driver does not have icon function */ /* Also do alternative call if the driver does not have icon function */
driver_alt_icon( drv, x, y, icon ); driver_alt_icon(drv, x, y, icon);
} }
} }
} }
void void
drivers_cursor( int x, int y, int state ) drivers_cursor(int x, int y, int state)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( x=%d, y=%d, state=%d )", __FUNCTION__, x, y, state ); debug(RPT_DEBUG, "%s(x=%d, y=%d, state=%d)", __FUNCTION__, x, y, state);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->cursor ) if (drv->cursor)
drv->cursor( drv, x, y, state ); drv->cursor(drv, x, y, state);
else else
driver_alt_cursor( drv, x, y, state ); driver_alt_cursor(drv, x, y, state);
} }
} }
void void
drivers_backlight( int brightness ) drivers_backlight(int brightness)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( brightness=%d )", __FUNCTION__, brightness ); debug(RPT_DEBUG, "%s(brightness=%d)", __FUNCTION__, brightness);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->backlight ) if (drv->backlight)
drv->backlight( drv, brightness ); drv->backlight(drv, brightness);
} }
} }
void void
drivers_output( int state ) drivers_output(int state)
{ {
Driver *drv; Driver *drv;
debug( RPT_DEBUG, "%s( state=%d )", __FUNCTION__, state ); debug(RPT_DEBUG, "%s(state=%d)", __FUNCTION__, state);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->output ) if (drv->output)
drv->output( drv, state ); drv->output(drv, state);
} }
} }
const char * const char *
drivers_get_key() drivers_get_key(void)
{ {
/* Find the first input keystroke, if any */ /* Find the first input keystroke, if any */
Driver *drv; Driver *drv;
const char * keystroke; const char *keystroke;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
ForAllDrivers(drv) { ForAllDrivers(drv) {
if( drv->get_key ) { if (drv->get_key) {
keystroke = drv->get_key( drv ); keystroke = drv->get_key(drv);
if( keystroke != NULL ) { if (keystroke != NULL) {
report( RPT_INFO, "Driver [%.40s] generated keystroke %.40s", drv->name, keystroke ); report(RPT_INFO, "Driver [%.40s] generated keystroke %.40s", drv->name, keystroke);
return keystroke; return keystroke;
} }
} }
+23 -23
View File
@@ -20,7 +20,7 @@ typedef struct DisplayProps {
int cellwidth, cellheight; int cellwidth, cellheight;
} DisplayProps; } DisplayProps;
extern DisplayProps * display_props; extern DisplayProps *display_props;
#ifndef bool #ifndef bool
# define bool short # define bool short
@@ -30,72 +30,72 @@ extern DisplayProps * display_props;
int int
drivers_load_driver( char * name ); drivers_load_driver(const char *name);
int int
drivers_unload_all(); drivers_unload_all(void);
const char * const char *
drivers_get_info(); drivers_get_info(void);
void void
drivers_clear(); drivers_clear(void);
void void
drivers_flush(); drivers_flush(void);
void void
drivers_string( int x, int y, char * string ); drivers_string(int x, int y, const char *string);
void void
drivers_chr( int x, int y, char c ); drivers_chr(int x, int y, char c);
void void
drivers_vbar( int x, int y, int len, int promille, int pattern ); drivers_vbar(int x, int y, int len, int promille, int pattern);
void void
drivers_hbar( int x, int y, int len, int promille, int pattern ); drivers_hbar(int x, int y, int len, int promille, int pattern);
void void
drivers_num( int x, int num ); drivers_num(int x, int num);
void void
drivers_heartbeat( int state ); drivers_heartbeat(int state);
void void
drivers_icon( int x, int y, int icon ); drivers_icon(int x, int y, int icon);
void void
drivers_set_char( char ch, char *dat ); drivers_set_char(char ch, char *dat);
int int
drivers_get_contrast(); drivers_get_contrast(void);
void void
drivers_set_contrast( int contrast ); drivers_set_contrast(int contrast);
void void
drivers_cursor( int x, int y, int state ); drivers_cursor(int x, int y, int state);
void void
drivers_backlight( int brightness ); drivers_backlight(int brightness);
void void
drivers_output( int state ); drivers_output(int state);
const char * const char *
drivers_get_key(); drivers_get_key(void);
/* Please don't read this list except using the following functions */ /* Please don't read this list except using the following functions */
extern LinkedList * loaded_drivers; extern LinkedList *loaded_drivers;
static inline Driver * drivers_getfirst () static inline Driver *drivers_getfirst(void)
{ {
return LL_GetFirst(loaded_drivers); return LL_GetFirst(loaded_drivers);
} }
static inline Driver * drivers_getnext () static inline Driver *drivers_getnext(void)
{ {
return LL_GetNext(loaded_drivers); return LL_GetNext(loaded_drivers);
} }
+1 -1
View File
@@ -1057,7 +1057,7 @@ CFontz633_hardware_clear (Driver *drvthis)
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
CFontz633_string (Driver *drvthis, int x, int y, char string[]) CFontz633_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -27,7 +27,7 @@ MODULE_EXPORT int CFontz633_cellwidth (Driver *drvthis);
MODULE_EXPORT int CFontz633_cellheight (Driver *drvthis); MODULE_EXPORT int CFontz633_cellheight (Driver *drvthis);
MODULE_EXPORT void CFontz633_clear (Driver *drvthis); MODULE_EXPORT void CFontz633_clear (Driver *drvthis);
MODULE_EXPORT void CFontz633_flush (Driver *drvthis); MODULE_EXPORT void CFontz633_flush (Driver *drvthis);
MODULE_EXPORT void CFontz633_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void CFontz633_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void CFontz633_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void CFontz633_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT const char *CFontz633_get_key (Driver *drvthis); MODULE_EXPORT const char *CFontz633_get_key (Driver *drvthis);
+1 -1
View File
@@ -1286,7 +1286,7 @@ CFontzPacket_hardware_clear (Driver *drvthis)
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
CFontzPacket_string (Driver *drvthis, int x, int y, char string[]) CFontzPacket_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -27,7 +27,7 @@ MODULE_EXPORT int CFontzPacket_cellwidth (Driver *drvthis);
MODULE_EXPORT int CFontzPacket_cellheight (Driver *drvthis); MODULE_EXPORT int CFontzPacket_cellheight (Driver *drvthis);
MODULE_EXPORT void CFontzPacket_clear (Driver *drvthis); MODULE_EXPORT void CFontzPacket_clear (Driver *drvthis);
MODULE_EXPORT void CFontzPacket_flush (Driver *drvthis); MODULE_EXPORT void CFontzPacket_flush (Driver *drvthis);
MODULE_EXPORT void CFontzPacket_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void CFontzPacket_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void CFontzPacket_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void CFontzPacket_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT const char *CFontzPacket_get_key (Driver *drvthis); MODULE_EXPORT const char *CFontzPacket_get_key (Driver *drvthis);
+1 -1
View File
@@ -1232,7 +1232,7 @@ CwLnx_clear(Driver *drvthis)
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
CwLnx_string(Driver *drvthis, int x, int y, char *string) CwLnx_string(Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
+1 -1
View File
@@ -58,7 +58,7 @@ MODULE_EXPORT int CwLnx_cellwidth(Driver *drvthis);
MODULE_EXPORT int CwLnx_cellheight(Driver *drvthis); MODULE_EXPORT int CwLnx_cellheight(Driver *drvthis);
MODULE_EXPORT void CwLnx_clear(Driver *drvthis); MODULE_EXPORT void CwLnx_clear(Driver *drvthis);
MODULE_EXPORT void CwLnx_flush(Driver *drvthis); MODULE_EXPORT void CwLnx_flush(Driver *drvthis);
MODULE_EXPORT void CwLnx_string(Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void CwLnx_string(Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void CwLnx_chr(Driver *drvthis, int x, int y, char c); MODULE_EXPORT void CwLnx_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT const char *CwLnx_get_key(Driver *drvthis); MODULE_EXPORT const char *CwLnx_get_key(Driver *drvthis);
+1 -1
View File
@@ -433,7 +433,7 @@ EyeboxOne_height (Driver *drvthis)
* Display a string at x,y * Display a string at x,y
*/ */
MODULE_EXPORT void MODULE_EXPORT void
EyeboxOne_string (Driver *drvthis, int x, int y, char *string) EyeboxOne_string (Driver *drvthis, int x, int y, const char string[])
{ {
int offset, siz; int offset, siz;
int bar,level; int bar,level;
+1 -1
View File
@@ -9,7 +9,7 @@ MODULE_EXPORT int EyeboxOne_width (Driver *drvthis);
MODULE_EXPORT int EyeboxOne_height (Driver *drvthis); MODULE_EXPORT int EyeboxOne_height (Driver *drvthis);
MODULE_EXPORT void EyeboxOne_clear (Driver *drvthis); MODULE_EXPORT void EyeboxOne_clear (Driver *drvthis);
MODULE_EXPORT void EyeboxOne_flush (Driver *drvthis); MODULE_EXPORT void EyeboxOne_flush (Driver *drvthis);
MODULE_EXPORT void EyeboxOne_string (Driver *drvthis, int x, int y, char *string); MODULE_EXPORT void EyeboxOne_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void EyeboxOne_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void EyeboxOne_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void EyeboxOne_set_char (Driver *drvthis, int n, char *dat); MODULE_EXPORT void EyeboxOne_set_char (Driver *drvthis, int n, char *dat);
+1 -1
View File
@@ -629,7 +629,7 @@ PrivateData *p = drvthis->private_data;
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
IOWarrior_string(Driver *drvthis, int x, int y, char *string) IOWarrior_string(Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -127,7 +127,7 @@ MODULE_EXPORT int IOWarrior_cellheight(Driver *drvthis);
MODULE_EXPORT int IOWarrior_cellwidth(Driver *drvthis); MODULE_EXPORT int IOWarrior_cellwidth(Driver *drvthis);
MODULE_EXPORT void IOWarrior_clear(Driver *drvthis); MODULE_EXPORT void IOWarrior_clear(Driver *drvthis);
MODULE_EXPORT void IOWarrior_chr(Driver *drvthis, int x, int y, char c); MODULE_EXPORT void IOWarrior_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void IOWarrior_string(Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void IOWarrior_string(Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void IOWarrior_flush(Driver *drvthis); MODULE_EXPORT void IOWarrior_flush(Driver *drvthis);
MODULE_EXPORT void IOWarrior_backlight(Driver *drvthis, int on); MODULE_EXPORT void IOWarrior_backlight(Driver *drvthis, int on);
MODULE_EXPORT void IOWarrior_vbar(Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void IOWarrior_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
+1 -1
View File
@@ -571,7 +571,7 @@ MD8800_clear (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
MD8800_string (Driver *drvthis, int x, int y, char string[]) MD8800_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -38,7 +38,7 @@ MODULE_EXPORT int MD8800_cellwidth (Driver *drvthis);
MODULE_EXPORT int MD8800_cellheight (Driver *drvthis); MODULE_EXPORT int MD8800_cellheight (Driver *drvthis);
MODULE_EXPORT void MD8800_clear (Driver *drvthis); MODULE_EXPORT void MD8800_clear (Driver *drvthis);
MODULE_EXPORT void MD8800_flush (Driver *drvthis); MODULE_EXPORT void MD8800_flush (Driver *drvthis);
MODULE_EXPORT void MD8800_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void MD8800_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void MD8800_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void MD8800_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void MD8800_output (Driver *drvthis, int on); MODULE_EXPORT void MD8800_output (Driver *drvthis, int on);
MODULE_EXPORT const char * MD8800_get_info(Driver *drvthis); MODULE_EXPORT const char * MD8800_get_info(Driver *drvthis);
+3 -3
View File
@@ -508,7 +508,7 @@ MtxcOrb_cellheight (Driver *drvthis)
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
MtxOrb_string (Driver *drvthis, int x, int y, char string[]) MtxOrb_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -1064,7 +1064,7 @@ MtxOrb_get_info (Driver *drvthis)
* \param options Options (currently unused). * \param options Options (currently unused).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
MtxOrb_vbar (Driver * drvthis, int x, int y, int len, int promille, int options) MtxOrb_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -1103,7 +1103,7 @@ MtxOrb_vbar (Driver * drvthis, int x, int y, int len, int promille, int options)
* \param options Options (currently unused). * \param options Options (currently unused).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
MtxOrb_hbar (Driver * drvthis, int x, int y, int len, int promille, int options) MtxOrb_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
+3 -3
View File
@@ -24,12 +24,12 @@ MODULE_EXPORT int MtxOrb_cellwidth (Driver *drvthis);
MODULE_EXPORT int MtxOrb_cellheight (Driver *drvthis); MODULE_EXPORT int MtxOrb_cellheight (Driver *drvthis);
MODULE_EXPORT void MtxOrb_clear (Driver *drvthis); MODULE_EXPORT void MtxOrb_clear (Driver *drvthis);
MODULE_EXPORT void MtxOrb_flush (Driver *drvthis); MODULE_EXPORT void MtxOrb_flush (Driver *drvthis);
MODULE_EXPORT void MtxOrb_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void MtxOrb_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void MtxOrb_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void MtxOrb_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT const char * MtxOrb_get_key (Driver *drvthis); MODULE_EXPORT const char * MtxOrb_get_key (Driver *drvthis);
MODULE_EXPORT void MtxOrb_vbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void MtxOrb_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void MtxOrb_hbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void MtxOrb_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT int MtxOrb_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT int MtxOrb_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void MtxOrb_num (Driver *drvthis, int x, int num); MODULE_EXPORT void MtxOrb_num (Driver *drvthis, int x, int num);
MODULE_EXPORT void MtxOrb_cursor (Driver *drvthis, int x, int y, int state); MODULE_EXPORT void MtxOrb_cursor (Driver *drvthis, int x, int y, int state);
+1 -1
View File
@@ -688,7 +688,7 @@ NoritakeVFD_clear (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
NoritakeVFD_string (Driver *drvthis, int x, int y, char string[]) NoritakeVFD_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -38,7 +38,7 @@ MODULE_EXPORT int NoritakeVFD_cellwidth (Driver *drvthis);
MODULE_EXPORT int NoritakeVFD_cellheight (Driver *drvthis); MODULE_EXPORT int NoritakeVFD_cellheight (Driver *drvthis);
MODULE_EXPORT void NoritakeVFD_clear (Driver *drvthis); MODULE_EXPORT void NoritakeVFD_clear (Driver *drvthis);
MODULE_EXPORT void NoritakeVFD_flush (Driver *drvthis); MODULE_EXPORT void NoritakeVFD_flush (Driver *drvthis);
MODULE_EXPORT void NoritakeVFD_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void NoritakeVFD_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void NoritakeVFD_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void NoritakeVFD_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void NoritakeVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void NoritakeVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+19 -19
View File
@@ -178,7 +178,7 @@ bayrad_init(Driver *drvthis)
// your driver. // your driver.
MODULE_EXPORT void MODULE_EXPORT void
bayrad_close(Driver * drvthis) bayrad_close(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -202,7 +202,7 @@ bayrad_close(Driver * drvthis)
// Returns the display width // Returns the display width
// //
MODULE_EXPORT int MODULE_EXPORT int
bayrad_width(Driver * drvthis) bayrad_width(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -214,7 +214,7 @@ bayrad_width(Driver * drvthis)
// Returns the display height // Returns the display height
// //
MODULE_EXPORT int MODULE_EXPORT int
bayrad_height(Driver * drvthis) bayrad_height(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -226,7 +226,7 @@ bayrad_height(Driver * drvthis)
// Returns the display's cell width // Returns the display's cell width
// //
MODULE_EXPORT int MODULE_EXPORT int
bayrad_cellwidth(Driver * drvthis) bayrad_cellwidth(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -238,7 +238,7 @@ bayrad_cellwidth(Driver * drvthis)
// Returns the display's cell height // Returns the display's cell height
// //
MODULE_EXPORT int MODULE_EXPORT int
bayrad_cellheight(Driver * drvthis) bayrad_cellheight(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -250,7 +250,7 @@ bayrad_cellheight(Driver * drvthis)
// Clears the LCD screen // Clears the LCD screen
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_clear(Driver * drvthis) bayrad_clear(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -263,7 +263,7 @@ bayrad_clear(Driver * drvthis)
// Flushes all output to the lcd... // Flushes all output to the lcd...
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_flush(Driver * drvthis) bayrad_flush(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -279,7 +279,7 @@ bayrad_flush(Driver * drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_string(Driver * drvthis, int x, int y, char string[]) bayrad_string(Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -315,7 +315,7 @@ bayrad_string(Driver * drvthis, int x, int y, char string[])
// upper-left is (1,1), and the lower right should be (20,2). // upper-left is (1,1), and the lower right should be (20,2).
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_chr(Driver * drvthis, int x, int y, char c) bayrad_chr(Driver *drvthis, int x, int y, char c)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
unsigned char ch = (unsigned char) c; unsigned char ch = (unsigned char) c;
@@ -339,7 +339,7 @@ bayrad_chr(Driver * drvthis, int x, int y, char c)
// Turns the lcd backlight on or off... // Turns the lcd backlight on or off...
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_backlight(Driver * drvthis, int on) bayrad_backlight(Driver *drvthis, int on)
{ {
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
@@ -364,7 +364,7 @@ bayrad_backlight(Driver * drvthis, int on)
// Tells the driver to get ready for vertical bargraphs. // Tells the driver to get ready for vertical bargraphs.
// //
static void static void
bayrad_init_vbar(Driver * drvthis) bayrad_init_vbar(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
static char bar_up[7][5*8] = { static char bar_up[7][5*8] = {
@@ -462,7 +462,7 @@ bayrad_init_vbar(Driver * drvthis)
// Tells the driver to get ready for horizontal bargraphs. // Tells the driver to get ready for horizontal bargraphs.
// //
static void static void
bayrad_init_hbar(Driver * drvthis) bayrad_init_hbar(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
static char bar_right[5][5*8] = { static char bar_right[5][5*8] = {
@@ -540,7 +540,7 @@ bayrad_init_hbar(Driver * drvthis)
// Tells the driver to get ready for big numbers, if possible. // Tells the driver to get ready for big numbers, if possible.
// //
static void static void
bayrad_init_num(Driver * drvthis) bayrad_init_num(Driver *drvthis)
{ {
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
@@ -551,7 +551,7 @@ bayrad_init_num(Driver * drvthis)
// Draws a big (4-row) number. // Draws a big (4-row) number.
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_num(Driver * drvthis, int x, int num) bayrad_num(Driver *drvthis, int x, int num)
{ {
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
@@ -562,7 +562,7 @@ bayrad_num(Driver * drvthis, int x, int num)
// Changes the font data of character n. // Changes the font data of character n.
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_set_char(Driver * drvthis, int n, char *dat) bayrad_set_char(Driver *drvthis, int n, char *dat)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char out[4]; char out[4];
@@ -598,7 +598,7 @@ bayrad_set_char(Driver * drvthis, int n, char *dat)
// Draws a vertical bar, from the bottom of the screen up. // Draws a vertical bar, from the bottom of the screen up.
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_vbar(Driver * drvthis, int x, int y, int len, int promille, int options) bayrad_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -620,7 +620,7 @@ bayrad_vbar(Driver * drvthis, int x, int y, int len, int promille, int options)
// Draws a horizontal bar to the right. // Draws a horizontal bar to the right.
// //
MODULE_EXPORT void MODULE_EXPORT void
bayrad_hbar(Driver * drvthis, int x, int y, int len, int promille, int options) bayrad_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -643,7 +643,7 @@ bayrad_hbar(Driver * drvthis, int x, int y, int len, int promille, int options)
// Places an icon on screen // Places an icon on screen
// //
MODULE_EXPORT int MODULE_EXPORT int
bayrad_icon(Driver * drvthis, int x, int y, int icon) bayrad_icon(Driver *drvthis, int x, int y, int icon)
{ {
/*PrivateData *p = drvthis->private_data; /*PrivateData *p = drvthis->private_data;
static char icons[3][5*8] = { static char icons[3][5*8] = {
@@ -694,7 +694,7 @@ bayrad_icon(Driver * drvthis, int x, int y, int icon)
// Return 0 for "nothing available". // Return 0 for "nothing available".
// //
MODULE_EXPORT const char * MODULE_EXPORT const char *
bayrad_get_key(Driver * drvthis) bayrad_get_key(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
fd_set brfdset; fd_set brfdset;
+16 -16
View File
@@ -10,25 +10,25 @@
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int bayrad_init(Driver * drvthis); MODULE_EXPORT int bayrad_init(Driver *drvthis);
MODULE_EXPORT void bayrad_close(Driver * drvthis); MODULE_EXPORT void bayrad_close(Driver *drvthis);
MODULE_EXPORT int bayrad_width(Driver * drvthis); MODULE_EXPORT int bayrad_width(Driver *drvthis);
MODULE_EXPORT int bayrad_height(Driver * drvthis); MODULE_EXPORT int bayrad_height(Driver *drvthis);
MODULE_EXPORT int bayrad_cellwidth(Driver * drvthis); MODULE_EXPORT int bayrad_cellwidth(Driver *drvthis);
MODULE_EXPORT int bayrad_cellheight(Driver * drvthis); MODULE_EXPORT int bayrad_cellheight(Driver *drvthis);
MODULE_EXPORT void bayrad_clear(Driver * drvthis); MODULE_EXPORT void bayrad_clear(Driver *drvthis);
MODULE_EXPORT void bayrad_flush(Driver * drvthis); MODULE_EXPORT void bayrad_flush(Driver *drvthis);
MODULE_EXPORT void bayrad_string(Driver * drvthis, int x, int y, char string[]); MODULE_EXPORT void bayrad_string(Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void bayrad_chr(Driver * drvthis, int x, int y, char c); MODULE_EXPORT void bayrad_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void bayrad_vbar(Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void bayrad_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void bayrad_hbar(Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void bayrad_hbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT int bayrad_icon(Driver * drvthis, int x, int y, int icon); MODULE_EXPORT int bayrad_icon(Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void bayrad_set_char(Driver * drvthis, int n, char *dat); MODULE_EXPORT void bayrad_set_char(Driver *drvthis, int n, char *dat);
MODULE_EXPORT void bayrad_backlight(Driver * drvthis, int promille); MODULE_EXPORT void bayrad_backlight(Driver *drvthis, int promille);
MODULE_EXPORT const char *bayrad_get_key(Driver * drvthis); MODULE_EXPORT const char *bayrad_get_key(Driver *drvthis);
#endif #endif
+1 -1
View File
@@ -430,7 +430,7 @@ curses_backlight (Driver *drvthis, int on)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
curses_string (Driver *drvthis, int x, int y, char *string) curses_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
+2 -2
View File
@@ -3,13 +3,13 @@
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int curses_init (Driver * drvthis); MODULE_EXPORT int curses_init (Driver *drvthis);
MODULE_EXPORT void curses_close (Driver *drvthis); MODULE_EXPORT void curses_close (Driver *drvthis);
MODULE_EXPORT int curses_width (Driver *drvthis); MODULE_EXPORT int curses_width (Driver *drvthis);
MODULE_EXPORT int curses_height (Driver *drvthis); MODULE_EXPORT int curses_height (Driver *drvthis);
MODULE_EXPORT void curses_clear (Driver *drvthis); MODULE_EXPORT void curses_clear (Driver *drvthis);
MODULE_EXPORT void curses_flush (Driver *drvthis); MODULE_EXPORT void curses_flush (Driver *drvthis);
MODULE_EXPORT void curses_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void curses_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void curses_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void curses_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void curses_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void curses_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+1 -1
View File
@@ -137,7 +137,7 @@ debug_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
debug_string (Driver *drvthis, int x, int y, char string[]) debug_string (Driver *drvthis, int x, int y, const char string[])
{ {
int i; int i;
+1 -1
View File
@@ -9,7 +9,7 @@ MODULE_EXPORT int debug_width (Driver *drvthis);
MODULE_EXPORT int debug_height (Driver *drvthis); MODULE_EXPORT int debug_height (Driver *drvthis);
MODULE_EXPORT void debug_clear (Driver *drvthis); MODULE_EXPORT void debug_clear (Driver *drvthis);
MODULE_EXPORT void debug_flush (Driver *drvthis); MODULE_EXPORT void debug_flush (Driver *drvthis);
MODULE_EXPORT void debug_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void debug_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void debug_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void debug_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void debug_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void debug_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+6 -6
View File
@@ -59,7 +59,7 @@ MODULE_EXPORT char *symbol_prefix = "EA65_";
// Opens com port and sets baud correctly... // Opens com port and sets baud correctly...
// //
MODULE_EXPORT int MODULE_EXPORT int
EA65_init (Driver * drvthis) EA65_init (Driver *drvthis)
{ {
debug(RPT_INFO, "EA65: init(%p)", drvthis); debug(RPT_INFO, "EA65: init(%p)", drvthis);
@@ -230,7 +230,7 @@ EA65_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (9,1). // upper-left is (1,1), and the lower right should be (9,1).
// //
MODULE_EXPORT void MODULE_EXPORT void
EA65_chr (Driver * drvthis, int x, int y, char c) EA65_chr (Driver *drvthis, int x, int y, char c)
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
@@ -252,7 +252,7 @@ EA65_chr (Driver * drvthis, int x, int y, char c)
// Sets the backlight on or off // Sets the backlight on or off
// //
MODULE_EXPORT void MODULE_EXPORT void
EA65_backlight (Driver * drvthis, int on) EA65_backlight (Driver *drvthis, int on)
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
@@ -269,7 +269,7 @@ EA65_backlight (Driver * drvthis, int on)
// Clears the LCD screen // Clears the LCD screen
// //
MODULE_EXPORT void MODULE_EXPORT void
EA65_clear (Driver * drvthis) EA65_clear (Driver *drvthis)
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
@@ -282,7 +282,7 @@ EA65_clear (Driver * drvthis)
// upper-left is (1,1), and the lower right should be (9,1). // upper-left is (1,1), and the lower right should be (9,1).
// //
MODULE_EXPORT void MODULE_EXPORT void
EA65_string (Driver * drvthis, int x, int y, char string[]) EA65_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
@@ -304,7 +304,7 @@ EA65_string (Driver * drvthis, int x, int y, char string[])
//// Turns the recording LED on or off as desired. //// Turns the recording LED on or off as desired.
//// ////
MODULE_EXPORT void MODULE_EXPORT void
EA65_output (Driver * drvthis, int on) EA65_output (Driver *drvthis, int on)
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
+10 -10
View File
@@ -6,16 +6,16 @@
#define DEFAULT_BRIGHTNESS 500 #define DEFAULT_BRIGHTNESS 500
#define DEFAULT_OFFBRIGHTNESS 0 #define DEFAULT_OFFBRIGHTNESS 0
MODULE_EXPORT int EA65_init (Driver * drvthis); MODULE_EXPORT int EA65_init (Driver *drvthis);
MODULE_EXPORT void EA65_close (Driver * drvthis); MODULE_EXPORT void EA65_close (Driver *drvthis);
MODULE_EXPORT int EA65_width (Driver * drvthis); MODULE_EXPORT int EA65_width (Driver *drvthis);
MODULE_EXPORT int EA65_height (Driver * drvthis); MODULE_EXPORT int EA65_height (Driver *drvthis);
MODULE_EXPORT void EA65_clear (Driver * drvthis); MODULE_EXPORT void EA65_clear (Driver *drvthis);
MODULE_EXPORT void EA65_flush (Driver * drvthis); MODULE_EXPORT void EA65_flush (Driver *drvthis);
MODULE_EXPORT void EA65_string (Driver * drvthis, int x, int y, char string[]); MODULE_EXPORT void EA65_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void EA65_chr (Driver * drvthis, int x, int y, char c); MODULE_EXPORT void EA65_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void EA65_brightness (Driver * drvthis, int promille); MODULE_EXPORT void EA65_brightness (Driver *drvthis, int promille);
MODULE_EXPORT void EA65_output (Driver * drvthis, int on); MODULE_EXPORT void EA65_output (Driver *drvthis, int on);
#endif #endif
+2 -2
View File
@@ -200,7 +200,7 @@ MODULE_EXPORT void g15_chr (Driver *drvthis, int x, int y, char c)
// Prints a string on the lcd display, at position (x,y). The // Prints a string on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,5). // upper-left is (1,1), and the lower right should be (20,5).
// //
MODULE_EXPORT void g15_string (Driver *drvthis, int x, int y, char string[]) MODULE_EXPORT void g15_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -452,7 +452,7 @@ MODULE_EXPORT void g15_backlight(Driver *drvthis, int on)
} }
} }
MODULE_EXPORT void g15_num(Driver * drvthis, int x, int num) MODULE_EXPORT void g15_num(Driver *drvthis, int x, int num)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
+2 -2
View File
@@ -80,13 +80,13 @@ MODULE_EXPORT int g15_cellwidth (Driver *drvthis);
MODULE_EXPORT int g15_cellheight (Driver *drvthis); MODULE_EXPORT int g15_cellheight (Driver *drvthis);
MODULE_EXPORT void g15_clear (Driver *drvthis); MODULE_EXPORT void g15_clear (Driver *drvthis);
MODULE_EXPORT void g15_flush (Driver *drvthis); MODULE_EXPORT void g15_flush (Driver *drvthis);
MODULE_EXPORT void g15_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void g15_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void g15_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void g15_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT int g15_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT int g15_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void g15_hbar(Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void g15_hbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void g15_vbar(Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void g15_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT const char * g15_get_key (Driver *drvthis); MODULE_EXPORT const char * g15_get_key (Driver *drvthis);
MODULE_EXPORT void g15_backlight(Driver *drvthis, int on); MODULE_EXPORT void g15_backlight(Driver *drvthis, int on);
MODULE_EXPORT void g15_num(Driver * drvthis, int x, int num); MODULE_EXPORT void g15_num(Driver *drvthis, int x, int num);
#endif /*G15_H_*/ #endif /*G15_H_*/
+1 -1
View File
@@ -262,7 +262,7 @@ glcdlib_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,6). // upper-left is (1,1), and the lower right should be (20,6).
// //
MODULE_EXPORT void MODULE_EXPORT void
glcdlib_string (Driver *drvthis, int x, int y, char string[]) glcdlib_string (Driver *drvthis, int x, int y, const char string[])
{ {
debug(RPT_DEBUG, "String out"); debug(RPT_DEBUG, "String out");
y--; y--;
+1 -1
View File
@@ -35,7 +35,7 @@ MODULE_EXPORT int glcdlib_width (Driver *drvthis);
MODULE_EXPORT int glcdlib_height (Driver *drvthis); MODULE_EXPORT int glcdlib_height (Driver *drvthis);
MODULE_EXPORT void glcdlib_clear (Driver *drvthis); MODULE_EXPORT void glcdlib_clear (Driver *drvthis);
MODULE_EXPORT void glcdlib_flush (Driver *drvthis); MODULE_EXPORT void glcdlib_flush (Driver *drvthis);
MODULE_EXPORT void glcdlib_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void glcdlib_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void glcdlib_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void glcdlib_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT int glcdlib_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT int glcdlib_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT int glcdlib_cellwidth (Driver *drvthis); MODULE_EXPORT int glcdlib_cellwidth (Driver *drvthis);
+2 -2
View File
@@ -393,10 +393,10 @@ glk_flush(Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
glk_string(Driver *drvthis, int x, int y, char string[]) glk_string(Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char *s; const char *s;
debug(RPT_DEBUG, "glk_string(%d, %d, \"%s\")", x, y, string); debug(RPT_DEBUG, "glk_string(%d, %d, \"%s\")", x, y, string);
+1 -1
View File
@@ -11,7 +11,7 @@ MODULE_EXPORT int glk_cellwidth(Driver *drvthis);
MODULE_EXPORT int glk_cellheight(Driver *drvthis); MODULE_EXPORT int glk_cellheight(Driver *drvthis);
MODULE_EXPORT void glk_clear(Driver *drvthis); MODULE_EXPORT void glk_clear(Driver *drvthis);
MODULE_EXPORT void glk_flush(Driver *drvthis); MODULE_EXPORT void glk_flush(Driver *drvthis);
MODULE_EXPORT void glk_string(Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void glk_string(Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void glk_chr(Driver *drvthis, int x, int y, char c); MODULE_EXPORT void glk_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void glk_old_vbar(Driver *drvthis, int x, int len); MODULE_EXPORT void glk_old_vbar(Driver *drvthis, int x, int len);
+2 -2
View File
@@ -127,7 +127,7 @@ MODULE_EXPORT char *symbol_prefix = "HD44780_";
// Opens com port and sets baud correctly... // Opens com port and sets baud correctly...
// //
MODULE_EXPORT int MODULE_EXPORT int
HD44780_init (Driver * drvthis) HD44780_init (Driver *drvthis)
{ {
// TODO: remove the two magic numbers below // TODO: remove the two magic numbers below
// TODO: single point of return // TODO: single point of return
@@ -606,7 +606,7 @@ HD44780_chr (Driver *drvthis, int x, int y, char ch)
// Place a string in the framebuffer // Place a string in the framebuffer
// //
MODULE_EXPORT void MODULE_EXPORT void
HD44780_string (Driver *drvthis, int x, int y, char *string) HD44780_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -26,7 +26,7 @@ MODULE_EXPORT int HD44780_cellwidth (Driver *drvthis);
MODULE_EXPORT int HD44780_cellheight (Driver *drvthis); MODULE_EXPORT int HD44780_cellheight (Driver *drvthis);
MODULE_EXPORT void HD44780_clear (Driver *drvthis); MODULE_EXPORT void HD44780_clear (Driver *drvthis);
MODULE_EXPORT void HD44780_flush (Driver *drvthis); MODULE_EXPORT void HD44780_flush (Driver *drvthis);
MODULE_EXPORT void HD44780_string (Driver *drvthis, int x, int y, char *s); MODULE_EXPORT void HD44780_string (Driver *drvthis, int x, int y, const char s[]);
MODULE_EXPORT void HD44780_chr (Driver *drvthis, int x, int y, char ch); MODULE_EXPORT void HD44780_chr (Driver *drvthis, int x, int y, char ch);
MODULE_EXPORT void HD44780_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void HD44780_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+1 -1
View File
@@ -245,7 +245,7 @@ MODULE_EXPORT void imon_flush (Driver *drvthis)
* \param y Vertical character position (row). * \param y Vertical character position (row).
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, char string[]) MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, const char string[])
{ {
int i; int i;
+1 -1
View File
@@ -36,7 +36,7 @@ MODULE_EXPORT int imon_cellwidth (Driver *drvthis);
MODULE_EXPORT int imon_cellheight (Driver *drvthis); MODULE_EXPORT int imon_cellheight (Driver *drvthis);
MODULE_EXPORT void imon_clear (Driver *drvthis); MODULE_EXPORT void imon_clear (Driver *drvthis);
MODULE_EXPORT void imon_flush (Driver *drvthis); MODULE_EXPORT void imon_flush (Driver *drvthis);
MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void imon_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void imon_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT int imon_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT int imon_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT const char *imon_get_info (Driver *drvthis); MODULE_EXPORT const char *imon_get_info (Driver *drvthis);
+17 -17
View File
@@ -58,8 +58,8 @@ typedef struct driver_private_data {
} PrivateData; } PrivateData;
static void LB216_hidecursor(Driver * drvthis); static void LB216_hidecursor(Driver *drvthis);
static void LB216_reboot(Driver * drvthis); static void LB216_reboot(Driver *drvthis);
// Vars for the server core // Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION; MODULE_EXPORT char *api_version = API_VERSION;
@@ -74,7 +74,7 @@ MODULE_EXPORT char *symbol_prefix = "LB216_";
// Opens com port and sets baud correctly... // Opens com port and sets baud correctly...
// //
MODULE_EXPORT int MODULE_EXPORT int
LB216_init(Driver * drvthis) LB216_init(Driver *drvthis)
{ {
PrivateData *p; PrivateData *p;
struct termios portset; struct termios portset;
@@ -190,7 +190,7 @@ LB216_init(Driver * drvthis)
// Clean-up // Clean-up
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_close(Driver * drvthis) LB216_close(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -256,7 +256,7 @@ LB216_cellheight (Driver *drvthis)
// Clears the LCD screen // Clears the LCD screen
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_clear (Driver * drvthis) LB216_clear (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -268,7 +268,7 @@ LB216_clear (Driver * drvthis)
// Flushes the framebuffer to the LCD // Flushes the framebuffer to the LCD
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_flush(Driver * drvthis) LB216_flush(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT]; char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
@@ -295,7 +295,7 @@ LB216_flush(Driver * drvthis)
// upper-left is (1,1), and the lower right should be (16,2). // upper-left is (1,1), and the lower right should be (16,2).
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_chr(Driver * drvthis, int x, int y, char c) LB216_chr(Driver *drvthis, int x, int y, char c)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -315,7 +315,7 @@ LB216_chr(Driver * drvthis, int x, int y, char c)
// an intermediate brightness... // an intermediate brightness...
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_backlight(Driver * drvthis, int on) LB216_backlight(Driver *drvthis, int on)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -329,7 +329,7 @@ LB216_backlight(Driver * drvthis, int on)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Get rid of the blinking curson // Get rid of the blinking curson
// //
static void LB216_hidecursor(Driver * drvthis) static void LB216_hidecursor(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char out[4]; char out[4];
@@ -341,7 +341,7 @@ static void LB216_hidecursor(Driver * drvthis)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Reset the display bios // Reset the display bios
// //
static void LB216_reboot(Driver * drvthis) static void LB216_reboot(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char out[4]; char out[4];
@@ -352,7 +352,7 @@ static void LB216_reboot(Driver * drvthis)
MODULE_EXPORT void MODULE_EXPORT void
LB216_string (Driver * drvthis, int x, int y, char string[]) LB216_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -378,7 +378,7 @@ LB216_string (Driver * drvthis, int x, int y, char string[])
// Sets up for vertical bars. Call before LB216->vbar() // Sets up for vertical bars. Call before LB216->vbar()
// //
static void static void
LB216_init_vbar(Driver * drvthis) LB216_init_vbar(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char a[] = { char a[] = {
@@ -468,7 +468,7 @@ LB216_init_vbar(Driver * drvthis)
// Inits horizontal bars... // Inits horizontal bars...
// //
static void static void
LB216_init_hbar(Driver * drvthis) LB216_init_hbar(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char a[] = { char a[] = {
@@ -536,7 +536,7 @@ LB216_init_hbar(Driver * drvthis)
// Draws a vertical bar... // Draws a vertical bar...
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_vbar(Driver * drvthis, int x, int len) LB216_vbar(Driver *drvthis, int x, int len)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 }; char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 };
@@ -556,7 +556,7 @@ LB216_vbar(Driver * drvthis, int x, int len)
// Draws a horizontal bar to the right. // Draws a horizontal bar to the right.
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_hbar(Driver * drvthis, int x, int y, int len) LB216_hbar(Driver *drvthis, int x, int y, int len)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char map[7] = { 32, 1, 2, 3, 4, 5 }; char map[7] = { 32, 1, 2, 3, 4, 5 };
@@ -580,7 +580,7 @@ LB216_hbar(Driver * drvthis, int x, int y, int len)
// The input is just an array of characters... // The input is just an array of characters...
// //
MODULE_EXPORT void MODULE_EXPORT void
LB216_set_char(Driver * drvthis, int n, char *dat) LB216_set_char(Driver *drvthis, int n, char *dat)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char out[4]; char out[4];
@@ -608,7 +608,7 @@ LB216_set_char(Driver * drvthis, int n, char *dat)
MODULE_EXPORT int MODULE_EXPORT int
LB216_icon(Driver * drvthis, int x, int y, int icon) LB216_icon(Driver *drvthis, int x, int y, int icon)
{ {
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
static char heart_open[] = { static char heart_open[] = {
+12 -12
View File
@@ -3,24 +3,24 @@
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int LB216_init(Driver * drvthis); MODULE_EXPORT int LB216_init(Driver *drvthis);
MODULE_EXPORT void LB216_close(Driver * drvthis); MODULE_EXPORT void LB216_close(Driver *drvthis);
MODULE_EXPORT int LB216_width (Driver *drvthis); MODULE_EXPORT int LB216_width (Driver *drvthis);
MODULE_EXPORT int LB216_height (Driver *drvthis); MODULE_EXPORT int LB216_height (Driver *drvthis);
MODULE_EXPORT int LB216_cellwidth (Driver *drvthis); MODULE_EXPORT int LB216_cellwidth (Driver *drvthis);
MODULE_EXPORT int LB216_cellheight (Driver *drvthis); MODULE_EXPORT int LB216_cellheight (Driver *drvthis);
MODULE_EXPORT void LB216_clear (Driver * drvthis); MODULE_EXPORT void LB216_clear (Driver *drvthis);
MODULE_EXPORT void LB216_flush(Driver * drvthis); MODULE_EXPORT void LB216_flush(Driver *drvthis);
MODULE_EXPORT void LB216_string (Driver * drvthis, int x, int y, char string[]); MODULE_EXPORT void LB216_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void LB216_chr(Driver * drvthis, int x, int y, char c) ; MODULE_EXPORT void LB216_chr(Driver *drvthis, int x, int y, char c) ;
MODULE_EXPORT void LB216_old_vbar(Driver * drvthis, int x, int len); MODULE_EXPORT void LB216_old_vbar(Driver *drvthis, int x, int len);
MODULE_EXPORT void LB216_old_hbar(Driver * drvthis, int x, int y, int len); MODULE_EXPORT void LB216_old_hbar(Driver *drvthis, int x, int y, int len);
MODULE_EXPORT void LB216_num(Driver * drvthis, int x, int num); MODULE_EXPORT void LB216_num(Driver *drvthis, int x, int num);
MODULE_EXPORT int LB216_icon(Driver * drvthis, int x, int y, int icon); MODULE_EXPORT int LB216_icon(Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void LB216_set_char(Driver * drvthis, int n, char *dat); MODULE_EXPORT void LB216_set_char(Driver *drvthis, int n, char *dat);
MODULE_EXPORT void LB216_backlight(Driver * drvthis, int on); MODULE_EXPORT void LB216_backlight(Driver *drvthis, int on);
#endif #endif
+26 -26
View File
@@ -127,44 +127,44 @@ typedef struct lcd_logical_driver {
/* The driver loader will look for symbols with these names ! */ /* The driver loader will look for symbols with these names ! */
/* mandatory functions (necessary for all drivers) */ /* mandatory functions (necessary for all drivers) */
int (*init) (struct lcd_logical_driver* drvthis); int (*init) (struct lcd_logical_driver *drvthis);
void (*close) (struct lcd_logical_driver* drvthis); void (*close) (struct lcd_logical_driver *drvthis);
/* essential output functions (necessary for output drivers) */ /* essential output functions (necessary for output drivers) */
int (*width) (struct lcd_logical_driver* drvthis); int (*width) (struct lcd_logical_driver *drvthis);
int (*height) (struct lcd_logical_driver* drvthis); int (*height) (struct lcd_logical_driver *drvthis);
void (*clear) (struct lcd_logical_driver* drvthis); void (*clear) (struct lcd_logical_driver *drvthis);
void (*flush) (struct lcd_logical_driver* drvthis); void (*flush) (struct lcd_logical_driver *drvthis);
void (*string) (struct lcd_logical_driver* drvthis, int x, int y, char *str); void (*string) (struct lcd_logical_driver *drvthis, int x, int y, const char *str);
void (*chr) (struct lcd_logical_driver* drvthis, int x, int y, char c); void (*chr) (struct lcd_logical_driver *drvthis, int x, int y, char c);
/* essential input functions (necessary for all input drivers) */ /* essential input functions (necessary for all input drivers) */
const char *(*get_key) (struct lcd_logical_driver* drvthis); const char *(*get_key) (struct lcd_logical_driver *drvthis);
/* extended output functions (optional; core provides alternatives) */ /* extended output functions (optional; core provides alternatives) */
void (*vbar) (struct lcd_logical_driver* drvthis, int x, int y, int len, int promille, int pattern); void (*vbar) (struct lcd_logical_driver *drvthis, int x, int y, int len, int promille, int pattern);
void (*hbar) (struct lcd_logical_driver* drvthis, int x, int y, int len, int promille, int pattern); void (*hbar) (struct lcd_logical_driver *drvthis, int x, int y, int len, int promille, int pattern);
void (*num) (struct lcd_logical_driver* drvthis, int x, int num); void (*num) (struct lcd_logical_driver *drvthis, int x, int num);
void (*heartbeat) (struct lcd_logical_driver* drvthis, int state); void (*heartbeat) (struct lcd_logical_driver *drvthis, int state);
int (*icon) (struct lcd_logical_driver* drvthis, int x, int y, int icon); int (*icon) (struct lcd_logical_driver *drvthis, int x, int y, int icon);
void (*cursor) (struct lcd_logical_driver* drvthis, int x, int y, int type); void (*cursor) (struct lcd_logical_driver *drvthis, int x, int y, int type);
/* user-defined character functions, are those still supported ? */ /* user-defined character functions, are those still supported ? */
void (*set_char) (struct lcd_logical_driver* drvthis, int n, unsigned char *dat); void (*set_char) (struct lcd_logical_driver *drvthis, int n, unsigned char *dat);
int (*get_free_chars) (struct lcd_logical_driver* drvthis); int (*get_free_chars) (struct lcd_logical_driver *drvthis);
int (*cellwidth) (struct lcd_logical_driver* drvthis); int (*cellwidth) (struct lcd_logical_driver *drvthis);
int (*cellheight) (struct lcd_logical_driver* drvthis); int (*cellheight) (struct lcd_logical_driver *drvthis);
/* Hardware functions */ /* Hardware functions */
int (*get_contrast) (struct lcd_logical_driver* drvthis); int (*get_contrast) (struct lcd_logical_driver *drvthis);
void (*set_contrast) (struct lcd_logical_driver* drvthis, int promille); void (*set_contrast) (struct lcd_logical_driver *drvthis, int promille);
int (*get_brightness) (struct lcd_logical_driver* drvthis, int state); int (*get_brightness) (struct lcd_logical_driver *drvthis, int state);
void (*set_brightness) (struct lcd_logical_driver* drvthis, int state, int promille); void (*set_brightness) (struct lcd_logical_driver *drvthis, int state, int promille);
void (*backlight) (struct lcd_logical_driver* drvthis, int on); void (*backlight) (struct lcd_logical_driver *drvthis, int on);
void (*output) (struct lcd_logical_driver* drvthis, int state); void (*output) (struct lcd_logical_driver *drvthis, int state);
/* informational functions */ /* informational functions */
const char * (*get_info) (struct lcd_logical_driver* drvthis); const char * (*get_info) (struct lcd_logical_driver *drvthis);
/******** Variables in server core available for drivers ********/ /******** Variables in server core available for drivers ********/
+1 -1
View File
@@ -339,7 +339,7 @@ lcdm001_chr (Driver *drvthis, int x, int y, char c)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_string (Driver *drvthis, int x, int y, char *string) lcdm001_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -39,7 +39,7 @@ MODULE_EXPORT int lcdm001_width (Driver *drvthis);
MODULE_EXPORT int lcdm001_height (Driver *drvthis); MODULE_EXPORT int lcdm001_height (Driver *drvthis);
MODULE_EXPORT void lcdm001_clear (Driver *drvthis); MODULE_EXPORT void lcdm001_clear (Driver *drvthis);
MODULE_EXPORT void lcdm001_flush (Driver *drvthis); MODULE_EXPORT void lcdm001_flush (Driver *drvthis);
MODULE_EXPORT void lcdm001_string (Driver *drvthis, int x, int y, char *string); MODULE_EXPORT void lcdm001_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void lcdm001_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void lcdm001_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void lcdm001_old_vbar (Driver *drvthis, int x, int len); MODULE_EXPORT void lcdm001_old_vbar (Driver *drvthis, int x, int len);
+1 -1
View File
@@ -384,7 +384,7 @@ ms6931_clear (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (16,2). // upper-left is (1,1), and the lower right should be (16,2).
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_string (Driver *drvthis, int x, int y, char string[]) ms6931_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -45,7 +45,7 @@ MODULE_EXPORT void ms6931_backlight (Driver *drvthis, int on);
MODULE_EXPORT void ms6931_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void ms6931_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void ms6931_clear (Driver *drvthis); MODULE_EXPORT void ms6931_clear (Driver *drvthis);
MODULE_EXPORT void ms6931_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void ms6931_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT const char *ms6931_get_key (Driver *drvthis); MODULE_EXPORT const char *ms6931_get_key (Driver *drvthis);
MODULE_EXPORT void ms6931_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern); MODULE_EXPORT void ms6931_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern);
MODULE_EXPORT void ms6931_heartbeat (Driver *drvthis, int state); MODULE_EXPORT void ms6931_heartbeat (Driver *drvthis, int state);
+19 -19
View File
@@ -118,7 +118,7 @@ MODULE_EXPORT char *symbol_prefix = "MTC_S16209X_";
// Opens com port and sets baud correctly... // Opens com port and sets baud correctly...
// //
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_init (Driver * drvthis) MTC_S16209X_init (Driver *drvthis)
{ {
PrivateData *p; PrivateData *p;
struct termios portset; struct termios portset;
@@ -228,7 +228,7 @@ MTC_S16209X_init (Driver * drvthis)
// Clean-up // Clean-up
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_close (Driver * drvthis) MTC_S16209X_close (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -258,7 +258,7 @@ MTC_S16209X_close (Driver * drvthis)
// Returns the display width // Returns the display width
// //
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_width (Driver * drvthis) MTC_S16209X_width (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -269,7 +269,7 @@ MTC_S16209X_width (Driver * drvthis)
// Returns the display height // Returns the display height
// //
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_height (Driver * drvthis) MTC_S16209X_height (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -280,7 +280,7 @@ MTC_S16209X_height (Driver * drvthis)
// Returns the display's cell width // Returns the display's cell width
// //
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_cellwidth (Driver * drvthis) MTC_S16209X_cellwidth (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -291,7 +291,7 @@ MTC_S16209X_cellwidth (Driver * drvthis)
// Returns the display's cell height // Returns the display's cell height
// //
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_cellheight (Driver * drvthis) MTC_S16209X_cellheight (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -302,7 +302,7 @@ MTC_S16209X_cellheight (Driver * drvthis)
// Clears the LCD screen // Clears the LCD screen
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_clear (Driver * drvthis) MTC_S16209X_clear (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -314,7 +314,7 @@ MTC_S16209X_clear (Driver * drvthis)
// Flushes the framebuffer to the LCD // Flushes the framebuffer to the LCD
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_flush (Driver * drvthis) MTC_S16209X_flush (Driver *drvthis)
{ {
/* TODO: Do we really have a flush for this thing? Do we need to? How do we do it? */ /* TODO: Do we really have a flush for this thing? Do we need to? How do we do it? */
/* TODO Update: yes, we need to buffer and flush - else the LCD looks slow, and flicker a lot */ /* TODO Update: yes, we need to buffer and flush - else the LCD looks slow, and flicker a lot */
@@ -353,7 +353,7 @@ MTC_S16209X_flush (Driver * drvthis)
// upper-left is (1,1), and the lower right should be (16,2). // upper-left is (1,1), and the lower right should be (16,2).
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_chr (Driver * drvthis, int x, int y, char c) MTC_S16209X_chr (Driver *drvthis, int x, int y, char c)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -371,7 +371,7 @@ MTC_S16209X_chr (Driver * drvthis, int x, int y, char c)
// an intermediate brightness... // an intermediate brightness...
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_backlight (Driver * drvthis, int on) MTC_S16209X_backlight (Driver *drvthis, int on)
{ {
/* TODO: Can the backlights be controlled? Can't find anything in the docs */ /* TODO: Can the backlights be controlled? Can't find anything in the docs */
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
@@ -384,7 +384,7 @@ MTC_S16209X_backlight (Driver * drvthis, int on)
// Get rid of the blinking cursor // Get rid of the blinking cursor
// //
static void static void
MTC_S16209X_hidecursor (Driver * drvthis) MTC_S16209X_hidecursor (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int result; int result;
@@ -406,7 +406,7 @@ MTC_S16209X_hidecursor (Driver * drvthis)
// Reset the display bios // Reset the display bios
// //
static void static void
MTC_S16209X_reboot (Driver * drvthis) MTC_S16209X_reboot (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int result; int result;
@@ -418,7 +418,7 @@ MTC_S16209X_reboot (Driver * drvthis)
#endif // CAN_REBOOT_LCD #endif // CAN_REBOOT_LCD
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_string (Driver * drvthis, int x, int y, char string[]) MTC_S16209X_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -439,7 +439,7 @@ MTC_S16209X_string (Driver * drvthis, int x, int y, char string[])
// Sets up for vertical bars. Call before MTC_S16209X->vbar() // Sets up for vertical bars. Call before MTC_S16209X->vbar()
// //
static void static void
MTC_S16209X_init_vbar (Driver * drvthis) MTC_S16209X_init_vbar (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
static char a[] = { static char a[] = {
@@ -529,7 +529,7 @@ MTC_S16209X_init_vbar (Driver * drvthis)
// Inits horizontal bars... // Inits horizontal bars...
// //
static void static void
MTC_S16209X_init_hbar (Driver * drvthis) MTC_S16209X_init_hbar (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
static char a[] = { static char a[] = {
@@ -597,7 +597,7 @@ MTC_S16209X_init_hbar (Driver * drvthis)
// Draws a vertical bar... // Draws a vertical bar...
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_vbar (Driver * drvthis, int x, int y, int len, int promille, int options) MTC_S16209X_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -610,7 +610,7 @@ MTC_S16209X_vbar (Driver * drvthis, int x, int y, int len, int promille, int opt
// Draws a horizontal bar to the right. // Draws a horizontal bar to the right.
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_hbar (Driver * drvthis, int x, int y, int len, int promille, int options) MTC_S16209X_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -628,7 +628,7 @@ MTC_S16209X_hbar (Driver * drvthis, int x, int y, int len, int promille, int opt
// The input is just an array of characters... // The input is just an array of characters...
// //
MODULE_EXPORT void MODULE_EXPORT void
MTC_S16209X_set_char (Driver * drvthis, int n, char *dat) MTC_S16209X_set_char (Driver *drvthis, int n, char *dat)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
char out[4]; char out[4];
@@ -664,7 +664,7 @@ MTC_S16209X_set_char (Driver * drvthis, int n, char *dat)
} }
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_icon (Driver * drvthis, int x, int y, int icon) MTC_S16209X_icon (Driver *drvthis, int x, int y, int icon)
{ {
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
static char heart_open[] = { static char heart_open[] = {
+11 -11
View File
@@ -40,23 +40,23 @@
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int MTC_S16209X_init(Driver * drvthis); MODULE_EXPORT int MTC_S16209X_init(Driver *drvthis);
MODULE_EXPORT void MTC_S16209X_close(Driver * drvthis); MODULE_EXPORT void MTC_S16209X_close(Driver *drvthis);
MODULE_EXPORT int MTC_S16209X_width (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_width (Driver *drvthis);
MODULE_EXPORT int MTC_S16209X_height (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_height (Driver *drvthis);
MODULE_EXPORT int MTC_S16209X_cellwidth (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_cellwidth (Driver *drvthis);
MODULE_EXPORT int MTC_S16209X_cellheight (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_cellheight (Driver *drvthis);
MODULE_EXPORT void MTC_S16209X_clear (Driver * drvthis); MODULE_EXPORT void MTC_S16209X_clear (Driver *drvthis);
MODULE_EXPORT void MTC_S16209X_flush(Driver * drvthis); MODULE_EXPORT void MTC_S16209X_flush(Driver *drvthis);
MODULE_EXPORT void MTC_S16209X_string (Driver * drvthis, int x, int y, char string[]); MODULE_EXPORT void MTC_S16209X_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void MTC_S16209X_chr(Driver * drvthis, int x, int y, char c) ; MODULE_EXPORT void MTC_S16209X_chr(Driver *drvthis, int x, int y, char c) ;
MODULE_EXPORT void MTC_S16209X_vbar(Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void MTC_S16209X_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void MTC_S16209X_hbar(Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void MTC_S16209X_hbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT int MTC_S16209X_icon(Driver * drvthis, int x, int y, int icon); MODULE_EXPORT int MTC_S16209X_icon(Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void MTC_S16209X_set_char(Driver * drvthis, int n, char *dat); MODULE_EXPORT void MTC_S16209X_set_char(Driver *drvthis, int n, char *dat);
MODULE_EXPORT void MTC_S16209X_backlight(Driver * drvthis, int on); MODULE_EXPORT void MTC_S16209X_backlight(Driver *drvthis, int on);
#endif #endif
+1 -1
View File
@@ -301,7 +301,7 @@ sed1520_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
sed1520_string (Driver *drvthis, int x, int y, char string[]) sed1520_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -11,7 +11,7 @@ MODULE_EXPORT int sed1520_cellwidth (Driver *drvthis);
MODULE_EXPORT int sed1520_cellheight (Driver *drvthis); MODULE_EXPORT int sed1520_cellheight (Driver *drvthis);
MODULE_EXPORT void sed1520_clear (Driver *drvthis); MODULE_EXPORT void sed1520_clear (Driver *drvthis);
MODULE_EXPORT void sed1520_flush (Driver *drvthis); MODULE_EXPORT void sed1520_flush (Driver *drvthis);
MODULE_EXPORT void sed1520_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void sed1520_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void sed1520_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void sed1520_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void sed1520_old_vbar (Driver *drvthis, int x, int len); MODULE_EXPORT void sed1520_old_vbar (Driver *drvthis, int x, int len);
+3 -3
View File
@@ -462,7 +462,7 @@ MtxcOrb_cellheight (Driver *drvthis)
* \param string String that gets written. * \param string String that gets written.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
serialPOS_string (Driver *drvthis, int x, int y, char string[]) serialPOS_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -712,7 +712,7 @@ serialPOS_get_info (Driver *drvthis)
* \param options Options (currently unused). * \param options Options (currently unused).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
serialPOS_vbar (Driver * drvthis, int x, int y, int len, int promille, int options) serialPOS_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
// map // map
@@ -765,7 +765,7 @@ serialPOS_vbar (Driver * drvthis, int x, int y, int len, int promille, int optio
* \param options Options (currently unused). * \param options Options (currently unused).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
serialPOS_hbar (Driver * drvthis, int x, int y, int len, int promille, int options) serialPOS_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int pixels = ((long) 2 * len * p->cellwidth) * promille / 2000; int pixels = ((long) 2 * len * p->cellwidth) * promille / 2000;
+3 -3
View File
@@ -20,12 +20,12 @@ MODULE_EXPORT int serialPOS_cellwidth (Driver *drvthis);
MODULE_EXPORT int serialPOS_cellheight (Driver *drvthis); MODULE_EXPORT int serialPOS_cellheight (Driver *drvthis);
MODULE_EXPORT void serialPOS_clear (Driver *drvthis); MODULE_EXPORT void serialPOS_clear (Driver *drvthis);
MODULE_EXPORT void serialPOS_flush (Driver *drvthis); MODULE_EXPORT void serialPOS_flush (Driver *drvthis);
MODULE_EXPORT void serialPOS_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void serialPOS_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void serialPOS_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void serialPOS_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT const char * serialPOS_get_key (Driver *drvthis); MODULE_EXPORT const char * serialPOS_get_key (Driver *drvthis);
MODULE_EXPORT void serialPOS_vbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void serialPOS_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void serialPOS_hbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void serialPOS_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT int serialPOS_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT int serialPOS_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void serialPOS_num (Driver *drvthis, int x, int num); MODULE_EXPORT void serialPOS_num (Driver *drvthis, int x, int num);
MODULE_EXPORT void serialPOS_cursor (Driver *drvthis, int x, int y, int state); MODULE_EXPORT void serialPOS_cursor (Driver *drvthis, int x, int y, int state);
+54 -53
View File
@@ -129,11 +129,11 @@ serialVFD_init (Driver *drvthis)
p->refresh_timer = 480; p->refresh_timer = 480;
p->hw_brightness = 0; p->hw_brightness = 0;
debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis ); debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis);
/* Read config file */ /* Read config file */
p->use_parallel = drvthis->config_get_bool( drvthis->name, "use_parallel", 0, 0 ); p->use_parallel = drvthis->config_get_bool(drvthis->name, "use_parallel", 0, 0);
/* Which device should be used */ /* Which device should be used */
strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device)); strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
@@ -141,12 +141,12 @@ serialVFD_init (Driver *drvthis)
report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device); report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
if (p->use_parallel) { if (p->use_parallel) {
p->port = drvthis->config_get_int( drvthis->name, "port", 0, LPTPORT ); p->port = drvthis->config_get_int(drvthis->name, "port", 0, LPTPORT);
} }
else { else {
/* Which speed */ /* Which speed */
tmp = drvthis->config_get_int (drvthis->name, "Speed", 0, DEFAULT_SPEED); tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
if ((tmp != 1200) && (tmp != 2400) && (tmp != 9600) && (tmp != 19200) && (tmp != 115200)) { if ((tmp != 1200) && (tmp != 2400) && (tmp != 9600) && (tmp != 19200) && (tmp != 115200)) {
report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default %d.\n", report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default %d.\n",
drvthis->name, DEFAULT_SPEED); drvthis->name, DEFAULT_SPEED);
@@ -158,7 +158,7 @@ serialVFD_init (Driver *drvthis)
else if (tmp == 19200) p->speed = B19200; else if (tmp == 19200) p->speed = B19200;
else if (tmp == 115200) p->speed = B115200; else if (tmp == 115200) p->speed = B115200;
} }
// report(RPT_ERR, "%s: Port: %X\n", __FUNCTION__, p->port, strerror (errno)); // report(RPT_ERR, "%s: Port: %X\n", __FUNCTION__, p->port, strerror(errno));
/* Which size */ /* Which size */
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size)); strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
@@ -206,7 +206,7 @@ serialVFD_init (Driver *drvthis)
p->display_type = tmp; p->display_type = tmp;
/* Number of custom characters */ /* Number of custom characters */
tmp = drvthis->config_get_int (drvthis->name, "Custom-Characters", 0, -83); tmp = drvthis->config_get_int(drvthis->name, "Custom-Characters", 0, -83);
if ((tmp < 0) || (tmp > 99)) { if ((tmp < 0) || (tmp > 99)) {
report(RPT_WARNING, "%s: The number of Custom-Characters must be between 0 and 99. Using default.", report(RPT_WARNING, "%s: The number of Custom-Characters must be between 0 and 99. Using default.",
drvthis->name, 0); drvthis->name, 0);
@@ -215,10 +215,10 @@ serialVFD_init (Driver *drvthis)
p->customchars = tmp; p->customchars = tmp;
// report (RPT_ERR, "%s: Port: %X\n", __FUNCTION__, p->port, strerror (errno)); // report(RPT_ERR, "%s: Port: %X\n", __FUNCTION__, p->port, strerror(errno));
// Do connection type specific io-port init // Do connection type specific io-port init
if (Port_Function[p->use_parallel].init_fkt (drvthis) == -1) { if (Port_Function[p->use_parallel].init_fkt(drvthis) == -1) {
report(RPT_ERR, "%s: unable to initialize io-port.", drvthis->name); report(RPT_ERR, "%s: unable to initialize io-port.", drvthis->name);
return -1; return -1;
} }
@@ -243,11 +243,11 @@ serialVFD_init (Driver *drvthis)
//setup displayspecific data //setup displayspecific data
serialVFD_load_display_data(drvthis); serialVFD_load_display_data(drvthis);
// report (RPT_ERR, "%s: Port: %X\n", drvthis->name, p->port, strerror (errno)); // report(RPT_ERR, "%s: Port: %X\n", drvthis->name, p->port, strerror(errno));
//initialise display //initialise display
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[reset][1],p->hw_cmd[reset][0]); Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[reset][1],p->hw_cmd[reset][0]);
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[init_cmds][1],p->hw_cmd[init_cmds][0]); Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[init_cmds][1],p->hw_cmd[init_cmds][0]);
serialVFD_backlight(drvthis, 1); serialVFD_backlight(drvthis, 1);
report(RPT_DEBUG, "%s: init() done", drvthis->name); report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 0; return 0;
@@ -304,9 +304,9 @@ serialVFD_backlight (Driver *drvthis, int on)
// map range [0, 1000] -> [0, 4] that the hardware understands // map range [0, 1000] -> [0, 4] that the hardware understands
//(4 steps 0-250, 251-500, 501-750, 751-1000) //(4 steps 0-250, 251-500, 501-750, 751-1000)
hardware_value /= 251; hardware_value /= 251;
if(hardware_value != p->hw_brightness){ if (hardware_value != p->hw_brightness) {
p->hw_brightness=hardware_value; p->hw_brightness = hardware_value;
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[p->hw_brightness][1],\ Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[p->hw_brightness][1],\
p->hw_cmd[p->hw_brightness][0]); p->hw_cmd[p->hw_brightness][0]);
} }
@@ -322,11 +322,11 @@ serialVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int option
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
if (p->customchars >= p->cellheight || p->predefined_vbar == 1){ if (p->customchars >= p->cellheight || p->predefined_vbar == 1) {
serialVFD_init_vbar(drvthis); serialVFD_init_vbar(drvthis);
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, p->vbar_cc_offset); lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, p->vbar_cc_offset);
} }
else{ else {
lib_vbar_static(drvthis, x, y, len, promille, options, 2, 0x5E); lib_vbar_static(drvthis, x, y, len, promille, options, 2, 0x5E);
} }
} }
@@ -340,11 +340,11 @@ serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int option
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
if (p->customchars >= p->cellwidth || p->predefined_hbar == 1){ if (p->customchars >= p->cellwidth || p->predefined_hbar == 1) {
serialVFD_init_hbar(drvthis); serialVFD_init_hbar(drvthis);
lib_hbar_static(drvthis, x, y, len, promille, options, p->cellwidth, p->hbar_cc_offset); lib_hbar_static(drvthis, x, y, len, promille, options, p->cellwidth, p->hbar_cc_offset);
} }
else{ else {
lib_hbar_static(drvthis, x, y, len, promille, options, 2, 0x2C); lib_hbar_static(drvthis, x, y, len, promille, options, 2, 0x2C);
} }
} }
@@ -391,10 +391,10 @@ serialVFD_put_char (Driver *drvthis, int n)
{ // put char in display { // put char in display
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[set_user_char][1],\ Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[set_user_char][1],\
p->hw_cmd[set_user_char][0]);// substitute and select Character to overwrite p->hw_cmd[set_user_char][0]);// substitute and select Character to overwrite
Port_Function[p->use_parallel].write_fkt (drvthis, (char*)&p->usr_chr_mapping[n], 1); Port_Function[p->use_parallel].write_fkt(drvthis, (char*)&p->usr_chr_mapping[n], 1);
Port_Function[p->use_parallel].write_fkt (drvthis, &p->custom_char[n][0], p->usr_chr_dot_assignment[0]);// overwrite selected Character Port_Function[p->use_parallel].write_fkt(drvthis, &p->custom_char[n][0], p->usr_chr_dot_assignment[0]);// overwrite selected Character
} }
@@ -415,37 +415,37 @@ serialVFD_flush (Driver *drvthis)
for (i = 0; i < p->customchars; i++) { for (i = 0; i < p->customchars; i++) {
for (j = 0; j < p->usr_chr_dot_assignment[0]; j++) { for (j = 0; j < p->usr_chr_dot_assignment[0]; j++) {
if (p->custom_char[i][j] != p->custom_char_store[i][j]) { if (p->custom_char[i][j] != p->custom_char_store[i][j]) {
custom_char_changed[i]=1; custom_char_changed[i] = 1;
// report (RPT_ERR, "%s: Char: %X %i\n", __FUNCTION__, i, j, strerror (errno)); // report(RPT_ERR, "%s: Char: %X %i\n", __FUNCTION__, i, j, strerror(errno));
} }
p->custom_char_store[i][j]=p->custom_char[i][j]; p->custom_char_store[i][j] = p->custom_char[i][j];
} }
} }
if (p->refresh_timer > 500) { // Do a full refresh every 500 refreshs. if (p->refresh_timer > 500) { // Do a full refresh every 500 refreshs.
// With this it is possible to switch display on and off while lcdproc is running // With this it is possible to switch display on and off while lcdproc is running
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[init_cmds][1],p->hw_cmd[init_cmds][0]); Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[init_cmds][1],p->hw_cmd[init_cmds][0]);
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[p->hw_brightness][1],\ Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[p->hw_brightness][1],\
p->hw_cmd[p->hw_brightness][0]); // restore brightness p->hw_cmd[p->hw_brightness][0]); // restore brightness
memset(p->backingstore, 0, p->width * p->height); // clear Backing-store memset(p->backingstore, 0, p->width * p->height); // clear Backing-store
for(i=0;i<p->customchars;i++) // refresh all customcharacters for (i = 0; i < p->customchars; i++) // refresh all customcharacters
custom_char_changed[i]=1; custom_char_changed[i] = 1;
p->refresh_timer = 0; p->refresh_timer = 0;
} }
p->refresh_timer++; p->refresh_timer++;
if (p->display_type != 1) { //not KD Rev 2.1 if (p->display_type != 1) { //not KD Rev 2.1
for(i=0;i<p->customchars;i++) // set customcharacters for (i = 0; i < p->customchars; i++) // set customcharacters
if(custom_char_changed[i]) if (custom_char_changed[i])
serialVFD_put_char (drvthis, i); serialVFD_put_char(drvthis, i);
} }
if(custom_char_changed[p->last_custom]) if (custom_char_changed[p->last_custom])
p->last_custom=-10; p->last_custom = -10;
for (i = 0; i < (p->height * p->width); i++) { for (i = 0; i < (p->height * p->width); i++) {
@@ -453,37 +453,38 @@ serialVFD_flush (Driver *drvthis)
* on the screen, don't put it there again * on the screen, don't put it there again
*/ */
if(p->framebuf[i] != p->backingstore[i] || (p->framebuf[i] <=30 && custom_char_changed[(int)p->framebuf[i]])) { if ((p->framebuf[i] != p->backingstore[i]) ||
if (last_chr < i-1){ // if not last char written cursor has to be moved. ((p->framebuf[i] <= 30) && (custom_char_changed[(int)p->framebuf[i]]))) {
if(last_chr < i-2-p->hw_cmd[mv_cursor][0]) { if (last_chr < i-1) { // if not last char written cursor has to be moved.
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[mv_cursor][1],\ if (last_chr < i-2-p->hw_cmd[mv_cursor][0]) {
Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[mv_cursor][1],\
p->hw_cmd[mv_cursor][0]); p->hw_cmd[mv_cursor][0]);
Port_Function[p->use_parallel].write_fkt (drvthis, (char*)&i, 1); Port_Function[p->use_parallel].write_fkt(drvthis, (char*)&i, 1);
} }
else { else {
for (j = last_chr; j < (i-1); j++) for (j = last_chr; j < (i-1); j++)
Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[hor_tab][1], p->hw_cmd[hor_tab][0]); Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[hor_tab][1], p->hw_cmd[hor_tab][0]);
} }
} }
if(p->framebuf[i] <= 30) { // custom character if (p->framebuf[i] <= 30) { // custom character
if (p->display_type == 1) { // KD Rev 2.1 only if (p->display_type == 1) { // KD Rev 2.1 only
if (p->last_custom != p->framebuf[i]){ if (p->last_custom != p->framebuf[i]) {
Port_Function[p->use_parallel].write_fkt (drvthis, "\x1A\xDB", 2); // substitute and select character to overwrite (237) Port_Function[p->use_parallel].write_fkt(drvthis, "\x1A\xDB", 2); // substitute and select character to overwrite (237)
Port_Function[p->use_parallel].write_fkt (drvthis, &p->custom_char[(int)p->framebuf[i]][0], 7);// overwrite selected character Port_Function[p->use_parallel].write_fkt(drvthis, &p->custom_char[(int)p->framebuf[i]][0], 7);// overwrite selected character
} }
Port_Function[p->use_parallel].write_fkt (drvthis, "\xDB", 1); // write character Port_Function[p->use_parallel].write_fkt(drvthis, "\xDB", 1); // write character
p->last_custom = p->framebuf[i]; p->last_custom = p->framebuf[i];
} }
else { // all other displays else { // all other displays
Port_Function[p->use_parallel].write_fkt (drvthis, (char*)&p->usr_chr_mapping[(int)p->framebuf[i]], 1); Port_Function[p->use_parallel].write_fkt(drvthis, (char*)&p->usr_chr_mapping[(int)p->framebuf[i]], 1);
} }
} }
else if(p->framebuf[i] > 127 && (p->ISO_8859_1 != 0)) { // ISO_8859_1 translation for 129 ... 255 else if (p->framebuf[i] > 127 && (p->ISO_8859_1 != 0)) { // ISO_8859_1 translation for 129 ... 255
Port_Function[p->use_parallel].write_fkt (drvthis, &p->charmap[p->framebuf[i] - 128], 1); Port_Function[p->use_parallel].write_fkt(drvthis, &p->charmap[p->framebuf[i] - 128], 1);
} }
else { else {
Port_Function[p->use_parallel].write_fkt (drvthis, &p->framebuf[i], 1); Port_Function[p->use_parallel].write_fkt(drvthis, &p->framebuf[i], 1);
} }
last_chr = i; last_chr = i;
@@ -496,7 +497,7 @@ serialVFD_flush (Driver *drvthis)
MODULE_EXPORT void MODULE_EXPORT void
serialVFD_num( Driver * drvthis, int x, int num ) serialVFD_num(Driver * drvthis, int x, int num)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int do_init = 0; int do_init = 0;
@@ -544,7 +545,7 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon)
serialVFD_chr(drvthis, x, y, 127); serialVFD_chr(drvthis, x, y, 127);
break; break;
case ICON_HEART_FILLED: case ICON_HEART_FILLED:
if (p->customchars > 0){ if (p->customchars > 0) {
p->ccmode = CCMODE_STANDARD; p->ccmode = CCMODE_STANDARD;
serialVFD_set_char(drvthis, 0, heart_filled); serialVFD_set_char(drvthis, 0, heart_filled);
serialVFD_chr(drvthis, x, y, 0); serialVFD_chr(drvthis, x, y, 0);
@@ -553,7 +554,7 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon)
serialVFD_icon(drvthis, x, y, ICON_BLOCK_FILLED); serialVFD_icon(drvthis, x, y, ICON_BLOCK_FILLED);
break; break;
case ICON_HEART_OPEN: case ICON_HEART_OPEN:
if (p->customchars > 0){ if (p->customchars > 0) {
p->ccmode = CCMODE_STANDARD; p->ccmode = CCMODE_STANDARD;
serialVFD_set_char(drvthis, 0, heart_open); serialVFD_set_char(drvthis, 0, heart_open);
serialVFD_chr(drvthis, x, y, 0); serialVFD_chr(drvthis, x, y, 0);
@@ -637,7 +638,7 @@ serialVFD_clear (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
serialVFD_string (Driver *drvthis, int x, int y, char string[]) serialVFD_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -660,7 +661,7 @@ serialVFD_close (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
if (p != NULL) { if (p != NULL) {
Port_Function[p->use_parallel].close_fkt (drvthis); Port_Function[p->use_parallel].close_fkt(drvthis);
if (p->framebuf) if (p->framebuf)
free(p->framebuf); free(p->framebuf);
if (p->backingstore) if (p->backingstore)
+2 -2
View File
@@ -54,7 +54,7 @@ MODULE_EXPORT int serialVFD_cellwidth (Driver *drvthis);
MODULE_EXPORT int serialVFD_cellheight (Driver *drvthis); MODULE_EXPORT int serialVFD_cellheight (Driver *drvthis);
MODULE_EXPORT void serialVFD_clear (Driver *drvthis); MODULE_EXPORT void serialVFD_clear (Driver *drvthis);
MODULE_EXPORT void serialVFD_flush (Driver *drvthis); MODULE_EXPORT void serialVFD_flush (Driver *drvthis);
MODULE_EXPORT void serialVFD_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void serialVFD_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void serialVFD_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void serialVFD_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void serialVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void serialVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
@@ -67,7 +67,7 @@ MODULE_EXPORT int serialVFD_get_brightness (Driver *drvthis, int state);
MODULE_EXPORT void serialVFD_set_brightness (Driver *drvthis, int state, int promille); MODULE_EXPORT void serialVFD_set_brightness (Driver *drvthis, int state, int promille);
MODULE_EXPORT void serialVFD_backlight (Driver *drvthis, int on); MODULE_EXPORT void serialVFD_backlight (Driver *drvthis, int on);
MODULE_EXPORT void serialVFD_output (Driver *drvthis, int state); MODULE_EXPORT void serialVFD_output (Driver *drvthis, int state);
MODULE_EXPORT void serialVFD_num (Driver * drvthis, int x, int num); MODULE_EXPORT void serialVFD_num (Driver *drvthis, int x, int num);
MODULE_EXPORT int serialVFD_get_free_chars (Driver *drvthis); MODULE_EXPORT int serialVFD_get_free_chars (Driver *drvthis);
MODULE_EXPORT const char * serialVFD_get_info( Driver *drvthis ); MODULE_EXPORT const char * serialVFD_get_info( Driver *drvthis );
+253 -253
View File
@@ -41,304 +41,304 @@ void serialVFD_load_Futaba (Driver *drvthis);
void serialVFD_load_display_data(Driver *drvthis) void serialVFD_load_display_data(Driver *drvthis)
{ {
PrivateData *p = (PrivateData*) drvthis->private_data; PrivateData *p = (PrivateData*) drvthis->private_data;
switch (p->display_type) switch (p->display_type) {
{
case 0: case 0:
serialVFD_load_NEC_FIPC (drvthis); serialVFD_load_NEC_FIPC(drvthis);
break; break;
case 1: case 1:
serialVFD_load_KD (drvthis); serialVFD_load_KD(drvthis);
break; break;
case 2: case 2:
serialVFD_load_Noritake (drvthis); serialVFD_load_Noritake(drvthis);
break; break;
case 3: case 3:
serialVFD_load_Futaba (drvthis); serialVFD_load_Futaba(drvthis);
break; break;
} }
} }
void void
serialVFD_load_NEC_FIPC (Driver *drvthis) serialVFD_load_NEC_FIPC (Driver *drvthis)
{ //nec_fipc { //nec_fipc
PrivateData *p = (PrivateData*) drvthis->private_data; PrivateData *p = (PrivateData*) drvthis->private_data;
int tmp, w; int tmp, w;
if (p->customchars == -83) if (p->customchars == -83)
p->customchars=1; // number of custom characters the display provides p->customchars = 1; // number of custom characters the display provides
p->vbar_cc_offset=5; // character offset of the bars p->vbar_cc_offset = 5; // character offset of the bars
p->hbar_cc_offset=12; // character offset of the bars p->hbar_cc_offset = 12; // character offset of the bars
p->predefined_hbar=1; // the display has predefined hbar-characters p->predefined_hbar = 1; // the display has predefined hbar-characters
p->predefined_vbar=1; // the display has predefined vbar-characters p->predefined_vbar = 1; // the display has predefined vbar-characters
// hardwarespecific commands: // hardwarespecific commands:
// hw_cmd[Command][data] = {{commandlength , command 1}, // hw_cmd[Command][data] = {{commandlength , command 1},
// ..... // .....
// {commandlength , command N}} // {commandlength , command N}}
const char hw_cmd[10][4]={{1 ,0x04}, // dark const char hw_cmd[10][4] = {{1 ,0x04}, // dark
{1 ,0x03}, {1 ,0x03},
{1 ,0x02}, {1 ,0x02},
{1 ,0x01}, // bright {1 ,0x01}, // bright
{1 ,0x0D}, // pos1 {1 ,0x0D}, // pos1
{1 ,0x1B}, // move cursor {1 ,0x1B}, // move cursor
{1 ,0x0C}, // reset {1 ,0x0C}, // reset
{2 ,0x14, 0x11}, // init {2 ,0x14, 0x11}, // init
{1 ,0x1A}, // set user char {1 ,0x1A}, // set user char
{1 ,0x09}}; // tab {1 ,0x09}}; // tab
for (tmp=0;tmp < (10) ;tmp++) for (tmp = 0; tmp < 10; tmp++)
for (w=0;w < (4) ;w++) for (w = 0; w < 4; w++)
p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; p->hw_cmd[tmp][w] = hw_cmd[tmp][w];
// Translates ISO 8859-1 to display charset. // Translates ISO 8859-1 to display charset.
const unsigned char charmap[] = { const unsigned char charmap[] = {
/* #128 = 0x80 */ /* #128 = 0x80 */
128, 129, 130, 131, 132, 133, 134, 135, 128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159, 152, 153, 154, 155, 156, 157, 158, 159,
/* #160 = 0xA0 */ /* #160 = 0xA0 */
160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9, 160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9,
'"', '?', '?', '?', '?', '-', '?', '?', '"', '?', '?', '?', '?', '-', '?', '?',
0x8B, 0xF3, 0x89, 0x8A, 0x27, 0x98, '?', '.', 0x8B, 0xF3, 0x89, 0x8A, 0x27, 0x98, '?', '.',
',', '?', '?', '?', '?', 0x8C, '?', 0xAA, ',', '?', '?', '?', '?', 0x8C, '?', 0xAA,
/* #192 = 0xC0 */ /* #192 = 0xC0 */
'A', 'A', 'A', 'A', 0xA2, 0xA8, 'A', 'C', 'A', 'A', 'A', 'A', 0xA2, 0xA8, 'A', 'C',
'E', 'E', 'E', 0xB6, 'I', 'I', 'I', 'I', 'E', 'E', 'E', 0xB6, 'I', 'I', 'I', 'I',
'D', 0xA9, 'O', 'O', 'O', 'O', 0xA3, 0x8D, 'D', 0xA9, 'O', 'O', 'O', 'O', 0xA3, 0x8D,
'0', 'U', 'U', 'U', 0xA4, 'Y', 'p', 0x91, '0', 'U', 'U', 'U', 0xA4, 'Y', 'p', 0x91,
/* #224 = 0xE0 */ /* #224 = 0xE0 */
'a', 'a', 'a', 'a', 0xA5, 'a', 'a', 'c', 'a', 'a', 'a', 'a', 0xA5, 'a', 'a', 'c',
'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
'o', 'n', 'o', 'o', 'o', 'o', 0xA6, 0x8E, 'o', 'n', 'o', 'o', 'o', 'o', 0xA6, 0x8E,
'0', 'u', 'u', 'u', 0xA7, 'y', 'p', 'y' '0', 'u', 'u', 'u', 0xA7, 'y', 'p', 'y' };
}; for (tmp = 0; tmp < 128; tmp++)
for (tmp=0;tmp < 128 ;tmp++) p->charmap[tmp] = charmap[tmp];
p->charmap[tmp]=charmap[tmp];
//{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} // {bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...}
const int usr_chr_dot_assignment[57]={7, 1, 2, 3, 4, 5, 0, 0, 0, const int usr_chr_dot_assignment[57] = { 7,
6, 7, 8, 9,10, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0,
11,12,13,14,15, 0, 0, 0, 6, 7, 8, 9,10, 0, 0, 0,
16,17,18,19,20, 0, 0, 0, 11,12,13,14,15, 0, 0, 0,
21,22,23,24,25, 0, 0, 0, 16,17,18,19,20, 0, 0, 0,
26,27,28,29,30, 0, 0, 0, 21,22,23,24,25, 0, 0, 0,
31,32,33,34,35, 0, 0, 0}; 26,27,28,29,30, 0, 0, 0,
for (tmp=0;tmp < 57 ;tmp++) 31,32,33,34,35, 0, 0, 0 };
p->usr_chr_dot_assignment[tmp]=usr_chr_dot_assignment[tmp]; for (tmp = 0; tmp < 57; tmp++)
p->usr_chr_dot_assignment[tmp] = usr_chr_dot_assignment[tmp];
//Where to place the usercharacters (0..30) in the asciicode. // Where to place the usercharacters (0..30) in the asciicode.
//Also used to map standardcharacters in the usercharacterspace(0..30) // Also used to map standardcharacters in the usercharacterspace(0..30)
//(useful for displays with less then 30 usercharacters and predefined bars) // (useful for displays with less then 30 usercharacters and predefined bars)
const unsigned int usr_chr_mapping[31]= const unsigned int usr_chr_mapping[31] =
{0xAF,0,0,0,0,0, 0x5F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0, 0x5F, 0xE1, 0xE3, 0xE4}; {0xAF,0,0,0,0,0, 0x5F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0, 0x5F, 0xE1, 0xE3, 0xE4};
for (tmp=0;tmp < 31 ;tmp++) for (tmp = 0; tmp < 31; tmp++)
p->usr_chr_mapping[tmp]=usr_chr_mapping[tmp]; p->usr_chr_mapping[tmp] = usr_chr_mapping[tmp];
} }
void void
serialVFD_load_KD (Driver *drvthis) serialVFD_load_KD (Driver *drvthis)
{ //KD Rev2.1 { //KD Rev2.1
PrivateData *p = (PrivateData*) drvthis->private_data; PrivateData *p = (PrivateData*) drvthis->private_data;
int tmp, w; int tmp, w;
if (p->customchars == -83) if (p->customchars == -83)
p->customchars=31; // number of custom characters the display provides p->customchars = 31; // number of custom characters the display provides
p->vbar_cc_offset=0; // character offset of the bars p->vbar_cc_offset = 0; // character offset of the bars
p->hbar_cc_offset=0; // character offset of the bars p->hbar_cc_offset = 0; // character offset of the bars
p->predefined_hbar=0; // the display has predefined hbar-characters p->predefined_hbar = 0; // the display has predefined hbar-characters
p->predefined_vbar=0; // the display has predefined vbar-characters p->predefined_vbar = 0; // the display has predefined vbar-characters
// hardwarespecific commands: // hardwarespecific commands:
// hw_cmd[Command][data] = {{commandlength , command 1}, // hw_cmd[Command][data] = {{commandlength , command 1},
// ..... // .....
// {commandlength , command N}} // {commandlength , command N}}
const char hw_cmd[10][4]={{1 ,0x04}, // dark const char hw_cmd[10][4] = {{1 ,0x04}, // dark
{1 ,0x03}, {1 ,0x03},
{1 ,0x02}, {1 ,0x02},
{1 ,0x01}, // bright {1 ,0x01}, // bright
{1 ,0x0D}, // pos1 {1 ,0x0D}, // pos1
{1 ,0x1B}, // move cursor {1 ,0x1B}, // move cursor
{1 ,0x0C}, // reset {1 ,0x0C}, // reset
{2 ,0x14, 0x11}, // init {2 ,0x14, 0x11}, // init
{1 ,0x1A}, // set user char {1 ,0x1A}, // set user char
{1 ,0x09}}; // tab {1 ,0x09}}; // tab
for (tmp=0;tmp < (10) ;tmp++) for (tmp = 0; tmp < 10; tmp++)
for (w=0;w < (4) ;w++) for (w = 0; w < 4; w++)
p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; p->hw_cmd[tmp][w] = hw_cmd[tmp][w];
const unsigned char charmap[] = { const unsigned char charmap[] = {
/* #128 = 0x80 */ /* #128 = 0x80 */
128, 129, 130, 131, 132, 133, 134, 135, 128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159, 152, 153, 154, 155, 156, 157, 158, 159,
/* #160 = 0xA0 */ /* #160 = 0xA0 */
160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9, 160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9,
'"', '?', '?', '?', '?', '-', '?', '?', '"', '?', '?', '?', '?', '-', '?', '?',
0xA9, 0xBA, '?', '?', 0x27, '?', '?', '.', 0xA9, 0xBA, '?', '?', 0x27, '?', '?', '.',
',', '?', '?', '?', '?', '?', '?', '?', ',', '?', '?', '?', '?', '?', '?', '?',
/* #192 = 0xC0 */ /* #192 = 0xC0 */
0xB2, 'A', 'A', 'A', 0xA2, 0xA1, 'A', 'C', 0xB2, 'A', 'A', 'A', 0xA2, 0xA1, 'A', 'C',
'E', 'E', 0xA8, 0xB6, 0xAB, 0xAA, 0xAC, 0xA9, 'E', 'E', 0xA8, 0xB6, 0xAB, 0xAA, 0xAC, 0xA9,
'D', 0xAE, 0xB1, 0xB0, 0xBF, 'O', 0xA3, 'x', 'D', 0xAE, 0xB1, 0xB0, 0xBF, 'O', 0xA3, 'x',
0xAF, 0xB7, 0xB6, 0xB8, 0xA4, 'Y', 'p', 0x91, 0xAF, 0xB7, 0xB6, 0xB8, 0xA4, 'Y', 'p', 0x91,
/* #224 = 0xE0 */ /* #224 = 0xE0 */
0xD2, 0xC2, 0xC4, 'a', 0xA5, 0xC1, 0xC5, 0xC3, 0xD2, 0xC2, 0xC4, 'a', 0xA5, 0xC1, 0xC5, 0xC3,
0xC7, 0xC6, 0xC8, 0xD4, 0xCC, 0xCB, 0xCD, 0xCA, 0xC7, 0xC6, 0xC8, 0xD4, 0xCC, 0xCB, 0xCD, 0xCA,
'o', 0xCF, 0xD1, 0xD0, 0xCE, 'o', 0xA6, 0xBB, 'o', 0xCF, 0xD1, 0xD0, 0xCE, 'o', 0xA6, 0xBB,
0xD0, 0xD7, 0xD6, 0xD8, 0xA7, 'y', 'p', 'y' 0xD0, 0xD7, 0xD6, 0xD8, 0xA7, 'y', 'p', 'y' };
}; for (tmp = 0; tmp < 128; tmp++)
for (tmp=0;tmp < 128 ;tmp++) p->charmap[tmp] = charmap[tmp];
p->charmap[tmp]=charmap[tmp];
// {bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...}
const int usr_chr_dot_assignment[57] = { 7,
1, 2, 3, 4, 5, 0, 0, 0,
6, 7, 8, 9,10, 0, 0, 0,
11,12,13,14,15, 0, 0, 0,
16,17,18,19,20, 0, 0, 0,
21,22,23,24,25, 0, 0, 0,
26,27,28,29,30, 0, 0, 0,
31,32,33,34,35, 0, 0, 0 };
for (tmp = 0; tmp < 57; tmp++)
p->usr_chr_dot_assignment[tmp] = usr_chr_dot_assignment[tmp];
//{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} // Where to place the usercharacters (0..30) in the asciicode.
const int usr_chr_dot_assignment[57]={7, 1, 2, 3, 4, 5, 0, 0, 0, // Also used to map standardcharacters in the usercharacterspace(0..30)
6, 7, 8, 9,10, 0, 0, 0, // (useful for displays with less then 30 usercharacters and predefined bars)
11,12,13,14,15, 0, 0, 0, const unsigned int usr_chr_mapping[31]=
16,17,18,19,20, 0, 0, 0, {0xAF};
21,22,23,24,25, 0, 0, 0, for (tmp = 0; tmp < 31; tmp++)
26,27,28,29,30, 0, 0, 0, p->usr_chr_mapping[tmp] = usr_chr_mapping[tmp];
31,32,33,34,35, 0, 0, 0};
for (tmp=0;tmp < 57 ;tmp++)
p->usr_chr_dot_assignment[tmp]=usr_chr_dot_assignment[tmp];
//Where to place the usercharacters (0..30) in the asciicode.
//Also used to map standardcharacters in the usercharacterspace(0..30)
//(useful for displays with less then 30 usercharacters and predefined bars)
const unsigned int usr_chr_mapping[31]=
{0xAF};
for (tmp=0;tmp < 31 ;tmp++)
p->usr_chr_mapping[tmp]=usr_chr_mapping[tmp];
} }
void void
serialVFD_load_Noritake (Driver *drvthis) serialVFD_load_Noritake (Driver *drvthis)
{ //Noritake { //Noritake
PrivateData *p = (PrivateData*) drvthis->private_data; PrivateData *p = (PrivateData*) drvthis->private_data;
int tmp, w; int tmp, w;
if (p->customchars == -83) if (p->customchars == -83)
p->customchars=16; // number of custom characters the display provides p->customchars = 16; // number of custom characters the display provides
p->vbar_cc_offset=0; // character offset of the bars p->vbar_cc_offset = 0; // character offset of the bars
p->hbar_cc_offset=0; // character offset of the bars p->hbar_cc_offset = 0; // character offset of the bars
p->predefined_hbar=0; // the display has predefined hbar-characters p->predefined_hbar = 0; // the display has predefined hbar-characters
p->predefined_vbar=0; // the display has predefined vbar-characters p->predefined_vbar = 0; // the display has predefined vbar-characters
// hardwarespecific commands: // hardwarespecific commands:
// hw_cmd[Command][data] = {{commandlength , command 1}, // hw_cmd[Command][data] = {{commandlength , command 1},
// ..... // .....
// {commandlength , command N}} // {commandlength , command N}}
const char hw_cmd[10][4]={{3 ,0x1B, 0x4C, 0x00}, // dark const char hw_cmd[10][4] = {{3 ,0x1B, 0x4C, 0x00}, // dark
{3 ,0x1B, 0x4C, 0x50}, {3 ,0x1B, 0x4C, 0x50},
{3 ,0x1B, 0x4C, 0x90}, {3 ,0x1B, 0x4C, 0x90},
{3 ,0x1B, 0x4C, 0xFF}, // bright {3 ,0x1B, 0x4C, 0xFF}, // bright
{1 ,0x0C}, // pos1 {1 ,0x0C}, // pos1
{2 ,0x1B, 0x48}, // move cursor {2 ,0x1B, 0x48}, // move cursor
{2 ,0x1B, 0x49}, // reset {2 ,0x1B, 0x49}, // reset
{2 ,0x14, 0x11}, // init {2 ,0x14, 0x11}, // init
{2 ,0x1B, 0x43}, // set user char {2 ,0x1B, 0x43}, // set user char
{1 ,0x09}}; // tab {1 ,0x09}}; // tab
for (tmp=0;tmp < (10) ;tmp++) for (tmp = 0; tmp < 10; tmp++)
for (w=0;w < (4) ;w++) for (w = 0; w < 4; w++)
p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; p->hw_cmd[tmp][w] = hw_cmd[tmp][w];
// no charmap needed // no charmap needed
for (tmp=128;tmp <= 255 ;tmp++) for (tmp = 128; tmp <= 255; tmp++)
p->charmap[tmp]=tmp; p->charmap[tmp] = tmp;
//{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} // {bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...}
const int usr_chr_dot_assignment[57]={5, 1, 2, 3, 4, 5, 6, 7, 8, const int usr_chr_dot_assignment[57] = { 5,
9,10,11,12,13,14,15,16, 1, 2, 3, 4, 5, 6, 7, 8,
17,18,19,20,21,22,23,24, 9,10,11,12,13,14,15,16,
25,26,27,28,29,30,31,32, 17,18,19,20,21,22,23,24,
33,34,35, 0, 0, 0, 0, 0}; 25,26,27,28,29,30,31,32,
for (tmp=0;tmp < 57 ;tmp++) 33,34,35, 0, 0, 0, 0, 0 };
p->usr_chr_dot_assignment[tmp]=usr_chr_dot_assignment[tmp]; for (tmp = 0; tmp < 57; tmp++)
p->usr_chr_dot_assignment[tmp] = usr_chr_dot_assignment[tmp];
//Where to place the usercharacters (0..30) in the asciicode. // Where to place the usercharacters (0..30) in the asciicode.
//Also used to map standardcharacters in the usercharacterspace(0..30) // Also used to map standardcharacters in the usercharacterspace(0..30)
//(useful for displays with less then 30 usercharacters and predefined bars) // (useful for displays with less then 30 usercharacters and predefined bars)
const unsigned int usr_chr_mapping[31]= const unsigned int usr_chr_mapping[31]=
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\ {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\
0x0F, 0x10, 0x13 , 0x14, 0x1C, 0x1D, 0x1E, 0x1F}; 0x0F, 0x10, 0x13 , 0x14, 0x1C, 0x1D, 0x1E, 0x1F};
for (tmp=0;tmp < 31 ;tmp++) for (tmp = 0; tmp < 31; tmp++)
p->usr_chr_mapping[tmp]=usr_chr_mapping[tmp]; p->usr_chr_mapping[tmp] = usr_chr_mapping[tmp];
} }
void void
serialVFD_load_Futaba (Driver *drvthis) serialVFD_load_Futaba (Driver *drvthis)
{ //Futaba { //Futaba
PrivateData *p = (PrivateData*) drvthis->private_data; PrivateData *p = (PrivateData*) drvthis->private_data;
int tmp, w; int tmp, w;
if (p->customchars == -83) if (p->customchars == -83)
p->customchars=3; // number of custom characters the display provides p->customchars = 3; // number of custom characters the display provides
p->vbar_cc_offset=0; // character offset of the bars p->vbar_cc_offset = 0; // character offset of the bars
p->hbar_cc_offset=0; // character offset of the bars p->hbar_cc_offset = 0; // character offset of the bars
p->predefined_hbar=0; // the display has predefined hbar-characters p->predefined_hbar = 0; // the display has predefined hbar-characters
p->predefined_vbar=0; // the display has predefined vbar-characters p->predefined_vbar = 0; // the display has predefined vbar-characters
// hardwarespecific commands: // hardwarespecific commands:
// hw_cmd[Command][data] = {{commandlength , command 1}, // hw_cmd[Command][data] = {{commandlength , command 1},
// ..... // .....
// {commandlength , command N}} // {commandlength , command N}}
const char hw_cmd[10][4]={{2 ,0x04, 0x20}, // dark const char hw_cmd[10][4] = {{2 ,0x04, 0x20}, // dark
{2 ,0x04, 0x40}, {2 ,0x04, 0x40},
{2 ,0x04, 0x60}, {2 ,0x04, 0x60},
{2 ,0x04, 0xFF}, // bright {2 ,0x04, 0xFF}, // bright
{2 ,0x10, 0x00}, // pos1 {2 ,0x10, 0x00}, // pos1
{1 ,0x10,}, // move cursor {1 ,0x10,}, // move cursor
{1 ,0x1F}, // reset {1 ,0x1F}, // reset
{2 ,0x11,0x14}, // init {2 ,0x11,0x14}, // init
{1 ,0x03}, // set user char {1 ,0x03}, // set user char
{1 ,0x09}}; // tab {1 ,0x09}}; // tab
for (tmp=0;tmp < (10) ;tmp++) for (tmp = 0; tmp < 10; tmp++)
for (w=0;w < (4) ;w++) for (w = 0; w < 4; w++)
p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; p->hw_cmd[tmp][w] = hw_cmd[tmp][w];
// Translates ISO 8859-1 to display charset. // Translates ISO 8859-1 to display charset.
const unsigned char charmap[] = { const unsigned char charmap[] = {
/* #128 = 0x80 */ /* #128 = 0x80 */
128, 129, 130, 131, 132, 133, 134, 135, 128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159, 152, 153, 154, 155, 156, 157, 158, 159,
/* #160 = 0xA0 */ /* #160 = 0xA0 */
160, 0xAD, 0x9B, 0x9C, 0xC8, 0x9D, 0x7C, 0xC0, 160, 0xAD, 0x9B, 0x9C, 0xC8, 0x9D, 0x7C, 0xC0,
'"', '?', 0xA6, 0xAE, 0xAA, '-', '?', '?', '"', '?', 0xA6, 0xAE, 0xAA, '-', '?', '?',
0xEF, 0xCA, 0xC6, 0xC7, 0x27, 0xB8, '?', '.', 0xEF, 0xCA, 0xC6, 0xC7, 0x27, 0xB8, '?', '.',
',', '?', 0xA7, 0xAF, 0xAC, 0xAB, '?', 0xA8, ',', '?', 0xA7, 0xAF, 0xAC, 0xAB, '?', 0xA8,
/* #192 = 0xC0 */ /* #192 = 0xC0 */
0xD0, 'A', 0xD5, 'A', 0x8E, 0x8F, 0x92, 0x80, 0xD0, 'A', 0xD5, 'A', 0x8E, 0x8F, 0x92, 0x80,
0xD1, 0x90, 0xD6, 0xD3, 'I', 'I', 0xD7, 0xD4, 0xD1, 0x90, 0xD6, 0xD3, 'I', 'I', 0xD7, 0xD4,
'D', 0xA5, 'O', 'O', 0xD8, 'O', 0x99, 'x', 'D', 0xA5, 'O', 'O', 0xD8, 'O', 0x99, 'x',
'0', 0xD2, 'U', 0xD9, 0x9A, 'Y', 'p', 0xB1, '0', 0xD2, 'U', 0xD9, 0x9A, 'Y', 'p', 0xB1,
/* #224 = 0xE0 */ /* #224 = 0xE0 */
0x85, 0xA0, 0x83, 'a', 0x84, 0x86, 0x91, 0x87, 0x85, 0xA0, 0x83, 'a', 0x84, 0x86, 0x91, 0x87,
0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B, 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
'o', 0xA4, 0x95, 0xA9, 0x93, 'o', 0x94, '/', 'o', 0xA4, 0x95, 0xA9, 0x93, 'o', 0x94, '/',
'0', 0x97, 0xA3, 0x96, 0x81, 'y', 'p', 0x89 '0', 0x97, 0xA3, 0x96, 0x81, 'y', 'p', 0x89 };
}; for (tmp = 0; tmp < 128; tmp++)
for (tmp=0;tmp < 128 ;tmp++) p->charmap[tmp] = charmap[tmp];
p->charmap[tmp]=charmap[tmp];
// {bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...}
const int usr_chr_dot_assignment[57] = { 5,
8, 7, 6, 5, 4, 3, 2, 1,
16,15,14,13,12,11,10, 9,
24,23,22,21,20,19,18,17,
32,31,30,29,28,27,26,25,
0, 0, 0, 0, 0,35,34,33 };
for (tmp = 0; tmp < 57; tmp++)
p->usr_chr_dot_assignment[tmp] = usr_chr_dot_assignment[tmp];
//{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} // Where to place the usercharacters (0..30) in the asciicode.
const int usr_chr_dot_assignment[57]={5, 8, 7, 6, 5, 4, 3, 2, 1, // Also used to map standardcharacters in the usercharacterspace(0..30)
16,15,14,13,12,11,10, 9, // (useful for displays with less then 30 usercharacters and predefined bars)
24,23,22,21,20,19,18,17, const unsigned int usr_chr_mapping[31] = { 0xCD, 0xCE, 0xCF };
32,31,30,29,28,27,26,25, for (tmp = 0; tmp < 31; tmp++)
0, 0, 0, 0, 0,35,34,33}; p->usr_chr_mapping[tmp] = usr_chr_mapping[tmp];
for (tmp=0;tmp < 57 ;tmp++) }
p->usr_chr_dot_assignment[tmp]=usr_chr_dot_assignment[tmp];
//Where to place the usercharacters (0..30) in the asciicode.
//Also used to map standardcharacters in the usercharacterspace(0..30)
//(useful for displays with less then 30 usercharacters and predefined bars)
const unsigned int usr_chr_mapping[31]=
{0xCD, 0xCE, 0xCF};
for (tmp=0;tmp < 31 ;tmp++)
p->usr_chr_mapping[tmp]=usr_chr_mapping[tmp];
}
+17 -17
View File
@@ -45,7 +45,7 @@ void
serialVFD_write_serial (Driver *drvthis, unsigned char *dat, size_t length) serialVFD_write_serial (Driver *drvthis, unsigned char *dat, size_t length)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
write (p->fd,dat,length); write(p->fd,dat,length);
} }
void void
@@ -55,15 +55,15 @@ serialVFD_write_parallel (Driver *drvthis, unsigned char *dat, size_t length)
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i_para, j_para; int i_para, j_para;
for(i_para = 0; i_para < length; i_para++) { for (i_para = 0; i_para < length; i_para++) {
port_out(p->port, dat[i_para]); port_out(p->port, dat[i_para]);
// port_in(p->port+1); // port_in(p->port+1);
port_out(p->port+2, WR_on); port_out(p->port+2, WR_on);
port_in(p->port+1); port_in(p->port+1);
port_out(p->port+2, WR_off); port_out(p->port+2, WR_off);
port_in(p->port+1); port_in(p->port+1);
for(j_para=0; j_para < MAXBUSY; j_para++) { for (j_para = 0; j_para < MAXBUSY; j_para++) {
if((port_in(p->port+1)) & Busy) if ((port_in(p->port+1)) & Busy)
break; break;
} }
} }
@@ -78,14 +78,14 @@ serialVFD_init_serial (Driver *drvthis)
/* Set up io port correctly, and open it...*/ /* Set up io port correctly, and open it...*/
debug( RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device); debug( RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device);
p->fd = open (p->device, O_RDWR | O_NOCTTY | O_NDELAY); p->fd = open(p->device, O_RDWR | O_NOCTTY | O_NDELAY);
if (p->fd == -1) { if (p->fd == -1) {
report (RPT_ERR, "%s: open() of %s failed (%s)\n", __FUNCTION__, p->device, strerror (errno)); report(RPT_ERR, "%s: open() of %s failed (%s)\n", __FUNCTION__, p->device, strerror(errno));
return -1; return -1;
} }
tcgetattr (p->fd, &portset); tcgetattr(p->fd, &portset);
// We use RAW mode // We use RAW mode
#ifdef HAVE_CFMAKERAW #ifdef HAVE_CFMAKERAW
@@ -102,11 +102,11 @@ serialVFD_init_serial (Driver *drvthis)
#endif #endif
// Set port speed // Set port speed
cfsetospeed (&portset, p->speed); cfsetospeed(&portset, p->speed);
cfsetispeed (&portset, B0); cfsetispeed(&portset, B0);
// Do it... // Do it...
tcsetattr (p->fd, TCSANOW, &portset); tcsetattr(p->fd, TCSANOW, &portset);
return 0; return 0;
} }
@@ -115,14 +115,14 @@ serialVFD_init_parallel (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
#ifdef HAVE_PCSTYLE_LPT_CONTROL #ifdef HAVE_PCSTYLE_LPT_CONTROL
debug( RPT_DEBUG, "%s: Opening parallelport at: 0x%X", __FUNCTION__, p->port); debug(RPT_DEBUG, "%s: Opening parallelport at: 0x%X", __FUNCTION__, p->port);
if(port_access_multiple(p->port,3)) { if (port_access_multiple(p->port,3)) {
report (RPT_ERR, "%s: port_access_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror (errno)); report(RPT_ERR, "%s: port_access_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror(errno));
return -1; return -1;
} }
return 0; return 0;
#else #else
report (RPT_ERR, "%s: LCDproc was compiled without PCstyle LPT support\n", __FUNCTION__); report(RPT_ERR, "%s: LCDproc was compiled without PCstyle LPT support\n", __FUNCTION__);
return -1; return -1;
#endif #endif
} }
@@ -141,9 +141,9 @@ serialVFD_close_parallel (Driver *drvthis)
#ifdef HAVE_PCSTYLE_LPT_CONTROL #ifdef HAVE_PCSTYLE_LPT_CONTROL
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
debug( RPT_DEBUG, "%s: Closing parallelport at: 0x%X", __FUNCTION__, p->port); debug(RPT_DEBUG, "%s: Closing parallelport at: 0x%X", __FUNCTION__, p->port);
if(port_deny_multiple(p->port,3)) { if (port_deny_multiple(p->port,3)) {
report (RPT_ERR, "%s: port_deny_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror (errno)); report(RPT_ERR, "%s: port_deny_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror(errno));
} }
#endif #endif
} }
+1 -1
View File
@@ -513,7 +513,7 @@ stv5730_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (28,11). // upper-left is (1,1), and the lower right should be (28,11).
// //
MODULE_EXPORT void MODULE_EXPORT void
stv5730_string (Driver *drvthis, int x, int y, char string[]) stv5730_string (Driver *drvthis, int x, int y, const char string[])
{ {
//PrivateData *p = drvthis->private_data; //PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -11,7 +11,7 @@ MODULE_EXPORT int stv5730_cellwidth (Driver *drvthis);
MODULE_EXPORT int stv5730_cellheight (Driver *drvthis); MODULE_EXPORT int stv5730_cellheight (Driver *drvthis);
MODULE_EXPORT void stv5730_clear (Driver *drvthis); MODULE_EXPORT void stv5730_clear (Driver *drvthis);
MODULE_EXPORT void stv5730_flush (Driver *drvthis); MODULE_EXPORT void stv5730_flush (Driver *drvthis);
MODULE_EXPORT void stv5730_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void stv5730_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void stv5730_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void stv5730_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void stv5730_old_vbar (Driver *drvthis, int x, int len); MODULE_EXPORT void stv5730_old_vbar (Driver *drvthis, int x, int len);
MODULE_EXPORT void stv5730_old_hbar (Driver *drvthis, int x, int y, int len); MODULE_EXPORT void stv5730_old_hbar (Driver *drvthis, int x, int y, int len);
+9 -8
View File
@@ -441,7 +441,7 @@ svga_cellheight (Driver *drvthis)
* Clear screen * Clear screen
*/ */
MODULE_EXPORT void MODULE_EXPORT void
svga_clear (Driver * drvthis) svga_clear (Driver *drvthis)
{ {
debug(RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis); debug(RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
@@ -465,20 +465,21 @@ svga_flush (Driver *drvthis)
* upper-left is (1,1), and the lower right should be (p->width,p->height). * upper-left is (1,1), and the lower right should be (p->width,p->height).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
svga_string (Driver *drvthis, int x, int y, char string[]) svga_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; char *buffer = strdup(string);
char *ptr;
debug(RPT_DEBUG, "%s(%p, %d, %d, \"%s\")", __FUNCTION__, drvthis, x, y, string); debug(RPT_DEBUG, "%s(%p, %d, %d, \"%s\")", __FUNCTION__, drvthis, x, y, string);
for (i = 0; string[i] != '\0'; i++) { for (ptr = buffer; *ptr != '\0'; ptr++) {
char *c = &string[i];
if ((unsigned char) *c == 255) // TODO: Is this still necessary ? if ((unsigned char) *ptr == 255) // TODO: Is this still necessary ?
*c = '#'; *ptr = '#';
} }
gl_writen(x * p->cellwidth + p->xoffs, y * p->cellheight + p->yoffs, i, string); gl_writen(x * p->cellwidth + p->xoffs, y * p->cellheight + p->yoffs, (ptr - buffer), buffer);
free(buffer);
} }
+1 -1
View File
@@ -34,7 +34,7 @@ MODULE_EXPORT int svga_cellwidth (Driver *drvthis);
MODULE_EXPORT int svga_cellheight (Driver *drvthis); MODULE_EXPORT int svga_cellheight (Driver *drvthis);
MODULE_EXPORT void svga_clear (Driver *drvthis); MODULE_EXPORT void svga_clear (Driver *drvthis);
MODULE_EXPORT void svga_flush (Driver *drvthis); MODULE_EXPORT void svga_flush (Driver *drvthis);
MODULE_EXPORT void svga_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void svga_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void svga_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void svga_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void svga_vbar (Driver *drvthis, int x, int y, int len, int promille, int pattern); MODULE_EXPORT void svga_vbar (Driver *drvthis, int x, int y, int len, int promille, int pattern);
+1 -1
View File
@@ -312,7 +312,7 @@ t6963_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,6). // upper-left is (1,1), and the lower right should be (20,6).
// //
MODULE_EXPORT void MODULE_EXPORT void
t6963_string (Driver *drvthis, int x, int y, char string[]) t6963_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
+1 -1
View File
@@ -118,7 +118,7 @@ MODULE_EXPORT int t6963_width (Driver *drvthis);
MODULE_EXPORT int t6963_height (Driver *drvthis); MODULE_EXPORT int t6963_height (Driver *drvthis);
MODULE_EXPORT void t6963_clear (Driver *drvthis); MODULE_EXPORT void t6963_clear (Driver *drvthis);
MODULE_EXPORT void t6963_flush (Driver *drvthis); MODULE_EXPORT void t6963_flush (Driver *drvthis);
MODULE_EXPORT void t6963_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void t6963_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void t6963_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void t6963_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void t6963_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void t6963_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+1 -1
View File
@@ -185,7 +185,7 @@ text_flush (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
text_string (Driver *drvthis, int x, int y, char string[]) text_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+2 -2
View File
@@ -3,13 +3,13 @@
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int text_init (Driver * drvthis); MODULE_EXPORT int text_init (Driver *drvthis);
MODULE_EXPORT void text_close (Driver *drvthis); MODULE_EXPORT void text_close (Driver *drvthis);
MODULE_EXPORT int text_width (Driver *drvthis); MODULE_EXPORT int text_width (Driver *drvthis);
MODULE_EXPORT int text_height (Driver *drvthis); MODULE_EXPORT int text_height (Driver *drvthis);
MODULE_EXPORT void text_clear (Driver *drvthis); MODULE_EXPORT void text_clear (Driver *drvthis);
MODULE_EXPORT void text_flush (Driver *drvthis); MODULE_EXPORT void text_flush (Driver *drvthis);
MODULE_EXPORT void text_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void text_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void text_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void text_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void text_set_contrast (Driver *drvthis, int promille); MODULE_EXPORT void text_set_contrast (Driver *drvthis, int promille);
MODULE_EXPORT void text_backlight (Driver *drvthis, int on); MODULE_EXPORT void text_backlight (Driver *drvthis, int on);
+12 -12
View File
@@ -67,7 +67,7 @@ static unsigned char tyan_lcdm_read_key(int fd);
* Opens com port and sets baud correctly... * Opens com port and sets baud correctly...
*/ */
MODULE_EXPORT int MODULE_EXPORT int
tyan_lcdm_init (Driver * drvthis, char *args) tyan_lcdm_init (Driver *drvthis, char *args)
{ {
PrivateData *p; PrivateData *p;
struct termios portset; struct termios portset;
@@ -183,7 +183,7 @@ tyan_lcdm_init (Driver * drvthis, char *args)
* Clean-up * Clean-up
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_close (Driver * drvthis) tyan_lcdm_close (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -255,7 +255,7 @@ PrivateData *p = drvthis->private_data;
* Flushes all output to the lcd... * Flushes all output to the lcd...
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_flush (Driver * drvthis) tyan_lcdm_flush (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
@@ -333,7 +333,7 @@ tyan_lcdm_get_key (Driver *drvthis)
* The upper-left is (1,1), and the lower right should be (16,2). * The upper-left is (1,1), and the lower right should be (16,2).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_chr (Driver * drvthis, int x, int y, char c) tyan_lcdm_chr (Driver *drvthis, int x, int y, char c)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -351,7 +351,7 @@ tyan_lcdm_chr (Driver * drvthis, int x, int y, char c)
* Need to find out if we have support for intermediate value. * Need to find out if we have support for intermediate value.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_backlight (Driver * drvthis, int on) tyan_lcdm_backlight (Driver *drvthis, int on)
{ {
} }
@@ -360,7 +360,7 @@ tyan_lcdm_backlight (Driver * drvthis, int on)
* Draws a vertical bar... * Draws a vertical bar...
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_vbar (Driver * drvthis, int x, int y, int len, int promille, int options) tyan_lcdm_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
/* x and y are the start position of the bar. /* x and y are the start position of the bar.
* The bar by default grows in the 'up' direction * The bar by default grows in the 'up' direction
@@ -399,7 +399,7 @@ tyan_lcdm_vbar (Driver * drvthis, int x, int y, int len, int promille, int optio
* Draws a horizontal bar to the right. * Draws a horizontal bar to the right.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_hbar (Driver * drvthis, int x, int y, int len, int promille, int options) tyan_lcdm_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
/* x and y are the start position of the bar. /* x and y are the start position of the bar.
* The bar by default grows in the 'right' direction * The bar by default grows in the 'right' direction
@@ -436,7 +436,7 @@ tyan_lcdm_hbar (Driver * drvthis, int x, int y, int len, int promille, int optio
* Writes a big number. * Writes a big number.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_num (Driver * drvthis, int x, int num) tyan_lcdm_num (Driver *drvthis, int x, int num)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int do_init = 0; int do_init = 0;
@@ -483,7 +483,7 @@ tyan_lcdm_get_free_chars(Driver *drvthis)
* (least significant bit) is the rightmost pixel in each pixel row * (least significant bit) is the rightmost pixel in each pixel row
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_set_char (Driver * drvthis, int n, unsigned char *dat) tyan_lcdm_set_char (Driver *drvthis, int n, unsigned char *dat)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
unsigned char mask = (1 << p->cellwidth) - 1; unsigned char mask = (1 << p->cellwidth) - 1;
@@ -511,7 +511,7 @@ tyan_lcdm_set_char (Driver * drvthis, int n, unsigned char *dat)
* Places an icon on screen * Places an icon on screen
*/ */
MODULE_EXPORT int MODULE_EXPORT int
tyan_lcdm_icon (Driver * drvthis, int x, int y, int icon) tyan_lcdm_icon (Driver *drvthis, int x, int y, int icon)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
static unsigned char heart_open[] = static unsigned char heart_open[] =
@@ -693,7 +693,7 @@ tyan_lcdm_icon (Driver * drvthis, int x, int y, int icon)
* Clears the LCD screen * Clears the LCD screen
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_clear (Driver * drvthis) tyan_lcdm_clear (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -706,7 +706,7 @@ tyan_lcdm_clear (Driver * drvthis)
* upper-left is (1,1), and the lower right should be (16,2). * upper-left is (1,1), and the lower right should be (16,2).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
tyan_lcdm_string (Driver * drvthis, int x, int y, char string[]) tyan_lcdm_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+16 -16
View File
@@ -84,25 +84,25 @@ MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "tyan_lcdm_"; MODULE_EXPORT char *symbol_prefix = "tyan_lcdm_";
/* API: functions for the server core */ /* API: functions for the server core */
MODULE_EXPORT int tyan_lcdm_init (Driver * drvthis, char *device); MODULE_EXPORT int tyan_lcdm_init (Driver *drvthis, char *device);
MODULE_EXPORT void tyan_lcdm_close (Driver * drvthis); MODULE_EXPORT void tyan_lcdm_close (Driver *drvthis);
MODULE_EXPORT int tyan_lcdm_width (Driver * drvthis); MODULE_EXPORT int tyan_lcdm_width (Driver *drvthis);
MODULE_EXPORT int tyan_lcdm_height (Driver * drvthis); MODULE_EXPORT int tyan_lcdm_height (Driver *drvthis);
MODULE_EXPORT int tyan_lcdm_cellwidth (Driver * drvthis); MODULE_EXPORT int tyan_lcdm_cellwidth (Driver *drvthis);
MODULE_EXPORT int tyan_lcdm_cellheight (Driver * drvthis); MODULE_EXPORT int tyan_lcdm_cellheight (Driver *drvthis);
MODULE_EXPORT void tyan_lcdm_clear (Driver * drvthis); MODULE_EXPORT void tyan_lcdm_clear (Driver *drvthis);
MODULE_EXPORT void tyan_lcdm_flush (Driver * drvthis); MODULE_EXPORT void tyan_lcdm_flush (Driver *drvthis);
MODULE_EXPORT void tyan_lcdm_string (Driver * drvthis, int x, int y, char string[]); MODULE_EXPORT void tyan_lcdm_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void tyan_lcdm_chr (Driver * drvthis, int x, int y, char c); MODULE_EXPORT void tyan_lcdm_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void tyan_lcdm_vbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void tyan_lcdm_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void tyan_lcdm_hbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void tyan_lcdm_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void tyan_lcdm_num (Driver * drvthis, int x, int num); MODULE_EXPORT void tyan_lcdm_num (Driver *drvthis, int x, int num);
MODULE_EXPORT int tyan_lcdm_icon(Driver * drvthis, int x, int y, int icon); MODULE_EXPORT int tyan_lcdm_icon(Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT int tyan_lcdm_get_free_chars (Driver *drvthis); MODULE_EXPORT int tyan_lcdm_get_free_chars (Driver *drvthis);
MODULE_EXPORT void tyan_lcdm_set_char (Driver * drvthis, int n, unsigned char *dat); MODULE_EXPORT void tyan_lcdm_set_char (Driver *drvthis, int n, unsigned char *dat);
MODULE_EXPORT void tyan_lcdm_backlight (Driver * drvthis, int on); MODULE_EXPORT void tyan_lcdm_backlight (Driver *drvthis, int on);
#endif #endif
+5 -5
View File
@@ -456,7 +456,7 @@ ula200_ftdi_rawdata(Driver *drvthis, unsigned char flags, unsigned char ch)
// Displays a string // Displays a string
// //
static int static int
ula200_ftdi_string(Driver *drvthis, unsigned char *string, int len) ula200_ftdi_string(Driver *drvthis, const unsigned char *string, int len)
{ {
//PrivateData *p = (PrivateData *) drvthis->private_data; //PrivateData *p = (PrivateData *) drvthis->private_data;
unsigned char buffer[128]; unsigned char buffer[128];
@@ -626,7 +626,7 @@ ula200_init(Driver *drvthis)
EmptyKeyRing(&p->keyring); EmptyKeyRing(&p->keyring);
// Get and parse size // Get and parse size
s = drvthis->config_get_string( drvthis->name, "size", 0, "20x4"); s = drvthis->config_get_string(drvthis->name, "size", 0, "20x4");
if ((sscanf(s, "%dx%d", &(p->width), &(p->height)) != 2) if ((sscanf(s, "%dx%d", &(p->width), &(p->height)) != 2)
|| (p->width <= 0) || (p->width > LCD_MAX_WIDTH) || (p->width <= 0) || (p->width > LCD_MAX_WIDTH)
|| (p->height <= 0) || (p->height > LCD_MAX_HEIGHT)) { || (p->height <= 0) || (p->height > LCD_MAX_HEIGHT)) {
@@ -798,7 +798,7 @@ ula200_chr (Driver *drvthis, int x, int y, char ch)
// Place a string in the framebuffer // Place a string in the framebuffer
// //
MODULE_EXPORT void MODULE_EXPORT void
ula200_string (Driver *drvthis, int x, int y, char *s) ula200_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
int i; int i;
@@ -806,11 +806,11 @@ ula200_string (Driver *drvthis, int x, int y, char *s)
x --; // Convert 1-based coords to 0-based x --; // Convert 1-based coords to 0-based
y --; y --;
for (i = 0; s[i]; i++) { for (i = 0; string[i] != '\0'; i++) {
// Check for buffer overflows... // Check for buffer overflows...
if ((y * p->width) + x + i > (p->width * p->height)) if ((y * p->width) + x + i > (p->width * p->height))
break; break;
p->framebuf[(y*p->width) + x + i] = s[i]; p->framebuf[(y*p->width) + x + i] = string[i];
} }
} }
+10 -10
View File
@@ -32,15 +32,15 @@ MODULE_EXPORT int ula200_init(Driver *drvthis);
MODULE_EXPORT void ula200_close (Driver *drvthis); MODULE_EXPORT void ula200_close (Driver *drvthis);
MODULE_EXPORT int ula200_width (Driver *drvthis); MODULE_EXPORT int ula200_width (Driver *drvthis);
MODULE_EXPORT int ula200_height (Driver *drvthis); MODULE_EXPORT int ula200_height (Driver *drvthis);
MODULE_EXPORT void ula200_clear (Driver * drvthis); MODULE_EXPORT void ula200_clear (Driver *drvthis);
MODULE_EXPORT void ula200_string (Driver * drvthis, int x, int y, char string[]); MODULE_EXPORT void ula200_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void ula200_chr (Driver * drvthis, int x, int y, char c); MODULE_EXPORT void ula200_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void ula200_set_char (Driver * drvthis, int n, char *dat); MODULE_EXPORT void ula200_set_char (Driver *drvthis, int n, char *dat);
MODULE_EXPORT void ula200_backlight (Driver * drvthis, int on); MODULE_EXPORT void ula200_backlight (Driver *drvthis, int on);
MODULE_EXPORT void ula200_flush (Driver * drvthis); MODULE_EXPORT void ula200_flush (Driver *drvthis);
MODULE_EXPORT void ula200_vbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void ula200_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void ula200_hbar (Driver * drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void ula200_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void ula200_num (Driver * drvthis, int x, int num); MODULE_EXPORT void ula200_num (Driver *drvthis, int x, int num);
MODULE_EXPORT int ula200_icon(Driver * drvthis, int x, int y, int icon); MODULE_EXPORT int ula200_icon(Driver *drvthis, int x, int y, int icon);
#endif /* ULA200_H */ #endif /* ULA200_H */
+1 -1
View File
@@ -261,7 +261,7 @@ sli_clear (Driver *drvthis)
// upper-left is (1,1), and the lower right should be (20,4). // upper-left is (1,1), and the lower right should be (20,4).
// //
MODULE_EXPORT void MODULE_EXPORT void
sli_string (Driver *drvthis, int x, int y, char string[]) sli_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -17,7 +17,7 @@ MODULE_EXPORT int sli_cellwidth (Driver *drvthis);
MODULE_EXPORT int sli_cellheight (Driver *drvthis); MODULE_EXPORT int sli_cellheight (Driver *drvthis);
MODULE_EXPORT void sli_clear (Driver *drvthis); MODULE_EXPORT void sli_clear (Driver *drvthis);
MODULE_EXPORT void sli_flush (Driver *drvthis); MODULE_EXPORT void sli_flush (Driver *drvthis);
MODULE_EXPORT void sli_string (Driver *drvthis, int x, int y, char *string); MODULE_EXPORT void sli_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void sli_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void sli_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void sli_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT void sli_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+2 -2
View File
@@ -228,7 +228,7 @@ xosdlib_drv_height (Driver *drvthis)
* Clear screen * Clear screen
*/ */
MODULE_EXPORT void MODULE_EXPORT void
xosdlib_drv_clear (Driver * drvthis) xosdlib_drv_clear (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
@@ -265,7 +265,7 @@ xosdlib_drv_flush (Driver *drvthis)
* upper-left is (1,1), and the lower right should be (p->width,p->height). * upper-left is (1,1), and the lower right should be (p->width,p->height).
*/ */
MODULE_EXPORT void MODULE_EXPORT void
xosdlib_drv_string (Driver *drvthis, int x, int y, char string[]) xosdlib_drv_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
+1 -1
View File
@@ -40,7 +40,7 @@ MODULE_EXPORT int xosdlib_drv_width (Driver *drvthis);
MODULE_EXPORT int xosdlib_drv_height (Driver *drvthis); MODULE_EXPORT int xosdlib_drv_height (Driver *drvthis);
MODULE_EXPORT void xosdlib_drv_clear (Driver *drvthis); MODULE_EXPORT void xosdlib_drv_clear (Driver *drvthis);
MODULE_EXPORT void xosdlib_drv_flush (Driver *drvthis); MODULE_EXPORT void xosdlib_drv_flush (Driver *drvthis);
MODULE_EXPORT void xosdlib_drv_string (Driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void xosdlib_drv_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void xosdlib_drv_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void xosdlib_drv_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void xosdlib_drv_vbar (Driver *drvthis, int x, int y, int len, int promille, int pattern); MODULE_EXPORT void xosdlib_drv_vbar (Driver *drvthis, int x, int y, int len, int promille, int pattern);
+87 -87
View File
@@ -32,31 +32,31 @@
#include "render.h" /* For server_msg* */ #include "render.h" /* For server_msg* */
LinkedList * keylist; LinkedList *keylist;
char * toggle_rotate_key; char *toggle_rotate_key;
char * prev_screen_key; char *prev_screen_key;
char * next_screen_key; char *next_screen_key;
char * scroll_up_key; char *scroll_up_key;
char * scroll_down_key; char *scroll_down_key;
/* Local functions */ /* Local functions */
int server_input (int key); int server_input(int key);
void input_send_to_client (Client * c, const char * key); void input_send_to_client(Client *c, const char *key);
void input_internal_key (const char * key); void input_internal_key(const char *key);
int input_init() int input_init(void)
{ {
debug (RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
keylist = LL_new(); keylist = LL_new();
/* Get rotate/scroll keys from config file */ /* Get rotate/scroll keys from config file */
toggle_rotate_key = strdup (config_get_string ("server", "ToggleRotateKey", 0, "Enter")); toggle_rotate_key = strdup(config_get_string("server", "ToggleRotateKey", 0, "Enter"));
prev_screen_key = strdup (config_get_string ("server", "PrevScreenKey", 0, "Left")); prev_screen_key = strdup(config_get_string("server", "PrevScreenKey", 0, "Left"));
next_screen_key = strdup (config_get_string ("server", "NextScreenKey", 0, "Right")); next_screen_key = strdup(config_get_string("server", "NextScreenKey", 0, "Right"));
scroll_up_key = strdup (config_get_string ("server", "ScrollUpKey", 0, "Up")); scroll_up_key = strdup(config_get_string("server", "ScrollUpKey", 0, "Up"));
scroll_down_key = strdup (config_get_string ("server", "ScrollDownKey", 0, "Down")); scroll_down_key = strdup(config_get_string("server", "ScrollDownKey", 0, "Down"));
return 0; return 0;
} }
@@ -69,75 +69,75 @@ int input_shutdown()
return -1; return -1;
} }
free (keylist); free(keylist);
free (toggle_rotate_key); free(toggle_rotate_key);
free (prev_screen_key); free(prev_screen_key);
free (next_screen_key); free(next_screen_key);
free (scroll_up_key); free(scroll_up_key);
free (scroll_down_key); free(scroll_down_key);
return 0; return 0;
} }
int int
handle_input () handle_input(void)
{ {
const char * key; const char *key;
Screen * current_screen; Screen *current_screen;
Client * current_client; Client *current_client;
Client * target; Client *target;
KeyReservation * kr; KeyReservation *kr;
debug (RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
current_screen = screenlist_current(); current_screen = screenlist_current();
if( current_screen ) if (current_screen)
current_client = current_screen->client; current_client = current_screen->client;
else else
current_client = NULL; current_client = NULL;
/* Handle all keypresses */ /* Handle all keypresses */
while ((key = drivers_get_key ()) != NULL ) { while ((key = drivers_get_key()) != NULL) {
/* Find what client wants the key */ /* Find what client wants the key */
kr = input_find_key (key, current_client); kr = input_find_key(key, current_client);
if (kr) { if (kr) {
/* A hit ! */ /* A hit ! */
report (RPT_DEBUG, "%s: reserved key: \"%.40s\"", __FUNCTION__, key ); report(RPT_DEBUG, "%s: reserved key: \"%.40s\"", __FUNCTION__, key);
target = kr->client; target = kr->client;
} else { } else {
report (RPT_DEBUG, "%s: left over key: \"%.40s\"", __FUNCTION__, key ); report(RPT_DEBUG, "%s: left over key: \"%.40s\"", __FUNCTION__, key);
/*target = current_client;*/ /*target = current_client;*/
target = NULL; /* left-over keys are always for internal client */ target = NULL; /* left-over keys are always for internal client */
} }
if (target == NULL) { if (target == NULL) {
report (RPT_DEBUG, "%s: key is for internal client", __FUNCTION__ ); report(RPT_DEBUG, "%s: key is for internal client", __FUNCTION__);
input_internal_key (key); input_internal_key(key);
} else { } else {
/* It's an external client */ /* It's an external client */
report (RPT_DEBUG, "%s: key is for external client on socket %d", __FUNCTION__, target->sock ); report(RPT_DEBUG, "%s: key is for external client on socket %d", __FUNCTION__, target->sock);
input_send_to_client (target, key); input_send_to_client(target, key);
} }
} }
return 0; return 0;
} }
void input_send_to_client (Client * c, const char * key) void input_send_to_client(Client *c, const char *key)
{ {
char * s; char *s;
size_t size = strlen(key) + sizeof("key %s\n"); // this is large enough size_t size = strlen(key) + sizeof("key %s\n"); // this is large enough
debug (RPT_DEBUG, "%s( client=[%d], key=\"%.40s\" )", __FUNCTION__, c->sock, key); debug(RPT_DEBUG, "%s(client=[%d], key=\"%.40s\")", __FUNCTION__, c->sock, key);
/* Allocate just as much as we need */ /* Allocate just as much as we need */
s = calloc (1, size); s = calloc(1, size);
if (s != NULL) { if (s != NULL) {
snprintf(s, size, "key %s\n", key); snprintf(s, size, "key %s\n", key);
sock_send_string(c->sock, s); sock_send_string(c->sock, s);
free (s); free(s);
} }
else else
report(RPT_ERR, "%s: malloc failure", __FUNCTION__); report(RPT_ERR, "%s: malloc failure", __FUNCTION__);
@@ -145,47 +145,47 @@ void input_send_to_client (Client * c, const char * key)
void void
input_internal_key (const char * key) input_internal_key(const char *key)
{ {
if( is_menu_key(key) || screenlist_current() == menuscreen ) { if (is_menu_key(key) || screenlist_current() == menuscreen) {
menuscreen_key_handler(key); menuscreen_key_handler(key);
} }
else { else {
/* Keys are for scrolling or rotating */ /* Keys are for scrolling or rotating */
if( strcmp(key,toggle_rotate_key) == 0 ) { if (strcmp(key,toggle_rotate_key) == 0) {
autorotate = !autorotate; autorotate = !autorotate;
if( autorotate ) { if (autorotate) {
server_msg( "Rotate", 4 ); server_msg("Rotate", 4);
} else { } else {
server_msg( "Hold", 4 ); server_msg("Hold", 4);
} }
} }
else if( strcmp(key,prev_screen_key) == 0 ) { else if (strcmp(key,prev_screen_key) == 0) {
screenlist_goto_prev (); screenlist_goto_prev();
server_msg( "Prev", 4 ); server_msg("Prev", 4);
} }
else if( strcmp(key,next_screen_key) == 0 ) { else if (strcmp(key,next_screen_key) == 0) {
screenlist_goto_next (); screenlist_goto_next();
server_msg( "Next", 4 ); server_msg("Next", 4);
} }
else if( strcmp(key,scroll_up_key) == 0 ) { else if (strcmp(key,scroll_up_key) == 0) {
} }
else if( strcmp(key,scroll_down_key) == 0 ) { else if (strcmp(key,scroll_down_key) == 0) {
} }
} }
} }
int input_reserve_key (const char * key, bool exclusive, Client * client) int input_reserve_key(const char *key, bool exclusive, Client *client)
{ {
KeyReservation * kr; KeyReservation *kr;
debug (RPT_DEBUG, "%s( key=\"%.40s\", exclusive=%d, client=[%d] )", __FUNCTION__, key, exclusive, (client?client->sock:-1)); debug(RPT_DEBUG, "%s(key=\"%.40s\", exclusive=%d, client=[%d])", __FUNCTION__, key, exclusive, (client?client->sock:-1));
/* Find out if this key is already reserved in a way that interferes /* Find out if this key is already reserved in a way that interferes
* with the new reservation. * with the new reservation.
*/ */
for (kr=LL_GetFirst(keylist); kr; kr=LL_GetNext(keylist)) { for (kr = LL_GetFirst(keylist); kr; kr = LL_GetNext(keylist)) {
if (strcmp (kr->key, key) == 0) { if (strcmp(kr->key, key) == 0) {
if (kr->exclusive || exclusive) { if (kr->exclusive || exclusive) {
/* Sorry ! */ /* Sorry ! */
return -1; return -1;
@@ -194,63 +194,63 @@ int input_reserve_key (const char * key, bool exclusive, Client * client)
} }
/* We can now safely add it ! */ /* We can now safely add it ! */
kr = malloc (sizeof(KeyReservation)); kr = malloc(sizeof(KeyReservation));
kr->key = strdup (key); kr->key = strdup(key);
kr->exclusive = exclusive; kr->exclusive = exclusive;
kr->client = client; kr->client = client;
LL_Push(keylist, kr); LL_Push(keylist, kr);
report (RPT_INFO, "Key \"%.40s\" is now reserved in %s mode by client [%d]", key, (exclusive?"exclusive":"shared"), (client?client->sock:-1)); report(RPT_INFO, "Key \"%.40s\" is now reserved in %s mode by client [%d]", key, (exclusive?"exclusive":"shared"), (client?client->sock:-1));
return 0; return 0;
} }
void input_release_key (const char * key, Client * client) void input_release_key(const char *key, Client *client)
{ {
KeyReservation * kr; KeyReservation *kr;
debug (RPT_DEBUG, "%s( key=\"%.40s\", client=[%d] )", __FUNCTION__, key, (client?client->sock:-1)); debug(RPT_DEBUG, "%s(key=\"%.40s\", client=[%d])", __FUNCTION__, key, (client?client->sock:-1));
for (kr=LL_GetFirst(keylist); kr; kr=LL_GetNext(keylist)) { for (kr = LL_GetFirst(keylist); kr; kr = LL_GetNext(keylist)) {
if (kr->client == client if (kr->client == client
&& strcmp (kr->key, key) == 0) { && strcmp(kr->key, key) == 0) {
free (kr->key); free(kr->key);
free (kr); free(kr);
LL_DeleteNode (keylist); LL_DeleteNode(keylist);
report (RPT_INFO, "Key \"%.40s\" was reserved in %s mode by client [%d] and is now released", key, (kr->exclusive?"exclusive":"shared"), (client?client->sock:-1)); report(RPT_INFO, "Key \"%.40s\" was reserved in %s mode by client [%d] and is now released", key, (kr->exclusive?"exclusive":"shared"), (client?client->sock:-1));
return; return;
} }
} }
} }
void input_release_client_keys (Client * client) void input_release_client_keys(Client *client)
{ {
KeyReservation * kr; KeyReservation *kr;
debug (RPT_DEBUG, "%s( client=[%d] )", __FUNCTION__, (client?client->sock:-1)); debug(RPT_DEBUG, "%s(client=[%d])", __FUNCTION__, (client?client->sock:-1));
kr=LL_GetFirst(keylist); kr=LL_GetFirst(keylist);
while (kr) { while (kr) {
if (kr->client == client) { if (kr->client == client) {
report (RPT_INFO, "Key \"%.40s\" was reserved in %s mode by client [%d] and is now released", kr->key, (kr->exclusive?"exclusive":"shared"), (client?client->sock:-1)); report(RPT_INFO, "Key \"%.40s\" was reserved in %s mode by client [%d] and is now released", kr->key, (kr->exclusive?"exclusive":"shared"), (client?client->sock:-1));
free (kr->key); free(kr->key);
free (kr); free(kr);
LL_DeleteNode (keylist); LL_DeleteNode(keylist);
kr = LL_Get (keylist); kr = LL_Get(keylist);
} else { } else {
kr = LL_GetNext(keylist); kr = LL_GetNext(keylist);
} }
} }
} }
KeyReservation * input_find_key (const char * key, Client * client) KeyReservation *input_find_key(const char *key, Client *client)
{ {
KeyReservation * kr; KeyReservation *kr;
debug (RPT_DEBUG, "%s( key=\"%.40s\", client=[%d] )", __FUNCTION__, key, (client?client->sock:-1)); debug(RPT_DEBUG, "%s(key=\"%.40s\", client=[%d])", __FUNCTION__, key, (client?client->sock:-1));
for (kr=LL_GetFirst(keylist); kr; kr=LL_GetNext(keylist)) { for (kr = LL_GetFirst(keylist); kr; kr = LL_GetNext(keylist)) {
if (strcmp (kr->key, key) == 0) { if (strcmp(kr->key, key) == 0) {
if (kr->exclusive || client==kr->client) { if (kr->exclusive || client==kr->client) {
return kr; return kr;
} }
+9 -9
View File
@@ -16,7 +16,7 @@
#include <stdlib.h> #include <stdlib.h>
/* Accepts and uses keypad input while displaying screens... */ /* Accepts and uses keypad input while displaying screens... */
int handle_input (); int handle_input(void);
#ifndef bool #ifndef bool
# define bool short # define bool short
@@ -25,29 +25,29 @@ int handle_input ();
#endif #endif
typedef struct KeyReservation { typedef struct KeyReservation {
char * key; char *key;
bool exclusive; bool exclusive;
Client * client; /* NULL for internal clients */ Client *client; /* NULL for internal clients */
} KeyReservation; } KeyReservation;
int input_init(); int input_init(void);
/* Init the input handling system */ /* Init the input handling system */
int input_shutdown(); int input_shutdown(void);
/* Shut it down */ /* Shut it down */
int input_reserve_key (const char * key, bool exclusive, Client * client); int input_reserve_key(const char *key, bool exclusive, Client *client);
/* Reserves a key for a client */ /* Reserves a key for a client */
/* Return -1 if reservation of key is not possible */ /* Return -1 if reservation of key is not possible */
void input_release_key (const char * key, Client * client); void input_release_key(const char *key, Client *client);
/* Releases a key reservation */ /* Releases a key reservation */
void input_release_client_keys (Client * client); void input_release_client_keys(Client *client);
/* Releases all key reservations for a given client */ /* Releases all key reservations for a given client */
KeyReservation * input_find_key (const char * key, Client * client); KeyReservation *input_find_key(const char *key, Client *client);
/* Finds if a key reservation causes a 'hit'. /* Finds if a key reservation causes a 'hit'.
* If the key was reserved exclusively, the client will be ignored. * If the key was reserved exclusively, the client will be ignored.
* If the key was reserved shared, the client must match. * If the key was reserved shared, the client must match.
+162 -162
View File
@@ -162,8 +162,8 @@ static int interpret_boolean_arg(char *s);
static void output_help_screen(void); static void output_help_screen(void);
static void output_GPL_notice(void); static void output_GPL_notice(void);
#define CHAIN(e,f) { if( e>=0 ) { e=(f); }} #define CHAIN(e,f) { if (e>=0) { e=(f); }}
#define CHAIN_END(e,msg) { if( e<0 ) { report( RPT_CRIT,(msg)); exit(e); }} #define CHAIN_END(e,msg) { if (e<0) { report(RPT_CRIT,(msg)); exit(e); }}
int int
@@ -196,20 +196,20 @@ main(int argc, char **argv)
*/ */
/* Report that server is starting (report will be delayed) */ /* Report that server is starting (report will be delayed) */
report(RPT_NOTICE, "LCDd version %s starting", version ); report(RPT_NOTICE, "LCDd version %s starting", version);
report(RPT_INFO, "Built on %s, protocol version %s, API version %s", report(RPT_INFO, "Built on %s, protocol version %s, API version %s",
build_date, protocol_version, api_version ); build_date, protocol_version, api_version);
clear_settings(); clear_settings();
/* Read command line*/ /* Read command line*/
CHAIN( e, process_command_line(argc, argv) ); CHAIN(e, process_command_line(argc, argv));
/* Read config file /* Read config file
* If config file was not given on command line use default */ * If config file was not given on command line use default */
if (strcmp(configfile, UNSET_STR) == 0) if (strcmp(configfile, UNSET_STR) == 0)
strncpy(configfile, DEFAULT_CONFIGFILE, sizeof(configfile)); strncpy(configfile, DEFAULT_CONFIGFILE, sizeof(configfile));
CHAIN( e, process_configfile(configfile) ); CHAIN(e, process_configfile(configfile));
/* Set default values*/ /* Set default values*/
set_default_settings(); set_default_settings();
@@ -218,7 +218,7 @@ main(int argc, char **argv)
set_reporting("LCDd", report_level, report_dest); set_reporting("LCDd", report_level, report_dest);
report(RPT_INFO, "Set report level to %d, output to %s", report_level, report(RPT_INFO, "Set report level to %d, output to %s", report_level,
((report_dest == RPT_DEST_SYSLOG) ? "syslog" : "stderr")); ((report_dest == RPT_DEST_SYSLOG) ? "syslog" : "stderr"));
CHAIN_END( e, "Critical error while processing settings, abort." ); CHAIN_END(e, "Critical error while processing settings, abort.");
/* Now, go into daemon mode (if we should)... /* Now, go into daemon mode (if we should)...
* We wait for the child to report it is running OK. This mechanism * We wait for the child to report it is running OK. This mechanism
@@ -226,26 +226,26 @@ main(int argc, char **argv)
* child to loose the (LPT) port access. */ * child to loose the (LPT) port access. */
if (!foreground_mode) { if (!foreground_mode) {
report(RPT_INFO, "Server forking to background"); report(RPT_INFO, "Server forking to background");
CHAIN( e, parent_pid = daemonize() ); CHAIN(e, parent_pid = daemonize());
} else { } else {
output_GPL_notice(); output_GPL_notice();
report(RPT_INFO, "Server running in foreground"); report(RPT_INFO, "Server running in foreground");
} }
install_signal_handlers (!foreground_mode); install_signal_handlers(!foreground_mode);
/* Only catch SIGHUP if not in foreground mode */ /* Only catch SIGHUP if not in foreground mode */
/* Startup the subparts of the server */ /* Startup the subparts of the server */
CHAIN( e, sock_init(bind_addr, bind_port) ); CHAIN(e, sock_init(bind_addr, bind_port));
CHAIN( e, screenlist_init() ); CHAIN(e, screenlist_init());
CHAIN( e, init_drivers() ); CHAIN(e, init_drivers());
CHAIN( e, clients_init() ); CHAIN(e, clients_init());
CHAIN( e, input_init() ); CHAIN(e, input_init());
CHAIN( e, menuscreens_init() ); CHAIN(e, menuscreens_init());
CHAIN( e, server_screen_init() ); CHAIN(e, server_screen_init());
CHAIN_END( e, "Critical error while initializing, abort." ); CHAIN_END(e, "Critical error while initializing, abort.");
if (!foreground_mode) { if (!foreground_mode) {
/* Tell to parent that startup went OK. */ /* Tell to parent that startup went OK. */
wave_to_parent (parent_pid); wave_to_parent(parent_pid);
} }
drop_privs(user); /* This can't be done before, because sending a drop_privs(user); /* This can't be done before, because sending a
signal to a process of a different user will fail */ signal to a process of a different user will fail */
@@ -262,12 +262,12 @@ clear_settings(void)
{ {
int i; int i;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
bind_port = UNSET_INT; bind_port = UNSET_INT;
strncpy( bind_addr, UNSET_STR, sizeof(bind_addr) ); strncpy(bind_addr, UNSET_STR, sizeof(bind_addr));
strncpy( configfile, UNSET_STR, sizeof(configfile) ); strncpy(configfile, UNSET_STR, sizeof(configfile));
strncpy( user, UNSET_STR, sizeof(user) ); strncpy(user, UNSET_STR, sizeof(user));
foreground_mode = UNSET_INT; foreground_mode = UNSET_INT;
rotate_server_screen = UNSET_INT; rotate_server_screen = UNSET_INT;
backlight = UNSET_INT; backlight = UNSET_INT;
@@ -276,8 +276,8 @@ clear_settings(void)
report_dest = UNSET_INT; report_dest = UNSET_INT;
report_level = UNSET_INT; report_level = UNSET_INT;
for( i=0; i < num_drivers; i++ ) { for (i = 0; i < num_drivers; i++) {
free( drivernames[i] ); free(drivernames[i]);
drivernames[i] = NULL; drivernames[i] = NULL;
} }
num_drivers = 0; num_drivers = 0;
@@ -291,14 +291,14 @@ process_command_line(int argc, char **argv)
int c, b; int c, b;
int e = 0, help = 0; int e = 0, help = 0;
debug( RPT_DEBUG, "%s( argc=%d, argv=...)", __FUNCTION__, argc ); debug(RPT_DEBUG, "%s(argc=%d, argv=...)", __FUNCTION__, argc);
/* Reset getopt */ /* Reset getopt */
opterr = 0; /* Prevent some messages to stderr */ opterr = 0; /* Prevent some messages to stderr */
/* Analyze options here.. (please try to keep list of options the /* Analyze options here.. (please try to keep list of options the
* same everywhere) */ * same everywhere) */
while ((c = getopt(argc, argv, "hc:d:fa:p:u:w:s:r:i:" )) > 0) { while ((c = getopt(argc, argv, "hc:d:fa:p:u:w:s:r:i:")) > 0) {
switch(c) { switch(c) {
case 'h': case 'h':
help = 1; /* Continue to process the other help = 1; /* Continue to process the other
@@ -320,7 +320,7 @@ process_command_line(int argc, char **argv)
e = -1; e = -1;
} }
} else { } else {
report( RPT_ERR, "Too many drivers!" ); report(RPT_ERR, "Too many drivers!");
e = -1; e = -1;
} }
break; break;
@@ -340,15 +340,15 @@ process_command_line(int argc, char **argv)
break; break;
case 'w': case 'w':
default_duration = (int) (atof(optarg) * 1e6 / TIME_UNIT); default_duration = (int) (atof(optarg) * 1e6 / TIME_UNIT);
if ( default_duration * TIME_UNIT < 2e6 ) { if (default_duration * TIME_UNIT < 2e6) {
report( RPT_ERR, "Waittime should be at least 2 (seconds), not %.8s", optarg ); report(RPT_ERR, "Waittime should be at least 2 (seconds), not %.8s", optarg);
e = -1; e = -1;
} }
break; break;
case 's': case 's':
b = interpret_boolean_arg( optarg ); b = interpret_boolean_arg(optarg);
if( b == -1 ) { if (b == -1) {
report( RPT_ERR, "Not a boolean value: '%s'", optarg ); report(RPT_ERR, "Not a boolean value: '%s'", optarg);
e = -1; e = -1;
} else { } else {
report_dest = (b) ? RPT_DEST_SYSLOG : RPT_DEST_STDERR; report_dest = (b) ? RPT_DEST_SYSLOG : RPT_DEST_STDERR;
@@ -358,9 +358,9 @@ process_command_line(int argc, char **argv)
report_level = atoi(optarg); report_level = atoi(optarg);
break; break;
case 'i': case 'i':
b = interpret_boolean_arg( optarg ); b = interpret_boolean_arg(optarg);
if( b == -1 ) { if (b == -1) {
report( RPT_ERR, "Not a boolean value: '%s'", optarg ); report(RPT_ERR, "Not a boolean value: '%s'", optarg);
e = -1; e = -1;
} else { } else {
rotate_server_screen = b; rotate_server_screen = b;
@@ -369,18 +369,18 @@ process_command_line(int argc, char **argv)
case '?': case '?':
/* For some reason getopt also returns an '?' /* For some reason getopt also returns an '?'
* when an option argument is mission... */ * when an option argument is mission... */
report( RPT_ERR, "Unknown option: '%c'", optopt ); report(RPT_ERR, "Unknown option: '%c'", optopt);
e = -1; e = -1;
break; break;
case ':': case ':':
report( RPT_ERR, "Missing option argument!" ); report(RPT_ERR, "Missing option argument!");
e = -1; e = -1;
break; break;
} }
} }
if (optind < argc) { if (optind < argc) {
report( RPT_ERR, "Non-option arguments on the command line !"); report(RPT_ERR, "Non-option arguments on the command line !");
e = -1; e = -1;
} }
if (help) { if (help) {
@@ -398,58 +398,58 @@ process_configfile(char *configfile)
const char *s; const char *s;
/*char buf[64];*/ /*char buf[64];*/
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
/* Read server settings*/ /* Read server settings*/
if( config_read_file( configfile ) != 0 ) { if (config_read_file(configfile) != 0) {
report( RPT_CRIT, "Could not read config file: %s", configfile ); report(RPT_CRIT, "Could not read config file: %s", configfile);
return -1; return -1;
} }
if( bind_port == UNSET_INT ) if (bind_port == UNSET_INT)
bind_port = config_get_int( "server", "port", 0, UNSET_INT ); bind_port = config_get_int("server", "port", 0, UNSET_INT);
if( strcmp( bind_addr, UNSET_STR ) == 0 ) if (strcmp(bind_addr, UNSET_STR) == 0)
strncpy( bind_addr, config_get_string( "server", "bind", 0, UNSET_STR ), sizeof(bind_addr)); strncpy(bind_addr, config_get_string("server", "bind", 0, UNSET_STR), sizeof(bind_addr));
if( strcmp( user, UNSET_STR ) == 0 ) if (strcmp(user, UNSET_STR) == 0)
strncpy( user, config_get_string( "server", "user", 0, UNSET_STR ), sizeof(user)); strncpy(user, config_get_string("server", "user", 0, UNSET_STR), sizeof(user));
if( default_duration == UNSET_INT ) { if (default_duration == UNSET_INT) {
default_duration = (config_get_float( "server", "waittime", 0, 0 ) * 1e6 / TIME_UNIT ); default_duration = (config_get_float("server", "waittime", 0, 0) * 1e6 / TIME_UNIT);
if( default_duration == 0 ) if (default_duration == 0)
default_duration = UNSET_INT; default_duration = UNSET_INT;
else if( default_duration * TIME_UNIT < 2e6 ) { else if (default_duration * TIME_UNIT < 2e6) {
report( RPT_WARNING, "Waittime should be at least 2 (seconds). Set to 2 seconds." ); report(RPT_WARNING, "Waittime should be at least 2 (seconds). Set to 2 seconds.");
default_duration = 2e6 / TIME_UNIT; default_duration = 2e6 / TIME_UNIT;
} }
} }
if( foreground_mode == UNSET_INT ) { if (foreground_mode == UNSET_INT) {
int fg = config_get_bool( "server", "foreground", 0, UNSET_INT ); int fg = config_get_bool("server", "foreground", 0, UNSET_INT);
if( fg != UNSET_INT ) if (fg != UNSET_INT)
foreground_mode = fg; foreground_mode = fg;
} }
if( rotate_server_screen == UNSET_INT ) { if (rotate_server_screen == UNSET_INT) {
rotate_server_screen = config_get_bool( "server", "serverscreen", 0, UNSET_INT ); rotate_server_screen = config_get_bool("server", "serverscreen", 0, UNSET_INT);
} }
if( backlight == UNSET_INT ) { if (backlight == UNSET_INT) {
s = config_get_string( "server", "backlight", 0, UNSET_STR ); s = config_get_string("server", "backlight", 0, UNSET_STR);
if( strcmp( s, "on" ) == 0 ) { if (strcmp(s, "on") == 0) {
backlight = BACKLIGHT_ON; backlight = BACKLIGHT_ON;
} }
else if( strcmp( s, "off" ) == 0 ) { else if (strcmp(s, "off") == 0) {
backlight = BACKLIGHT_OFF; backlight = BACKLIGHT_OFF;
} }
else if( strcmp( s, "open" ) == 0 ) { else if (strcmp(s, "open") == 0) {
backlight = BACKLIGHT_OPEN; backlight = BACKLIGHT_OPEN;
} }
else if( strcmp( s, UNSET_STR ) != 0 ) { else if (strcmp(s, UNSET_STR) != 0) {
report( RPT_WARNING, "Backlight state should be on, off or open" ); report(RPT_WARNING, "Backlight state should be on, off or open");
} }
} }
@@ -459,8 +459,8 @@ process_configfile(char *configfile)
if (rs != UNSET_INT) if (rs != UNSET_INT)
report_dest = (rs) ? RPT_DEST_SYSLOG : RPT_DEST_STDERR; report_dest = (rs) ? RPT_DEST_SYSLOG : RPT_DEST_STDERR;
} }
if( report_level == UNSET_INT ) { if (report_level == UNSET_INT) {
report_level = config_get_int( "server", "reportLevel", 0, UNSET_INT ); report_level = config_get_int("server", "reportLevel", 0, UNSET_INT);
} }
@@ -469,16 +469,16 @@ process_configfile(char *configfile)
/* If drivers have been specified on the command line, then do not /* If drivers have been specified on the command line, then do not
* use the driver list from the config file. * use the driver list from the config file.
*/ */
if( num_drivers == 0 ) { if (num_drivers == 0) {
/* read the drivernames*/ /* read the drivernames*/
while( 1 ) { while(1) {
s = config_get_string( "server", "driver", num_drivers, NULL ); s = config_get_string("server", "driver", num_drivers, NULL);
if( !s ) if (!s)
break; break;
if( s[0] != 0 ) { if (s[0] != 0) {
drivernames[num_drivers] = malloc(strlen(s)+1); drivernames[num_drivers] = malloc(strlen(s)+1);
strcpy( drivernames[num_drivers], s ); strcpy(drivernames[num_drivers], s);
num_drivers++; num_drivers++;
} }
} }
@@ -491,15 +491,15 @@ process_configfile(char *configfile)
static void static void
set_default_settings(void) set_default_settings(void)
{ {
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
/* Set defaults into unfilled variables....*/ /* Set defaults into unfilled variables....*/
if (bind_port == UNSET_INT) if (bind_port == UNSET_INT)
bind_port = DEFAULT_BIND_PORT; bind_port = DEFAULT_BIND_PORT;
if (strcmp( bind_addr, UNSET_STR ) == 0) if (strcmp(bind_addr, UNSET_STR) == 0)
strncpy (bind_addr, DEFAULT_BIND_ADDR, sizeof(bind_addr)); strncpy(bind_addr, DEFAULT_BIND_ADDR, sizeof(bind_addr));
if (strcmp( user, UNSET_STR ) == 0) if (strcmp(user, UNSET_STR) == 0)
strncpy(user, DEFAULT_USER, sizeof(user)); strncpy(user, DEFAULT_USER, sizeof(user));
if (foreground_mode == UNSET_INT) if (foreground_mode == UNSET_INT)
@@ -512,14 +512,14 @@ set_default_settings(void)
if (backlight == UNSET_INT) if (backlight == UNSET_INT)
backlight = BACKLIGHT_OPEN; backlight = BACKLIGHT_OPEN;
if (report_dest == UNSET_INT ) if (report_dest == UNSET_INT)
report_dest = DEFAULT_REPORTDEST; report_dest = DEFAULT_REPORTDEST;
if( report_level == UNSET_INT ) if (report_level == UNSET_INT)
report_level = DEFAULT_REPORTLEVEL; report_level = DEFAULT_REPORTLEVEL;
/* Use default driver*/ /* Use default driver*/
if( num_drivers == 0 ) { if (num_drivers == 0) {
drivernames[0] = malloc(strlen(DEFAULT_DRIVER)+1); drivernames[0] = malloc(strlen(DEFAULT_DRIVER)+1);
strcpy(drivernames[0], DEFAULT_DRIVER); strcpy(drivernames[0], DEFAULT_DRIVER);
num_drivers = 1; num_drivers = 1;
@@ -537,20 +537,20 @@ install_signal_handlers(int allow_reload)
struct sigaction sa; struct sigaction sa;
debug( RPT_DEBUG, "%s( allow_reload=%d )", __FUNCTION__, allow_reload ); debug(RPT_DEBUG, "%s(allow_reload=%d)", __FUNCTION__, allow_reload);
sigemptyset ( &(sa.sa_mask) ); sigemptyset(&(sa.sa_mask));
/* Clients can cause SIGPIPE if they quit unexpectedly, and the /* Clients can cause SIGPIPE if they quit unexpectedly, and the
* default action is to kill the server. Just ignore it. */ * default action is to kill the server. Just ignore it. */
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &sa, NULL); sigaction(SIGPIPE, &sa, NULL);
sa.sa_handler = exit_program; sa.sa_handler = exit_program;
sa.sa_flags = SA_RESTART; sa.sa_flags = SA_RESTART;
sigaction (SIGINT, &sa, NULL); /* Ctrl-C will cause a clean exit...*/ sigaction(SIGINT, &sa, NULL); /* Ctrl-C will cause a clean exit...*/
sigaction (SIGTERM, &sa, NULL); /* and "kill"...*/ sigaction(SIGTERM, &sa, NULL); /* and "kill"...*/
if (allow_reload) { if (allow_reload) {
sa.sa_handler = catch_reload_signal; sa.sa_handler = catch_reload_signal;
@@ -559,13 +559,13 @@ install_signal_handlers(int allow_reload)
else { else {
/* Treat this signal just like INT and TERM */ /* Treat this signal just like INT and TERM */
} }
sigaction (SIGHUP, &sa, NULL); sigaction(SIGHUP, &sa, NULL);
#else #else
/* Win32 does not support POSIX signals i.e. sigaction(). However, it does /* Win32 does not support POSIX signals i.e. sigaction(). However, it does
* support ANSI signals in mingw. */ * support ANSI signals in mingw. */
signal (SIGINT, exit_program); /* Ctrl-C will cause a clean exit...*/ signal(SIGINT, exit_program); /* Ctrl-C will cause a clean exit...*/
signal (SIGTERM, exit_program); /* and "kill"...*/ signal(SIGTERM, exit_program); /* and "kill"...*/
signal (SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
/* REVISIT: implement SIGHUP on windows */ /* REVISIT: implement SIGHUP on windows */
#endif #endif
@@ -577,10 +577,10 @@ child_ok_func(int signal)
{ {
/* We only catch this signal to be sure the child runs OK. */ /* We only catch this signal to be sure the child runs OK. */
debug( RPT_INFO, "%s( signal=%d )", __FUNCTION__, signal ); debug(RPT_INFO, "%s(signal=%d)", __FUNCTION__, signal);
/* Exit now ! because of bug? in wait() */ /* Exit now ! because of bug? in wait() */
_exit( 0 ); /* Parent exits normally. */ _exit(0); /* Parent exits normally. */
} }
@@ -599,49 +599,49 @@ daemonize(void)
int child_status; int child_status;
struct sigaction sa; struct sigaction sa;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
parent = getpid(); parent = getpid();
debug( RPT_INFO, "parent = %d", parent ); debug(RPT_INFO, "parent = %d", parent);
/* Install handler at parent for child's signal */ /* Install handler at parent for child's signal */
/* sigaction should be more portable than signal, but it does not /* sigaction should be more portable than signal, but it does not
* work for some reason. */ * work for some reason. */
sa.sa_handler = child_ok_func; sa.sa_handler = child_ok_func;
sigemptyset ( &(sa.sa_mask) ); sigemptyset(&(sa.sa_mask));
sa.sa_flags = SA_RESTART; sa.sa_flags = SA_RESTART;
sigaction (SIGUSR1, &sa, NULL); sigaction(SIGUSR1, &sa, NULL);
/* Do the fork */ /* Do the fork */
switch ((child = fork ()) ) { switch ((child = fork())) {
case -1: case -1:
report( RPT_ERR, "Could not fork" ); report(RPT_ERR, "Could not fork");
return -1; return -1;
case 0: /* We are the child */ case 0: /* We are the child */
break; break;
default: /* We are the parent */ default: /* We are the parent */
debug( RPT_INFO, "child = %d", child ); debug(RPT_INFO, "child = %d", child);
wait( &child_status ); wait(&child_status);
/* BUG? According to the man page wait() should also return /* BUG? According to the man page wait() should also return
* when a signal comes in that is caught. Instead it * when a signal comes in that is caught. Instead it
* continues to wait. */ * continues to wait. */
if( WIFEXITED(child_status) ) { if (WIFEXITED(child_status)) {
/* Child exited normally, probably because of some /* Child exited normally, probably because of some
* error. */ * error. */
debug( RPT_INFO, "Child has terminated!" ); debug(RPT_INFO, "Child has terminated!");
exit( WEXITSTATUS(child_status) ); exit(WEXITSTATUS(child_status));
/* Parent exits with same status as child did... */ /* Parent exits with same status as child did... */
} }
/* Child is still running and has signalled it's OK. /* Child is still running and has signalled it's OK.
* This means the parent can now rest in peace. */ * This means the parent can now rest in peace. */
debug( RPT_INFO, "Got OK signal from child." ); debug(RPT_INFO, "Got OK signal from child.");
exit( 0 ); /* Parent exits normally. */ exit(0); /* Parent exits normally. */
} }
/* At this point we are always the child. */ /* At this point we are always the child. */
/* Reset signal handler */ /* Reset signal handler */
sa.sa_handler = SIG_DFL; sa.sa_handler = SIG_DFL;
sigaction (SIGUSR1, &sa, NULL); sigaction(SIGUSR1, &sa, NULL);
setsid(); /* Create a new session because otherwise we'll setsid(); /* Create a new session because otherwise we'll
* catch a SIGHUP when the shell is closed. */ * catch a SIGHUP when the shell is closed. */
@@ -655,9 +655,9 @@ static int
wave_to_parent(pid_t parent_pid) wave_to_parent(pid_t parent_pid)
{ {
#ifndef WIN32 #ifndef WIN32
debug( RPT_DEBUG, "%s( parent_pid=%d )", __FUNCTION__, parent_pid ); debug(RPT_DEBUG, "%s(parent_pid=%d)", __FUNCTION__, parent_pid);
kill( parent_pid, SIGUSR1 ); kill(parent_pid, SIGUSR1);
#endif #endif
return 0; return 0;
@@ -671,15 +671,15 @@ init_drivers(void)
int output_loaded = 0; int output_loaded = 0;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
for (i = 0; i < num_drivers; i++) { for (i = 0; i < num_drivers; i++) {
res = drivers_load_driver (drivernames[i]); res = drivers_load_driver(drivernames[i]);
if (res >= 0) { if (res >= 0) {
/* Load went OK */ /* Load went OK */
switch( res ) { switch(res) {
case 0: /* Driver does input only */ case 0: /* Driver does input only */
break; break;
case 1: /* Driver does output */ case 1: /* Driver does output */
@@ -691,15 +691,15 @@ init_drivers(void)
break; break;
} }
} else { } else {
report( RPT_ERR, "Could not load driver %.40s", drivernames[i] ); report(RPT_ERR, "Could not load driver %.40s", drivernames[i]);
} }
} }
/* Do we have a running output driver ?*/ /* Do we have a running output driver ?*/
if ( output_loaded ) { if (output_loaded) {
return 0; return 0;
} else { } else {
report( RPT_ERR, "There is no output driver" ); report(RPT_ERR, "There is no output driver");
return -1; return -1;
} }
} }
@@ -711,15 +711,15 @@ drop_privs(char *user)
#ifndef WIN32 #ifndef WIN32
struct passwd *pwent; struct passwd *pwent;
debug( RPT_DEBUG, "%s( user=\"%.40s\" )", __FUNCTION__, user ); debug(RPT_DEBUG, "%s(user=\"%.40s\")", __FUNCTION__, user);
if (getuid() == 0 || geteuid() == 0) { if (getuid() == 0 || geteuid() == 0) {
if ((pwent = getpwnam(user)) == NULL) { if ((pwent = getpwnam(user)) == NULL) {
report( RPT_ERR, "User %.40s not a valid user!", user ); report(RPT_ERR, "User %.40s not a valid user!", user);
return -1; return -1;
} else { } else {
if (setuid(pwent->pw_uid) < 0) { if (setuid(pwent->pw_uid) < 0) {
report( RPT_ERR, "Unable to switch to user %.40s", user ); report(RPT_ERR, "Unable to switch to user %.40s", user);
return -1; return -1;
} }
} }
@@ -735,15 +735,15 @@ drop_privs(char *user)
static int static int
init_screens(void) init_screens(void)
{ {
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
if (screenlist_init () < 0) { if (screenlist_init() < 0) {
report(RPT_ERR, "Error initializing screen list"); report(RPT_ERR, "Error initializing screen list");
return -1; return -1;
} }
/* Add the server screen */ /* Add the server screen */
if (server_screen_init () < 0) { if (server_screen_init() < 0) {
report(RPT_ERR, "Error initializing server screens"); report(RPT_ERR, "Error initializing server screens");
return -1; return -1;
} }
@@ -761,37 +761,37 @@ do_reload(void)
{ {
int e = 0; int e = 0;
drivers_unload_all (); /* Close all drivers */ drivers_unload_all(); /* Close all drivers */
config_clear(); config_clear();
clear_settings(); clear_settings();
/* Reread command line*/ /* Reread command line*/
CHAIN( e, process_command_line (stored_argc, stored_argv) ); CHAIN(e, process_command_line(stored_argc, stored_argv));
/* Reread config file */ /* Reread config file */
if (strcmp(configfile, UNSET_STR)==0) if (strcmp(configfile, UNSET_STR)==0)
strncpy(configfile, DEFAULT_CONFIGFILE, sizeof(configfile)); strncpy(configfile, DEFAULT_CONFIGFILE, sizeof(configfile));
CHAIN( e, process_configfile (configfile) ); CHAIN(e, process_configfile(configfile));
/* Set default values */ /* Set default values */
CHAIN( e, ( set_default_settings(), 0 )); CHAIN(e, (set_default_settings(), 0));
/* Set reporting values */ /* Set reporting values */
CHAIN( e, set_reporting("LCDd", report_level, report_dest) ); CHAIN(e, set_reporting("LCDd", report_level, report_dest));
CHAIN( e, ( report(RPT_INFO, "Set report level to %d, output to %s", report_level, CHAIN(e, (report(RPT_INFO, "Set report level to %d, output to %s", report_level,
((report_dest == RPT_DEST_SYSLOG) ? "syslog" : "stderr")), 0 ) ); ((report_dest == RPT_DEST_SYSLOG) ? "syslog" : "stderr")), 0));
/* And restart the drivers */ /* And restart the drivers */
CHAIN( e, init_drivers() ); CHAIN(e, init_drivers());
CHAIN_END( e, "Critical error while reloading, abort." ); CHAIN_END(e, "Critical error while reloading, abort.");
} }
static void static void
do_mainloop(void) do_mainloop(void)
{ {
Screen * s; Screen *s;
#ifndef WIN32 #ifndef WIN32
struct timeval t; struct timeval t;
struct timeval last_t; struct timeval last_t;
@@ -805,10 +805,10 @@ do_mainloop(void)
long int render_lag = 0; long int render_lag = 0;
long int t_diff; long int t_diff;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
#ifndef WIN32 #ifndef WIN32
gettimeofday (&t, NULL); /* Get initial time */ gettimeofday(&t, NULL); /* Get initial time */
#else #else
QueryPerformanceFrequency(&perf_freq); QueryPerformanceFrequency(&perf_freq);
/* scale perf_freq to number of cycles per micro-sec */ /* scale perf_freq to number of cycles per micro-sec */
@@ -821,7 +821,7 @@ do_mainloop(void)
/* Get current time */ /* Get current time */
last_t = t; last_t = t;
#ifndef WIN32 #ifndef WIN32
gettimeofday (&t, NULL); gettimeofday(&t, NULL);
t_diff = t.tv_sec - last_t.tv_sec; t_diff = t.tv_sec - last_t.tv_sec;
if ((t_diff + 1) > (LONG_MAX / 1e6)) { if ((t_diff + 1) > (LONG_MAX / 1e6)) {
/* We're going to overflow the calculation - probably been to sleep, fudge the values */ /* We're going to overflow the calculation - probably been to sleep, fudge the values */
@@ -844,9 +844,9 @@ do_mainloop(void)
process_lag += t_diff; process_lag += t_diff;
if (process_lag > 0) { if (process_lag > 0) {
/* Time for a processing stroke */ /* Time for a processing stroke */
sock_poll_clients (); /* poll clients for input*/ sock_poll_clients(); /* poll clients for input*/
parse_all_client_messages (); /* analyze input from network clients*/ parse_all_client_messages(); /* analyze input from network clients*/
handle_input (); /* handle key input from devices*/ handle_input(); /* handle key input from devices*/
/* We've done the job... */ /* We've done the job... */
process_lag = 0 - (1e6/PROCESS_FREQ); process_lag = 0 - (1e6/PROCESS_FREQ);
@@ -857,19 +857,19 @@ do_mainloop(void)
if (render_lag > 0) { if (render_lag > 0) {
/* Time for a rendering stroke */ /* Time for a rendering stroke */
timer ++; timer ++;
screenlist_process (); screenlist_process();
s = screenlist_current (); s = screenlist_current();
/* TODO: Move this call to every client connection /* TODO: Move this call to every client connection
* and every screen add... * and every screen add...
*/ */
if( s == server_screen ) { if (s == server_screen) {
update_server_screen (timer); update_server_screen();
} }
render_screen (s, timer); render_screen(s, timer);
/* We've done the job... */ /* We've done the job... */
if( render_lag > (1e6/RENDER_FREQ) * MAX_RENDER_LAG_FRAMES ) { if (render_lag > (1e6/RENDER_FREQ) * MAX_RENDER_LAG_FRAMES) {
/* Cause rendering slowdown because too much lag */ /* Cause rendering slowdown because too much lag */
render_lag = (1e6/RENDER_FREQ) * MAX_RENDER_LAG_FRAMES; render_lag = (1e6/RENDER_FREQ) * MAX_RENDER_LAG_FRAMES;
} }
@@ -878,10 +878,10 @@ do_mainloop(void)
} }
/* Sleep just as long as needed */ /* Sleep just as long as needed */
sleeptime = min (0-process_lag, 0-render_lag); sleeptime = min(0-process_lag, 0-render_lag);
if( sleeptime > 0 ) { if (sleeptime > 0) {
#ifndef WIN32 #ifndef WIN32
usleep (sleeptime); usleep(sleeptime);
#else #else
/* Sleep in Windows takes milliseconds argument */ /* Sleep in Windows takes milliseconds argument */
Sleep(sleeptime / 1000); Sleep(sleeptime / 1000);
@@ -889,14 +889,14 @@ do_mainloop(void)
} }
/* Check if a SIGHUP has been caught */ /* Check if a SIGHUP has been caught */
if( got_reload_signal ) { if (got_reload_signal) {
got_reload_signal = 0; got_reload_signal = 0;
do_reload (); do_reload();
} }
} }
/* Quit! */ /* Quit! */
exit_program (0); exit_program(0);
} }
@@ -905,14 +905,14 @@ exit_program(int val)
{ {
char buf[64]; char buf[64];
debug( RPT_DEBUG, "%s( val=%d )", __FUNCTION__, val ); debug(RPT_DEBUG, "%s(val=%d)", __FUNCTION__, val);
/* TODO: These things shouldn't be so interdependent. The order /* TODO: These things shouldn't be so interdependent. The order
* things are shut down in shouldn't matter... * things are shut down in shouldn't matter...
*/ */
if( val > 0 ) { if (val > 0) {
strncpy(buf, "Server shutting down on ", sizeof (buf) ); strncpy(buf, "Server shutting down on ", sizeof(buf));
switch(val) { switch(val) {
case 1: strcat(buf, "SIGHUP"); break; case 1: strcat(buf, "SIGHUP"); break;
case 2: strcat(buf, "SIGINT"); break; case 2: strcat(buf, "SIGINT"); break;
@@ -924,31 +924,31 @@ exit_program(int val)
} }
/* Set emergency reporting and flush all messages if not done already. */ /* Set emergency reporting and flush all messages if not done already. */
if (report_level == UNSET_INT ) if (report_level == UNSET_INT)
report_level = DEFAULT_REPORTLEVEL; report_level = DEFAULT_REPORTLEVEL;
if (report_dest == UNSET_INT ) if (report_dest == UNSET_INT)
report_dest = DEFAULT_REPORTDEST; report_dest = DEFAULT_REPORTDEST;
set_reporting("LCDd", report_level, report_dest); set_reporting("LCDd", report_level, report_dest);
goodbye_screen (); /* display goodbye screen on LCD display */ goodbye_screen(); /* display goodbye screen on LCD display */
drivers_unload_all (); /* release driver memory and file descriptors */ drivers_unload_all(); /* release driver memory and file descriptors */
/* Shutdown things if server start was complete */ /* Shutdown things if server start was complete */
clients_shutdown (); /* shutdown clients (must come first) */ clients_shutdown(); /* shutdown clients (must come first) */
menuscreens_shutdown (); menuscreens_shutdown();
screenlist_shutdown (); /* shutdown screens (must come after client_shutdown) */ screenlist_shutdown(); /* shutdown screens (must come after client_shutdown) */
input_shutdown (); /* shutdown key input part */ input_shutdown(); /* shutdown key input part */
sock_shutdown(); /* shutdown the sockets server */ sock_shutdown(); /* shutdown the sockets server */
report( RPT_INFO, "Exiting." ); report(RPT_INFO, "Exiting.");
_exit (0); _exit(0);
} }
static void static void
catch_reload_signal(int val) catch_reload_signal(int val)
{ {
debug( RPT_DEBUG, "%s( val=%d )", __FUNCTION__, val ); debug(RPT_DEBUG, "%s(val=%d)", __FUNCTION__, val);
got_reload_signal = 1; got_reload_signal = 1;
} }
@@ -981,7 +981,7 @@ output_GPL_notice(void)
*/ */
fprintf(stderr, "LCDd %s, LCDproc Protocol %s\n", VERSION, PROTOCOL_VERSION); fprintf(stderr, "LCDd %s, LCDproc Protocol %s\n", VERSION, PROTOCOL_VERSION);
fprintf(stderr, "Part of the LCDproc suite\n"); fprintf(stderr, "Part of the LCDproc suite\n");
fprintf(stderr, "Copyright (C) 1998-2006 William Ferrell, Scott Scriven\n" fprintf(stderr, "Copyright (C) 1998-2007 William Ferrell, Scott Scriven\n"
" and many other contributors\n\n"); " and many other contributors\n\n");
fprintf(stderr, "This program is free software; you can redistribute it and/or\n" fprintf(stderr, "This program is free software; you can redistribute it and/or\n"
@@ -1006,7 +1006,7 @@ output_help_screen(void)
/* Help screen is printed to stdout on purpose. No reason to have /* Help screen is printed to stdout on purpose. No reason to have
* this in syslog... * this in syslog...
*/ */
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
fprintf(stdout, "LCDd - LCDproc Server Daemon, %s\n\n", version); fprintf(stdout, "LCDd - LCDproc Server Daemon, %s\n\n", version);
fprintf(stdout, "Copyright (c) 1999-2006 Scott Scriven, William Ferrell, and misc. contributors.\n"); fprintf(stdout, "Copyright (c) 1999-2006 Scott Scriven, William Ferrell, and misc. contributors.\n");
+121 -121
View File
@@ -40,23 +40,23 @@
#include "widget.h" #include "widget.h"
extern Menu * custom_main_menu; extern Menu *custom_main_menu;
/** Basicly a patched version of LL_GetByIndex() that ignores hidden /** Basicly a patched version of LL_GetByIndex() that ignores hidden
* entries completely. (But it takes a menu as an argument.) */ * entries completely. (But it takes a menu as an argument.) */
static void * static void *
menu_get_subitem(Menu * menu, int index) menu_get_subitem(Menu *menu, int index)
{ {
MenuItem * item; MenuItem *item;
int i = 0; int i = 0;
debug (RPT_DEBUG, "%s( menu=[%s], index=%d )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], index=%d)", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), index); ((menu != NULL) ? menu->id : "(null)"), index);
for (item = LL_GetFirst(menu->data.menu.contents); for (item = LL_GetFirst(menu->data.menu.contents);
item != NULL; item != NULL;
item = LL_GetNext(menu->data.menu.contents)) item = LL_GetNext(menu->data.menu.contents))
{ {
if ( ! item->is_hidden) if (! item->is_hidden)
{ {
if (i == index) if (i == index)
return item; return item;
@@ -73,18 +73,18 @@ menu_get_subitem(Menu * menu, int index)
* *
* @return index of subitem if found and -1 otherwise. */ * @return index of subitem if found and -1 otherwise. */
static int static int
menu_get_index_of(Menu * menu, char * item_id) menu_get_index_of(Menu *menu, char *item_id)
{ {
MenuItem * item; MenuItem *item;
int i = 0; int i = 0;
debug (RPT_DEBUG, "%s( menu=[%s], item_id=%s )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], item_id=%s)", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), item_id); ((menu != NULL) ? menu->id : "(null)"), item_id);
for (item = LL_GetFirst(menu->data.menu.contents); for (item = LL_GetFirst(menu->data.menu.contents);
item != NULL; item != NULL;
item = LL_GetNext(menu->data.menu.contents)) item = LL_GetNext(menu->data.menu.contents))
{ {
if ( ! item->is_hidden) if (! item->is_hidden)
{ {
if (strcmp(item_id, item->id) == 0) if (strcmp(item_id, item->id) == 0)
return i; return i;
@@ -96,16 +96,16 @@ menu_get_index_of(Menu * menu, char * item_id)
} }
static int static int
menu_visible_item_count(Menu * menu) menu_visible_item_count(Menu *menu)
{ {
MenuItem * item; MenuItem *item;
int i = 0; int i = 0;
for (item = LL_GetFirst(menu->data.menu.contents); for (item = LL_GetFirst(menu->data.menu.contents);
item != NULL; item != NULL;
item = LL_GetNext(menu->data.menu.contents)) item = LL_GetNext(menu->data.menu.contents))
{ {
if ( ! item->is_hidden) if (! item->is_hidden)
++i; ++i;
} }
return i; return i;
@@ -113,15 +113,15 @@ menu_visible_item_count(Menu * menu)
Menu * Menu *
menu_create (char *id, MenuEventFunc(*event_func), menu_create(char *id, MenuEventFunc(*event_func),
char *text, Client *client) char *text, Client *client)
{ {
Menu *new_menu; Menu *new_menu;
debug (RPT_DEBUG, "%s( id=\"%s\", event_func=%p, text=\"%s\", client=%p )", debug(RPT_DEBUG, "%s(id=\"%s\", event_func=%p, text=\"%s\", client=%p)",
__FUNCTION__, id, event_func, text, client); __FUNCTION__, id, event_func, text, client);
new_menu = menuitem_create (MENUITEM_MENU, id, event_func, text, client); new_menu = menuitem_create(MENUITEM_MENU, id, event_func, text, client);
if (new_menu != NULL) { if (new_menu != NULL) {
new_menu->data.menu.contents = LL_new(); new_menu->data.menu.contents = LL_new();
@@ -132,9 +132,9 @@ menu_create (char *id, MenuEventFunc(*event_func),
} }
void void
menu_destroy (Menu *menu) menu_destroy(Menu *menu)
{ {
debug (RPT_DEBUG, "%s( menu=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)")); ((menu != NULL) ? menu->id : "(null)"));
if (menu == NULL) if (menu == NULL)
@@ -143,17 +143,17 @@ menu_destroy (Menu *menu)
if (custom_main_menu == menu) if (custom_main_menu == menu)
custom_main_menu = NULL; custom_main_menu = NULL;
menu_destroy_all_items (menu); menu_destroy_all_items(menu);
LL_Destroy (menu->data.menu.contents); LL_Destroy(menu->data.menu.contents);
menu->data.menu.contents = NULL; menu->data.menu.contents = NULL;
/* After this the general menuitem routine destroys the rest... */ /* After this the general menuitem routine destroys the rest... */
} }
void void
menu_add_item (Menu *menu, MenuItem *item) menu_add_item(Menu *menu, MenuItem *item)
{ {
debug (RPT_DEBUG, "%s( menu=[%s], item=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], item=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), ((menu != NULL) ? menu->id : "(null)"),
((item != NULL) ? item->id : "(null)")); ((item != NULL) ? item->id : "(null)"));
@@ -161,17 +161,17 @@ menu_add_item (Menu *menu, MenuItem *item)
return; return;
/* Add the item to the menu */ /* Add the item to the menu */
LL_Push (menu->data.menu.contents, item); LL_Push(menu->data.menu.contents, item);
item->parent = menu; item->parent = menu;
} }
void void
menu_remove_item (Menu *menu, MenuItem *item) menu_remove_item(Menu *menu, MenuItem *item)
{ {
int i; int i;
MenuItem * item2; MenuItem *item2;
debug (RPT_DEBUG, "%s( menu=[%s], item=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], item=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), ((menu != NULL) ? menu->id : "(null)"),
((item != NULL) ? item->id : "(null)")); ((item != NULL) ? item->id : "(null)"));
@@ -181,9 +181,9 @@ menu_remove_item (Menu *menu, MenuItem *item)
/* Find the item */ /* Find the item */
for (item2 = LL_GetFirst(menu->data.menu.contents), i = 0; for (item2 = LL_GetFirst(menu->data.menu.contents), i = 0;
item2 != NULL; item2 != NULL;
item2 = LL_GetNext(menu->data.menu.contents), i++ ) { item2 = LL_GetNext(menu->data.menu.contents), i++) {
if (item == item2) { if (item == item2) {
LL_DeleteNode (menu->data.menu.contents); LL_DeleteNode(menu->data.menu.contents);
if (menu->data.menu.selector_pos >= i) { if (menu->data.menu.selector_pos >= i) {
menu->data.menu.selector_pos--; menu->data.menu.selector_pos--;
if (menu->data.menu.scroll > 0) if (menu->data.menu.scroll > 0)
@@ -195,34 +195,34 @@ menu_remove_item (Menu *menu, MenuItem *item)
} }
void void
menu_destroy_all_items (Menu *menu) menu_destroy_all_items(Menu *menu)
{ {
MenuItem * item; MenuItem *item;
debug (RPT_DEBUG, "%s( menu=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)")); ((menu != NULL) ? menu->id : "(null)"));
if (menu == NULL) if (menu == NULL)
return; return;
for( item = menu_getfirst_item(menu); item != NULL; item = menu_getfirst_item(menu) ) { for (item = menu_getfirst_item(menu); item != NULL; item = menu_getfirst_item(menu)) {
menuitem_destroy (item); menuitem_destroy(item);
LL_Remove (menu->data.menu.contents, item); LL_Remove(menu->data.menu.contents, item);
} }
} }
MenuItem *menu_get_current_item (Menu *menu) MenuItem *menu_get_current_item(Menu *menu)
{ {
return (MenuItem*) ((menu != NULL) return (MenuItem*) ((menu != NULL)
? menu_get_subitem(menu, menu->data.menu.selector_pos) ? menu_get_subitem(menu, menu->data.menu.selector_pos)
: NULL); : NULL);
} }
MenuItem *menu_find_item (Menu *menu, char *id, bool recursive) MenuItem *menu_find_item(Menu *menu, char *id, bool recursive)
{ {
MenuItem * item; MenuItem *item;
debug (RPT_DEBUG, "%s( menu=[%s], id=\"%s\", recursive=%d )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], id=\"%s\", recursive=%d)", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), id, recursive); ((menu != NULL) ? menu->id : "(null)"), id, recursive);
if ((menu == NULL) || (id == NULL)) if ((menu == NULL) || (id == NULL))
@@ -230,13 +230,13 @@ MenuItem *menu_find_item (Menu *menu, char *id, bool recursive)
if (strcmp(menu->id, id) == 0) if (strcmp(menu->id, id) == 0)
return menu; return menu;
for( item = menu_getfirst_item(menu); item != NULL; item = menu_getnext_item(menu) ) { for (item = menu_getfirst_item(menu); item != NULL; item = menu_getnext_item(menu)) {
if ( strcmp(item->id, id) == 0 ) { if (strcmp(item->id, id) == 0) {
return item; return item;
} }
else if (recursive && item->type == MENUITEM_MENU) { else if (recursive && item->type == MENUITEM_MENU) {
MenuItem * res; MenuItem *res;
res = menu_find_item (item, id, recursive); res = menu_find_item(item, id, recursive);
if (res) { if (res) {
return res; return res;
} }
@@ -250,9 +250,9 @@ void menu_set_association(Menu *menu, void *assoc)
menu->data.menu.association = assoc; menu->data.menu.association = assoc;
} }
void menu_reset (Menu *menu) void menu_reset(Menu *menu)
{ {
debug (RPT_DEBUG, "%s( menu=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)")); ((menu != NULL) ? menu->id : "(null)"));
if (menu == NULL) if (menu == NULL)
@@ -262,13 +262,13 @@ void menu_reset (Menu *menu)
menu->data.menu.scroll = 0; menu->data.menu.scroll = 0;
} }
void menu_build_screen (MenuItem *menu, Screen *s) void menu_build_screen(MenuItem *menu, Screen *s)
{ {
Widget * w; Widget *w;
MenuItem * subitem; MenuItem *subitem;
int itemnr; int itemnr;
debug (RPT_DEBUG, "%s( menu=[%s], screen=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], screen=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), ((menu != NULL) ? menu->id : "(null)"),
((s != NULL) ? s->id : "(null)")); ((s != NULL) ? s->id : "(null)"));
@@ -279,57 +279,57 @@ void menu_build_screen (MenuItem *menu, Screen *s)
/* Problem: frames are not handled correctly by renderer */ /* Problem: frames are not handled correctly by renderer */
/* Create menu title widget */ /* Create menu title widget */
w = widget_create ("title", WID_TITLE, s); w = widget_create("title", WID_TITLE, s);
if (w != NULL) { if (w != NULL) {
screen_add_widget (s, w); screen_add_widget(s, w);
w->text = strdup(menu->text); w->text = strdup(menu->text);
w->x = 1; w->x = 1;
} }
/* Create widgets for each subitem in the menu */ /* Create widgets for each subitem in the menu */
for (subitem = LL_GetFirst (menu->data.menu.contents), itemnr = 0; for (subitem = LL_GetFirst(menu->data.menu.contents), itemnr = 0;
subitem != NULL; subitem != NULL;
subitem = LL_GetNext (menu->data.menu.contents), itemnr ++ ) subitem = LL_GetNext(menu->data.menu.contents), itemnr ++)
{ {
char buf[10]; char buf[10];
if (subitem->is_hidden) if (subitem->is_hidden)
continue; continue;
snprintf (buf, sizeof(buf)-1, "text%d", itemnr); snprintf(buf, sizeof(buf)-1, "text%d", itemnr);
buf[sizeof(buf)-1] = 0; buf[sizeof(buf)-1] = 0;
w = widget_create (buf, WID_STRING, s); w = widget_create(buf, WID_STRING, s);
/* (buf will be copied) */ /* (buf will be copied) */
if (w != NULL) { if (w != NULL) {
screen_add_widget (s, w); screen_add_widget(s, w);
w->x = 2; w->x = 2;
switch (subitem->type) { switch (subitem->type) {
case MENUITEM_CHECKBOX: case MENUITEM_CHECKBOX:
/* Limit string length */ /* Limit string length */
w->text = strdup (subitem->text); w->text = strdup(subitem->text);
if (strlen(subitem->text) >= display_props->width-2) { if (strlen(subitem->text) >= display_props->width-2) {
(w->text)[display_props->width-2] = 0; (w->text)[display_props->width-2] = 0;
} }
/* Add icon for checkbox */ /* Add icon for checkbox */
snprintf (buf, sizeof(buf)-1, "icon%d", itemnr); snprintf(buf, sizeof(buf)-1, "icon%d", itemnr);
buf[sizeof(buf)-1] = 0; buf[sizeof(buf)-1] = 0;
w = widget_create (buf, WID_ICON, s); w = widget_create(buf, WID_ICON, s);
/* (buf will be copied) */ /* (buf will be copied) */
screen_add_widget (s, w); screen_add_widget(s, w);
w->x = display_props->width - 1; w->x = display_props->width - 1;
w->length = ICON_CHECKBOX_OFF; w->length = ICON_CHECKBOX_OFF;
break; break;
case MENUITEM_RING: case MENUITEM_RING:
/* Create string for text + ringtext */ /* Create string for text + ringtext */
w->text = malloc (display_props->width); w->text = malloc(display_props->width);
break; break;
case MENUITEM_MENU: case MENUITEM_MENU:
/* Limit string length */ /* Limit string length */
w->text = malloc( strlen(subitem->text) + 4 ); w->text = malloc(strlen(subitem->text) + 4);
strcpy( w->text, subitem->text ); strcpy(w->text, subitem->text);
strcat( w->text, " >" ); strcat(w->text, " >");
if (strlen(subitem->text) >= display_props->width-1) { if (strlen(subitem->text) >= display_props->width-1) {
(w->text)[display_props->width-1] = '\0'; (w->text)[display_props->width-1] = '\0';
} }
@@ -340,7 +340,7 @@ void menu_build_screen (MenuItem *menu, Screen *s)
case MENUITEM_ALPHA: case MENUITEM_ALPHA:
case MENUITEM_IP: case MENUITEM_IP:
/* Limit string length */ /* Limit string length */
w->text = strdup (subitem->text); w->text = strdup(subitem->text);
if (strlen(subitem->text) >= display_props->width-1) { if (strlen(subitem->text) >= display_props->width-1) {
(w->text)[display_props->width-1] = '\0'; (w->text)[display_props->width-1] = '\0';
} }
@@ -352,26 +352,26 @@ void menu_build_screen (MenuItem *menu, Screen *s)
} }
/* Add arrow for selection on the left */ /* Add arrow for selection on the left */
w = widget_create ("selector", WID_ICON, s); w = widget_create("selector", WID_ICON, s);
if (w != NULL) { if (w != NULL) {
screen_add_widget (s, w); screen_add_widget(s, w);
w->length = ICON_SELECTOR_AT_LEFT; w->length = ICON_SELECTOR_AT_LEFT;
w->x = 1; w->x = 1;
} }
/* Add scrollers on the right side on top and bottom */ /* Add scrollers on the right side on top and bottom */
/* TODO: when menu is in a frame, these can be removed */ /* TODO: when menu is in a frame, these can be removed */
w = widget_create ("upscroller", WID_ICON, s); w = widget_create("upscroller", WID_ICON, s);
if (w != NULL) { if (w != NULL) {
screen_add_widget (s, w); screen_add_widget(s, w);
w->length = ICON_ARROW_UP; w->length = ICON_ARROW_UP;
w->x = display_props->width; w->x = display_props->width;
w->y = 1; w->y = 1;
} }
w = widget_create ("downscroller", WID_ICON, s); w = widget_create("downscroller", WID_ICON, s);
if (w != NULL) { if (w != NULL) {
screen_add_widget (s, w); screen_add_widget(s, w);
w->length = ICON_ARROW_DOWN; w->length = ICON_ARROW_DOWN;
w->x = display_props->width; w->x = display_props->width;
w->y = display_props->height; w->y = display_props->height;
@@ -379,14 +379,14 @@ void menu_build_screen (MenuItem *menu, Screen *s)
} }
void menu_update_screen (MenuItem *menu, Screen *s) void menu_update_screen(MenuItem *menu, Screen *s)
{ {
Widget * w; Widget *w;
MenuItem * subitem; MenuItem *subitem;
int itemnr; int itemnr;
int hidden_count = 0; int hidden_count = 0;
debug (RPT_DEBUG, "%s( menu=[%s], screen=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], screen=[%s])", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), ((menu != NULL) ? menu->id : "(null)"),
((s != NULL) ? s->id : "(null)")); ((s != NULL) ? s->id : "(null)"));
@@ -394,8 +394,8 @@ void menu_update_screen (MenuItem *menu, Screen *s)
return; return;
/* Update widgets for the title */ /* Update widgets for the title */
w = screen_find_widget (s, "title"); w = screen_find_widget(s, "title");
if (!w) report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "title"); if (!w) report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "title");
w->y = 1 - menu->data.menu.scroll; w->y = 1 - menu->data.menu.scroll;
/* TODO: remove next 5 limes when rendering is safe */ /* TODO: remove next 5 limes when rendering is safe */
@@ -406,12 +406,12 @@ void menu_update_screen (MenuItem *menu, Screen *s)
} }
/* Update widgets for each subitem in the menu */ /* Update widgets for each subitem in the menu */
for (subitem = LL_GetFirst (menu->data.menu.contents), itemnr = 0; for (subitem = LL_GetFirst(menu->data.menu.contents), itemnr = 0;
subitem; subitem;
subitem = LL_GetNext (menu->data.menu.contents), itemnr ++ ) subitem = LL_GetNext(menu->data.menu.contents), itemnr ++)
{ {
char buf[10]; char buf[10];
char * p; char *p;
if (subitem->is_hidden) if (subitem->is_hidden)
{ {
@@ -420,10 +420,10 @@ void menu_update_screen (MenuItem *menu, Screen *s)
++hidden_count; ++hidden_count;
continue; continue;
} }
snprintf (buf, sizeof(buf)-1, "text%d", itemnr); snprintf(buf, sizeof(buf)-1, "text%d", itemnr);
buf[sizeof(buf)-1] = 0; buf[sizeof(buf)-1] = 0;
w = screen_find_widget (s, buf); w = screen_find_widget(s, buf);
if (!w) report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf); if (!w) report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf);
w->y = 2 + itemnr - hidden_count - menu->data.menu.scroll; w->y = 2 + itemnr - hidden_count - menu->data.menu.scroll;
/* TODO: remove next 5 lines when rendering is safe */ /* TODO: remove next 5 lines when rendering is safe */
@@ -437,10 +437,10 @@ void menu_update_screen (MenuItem *menu, Screen *s)
case MENUITEM_CHECKBOX: case MENUITEM_CHECKBOX:
/* Update icon value for checkbox */ /* Update icon value for checkbox */
snprintf (buf, sizeof(buf)-1, "icon%d", itemnr); snprintf(buf, sizeof(buf)-1, "icon%d", itemnr);
buf[sizeof(buf)-1] = 0; buf[sizeof(buf)-1] = 0;
w = screen_find_widget (s, buf); w = screen_find_widget(s, buf);
if (!w) report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf); if (!w) report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf);
w->y = 2 + itemnr - menu->data.menu.scroll; w->y = 2 + itemnr - menu->data.menu.scroll;
w->length = ((int[]){ICON_CHECKBOX_OFF,ICON_CHECKBOX_ON,ICON_CHECKBOX_GRAY})[subitem->data.checkbox.value]; w->length = ((int[]){ICON_CHECKBOX_OFF,ICON_CHECKBOX_ON,ICON_CHECKBOX_GRAY})[subitem->data.checkbox.value];
@@ -454,28 +454,28 @@ void menu_update_screen (MenuItem *menu, Screen *s)
case MENUITEM_RING: case MENUITEM_RING:
if (subitem->data.ring.value >= LL_Length(subitem->data.ring.strings)) { if (subitem->data.ring.value >= LL_Length(subitem->data.ring.strings)) {
/* No strings available */ /* No strings available */
memcpy (w->text, subitem->text, display_props->width - 2); memcpy(w->text, subitem->text, display_props->width - 2);
w->text[ display_props->width - 2 ] = 0; w->text[ display_props->width - 2 ] = 0;
} }
else { else {
/* Limit string length and add ringstring */ /* Limit string length and add ringstring */
p = LL_GetByIndex (subitem->data.ring.strings, subitem->data.ring.value); p = LL_GetByIndex(subitem->data.ring.strings, subitem->data.ring.value);
assert(p != NULL); assert(p != NULL);
if (strlen(p) > display_props->width - 3) { if (strlen(p) > display_props->width - 3) {
short a = display_props->width - 3; short a = display_props->width - 3;
/* We need to limit the ring string and DON'T /* We need to limit the ring string and DON'T
* display the item text */ * display the item text */
strcpy (w->text, " "); strcpy(w->text, " ");
memcpy (w->text + 1, p, a); memcpy(w->text + 1, p, a);
w->text[a + 1] = 0; w->text[a + 1] = 0;
} }
else { else {
short b = display_props->width - 2 - strlen (p); short b = display_props->width - 2 - strlen(p);
short c = min (strlen (subitem->text), b - 1); short c = min(strlen(subitem->text), b - 1);
/* We don't limit the ring string */ /* We don't limit the ring string */
memset (w->text, ' ', b); memset(w->text, ' ', b);
memcpy (w->text, subitem->text, c); memcpy(w->text, subitem->text, c);
strcpy (w->text + b, p); strcpy(w->text + b, p);
} }
} }
break; break;
@@ -485,32 +485,32 @@ void menu_update_screen (MenuItem *menu, Screen *s)
} }
/* Update selector position */ /* Update selector position */
w = screen_find_widget (s, "selector"); w = screen_find_widget(s, "selector");
if (w != NULL) if (w != NULL)
w->y = 2 + menu->data.menu.selector_pos - menu->data.menu.scroll; w->y = 2 + menu->data.menu.selector_pos - menu->data.menu.scroll;
else else
report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "selector"); report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "selector");
/* Enable upscroller (if necessary) */ /* Enable upscroller (if necessary) */
w = screen_find_widget (s, "upscroller"); w = screen_find_widget(s, "upscroller");
if (w != NULL) if (w != NULL)
w->type = (menu->data.menu.scroll > 0) ? WID_ICON : WID_NONE; w->type = (menu->data.menu.scroll > 0) ? WID_ICON : WID_NONE;
else else
report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "upscroller"); report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "upscroller");
/* Enable downscroller (if necessary) */ /* Enable downscroller (if necessary) */
w = screen_find_widget (s, "downscroller"); w = screen_find_widget(s, "downscroller");
if (w != NULL) if (w != NULL)
w->type = (menu_visible_item_count(menu) >= menu->data.menu.scroll + display_props->height) w->type = (menu_visible_item_count(menu) >= menu->data.menu.scroll + display_props->height)
? WID_ICON : WID_NONE; ? WID_ICON : WID_NONE;
else else
report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "downscroller"); report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "downscroller");
} }
MenuItem * menu_get_item_for_predecessor_check(Menu *menu) MenuItem *menu_get_item_for_predecessor_check(Menu *menu)
{ {
MenuItem *subitem = menu_get_subitem(menu, menu->data.menu.selector_pos); MenuItem *subitem = menu_get_subitem(menu, menu->data.menu.selector_pos);
if ( ! subitem) if (! subitem)
return NULL; return NULL;
switch (subitem->type) { switch (subitem->type) {
case MENUITEM_ACTION: case MENUITEM_ACTION:
@@ -534,10 +534,10 @@ MenuItem * menu_get_item_for_predecessor_check(Menu *menu)
} }
} }
MenuItem * menu_get_item_for_successor_check(Menu *menu) MenuItem *menu_get_item_for_successor_check(Menu *menu)
{ {
MenuItem *subitem = menu_get_subitem(menu, menu->data.menu.selector_pos); MenuItem *subitem = menu_get_subitem(menu, menu->data.menu.selector_pos);
if ( ! subitem) if (! subitem)
return NULL; return NULL;
switch (subitem->type) { switch (subitem->type) {
case MENUITEM_ACTION: case MENUITEM_ACTION:
@@ -555,10 +555,10 @@ MenuItem * menu_get_item_for_successor_check(Menu *menu)
} }
} }
MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, bool extended) MenuResult menu_process_input(Menu *menu, MenuToken token, const char *key, bool extended)
{ {
MenuItem *subitem; MenuItem *subitem;
debug (RPT_DEBUG, "%s( menu=[%s], token=%d, key=\"%s\" )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], token=%d, key=\"%s\")", __FUNCTION__,
((menu != NULL) ? menu->id : "(null)"), token, key); ((menu != NULL) ? menu->id : "(null)"), token, key);
if (menu == NULL) if (menu == NULL)
@@ -567,18 +567,18 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo
switch (token) { switch (token) {
case MENUTOKEN_MENU: case MENUTOKEN_MENU:
subitem = menu_get_item_for_predecessor_check(menu); subitem = menu_get_item_for_predecessor_check(menu);
if ( ! subitem) if (! subitem)
return MENURESULT_ERROR; return MENURESULT_ERROR;
return menuitem_predecessor2menuresult( return menuitem_predecessor2menuresult(
subitem->predecessor_id, MENURESULT_CLOSE); subitem->predecessor_id, MENURESULT_CLOSE);
case MENUTOKEN_ENTER: case MENUTOKEN_ENTER:
subitem = menu_get_subitem (menu, menu->data.menu.selector_pos); subitem = menu_get_subitem(menu, menu->data.menu.selector_pos);
if (!subitem) if (!subitem)
break; break;
switch (subitem->type) { switch (subitem->type) {
case MENUITEM_ACTION: case MENUITEM_ACTION:
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_SELECT); subitem->event_func(subitem, MENUEVENT_SELECT);
return menuitem_successor2menuresult( return menuitem_successor2menuresult(
subitem->successor_id, MENURESULT_NONE); subitem->successor_id, MENURESULT_NONE);
case MENUITEM_CHECKBOX: case MENUITEM_CHECKBOX:
@@ -589,13 +589,13 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo
subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 2; subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 2;
} }
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_UPDATE); subitem->event_func(subitem, MENUEVENT_UPDATE);
return menuitem_successor2menuresult( return menuitem_successor2menuresult(
subitem->successor_id, MENURESULT_NONE); subitem->successor_id, MENURESULT_NONE);
case MENUITEM_RING: case MENUITEM_RING:
subitem->data.ring.value = (subitem->data.ring.value + 1) % LL_Length (subitem->data.ring.strings); subitem->data.ring.value = (subitem->data.ring.value + 1) % LL_Length(subitem->data.ring.strings);
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_UPDATE); subitem->event_func(subitem, MENUEVENT_UPDATE);
return menuitem_successor2menuresult( return menuitem_successor2menuresult(
subitem->successor_id, MENURESULT_NONE); subitem->successor_id, MENURESULT_NONE);
case MENUITEM_MENU: case MENUITEM_MENU:
@@ -636,7 +636,7 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo
if (!extended) if (!extended)
return MENURESULT_NONE; return MENURESULT_NONE;
subitem = menu_get_subitem (menu, menu->data.menu.selector_pos); subitem = menu_get_subitem(menu, menu->data.menu.selector_pos);
if (subitem == NULL) if (subitem == NULL)
break; break;
switch (subitem->type) { switch (subitem->type) {
@@ -650,15 +650,15 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo
subitem->data.checkbox.value = (subitem->data.checkbox.value - 1) % 2; subitem->data.checkbox.value = (subitem->data.checkbox.value - 1) % 2;
} }
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_UPDATE); subitem->event_func(subitem, MENUEVENT_UPDATE);
return MENURESULT_NONE; return MENURESULT_NONE;
case MENUITEM_RING: case MENUITEM_RING:
/* ring: jump to the end if beginning is reached */ /* ring: jump to the end if beginning is reached */
subitem->data.ring.value = (subitem->data.ring.value < 1) subitem->data.ring.value = (subitem->data.ring.value < 1)
? LL_Length (subitem->data.ring.strings) - 1 ? LL_Length(subitem->data.ring.strings) - 1
: (subitem->data.ring.value - 1) % LL_Length (subitem->data.ring.strings); : (subitem->data.ring.value - 1) % LL_Length(subitem->data.ring.strings);
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_UPDATE); subitem->event_func(subitem, MENUEVENT_UPDATE);
return MENURESULT_NONE; return MENURESULT_NONE;
default: default:
break; break;
@@ -680,12 +680,12 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo
subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 2; subitem->data.checkbox.value = (subitem->data.checkbox.value + 1) % 2;
} }
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_UPDATE); subitem->event_func(subitem, MENUEVENT_UPDATE);
return MENURESULT_NONE; return MENURESULT_NONE;
case MENUITEM_RING: case MENUITEM_RING:
subitem->data.ring.value = (subitem->data.ring.value + 1) % LL_Length (subitem->data.ring.strings); subitem->data.ring.value = (subitem->data.ring.value + 1) % LL_Length(subitem->data.ring.strings);
if (subitem->event_func) if (subitem->event_func)
subitem->event_func (subitem, MENUEVENT_UPDATE); subitem->event_func(subitem, MENUEVENT_UPDATE);
return MENURESULT_NONE; return MENURESULT_NONE;
case MENUITEM_MENU: case MENUITEM_MENU:
return MENURESULT_ENTER; return MENURESULT_ENTER;
@@ -702,10 +702,10 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo
/** positions current item pointer on subitem subitem_id. If subitem_id is /** positions current item pointer on subitem subitem_id. If subitem_id is
* hidden or not valid subitem of menu this function does nothing. */ * hidden or not valid subitem of menu this function does nothing. */
void menu_select_subitem(Menu *menu, char * subitem_id) void menu_select_subitem(Menu *menu, char *subitem_id)
{ {
assert(menu != NULL); assert(menu != NULL);
debug(RPT_DEBUG, "%s( menu=[%s], subitem_id=\"%s\" )", __FUNCTION__, debug(RPT_DEBUG, "%s(menu=[%s], subitem_id=\"%s\")", __FUNCTION__,
menu->id, subitem_id); menu->id, subitem_id);
int position = menu_get_index_of(menu, subitem_id); int position = menu_get_index_of(menu, subitem_id);
if (position < 0) if (position < 0)
+16 -16
View File
@@ -38,28 +38,28 @@ typedef MenuItem Menu;
#include "screen.h" #include "screen.h"
/** Creates a new menu. */ /** Creates a new menu. */
Menu *menu_create (char *id, MenuEventFunc(*event_func), Menu *menu_create(char *id, MenuEventFunc(*event_func),
char *text, Client *client); char *text, Client *client);
/** Deletes menu from memory. /** Deletes menu from memory.
* Destructors will be called for all subitems. * Destructors will be called for all subitems.
* DO NOT CALL THIS FUNCTION, CALL menuitem_destroy INSTEAD ! * DO NOT CALL THIS FUNCTION, CALL menuitem_destroy INSTEAD !
*/ */
void menu_destroy (Menu *menu); void menu_destroy(Menu *menu);
void menu_add_item (Menu *menu, MenuItem *item); void menu_add_item(Menu *menu, MenuItem *item);
/** Adds an item to the menu */ /** Adds an item to the menu */
/** Removes an item from the menu (does not destroy it) */ /** Removes an item from the menu (does not destroy it) */
void menu_remove_item (Menu *menu, MenuItem *item); void menu_remove_item(Menu *menu, MenuItem *item);
/** Destroys and removes all items from the menu */ /** Destroys and removes all items from the menu */
void menu_destroy_all_items (Menu *menu); void menu_destroy_all_items(Menu *menu);
/** Enumeration function. /** Enumeration function.
* Retrieves the first item from the list of items in the menu. * Retrieves the first item from the list of items in the menu.
*/ */
static inline MenuItem *menu_getfirst_item (Menu *menu) static inline MenuItem *menu_getfirst_item(Menu *menu)
{ {
return (MenuItem*) ((menu != NULL) return (MenuItem*) ((menu != NULL)
? LL_GetFirst(menu->data.menu.contents) ? LL_GetFirst(menu->data.menu.contents)
@@ -71,7 +71,7 @@ static inline MenuItem *menu_getfirst_item (Menu *menu)
* No other menu calls should be made between menu_first_item() and * No other menu calls should be made between menu_first_item() and
* this function, to keep the list-cursor where it is. * this function, to keep the list-cursor where it is.
*/ */
static inline MenuItem *menu_getnext_item (Menu *menu) static inline MenuItem *menu_getnext_item(Menu *menu)
{ {
return (MenuItem*) ((menu != NULL) return (MenuItem*) ((menu != NULL)
? LL_GetNext(menu->data.menu.contents) ? LL_GetNext(menu->data.menu.contents)
@@ -80,10 +80,10 @@ static inline MenuItem *menu_getnext_item (Menu *menu)
/** Retrieves the current (non-hidden) item from the list of items in the /** Retrieves the current (non-hidden) item from the list of items in the
* menu. */ * menu. */
MenuItem *menu_get_current_item (Menu *menu); MenuItem *menu_get_current_item(Menu *menu);
/** Finds an item in the menu by the given id. */ /** Finds an item in the menu by the given id. */
MenuItem *menu_find_item (Menu *menu, char *id, bool recursive); MenuItem *menu_find_item(Menu *menu, char *id, bool recursive);
/** sets the association member of a Menu. */ /** sets the association member of a Menu. */
void menu_set_association(Menu *menu, void *assoc); void menu_set_association(Menu *menu, void *assoc);
@@ -91,17 +91,17 @@ void menu_set_association(Menu *menu, void *assoc);
/** Resets it to initial state. /** Resets it to initial state.
* DO NOT CALL THIS FUNCTION, CALL menuitem_reset_screen INSTEAD ! * DO NOT CALL THIS FUNCTION, CALL menuitem_reset_screen INSTEAD !
*/ */
void menu_reset (Menu *menu); void menu_reset(Menu *menu);
/** Builds the selected menuitem on screen using widgets. /** Builds the selected menuitem on screen using widgets.
* DO NOT CALL THIS FUNCTION, CALL menuitem_rebuild_screen INSTEAD ! * DO NOT CALL THIS FUNCTION, CALL menuitem_rebuild_screen INSTEAD !
*/ */
void menu_build_screen (Menu *menu, Screen *s); void menu_build_screen(Menu *menu, Screen *s);
/** Updates the widgets of the selected menuitem /** Updates the widgets of the selected menuitem
* DO NOT CALL THIS FUNCTION, CALL menuitem_update_screen INSTEAD ! * DO NOT CALL THIS FUNCTION, CALL menuitem_update_screen INSTEAD !
*/ */
void menu_update_screen (Menu *menu, Screen *s); void menu_update_screen(Menu *menu, Screen *s);
/** /**
* For predecessor-Check: returns selected subitem of menu if this subitem * For predecessor-Check: returns selected subitem of menu if this subitem
@@ -109,7 +109,7 @@ void menu_update_screen (Menu *menu, Screen *s);
* predecessor and menu otherwise. * predecessor and menu otherwise.
* *
* @return NULL on error. */ * @return NULL on error. */
MenuItem * menu_get_item_for_predecessor_check(Menu *menu); MenuItem *menu_get_item_for_predecessor_check(Menu *menu);
/** /**
* For successor-Check: returns selected subitem of menu if * For successor-Check: returns selected subitem of menu if
@@ -117,14 +117,14 @@ MenuItem * menu_get_item_for_predecessor_check(Menu *menu);
* otherwise. * otherwise.
* *
* @return NULL on error. */ * @return NULL on error. */
MenuItem * menu_get_item_for_successor_check(Menu *menu); MenuItem *menu_get_item_for_successor_check(Menu *menu);
/** Does something with the given input. /** Does something with the given input.
* key is only used if token is MENUTOKEN_OTHER. * key is only used if token is MENUTOKEN_OTHER.
* DO NOT CALL THIS FUNCTION, CALL menuitem_process_input INSTEAD ! * DO NOT CALL THIS FUNCTION, CALL menuitem_process_input INSTEAD !
*/ */
MenuResult menu_process_input (Menu *menu, MenuToken token, const char * key, bool extended); MenuResult menu_process_input(Menu *menu, MenuToken token, const char *key, bool extended);
/** positions current item pointer on subitem subitem_id. */ /** positions current item pointer on subitem subitem_id. */
void menu_select_subitem(Menu *menu, char * subitem_id); void menu_select_subitem(Menu *menu, char *subitem_id);
#endif #endif
+271 -271
View File
File diff suppressed because it is too large Load Diff
+20 -20
View File
@@ -204,10 +204,10 @@ MenuResult menuitem_predecessor2menuresult(char *predecessor_id, MenuResult defa
/** translates a successor_id into a MenuResult. */ /** translates a successor_id into a MenuResult. */
MenuResult menuitem_successor2menuresult(char *successor_id, MenuResult default_result); MenuResult menuitem_successor2menuresult(char *successor_id, MenuResult default_result);
MenuItem * menuitem_search(char *menu_id, Client *client); MenuItem *menuitem_search(char *menu_id, Client *client);
/** YOU SHOULD NOT CALL THIS FUNCTION BUT THE TYPE SPECIFIC ONE INSTEAD */ /** YOU SHOULD NOT CALL THIS FUNCTION BUT THE TYPE SPECIFIC ONE INSTEAD */
MenuItem *menuitem_create (MenuItemType type, char *id, MenuItem *menuitem_create(MenuItemType type, char *id,
MenuEventFunc(*event_func), char *text, Client *client); MenuEventFunc(*event_func), char *text, Client *client);
/* For all constructor functions below the following: /* For all constructor functions below the following:
@@ -229,13 +229,13 @@ MenuItem *menuitem_create (MenuItemType type, char *id,
/** Creates a an action item (a string only). Generated events: /** Creates a an action item (a string only). Generated events:
* MENUEVENT_SELECT when user selects the item. * MENUEVENT_SELECT when user selects the item.
*/ */
MenuItem *menuitem_create_action (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_action(char *id, MenuEventFunc(*event_func),
char *text, Client *client, MenuResult menu_result); char *text, Client *client, MenuResult menu_result);
/** Creates a checkbox. /** Creates a checkbox.
* Generated events: MENUEVENT_UPDATE when user changes value (immediately). * Generated events: MENUEVENT_UPDATE when user changes value (immediately).
*/ */
MenuItem *menuitem_create_checkbox (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_checkbox(char *id, MenuEventFunc(*event_func),
char *text, Client *client, bool allow_gray, bool value); char *text, Client *client, bool allow_gray, bool value);
/** Creates a ring with the given string, separated by tabs. /** Creates a ring with the given string, separated by tabs.
@@ -243,7 +243,7 @@ MenuItem *menuitem_create_checkbox (char *id, MenuEventFunc(*event_func),
* eg: if strings="abc\\tdef" the value=1 means that "def" is selected. * eg: if strings="abc\\tdef" the value=1 means that "def" is selected.
* Generated events: MENUEVENT_UPDATE when user changes value (immediately). * Generated events: MENUEVENT_UPDATE when user changes value (immediately).
*/ */
MenuItem *menuitem_create_ring (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_ring(char *id, MenuEventFunc(*event_func),
char *text, Client *client, char *strings, short value); char *text, Client *client, char *strings, short value);
/** Creates a slider with the given min and max values. /** Creates a slider with the given min and max values.
@@ -253,7 +253,7 @@ MenuItem *menuitem_create_ring (char *id, MenuEventFunc(*event_func),
* and update the value yourself. * and update the value yourself.
* MENUEVENT_PLUS, MENUEVENT_MINUS when slider is moved (immediately). * MENUEVENT_PLUS, MENUEVENT_MINUS when slider is moved (immediately).
*/ */
MenuItem *menuitem_create_slider (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_slider(char *id, MenuEventFunc(*event_func),
char *text, Client *client, char *mintext, char *maxtext, char *text, Client *client, char *mintext, char *maxtext,
int minvalue, int maxvalue, int stepsize, int value); int minvalue, int maxvalue, int stepsize, int value);
@@ -261,7 +261,7 @@ MenuItem *menuitem_create_slider (char *id, MenuEventFunc(*event_func),
* Value can range from minvalue to maxvalue. * Value can range from minvalue to maxvalue.
* MENUEVENT_UPDATE when user finishes the value (no immediate update). * MENUEVENT_UPDATE when user finishes the value (no immediate update).
*/ */
MenuItem *menuitem_create_numeric (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_numeric(char *id, MenuEventFunc(*event_func),
char *text, Client *client, int minvalue, int maxvalue, int value); char *text, Client *client, int minvalue, int maxvalue, int value);
/** Creates a string value box. /** Creates a string value box.
@@ -271,7 +271,7 @@ MenuItem *menuitem_create_numeric (char *id, MenuEventFunc(*event_func),
* input. * input.
* MENUEVENT_UPDATE when user finishes the value (no immediate update). * MENUEVENT_UPDATE when user finishes the value (no immediate update).
*/ */
MenuItem *menuitem_create_alpha (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_alpha(char *id, MenuEventFunc(*event_func),
char *text, Client *client, char password_char, short minlength, short maxlength, char *text, Client *client, char password_char, short minlength, short maxlength,
bool allow_caps, bool allow_noncaps, bool allow_numbers, bool allow_caps, bool allow_noncaps, bool allow_numbers,
char *allowed_extra, char *value); char *allowed_extra, char *value);
@@ -279,20 +279,20 @@ MenuItem *menuitem_create_alpha (char *id, MenuEventFunc(*event_func),
/** Creates an ip value box. can be either v4 or v6 /** Creates an ip value box. can be either v4 or v6
* MENUEVENT_UPDATE when user finishes the value (no immediate update). * MENUEVENT_UPDATE when user finishes the value (no immediate update).
*/ */
MenuItem *menuitem_create_ip (char *id, MenuEventFunc(*event_func), MenuItem *menuitem_create_ip(char *id, MenuEventFunc(*event_func),
char *text, Client *client, bool v6, char *value); char *text, Client *client, bool v6, char *value);
/** Deletes item from memory. /** Deletes item from memory.
* All allocated extra data (like strings) will be freed. * All allocated extra data (like strings) will be freed.
*/ */
void menuitem_destroy (MenuItem *item); void menuitem_destroy(MenuItem *item);
/** Resets the item to the initial state. /** Resets the item to the initial state.
* You should call menuitem_update after this to see the effects. * You should call menuitem_update after this to see the effects.
* This call is useless on items that have immediate effect, like a slider. * This call is useless on items that have immediate effect, like a slider.
* Those items do not keep temporary data. * Those items do not keep temporary data.
*/ */
void menuitem_reset (MenuItem *item); void menuitem_reset(MenuItem *item);
/** (Re)builds the selected menuitem on screen using widgets. /** (Re)builds the selected menuitem on screen using widgets.
* Should be re-called if menuitem data has been changed. * Should be re-called if menuitem data has been changed.
@@ -300,30 +300,30 @@ void menuitem_reset (MenuItem *item);
* - the values * - the values
* - the menu scroll and menu index * - the menu scroll and menu index
*/ */
void menuitem_rebuild_screen (MenuItem *item, Screen *s); void menuitem_rebuild_screen(MenuItem *item, Screen *s);
/** Updates the widgets of the selected menuitem /** Updates the widgets of the selected menuitem
* Fills all widget attributes with the corrrect values. * Fills all widget attributes with the corrrect values.
*/ */
void menuitem_update_screen (MenuItem *item, Screen *s); void menuitem_update_screen(MenuItem *item, Screen *s);
/** Does something with the given input. /** Does something with the given input.
* key is only used if token is MENUTOKEN_OTHER. * key is only used if token is MENUTOKEN_OTHER.
*/ */
MenuResult menuitem_process_input (MenuItem *item, MenuToken token, const char * key, bool extended); MenuResult menuitem_process_input(MenuItem *item, MenuToken token, const char *key, bool extended);
/** returns the Client that owns the MenuItem. item must not be null */ /** returns the Client that owns the MenuItem. item must not be null */
Client * menuitem_get_client(MenuItem * item); Client *menuitem_get_client(MenuItem *item);
/** Converts a tab-separated list to a LinkedList. */ /** Converts a tab-separated list to a LinkedList. */
LinkedList * tablist2linkedlist (char * strings); LinkedList *tablist2linkedlist(char *strings);
MenuItemType menuitem_typename_to_type (char *name); MenuItemType menuitem_typename_to_type(char *name);
char *menuitem_type_to_typename (MenuItemType type); char *menuitem_type_to_typename(MenuItemType type);
MenuEventType menuitem_eventtypename_to_eventtype (char *name); MenuEventType menuitem_eventtypename_to_eventtype(char *name);
char *menuitem_eventtype_to_eventtypename (MenuEventType type); char *menuitem_eventtype_to_eventtypename(MenuEventType type);
#endif #endif
+201 -200
View File
@@ -41,152 +41,152 @@
/* Next include files are needed for settings that we can modify */ /* Next include files are needed for settings that we can modify */
#include "render.h" #include "render.h"
char * menu_key; char *menu_key;
char * enter_key; char *enter_key;
char * up_key; char *up_key;
char * down_key; char *down_key;
char * left_key; char *left_key;
char * right_key; char *right_key;
Screen * menuscreen = NULL; Screen *menuscreen = NULL;
MenuItem * active_menuitem = NULL; MenuItem *active_menuitem = NULL;
/** the "real" main_menu */ /** the "real" main_menu */
Menu * main_menu = NULL; Menu *main_menu = NULL;
/** customizable entry point into the menu system (see menu_set_main()). */ /** customizable entry point into the menu system (see menu_set_main()). */
Menu * custom_main_menu = NULL; Menu *custom_main_menu = NULL;
Menu * screens_menu = NULL; Menu *screens_menu = NULL;
/* Local prototypes */ /* Local prototypes */
static void handle_quit(); static void handle_quit(void);
static void handle_close(); static void handle_close(void);
static void handle_none(); static void handle_none(void);
static void handle_enter(); static void handle_enter(void);
static void handle_successor(); static void handle_successor(void);
void menuscreen_switch_item (MenuItem * new_menuitem); void menuscreen_switch_item(MenuItem *new_menuitem);
void menuscreen_create_menu (); void menuscreen_create_menu(void);
Menu* menuscreen_get_main (); Menu *menuscreen_get_main(void);
MenuEventFunc (heartbeat_handler); MenuEventFunc(heartbeat_handler);
MenuEventFunc (backlight_handler); MenuEventFunc(backlight_handler);
MenuEventFunc (contrast_handler); MenuEventFunc(contrast_handler);
MenuEventFunc (brightness_handler); MenuEventFunc(brightness_handler);
int menuscreens_init() int menuscreens_init(void)
{ {
const char *tmp; const char *tmp;
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
/* Get keys from config file */ /* Get keys from config file */
menu_key = strdup (config_get_string ("menu", "MenuKey", 0, "Menu")); menu_key = strdup(config_get_string("menu", "MenuKey", 0, "Menu"));
enter_key = strdup (config_get_string ("menu", "EnterKey", 0, "Enter")); enter_key = strdup(config_get_string("menu", "EnterKey", 0, "Enter"));
up_key = strdup (config_get_string ("menu", "UpKey", 0, "Up")); up_key = strdup(config_get_string("menu", "UpKey", 0, "Up"));
down_key = strdup (config_get_string ("menu", "DownKey", 0, "Down")); down_key = strdup(config_get_string("menu", "DownKey", 0, "Down"));
/* if the user has specified in the conf file a left and right key */ /* if the user has specified in the conf file a left and right key */
left_key = right_key = NULL; left_key = right_key = NULL;
tmp = config_get_string ("menu", "LeftKey", 0, NULL); tmp = config_get_string("menu", "LeftKey", 0, NULL);
if (tmp) if (tmp)
left_key = strdup(tmp); left_key = strdup(tmp);
tmp = config_get_string ("menu", "RightKey", 0, NULL); tmp = config_get_string("menu", "RightKey", 0, NULL);
if (tmp) if (tmp)
right_key = strdup(tmp); right_key = strdup(tmp);
/* Now reserve keys */ /* Now reserve keys */
input_reserve_key (menu_key, true, NULL); input_reserve_key(menu_key, true, NULL);
input_reserve_key (enter_key, false, NULL); input_reserve_key(enter_key, false, NULL);
input_reserve_key (up_key, false, NULL); input_reserve_key(up_key, false, NULL);
input_reserve_key (down_key, false, NULL); input_reserve_key(down_key, false, NULL);
if (left_key) if (left_key)
input_reserve_key (left_key, false, NULL); input_reserve_key(left_key, false, NULL);
if (right_key) if (right_key)
input_reserve_key (right_key, false, NULL); input_reserve_key(right_key, false, NULL);
/* Create screen */ /* Create screen */
menuscreen = screen_create ("_menu_screen", NULL); menuscreen = screen_create("_menu_screen", NULL);
if (menuscreen != NULL) if (menuscreen != NULL)
menuscreen->priority = PRI_HIDDEN; menuscreen->priority = PRI_HIDDEN;
active_menuitem = NULL; active_menuitem = NULL;
screenlist_add (menuscreen); screenlist_add(menuscreen);
/* Build menu */ /* Build menu */
menuscreen_create_menu (); menuscreen_create_menu();
return 0; return 0;
} }
int menuscreens_shutdown() int menuscreens_shutdown(void)
{ {
debug (RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
/* Program shutdown before completed startup */ /* Program shutdown before completed startup */
if (!menuscreen) if (!menuscreen)
return -1; return -1;
/* Quit menu just to make sure */ /* Quit menu just to make sure */
menuscreen_switch_item (NULL); menuscreen_switch_item(NULL);
/* Destroy the menuscreen */ /* Destroy the menuscreen */
screenlist_remove (menuscreen); screenlist_remove(menuscreen);
screen_destroy (menuscreen); screen_destroy(menuscreen);
menuscreen = NULL; menuscreen = NULL;
/* Destroy all menus */ /* Destroy all menus */
menuitem_destroy (main_menu); menuitem_destroy(main_menu);
main_menu = NULL; main_menu = NULL;
custom_main_menu = NULL; custom_main_menu = NULL;
screens_menu = NULL; screens_menu = NULL;
/* Forget menu's key reservations */ /* Forget menu's key reservations */
input_release_client_keys (NULL); input_release_client_keys(NULL);
free (menu_key); free(menu_key);
free (enter_key); free(enter_key);
free (up_key); free(up_key);
free (down_key); free(down_key);
if (left_key) if (left_key)
free (left_key); free(left_key);
if (right_key) if (right_key)
free (right_key); free(right_key);
return 0; return 0;
} }
void menuscreen_inform_item_destruction (MenuItem * item) void menuscreen_inform_item_destruction(MenuItem *item)
{ {
MenuItem * i; MenuItem *i;
debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__,
((item != NULL) ? item->id : "(null)")); ((item != NULL) ? item->id : "(null)"));
/* Are we currently in (a subitem of) the given item ? */ /* Are we currently in (a subitem of) the given item ? */
for( i = active_menuitem; i != NULL; i = i->parent ) { for (i = active_menuitem; i != NULL; i = i->parent) {
if( i == item ) { if (i == item) {
menuscreen_switch_item (item->parent); menuscreen_switch_item(item->parent);
} }
} }
} }
void menuscreen_inform_item_modified (MenuItem * item) void menuscreen_inform_item_modified(MenuItem *item)
{ {
debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__,
((item != NULL) ? item->id : "(null)")); ((item != NULL) ? item->id : "(null)"));
if ((active_menuitem == NULL) || (item == NULL)) if ((active_menuitem == NULL) || (item == NULL))
return; return;
/* Are we currently in the item or the parent of the item ? */ /* Are we currently in the item or the parent of the item ? */
if( active_menuitem == item || active_menuitem == item->parent ) { if (active_menuitem == item || active_menuitem == item->parent) {
menuitem_rebuild_screen( active_menuitem, menuscreen ); menuitem_rebuild_screen(active_menuitem, menuscreen);
} }
} }
bool is_menu_key (const char * key) bool is_menu_key(const char *key)
{ {
if (menu_key && key && strcmp (key, menu_key) == 0) if (menu_key && key && strcmp(key, menu_key) == 0)
return true; return true;
else else
return false; return false;
@@ -197,11 +197,11 @@ bool is_menu_key (const char * key)
* To leave the menu system, specify NULL for new_menuitem. * To leave the menu system, specify NULL for new_menuitem.
* The item will not be reset when the new item is a child of the last one. * The item will not be reset when the new item is a child of the last one.
*/ */
void menuscreen_switch_item (MenuItem * new_menuitem) void menuscreen_switch_item(MenuItem *new_menuitem)
{ {
MenuItem * old_menuitem = active_menuitem; MenuItem *old_menuitem = active_menuitem;
debug (RPT_DEBUG, "%s( item=[%s] ) from active_menuitem=[%s]", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s]) from active_menuitem=[%s]", __FUNCTION__,
((new_menuitem != NULL) ? new_menuitem->id : "(null)"), ((new_menuitem != NULL) ? new_menuitem->id : "(null)"),
((old_menuitem != NULL) ? old_menuitem->id : "(null)")); ((old_menuitem != NULL) ? old_menuitem->id : "(null)"));
@@ -216,16 +216,16 @@ void menuscreen_switch_item (MenuItem * new_menuitem)
menuscreen->priority = PRI_HIDDEN; menuscreen->priority = PRI_HIDDEN;
} else if (!old_menuitem && new_menuitem) { } else if (!old_menuitem && new_menuitem) {
/* Menu is becoming active */ /* Menu is becoming active */
menuitem_reset (active_menuitem); menuitem_reset(active_menuitem);
menuitem_rebuild_screen (active_menuitem, menuscreen); menuitem_rebuild_screen(active_menuitem, menuscreen);
menuscreen->priority = PRI_INPUT; menuscreen->priority = PRI_INPUT;
} else { } else {
/* We're left with the usual case: a menu level switch */ /* We're left with the usual case: a menu level switch */
if( old_menuitem->parent != new_menuitem) { if (old_menuitem->parent != new_menuitem) {
menuitem_reset (new_menuitem); menuitem_reset(new_menuitem);
} }
menuitem_rebuild_screen (active_menuitem, menuscreen); menuitem_rebuild_screen(active_menuitem, menuscreen);
} }
if (old_menuitem && old_menuitem->event_func) if (old_menuitem && old_menuitem->event_func)
@@ -236,27 +236,27 @@ void menuscreen_switch_item (MenuItem * new_menuitem)
return; return;
} }
static void handle_quit() static void handle_quit(void)
{ {
debug (RPT_DEBUG, "%s: Closing menu screen", __FUNCTION__); debug(RPT_DEBUG, "%s: Closing menu screen", __FUNCTION__);
menuscreen_switch_item(NULL); menuscreen_switch_item(NULL);
} }
static void handle_close() static void handle_close(void)
{ {
debug (RPT_DEBUG, "%s: Closing item", __FUNCTION__); debug(RPT_DEBUG, "%s: Closing item", __FUNCTION__);
menuscreen_switch_item( menuscreen_switch_item(
(active_menuitem == menuscreen_get_main()) (active_menuitem == menuscreen_get_main())
? NULL ? NULL
: active_menuitem->parent); : active_menuitem->parent);
} }
static void handle_none() static void handle_none(void)
{ {
debug (RPT_DEBUG, "%s: Staying in item", __FUNCTION__); debug(RPT_DEBUG, "%s: Staying in item", __FUNCTION__);
if (active_menuitem) if (active_menuitem)
{ {
menuitem_update_screen (active_menuitem, menuscreen); menuitem_update_screen(active_menuitem, menuscreen);
/* No rebuild needed, only value can be changed */ /* No rebuild needed, only value can be changed */
} }
/* Nothing extra to be done */ /* Nothing extra to be done */
@@ -267,19 +267,19 @@ static void handle_none()
* own screen. The menuitem_process_input function should do * own screen. The menuitem_process_input function should do
* things like toggling checkboxes ! * things like toggling checkboxes !
*/ */
static void handle_enter() static void handle_enter(void)
{ {
debug (RPT_DEBUG, "%s: Entering subitem", __FUNCTION__); debug(RPT_DEBUG, "%s: Entering subitem", __FUNCTION__);
menuscreen_switch_item (menu_get_current_item (active_menuitem)); menuscreen_switch_item(menu_get_current_item(active_menuitem));
} }
static void handle_predecessor() static void handle_predecessor(void)
{ {
MenuItem* item = (active_menuitem->type == MENUITEM_MENU) MenuItem* item = (active_menuitem->type == MENUITEM_MENU)
? menu_get_item_for_predecessor_check(active_menuitem) ? menu_get_item_for_predecessor_check(active_menuitem)
: active_menuitem; : active_menuitem;
assert(item != NULL); assert(item != NULL);
debug (RPT_DEBUG, "%s: Switching to registered predecessor '%s' of '%s'.", debug(RPT_DEBUG, "%s: Switching to registered predecessor '%s' of '%s'.",
__FUNCTION__, item->predecessor_id, item->id); __FUNCTION__, item->predecessor_id, item->id);
MenuItem *predecessor = menuitem_search( MenuItem *predecessor = menuitem_search(
item->predecessor_id, (Client*)active_menuitem->client); item->predecessor_id, (Client*)active_menuitem->client);
@@ -288,7 +288,7 @@ static void handle_predecessor()
// note: if _quit_, _close_, _none_ get here this // note: if _quit_, _close_, _none_ get here this
// would be an implementation error - they should // would be an implementation error - they should
// have been handled via different MENURESULT codes. // have been handled via different MENURESULT codes.
report (RPT_ERR, "%s: cannot find predecessor '%s' of '%s'.", report(RPT_ERR, "%s: cannot find predecessor '%s' of '%s'.",
__FUNCTION__, item->predecessor_id, item->id); __FUNCTION__, item->predecessor_id, item->id);
return; return;
} }
@@ -314,13 +314,13 @@ static void handle_predecessor()
} }
} }
static void handle_successor() static void handle_successor(void)
{ {
MenuItem* item = (active_menuitem->type == MENUITEM_MENU) MenuItem* item = (active_menuitem->type == MENUITEM_MENU)
? menu_get_item_for_successor_check(active_menuitem) ? menu_get_item_for_successor_check(active_menuitem)
: active_menuitem; : active_menuitem;
assert(item != NULL); assert(item != NULL);
debug (RPT_DEBUG, "%s: Switching to registered successor '%s' of '%s'.", debug(RPT_DEBUG, "%s: Switching to registered successor '%s' of '%s'.",
__FUNCTION__, item->successor_id, item->id); __FUNCTION__, item->successor_id, item->id);
MenuItem *successor = menuitem_search( MenuItem *successor = menuitem_search(
item->successor_id, (Client*)active_menuitem->client); item->successor_id, (Client*)active_menuitem->client);
@@ -329,7 +329,7 @@ static void handle_successor()
// note: if _quit_, _close_, _none_ get here this // note: if _quit_, _close_, _none_ get here this
// would be an implementation error - they should // would be an implementation error - they should
// have been handled via different MENURESULT codes. // have been handled via different MENURESULT codes.
report (RPT_ERR, "%s: cannot find successor '%s' of '%s'.", report(RPT_ERR, "%s: cannot find successor '%s' of '%s'.",
__FUNCTION__, item->successor_id, item->id); __FUNCTION__, item->successor_id, item->id);
return; return;
} }
@@ -355,29 +355,29 @@ static void handle_successor()
} }
} }
void menuscreen_key_handler (const char *key) void menuscreen_key_handler(const char *key)
{ {
char token = 0; char token = 0;
MenuResult res; MenuResult res;
debug (RPT_DEBUG, "%s( \"%s\" )", __FUNCTION__, key); debug(RPT_DEBUG, "%s(\"%s\")", __FUNCTION__, key);
if (strcmp (key, menu_key) == 0) { if (strcmp(key, menu_key) == 0) {
token = MENUTOKEN_MENU; token = MENUTOKEN_MENU;
} }
else if (strcmp (key, enter_key) == 0) { else if (strcmp(key, enter_key) == 0) {
token = MENUTOKEN_ENTER; token = MENUTOKEN_ENTER;
} }
else if (strcmp (key, up_key) == 0) { else if (strcmp(key, up_key) == 0) {
token = MENUTOKEN_UP; token = MENUTOKEN_UP;
} }
else if (strcmp (key, down_key) == 0) { else if (strcmp(key, down_key) == 0) {
token = MENUTOKEN_DOWN; token = MENUTOKEN_DOWN;
} }
else if (left_key && strcmp (key, left_key) == 0) { else if (left_key && strcmp(key, left_key) == 0) {
token = MENUTOKEN_LEFT; token = MENUTOKEN_LEFT;
} }
else if (right_key && strcmp (key, right_key) == 0) { else if (right_key && strcmp(key, right_key) == 0) {
token = MENUTOKEN_RIGHT; token = MENUTOKEN_RIGHT;
} }
else { else {
@@ -386,17 +386,17 @@ void menuscreen_key_handler (const char *key)
/* Is the menu already active ? */ /* Is the menu already active ? */
if (!active_menuitem) { if (!active_menuitem) {
debug (RPT_DEBUG, "%s: Activating menu screen", __FUNCTION__); debug(RPT_DEBUG, "%s: Activating menu screen", __FUNCTION__);
menuscreen_switch_item(menuscreen_get_main()); menuscreen_switch_item(menuscreen_get_main());
return; return;
} }
res = menuitem_process_input (active_menuitem, token, key, res = menuitem_process_input(active_menuitem, token, key,
((left_key || right_key) ? 1 : 0)); ((left_key || right_key) ? 1 : 0));
switch (res) { switch (res) {
case MENURESULT_ERROR: case MENURESULT_ERROR:
report (RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__); report(RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__);
break; break;
case MENURESULT_NONE: case MENURESULT_NONE:
handle_none(); handle_none();
@@ -422,38 +422,38 @@ void menuscreen_key_handler (const char *key)
} }
} }
void menuscreen_create_menu () void menuscreen_create_menu(void)
{ {
Menu * options_menu; Menu *options_menu;
Menu * driver_menu; Menu *driver_menu;
MenuItem * checkbox; MenuItem *checkbox;
MenuItem * slider; MenuItem *slider;
Driver * driver; Driver *driver;
#ifdef LCDPROC_TESTMENUS #ifdef LCDPROC_TESTMENUS
MenuItem * test_item; MenuItem *test_item;
Menu * test_menu; Menu *test_menu;
#endif /*LCDPROC_TESTMENUS*/ #endif /*LCDPROC_TESTMENUS*/
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
main_menu = menu_create ("mainmenu", NULL, "LCDproc Menu", NULL); main_menu = menu_create("mainmenu", NULL, "LCDproc Menu", NULL);
options_menu = menu_create ("options", NULL, "Options", NULL); options_menu = menu_create("options", NULL, "Options", NULL);
menu_add_item (main_menu, options_menu); menu_add_item(main_menu, options_menu);
#ifdef LCDPROC_TESTMENUS #ifdef LCDPROC_TESTMENUS
screens_menu = menu_create ("screens", NULL, "Screens", NULL); screens_menu = menu_create("screens", NULL, "Screens", NULL);
menu_add_item (main_menu, screens_menu); menu_add_item(main_menu, screens_menu);
#endif /*LCDPROC_TESTMENUS*/ #endif /*LCDPROC_TESTMENUS*/
/* menu's client is NULL since we're in the server */ /* menu's client is NULL since we're in the server */
checkbox = menuitem_create_checkbox ("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat); checkbox = menuitem_create_checkbox("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat);
menu_add_item (options_menu, checkbox); menu_add_item(options_menu, checkbox);
/* menu's client is NULL since we're in the server */ /* menu's client is NULL since we're in the server */
checkbox = menuitem_create_checkbox ("backlight", backlight_handler, "Backlight", NULL, true, backlight); checkbox = menuitem_create_checkbox("backlight", backlight_handler, "Backlight", NULL, true, backlight);
menu_add_item (options_menu, checkbox); menu_add_item(options_menu, checkbox);
for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) { for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) {
int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0; int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0;
@@ -461,83 +461,83 @@ void menuscreen_create_menu ()
if (contrast_avail || brightness_avail) { if (contrast_avail || brightness_avail) {
/* menu's client is NULL since we're in the server */ /* menu's client is NULL since we're in the server */
driver_menu = menu_create (driver->name, NULL, driver->name, NULL); driver_menu = menu_create(driver->name, NULL, driver->name, NULL);
menu_set_association(driver_menu, driver); menu_set_association(driver_menu, driver);
menu_add_item (options_menu, driver_menu); menu_add_item(options_menu, driver_menu);
if (contrast_avail) { if (contrast_avail) {
int contrast = driver->get_contrast(driver); int contrast = driver->get_contrast(driver);
/* menu's client is NULL since we're in the server */ /* menu's client is NULL since we're in the server */
slider = menuitem_create_slider ("contrast", contrast_handler, "Contrast", slider = menuitem_create_slider("contrast", contrast_handler, "Contrast",
NULL, "min", "max", 0, 1000, 25, contrast); NULL, "min", "max", 0, 1000, 25, contrast);
menu_add_item (driver_menu, slider); menu_add_item(driver_menu, slider);
} }
if (brightness_avail) { if (brightness_avail) {
int onbrightness = driver->get_brightness (driver, BACKLIGHT_ON); int onbrightness = driver->get_brightness(driver, BACKLIGHT_ON);
int offbrightness = driver->get_brightness (driver, BACKLIGHT_OFF); int offbrightness = driver->get_brightness(driver, BACKLIGHT_OFF);
slider = menuitem_create_slider ("onbrightness", brightness_handler, "On Brightness", slider = menuitem_create_slider("onbrightness", brightness_handler, "On Brightness",
NULL, "min", "max", 0, 1000, 25, onbrightness); NULL, "min", "max", 0, 1000, 25, onbrightness);
menu_add_item (driver_menu, slider); menu_add_item(driver_menu, slider);
slider = menuitem_create_slider ("offbrightness", brightness_handler, "Off Brightness", slider = menuitem_create_slider("offbrightness", brightness_handler, "Off Brightness",
NULL, "min", "max", 0, 1000, 25, offbrightness); NULL, "min", "max", 0, 1000, 25, offbrightness);
menu_add_item (driver_menu, slider); menu_add_item(driver_menu, slider);
} }
} }
} }
#ifdef LCDPROC_TESTMENUS #ifdef LCDPROC_TESTMENUS
test_menu = menu_create ("test", NULL, "Test menu", NULL); test_menu = menu_create("test", NULL, "Test menu", NULL);
menu_add_item (main_menu, test_menu); menu_add_item(main_menu, test_menu);
/* menu's client is NULL since we're in the server */ /* menu's client is NULL since we're in the server */
test_item = menuitem_create_action ("", NULL, "Action", NULL, MENURESULT_NONE); test_item = menuitem_create_action("", NULL, "Action", NULL, MENURESULT_NONE);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_action ("", NULL, "Action,closing", NULL, MENURESULT_CLOSE); test_item = menuitem_create_action("", NULL, "Action,closing", NULL, MENURESULT_CLOSE);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_action ("", NULL, "Action,quitting", NULL, MENURESULT_QUIT); test_item = menuitem_create_action("", NULL, "Action,quitting", NULL, MENURESULT_QUIT);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_checkbox ("", NULL, "Checkbox", NULL, false, false); test_item = menuitem_create_checkbox("", NULL, "Checkbox", NULL, false, false);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_checkbox ("", NULL, "Checkbox, gray", NULL, true, false); test_item = menuitem_create_checkbox("", NULL, "Checkbox, gray", NULL, true, false);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_ring ("", NULL, "Ring", NULL, "ABC\tDEF\t01234567890\tOr a very long string that will not fit on any display", 1); test_item = menuitem_create_ring("", NULL, "Ring", NULL, "ABC\tDEF\t01234567890\tOr a very long string that will not fit on any display", 1);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_slider ("", NULL, "Slider", NULL, "mintext", "maxtext", -20, 20, 1, 0); test_item = menuitem_create_slider("", NULL, "Slider", NULL, "mintext", "maxtext", -20, 20, 1, 0);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_slider ("", NULL, "Slider,step=5", NULL, "mintext", "maxtext", -20, 20, 5, 0); test_item = menuitem_create_slider("", NULL, "Slider,step=5", NULL, "mintext", "maxtext", -20, 20, 5, 0);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_numeric ("", NULL, "Numeric", NULL, 1, 365, 15); test_item = menuitem_create_numeric("", NULL, "Numeric", NULL, 1, 365, 15);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_numeric ("", NULL, "Numeric,signed", NULL, -20, +20, 15); test_item = menuitem_create_numeric("", NULL, "Numeric,signed", NULL, -20, +20, 15);
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_alpha ("", NULL, "Alpha", NULL, 0, 3, 12, true, true, true, ".-+@", "LCDproc-v0.5"); test_item = menuitem_create_alpha("", NULL, "Alpha", NULL, 0, 3, 12, true, true, true, ".-+@", "LCDproc-v0.5");
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_alpha ("", NULL, "Alpha, caps only", NULL, 0, 3, 12, true, false, false, "-", "LCDPROC"); test_item = menuitem_create_alpha("", NULL, "Alpha, caps only", NULL, 0, 3, 12, true, false, false, "-", "LCDPROC");
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_ip ("", NULL, "IPv4", NULL, 0, "192.168.1.245"); test_item = menuitem_create_ip("", NULL, "IPv4", NULL, 0, "192.168.1.245");
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
test_item = menuitem_create_ip ("", NULL, "IPv6", NULL, 1, "1080:0:0:0:8:800:200C:417A"); test_item = menuitem_create_ip("", NULL, "IPv6", NULL, 1, "1080:0:0:0:8:800:200C:417A");
menu_add_item (test_menu, test_item); menu_add_item(test_menu, test_item);
#endif /*LCDPROC_TESTMENUS*/ #endif /*LCDPROC_TESTMENUS*/
} }
MenuEventFunc (heartbeat_handler) MenuEventFunc (heartbeat_handler)
{ {
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
((item != NULL) ? item->id : "(null)"), event); ((item != NULL) ? item->id : "(null)"), event);
if (event == MENUEVENT_UPDATE) { if (event == MENUEVENT_UPDATE) {
/* Set heartbeat setting */ /* Set heartbeat setting */
heartbeat = item->data.checkbox.value; heartbeat = item->data.checkbox.value;
report (RPT_INFO, "Menu: set heartbeat to %d", report(RPT_INFO, "Menu: set heartbeat to %d",
item->data.checkbox.value); item->data.checkbox.value);
} }
return 0; return 0;
@@ -545,14 +545,14 @@ MenuEventFunc (heartbeat_handler)
MenuEventFunc (backlight_handler) MenuEventFunc (backlight_handler)
{ {
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
((item != NULL) ? item->id : "(null)"), event); ((item != NULL) ? item->id : "(null)"), event);
if (event == MENUEVENT_UPDATE) if (event == MENUEVENT_UPDATE)
{ {
/* Set backlight setting */ /* Set backlight setting */
backlight = item->data.checkbox.value; backlight = item->data.checkbox.value;
report (RPT_INFO, "Menu: set backlight to %d", report(RPT_INFO, "Menu: set backlight to %d",
item->data.checkbox.value); item->data.checkbox.value);
} }
return 0; return 0;
@@ -560,7 +560,7 @@ MenuEventFunc (backlight_handler)
MenuEventFunc (contrast_handler) MenuEventFunc (contrast_handler)
{ {
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
((item != NULL) ? item->id : "(null)"), event); ((item != NULL) ? item->id : "(null)"), event);
/* This function can be called by one of several drivers that /* This function can be called by one of several drivers that
@@ -568,10 +568,11 @@ MenuEventFunc (contrast_handler)
* We need to check the menu association to see which driver. */ * We need to check the menu association to see which driver. */
if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) { if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) {
/* Determine the driver */ /* Determine the driver */
Driver * driver = item->parent->data.menu.association; Driver *driver = item->parent->data.menu.association;
if (driver != NULL) { if (driver != NULL) {
driver->set_contrast (driver, item->data.slider.value); driver->set_contrast(driver, item->data.slider.value);
report (RPT_INFO, "Menu: set contrast of [%.40s] to %d", report(RPT_INFO, "Menu: set contrast of [%.40s] to %d",
driver->name, item->data.slider.value); driver->name, item->data.slider.value);
} }
} }
@@ -580,7 +581,7 @@ MenuEventFunc (contrast_handler)
MenuEventFunc (brightness_handler) MenuEventFunc (brightness_handler)
{ {
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__, debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
((item != NULL) ? item->id : "(null)"), event); ((item != NULL) ? item->id : "(null)"), event);
/* This function can be called by one of several drivers that /* This function can be called by one of several drivers that
@@ -588,14 +589,14 @@ MenuEventFunc (brightness_handler)
* We need to check the menu association to see which driver. */ * We need to check the menu association to see which driver. */
if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) { if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) {
/* Determine the driver */ /* Determine the driver */
Driver * driver = item->parent->data.menu.association; Driver *driver = item->parent->data.menu.association;
if (driver != NULL) { if (driver != NULL) {
if ( strcmp (item->id, "onbrightness") == 0) { if (strcmp(item->id, "onbrightness") == 0) {
driver->set_brightness (driver, BACKLIGHT_ON, item->data.slider.value); driver->set_brightness(driver, BACKLIGHT_ON, item->data.slider.value);
} }
else if ( strcmp (item->id, "offbrightness") == 0) { else if (strcmp(item->id, "offbrightness") == 0) {
driver->set_brightness (driver, BACKLIGHT_OFF, item->data.slider.value); driver->set_brightness(driver, BACKLIGHT_OFF, item->data.slider.value);
} }
} }
} }
@@ -603,12 +604,12 @@ MenuEventFunc (brightness_handler)
} }
void void
menuscreen_add_screen (Screen * s) menuscreen_add_screen(Screen *s)
{ {
Menu * m; Menu *m;
MenuItem * mi; MenuItem *mi;
debug (RPT_DEBUG, "%s( s=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__,
((s != NULL) ? s->id : "(null)")); ((s != NULL) ? s->id : "(null)"));
/* screens have not been created or no screen given ... */ /* screens have not been created or no screen given ... */
@@ -616,33 +617,33 @@ menuscreen_add_screen (Screen * s)
return; return;
/* Create a menu entry for the screen */ /* Create a menu entry for the screen */
m = menu_create (s->id, NULL, ((s->name != NULL) ? s->name : s->id), s->client); m = menu_create(s->id, NULL, ((s->name != NULL) ? s->name : s->id), s->client);
menu_set_association(m, s); menu_set_association(m, s);
menu_add_item (screens_menu, m); menu_add_item(screens_menu, m);
/* And add some items for it... */ /* And add some items for it... */
mi = menuitem_create_action ("", NULL, "(don't work yet)", s->client, MENURESULT_NONE); mi = menuitem_create_action("", NULL, "(don't work yet)", s->client, MENURESULT_NONE);
menu_add_item (m, mi); menu_add_item(m, mi);
mi = menuitem_create_action ("", NULL, "To Front", s->client, MENURESULT_QUIT); mi = menuitem_create_action("", NULL, "To Front", s->client, MENURESULT_QUIT);
menu_add_item (m, mi); menu_add_item(m, mi);
mi = menuitem_create_checkbox ("", NULL, "Visible", s->client, false, true); mi = menuitem_create_checkbox("", NULL, "Visible", s->client, false, true);
menu_add_item (m, mi); menu_add_item(m, mi);
mi = menuitem_create_numeric ("", NULL, "Duration", s->client, 2, 3600, s->duration); mi = menuitem_create_numeric("", NULL, "Duration", s->client, 2, 3600, s->duration);
menu_add_item (m, mi); menu_add_item(m, mi);
mi = menuitem_create_ring ("", NULL, "Priority", s->client, mi = menuitem_create_ring("", NULL, "Priority", s->client,
"Hidden\tBackground\tForeground\tAlert\tInput", s->priority); "Hidden\tBackground\tForeground\tAlert\tInput", s->priority);
menu_add_item (m, mi); menu_add_item(m, mi);
} }
void void
menuscreen_remove_screen (Screen * s) menuscreen_remove_screen(Screen *s)
{ {
debug (RPT_DEBUG, "%s( s=[%s] )", __FUNCTION__, debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__,
(s != NULL) ? s->id : "(NULL)"); (s != NULL) ? s->id : "(NULL)");
/* allow to remove the menuscreen itself */ /* allow to remove the menuscreen itself */
@@ -650,36 +651,36 @@ menuscreen_remove_screen (Screen * s)
return; return;
if (screens_menu) { if (screens_menu) {
Menu * m = menu_find_item (screens_menu, s->id, false); Menu *m = menu_find_item(screens_menu, s->id, false);
menu_remove_item (screens_menu, m); menu_remove_item(screens_menu, m);
menuitem_destroy (m); menuitem_destroy(m);
} }
} }
int int
menuscreen_goto (Menu * menu) menuscreen_goto(Menu *menu)
{ {
debug (RPT_DEBUG, "%s( m=[%s] ): active_menuitem=[%s]", debug(RPT_DEBUG, "%s(m=[%s]): active_menuitem=[%s]",
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)", __FUNCTION__, (menu != NULL) ? menu->id : "(NULL)",
(active_menuitem != NULL) ? active_menuitem->id : "(NULL)"); (active_menuitem != NULL) ? active_menuitem->id : "(NULL)");
menuscreen_switch_item (menu); menuscreen_switch_item(menu);
return 0; return 0;
} }
/** sets custom main menu. Use NULL pointer to reset it to the "real" main /** sets custom main menu. Use NULL pointer to reset it to the "real" main
* menu. */ * menu. */
int int
menuscreen_set_main (Menu * menu) menuscreen_set_main(Menu *menu)
{ {
debug (RPT_DEBUG, "%s( m=[%s] )", debug(RPT_DEBUG, "%s(m=[%s])",
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)"); __FUNCTION__, (menu != NULL) ? menu->id : "(NULL)");
custom_main_menu = menu; custom_main_menu = menu;
return 0; return 0;
} }
Menu* Menu *
menuscreen_get_main() menuscreen_get_main(void)
{ {
return custom_main_menu ? custom_main_menu : main_menu; return custom_main_menu ? custom_main_menu : main_menu;
} }
+12 -12
View File
@@ -20,42 +20,42 @@
#include "menuitem.h" #include "menuitem.h"
#include "screen.h" #include "screen.h"
extern Screen * menuscreen; extern Screen *menuscreen;
extern Menu * main_menu; extern Menu *main_menu;
int menuscreens_init(); int menuscreens_init(void);
int menuscreens_shutdown(); int menuscreens_shutdown(void);
/** This function indicates to the input part whether this key was the /** This function indicates to the input part whether this key was the
* reserved menu key. * reserved menu key.
*/ */
bool is_menu_key (const char * key); bool is_menu_key(const char *key);
/** Meant for other parts of the program to inform the menuscreen that the /** Meant for other parts of the program to inform the menuscreen that the
* item is about to be removed. * item is about to be removed.
*/ */
void menuscreen_inform_item_destruction (MenuItem * item); void menuscreen_inform_item_destruction(MenuItem *item);
/** Meant for other parts of the program to inform the menuscreen that some /** Meant for other parts of the program to inform the menuscreen that some
* properties of the item have been modified. * properties of the item have been modified.
*/ */
void menuscreen_inform_item_modified (MenuItem * item); void menuscreen_inform_item_modified(MenuItem *item);
/** This handler handles the keypresses for the menu. /** This handler handles the keypresses for the menu.
*/ */
void menuscreen_key_handler (const char *key); void menuscreen_key_handler(const char *key);
/** Adds a menu for the given screen */ /** Adds a menu for the given screen */
void menuscreen_add_screen (Screen * s); void menuscreen_add_screen(Screen *s);
/** Removes the menu of the given screen */ /** Removes the menu of the given screen */
void menuscreen_remove_screen (Screen * s); void menuscreen_remove_screen(Screen *s);
/** switches to menu. */ /** switches to menu. */
int menuscreen_goto (Menu * menu); int menuscreen_goto(Menu *menu);
/** sets custom_main_menu. */ /** sets custom_main_menu. */
int menuscreen_set_main (Menu * menu); int menuscreen_set_main(Menu *menu);
#endif #endif
+16 -16
View File
@@ -48,7 +48,7 @@ static inline int is_closing_quote(char x, char q) {
} }
static int parse_message (const char *str, Client *c) static int parse_message(const char *str, Client *c)
{ {
typedef enum { ST_INITIAL, ST_WHITESPACE, ST_ARGUMENT, ST_FINAL } State; typedef enum { ST_INITIAL, ST_WHITESPACE, ST_ARGUMENT, ST_FINAL } State;
State state = ST_INITIAL; State state = ST_INITIAL;
@@ -62,14 +62,14 @@ static int parse_message (const char *str, Client *c)
int argpos = 0; int argpos = 0;
CommandFunc function = NULL; CommandFunc function = NULL;
debug( RPT_DEBUG, "%s( str=\"%.120s\", client=[%d] )", __FUNCTION__, str, c->sock ); debug(RPT_DEBUG, "%s(str=\"%.120s\", client=[%d])", __FUNCTION__, str, c->sock);
/* We will create a list of strings that is shorter or equally long as /* We will create a list of strings that is shorter or equally long as
* the original string str. * the original string str.
*/ */
arg_space = malloc(strlen(str)+1); arg_space = malloc(strlen(str)+1);
if (arg_space == NULL) { if (arg_space == NULL) {
report (RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); report(RPT_ERR, "%s: Could not allocate memory", __FUNCTION__);
sock_send_error(c->sock, "error allocating memory!\n"); sock_send_error(c->sock, "error allocating memory!\n");
} }
@@ -109,7 +109,7 @@ static int parse_message (const char *str, Client *c)
/* We solve quoted chars here right away */ /* We solve quoted chars here right away */
const char escape_chars[] = "nrt"; const char escape_chars[] = "nrt";
const char escape_trans[] = "\n\r\t"; const char escape_trans[] = "\n\r\t";
char *p = strchr( escape_chars, str[pos] ); char *p = strchr(escape_chars, str[pos]);
/* Is it wise to have the characters \n, \r & \t expanded ? /* Is it wise to have the characters \n, \r & \t expanded ?
* Can the displays deal with them ? * Can the displays deal with them ?
@@ -183,7 +183,7 @@ static int parse_message (const char *str, Client *c)
if (error) { if (error) {
sock_send_error(c->sock, "Could not parse command\n"); sock_send_error(c->sock, "Could not parse command\n");
free( arg_space ); free(arg_space);
return 0; return 0;
} }
@@ -198,37 +198,37 @@ static int parse_message (const char *str, Client *c)
function = get_command_function(argv[0]); function = get_command_function(argv[0]);
if (function != NULL) { if (function != NULL) {
error = function (c, argc, argv); error = function(c, argc, argv);
if (error) { if (error) {
sock_printf_error(c->sock, "Function returned error \"%.40s\"\n", argv[0]); sock_printf_error(c->sock, "Function returned error \"%.40s\"\n", argv[0]);
report( RPT_WARNING, "Command function returned an error after command from client on socket %d: %.40s", c->sock, str ); report(RPT_WARNING, "Command function returned an error after command from client on socket %d: %.40s", c->sock, str);
} }
} }
else { else {
sock_printf_error(c->sock, "Invalid command \"%.40s\"\n", argv[0]); sock_printf_error(c->sock, "Invalid command \"%.40s\"\n", argv[0]);
report( RPT_WARNING, "Invalid command from client on socket %d: %.40s", c->sock, str ); report(RPT_WARNING, "Invalid command from client on socket %d: %.40s", c->sock, str);
} }
free( arg_space ); free(arg_space);
return 0; return 0;
} }
int int
parse_all_client_messages () parse_all_client_messages(void)
{ {
Client * c; Client *c;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
for (c = clients_getfirst(); c != NULL; c = clients_getnext()) { for (c = clients_getfirst(); c != NULL; c = clients_getnext()) {
char * str; char *str;
/* And parse all its messages...*/ /* And parse all its messages...*/
/*debug(RPT_DEBUG, "parse: Getting messages...");*/ /*debug(RPT_DEBUG, "parse: Getting messages...");*/
for (str = client_get_message (c); str != NULL; str = client_get_message (c)) { for (str = client_get_message(c); str != NULL; str = client_get_message(c)) {
parse_message (str, c); parse_message(str, c);
free (str); free(str);
} }
} }
return 0; return 0;
+1 -1
View File
@@ -13,6 +13,6 @@
#define PARSE_H #define PARSE_H
// This should be pretty self-explanatory... // This should be pretty self-explanatory...
int parse_all_client_messages (); int parse_all_client_messages(void);
#endif #endif
+69 -69
View File
@@ -44,22 +44,22 @@ static int heartbeat_fallback = HEARTBEAT_ON; /* If no heartbeat setting has bee
int backlight = BACKLIGHT_OPEN; int backlight = BACKLIGHT_OPEN;
static int backlight_fallback = BACKLIGHT_ON; /* If no backlight setting has been set at all */ static int backlight_fallback = BACKLIGHT_ON; /* If no backlight setting has been set at all */
int output_state = 0; int output_state = 0;
char * server_msg_text; char *server_msg_text;
int server_msg_expire = 0; int server_msg_expire = 0;
static int reset; static int reset;
#define BUFSIZE 1024 #define BUFSIZE 1024
static int render_frame (LinkedList * list, char fscroll, int left, int top, int right, int bottom, int fwid, int fhgt, int fspeed, long int timer); static int render_frame(LinkedList *list, char fscroll, int left, int top, int right, int bottom, int fwid, int fhgt, int fspeed, long int timer);
int int
render_screen (Screen * s, long int timer) render_screen(Screen *s, long int timer)
{ {
static Screen * old_s = NULL; static Screen *old_s = NULL;
int tmp_state = 0; int tmp_state = 0;
debug(RPT_DEBUG, "%s( screen=[%.40s], timer=%d ) ==== START RENDERING ====", __FUNCTION__, s->id, timer ); debug(RPT_DEBUG, "%s(screen=[%.40s], timer=%d) ==== START RENDERING ====", __FUNCTION__, s->id, timer);
reset = 1; reset = 1;
@@ -71,7 +71,7 @@ render_screen (Screen * s, long int timer)
old_s = s; old_s = s;
/* Clear the LCD screen... */ /* Clear the LCD screen... */
drivers_clear (); drivers_clear();
/* FIXME drivers_backlight -- /* FIXME drivers_backlight --
* *
@@ -94,32 +94,32 @@ render_screen (Screen * s, long int timer)
/* NOTE: dirty stripping of other options... */ /* NOTE: dirty stripping of other options... */
/* Backlight flash: check timer and flip backlight as appropriate */ /* Backlight flash: check timer and flip backlight as appropriate */
if (tmp_state & BACKLIGHT_FLASH) { if (tmp_state & BACKLIGHT_FLASH) {
drivers_backlight ( drivers_backlight(
( (
(tmp_state & BACKLIGHT_ON) (tmp_state & BACKLIGHT_ON)
^ ((timer & 7) == 7) ^ ((timer & 7) == 7)
) ? BACKLIGHT_ON : BACKLIGHT_OFF ); ) ? BACKLIGHT_ON : BACKLIGHT_OFF);
/* Backlight blink: check timer and flip backlight as appropriate */ /* Backlight blink: check timer and flip backlight as appropriate */
} }
else if (tmp_state & BACKLIGHT_BLINK) { else if (tmp_state & BACKLIGHT_BLINK) {
drivers_backlight ( drivers_backlight(
( (
(tmp_state & BACKLIGHT_ON) (tmp_state & BACKLIGHT_ON)
^ ((timer & 14) == 14) ^ ((timer & 14) == 14)
) ? BACKLIGHT_ON : BACKLIGHT_OFF ); ) ? BACKLIGHT_ON : BACKLIGHT_OFF);
} else { } else {
/* Simple: Only send lowest bit then...*/ /* Simple: Only send lowest bit then...*/
drivers_backlight (tmp_state & BACKLIGHT_ON); drivers_backlight(tmp_state & BACKLIGHT_ON);
} }
/* Output ports from LCD - outputs depend on the current screen */ /* Output ports from LCD - outputs depend on the current screen */
drivers_output (output_state); drivers_output(output_state);
/* Draw a frame... */ /* Draw a frame... */
render_frame (s->widgetlist, 'v', 0, 0, display_props->width, display_props->height, s->width, s->height, (((s->duration / s->height) < 1) ? 1 : (s->duration / s->height)), timer); render_frame(s->widgetlist, 'v', 0, 0, display_props->width, display_props->height, s->width, s->height, (((s->duration / s->height) < 1) ? 1 : (s->duration / s->height)), timer);
/* Set the cursor */ /* Set the cursor */
drivers_cursor (s->cursor_x, s->cursor_y, s->cursor); drivers_cursor(s->cursor_x, s->cursor_y, s->cursor);
if (heartbeat != HEARTBEAT_OPEN) { if (heartbeat != HEARTBEAT_OPEN) {
tmp_state = heartbeat; tmp_state = heartbeat;
@@ -133,19 +133,19 @@ render_screen (Screen * s, long int timer)
drivers_heartbeat(tmp_state); drivers_heartbeat(tmp_state);
/* If there is an server message that is not expired, display it */ /* If there is an server message that is not expired, display it */
if( server_msg_expire > 0 ) { if (server_msg_expire > 0) {
drivers_string( display_props->width - strlen(server_msg_text) + 1, drivers_string(display_props->width - strlen(server_msg_text) + 1,
display_props->height, server_msg_text ); display_props->height, server_msg_text);
server_msg_expire --; server_msg_expire --;
if( server_msg_expire == 0 ) { if (server_msg_expire == 0) {
free( server_msg_text ); free(server_msg_text);
} }
} }
/* flush display out, frame and all... */ /* flush display out, frame and all... */
drivers_flush (); drivers_flush();
debug(RPT_DEBUG, "==== END RENDERING ====" ); debug(RPT_DEBUG, "==== END RENDERING ====");
return 0; return 0;
} }
@@ -154,7 +154,7 @@ render_screen (Screen * s, long int timer)
/* Best thing to do is to remove support for frames... but anyway... */ /* Best thing to do is to remove support for frames... but anyway... */
/* */ /* */
static int static int
render_frame (LinkedList * list, render_frame(LinkedList *list,
char fscroll, /* direction of scrolling */ char fscroll, /* direction of scrolling */
int left, /* left edge of frame */ int left, /* left edge of frame */
int top, /* top edge of frame */ int top, /* top edge of frame */
@@ -177,10 +177,10 @@ render_frame (LinkedList * list,
int str_length = BUFSIZE-1; int str_length = BUFSIZE-1;
int reset = 1; int reset = 1;
debug( RPT_DEBUG, "%s( list=%p, fscroll='%c', left=%d, top=%d, " debug(RPT_DEBUG, "%s(list=%p, fscroll='%c', left=%d, top=%d, "
"right=%d, bottom=%d, fwid=%d, fhgt=%d, fspeed=%d, timer=%d )", "right=%d, bottom=%d, fwid=%d, fhgt=%d, fspeed=%d, timer=%d)",
__FUNCTION__, list, fscroll, left,top, right, bottom, __FUNCTION__, list, fscroll, left,top, right, bottom,
fwid, fhgt, fspeed, timer ); fwid, fhgt, fspeed, timer);
/* return on no data or illegal height */ /* return on no data or illegal height */
if (!list || (fhgt <= 0)) if (!list || (fhgt <= 0))
@@ -203,12 +203,12 @@ render_frame (LinkedList * list,
} }
/* reset widget list */ /* reset widget list */
LL_Rewind (list); LL_Rewind(list);
/* loop over all widgets */ /* loop over all widgets */
do { do {
char str[BUFSIZE]; /* scratch buffer */ char str[BUFSIZE]; /* scratch buffer */
Widget *w = (Widget *) LL_Get (list); Widget *w = (Widget *) LL_Get(list);
if (!w) if (!w)
return -1; return -1;
@@ -220,9 +220,9 @@ render_frame (LinkedList * list,
(w->y <= vis_height + fy) && (w->y > fy)) { (w->y <= vis_height + fy) && (w->y > fy)) {
w->x = min(w->x, vis_width); w->x = min(w->x, vis_width);
str_length = min(vis_width - w->x + 1, BUFSIZE - 1); str_length = min(vis_width - w->x + 1, BUFSIZE - 1);
strncpy (str, w->text, str_length); strncpy(str, w->text, str_length);
str[str_length] = 0; str[str_length] = 0;
drivers_string (w->x + left, w->y + top - fy, str); drivers_string(w->x + left, w->y + top - fy, str);
} }
break; break;
case WID_HBAR: case WID_HBAR:
@@ -233,17 +233,17 @@ render_frame (LinkedList * list,
(w->y <= vis_height + fy) && (w->y > fy)) { (w->y <= vis_height + fy) && (w->y > fy)) {
if (w->length > 0) { if (w->length > 0) {
if ((w->length / display_props->cellwidth) < vis_width - w->x + 1) { if ((w->length / display_props->cellwidth) < vis_width - w->x + 1) {
/*was: drivers_hbar (w->x + left, w->y + top - fy, w->length); */ /*was: drivers_hbar(w->x + left, w->y + top - fy, w->length); */
/* improvised len and promille */ /* improvised len and promille */
int full_len = display_props->width - w->x - left + 1; int full_len = display_props->width - w->x - left + 1;
int promille = (long) 1000 * w->length / ( display_props->cellwidth * full_len ); int promille = (long) 1000 * w->length / (display_props->cellwidth * full_len);
drivers_hbar (w->x + left, w->y + top - fy, full_len, promille, BAR_PATTERN_FILLED); drivers_hbar(w->x + left, w->y + top - fy, full_len, promille, BAR_PATTERN_FILLED);
} }
else { else {
/*was: drivers_hbar (w->x + left, w->y + top - fy, wid * display_props->cellwidth); */ /*was: drivers_hbar(w->x + left, w->y + top - fy, wid * display_props->cellwidth); */
/* Improvised len and promille while we have the old widget language */ /* Improvised len and promille while we have the old widget language */
int full_len = ( display_props->width - w->x - left + 1 ); int full_len = (display_props->width - w->x - left + 1);
drivers_hbar (w->x + left, w->y + top - fy, full_len, 1000, BAR_PATTERN_FILLED); drivers_hbar(w->x + left, w->y + top - fy, full_len, 1000, BAR_PATTERN_FILLED);
} }
} else if (w->length < 0) { } else if (w->length < 0) {
/* TODO: Rearrange stuff to get left-extending /* TODO: Rearrange stuff to get left-extending
@@ -263,7 +263,7 @@ render_frame (LinkedList * list,
/* Improvised len and promille while we have the old widget language */ /* Improvised len and promille while we have the old widget language */
int full_len = display_props->height; int full_len = display_props->height;
int promille = (long) 1000 * w->length / display_props->cellheight / full_len; int promille = (long) 1000 * w->length / display_props->cellheight / full_len;
drivers_vbar (w->x, display_props->height, full_len, promille, BAR_PATTERN_FILLED); drivers_vbar(w->x, display_props->height, full_len, promille, BAR_PATTERN_FILLED);
} else if (w->length < 0) { } else if (w->length < 0) {
/* TODO: Rearrange stuff to get down-extending /* TODO: Rearrange stuff to get down-extending
* vbars to draw correctly... * vbars to draw correctly...
@@ -274,7 +274,7 @@ render_frame (LinkedList * list,
} }
break; break;
case WID_ICON: case WID_ICON:
drivers_icon (w->x, w->y, w->length); drivers_icon(w->x, w->y, w->length);
break; break;
case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/ case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/
@@ -283,13 +283,13 @@ render_frame (LinkedList * list,
if (vis_width < 8) if (vis_width < 8)
break; break;
drivers_icon (w->x + left, w->y + top, ICON_BLOCK_FILLED); drivers_icon(w->x + left, w->y + top, ICON_BLOCK_FILLED);
drivers_icon (w->x + left + 1, w->y + top, ICON_BLOCK_FILLED); drivers_icon(w->x + left + 1, w->y + top, ICON_BLOCK_FILLED);
length = strlen (w->text); length = strlen(w->text);
length = min(length, BUFSIZE - 1); length = min(length, BUFSIZE - 1);
if (length <= vis_width - 6) { if (length <= vis_width - 6) {
strncpy (str, w->text, length); strncpy(str, w->text, length);
str[length] = 0; str[length] = 0;
x = length + 5; x = length + 5;
} else /* Scroll the title, if it doesn't fit...*/ } else /* Scroll the title, if it doesn't fit...*/
@@ -307,15 +307,15 @@ render_frame (LinkedList * list,
x = (length - (vis_width - 6)) - x; x = (length - (vis_width - 6)) - x;
str_length = abs(vis_width - 6); str_length = abs(vis_width - 6);
str_length = min(str_length, BUFSIZE -1); str_length = min(str_length, BUFSIZE -1);
strncpy (str, w->text + x, str_length); strncpy(str, w->text + x, str_length);
str[str_length] = 0; str[str_length] = 0;
x = vis_width - 1; x = vis_width - 1;
} }
drivers_string (w->x + 3 + left, w->y + top, str); drivers_string(w->x + 3 + left, w->y + top, str);
for (; x<=vis_width; x++) { for (; x<=vis_width; x++) {
drivers_icon (w->x + x - 1 + left, w->y + top, ICON_BLOCK_FILLED); drivers_icon(w->x + x - 1 + left, w->y + top, ICON_BLOCK_FILLED);
} }
break; break;
@@ -336,10 +336,10 @@ render_frame (LinkedList * list,
* last letter in the string... (1-off error?) * last letter in the string... (1-off error?)
*/ */
case 'm': // Marquee case 'm': // Marquee
length = strlen (w->text); length = strlen(w->text);
if (length <= screen_width) { if (length <= screen_width) {
/* it fits within the box, just render it */ /* it fits within the box, just render it */
drivers_string (w->left, w->top, w->text); drivers_string(w->left, w->top, w->text);
} else { } else {
int necessaryTimeUnits = 0; int necessaryTimeUnits = 0;
@@ -355,11 +355,11 @@ render_frame (LinkedList * list,
if (offset <= length) { if (offset <= length) {
int room = screen_width - (length - offset); int room = screen_width - (length - offset);
strncpy (str, &w->text[offset], screen_width); strncpy(str, &w->text[offset], screen_width);
// if there's more room, restart at the beginning // if there's more room, restart at the beginning
if (room > 0) { if (room > 0) {
strncat (str, w->text, room); strncat(str, w->text, room);
} }
str[screen_width] = '\0'; str[screen_width] = '\0';
@@ -368,14 +368,14 @@ render_frame (LinkedList * list,
} else { } else {
str[0] = '\0'; str[0] = '\0';
} }
drivers_string (w->left, w->top, str); drivers_string(w->left, w->top, str);
} }
break; break;
case 'h': case 'h':
length = strlen (w->text) + 1; length = strlen(w->text) + 1;
if (length <= screen_width) { if (length <= screen_width) {
/* it fits within the box, just render it */ /* it fits within the box, just render it */
drivers_string (w->left, w->top, w->text); drivers_string(w->left, w->top, w->text);
} else { } else {
int effLength = length - screen_width; int effLength = length - screen_width;
int necessaryTimeUnits = 0; int necessaryTimeUnits = 0;
@@ -405,13 +405,13 @@ render_frame (LinkedList * list,
offset = 0; offset = 0;
} }
if (offset <= length) { if (offset <= length) {
strncpy (str, &((w->text)[offset]), screen_width); strncpy(str, &((w->text)[offset]), screen_width);
str[screen_width] = '\0'; str[screen_width] = '\0';
/*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset); */ /*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset); */
} else { } else {
str[0] = '\0'; str[0] = '\0';
} }
drivers_string (w->left, w->top, str); drivers_string(w->left, w->top, str);
} }
break; break;
/* FIXME: Vert scrollers don't always seem to scroll */ /* FIXME: Vert scrollers don't always seem to scroll */
@@ -421,10 +421,10 @@ render_frame (LinkedList * list,
{ {
int i = 0; int i = 0;
length = strlen (w->text); length = strlen(w->text);
if (length <= screen_width) { if (length <= screen_width) {
/* no scrolling required... */ /* no scrolling required... */
drivers_string (w->left, w->top, w->text); drivers_string(w->left, w->top, w->text);
} else { } else {
int lines_required = (length / screen_width) int lines_required = (length / screen_width)
+ (length % screen_width ? 1 : 0); + (length % screen_width ? 1 : 0);
@@ -433,7 +433,7 @@ render_frame (LinkedList * list,
if (lines_required <= available_lines) { if (lines_required <= available_lines) {
/* easy...*/ /* easy...*/
for (i = 0; i < lines_required; i++) { for (i = 0; i < lines_required; i++) {
strncpy (str, &((w->text)[i * screen_width]), screen_width); strncpy(str, &((w->text)[i * screen_width]), screen_width);
str[screen_width] = '\0'; str[screen_width] = '\0';
drivers_string (w->left, w->top + i, str); drivers_string (w->left, w->top + i, str);
} }
@@ -470,11 +470,11 @@ render_frame (LinkedList * list,
} }
/*debug(RPT_DEBUG, "rendering begin: %d timer: %d effLines: %d",begin,timer,effLines); */ /*debug(RPT_DEBUG, "rendering begin: %d timer: %d effLines: %d",begin,timer,effLines); */
for (i = begin; i < begin + available_lines; i++) { for (i = begin; i < begin + available_lines; i++) {
strncpy (str, &((w->text)[i * (screen_width)]), screen_width); strncpy(str, &((w->text)[i * (screen_width)]), screen_width);
str[screen_width] = '\0'; str[screen_width] = '\0';
/*debug(RPT_DEBUG, "rendering: '%s' of %s", */ /*debug(RPT_DEBUG, "rendering: '%s' of %s", */
/*str,w->text); */ /*str,w->text); */
drivers_string (w->left, w->top + (i - begin), str); drivers_string(w->left, w->top + (i - begin), str);
} }
} }
} }
@@ -494,7 +494,7 @@ render_frame (LinkedList * list,
int new_bottom = min(top + w->bottom, bottom); int new_bottom = min(top + w->bottom, bottom);
if ((new_left < right) && (new_top < bottom)) /* Render only if it's visible...*/ if ((new_left < right) && (new_top < bottom)) /* Render only if it's visible...*/
render_frame (w->frame_screen->widgetlist, w->length, new_left, new_top, new_right, new_bottom, w->width, w->height, w->speed, timer); render_frame(w->frame_screen->widgetlist, w->length, new_left, new_top, new_right, new_bottom, w->width, w->height, w->speed, timer);
} }
break; break;
case WID_NUM: /* FIXME: doesn't work in frames...*/ case WID_NUM: /* FIXME: doesn't work in frames...*/
@@ -503,37 +503,37 @@ render_frame (LinkedList * list,
if (reset) { if (reset) {
reset = 0; reset = 0;
} }
drivers_num (w->x + left, w->y); drivers_num(w->x + left, w->y);
} }
break; break;
case WID_NONE: case WID_NONE:
default: default:
break; break;
} }
} while (LL_Next (list) == 0); } while (LL_Next(list) == 0);
return 0; return 0;
} }
int int
server_msg( const char * text, int expire ) server_msg(const char *text, int expire)
{ {
debug( RPT_DEBUG, "%s( text=\"%.40s\", expire=%d )", __FUNCTION__, text, expire ); debug(RPT_DEBUG, "%s(text=\"%.40s\", expire=%d)", __FUNCTION__, text, expire);
if( strlen(text) > 15 || expire <= 0 ) { if (strlen(text) > 15 || expire <= 0) {
return -1; return -1;
} }
/* Still a message active ? */ /* Still a message active ? */
if( server_msg_expire > 0 ) { if (server_msg_expire > 0) {
free( server_msg_text ); free(server_msg_text);
} }
/* Store new message */ /* Store new message */
server_msg_text = malloc( strlen(text) + 3 ); server_msg_text = malloc(strlen(text) + 3);
strcpy( server_msg_text, "| " ); strcpy(server_msg_text, "| ");
strcat( server_msg_text, text ); strcat(server_msg_text, text);
server_msg_expire = expire; server_msg_expire = expire;
+2 -2
View File
@@ -34,10 +34,10 @@ extern int heartbeat;
extern int backlight; extern int backlight;
extern int output_state; extern int output_state;
int render_screen (Screen * s, long int timer); int render_screen(Screen *s, long int timer);
/* Renders the given screen. */ /* Renders the given screen. */
int server_msg( const char * text, int expire ); int server_msg(const char *text, int expire);
/* Displays a short message in a corner. Message must be shorter /* Displays a short message in a corner. Message must be shorter
* than 16 chars. */ * than 16 chars. */
+33 -33
View File
@@ -43,19 +43,19 @@ char *pri_names[] = {
}; };
Screen * Screen *
screen_create (char * id, Client * client) screen_create(char *id, Client *client)
{ {
Screen *s; Screen *s;
debug( RPT_DEBUG, "%s( id=\"%.40s\", client=[%d] )", __FUNCTION__, id, (client?client->sock:-1)); debug(RPT_DEBUG, "%s(id=\"%.40s\", client=[%d])", __FUNCTION__, id, (client?client->sock:-1));
s = malloc (sizeof (Screen)); s = malloc(sizeof(Screen));
if (!s) { if (!s) {
report(RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
return NULL; return NULL;
} }
if (!id) { if (!id) {
report (RPT_ERR, "%s: Need id string", __FUNCTION__); report(RPT_ERR, "%s: Need id string", __FUNCTION__);
return NULL; return NULL;
} }
/* Client can be NULL for serverscreens and other client-less screens */ /* Client can be NULL for serverscreens and other client-less screens */
@@ -83,100 +83,100 @@ screen_create (char * id, Client * client)
s->cursor_x = 1; s->cursor_x = 1;
s->cursor_y = 1; s->cursor_y = 1;
s->widgetlist = LL_new (); s->widgetlist = LL_new();
if (!s->widgetlist) { if (!s->widgetlist) {
report(RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
return NULL; return NULL;
} }
menuscreen_add_screen (s); menuscreen_add_screen(s);
return s; return s;
} }
int int
screen_destroy (Screen * s) screen_destroy(Screen *s)
{ {
Widget *w; Widget *w;
debug( RPT_DEBUG, "%s( s=[%.40s] )", __FUNCTION__, s->id ); debug(RPT_DEBUG, "%s(s=[%.40s])", __FUNCTION__, s->id);
menuscreen_remove_screen (s); menuscreen_remove_screen(s);
screenlist_remove (s); screenlist_remove(s);
for (w=LL_GetFirst(s->widgetlist); w; w=LL_GetNext(s->widgetlist)) { for (w = LL_GetFirst(s->widgetlist); w; w = LL_GetNext(s->widgetlist)) {
/* Free a widget...*/ /* Free a widget...*/
widget_destroy (w); widget_destroy(w);
} }
LL_Destroy (s->widgetlist); LL_Destroy(s->widgetlist);
if (s->id) if (s->id)
free (s->id); free(s->id);
if (s->name) if (s->name)
free (s->name); free(s->name);
free (s); free(s);
return 0; return 0;
} }
int int
screen_add_widget (Screen * s, Widget * w) screen_add_widget(Screen *s, Widget *w)
{ {
debug( RPT_DEBUG, "%s( s=[%.40s], widget=[%.40s] )", __FUNCTION__, s->id, w->id ); debug(RPT_DEBUG, "%s(s=[%.40s], widget=[%.40s])", __FUNCTION__, s->id, w->id);
LL_Push (s->widgetlist, (void *) w); LL_Push(s->widgetlist, (void *) w);
return 0; return 0;
} }
int int
screen_remove_widget (Screen * s, Widget * w) screen_remove_widget(Screen *s, Widget *w)
{ {
debug( RPT_DEBUG, "%s( s=[%.40s], widget=[%.40s] )", __FUNCTION__, s->id, w->id ); debug(RPT_DEBUG, "%s(s=[%.40s], widget=[%.40s])", __FUNCTION__, s->id, w->id);
LL_Remove (s->widgetlist, (void *) w); LL_Remove(s->widgetlist, (void *) w);
return 0; return 0;
} }
Widget * Widget *
screen_find_widget (Screen * s, char *id) screen_find_widget(Screen *s, char *id)
{ {
Widget * w; Widget *w;
if (!s) if (!s)
return NULL; return NULL;
if (!id) if (!id)
return NULL; return NULL;
debug( RPT_DEBUG, "%s( s=[%.40s], id=\"%.40s\" )", __FUNCTION__, s->id, id ); debug(RPT_DEBUG, "%s(s=[%.40s], id=\"%.40s\")", __FUNCTION__, s->id, id);
for ( w=LL_GetFirst(s->widgetlist); w; w=LL_GetNext(s->widgetlist) ) { for (w = LL_GetFirst(s->widgetlist); w; w = LL_GetNext(s->widgetlist)) {
if (0 == strcmp (w->id, id)) { if (0 == strcmp(w->id, id)) {
debug (RPT_DEBUG, "%s: Found %s", __FUNCTION__, id); debug(RPT_DEBUG, "%s: Found %s", __FUNCTION__, id);
return w; return w;
} }
/* Search subscreens recursively */ /* Search subscreens recursively */
if (w->type == WID_FRAME) { if (w->type == WID_FRAME) {
w = widget_search_subs (w, id); w = widget_search_subs(w, id);
if (w) if (w)
return w; return w;
} }
} }
debug (RPT_DEBUG, "%s: Not found", __FUNCTION__); debug(RPT_DEBUG, "%s: Not found", __FUNCTION__);
return NULL; return NULL;
} }
Priority Priority
screen_pri_name_to_pri (char * priname) screen_pri_name_to_pri(char *priname)
{ {
Priority pri = WID_NONE; Priority pri = WID_NONE;
int i; int i;
for (i = 0; pri_names[i]; i++) { for (i = 0; pri_names[i]; i++) {
if (strcmp (pri_names[i], priname) == 0) { if (strcmp(pri_names[i], priname) == 0) {
pri = i; pri = i;
break; /* it's valid: skip out...*/ break; /* it's valid: skip out...*/
} }
@@ -185,7 +185,7 @@ screen_pri_name_to_pri (char * priname)
} }
char * char *
screen_pri_to_pri_name (Priority pri) screen_pri_to_pri_name(Priority pri)
{ {
return pri_names[pri]; return pri_names[pri];
} }
+9 -9
View File
@@ -51,26 +51,26 @@ extern int default_priority ;
#include "client.h" #include "client.h"
/* Creates a new screen */ /* Creates a new screen */
Screen * screen_create (char * id, Client * client); Screen *screen_create(char *id, Client *client);
/* Destroys a screen */ /* Destroys a screen */
int screen_destroy (Screen * s); int screen_destroy(Screen *s);
/* Add a widget to a screen */ /* Add a widget to a screen */
int screen_add_widget (Screen * s, Widget * w); int screen_add_widget(Screen *s, Widget *w);
/* Remove a widget from a screen (does not destroy it) */ /* Remove a widget from a screen (does not destroy it) */
int screen_remove_widget (Screen * s, Widget * w); int screen_remove_widget(Screen *s, Widget *w);
/* List functions */ /* List functions */
static inline Widget * screen_getfirst_widget (Screen * s) static inline Widget *screen_getfirst_widget(Screen *s)
{ {
return (Widget *) ((s != NULL) return (Widget *) ((s != NULL)
? LL_GetFirst(s->widgetlist) ? LL_GetFirst(s->widgetlist)
: NULL); : NULL);
} }
static inline Widget * screen_getnext_widget (Screen * s) static inline Widget *screen_getnext_widget(Screen *s)
{ {
return (Widget *) ((s != NULL) return (Widget *) ((s != NULL)
? LL_GetNext(s->widgetlist) ? LL_GetNext(s->widgetlist)
@@ -79,10 +79,10 @@ static inline Widget * screen_getnext_widget (Screen * s)
/* Find a widget in a screen */ /* Find a widget in a screen */
Widget *screen_find_widget (Screen * s, char *id); Widget *screen_find_widget(Screen *s, char *id);
/* Convert priority names to priority and vv */ /* Convert priority names to priority and vv */
Priority screen_pri_name_to_pri (char * pri_name); Priority screen_pri_name_to_pri(char *pri_name);
char * screen_pri_to_pri_name (Priority pri); char *screen_pri_to_pri_name(Priority pri);
#endif #endif
+49 -49
View File
@@ -26,20 +26,20 @@
#include "main.h" /* for timer */ #include "main.h" /* for timer */
/* Local functions */ /* Local functions */
int compare_priority (void *one, void *two); int compare_priority(void *one, void *two);
bool autorotate = 1; /* If on, INFO and FOREGROUND screens will rotate */ bool autorotate = 1; /* If on, INFO and FOREGROUND screens will rotate */
LinkedList *screenlist = NULL; LinkedList *screenlist = NULL;
Screen * current_screen = NULL; Screen *current_screen = NULL;
long int current_screen_start_time = 0; long int current_screen_start_time = 0;
int int
screenlist_init () screenlist_init(void)
{ {
report (RPT_DEBUG, "%s()", __FUNCTION__); report(RPT_DEBUG, "%s()", __FUNCTION__);
screenlist = LL_new (); screenlist = LL_new();
if (!screenlist) { if (!screenlist) {
report(RPT_ERR, "%s: Error allocating", __FUNCTION__); report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
return -1; return -1;
@@ -49,71 +49,71 @@ screenlist_init ()
int int
screenlist_shutdown () screenlist_shutdown(void)
{ {
report (RPT_DEBUG, "%s()", __FUNCTION__); report(RPT_DEBUG, "%s()", __FUNCTION__);
if( !screenlist ) { if (!screenlist) {
/* Program shutdown before completed startup */ /* Program shutdown before completed startup */
return -1; return -1;
} }
LL_Destroy (screenlist); LL_Destroy(screenlist);
return 0; return 0;
} }
int int
screenlist_add (Screen * s) screenlist_add(Screen *s)
{ {
if (!screenlist) if (!screenlist)
return -1; return -1;
return LL_Push (screenlist, s); return LL_Push(screenlist, s);
} }
int int
screenlist_remove (Screen * s) screenlist_remove(Screen *s)
{ {
debug (RPT_DEBUG, "%s( s=[%.40s] )", __FUNCTION__, s->id); debug(RPT_DEBUG, "%s(s=[%.40s])", __FUNCTION__, s->id);
if (!screenlist) if (!screenlist)
return -1; return -1;
/* Are we trying to remove the current screen ? */ /* Are we trying to remove the current screen ? */
if (s == current_screen) { if (s == current_screen) {
screenlist_goto_next (); screenlist_goto_next();
if (s == current_screen) { if (s == current_screen) {
/* Hmm, no other screen had same priority */ /* Hmm, no other screen had same priority */
void * res = LL_Remove (screenlist, s); void *res = LL_Remove(screenlist, s);
/* And now once more */ /* And now once more */
screenlist_goto_next (); screenlist_goto_next();
return (res == NULL) ? -1 : 0; return (res == NULL) ? -1 : 0;
} }
} }
return (LL_Remove (screenlist, s) == NULL) ? -1 : 0; return (LL_Remove(screenlist, s) == NULL) ? -1 : 0;
} }
void void
screenlist_process () screenlist_process(void)
{ {
Screen * s; Screen *s;
Screen * f; Screen *f;
report (RPT_DEBUG, "%s()", __FUNCTION__); report(RPT_DEBUG, "%s()", __FUNCTION__);
if (!screenlist) if (!screenlist)
return; return;
/* Sort the list acfording to priority class */ /* Sort the list acfording to priority class */
LL_Sort (screenlist, compare_priority); LL_Sort(screenlist, compare_priority);
f = LL_GetFirst(screenlist); f = LL_GetFirst(screenlist);
/**** First we need to check out the current situation. ****/ /**** First we need to check out the current situation. ****/
/* Check whether there is an active screen */ /* Check whether there is an active screen */
s = screenlist_current (); s = screenlist_current();
if (!s) { if (!s) {
/* We have no active screen yet. /* We have no active screen yet.
* Try to switch to the first screen in the list... */ * Try to switch to the first screen in the list... */
@@ -123,7 +123,7 @@ screenlist_process ()
/* There was no screen in the list */ /* There was no screen in the list */
return; return;
} }
screenlist_switch (s); screenlist_switch(s);
return; return;
} }
else { else {
@@ -137,8 +137,8 @@ screenlist_process ()
if (s->timeout <= 0) { if (s->timeout <= 0) {
/* Expired, we can destroy it */ /* Expired, we can destroy it */
report(RPT_DEBUG, "Removing expired screen [%.40s]", s->id); report(RPT_DEBUG, "Removing expired screen [%.40s]", s->id);
client_remove_screen (s->client, s); client_remove_screen(s->client, s);
screen_destroy (s); screen_destroy(s);
} }
} }
} }
@@ -165,14 +165,14 @@ screenlist_process ()
void void
screenlist_switch (Screen * s) screenlist_switch(Screen *s)
{ {
Client * c; Client *c;
char str[256]; char str[256];
if (!s) return; if (!s) return;
report (RPT_DEBUG, "%s( s=[%.40s] )", __FUNCTION__, s->id ); report(RPT_DEBUG, "%s(s=[%.40s])", __FUNCTION__, s->id);
if (s == current_screen) { if (s == current_screen) {
/* Nothing to be done */ /* Nothing to be done */
@@ -183,8 +183,8 @@ screenlist_switch (Screen * s)
c = current_screen->client; c = current_screen->client;
if (c) { if (c) {
/* Tell the client we're not listening any more...*/ /* Tell the client we're not listening any more...*/
snprintf (str, sizeof(str), "ignore %s\n", current_screen->id); snprintf(str, sizeof(str), "ignore %s\n", current_screen->id);
sock_send_string (c->sock, str); sock_send_string(c->sock, str);
} else { } else {
/* It's a server screen, no need to inform it. */ /* It's a server screen, no need to inform it. */
} }
@@ -192,82 +192,82 @@ screenlist_switch (Screen * s)
c = s->client; c = s->client;
if (c) { if (c) {
/* Tell the client we're paying attention...*/ /* Tell the client we're paying attention...*/
snprintf (str, sizeof(str), "listen %s\n", s->id); snprintf(str, sizeof(str), "listen %s\n", s->id);
sock_send_string (c->sock, str); sock_send_string(c->sock, str);
} else { } else {
/* It's a server screen, no need to inform it. */ /* It's a server screen, no need to inform it. */
} }
report (RPT_INFO, "%s: switched to screen [%.40s]", __FUNCTION__, s->id ); report(RPT_INFO, "%s: switched to screen [%.40s]", __FUNCTION__, s->id);
current_screen = s; current_screen = s;
current_screen_start_time = timer; current_screen_start_time = timer;
} }
Screen * Screen *
screenlist_current () screenlist_current(void)
{ {
return current_screen; return current_screen;
} }
int int
screenlist_goto_next () screenlist_goto_next(void)
{ {
Screen *s; Screen *s;
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
if (!current_screen) if (!current_screen)
return -1; return -1;
/* Find current screen in screenlist */ /* Find current screen in screenlist */
for( s = LL_GetFirst(screenlist); s && s != current_screen; s = LL_GetNext(screenlist) ); for (s = LL_GetFirst(screenlist); s && s != current_screen; s = LL_GetNext(screenlist));
/* One step forward */ /* One step forward */
s = LL_GetNext(screenlist); s = LL_GetNext(screenlist);
if( !s || s->priority < current_screen->priority) { if (!s || s->priority < current_screen->priority) {
/* To far, go back to start of screenlist */ /* To far, go back to start of screenlist */
s = LL_GetFirst(screenlist); s = LL_GetFirst(screenlist);
} }
screenlist_switch (s); screenlist_switch(s);
return 0; return 0;
} }
int int
screenlist_goto_prev () screenlist_goto_prev(void)
{ {
Screen *s; Screen *s;
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
if (!current_screen) if (!current_screen)
return -1; return -1;
/* Find current screen in screenlist */ /* Find current screen in screenlist */
for( s = LL_GetFirst(screenlist); s && s != current_screen; s = LL_GetNext(screenlist) ); for (s = LL_GetFirst(screenlist); s && s != current_screen; s = LL_GetNext(screenlist));
/* One step back */ /* One step back */
s = LL_GetPrev(screenlist); s = LL_GetPrev(screenlist);
if( !s ) { if (!s) {
/* We're at the start of the screenlist. We should find the /* We're at the start of the screenlist. We should find the
* last screen with the same priority as the first screen. * last screen with the same priority as the first screen.
*/ */
Screen * f = LL_GetFirst(screenlist); Screen *f = LL_GetFirst(screenlist);
Screen * n; Screen *n;
s = f; s = f;
while( (n = LL_GetNext(screenlist)) && n->priority == f->priority ) { while ((n = LL_GetNext(screenlist)) && n->priority == f->priority) {
s = n; s = n;
} }
} }
screenlist_switch (s); screenlist_switch(s);
return 0; return 0;
} }
/* Internal function for sorting. */ /* Internal function for sorting. */
int int
compare_priority (void *one, void *two) compare_priority(void *one, void *two)
{ {
Screen *a, *b; Screen *a, *b;
+9 -9
View File
@@ -25,33 +25,33 @@
/*extern int screenlist_action;*/ /*extern int screenlist_action;*/
extern bool autorotate; extern bool autorotate;
int screenlist_init (); int screenlist_init(void);
/* Initializes the screenlist. */ /* Initializes the screenlist. */
int screenlist_shutdown (); int screenlist_shutdown(void);
/* Shuts down the screenlist. */ /* Shuts down the screenlist. */
int screenlist_add (Screen * s); int screenlist_add(Screen *s);
/* Adds a screen to the screenlist. */ /* Adds a screen to the screenlist. */
int screenlist_remove (Screen * s); int screenlist_remove(Screen *s);
/* Removes a screen from the screenlist. */ /* Removes a screen from the screenlist. */
void screenlist_process (); void screenlist_process(void);
/* Processes the screenlist. Decides if we need to switch to an other /* Processes the screenlist. Decides if we need to switch to an other
* screen. */ * screen. */
void screenlist_switch (Screen * s); void screenlist_switch(Screen *s);
/* Switches to an other screen in the proper way. Informs clients of /* Switches to an other screen in the proper way. Informs clients of
* the switch. ALWAYS USE THIS FUNCTION TO SWITCH SCREENS. */ * the switch. ALWAYS USE THIS FUNCTION TO SWITCH SCREENS. */
Screen *screenlist_current (); Screen *screenlist_current(void);
/* Returns the currently active screen. */ /* Returns the currently active screen. */
int screenlist_goto_next (); int screenlist_goto_next(void);
/* Moves on to the next screen. */ /* Moves on to the next screen. */
int screenlist_goto_prev (); int screenlist_goto_prev(void);
/* Moves on to the previous screen. */ /* Moves on to the previous screen. */
#endif #endif
+41 -38
View File
@@ -35,79 +35,82 @@
#define UNSET_INT -1 #define UNSET_INT -1
Screen * server_screen;
int rotate_server_screen = UNSET_INT;
#define MAX_SERVERSCREEN_WIDTH 40 #define MAX_SERVERSCREEN_WIDTH 40
Screen *server_screen;
int rotate_server_screen = UNSET_INT;
int int
server_screen_init () server_screen_init(void)
{ {
Widget * w; Widget *w;
int line; int line;
debug (RPT_DEBUG, "server_screen_init"); debug(RPT_DEBUG, "server_screen_init");
/* Create the screen */ /* Create the screen */
server_screen = screen_create ("_server_screen", NULL); server_screen = screen_create("_server_screen", NULL);
if (!server_screen) { if (!server_screen) {
report (RPT_ERR, "server_screen_init: Error allocating screen"); report(RPT_ERR, "server_screen_init: Error allocating screen");
return -1; return -1;
} }
server_screen->name = "Server screen"; server_screen->name = "Server screen";
server_screen->duration = RENDER_FREQ; /* 1 second, instead of 4...*/ server_screen->duration = RENDER_FREQ; /* 1 second, instead of 4...*/
if ((rotate_server_screen == UNSET_INT ) || (rotate_server_screen == 1)) { if ((rotate_server_screen == UNSET_INT) || (rotate_server_screen == 1)) {
server_screen->priority = PRI_INFO; server_screen->priority = PRI_INFO;
} else { } else {
server_screen->priority = PRI_BACKGROUND; server_screen->priority = PRI_BACKGROUND;
} }
/* Create all the widgets...*/ /* Create all the widgets...*/
for (line=1; line<=4; line++) { for (line = 1; line <= 4; line++) {
char id[8]; char id[8];
sprintf (id, "line%d", line); sprintf(id, "line%d", line);
w = widget_create (id, WID_STRING, server_screen); w = widget_create(id, WID_STRING, server_screen);
if (!w) { if (!w) {
report (RPT_ERR, "server_screen_init: Can't create a widget"); report(RPT_ERR, "server_screen_init: Can't create a widget");
return -1; return -1;
} }
screen_add_widget (server_screen, w); screen_add_widget(server_screen, w);
w->x = 1; w->x = 1;
w->y = line; w->y = line;
w->text = malloc (MAX_SERVERSCREEN_WIDTH+1); w->text = malloc(MAX_SERVERSCREEN_WIDTH+1);
if (line == 1) { if (line == 1) {
w->type = WID_TITLE; w->type = WID_TITLE;
strncpy (w->text, "LCDproc Server", MAX_SERVERSCREEN_WIDTH); strncpy(w->text, "LCDproc Server", MAX_SERVERSCREEN_WIDTH);
} else { } else {
w->text[0] = 0; w->text[0] = '\0';
} }
} }
/* And enqueue the screen*/ /* And enqueue the screen*/
screenlist_add (server_screen); screenlist_add(server_screen);
debug (RPT_DEBUG, "server_screen_init done"); debug(RPT_DEBUG, "server_screen_init done");
return 0; return 0;
} }
int int
server_screen_shutdown () server_screen_shutdown(void)
{ {
if (!server_screen) return -1; if (!server_screen)
return -1;
screenlist_remove (server_screen); screenlist_remove(server_screen);
screen_destroy (server_screen); screen_destroy(server_screen);
return 0; return 0;
} }
int int
update_server_screen () update_server_screen(void)
{ {
Client * c; Client *c;
Widget * w; Widget *w;
int num_clients; int num_clients;
int num_screens; int num_screens;
@@ -116,33 +119,33 @@ update_server_screen ()
/* ... and screens */ /* ... and screens */
num_screens = 0; num_screens = 0;
for (c = clients_getfirst (); c; c = clients_getnext () ) { for (c = clients_getfirst(); c != NULL; c = clients_getnext()) {
num_screens += client_screen_count(c); num_screens += client_screen_count(c);
} }
/* Format strings for the appropriate size display... */ /* Format strings for the appropriate size display... */
if (display_props->height >= 3) { if (display_props->height >= 3) {
w = screen_find_widget (server_screen, "line2"); w = screen_find_widget(server_screen, "line2");
snprintf (w->text, MAX_SERVERSCREEN_WIDTH, snprintf(w->text, MAX_SERVERSCREEN_WIDTH,
"Clients: %i", num_clients); "Clients: %i", num_clients);
w = screen_find_widget (server_screen, "line3"); w = screen_find_widget(server_screen, "line3");
snprintf (w->text, MAX_SERVERSCREEN_WIDTH, snprintf(w->text, MAX_SERVERSCREEN_WIDTH,
"Screens: %i", num_screens); "Screens: %i", num_screens);
} else { } else {
w = screen_find_widget (server_screen, "line2"); w = screen_find_widget(server_screen, "line2");
/*if (display_props->width >= 20)*/ snprintf(w->text, MAX_SERVERSCREEN_WIDTH,
snprintf (w->text, MAX_SERVERSCREEN_WIDTH, ((display_props->width >= 16)
"Cli: %i Scr: %i", ? "Cli: %i Scr: %i"
: "C: %i S: %i"),
num_clients, num_screens); num_clients, num_screens);
/*else * 16x2 size */
} }
return 0; return 0;
} }
int int
goodbye_screen() goodbye_screen(void)
{ {
if(!display_props) if (!display_props)
return 0; return 0;
drivers_clear(); drivers_clear();
+5 -5
View File
@@ -14,13 +14,13 @@
#include "screen.h" #include "screen.h"
extern Screen * server_screen; extern Screen *server_screen;
extern int rotate_server_screen; extern int rotate_server_screen;
int server_screen_init (); int server_screen_init(void);
int server_screen_shutdown (); int server_screen_shutdown(void);
int update_server_screen (); int update_server_screen(void);
int goodbye_screen (); int goodbye_screen(void);
#endif #endif
+33 -33
View File
@@ -83,7 +83,7 @@ sock_init(char* bind_addr, int bind_port)
#ifdef WINSOCK2 #ifdef WINSOCK2
/* Initialize the Winsock dll */ /* Initialize the Winsock dll */
WSADATA wsaData; WSADATA wsaData;
int startup = WSAStartup( MAKEWORD(2, 2), &wsaData ); int startup = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (startup != 0) if (startup != 0)
{ {
report(RPT_ERR, "%s: Could not start Winsock library - %s", report(RPT_ERR, "%s: Could not start Winsock library - %s",
@@ -92,12 +92,12 @@ sock_init(char* bind_addr, int bind_port)
/* REVISIT: call WSACleanup(); */ /* REVISIT: call WSACleanup(); */
#endif #endif
debug (RPT_DEBUG, "%s( bind_addr=\"%s\", port=%d )", __FUNCTION__, bind_addr, bind_port); debug(RPT_DEBUG, "%s(bind_addr=\"%s\", port=%d)", __FUNCTION__, bind_addr, bind_port);
/* Create the socket and set it up to accept connections. */ /* Create the socket and set it up to accept connections. */
listening_fd = sock_create_inet_socket (bind_addr, bind_port); listening_fd = sock_create_inet_socket(bind_addr, bind_port);
if (listening_fd < 0) { if (listening_fd < 0) {
report (RPT_ERR, "%s: Error creating socket - %s", report(RPT_ERR, "%s: Error creating socket - %s",
__FUNCTION__, sock_geterror()); __FUNCTION__, sock_geterror());
return -1; return -1;
} }
@@ -158,11 +158,11 @@ This code gets the send and receive buffer sizes.
int int
sock_shutdown () sock_shutdown(void)
{ {
int retVal = 0; int retVal = 0;
debug( RPT_DEBUG, "%s()", __FUNCTION__ ); debug(RPT_DEBUG, "%s()", __FUNCTION__);
/*struct ClientSocketMap* clientIt;*/ /*struct ClientSocketMap* clientIt;*/
@@ -183,7 +183,7 @@ sock_shutdown ()
} }
LL_Destroy(openSocketList); LL_Destroy(openSocketList);
*/ */
close( listening_fd ); close(listening_fd);
LL_Destroy(freeClientSocketList); LL_Destroy(freeClientSocketList);
free(freeClientSocketPool); free(freeClientSocketPool);
@@ -203,15 +203,15 @@ sock_shutdown ()
/****************************************************************************/ /****************************************************************************/
/* Creates a socket in internet space */ /* Creates a socket in internet space */
int int
sock_create_inet_socket (char * addr, unsigned int port) sock_create_inet_socket(char *addr, unsigned int port)
{ {
struct sockaddr_in name; struct sockaddr_in name;
int sock, sockopt=1; int sock, sockopt=1;
debug (RPT_DEBUG, "%s( addr=\"%s\", port=%i )", __FUNCTION__, addr, port); debug(RPT_DEBUG, "%s(addr=\"%s\", port=%i)", __FUNCTION__, addr, port);
/* Create the socket. */ /* Create the socket. */
sock = socket (PF_INET, SOCK_STREAM, 0); sock = socket(PF_INET, SOCK_STREAM, 0);
#ifdef WINSOCK2 #ifdef WINSOCK2
if (sock == INVALID_SOCKET) if (sock == INVALID_SOCKET)
#else #else
@@ -230,9 +230,9 @@ sock_create_inet_socket (char * addr, unsigned int port)
} }
/* Give the socket a name. */ /* Give the socket a name. */
memset (&name, 0, sizeof (name)); memset(&name, 0, sizeof(name));
name.sin_family = AF_INET; name.sin_family = AF_INET;
name.sin_port = htons (port); name.sin_port = htons(port);
#ifndef WINSOCK2 #ifndef WINSOCK2
/* REVISIT: can probably use the same code as under winsock */ /* REVISIT: can probably use the same code as under winsock */
inet_aton(addr, &name.sin_addr); inet_aton(addr, &name.sin_addr);
@@ -240,7 +240,7 @@ sock_create_inet_socket (char * addr, unsigned int port)
name.sin_addr.S_un.S_addr = inet_addr(addr); name.sin_addr.S_un.S_addr = inet_addr(addr);
#endif #endif
if (bind(sock, (struct sockaddr *) &name, sizeof (name)) < 0) if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0)
{ {
report(RPT_ERR, "%s: Could not bind to port %d at address %s - %s", report(RPT_ERR, "%s: Could not bind to port %d at address %s - %s",
__FUNCTION__, port, addr, sock_geterror()); __FUNCTION__, port, addr, sock_geterror());
@@ -249,7 +249,7 @@ sock_create_inet_socket (char * addr, unsigned int port)
report(RPT_NOTICE, "Listening for queries on %s:%d", addr, port); report(RPT_NOTICE, "Listening for queries on %s:%d", addr, port);
} }
if (listen (sock, 1) < 0) { if (listen(sock, 1) < 0) {
report(RPT_ERR, "%s: error in attempting to listen to port " report(RPT_ERR, "%s: error in attempting to listen to port "
"%d at %s - %s", "%d at %s - %s",
__FUNCTION__, port, addr, sock_geterror()); __FUNCTION__, port, addr, sock_geterror());
@@ -257,8 +257,8 @@ sock_create_inet_socket (char * addr, unsigned int port)
} }
/* Initialize the set of active sockets. */ /* Initialize the set of active sockets. */
FD_ZERO (&active_fd_set); FD_ZERO(&active_fd_set);
FD_SET (sock, &active_fd_set); FD_SET(sock, &active_fd_set);
return sock; return sock;
} }
@@ -266,14 +266,14 @@ sock_create_inet_socket (char * addr, unsigned int port)
/* Service all clients with input pending...*/ /* Service all clients with input pending...*/
int int
sock_poll_clients () sock_poll_clients(void)
{ {
int err; int err;
struct sockaddr_in clientname; struct sockaddr_in clientname;
struct timeval t; struct timeval t;
struct ClientSocketMap* clientSocket; struct ClientSocketMap* clientSocket;
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
t.tv_sec = 0; t.tv_sec = 0;
t.tv_usec = 0; t.tv_usec = 0;
@@ -281,7 +281,7 @@ sock_poll_clients ()
/* Block until input arrives on one or more active sockets. */ /* Block until input arrives on one or more active sockets. */
read_fd_set = active_fd_set; read_fd_set = active_fd_set;
if (select (FD_SETSIZE, &read_fd_set, NULL, NULL, &t) < 0) { if (select(FD_SETSIZE, &read_fd_set, NULL, NULL, &t) < 0) {
report(RPT_ERR, "%s: Select error - %s", report(RPT_ERR, "%s: Select error - %s",
__FUNCTION__, sock_geterror()); __FUNCTION__, sock_geterror());
return -1; return -1;
@@ -301,7 +301,7 @@ sock_poll_clients ()
Client* c; Client* c;
int new_sock; int new_sock;
socklen_t size = sizeof(clientname); socklen_t size = sizeof(clientname);
new_sock = accept (listening_fd, (struct sockaddr *) &clientname, &size); new_sock = accept(listening_fd, (struct sockaddr *) &clientname, &size);
#ifdef WINSOCK2 #ifdef WINSOCK2
if (new_sock == INVALID_SOCKET) if (new_sock == INVALID_SOCKET)
#else #else
@@ -312,9 +312,9 @@ sock_poll_clients ()
__FUNCTION__, sock_geterror()); __FUNCTION__, sock_geterror());
return -1; return -1;
} }
report (RPT_NOTICE, "Connect from host %s:%hu on socket %i", report(RPT_NOTICE, "Connect from host %s:%hu on socket %i",
inet_ntoa (clientname.sin_addr), ntohs (clientname.sin_port), new_sock); inet_ntoa(clientname.sin_addr), ntohs(clientname.sin_port), new_sock);
FD_SET (new_sock, &active_fd_set); FD_SET(new_sock, &active_fd_set);
#ifdef WINSOCK2 #ifdef WINSOCK2
{ {
@@ -326,8 +326,8 @@ sock_poll_clients ()
#endif #endif
/* Create new client */ /* Create new client */
if ((c = client_create (new_sock)) == NULL) { if ((c = client_create(new_sock)) == NULL) {
report( RPT_ERR, "%s: Error creating client on socket %i - %s", report(RPT_ERR, "%s: Error creating client on socket %i - %s",
__FUNCTION__, clientSocket->socket, sock_geterror()); __FUNCTION__, clientSocket->socket, sock_geterror());
return -1; return -1;
} else { } else {
@@ -347,17 +347,17 @@ sock_poll_clients ()
return -1; return -1;
} }
} }
if (clients_add_client (c) != 0) { if (clients_add_client(c) != 0) {
report( RPT_ERR, "%s: Could not add client on socket %i", __FUNCTION__, clientSocket->socket); report(RPT_ERR, "%s: Could not add client on socket %i", __FUNCTION__, clientSocket->socket);
return -1; return -1;
} }
} else { } else {
/* Data arriving on an already-connected socket. */ /* Data arriving on an already-connected socket. */
err = 0; err = 0;
do { do {
debug (RPT_DEBUG, "%s: reading...", __FUNCTION__); debug(RPT_DEBUG, "%s: reading...", __FUNCTION__);
err = sock_read_from_client(clientSocket); err = sock_read_from_client(clientSocket);
debug (RPT_DEBUG, "%s: ...done", __FUNCTION__); debug(RPT_DEBUG, "%s: ...done", __FUNCTION__);
if (err < 0) if (err < 0)
{ {
/* Client disconnected, destroy client data */ /* Client disconnected, destroy client data */
@@ -367,7 +367,7 @@ sock_poll_clients ()
struct ClientSocketMap* entry; struct ClientSocketMap* entry;
/*sock_send_string(i, "bye\n");*/ /*sock_send_string(i, "bye\n");*/
report (RPT_NOTICE, "Client on socket %i disconnected", report(RPT_NOTICE, "Client on socket %i disconnected",
clientSocket->socket); clientSocket->socket);
client_destroy(clientSocket->client); client_destroy(clientSocket->client);
clients_remove_client(clientSocket->client); clients_remove_client(clientSocket->client);
@@ -377,7 +377,7 @@ sock_poll_clients ()
entry = (struct ClientSocketMap*) LL_DeleteNode(openSocketList); entry = (struct ClientSocketMap*) LL_DeleteNode(openSocketList);
LL_Push(freeClientSocketList, (void*) entry); LL_Push(freeClientSocketList, (void*) entry);
} else { } else {
report (RPT_ERR, "%s: Can't find client of socket %i", report(RPT_ERR, "%s: Can't find client of socket %i",
__FUNCTION__, clientSocket->socket); __FUNCTION__, clientSocket->socket);
} }
} }
@@ -394,7 +394,7 @@ sock_read_from_client(struct ClientSocketMap* clientSocketMap)
char buffer[MAXMSG]; char buffer[MAXMSG];
int nbytes, i; int nbytes, i;
debug (RPT_DEBUG, "%s()", __FUNCTION__); debug(RPT_DEBUG, "%s()", __FUNCTION__);
errno = 0; errno = 0;
nbytes = sock_recv(clientSocketMap->socket, buffer, MAXMSG); nbytes = sock_recv(clientSocketMap->socket, buffer, MAXMSG);
@@ -419,7 +419,7 @@ sock_read_from_client(struct ClientSocketMap* clientSocketMap)
if (buffer[i] == 0) if (buffer[i] == 0)
buffer[i] = '\n'; buffer[i] = '\n';
/* Enqueue a "client message" here...*/ /* Enqueue a "client message" here...*/
/* c = clients_find_client_by_sock (filedes); - Deprecated by clientsocketmap*/ /* c = clients_find_client_by_sock(filedes); - Deprecated by clientsocketmap*/
if (clientSocketMap->client) { if (clientSocketMap->client) {
client_add_message(clientSocketMap->client, buffer); client_add_message(clientSocketMap->client, buffer);
} else { } else {
+2 -2
View File
@@ -19,9 +19,9 @@ typedef struct sockaddr_in sockaddr_in;
/* Server functions...*/ /* Server functions...*/
int sock_init(char* bind_addr, int bind_port); int sock_init(char* bind_addr, int bind_port);
int sock_shutdown(); int sock_shutdown(void);
int sock_create_inet_socket(char* bind_addr, unsigned int port); int sock_create_inet_socket(char* bind_addr, unsigned int port);
int sock_poll_clients(); int sock_poll_clients(void);
int verify_ipv4(const char *addr); int verify_ipv4(const char *addr);
int verify_ipv6(const char *addr); int verify_ipv6(const char *addr);
+28 -28
View File
@@ -69,22 +69,22 @@ struct icontable {
Widget * Widget *
widget_create (char *id, WidgetType type, Screen * screen) widget_create(char *id, WidgetType type, Screen *screen)
{ {
Widget * w; Widget *w;
debug (RPT_DEBUG, "%s( id=\"%s\", type=%d, screen=[%s] )", __FUNCTION__, id, type, screen->id ); debug(RPT_DEBUG, "%s(id=\"%s\", type=%d, screen=[%s])", __FUNCTION__, id, type, screen->id);
/* Create it */ /* Create it */
w = malloc (sizeof (Widget)); w = malloc(sizeof(Widget));
if (!w) { if (!w) {
report (RPT_DEBUG, "%s: Error allocating", __FUNCTION__); report(RPT_DEBUG, "%s: Error allocating", __FUNCTION__);
return NULL; return NULL;
} }
w->id = strdup(id); w->id = strdup(id);
if (!w->id) { if (!w->id) {
report (RPT_DEBUG, "%s: Error allocating", __FUNCTION__); report(RPT_DEBUG, "%s: Error allocating", __FUNCTION__);
return NULL; return NULL;
} }
@@ -105,49 +105,49 @@ widget_create (char *id, WidgetType type, Screen * screen)
if (w->type == WID_FRAME) { if (w->type == WID_FRAME) {
/* create a screen for the frame widget */ /* create a screen for the frame widget */
char * frame_name; char *frame_name;
frame_name = malloc (strlen("frame_") + strlen(id) + 1); frame_name = malloc(strlen("frame_") + strlen(id) + 1);
strcpy (frame_name, "frame_"); strcpy(frame_name, "frame_");
strcat (frame_name, id); strcat(frame_name, id);
w->frame_screen = screen_create (frame_name, screen->client); w->frame_screen = screen_create(frame_name, screen->client);
free (frame_name); /* not needed anymore */ free(frame_name); /* not needed anymore */
} }
return w; return w;
} }
int int
widget_destroy (Widget * w) widget_destroy(Widget *w)
{ {
debug (RPT_DEBUG, "%s( w=[%s] )", __FUNCTION__, w->id); debug(RPT_DEBUG, "%s(w=[%s])", __FUNCTION__, w->id);
if (!w) if (!w)
return -1; return -1;
if (w->id) if (w->id)
free (w->id); free(w->id);
if (w->text) if (w->text)
free (w->text); free(w->text);
/* Free subscreen of frame widget too */ /* Free subscreen of frame widget too */
if (w->type == WID_FRAME) { if (w->type == WID_FRAME) {
screen_destroy (w->frame_screen); screen_destroy(w->frame_screen);
} }
free (w); free(w);
return 0; return 0;
} }
WidgetType WidgetType
widget_typename_to_type (char * typename) widget_typename_to_type(char *typename)
{ {
WidgetType wid_type = WID_NONE; WidgetType wid_type = WID_NONE;
int i; int i;
for (i = 0; typenames[i]; i++) { for (i = 0; typenames[i]; i++) {
if (strcmp (typenames[i], typename) == 0) { if (strcmp(typenames[i], typename) == 0) {
wid_type = i; wid_type = i;
break; /* it's valid: skip out...*/ break; /* it's valid: skip out...*/
} }
@@ -156,26 +156,26 @@ widget_typename_to_type (char * typename)
} }
char * char *
widget_type_to_typename (WidgetType t) widget_type_to_typename(WidgetType t)
{ {
return typenames[t]; return typenames[t];
} }
Widget * Widget *
widget_search_subs (Widget * w, char * id) widget_search_subs(Widget *w, char *id)
{ {
if (w->type == WID_FRAME) { if (w->type == WID_FRAME) {
return screen_find_widget (w->frame_screen, id); return screen_find_widget(w->frame_screen, id);
} else { } else {
return NULL; /* no kids */ return NULL; /* no kids */
} }
} }
char *widget_icon_to_iconname (int icon) char *widget_icon_to_iconname(int icon)
{ {
int i; int i;
for (i=0; icontable[i].iconname; i++) { for (i = 0; icontable[i].iconname; i++) {
if (icontable[i].icon == icon) { if (icontable[i].icon == icon) {
return icontable[i].iconname; return icontable[i].iconname;
} }
@@ -184,12 +184,12 @@ char *widget_icon_to_iconname (int icon)
return NULL; return NULL;
} }
int widget_iconname_to_icon (char *iconname) int widget_iconname_to_icon(char *iconname)
{ {
int i; int i;
for (i=0; icontable[i].iconname; i++) { for (i = 0; icontable[i].iconname; i++) {
if (strcasecmp( icontable[i].iconname, iconname) == 0) { if (strcasecmp(icontable[i].iconname, iconname) == 0) {
return icontable[i].icon; return icontable[i].icon;
} }
} }
+9 -9
View File
@@ -33,38 +33,38 @@ typedef enum WidgetType {
typedef struct Widget { typedef struct Widget {
char *id; char *id;
WidgetType type; WidgetType type;
Screen * screen; /* What screen is this widget in ? */ Screen *screen; /* What screen is this widget in ? */
int x, y; /* Position */ int x, y; /* Position */
int width, height; /* Visible size */ int width, height; /* Visible size */
int left, top, right, bottom; /* bounding rectangle */ int left, top, right, bottom; /* bounding rectangle */
int length; /* size or direction */ int length; /* size or direction */
int speed; /* For scroller... */ int speed; /* For scroller... */
char *text; /* text or binary data */ char *text; /* text or binary data */
struct Screen * frame_screen; /* frame widget get an associated screen */ struct Screen *frame_screen; /* frame widget get an associated screen */
//LinkedList *kids; /* Frames can contain more widgets...*/ //LinkedList *kids; /* Frames can contain more widgets...*/
} Widget; } Widget;
#define WID_MAX_DIR 4 #define WID_MAX_DIR 4
/* Create new widget */ /* Create new widget */
Widget * widget_create (char *id, WidgetType type, Screen * screen); Widget *widget_create(char *id, WidgetType type, Screen *screen);
/* Destroy a widget */ /* Destroy a widget */
int widget_destroy (Widget * w); int widget_destroy(Widget *w);
/* Convert a widget typename to a widget type */ /* Convert a widget typename to a widget type */
WidgetType widget_typename_to_type (char * typename); WidgetType widget_typename_to_type(char *typename);
/* Convert a widget typename to a widget type */ /* Convert a widget typename to a widget type */
char *widget_type_to_typename (WidgetType t); char *widget_type_to_typename(WidgetType t);
/* Search subwidgets of a widget */ /* Search subwidgets of a widget */
Widget * widget_search_subs (Widget * w, char * id); Widget *widget_search_subs(Widget *w, char *id);
/* Convert icon number to icon name */ /* Convert icon number to icon name */
char *widget_icon_to_iconname (int icon); char *widget_icon_to_iconname(int icon);
/* Convert iconname to icon number */ /* Convert iconname to icon number */
int widget_iconname_to_icon (char *iconname); int widget_iconname_to_icon(char *iconname);
#endif #endif