diff --git a/Makefile.am b/Makefile.am index 25c1c2f..af1e45a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,4 +22,8 @@ install-html-userguide: dox: $(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 diff --git a/contrib/patches/lcdprocserverSEG.diff b/contrib/patches/lcdprocserverSEG.diff index 05abf77..99f99bc 100644 --- a/contrib/patches/lcdprocserverSEG.diff +++ b/contrib/patches/lcdprocserverSEG.diff @@ -999,7 +999,7 @@ diff --exclude='*.wanjet' --exclude='.??*' --exclude=config.h --exclude='*.orig' + * and every screen add... + */ + if( s == server_screen ) { -+ update_server_screen (timer); ++ update_server_screen(); + } + render_screen (s, timer); + diff --git a/server/client.c b/server/client.c index 3b63c01..f0119aa 100644 --- a/server/client.c +++ b/server/client.c @@ -25,16 +25,16 @@ #include "shared/report.h" #include "shared/LL.h" -Client * client_create (int sock) +Client *client_create(int sock) { Client *c; - debug (RPT_DEBUG, "%s( sock=%i )", __FUNCTION__, sock); + debug(RPT_DEBUG, "%s(sock=%i)", __FUNCTION__, sock); /* Allocate new client...*/ - c = malloc (sizeof (Client)); + c = malloc(sizeof(Client)); if (!c) { - report (RPT_ERR, "%s: Error allocating", __FUNCTION__); + report(RPT_ERR, "%s: Error allocating", __FUNCTION__); return NULL; } /* Init struct members*/ @@ -44,10 +44,10 @@ Client * client_create (int sock) c->heartbeat = HEARTBEAT_OPEN; /*Set up message list...*/ - c->messages = LL_new (); + c->messages = LL_new(); if (!c->messages) { - report (RPT_ERR, "%s: Error allocating", __FUNCTION__); - free (c); + report(RPT_ERR, "%s: Error allocating", __FUNCTION__); + free(c); return NULL; } @@ -58,79 +58,79 @@ Client * client_create (int sock) c->screenlist = LL_new(); if (!c->screenlist) { - report( RPT_ERR, "%s: Error allocating", __FUNCTION__); + report(RPT_ERR, "%s: Error allocating", __FUNCTION__); return NULL; } return c; } int -client_destroy (Client * c) +client_destroy(Client *c) { Screen *s; - char * str; + char *str; if (!c) return -1; - debug (RPT_DEBUG, "%s( c=[%d] )", __FUNCTION__, c->sock ); + debug(RPT_DEBUG, "%s(c=[%d])", __FUNCTION__, c->sock); /* Close the socket */ - close (c->sock); + close(c->sock); /* Eat messages */ - while ((str = client_get_message (c))) { - free (str); + while ((str = client_get_message(c))) { + free(str); } - LL_Destroy( c->messages ); + LL_Destroy(c->messages); /* 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...*/ - screen_destroy (s); + screen_destroy(s); /* Note that the screen is not removed from the list because * the list will be destroyed anyway... */ } - LL_Destroy( c->screenlist); + LL_Destroy(c->screenlist); /* Destroy the client's menu, if it exists */ if (c->menu) { - menuscreen_inform_item_destruction (c->menu); - menu_remove_item (c->menu->parent, c->menu); - menuscreen_inform_item_modified (c->menu->parent); - menuitem_destroy (c->menu); + menuscreen_inform_item_destruction(c->menu); + menu_remove_item(c->menu->parent, c->menu); + menuscreen_inform_item_modified(c->menu->parent); + menuitem_destroy(c->menu); } /* Forget client's key reservations */ - input_release_client_keys (c); + input_release_client_keys(c); /* Free client's other data */ c->ack = 0; /* Clean up the name...*/ if (c->name) - free (c->name); + free(c->name); /* Remove structure */ - free (c); + free(c); - debug( RPT_DEBUG, "%s: Client data removed", __FUNCTION__); + debug(RPT_DEBUG, "%s: Client data removed", __FUNCTION__); return 0; } /*Add and remove messages from the client's queue...*/ int -client_add_message (Client * c, char *message) +client_add_message(Client *c, char *message) { int err = 0; char *dup; char *str, *cp; 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) return -1; @@ -138,19 +138,19 @@ client_add_message (Client * c, char *message) return -1; /* Copy the string to avoid overwriting the original...*/ - dup = strdup (message); + dup = strdup(message); if (!dup) { report(RPT_ERR, "%s: Error allocating", __FUNCTION__); return -1; } /* Now split the string into lines and enqueue each one...*/ - for (str = strtok (dup, delimiters); str; str = strtok (NULL, delimiters)) { - cp = strdup (str); - debug (RPT_DEBUG, "%s: Queued message: \"%s\"", __FUNCTION__, cp); - err += LL_Enqueue (c->messages, (void *) cp); + for (str = strtok(dup, delimiters); str; str = strtok(NULL, delimiters)) { + cp = strdup(str); + debug(RPT_DEBUG, "%s: Queued message: \"%s\"", __FUNCTION__, cp); + err += LL_Enqueue(c->messages, (void *) cp); } - free (dup); + free(dup); /* Err is the number of errors encountered...*/ return err; @@ -158,23 +158,23 @@ client_add_message (Client * c, char *message) /* Woo-hoo! A simple function. :)*/ char * -client_get_message (Client * c) +client_get_message(Client *c) { char *str; - debug(RPT_DEBUG, "%s( c=[%d] )", __FUNCTION__, c->sock); + debug(RPT_DEBUG, "%s(c=[%d])", __FUNCTION__, c->sock); if (!c) return NULL; - str = (char *) LL_Dequeue (c->messages); + str = (char *) LL_Dequeue(c->messages); return str; } Screen * -client_find_screen (Client * c, char *id) +client_find_screen(Client *c, char *id) { Screen *s; @@ -183,58 +183,58 @@ client_find_screen (Client * c, char *id) if (!id) 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 { - s = LL_Get (c->screenlist); - if ((s) && (0 == strcmp (s->id, id))) { - debug (RPT_DEBUG, "%s: Found %s", __FUNCTION__, id); + s = LL_Get(c->screenlist); + if ((s) && (0 == strcmp(s->id, id))) { + debug(RPT_DEBUG, "%s: Found %s", __FUNCTION__, id); return s; } - } while (LL_Next (c->screenlist) == 0); + } while (LL_Next(c->screenlist) == 0); return NULL; } int -client_add_screen (Client * c, Screen * s) +client_add_screen(Client *c, Screen *s) { if (!c) return -1; if (!s) 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...*/ - screenlist_add (s); + screenlist_add(s); return 0; } int -client_remove_screen (Client * c, Screen * s) +client_remove_screen(Client *c, Screen *s) { if (!c) return -1; if (!s) 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?*/ - LL_Remove (c->screenlist, (void *) s); + LL_Remove(c->screenlist, (void *) s); /* Now, remove it from the screenlist...*/ - screenlist_remove (s); + screenlist_remove(s); return 0; } -int client_screen_count (Client * c) +int client_screen_count(Client *c) { return LL_Length(c->screenlist); } diff --git a/server/client.h b/server/client.h index 80f3df4..ee3e663 100644 --- a/server/client.h +++ b/server/client.h @@ -37,35 +37,35 @@ typedef struct Client { LinkedList *screenlist; /* Maybe it has created a menu */ - Menu * menu; + Menu *menu; } Client; #include "screen.h" /* 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 */ -int client_destroy (Client * c); +int client_destroy(Client *c); /* Close the socket */ -void client_close_sock (Client * c); +void client_close_sock(Client *c); /* 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 */ -char * client_get_message (Client * c); +char *client_get_message(Client *c); /* 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 diff --git a/server/clients.c b/server/clients.c index 2d4e6cc..c6d9e4d 100644 --- a/server/clients.c +++ b/server/clients.c @@ -29,13 +29,13 @@ LinkedList *clientlist = NULL; /* Initialize and kill client list...*/ int -clients_init () +clients_init(void) { debug(RPT_DEBUG, "%s()", __FUNCTION__); - clientlist = LL_new (); + clientlist = LL_new(); if (!clientlist) { - report( RPT_ERR, "%s: Unable to create client list", __FUNCTION__); + report(RPT_ERR, "%s: Unable to create client list", __FUNCTION__); return -1; } @@ -43,68 +43,68 @@ clients_init () } int -clients_shutdown () +clients_shutdown(void) { Client *c; - debug (RPT_DEBUG, "%s()", __FUNCTION__); + debug(RPT_DEBUG, "%s()", __FUNCTION__); - if( !clientlist ) { + if (!clientlist) { /* Program shutdown before completed startup */ return -1; } /* Free all client structures... */ - for (c=LL_GetFirst (clientlist); c; c=LL_GetNext (clientlist) ) { - debug (RPT_DEBUG, "%s: ...", __FUNCTION__); + for (c = LL_GetFirst(clientlist); c; c = LL_GetNext(clientlist)) { + debug(RPT_DEBUG, "%s: ...", __FUNCTION__); if (c) { - debug (RPT_DEBUG, "%s: ... %i ...", __FUNCTION__, c->sock); - if (client_destroy (c) != 0) { - report (RPT_ERR, "%s: Error freeing client", __FUNCTION__); + debug(RPT_DEBUG, "%s: ... %i ...", __FUNCTION__, c->sock); + if (client_destroy(c) != 0) { + report(RPT_ERR, "%s: Error freeing client", __FUNCTION__); } else { - debug (RPT_DEBUG, "%s: Freed client...", __FUNCTION__); + debug(RPT_DEBUG, "%s: Freed client...", __FUNCTION__); } } else { - debug (RPT_DEBUG, "%s: No client!", __FUNCTION__); + debug(RPT_DEBUG, "%s: No client!", __FUNCTION__); } } /* Then, free the list...*/ - LL_Destroy (clientlist); + LL_Destroy(clientlist); - debug (RPT_DEBUG, "%s: done", __FUNCTION__); + debug(RPT_DEBUG, "%s: done", __FUNCTION__); return 0; } int -clients_add_client (Client *c) +clients_add_client(Client *c) { /* Add the client to the clients list... */ - return LL_Push (clientlist, c); + return LL_Push(clientlist, c); } int -clients_remove_client (Client *c) +clients_remove_client(Client *c) { /* Remove the client from the clients list... */ - return (LL_Remove (clientlist, c) == NULL)?-1:0; + return(LL_Remove(clientlist, c) == NULL)?-1:0; } Client * -clients_getfirst () +clients_getfirst(void) { return (Client *) LL_GetFirst(clientlist); } Client * -clients_getnext () +clients_getnext(void) { return (Client *) LL_GetNext(clientlist); } int -clients_client_count () +clients_client_count(void) { return LL_Length(clientlist); } @@ -115,19 +115,19 @@ clients_client_count () */ Client * -clients_find_client_by_sock (int sock) +clients_find_client_by_sock(int sock) { 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) { return c; } } - debug (RPT_ERR, "%s: failed", __FUNCTION__); + debug(RPT_ERR, "%s: failed", __FUNCTION__); return NULL; } diff --git a/server/clients.h b/server/clients.h index 3c6c2eb..c52b331 100644 --- a/server/clients.h +++ b/server/clients.h @@ -18,19 +18,19 @@ /* extern LinkedList *clientlist; Not needed outside ? */ /* Initialize and kill client list...*/ -int clients_init (); -int clients_shutdown (); +int clients_init(void); +int clients_shutdown(void); /* Add/remove clients (return -1 for error) */ -int clients_add_client (Client *c); -int clients_remove_client (Client *c); +int clients_add_client(Client *c); +int clients_remove_client(Client *c); /* List functions */ -Client * clients_getfirst (); -Client * clients_getnext (); -int clients_client_count (); +Client *clients_getfirst(void); +Client *clients_getnext(void); +int clients_client_count(void); /* 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 diff --git a/server/driver.c b/server/driver.c index 8b4489f..51d3648 100644 --- a/server/driver.c +++ b/server/driver.c @@ -41,202 +41,202 @@ typedef struct driver_symbols { - char *name; + const char *name; short offset; /* offset in Driver structure */ short required; } DriverSymbols; 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 }, - { "supports_multiple", offsetof(Driver, supports_multiple), 1 }, - { "symbol_prefix", offsetof(Driver, symbol_prefix), 1 }, - { "init", offsetof(Driver, init), 1 }, - { "close", offsetof(Driver, close), 1 }, - { "width", offsetof(Driver, width), 0 }, - { "height", offsetof(Driver, height), 0 }, - { "clear", offsetof(Driver, clear), 0 }, - { "flush", offsetof(Driver, flush), 0 }, - { "string", offsetof(Driver, string), 0 }, - { "chr", offsetof(Driver, chr), 0 }, - { "vbar", offsetof(Driver, vbar), 0 }, - { "hbar", offsetof(Driver, hbar), 0 }, - { "num", offsetof(Driver, num), 0 }, - { "heartbeat", offsetof(Driver, heartbeat), 0 }, - { "icon", offsetof(Driver, icon), 0 }, - { "cursor", offsetof(Driver, cursor), 0 }, - { "set_char", offsetof(Driver, set_char), 0 }, - { "get_free_chars", offsetof(Driver, get_free_chars), 0 }, - { "cellwidth", offsetof(Driver, cellwidth), 0 }, - { "cellheight", offsetof(Driver, cellheight), 0 }, - { "get_contrast", offsetof(Driver, get_contrast), 0 }, - { "set_contrast", offsetof(Driver, set_contrast), 0 }, - { "get_brightness", offsetof(Driver, get_brightness), 0 }, - { "set_brightness", offsetof(Driver, set_brightness), 0 }, - { "backlight", offsetof(Driver, backlight), 0 }, - { "output", offsetof(Driver, output), 0 }, - { "get_key", offsetof(Driver, get_key), 0 }, - { "get_info", offsetof(Driver, get_info), 0 }, + { "supports_multiple", offsetof(Driver, supports_multiple), 1 }, + { "symbol_prefix", offsetof(Driver, symbol_prefix), 1 }, + { "init", offsetof(Driver, init), 1 }, + { "close", offsetof(Driver, close), 1 }, + { "width", offsetof(Driver, width), 0 }, + { "height", offsetof(Driver, height), 0 }, + { "clear", offsetof(Driver, clear), 0 }, + { "flush", offsetof(Driver, flush), 0 }, + { "string", offsetof(Driver, string), 0 }, + { "chr", offsetof(Driver, chr), 0 }, + { "vbar", offsetof(Driver, vbar), 0 }, + { "hbar", offsetof(Driver, hbar), 0 }, + { "num", offsetof(Driver, num), 0 }, + { "heartbeat", offsetof(Driver, heartbeat), 0 }, + { "icon", offsetof(Driver, icon), 0 }, + { "cursor", offsetof(Driver, cursor), 0 }, + { "set_char", offsetof(Driver, set_char), 0 }, + { "get_free_chars", offsetof(Driver, get_free_chars), 0 }, + { "cellwidth", offsetof(Driver, cellwidth), 0 }, + { "cellheight", offsetof(Driver, cellheight), 0 }, + { "get_contrast", offsetof(Driver, get_contrast), 0 }, + { "set_contrast", offsetof(Driver, set_contrast), 0 }, + { "get_brightness", offsetof(Driver, get_brightness), 0 }, + { "set_brightness", offsetof(Driver, set_brightness), 0 }, + { "backlight", offsetof(Driver, backlight), 0 }, + { "output", offsetof(Driver, output), 0 }, + { "get_key", offsetof(Driver, get_key), 0 }, + { "get_info", offsetof(Driver, get_info), 0 }, { NULL, 0, 0 } }; /* Functions for the driver */ -static int request_display_width(); -static int request_display_height(); -static int driver_store_private_ptr(Driver * driver, void * private_data); +static int request_display_width(void); +static int request_display_height(void); +static int driver_store_private_ptr(Driver *driver, void *private_data); Driver * -driver_load( char * name, char * filename ) +driver_load(const char *name, const char *filename) { - Driver * driver = NULL; + Driver *driver = NULL; 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 */ - driver = malloc( sizeof( Driver )); - memset( driver, 0, sizeof (Driver)); + driver = malloc(sizeof(Driver)); + memset(driver, 0, sizeof(Driver)); /* And store its name and filename */ - driver->name = malloc( strlen( name ) + 1 ); - strcpy( driver->name, name ); - driver->filename = malloc( strlen( filename ) + 1 ); - strcpy( driver->filename, filename ); + driver->name = malloc(strlen(name) + 1); + strcpy(driver->name, name); + driver->filename = malloc(strlen(filename) + 1); + strcpy(driver->filename, filename); /* Load and bind the driver module and locate the symbols */ - if( driver_bind_module( driver ) < 0 ) { - report( RPT_ERR, "Driver [%.40s] binding failed", name ); - free( driver->name ); - free( driver->filename ); - free( driver ); + if (driver_bind_module(driver) < 0) { + report(RPT_ERR, "Driver [%.40s] binding failed", name); + free(driver->name); + free(driver->filename); + free(driver); return NULL; } /* Check module version */ - if( strcmp( *(driver->api_version), API_VERSION ) != 0 ) { - report( RPT_ERR, "Driver [%.40s] is of an incompatible version", name ); - driver_unbind_module( driver ); - free( driver->name ); - free( driver->filename ); - free( driver ); + if (strcmp(*(driver->api_version), API_VERSION) != 0) { + report(RPT_ERR, "Driver [%.40s] is of an incompatible version", name); + driver_unbind_module(driver); + free(driver->name); + free(driver->filename); + free(driver); return NULL; } /* Call the init function */ - debug( RPT_DEBUG, "%s: Calling driver [%.40s] init function", __FUNCTION__, driver->name ); - res = driver->init( driver ); - if( res < 0 ) { - report( RPT_ERR, "Driver [%.40s] init failed, return code < 0", driver->name ); + debug(RPT_DEBUG, "%s: Calling driver [%.40s] init function", __FUNCTION__, driver->name); + res = driver->init(driver); + if (res < 0) { + report(RPT_ERR, "Driver [%.40s] init failed, return code < 0", driver->name); /* Driver load failed, driver should not be added to list * Free driver structure again */ - driver_unbind_module( driver ); - free( driver->name ); - free( driver->filename ); - free( driver ); + driver_unbind_module(driver); + free(driver->name); + free(driver->filename); + free(driver); return NULL; } - debug( RPT_NOTICE, "Driver [%.40s] loaded", driver->name ); + debug(RPT_NOTICE, "Driver [%.40s] loaded", driver->name); return driver; } int -driver_unload( Driver * driver ) +driver_unload(Driver *driver) { - debug( RPT_NOTICE, "Closing driver [%.40s]", driver->name ); - if( driver->close ) - driver->close (driver); + debug(RPT_NOTICE, "Closing driver [%.40s]", driver->name); + if (driver->close) + driver->close(driver); /* Unlaod the module */ - driver_unbind_module( driver ); + driver_unbind_module(driver); /* Free its data */ - free( driver->filename ); - free( driver->name ); - free( driver ); - debug( RPT_DEBUG, "%s: Driver unloaded", __FUNCTION__ ); + free(driver->filename); + free(driver->name); + free(driver); + debug(RPT_DEBUG, "%s: Driver unloaded", __FUNCTION__); return 0; } int -driver_bind_module( Driver * driver ) +driver_bind_module(Driver *driver) { int i; 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 */ #ifndef WIN32 - driver->module_handle = dlopen( driver->filename, RTLD_NOW ); + driver->module_handle = dlopen(driver->filename, RTLD_NOW); #else - driver->module_handle = LoadLibraryEx( (driver->filename), NULL, 0 ); + driver->module_handle = LoadLibraryEx((driver->filename), NULL, 0); #endif - if( driver->module_handle == NULL ) { + if (driver->module_handle == NULL) { #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 /* 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 return -1; } /* And locate the symbols */ - for( i=0; driver_symbols[i].name; i++ ) { + for (i = 0; driver_symbols[i].name; i++) { void (**p)(); - p = (void(**)() ) ((size_t)driver + (driver_symbols[i].offset)); + p = (void(**)()) ((size_t)driver + (driver_symbols[i].offset)); *p = NULL; /* Add the symbol_prefix */ - if( driver->symbol_prefix ) { - char *s = malloc( strlen( *(driver->symbol_prefix) ) + strlen( driver_symbols[i].name ) + 1 ); - strcpy( s, *(driver->symbol_prefix) ) ; - strcat( s, driver_symbols[i].name ); - debug( RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, s ); + if (driver->symbol_prefix) { + char *s = malloc(strlen(*(driver->symbol_prefix)) + strlen(driver_symbols[i].name) + 1); + strcpy(s, *(driver->symbol_prefix)); + strcat(s, driver_symbols[i].name); + debug(RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, s); #ifndef WIN32 - *p = dlsym( driver->module_handle, s ); + *p = dlsym(driver->module_handle, s); #else - *p = (void(*)()) (GetProcAddress( driver->module_handle, s )); + *p = (void(*)()) (GetProcAddress(driver->module_handle, s)); #endif - free( s ); + free(s); } /* Retrieve the symbol */ - if( !*p ) { - debug( RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, driver_symbols[i].name ); + if (!*p) { + debug(RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, driver_symbols[i].name); #ifndef WIN32 - *p = dlsym( driver->module_handle, driver_symbols[i].name ); + *p = dlsym(driver->module_handle, driver_symbols[i].name); #else - *p = (void(*)()) (GetProcAddress( driver->module_handle, driver_symbols[i].name )); + *p = (void(*)()) (GetProcAddress(driver->module_handle, driver_symbols[i].name)); #endif } - if( *p ) { - debug( RPT_DEBUG, "%s: found symbol at: %p", __FUNCTION__, *p ); + if (*p) { + debug(RPT_DEBUG, "%s: found symbol at: %p", __FUNCTION__, *p); } /* Was the symbol required but not found ? */ - if( !*p && driver_symbols[i].required ) { - report( RPT_ERR, "Driver [%.40s] does not have required symbol: %s", driver->name, driver_symbols[i].name ); + if (!*p && driver_symbols[i].required) { + report(RPT_ERR, "Driver [%.40s] does not have required symbol: %s", driver->name, driver_symbols[i].name); missing_symbols = 1; } } /* If errors, leave now while we can :) */ - if( missing_symbols ) { - report( RPT_ERR, "Driver [%.40s] does not have all obligatory symbols", driver->name ); + if (missing_symbols) { + report(RPT_ERR, "Driver [%.40s] does not have all obligatory symbols", driver->name); #ifndef WIN32 - dlclose( driver->module_handle ); + dlclose(driver->module_handle); #else - FreeLibrary( driver->module_handle ); + FreeLibrary(driver->module_handle); #endif return -1; } @@ -267,14 +267,14 @@ driver_bind_module( Driver * driver ) 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 - dlclose( driver->module_handle ); + dlclose(driver->module_handle); #else - FreeLibrary( driver->module_handle ); + FreeLibrary(driver->module_handle); #endif return 0; @@ -282,7 +282,7 @@ driver_unbind_module( Driver * driver ) bool -driver_does_output( Driver * driver ) +driver_does_output(Driver *driver) { return (driver->width != NULL || driver->height != NULL @@ -293,30 +293,30 @@ driver_does_output( Driver * driver ) bool -driver_does_input( Driver * driver ) +driver_does_input(Driver *driver) { return (driver->get_key != NULL) ? 1 : 0; } bool -driver_stay_in_foreground( Driver * driver ) +driver_stay_in_foreground(Driver *driver) { return *driver->stay_in_foreground; } bool -driver_supports_multiple( Driver * driver ) +driver_supports_multiple(Driver *driver) { return *driver->supports_multiple; } 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; return 0; @@ -324,33 +324,33 @@ driver_store_private_ptr(Driver * driver, void * private_data) static int -request_display_width() +request_display_width(void) { - if( !display_props ) + if (!display_props) return 0; return display_props->width; } static int -request_display_height() +request_display_height(void) { - if( !display_props ) + if (!display_props) return 0; return display_props->height; } 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; - 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) return; - for ( pos=0; poschr (drv, x, y-pos, '|'); + for (pos = 0; pos < len; pos++) { + if (2 * pos < ((long) promille * len / 500 + 1)) { + drv->chr(drv, x, y-pos, '|'); } else { ; /* print nothing */ } @@ -358,18 +358,18 @@ 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 ) +driver_alt_hbar(Driver *drv, int x, int y, int len, int promille, int pattern) { 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) return; - for ( pos=0; poschr (drv, x+pos, y, '-'); + for (pos = 0; pos < len; pos++) { + if (2 * pos < ((long) promille * len / 500 + 1)) { + drv->chr(drv, x+pos, y, '-'); } else { ; /* print nothing */ } @@ -377,7 +377,7 @@ 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 ) +driver_alt_num(Driver *drv, int x, int num) { /* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/ /* Moved to driver.c by Joris Robijn */ @@ -443,7 +443,7 @@ driver_alt_num( Driver * drv, int x, int num ) 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)) return; @@ -452,15 +452,15 @@ driver_alt_num( Driver * drv, int x, int num ) for (y = 0; y < 4; y++) 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 -driver_alt_heartbeat( Driver * drv, int state ) +driver_alt_heartbeat(Driver *drv, int state) { 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) return; @@ -475,18 +475,18 @@ driver_alt_heartbeat( Driver * drv, int state ) icon = (timer & 5) ? ICON_HEART_FILLED : ICON_HEART_OPEN; if (drv->icon) - drv->icon( drv, drv->width(drv), 1, icon); + drv->icon(drv, drv->width(drv), 1, icon); else - driver_alt_icon( drv, drv->width(drv), 1, icon); + driver_alt_icon(drv, drv->width(drv), 1, icon); } 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 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) return; @@ -515,31 +515,31 @@ driver_alt_icon( Driver * drv, int x, int y, int icon ) case ICON_PREV: ch1 = '|'; ch2 = '<'; break; case ICON_REC: ch1 = '('; ch2 = ')'; break; } - drv->chr( drv, x, y, ch1); + drv->chr(drv, x, y, ch1); 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... */ - 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_DEFAULT_ON: if (timer & 2 && drv->chr) { if (drv->icon) { - drv->icon( drv, x, y, ICON_BLOCK_FILLED); + drv->icon(drv, x, y, ICON_BLOCK_FILLED); } else { - driver_alt_icon( drv, x, y, ICON_BLOCK_FILLED ); + driver_alt_icon(drv, x, y, ICON_BLOCK_FILLED); } } break; case CURSOR_UNDER: if (timer & 2 && drv->chr) { - drv->chr( drv, x, y, '_'); + drv->chr(drv, x, y, '_'); } break; } diff --git a/server/driver.h b/server/driver.h index 8ecb31d..900b4cf 100644 --- a/server/driver.h +++ b/server/driver.h @@ -21,42 +21,42 @@ #endif Driver * -driver_load( char * name, char * filename ); +driver_load(const char *name, const char *filename); int -driver_unload( Driver * driver ); +driver_unload(Driver *driver); int -driver_bind_module( Driver * driver ); +driver_bind_module(Driver *driver); int -driver_unbind_module( Driver * driver ); +driver_unbind_module(Driver *driver); bool -driver_does_output( Driver * driver ); +driver_does_output(Driver *driver); bool -driver_does_input( Driver * driver ); +driver_does_input(Driver *driver); bool -driver_support_multiple( Driver * driver ); +driver_support_multiple(Driver *driver); bool -driver_stay_in_foreground( Driver * driver ); +driver_stay_in_foreground(Driver *driver); /* 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 diff --git a/server/drivers.c b/server/drivers.c index dc70a78..b322f9d 100644 --- a/server/drivers.c +++ b/server/drivers.c @@ -5,7 +5,7 @@ * This file is released under the GNU General Public License. Refer to the * 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. @@ -33,10 +33,10 @@ /* lcd.h is used for the driver API definition */ -LinkedList * loaded_drivers = NULL; -DisplayProps * display_props = NULL; +LinkedList *loaded_drivers = 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. */ int -drivers_load_driver( char * name ) +drivers_load_driver(const char *name) { - Driver * driver; - const char * s; - char * driverpath; - char * filename; + Driver *driver; + const char *s; + char *driverpath; + char *filename; - debug( RPT_DEBUG, "%s( name=\"%.40s\")", __FUNCTION__, name ); + debug(RPT_DEBUG, "%s(name=\"%.40s\")", __FUNCTION__, name); /* First driver ? */ - if( !loaded_drivers ) { + if (!loaded_drivers) { /* Create linked list */ - loaded_drivers = LL_new (); - if( !loaded_drivers ) { - report( RPT_ERR, "Error allocating driver list." ); + loaded_drivers = LL_new(); + if (!loaded_drivers) { + report(RPT_ERR, "Error allocating driver list."); return -1; } } /* Retrieve data from config file */ - s = config_get_string( "server", "DriverPath", 0, "" ); - driverpath = malloc( strlen(s) + 1 ); - strcpy( driverpath, s ); + s = config_get_string("server", "DriverPath", 0, ""); + driverpath = malloc(strlen(s) + 1); + strcpy(driverpath, s); - s = config_get_string( name, "File", 0, NULL ); - if( s ) { - filename = malloc( strlen(driverpath) + strlen(s) + 1 ); - strcpy( filename, driverpath ); - strcat( filename, s ); + s = config_get_string(name, "File", 0, NULL); + if (s) { + filename = malloc(strlen(driverpath) + strlen(s) + 1); + strcpy(filename, driverpath); + strcat(filename, s); } else { - filename = malloc( strlen(driverpath) + strlen(name) + strlen(MODULE_EXTENSION) + 1 ); - strcpy( filename, driverpath ); - strcat( filename, name ); - strcat( filename, MODULE_EXTENSION ); + filename = malloc(strlen(driverpath) + strlen(name) + strlen(MODULE_EXTENSION) + 1); + strcpy(filename, driverpath); + strcat(filename, name); + strcat(filename, MODULE_EXTENSION); } /* Load the module */ - driver = driver_load( name, filename ); - if( driver == NULL ) { + driver = driver_load(name, filename); + if (driver == NULL) { /* It failed. The message has already been given by driver_load() */ - report( RPT_INFO, "Module %.40s could not be loaded", filename ); - free( driverpath ); - free( filename ); + report(RPT_INFO, "Module %.40s could not be loaded", filename); + free(driverpath); + free(filename); return -1; } /* Add driver to list */ - LL_Push( loaded_drivers, driver ); + LL_Push(loaded_drivers, driver); - free( driverpath ); - free( filename ); + free(driverpath); + free(filename); /* If first driver, store display properties */ - if( driver_does_output(driver) && !display_props ) { - if( driver->width(driver) <= 0 || driver->width(driver) > LCD_MAX_WIDTH - || driver->height(driver) <= 0 || driver->height(driver) > LCD_MAX_HEIGHT ) { - report( RPT_ERR, "Driver [%.40s] has invalid display size", driver->name ); + if (driver_does_output(driver) && !display_props) { + if (driver->width(driver) <= 0 || driver->width(driver) > LCD_MAX_WIDTH + || driver->height(driver) <= 0 || driver->height(driver) > LCD_MAX_HEIGHT) { + report(RPT_ERR, "Driver [%.40s] has invalid display size", driver->name); } /* Allocate new DisplayProps structure */ - display_props = malloc( sizeof( DisplayProps )); + display_props = malloc(sizeof(DisplayProps)); display_props->width = driver->width(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); else 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); else display_props->cellheight = LCD_DEFAULT_CELLHEIGHT; } /* Return the driver type */ - if( driver_does_output(driver) ) { - if( driver_stay_in_foreground(driver) ) + if (driver_does_output(driver)) { + if (driver_stay_in_foreground(driver)) return 2; else return 1; @@ -140,14 +140,14 @@ drivers_load_driver( char * name ) * \return 0. */ 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 ) { - driver_unload( driver ); + while ((driver = LL_Pop(loaded_drivers)) != NULL) { + driver_unload(driver); } return 0; @@ -157,18 +157,18 @@ drivers_unload_all() /** * Get information from loaded drivers. * \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 * -drivers_get_info() +drivers_get_info(void) { Driver *drv; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); ForAllDrivers(drv) { - if( drv->get_info ) { - return drv->get_info( drv ); + if (drv->get_info) { + return drv->get_info(drv); } } return ""; @@ -180,15 +180,15 @@ drivers_get_info() * Call clear() function of all loaded drivers that have a clear() function defined. */ void -drivers_clear() +drivers_clear(void) { Driver *drv; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); ForAllDrivers(drv) { - if( drv->clear ) - drv->clear( drv ); + if (drv->clear) + drv->clear(drv); } } @@ -198,53 +198,53 @@ drivers_clear() * Call flush() function of all loaded drivers that have a flush() function defined. */ void -drivers_flush() +drivers_flush(void) { Driver *drv; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); ForAllDrivers(drv) { - if( drv->flush ) - drv->flush( drv ); + if (drv->flush) + drv->flush(drv); } } void -drivers_string( int x, int y, char * string ) +drivers_string(int x, int y, const char *string) { 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) { - if( drv->string ) - drv->string( drv, x, y, string ); + if (drv->string) + drv->string(drv, x, y, string); } } void -drivers_chr( int x, int y, char c ) +drivers_chr(int x, int y, char c) { 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) { - if( drv->chr ) - drv->chr( drv, x, y, c ); + if (drv->chr) + drv->chr(drv, x, y, c); } } 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; - 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 * @@ -253,141 +253,141 @@ drivers_vbar( int x, int y, int len, int promille, int pattern ) ForAllDrivers(drv) { - if( drv->vbar ) - drv->vbar( drv, x, y, len, promille, pattern ); + if (drv->vbar) + drv->vbar(drv, x, y, len, promille, pattern); else - driver_alt_vbar( drv, x, y, len, promille, pattern ); + driver_alt_vbar(drv, x, y, len, promille, pattern); } } 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; - 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) { - if( drv->hbar ) - drv->hbar( drv, x, y, len, promille, pattern ); + if (drv->hbar) + drv->hbar(drv, x, y, len, promille, pattern); else - driver_alt_hbar( drv, x, y, len, promille, pattern ); + driver_alt_hbar(drv, x, y, len, promille, pattern); } } void -drivers_num( int x, int num ) +drivers_num(int x, int num) { 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) { - if( drv->num ) - drv->num( drv, x, num ); + if (drv->num) + drv->num(drv, x, num); else - driver_alt_num( drv, x, num ); + driver_alt_num(drv, x, num); } } void -drivers_heartbeat( int state ) +drivers_heartbeat(int state) { Driver *drv; - debug( RPT_DEBUG, "%s( state=%d )", __FUNCTION__, state ); + debug(RPT_DEBUG, "%s(state=%d)", __FUNCTION__, state); ForAllDrivers(drv) { - if( drv->heartbeat ) - drv->heartbeat( drv, state ); + if (drv->heartbeat) + drv->heartbeat(drv, state); else - driver_alt_heartbeat( drv, state ); + driver_alt_heartbeat(drv, state); } } void -drivers_icon( int x, int y, int icon ) +drivers_icon(int x, int y, int icon) { 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) { /* Does the driver have the icon function ? */ - if( drv->icon ) { + if (drv->icon) { /* 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 */ - driver_alt_icon( drv, x, y, icon ); + driver_alt_icon(drv, x, y, icon); } } else { /* 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 -drivers_cursor( int x, int y, int state ) +drivers_cursor(int x, int y, int state) { 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) { - if( drv->cursor ) - drv->cursor( drv, x, y, state ); + if (drv->cursor) + drv->cursor(drv, x, y, state); else - driver_alt_cursor( drv, x, y, state ); + driver_alt_cursor(drv, x, y, state); } } void -drivers_backlight( int brightness ) +drivers_backlight(int brightness) { Driver *drv; - debug( RPT_DEBUG, "%s( brightness=%d )", __FUNCTION__, brightness ); + debug(RPT_DEBUG, "%s(brightness=%d)", __FUNCTION__, brightness); ForAllDrivers(drv) { - if( drv->backlight ) - drv->backlight( drv, brightness ); + if (drv->backlight) + drv->backlight(drv, brightness); } } void -drivers_output( int state ) +drivers_output(int state) { Driver *drv; - debug( RPT_DEBUG, "%s( state=%d )", __FUNCTION__, state ); + debug(RPT_DEBUG, "%s(state=%d)", __FUNCTION__, state); ForAllDrivers(drv) { - if( drv->output ) - drv->output( drv, state ); + if (drv->output) + drv->output(drv, state); } } const char * -drivers_get_key() +drivers_get_key(void) { /* Find the first input keystroke, if any */ Driver *drv; - const char * keystroke; + const char *keystroke; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); ForAllDrivers(drv) { - if( drv->get_key ) { - keystroke = drv->get_key( drv ); - if( keystroke != NULL ) { - report( RPT_INFO, "Driver [%.40s] generated keystroke %.40s", drv->name, keystroke ); + if (drv->get_key) { + keystroke = drv->get_key(drv); + if (keystroke != NULL) { + report(RPT_INFO, "Driver [%.40s] generated keystroke %.40s", drv->name, keystroke); return keystroke; } } diff --git a/server/drivers.h b/server/drivers.h index 16fd9c6..9685e6e 100644 --- a/server/drivers.h +++ b/server/drivers.h @@ -20,7 +20,7 @@ typedef struct DisplayProps { int cellwidth, cellheight; } DisplayProps; -extern DisplayProps * display_props; +extern DisplayProps *display_props; #ifndef bool # define bool short @@ -30,72 +30,72 @@ extern DisplayProps * display_props; int -drivers_load_driver( char * name ); +drivers_load_driver(const char *name); int -drivers_unload_all(); +drivers_unload_all(void); const char * -drivers_get_info(); +drivers_get_info(void); void -drivers_clear(); +drivers_clear(void); void -drivers_flush(); +drivers_flush(void); void -drivers_string( int x, int y, char * string ); +drivers_string(int x, int y, const char *string); void -drivers_chr( int x, int y, char c ); +drivers_chr(int x, int y, char c); 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 -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 -drivers_num( int x, int num ); +drivers_num(int x, int num); void -drivers_heartbeat( int state ); +drivers_heartbeat(int state); void -drivers_icon( int x, int y, int icon ); +drivers_icon(int x, int y, int icon); void -drivers_set_char( char ch, char *dat ); +drivers_set_char(char ch, char *dat); int -drivers_get_contrast(); +drivers_get_contrast(void); void -drivers_set_contrast( int contrast ); +drivers_set_contrast(int contrast); void -drivers_cursor( int x, int y, int state ); +drivers_cursor(int x, int y, int state); void -drivers_backlight( int brightness ); +drivers_backlight(int brightness); void -drivers_output( int state ); +drivers_output(int state); const char * -drivers_get_key(); +drivers_get_key(void); /* 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); } -static inline Driver * drivers_getnext () +static inline Driver *drivers_getnext(void) { return LL_GetNext(loaded_drivers); } diff --git a/server/drivers/CFontz633.c b/server/drivers/CFontz633.c index 1aeda32..e990949 100644 --- a/server/drivers/CFontz633.c +++ b/server/drivers/CFontz633.c @@ -1057,7 +1057,7 @@ CFontz633_hardware_clear (Driver *drvthis) * \param string String that gets written. */ 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; int i; diff --git a/server/drivers/CFontz633.h b/server/drivers/CFontz633.h index 8891cf6..8174e43 100644 --- a/server/drivers/CFontz633.h +++ b/server/drivers/CFontz633.h @@ -27,7 +27,7 @@ MODULE_EXPORT int CFontz633_cellwidth (Driver *drvthis); MODULE_EXPORT int CFontz633_cellheight (Driver *drvthis); MODULE_EXPORT void CFontz633_clear (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 const char *CFontz633_get_key (Driver *drvthis); diff --git a/server/drivers/CFontzPacket.c b/server/drivers/CFontzPacket.c index a822f54..33a7384 100644 --- a/server/drivers/CFontzPacket.c +++ b/server/drivers/CFontzPacket.c @@ -1286,7 +1286,7 @@ CFontzPacket_hardware_clear (Driver *drvthis) * \param string String that gets written. */ 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; int i; diff --git a/server/drivers/CFontzPacket.h b/server/drivers/CFontzPacket.h index ad0389b..9896e5e 100644 --- a/server/drivers/CFontzPacket.h +++ b/server/drivers/CFontzPacket.h @@ -27,7 +27,7 @@ MODULE_EXPORT int CFontzPacket_cellwidth (Driver *drvthis); MODULE_EXPORT int CFontzPacket_cellheight (Driver *drvthis); MODULE_EXPORT void CFontzPacket_clear (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 const char *CFontzPacket_get_key (Driver *drvthis); diff --git a/server/drivers/CwLnx.c b/server/drivers/CwLnx.c index e4e2646..641d15c 100644 --- a/server/drivers/CwLnx.c +++ b/server/drivers/CwLnx.c @@ -1232,7 +1232,7 @@ CwLnx_clear(Driver *drvthis) * \param string String that gets written. */ 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; diff --git a/server/drivers/CwLnx.h b/server/drivers/CwLnx.h index 62a14dc..e6a17db 100644 --- a/server/drivers/CwLnx.h +++ b/server/drivers/CwLnx.h @@ -58,7 +58,7 @@ MODULE_EXPORT int CwLnx_cellwidth(Driver *drvthis); MODULE_EXPORT int CwLnx_cellheight(Driver *drvthis); MODULE_EXPORT void CwLnx_clear(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 const char *CwLnx_get_key(Driver *drvthis); diff --git a/server/drivers/EyeboxOne.c b/server/drivers/EyeboxOne.c index 87a53d7..1405156 100644 --- a/server/drivers/EyeboxOne.c +++ b/server/drivers/EyeboxOne.c @@ -433,7 +433,7 @@ EyeboxOne_height (Driver *drvthis) * Display a string at x,y */ 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 bar,level; diff --git a/server/drivers/EyeboxOne.h b/server/drivers/EyeboxOne.h index 8eb8667..a59ef32 100644 --- a/server/drivers/EyeboxOne.h +++ b/server/drivers/EyeboxOne.h @@ -9,7 +9,7 @@ MODULE_EXPORT int EyeboxOne_width (Driver *drvthis); MODULE_EXPORT int EyeboxOne_height (Driver *drvthis); MODULE_EXPORT void EyeboxOne_clear (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_set_char (Driver *drvthis, int n, char *dat); diff --git a/server/drivers/IOWarrior.c b/server/drivers/IOWarrior.c index dc37eea..1e13d90 100644 --- a/server/drivers/IOWarrior.c +++ b/server/drivers/IOWarrior.c @@ -629,7 +629,7 @@ PrivateData *p = drvthis->private_data; * \param string String that gets written. */ 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; int i; diff --git a/server/drivers/IOWarrior.h b/server/drivers/IOWarrior.h index 8cc4c36..fdabe3a 100644 --- a/server/drivers/IOWarrior.h +++ b/server/drivers/IOWarrior.h @@ -127,7 +127,7 @@ MODULE_EXPORT int IOWarrior_cellheight(Driver *drvthis); MODULE_EXPORT int IOWarrior_cellwidth(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_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_backlight(Driver *drvthis, int on); MODULE_EXPORT void IOWarrior_vbar(Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/MD8800.c b/server/drivers/MD8800.c index 983e118..7c2db9f 100644 --- a/server/drivers/MD8800.c +++ b/server/drivers/MD8800.c @@ -571,7 +571,7 @@ MD8800_clear (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; int i; diff --git a/server/drivers/MD8800.h b/server/drivers/MD8800.h index 6b713e0..b367e21 100644 --- a/server/drivers/MD8800.h +++ b/server/drivers/MD8800.h @@ -38,7 +38,7 @@ MODULE_EXPORT int MD8800_cellwidth (Driver *drvthis); MODULE_EXPORT int MD8800_cellheight (Driver *drvthis); MODULE_EXPORT void MD8800_clear (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_output (Driver *drvthis, int on); MODULE_EXPORT const char * MD8800_get_info(Driver *drvthis); diff --git a/server/drivers/MtxOrb.c b/server/drivers/MtxOrb.c index d144832..acd8eae 100644 --- a/server/drivers/MtxOrb.c +++ b/server/drivers/MtxOrb.c @@ -508,7 +508,7 @@ MtxcOrb_cellheight (Driver *drvthis) * \param string String that gets written. */ 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; int i; @@ -1064,7 +1064,7 @@ MtxOrb_get_info (Driver *drvthis) * \param options Options (currently unused). */ 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; @@ -1103,7 +1103,7 @@ MtxOrb_vbar (Driver * drvthis, int x, int y, int len, int promille, int options) * \param options Options (currently unused). */ 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; diff --git a/server/drivers/MtxOrb.h b/server/drivers/MtxOrb.h index 0e9fa16..32bd9d1 100644 --- a/server/drivers/MtxOrb.h +++ b/server/drivers/MtxOrb.h @@ -24,12 +24,12 @@ MODULE_EXPORT int MtxOrb_cellwidth (Driver *drvthis); MODULE_EXPORT int MtxOrb_cellheight (Driver *drvthis); MODULE_EXPORT void MtxOrb_clear (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 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_hbar (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 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_cursor (Driver *drvthis, int x, int y, int state); diff --git a/server/drivers/NoritakeVFD.c b/server/drivers/NoritakeVFD.c index 5ca3a89..9c65cc0 100644 --- a/server/drivers/NoritakeVFD.c +++ b/server/drivers/NoritakeVFD.c @@ -688,7 +688,7 @@ NoritakeVFD_clear (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; int i; diff --git a/server/drivers/NoritakeVFD.h b/server/drivers/NoritakeVFD.h index 0a47908..fb3a0c9 100644 --- a/server/drivers/NoritakeVFD.h +++ b/server/drivers/NoritakeVFD.h @@ -38,7 +38,7 @@ MODULE_EXPORT int NoritakeVFD_cellwidth (Driver *drvthis); MODULE_EXPORT int NoritakeVFD_cellheight (Driver *drvthis); MODULE_EXPORT void NoritakeVFD_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/bayrad.c b/server/drivers/bayrad.c index 419831f..906e3a6 100644 --- a/server/drivers/bayrad.c +++ b/server/drivers/bayrad.c @@ -178,7 +178,7 @@ bayrad_init(Driver *drvthis) // your driver. MODULE_EXPORT void -bayrad_close(Driver * drvthis) +bayrad_close(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -202,7 +202,7 @@ bayrad_close(Driver * drvthis) // Returns the display width // MODULE_EXPORT int -bayrad_width(Driver * drvthis) +bayrad_width(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -214,7 +214,7 @@ bayrad_width(Driver * drvthis) // Returns the display height // MODULE_EXPORT int -bayrad_height(Driver * drvthis) +bayrad_height(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -226,7 +226,7 @@ bayrad_height(Driver * drvthis) // Returns the display's cell width // MODULE_EXPORT int -bayrad_cellwidth(Driver * drvthis) +bayrad_cellwidth(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -238,7 +238,7 @@ bayrad_cellwidth(Driver * drvthis) // Returns the display's cell height // MODULE_EXPORT int -bayrad_cellheight(Driver * drvthis) +bayrad_cellheight(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -250,7 +250,7 @@ bayrad_cellheight(Driver * drvthis) // Clears the LCD screen // MODULE_EXPORT void -bayrad_clear(Driver * drvthis) +bayrad_clear(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -263,7 +263,7 @@ bayrad_clear(Driver * drvthis) // Flushes all output to the lcd... // MODULE_EXPORT void -bayrad_flush(Driver * drvthis) +bayrad_flush(Driver *drvthis) { 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). // 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; 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). // 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; 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... // MODULE_EXPORT void -bayrad_backlight(Driver * drvthis, int on) +bayrad_backlight(Driver *drvthis, int on) { //PrivateData *p = drvthis->private_data; @@ -364,7 +364,7 @@ bayrad_backlight(Driver * drvthis, int on) // Tells the driver to get ready for vertical bargraphs. // static void -bayrad_init_vbar(Driver * drvthis) +bayrad_init_vbar(Driver *drvthis) { PrivateData *p = drvthis->private_data; 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. // static void -bayrad_init_hbar(Driver * drvthis) +bayrad_init_hbar(Driver *drvthis) { PrivateData *p = drvthis->private_data; 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. // static void -bayrad_init_num(Driver * drvthis) +bayrad_init_num(Driver *drvthis) { //PrivateData *p = drvthis->private_data; @@ -551,7 +551,7 @@ bayrad_init_num(Driver * drvthis) // Draws a big (4-row) number. // MODULE_EXPORT void -bayrad_num(Driver * drvthis, int x, int num) +bayrad_num(Driver *drvthis, int x, int num) { //PrivateData *p = drvthis->private_data; @@ -562,7 +562,7 @@ bayrad_num(Driver * drvthis, int x, int num) // Changes the font data of character n. // 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; 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. // 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; @@ -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. // 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; @@ -643,7 +643,7 @@ bayrad_hbar(Driver * drvthis, int x, int y, int len, int promille, int options) // Places an icon on screen // 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; 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". // MODULE_EXPORT const char * -bayrad_get_key(Driver * drvthis) +bayrad_get_key(Driver *drvthis) { PrivateData *p = drvthis->private_data; fd_set brfdset; diff --git a/server/drivers/bayrad.h b/server/drivers/bayrad.h index 1457d2c..3713eca 100644 --- a/server/drivers/bayrad.h +++ b/server/drivers/bayrad.h @@ -10,25 +10,25 @@ #include "lcd.h" -MODULE_EXPORT int bayrad_init(Driver * drvthis); -MODULE_EXPORT void bayrad_close(Driver * drvthis); -MODULE_EXPORT int bayrad_width(Driver * drvthis); -MODULE_EXPORT int bayrad_height(Driver * drvthis); -MODULE_EXPORT int bayrad_cellwidth(Driver * drvthis); -MODULE_EXPORT int bayrad_cellheight(Driver * drvthis); -MODULE_EXPORT void bayrad_clear(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_chr(Driver * drvthis, int x, int y, char c); +MODULE_EXPORT int bayrad_init(Driver *drvthis); +MODULE_EXPORT void bayrad_close(Driver *drvthis); +MODULE_EXPORT int bayrad_width(Driver *drvthis); +MODULE_EXPORT int bayrad_height(Driver *drvthis); +MODULE_EXPORT int bayrad_cellwidth(Driver *drvthis); +MODULE_EXPORT int bayrad_cellheight(Driver *drvthis); +MODULE_EXPORT void bayrad_clear(Driver *drvthis); +MODULE_EXPORT void bayrad_flush(Driver *drvthis); +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_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 int bayrad_icon(Driver * drvthis, int x, int y, int icon); +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 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 diff --git a/server/drivers/curses_drv.c b/server/drivers/curses_drv.c index 2c5795c..d4061ba 100644 --- a/server/drivers/curses_drv.c +++ b/server/drivers/curses_drv.c @@ -430,7 +430,7 @@ curses_backlight (Driver *drvthis, int on) // upper-left is (1,1), and the lower right should be (20,4). // 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; diff --git a/server/drivers/curses_drv.h b/server/drivers/curses_drv.h index a922508..78a8cb3 100644 --- a/server/drivers/curses_drv.h +++ b/server/drivers/curses_drv.h @@ -3,13 +3,13 @@ #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 int curses_width (Driver *drvthis); MODULE_EXPORT int curses_height (Driver *drvthis); MODULE_EXPORT void curses_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/debug.c b/server/drivers/debug.c index 4b40b60..305f1f6 100644 --- a/server/drivers/debug.c +++ b/server/drivers/debug.c @@ -137,7 +137,7 @@ debug_flush (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; diff --git a/server/drivers/debug.h b/server/drivers/debug.h index da9ac90..97e70ba 100644 --- a/server/drivers/debug.h +++ b/server/drivers/debug.h @@ -9,7 +9,7 @@ MODULE_EXPORT int debug_width (Driver *drvthis); MODULE_EXPORT int debug_height (Driver *drvthis); MODULE_EXPORT void debug_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/ea65.c b/server/drivers/ea65.c index c69cfc9..afea52a 100644 --- a/server/drivers/ea65.c +++ b/server/drivers/ea65.c @@ -59,7 +59,7 @@ MODULE_EXPORT char *symbol_prefix = "EA65_"; // Opens com port and sets baud correctly... // MODULE_EXPORT int -EA65_init (Driver * drvthis) +EA65_init (Driver *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). // 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; @@ -252,7 +252,7 @@ EA65_chr (Driver * drvthis, int x, int y, char c) // Sets the backlight on or off // MODULE_EXPORT void -EA65_backlight (Driver * drvthis, int on) +EA65_backlight (Driver *drvthis, int on) { PrivateData *p = (PrivateData *) drvthis->private_data; @@ -269,7 +269,7 @@ EA65_backlight (Driver * drvthis, int on) // Clears the LCD screen // MODULE_EXPORT void -EA65_clear (Driver * drvthis) +EA65_clear (Driver *drvthis) { 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). // 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; @@ -304,7 +304,7 @@ EA65_string (Driver * drvthis, int x, int y, char string[]) //// Turns the recording LED on or off as desired. //// MODULE_EXPORT void -EA65_output (Driver * drvthis, int on) +EA65_output (Driver *drvthis, int on) { PrivateData *p = (PrivateData *) drvthis->private_data; diff --git a/server/drivers/ea65.h b/server/drivers/ea65.h index 8ae1594..8135452 100644 --- a/server/drivers/ea65.h +++ b/server/drivers/ea65.h @@ -6,16 +6,16 @@ #define DEFAULT_BRIGHTNESS 500 #define DEFAULT_OFFBRIGHTNESS 0 -MODULE_EXPORT int EA65_init (Driver * drvthis); -MODULE_EXPORT void EA65_close (Driver * drvthis); -MODULE_EXPORT int EA65_width (Driver * drvthis); -MODULE_EXPORT int EA65_height (Driver * drvthis); -MODULE_EXPORT void EA65_clear (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_chr (Driver * drvthis, int x, int y, char c); +MODULE_EXPORT int EA65_init (Driver *drvthis); +MODULE_EXPORT void EA65_close (Driver *drvthis); +MODULE_EXPORT int EA65_width (Driver *drvthis); +MODULE_EXPORT int EA65_height (Driver *drvthis); +MODULE_EXPORT void EA65_clear (Driver *drvthis); +MODULE_EXPORT void EA65_flush (Driver *drvthis); +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_brightness (Driver * drvthis, int promille); -MODULE_EXPORT void EA65_output (Driver * drvthis, int on); +MODULE_EXPORT void EA65_brightness (Driver *drvthis, int promille); +MODULE_EXPORT void EA65_output (Driver *drvthis, int on); #endif diff --git a/server/drivers/g15.c b/server/drivers/g15.c index 059b242..84dc362 100644 --- a/server/drivers/g15.c +++ b/server/drivers/g15.c @@ -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 // 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; 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; diff --git a/server/drivers/g15.h b/server/drivers/g15.h index 2cf4388..a77a088 100644 --- a/server/drivers/g15.h +++ b/server/drivers/g15.h @@ -80,13 +80,13 @@ MODULE_EXPORT int g15_cellwidth (Driver *drvthis); MODULE_EXPORT int g15_cellheight (Driver *drvthis); MODULE_EXPORT void g15_clear (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 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_vbar(Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT const char * g15_get_key (Driver *drvthis); 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_*/ diff --git a/server/drivers/glcdlib.c b/server/drivers/glcdlib.c index 789184a..8e8a2c6 100644 --- a/server/drivers/glcdlib.c +++ b/server/drivers/glcdlib.c @@ -262,7 +262,7 @@ glcdlib_flush (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,6). // 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"); y--; diff --git a/server/drivers/glcdlib.h b/server/drivers/glcdlib.h index 3b66970..d5f9710 100644 --- a/server/drivers/glcdlib.h +++ b/server/drivers/glcdlib.h @@ -35,7 +35,7 @@ MODULE_EXPORT int glcdlib_width (Driver *drvthis); MODULE_EXPORT int glcdlib_height (Driver *drvthis); MODULE_EXPORT void glcdlib_clear (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 int glcdlib_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT int glcdlib_cellwidth (Driver *drvthis); diff --git a/server/drivers/glk.c b/server/drivers/glk.c index edf2b6e..7921dd3 100644 --- a/server/drivers/glk.c +++ b/server/drivers/glk.c @@ -393,10 +393,10 @@ glk_flush(Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; - char *s; + const char *s; debug(RPT_DEBUG, "glk_string(%d, %d, \"%s\")", x, y, string); diff --git a/server/drivers/glk.h b/server/drivers/glk.h index 2f8a57d..5a1bb13 100644 --- a/server/drivers/glk.h +++ b/server/drivers/glk.h @@ -11,7 +11,7 @@ MODULE_EXPORT int glk_cellwidth(Driver *drvthis); MODULE_EXPORT int glk_cellheight(Driver *drvthis); MODULE_EXPORT void glk_clear(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_old_vbar(Driver *drvthis, int x, int len); diff --git a/server/drivers/hd44780.c b/server/drivers/hd44780.c index 7ee7631..440d29c 100644 --- a/server/drivers/hd44780.c +++ b/server/drivers/hd44780.c @@ -127,7 +127,7 @@ MODULE_EXPORT char *symbol_prefix = "HD44780_"; // Opens com port and sets baud correctly... // MODULE_EXPORT int -HD44780_init (Driver * drvthis) +HD44780_init (Driver *drvthis) { // TODO: remove the two magic numbers below // 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 // 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; int i; diff --git a/server/drivers/hd44780.h b/server/drivers/hd44780.h index 1a48b9c..eb46c39 100644 --- a/server/drivers/hd44780.h +++ b/server/drivers/hd44780.h @@ -26,7 +26,7 @@ MODULE_EXPORT int HD44780_cellwidth (Driver *drvthis); MODULE_EXPORT int HD44780_cellheight (Driver *drvthis); MODULE_EXPORT void HD44780_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/imon.c b/server/drivers/imon.c index 47bf56c..180ae62 100644 --- a/server/drivers/imon.c +++ b/server/drivers/imon.c @@ -245,7 +245,7 @@ MODULE_EXPORT void imon_flush (Driver *drvthis) * \param y Vertical character position (row). * \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; diff --git a/server/drivers/imon.h b/server/drivers/imon.h index 977ac10..908f8b6 100644 --- a/server/drivers/imon.h +++ b/server/drivers/imon.h @@ -36,7 +36,7 @@ MODULE_EXPORT int imon_cellwidth (Driver *drvthis); MODULE_EXPORT int imon_cellheight (Driver *drvthis); MODULE_EXPORT void imon_clear (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 int imon_icon (Driver *drvthis, int x, int y, int icon); MODULE_EXPORT const char *imon_get_info (Driver *drvthis); diff --git a/server/drivers/lb216.c b/server/drivers/lb216.c index 2d0e48e..f955360 100644 --- a/server/drivers/lb216.c +++ b/server/drivers/lb216.c @@ -58,8 +58,8 @@ typedef struct driver_private_data { } PrivateData; -static void LB216_hidecursor(Driver * drvthis); -static void LB216_reboot(Driver * drvthis); +static void LB216_hidecursor(Driver *drvthis); +static void LB216_reboot(Driver *drvthis); // Vars for the server core MODULE_EXPORT char *api_version = API_VERSION; @@ -74,7 +74,7 @@ MODULE_EXPORT char *symbol_prefix = "LB216_"; // Opens com port and sets baud correctly... // MODULE_EXPORT int -LB216_init(Driver * drvthis) +LB216_init(Driver *drvthis) { PrivateData *p; struct termios portset; @@ -190,7 +190,7 @@ LB216_init(Driver * drvthis) // Clean-up // MODULE_EXPORT void -LB216_close(Driver * drvthis) +LB216_close(Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -256,7 +256,7 @@ LB216_cellheight (Driver *drvthis) // Clears the LCD screen // MODULE_EXPORT void -LB216_clear (Driver * drvthis) +LB216_clear (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -268,7 +268,7 @@ LB216_clear (Driver * drvthis) // Flushes the framebuffer to the LCD // MODULE_EXPORT void -LB216_flush(Driver * drvthis) +LB216_flush(Driver *drvthis) { PrivateData *p = drvthis->private_data; 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). // 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; @@ -315,7 +315,7 @@ LB216_chr(Driver * drvthis, int x, int y, char c) // an intermediate brightness... // MODULE_EXPORT void -LB216_backlight(Driver * drvthis, int on) +LB216_backlight(Driver *drvthis, int on) { PrivateData *p = drvthis->private_data; @@ -329,7 +329,7 @@ LB216_backlight(Driver * drvthis, int on) ///////////////////////////////////////////////////////////////// // Get rid of the blinking curson // -static void LB216_hidecursor(Driver * drvthis) +static void LB216_hidecursor(Driver *drvthis) { PrivateData *p = drvthis->private_data; char out[4]; @@ -341,7 +341,7 @@ static void LB216_hidecursor(Driver * drvthis) ///////////////////////////////////////////////////////////////// // Reset the display bios // -static void LB216_reboot(Driver * drvthis) +static void LB216_reboot(Driver *drvthis) { PrivateData *p = drvthis->private_data; char out[4]; @@ -352,7 +352,7 @@ static void LB216_reboot(Driver * drvthis) 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; 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() // static void -LB216_init_vbar(Driver * drvthis) +LB216_init_vbar(Driver *drvthis) { PrivateData *p = drvthis->private_data; char a[] = { @@ -468,7 +468,7 @@ LB216_init_vbar(Driver * drvthis) // Inits horizontal bars... // static void -LB216_init_hbar(Driver * drvthis) +LB216_init_hbar(Driver *drvthis) { PrivateData *p = drvthis->private_data; char a[] = { @@ -536,7 +536,7 @@ LB216_init_hbar(Driver * drvthis) // Draws a vertical bar... // MODULE_EXPORT void -LB216_vbar(Driver * drvthis, int x, int len) +LB216_vbar(Driver *drvthis, int x, int len) { PrivateData *p = drvthis->private_data; 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. // 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; 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... // 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; char out[4]; @@ -608,7 +608,7 @@ LB216_set_char(Driver * drvthis, int n, char *dat) 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; static char heart_open[] = { diff --git a/server/drivers/lb216.h b/server/drivers/lb216.h index 6958cb7..ba37583 100644 --- a/server/drivers/lb216.h +++ b/server/drivers/lb216.h @@ -3,24 +3,24 @@ #include "lcd.h" -MODULE_EXPORT int LB216_init(Driver * drvthis); -MODULE_EXPORT void LB216_close(Driver * drvthis); +MODULE_EXPORT int LB216_init(Driver *drvthis); +MODULE_EXPORT void LB216_close(Driver *drvthis); MODULE_EXPORT int LB216_width (Driver *drvthis); MODULE_EXPORT int LB216_height (Driver *drvthis); MODULE_EXPORT int LB216_cellwidth (Driver *drvthis); MODULE_EXPORT int LB216_cellheight (Driver *drvthis); -MODULE_EXPORT void LB216_clear (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_chr(Driver * drvthis, int x, int y, char c) ; +MODULE_EXPORT void LB216_clear (Driver *drvthis); +MODULE_EXPORT void LB216_flush(Driver *drvthis); +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_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_num(Driver * drvthis, int x, int num); -MODULE_EXPORT int LB216_icon(Driver * drvthis, int x, int y, int icon); +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_num(Driver *drvthis, int x, int num); +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 diff --git a/server/drivers/lcd.h b/server/drivers/lcd.h index 9bf7550..348be4e 100644 --- a/server/drivers/lcd.h +++ b/server/drivers/lcd.h @@ -127,44 +127,44 @@ typedef struct lcd_logical_driver { /* The driver loader will look for symbols with these names ! */ /* mandatory functions (necessary for all drivers) */ - int (*init) (struct lcd_logical_driver* drvthis); - void (*close) (struct lcd_logical_driver* drvthis); + int (*init) (struct lcd_logical_driver *drvthis); + void (*close) (struct lcd_logical_driver *drvthis); /* essential output functions (necessary for output drivers) */ - int (*width) (struct lcd_logical_driver* drvthis); - int (*height) (struct lcd_logical_driver* drvthis); - void (*clear) (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 (*chr) (struct lcd_logical_driver* drvthis, int x, int y, char c); + int (*width) (struct lcd_logical_driver *drvthis); + int (*height) (struct lcd_logical_driver *drvthis); + void (*clear) (struct lcd_logical_driver *drvthis); + void (*flush) (struct lcd_logical_driver *drvthis); + 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); /* 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) */ - 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 (*num) (struct lcd_logical_driver* drvthis, int x, int num); - void (*heartbeat) (struct lcd_logical_driver* drvthis, int state); - 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 (*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 (*num) (struct lcd_logical_driver *drvthis, int x, int num); + void (*heartbeat) (struct lcd_logical_driver *drvthis, int state); + 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); /* user-defined character functions, are those still supported ? */ - void (*set_char) (struct lcd_logical_driver* drvthis, int n, unsigned char *dat); - int (*get_free_chars) (struct lcd_logical_driver* drvthis); - int (*cellwidth) (struct lcd_logical_driver* drvthis); - int (*cellheight) (struct lcd_logical_driver* drvthis); + void (*set_char) (struct lcd_logical_driver *drvthis, int n, unsigned char *dat); + int (*get_free_chars) (struct lcd_logical_driver *drvthis); + int (*cellwidth) (struct lcd_logical_driver *drvthis); + int (*cellheight) (struct lcd_logical_driver *drvthis); /* Hardware functions */ - int (*get_contrast) (struct lcd_logical_driver* drvthis); - void (*set_contrast) (struct lcd_logical_driver* drvthis, int promille); - int (*get_brightness) (struct lcd_logical_driver* drvthis, int state); - void (*set_brightness) (struct lcd_logical_driver* drvthis, int state, int promille); - void (*backlight) (struct lcd_logical_driver* drvthis, int on); - void (*output) (struct lcd_logical_driver* drvthis, int state); + int (*get_contrast) (struct lcd_logical_driver *drvthis); + void (*set_contrast) (struct lcd_logical_driver *drvthis, int promille); + int (*get_brightness) (struct lcd_logical_driver *drvthis, int state); + void (*set_brightness) (struct lcd_logical_driver *drvthis, int state, int promille); + void (*backlight) (struct lcd_logical_driver *drvthis, int on); + void (*output) (struct lcd_logical_driver *drvthis, int state); /* 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 ********/ diff --git a/server/drivers/lcdm001.c b/server/drivers/lcdm001.c index b59a216..ecc9c0f 100644 --- a/server/drivers/lcdm001.c +++ b/server/drivers/lcdm001.c @@ -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). // 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; int i; diff --git a/server/drivers/lcdm001.h b/server/drivers/lcdm001.h index db740fb..246afa6 100644 --- a/server/drivers/lcdm001.h +++ b/server/drivers/lcdm001.h @@ -39,7 +39,7 @@ MODULE_EXPORT int lcdm001_width (Driver *drvthis); MODULE_EXPORT int lcdm001_height (Driver *drvthis); MODULE_EXPORT void lcdm001_clear (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_old_vbar (Driver *drvthis, int x, int len); diff --git a/server/drivers/ms6931.c b/server/drivers/ms6931.c index ab8ad85..09715ec 100644 --- a/server/drivers/ms6931.c +++ b/server/drivers/ms6931.c @@ -384,7 +384,7 @@ ms6931_clear (Driver *drvthis) // upper-left is (1,1), and the lower right should be (16,2). // 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; int i; diff --git a/server/drivers/ms6931.h b/server/drivers/ms6931.h index 3f16c77..11eb467 100644 --- a/server/drivers/ms6931.h +++ b/server/drivers/ms6931.h @@ -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_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 void ms6931_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern); MODULE_EXPORT void ms6931_heartbeat (Driver *drvthis, int state); diff --git a/server/drivers/mtc_s16209x.c b/server/drivers/mtc_s16209x.c index 286bf98..305d19b 100644 --- a/server/drivers/mtc_s16209x.c +++ b/server/drivers/mtc_s16209x.c @@ -118,7 +118,7 @@ MODULE_EXPORT char *symbol_prefix = "MTC_S16209X_"; // Opens com port and sets baud correctly... // MODULE_EXPORT int -MTC_S16209X_init (Driver * drvthis) +MTC_S16209X_init (Driver *drvthis) { PrivateData *p; struct termios portset; @@ -228,7 +228,7 @@ MTC_S16209X_init (Driver * drvthis) // Clean-up // MODULE_EXPORT void -MTC_S16209X_close (Driver * drvthis) +MTC_S16209X_close (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -258,7 +258,7 @@ MTC_S16209X_close (Driver * drvthis) // Returns the display width // MODULE_EXPORT int -MTC_S16209X_width (Driver * drvthis) +MTC_S16209X_width (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -269,7 +269,7 @@ MTC_S16209X_width (Driver * drvthis) // Returns the display height // MODULE_EXPORT int -MTC_S16209X_height (Driver * drvthis) +MTC_S16209X_height (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -280,7 +280,7 @@ MTC_S16209X_height (Driver * drvthis) // Returns the display's cell width // MODULE_EXPORT int -MTC_S16209X_cellwidth (Driver * drvthis) +MTC_S16209X_cellwidth (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -291,7 +291,7 @@ MTC_S16209X_cellwidth (Driver * drvthis) // Returns the display's cell height // MODULE_EXPORT int -MTC_S16209X_cellheight (Driver * drvthis) +MTC_S16209X_cellheight (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -302,7 +302,7 @@ MTC_S16209X_cellheight (Driver * drvthis) // Clears the LCD screen // MODULE_EXPORT void -MTC_S16209X_clear (Driver * drvthis) +MTC_S16209X_clear (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -314,7 +314,7 @@ MTC_S16209X_clear (Driver * drvthis) // Flushes the framebuffer to the LCD // 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 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). // 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; @@ -371,7 +371,7 @@ MTC_S16209X_chr (Driver * drvthis, int x, int y, char c) // an intermediate brightness... // 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 */ //PrivateData *p = drvthis->private_data; @@ -384,7 +384,7 @@ MTC_S16209X_backlight (Driver * drvthis, int on) // Get rid of the blinking cursor // static void -MTC_S16209X_hidecursor (Driver * drvthis) +MTC_S16209X_hidecursor (Driver *drvthis) { PrivateData *p = drvthis->private_data; int result; @@ -406,7 +406,7 @@ MTC_S16209X_hidecursor (Driver * drvthis) // Reset the display bios // static void -MTC_S16209X_reboot (Driver * drvthis) +MTC_S16209X_reboot (Driver *drvthis) { PrivateData *p = drvthis->private_data; int result; @@ -418,7 +418,7 @@ MTC_S16209X_reboot (Driver * drvthis) #endif // CAN_REBOOT_LCD 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; 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() // static void -MTC_S16209X_init_vbar (Driver * drvthis) +MTC_S16209X_init_vbar (Driver *drvthis) { PrivateData *p = drvthis->private_data; static char a[] = { @@ -529,7 +529,7 @@ MTC_S16209X_init_vbar (Driver * drvthis) // Inits horizontal bars... // static void -MTC_S16209X_init_hbar (Driver * drvthis) +MTC_S16209X_init_hbar (Driver *drvthis) { PrivateData *p = drvthis->private_data; static char a[] = { @@ -597,7 +597,7 @@ MTC_S16209X_init_hbar (Driver * drvthis) // Draws a vertical bar... // 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; @@ -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. // 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; @@ -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... // 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; char out[4]; @@ -664,7 +664,7 @@ MTC_S16209X_set_char (Driver * drvthis, int n, char *dat) } 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; static char heart_open[] = { diff --git a/server/drivers/mtc_s16209x.h b/server/drivers/mtc_s16209x.h index 3a91683..1e48cc6 100644 --- a/server/drivers/mtc_s16209x.h +++ b/server/drivers/mtc_s16209x.h @@ -40,23 +40,23 @@ #include "lcd.h" -MODULE_EXPORT int MTC_S16209X_init(Driver * drvthis); -MODULE_EXPORT void MTC_S16209X_close(Driver * drvthis); +MODULE_EXPORT int MTC_S16209X_init(Driver *drvthis); +MODULE_EXPORT void MTC_S16209X_close(Driver *drvthis); MODULE_EXPORT int MTC_S16209X_width (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_height (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_cellwidth (Driver *drvthis); MODULE_EXPORT int MTC_S16209X_cellheight (Driver *drvthis); -MODULE_EXPORT void MTC_S16209X_clear (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_chr(Driver * drvthis, int x, int y, char c) ; +MODULE_EXPORT void MTC_S16209X_clear (Driver *drvthis); +MODULE_EXPORT void MTC_S16209X_flush(Driver *drvthis); +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_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 int MTC_S16209X_icon(Driver * drvthis, int x, int y, int icon); +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 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 diff --git a/server/drivers/sed1520.c b/server/drivers/sed1520.c index 449839e..cc93173 100644 --- a/server/drivers/sed1520.c +++ b/server/drivers/sed1520.c @@ -301,7 +301,7 @@ sed1520_flush (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; int i; diff --git a/server/drivers/sed1520.h b/server/drivers/sed1520.h index 7eb506f..123fbc4 100644 --- a/server/drivers/sed1520.h +++ b/server/drivers/sed1520.h @@ -11,7 +11,7 @@ MODULE_EXPORT int sed1520_cellwidth (Driver *drvthis); MODULE_EXPORT int sed1520_cellheight (Driver *drvthis); MODULE_EXPORT void sed1520_clear (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_old_vbar (Driver *drvthis, int x, int len); diff --git a/server/drivers/serialPOS.c b/server/drivers/serialPOS.c index c984f1f..f714254 100644 --- a/server/drivers/serialPOS.c +++ b/server/drivers/serialPOS.c @@ -462,7 +462,7 @@ MtxcOrb_cellheight (Driver *drvthis) * \param string String that gets written. */ 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; int i; @@ -712,7 +712,7 @@ serialPOS_get_info (Driver *drvthis) * \param options Options (currently unused). */ 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; // map @@ -765,7 +765,7 @@ serialPOS_vbar (Driver * drvthis, int x, int y, int len, int promille, int optio * \param options Options (currently unused). */ 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; int pixels = ((long) 2 * len * p->cellwidth) * promille / 2000; diff --git a/server/drivers/serialPOS.h b/server/drivers/serialPOS.h index 74a16a2..0cad488 100644 --- a/server/drivers/serialPOS.h +++ b/server/drivers/serialPOS.h @@ -20,12 +20,12 @@ MODULE_EXPORT int serialPOS_cellwidth (Driver *drvthis); MODULE_EXPORT int serialPOS_cellheight (Driver *drvthis); MODULE_EXPORT void serialPOS_clear (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 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_hbar (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 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_cursor (Driver *drvthis, int x, int y, int state); diff --git a/server/drivers/serialVFD.c b/server/drivers/serialVFD.c index adec9fc..e27ff3d 100644 --- a/server/drivers/serialVFD.c +++ b/server/drivers/serialVFD.c @@ -129,11 +129,11 @@ serialVFD_init (Driver *drvthis) p->refresh_timer = 480; p->hw_brightness = 0; - debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis ); + debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis); /* 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 */ 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); 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 { /* 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)) { report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default %d.\n", drvthis->name, DEFAULT_SPEED); @@ -158,7 +158,7 @@ serialVFD_init (Driver *drvthis) else if (tmp == 19200) p->speed = B19200; 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 */ 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; /* 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)) { report(RPT_WARNING, "%s: The number of Custom-Characters must be between 0 and 99. Using default.", drvthis->name, 0); @@ -215,10 +215,10 @@ serialVFD_init (Driver *drvthis) 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 - 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); return -1; } @@ -243,11 +243,11 @@ serialVFD_init (Driver *drvthis) //setup displayspecific data 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 - 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[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]); serialVFD_backlight(drvthis, 1); report(RPT_DEBUG, "%s: init() done", drvthis->name); return 0; @@ -304,9 +304,9 @@ serialVFD_backlight (Driver *drvthis, int on) // map range [0, 1000] -> [0, 4] that the hardware understands //(4 steps 0-250, 251-500, 501-750, 751-1000) hardware_value /= 251; - if(hardware_value != p->hw_brightness){ - p->hw_brightness=hardware_value; - Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[p->hw_brightness][1],\ + if (hardware_value != p->hw_brightness) { + p->hw_brightness = hardware_value; + Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[p->hw_brightness][1],\ 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; - if (p->customchars >= p->cellheight || p->predefined_vbar == 1){ + if (p->customchars >= p->cellheight || p->predefined_vbar == 1) { serialVFD_init_vbar(drvthis); 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); } } @@ -340,11 +340,11 @@ serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int option { 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); 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); } } @@ -391,10 +391,10 @@ serialVFD_put_char (Driver *drvthis, int n) { // put char in display 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 - 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, (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 } @@ -415,37 +415,37 @@ serialVFD_flush (Driver *drvthis) for (i = 0; i < p->customchars; i++) { for (j = 0; j < p->usr_chr_dot_assignment[0]; j++) { if (p->custom_char[i][j] != p->custom_char_store[i][j]) { - custom_char_changed[i]=1; -// report (RPT_ERR, "%s: Char: %X %i\n", __FUNCTION__, i, j, strerror (errno)); + custom_char_changed[i] = 1; +// 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. // 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 memset(p->backingstore, 0, p->width * p->height); // clear Backing-store - for(i=0;icustomchars;i++) // refresh all customcharacters - custom_char_changed[i]=1; + for (i = 0; i < p->customchars; i++) // refresh all customcharacters + custom_char_changed[i] = 1; p->refresh_timer = 0; } p->refresh_timer++; if (p->display_type != 1) { //not KD Rev 2.1 - for(i=0;icustomchars;i++) // set customcharacters - if(custom_char_changed[i]) - serialVFD_put_char (drvthis, i); + for (i = 0; i < p->customchars; i++) // set customcharacters + if (custom_char_changed[i]) + serialVFD_put_char(drvthis, i); } - if(custom_char_changed[p->last_custom]) - p->last_custom=-10; + if (custom_char_changed[p->last_custom]) + p->last_custom = -10; 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 */ - if(p->framebuf[i] != p->backingstore[i] || (p->framebuf[i] <=30 && custom_char_changed[(int)p->framebuf[i]])) { - if (last_chr < i-1){ // if not last char written cursor has to be moved. - 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],\ + if ((p->framebuf[i] != p->backingstore[i]) || + ((p->framebuf[i] <= 30) && (custom_char_changed[(int)p->framebuf[i]]))) { + if (last_chr < i-1) { // if not last char written cursor has to be moved. + 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]); - Port_Function[p->use_parallel].write_fkt (drvthis, (char*)&i, 1); + Port_Function[p->use_parallel].write_fkt(drvthis, (char*)&i, 1); } else { 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->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, &p->custom_char[(int)p->framebuf[i]][0], 7);// overwrite selected character + 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, &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]; } 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 - Port_Function[p->use_parallel].write_fkt (drvthis, &p->charmap[p->framebuf[i] - 128], 1); + 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); } 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; @@ -496,7 +497,7 @@ serialVFD_flush (Driver *drvthis) MODULE_EXPORT void -serialVFD_num( Driver * drvthis, int x, int num ) +serialVFD_num(Driver * drvthis, int x, int num) { PrivateData *p = drvthis->private_data; int do_init = 0; @@ -544,7 +545,7 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon) serialVFD_chr(drvthis, x, y, 127); break; case ICON_HEART_FILLED: - if (p->customchars > 0){ + if (p->customchars > 0) { p->ccmode = CCMODE_STANDARD; serialVFD_set_char(drvthis, 0, heart_filled); 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); break; case ICON_HEART_OPEN: - if (p->customchars > 0){ + if (p->customchars > 0) { p->ccmode = CCMODE_STANDARD; serialVFD_set_char(drvthis, 0, heart_open); 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). // 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; int i; @@ -660,7 +661,7 @@ serialVFD_close (Driver *drvthis) { PrivateData *p = drvthis->private_data; if (p != NULL) { - Port_Function[p->use_parallel].close_fkt (drvthis); + Port_Function[p->use_parallel].close_fkt(drvthis); if (p->framebuf) free(p->framebuf); if (p->backingstore) diff --git a/server/drivers/serialVFD.h b/server/drivers/serialVFD.h index 5eccffd..5792eca 100644 --- a/server/drivers/serialVFD.h +++ b/server/drivers/serialVFD.h @@ -54,7 +54,7 @@ MODULE_EXPORT int serialVFD_cellwidth (Driver *drvthis); MODULE_EXPORT int serialVFD_cellheight (Driver *drvthis); MODULE_EXPORT void serialVFD_clear (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_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_backlight (Driver *drvthis, int on); 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 const char * serialVFD_get_info( Driver *drvthis ); diff --git a/server/drivers/serialVFD_displays.c b/server/drivers/serialVFD_displays.c index 9beb6c6..9e882fc 100644 --- a/server/drivers/serialVFD_displays.c +++ b/server/drivers/serialVFD_displays.c @@ -41,304 +41,304 @@ void serialVFD_load_Futaba (Driver *drvthis); void serialVFD_load_display_data(Driver *drvthis) { PrivateData *p = (PrivateData*) drvthis->private_data; - switch (p->display_type) - { + switch (p->display_type) { case 0: - serialVFD_load_NEC_FIPC (drvthis); + serialVFD_load_NEC_FIPC(drvthis); break; case 1: - serialVFD_load_KD (drvthis); + serialVFD_load_KD(drvthis); break; case 2: - serialVFD_load_Noritake (drvthis); + serialVFD_load_Noritake(drvthis); break; case 3: - serialVFD_load_Futaba (drvthis); + serialVFD_load_Futaba(drvthis); break; - } + } } - void serialVFD_load_NEC_FIPC (Driver *drvthis) { //nec_fipc - PrivateData *p = (PrivateData*) drvthis->private_data; - int tmp, w; + PrivateData *p = (PrivateData*) drvthis->private_data; + int tmp, w; - if (p->customchars == -83) - p->customchars=1; // number of custom characters the display provides - p->vbar_cc_offset=5; // 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_vbar=1; // the display has predefined vbar-characters + if (p->customchars == -83) + p->customchars = 1; // number of custom characters the display provides + p->vbar_cc_offset = 5; // 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_vbar = 1; // the display has predefined vbar-characters - // hardwarespecific commands: - // hw_cmd[Command][data] = {{commandlength , command 1}, - // ..... - // {commandlength , command N}} - const char hw_cmd[10][4]={{1 ,0x04}, // dark - {1 ,0x03}, - {1 ,0x02}, - {1 ,0x01}, // bright - {1 ,0x0D}, // pos1 - {1 ,0x1B}, // move cursor - {1 ,0x0C}, // reset - {2 ,0x14, 0x11}, // init - {1 ,0x1A}, // set user char - {1 ,0x09}}; // tab - for (tmp=0;tmp < (10) ;tmp++) - for (w=0;w < (4) ;w++) - p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; + // hardwarespecific commands: + // hw_cmd[Command][data] = {{commandlength , command 1}, + // ..... + // {commandlength , command N}} + const char hw_cmd[10][4] = {{1 ,0x04}, // dark + {1 ,0x03}, + {1 ,0x02}, + {1 ,0x01}, // bright + {1 ,0x0D}, // pos1 + {1 ,0x1B}, // move cursor + {1 ,0x0C}, // reset + {2 ,0x14, 0x11}, // init + {1 ,0x1A}, // set user char + {1 ,0x09}}; // tab + for (tmp = 0; tmp < 10; tmp++) + for (w = 0; w < 4; w++) + p->hw_cmd[tmp][w] = hw_cmd[tmp][w]; - // Translates ISO 8859-1 to display charset. - const unsigned char charmap[] = { - /* #128 = 0x80 */ - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - /* #160 = 0xA0 */ - 160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9, - '"', '?', '?', '?', '?', '-', '?', '?', - 0x8B, 0xF3, 0x89, 0x8A, 0x27, 0x98, '?', '.', - ',', '?', '?', '?', '?', 0x8C, '?', 0xAA, - /* #192 = 0xC0 */ - 'A', 'A', 'A', 'A', 0xA2, 0xA8, 'A', 'C', - 'E', 'E', 'E', 0xB6, 'I', 'I', 'I', 'I', - 'D', 0xA9, 'O', 'O', 'O', 'O', 0xA3, 0x8D, - '0', 'U', 'U', 'U', 0xA4, 'Y', 'p', 0x91, - /* #224 = 0xE0 */ - 'a', 'a', 'a', 'a', 0xA5, 'a', 'a', 'c', - 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', - 'o', 'n', 'o', 'o', 'o', 'o', 0xA6, 0x8E, - '0', 'u', 'u', 'u', 0xA7, 'y', 'p', 'y' - }; - for (tmp=0;tmp < 128 ;tmp++) - p->charmap[tmp]=charmap[tmp]; + // Translates ISO 8859-1 to display charset. + const unsigned char charmap[] = { + /* #128 = 0x80 */ + 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, + /* #160 = 0xA0 */ + 160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9, + '"', '?', '?', '?', '?', '-', '?', '?', + 0x8B, 0xF3, 0x89, 0x8A, 0x27, 0x98, '?', '.', + ',', '?', '?', '?', '?', 0x8C, '?', 0xAA, + /* #192 = 0xC0 */ + 'A', 'A', 'A', 'A', 0xA2, 0xA8, 'A', 'C', + 'E', 'E', 'E', 0xB6, 'I', 'I', 'I', 'I', + 'D', 0xA9, 'O', 'O', 'O', 'O', 0xA3, 0x8D, + '0', 'U', 'U', 'U', 0xA4, 'Y', 'p', 0x91, + /* #224 = 0xE0 */ + 'a', 'a', 'a', 'a', 0xA5, 'a', 'a', 'c', + 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', + 'o', 'n', 'o', 'o', 'o', 'o', 0xA6, 0x8E, + '0', 'u', 'u', 'u', 0xA7, 'y', 'p', 'y' }; + for (tmp = 0; tmp < 128; 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, ...} + 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]; - //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,0,0,0,0,0, 0x5F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0, 0x5F, 0xE1, 0xE3, 0xE4}; - for (tmp=0;tmp < 31 ;tmp++) - p->usr_chr_mapping[tmp]=usr_chr_mapping[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,0,0,0,0,0, 0x5F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0, 0x5F, 0xE1, 0xE3, 0xE4}; + for (tmp = 0; tmp < 31; tmp++) + p->usr_chr_mapping[tmp] = usr_chr_mapping[tmp]; } + void serialVFD_load_KD (Driver *drvthis) { //KD Rev2.1 - PrivateData *p = (PrivateData*) drvthis->private_data; - int tmp, w; + PrivateData *p = (PrivateData*) drvthis->private_data; + int tmp, w; - if (p->customchars == -83) - p->customchars=31; // number of custom characters the display provides - p->vbar_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_vbar=0; // the display has predefined vbar-characters + if (p->customchars == -83) + p->customchars = 31; // number of custom characters the display provides + p->vbar_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_vbar = 0; // the display has predefined vbar-characters - // hardwarespecific commands: - // hw_cmd[Command][data] = {{commandlength , command 1}, - // ..... - // {commandlength , command N}} - const char hw_cmd[10][4]={{1 ,0x04}, // dark - {1 ,0x03}, - {1 ,0x02}, - {1 ,0x01}, // bright - {1 ,0x0D}, // pos1 - {1 ,0x1B}, // move cursor - {1 ,0x0C}, // reset - {2 ,0x14, 0x11}, // init - {1 ,0x1A}, // set user char - {1 ,0x09}}; // tab - for (tmp=0;tmp < (10) ;tmp++) - for (w=0;w < (4) ;w++) - p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; + // hardwarespecific commands: + // hw_cmd[Command][data] = {{commandlength , command 1}, + // ..... + // {commandlength , command N}} + const char hw_cmd[10][4] = {{1 ,0x04}, // dark + {1 ,0x03}, + {1 ,0x02}, + {1 ,0x01}, // bright + {1 ,0x0D}, // pos1 + {1 ,0x1B}, // move cursor + {1 ,0x0C}, // reset + {2 ,0x14, 0x11}, // init + {1 ,0x1A}, // set user char + {1 ,0x09}}; // tab + for (tmp = 0; tmp < 10; tmp++) + for (w = 0; w < 4; w++) + p->hw_cmd[tmp][w] = hw_cmd[tmp][w]; - const unsigned char charmap[] = { - /* #128 = 0x80 */ - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - /* #160 = 0xA0 */ - 160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9, - '"', '?', '?', '?', '?', '-', '?', '?', - 0xA9, 0xBA, '?', '?', 0x27, '?', '?', '.', - ',', '?', '?', '?', '?', '?', '?', '?', - /* #192 = 0xC0 */ - 0xB2, 'A', 'A', 'A', 0xA2, 0xA1, 'A', 'C', - 'E', 'E', 0xA8, 0xB6, 0xAB, 0xAA, 0xAC, 0xA9, - 'D', 0xAE, 0xB1, 0xB0, 0xBF, 'O', 0xA3, 'x', - 0xAF, 0xB7, 0xB6, 0xB8, 0xA4, 'Y', 'p', 0x91, - /* #224 = 0xE0 */ - 0xD2, 0xC2, 0xC4, 'a', 0xA5, 0xC1, 0xC5, 0xC3, - 0xC7, 0xC6, 0xC8, 0xD4, 0xCC, 0xCB, 0xCD, 0xCA, - 'o', 0xCF, 0xD1, 0xD0, 0xCE, 'o', 0xA6, 0xBB, - 0xD0, 0xD7, 0xD6, 0xD8, 0xA7, 'y', 'p', 'y' - }; - for (tmp=0;tmp < 128 ;tmp++) - p->charmap[tmp]=charmap[tmp]; + const unsigned char charmap[] = { + /* #128 = 0x80 */ + 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, + /* #160 = 0xA0 */ + 160, '!', 0xF7, 0xF8, '?', '?', 0x7C, 0xF9, + '"', '?', '?', '?', '?', '-', '?', '?', + 0xA9, 0xBA, '?', '?', 0x27, '?', '?', '.', + ',', '?', '?', '?', '?', '?', '?', '?', + /* #192 = 0xC0 */ + 0xB2, 'A', 'A', 'A', 0xA2, 0xA1, 'A', 'C', + 'E', 'E', 0xA8, 0xB6, 0xAB, 0xAA, 0xAC, 0xA9, + 'D', 0xAE, 0xB1, 0xB0, 0xBF, 'O', 0xA3, 'x', + 0xAF, 0xB7, 0xB6, 0xB8, 0xA4, 'Y', 'p', 0x91, + /* #224 = 0xE0 */ + 0xD2, 0xC2, 0xC4, 'a', 0xA5, 0xC1, 0xC5, 0xC3, + 0xC7, 0xC6, 0xC8, 0xD4, 0xCC, 0xCB, 0xCD, 0xCA, + 'o', 0xCF, 0xD1, 0xD0, 0xCE, 'o', 0xA6, 0xBB, + 0xD0, 0xD7, 0xD6, 0xD8, 0xA7, 'y', 'p', 'y' }; + for (tmp = 0; tmp < 128; 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, ...} - 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]; - - //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]; + // 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 serialVFD_load_Noritake (Driver *drvthis) { //Noritake - PrivateData *p = (PrivateData*) drvthis->private_data; - int tmp, w; + PrivateData *p = (PrivateData*) drvthis->private_data; + int tmp, w; - if (p->customchars == -83) - p->customchars=16; // number of custom characters the display provides - p->vbar_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_vbar=0; // the display has predefined vbar-characters + if (p->customchars == -83) + p->customchars = 16; // number of custom characters the display provides + p->vbar_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_vbar = 0; // the display has predefined vbar-characters - // hardwarespecific commands: - // hw_cmd[Command][data] = {{commandlength , command 1}, - // ..... - // {commandlength , command N}} - const char hw_cmd[10][4]={{3 ,0x1B, 0x4C, 0x00}, // dark - {3 ,0x1B, 0x4C, 0x50}, - {3 ,0x1B, 0x4C, 0x90}, - {3 ,0x1B, 0x4C, 0xFF}, // bright - {1 ,0x0C}, // pos1 - {2 ,0x1B, 0x48}, // move cursor - {2 ,0x1B, 0x49}, // reset - {2 ,0x14, 0x11}, // init - {2 ,0x1B, 0x43}, // set user char - {1 ,0x09}}; // tab - for (tmp=0;tmp < (10) ;tmp++) - for (w=0;w < (4) ;w++) - p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; + // hardwarespecific commands: + // hw_cmd[Command][data] = {{commandlength , command 1}, + // ..... + // {commandlength , command N}} + const char hw_cmd[10][4] = {{3 ,0x1B, 0x4C, 0x00}, // dark + {3 ,0x1B, 0x4C, 0x50}, + {3 ,0x1B, 0x4C, 0x90}, + {3 ,0x1B, 0x4C, 0xFF}, // bright + {1 ,0x0C}, // pos1 + {2 ,0x1B, 0x48}, // move cursor + {2 ,0x1B, 0x49}, // reset + {2 ,0x14, 0x11}, // init + {2 ,0x1B, 0x43}, // set user char + {1 ,0x09}}; // tab + for (tmp = 0; tmp < 10; tmp++) + for (w = 0; w < 4; w++) + p->hw_cmd[tmp][w] = hw_cmd[tmp][w]; - // no charmap needed - for (tmp=128;tmp <= 255 ;tmp++) - p->charmap[tmp]=tmp; + // no charmap needed + for (tmp = 128; tmp <= 255; tmp++) + p->charmap[tmp] = tmp; - //{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, - 9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24, - 25,26,27,28,29,30,31,32, - 33,34,35, 0, 0, 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, ...} + const int usr_chr_dot_assignment[57] = { 5, + 1, 2, 3, 4, 5, 6, 7, 8, + 9,10,11,12,13,14,15,16, + 17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32, + 33,34,35, 0, 0, 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]= - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\ - 0x0F, 0x10, 0x13 , 0x14, 0x1C, 0x1D, 0x1E, 0x1F}; - for (tmp=0;tmp < 31 ;tmp++) - p->usr_chr_mapping[tmp]=usr_chr_mapping[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]= + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\ + 0x0F, 0x10, 0x13 , 0x14, 0x1C, 0x1D, 0x1E, 0x1F}; + for (tmp = 0; tmp < 31; tmp++) + p->usr_chr_mapping[tmp] = usr_chr_mapping[tmp]; } + + void serialVFD_load_Futaba (Driver *drvthis) { //Futaba - PrivateData *p = (PrivateData*) drvthis->private_data; - int tmp, w; + PrivateData *p = (PrivateData*) drvthis->private_data; + int tmp, w; - if (p->customchars == -83) - p->customchars=3; // number of custom characters the display provides - p->vbar_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_vbar=0; // the display has predefined vbar-characters + if (p->customchars == -83) + p->customchars = 3; // number of custom characters the display provides + p->vbar_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_vbar = 0; // the display has predefined vbar-characters - // hardwarespecific commands: - // hw_cmd[Command][data] = {{commandlength , command 1}, - // ..... - // {commandlength , command N}} - const char hw_cmd[10][4]={{2 ,0x04, 0x20}, // dark - {2 ,0x04, 0x40}, - {2 ,0x04, 0x60}, - {2 ,0x04, 0xFF}, // bright - {2 ,0x10, 0x00}, // pos1 - {1 ,0x10,}, // move cursor - {1 ,0x1F}, // reset - {2 ,0x11,0x14}, // init - {1 ,0x03}, // set user char - {1 ,0x09}}; // tab - for (tmp=0;tmp < (10) ;tmp++) - for (w=0;w < (4) ;w++) - p->hw_cmd[tmp][w]=hw_cmd[tmp][w]; + // hardwarespecific commands: + // hw_cmd[Command][data] = {{commandlength , command 1}, + // ..... + // {commandlength , command N}} + const char hw_cmd[10][4] = {{2 ,0x04, 0x20}, // dark + {2 ,0x04, 0x40}, + {2 ,0x04, 0x60}, + {2 ,0x04, 0xFF}, // bright + {2 ,0x10, 0x00}, // pos1 + {1 ,0x10,}, // move cursor + {1 ,0x1F}, // reset + {2 ,0x11,0x14}, // init + {1 ,0x03}, // set user char + {1 ,0x09}}; // tab + for (tmp = 0; tmp < 10; tmp++) + for (w = 0; w < 4; w++) + p->hw_cmd[tmp][w] = hw_cmd[tmp][w]; - // Translates ISO 8859-1 to display charset. - const unsigned char charmap[] = { - /* #128 = 0x80 */ - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - /* #160 = 0xA0 */ - 160, 0xAD, 0x9B, 0x9C, 0xC8, 0x9D, 0x7C, 0xC0, - '"', '?', 0xA6, 0xAE, 0xAA, '-', '?', '?', - 0xEF, 0xCA, 0xC6, 0xC7, 0x27, 0xB8, '?', '.', - ',', '?', 0xA7, 0xAF, 0xAC, 0xAB, '?', 0xA8, - /* #192 = 0xC0 */ - 0xD0, 'A', 0xD5, 'A', 0x8E, 0x8F, 0x92, 0x80, - 0xD1, 0x90, 0xD6, 0xD3, 'I', 'I', 0xD7, 0xD4, - 'D', 0xA5, 'O', 'O', 0xD8, 'O', 0x99, 'x', - '0', 0xD2, 'U', 0xD9, 0x9A, 'Y', 'p', 0xB1, - /* #224 = 0xE0 */ - 0x85, 0xA0, 0x83, 'a', 0x84, 0x86, 0x91, 0x87, - 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B, - 'o', 0xA4, 0x95, 0xA9, 0x93, 'o', 0x94, '/', - '0', 0x97, 0xA3, 0x96, 0x81, 'y', 'p', 0x89 - }; - for (tmp=0;tmp < 128 ;tmp++) - p->charmap[tmp]=charmap[tmp]; + // Translates ISO 8859-1 to display charset. + const unsigned char charmap[] = { + /* #128 = 0x80 */ + 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, + /* #160 = 0xA0 */ + 160, 0xAD, 0x9B, 0x9C, 0xC8, 0x9D, 0x7C, 0xC0, + '"', '?', 0xA6, 0xAE, 0xAA, '-', '?', '?', + 0xEF, 0xCA, 0xC6, 0xC7, 0x27, 0xB8, '?', '.', + ',', '?', 0xA7, 0xAF, 0xAC, 0xAB, '?', 0xA8, + /* #192 = 0xC0 */ + 0xD0, 'A', 0xD5, 'A', 0x8E, 0x8F, 0x92, 0x80, + 0xD1, 0x90, 0xD6, 0xD3, 'I', 'I', 0xD7, 0xD4, + 'D', 0xA5, 'O', 'O', 0xD8, 'O', 0x99, 'x', + '0', 0xD2, 'U', 0xD9, 0x9A, 'Y', 'p', 0xB1, + /* #224 = 0xE0 */ + 0x85, 0xA0, 0x83, 'a', 0x84, 0x86, 0x91, 0x87, + 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B, + 'o', 0xA4, 0x95, 0xA9, 0x93, 'o', 0x94, '/', + '0', 0x97, 0xA3, 0x96, 0x81, 'y', 'p', 0x89 }; + for (tmp = 0; tmp < 128; 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, ...} - 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]; - - //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]; - } + // 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]; +} diff --git a/server/drivers/serialVFD_io.c b/server/drivers/serialVFD_io.c index 1696d18..02feac3 100644 --- a/server/drivers/serialVFD_io.c +++ b/server/drivers/serialVFD_io.c @@ -45,7 +45,7 @@ void serialVFD_write_serial (Driver *drvthis, unsigned char *dat, size_t length) { PrivateData *p = drvthis->private_data; - write (p->fd,dat,length); + write(p->fd,dat,length); } void @@ -55,15 +55,15 @@ serialVFD_write_parallel (Driver *drvthis, unsigned char *dat, size_t length) PrivateData *p = drvthis->private_data; 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_in(p->port+1); port_out(p->port+2, WR_on); port_in(p->port+1); port_out(p->port+2, WR_off); port_in(p->port+1); - for(j_para=0; j_para < MAXBUSY; j_para++) { - if((port_in(p->port+1)) & Busy) + for (j_para = 0; j_para < MAXBUSY; j_para++) { + if ((port_in(p->port+1)) & Busy) break; } } @@ -78,14 +78,14 @@ serialVFD_init_serial (Driver *drvthis) /* Set up io port correctly, and open it...*/ 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) { - 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; } - tcgetattr (p->fd, &portset); + tcgetattr(p->fd, &portset); // We use RAW mode #ifdef HAVE_CFMAKERAW @@ -102,11 +102,11 @@ serialVFD_init_serial (Driver *drvthis) #endif // Set port speed - cfsetospeed (&portset, p->speed); - cfsetispeed (&portset, B0); + cfsetospeed(&portset, p->speed); + cfsetispeed(&portset, B0); // Do it... - tcsetattr (p->fd, TCSANOW, &portset); + tcsetattr(p->fd, TCSANOW, &portset); return 0; } @@ -115,14 +115,14 @@ serialVFD_init_parallel (Driver *drvthis) { PrivateData *p = drvthis->private_data; #ifdef HAVE_PCSTYLE_LPT_CONTROL - debug( RPT_DEBUG, "%s: Opening parallelport at: 0x%X", __FUNCTION__, p->port); - 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)); + debug(RPT_DEBUG, "%s: Opening parallelport at: 0x%X", __FUNCTION__, p->port); + 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)); return -1; } return 0; #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; #endif } @@ -141,9 +141,9 @@ serialVFD_close_parallel (Driver *drvthis) #ifdef HAVE_PCSTYLE_LPT_CONTROL PrivateData *p = drvthis->private_data; - debug( RPT_DEBUG, "%s: Closing parallelport at: 0x%X", __FUNCTION__, p->port); - 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)); + debug(RPT_DEBUG, "%s: Closing parallelport at: 0x%X", __FUNCTION__, p->port); + 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)); } #endif } diff --git a/server/drivers/stv5730.c b/server/drivers/stv5730.c index c8f6fa5..7154191 100644 --- a/server/drivers/stv5730.c +++ b/server/drivers/stv5730.c @@ -513,7 +513,7 @@ stv5730_flush (Driver *drvthis) // upper-left is (1,1), and the lower right should be (28,11). // 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; int i; diff --git a/server/drivers/stv5730.h b/server/drivers/stv5730.h index 166c105..148af35 100644 --- a/server/drivers/stv5730.h +++ b/server/drivers/stv5730.h @@ -11,7 +11,7 @@ MODULE_EXPORT int stv5730_cellwidth (Driver *drvthis); MODULE_EXPORT int stv5730_cellheight (Driver *drvthis); MODULE_EXPORT void stv5730_clear (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_old_vbar (Driver *drvthis, int x, int len); MODULE_EXPORT void stv5730_old_hbar (Driver *drvthis, int x, int y, int len); diff --git a/server/drivers/svgalib_drv.c b/server/drivers/svgalib_drv.c index bfe1551..e4e6e4a 100644 --- a/server/drivers/svgalib_drv.c +++ b/server/drivers/svgalib_drv.c @@ -441,7 +441,7 @@ svga_cellheight (Driver *drvthis) * Clear screen */ MODULE_EXPORT void -svga_clear (Driver * drvthis) +svga_clear (Driver *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). */ 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; - int i; + char *buffer = strdup(string); + char *ptr; debug(RPT_DEBUG, "%s(%p, %d, %d, \"%s\")", __FUNCTION__, drvthis, x, y, string); - for (i = 0; string[i] != '\0'; i++) { - char *c = &string[i]; + for (ptr = buffer; *ptr != '\0'; ptr++) { - if ((unsigned char) *c == 255) // TODO: Is this still necessary ? - *c = '#'; + if ((unsigned char) *ptr == 255) // TODO: Is this still necessary ? + *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); } diff --git a/server/drivers/svgalib_drv.h b/server/drivers/svgalib_drv.h index 7ba06da..cbbb662 100644 --- a/server/drivers/svgalib_drv.h +++ b/server/drivers/svgalib_drv.h @@ -34,7 +34,7 @@ MODULE_EXPORT int svga_cellwidth (Driver *drvthis); MODULE_EXPORT int svga_cellheight (Driver *drvthis); MODULE_EXPORT void svga_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int pattern); diff --git a/server/drivers/t6963.c b/server/drivers/t6963.c index 93e4f20..9fa8ca0 100644 --- a/server/drivers/t6963.c +++ b/server/drivers/t6963.c @@ -312,7 +312,7 @@ t6963_flush (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,6). // 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; diff --git a/server/drivers/t6963.h b/server/drivers/t6963.h index d6dfb81..c408359 100644 --- a/server/drivers/t6963.h +++ b/server/drivers/t6963.h @@ -118,7 +118,7 @@ MODULE_EXPORT int t6963_width (Driver *drvthis); MODULE_EXPORT int t6963_height (Driver *drvthis); MODULE_EXPORT void t6963_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/text.c b/server/drivers/text.c index 2c3647b..deaee44 100644 --- a/server/drivers/text.c +++ b/server/drivers/text.c @@ -185,7 +185,7 @@ text_flush (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; int i; diff --git a/server/drivers/text.h b/server/drivers/text.h index 9316069..b780926 100644 --- a/server/drivers/text.h +++ b/server/drivers/text.h @@ -3,13 +3,13 @@ #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 int text_width (Driver *drvthis); MODULE_EXPORT int text_height (Driver *drvthis); MODULE_EXPORT void text_clear (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_set_contrast (Driver *drvthis, int promille); MODULE_EXPORT void text_backlight (Driver *drvthis, int on); diff --git a/server/drivers/tyan_lcdm.c b/server/drivers/tyan_lcdm.c index 8559644..9106725 100644 --- a/server/drivers/tyan_lcdm.c +++ b/server/drivers/tyan_lcdm.c @@ -67,7 +67,7 @@ static unsigned char tyan_lcdm_read_key(int fd); * Opens com port and sets baud correctly... */ MODULE_EXPORT int -tyan_lcdm_init (Driver * drvthis, char *args) +tyan_lcdm_init (Driver *drvthis, char *args) { PrivateData *p; struct termios portset; @@ -183,7 +183,7 @@ tyan_lcdm_init (Driver * drvthis, char *args) * Clean-up */ MODULE_EXPORT void -tyan_lcdm_close (Driver * drvthis) +tyan_lcdm_close (Driver *drvthis) { PrivateData *p = drvthis->private_data; @@ -255,7 +255,7 @@ PrivateData *p = drvthis->private_data; * Flushes all output to the lcd... */ MODULE_EXPORT void -tyan_lcdm_flush (Driver * drvthis) +tyan_lcdm_flush (Driver *drvthis) { PrivateData *p = drvthis->private_data; 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). */ 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; @@ -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. */ 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... */ 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. * 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. */ 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. * 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. */ 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; 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 */ 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; 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 */ 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; static unsigned char heart_open[] = @@ -693,7 +693,7 @@ tyan_lcdm_icon (Driver * drvthis, int x, int y, int icon) * Clears the LCD screen */ MODULE_EXPORT void -tyan_lcdm_clear (Driver * drvthis) +tyan_lcdm_clear (Driver *drvthis) { 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). */ 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; int i; diff --git a/server/drivers/tyan_lcdm.h b/server/drivers/tyan_lcdm.h index 5f45a4d..05e90d6 100644 --- a/server/drivers/tyan_lcdm.h +++ b/server/drivers/tyan_lcdm.h @@ -84,25 +84,25 @@ MODULE_EXPORT int supports_multiple = 0; MODULE_EXPORT char *symbol_prefix = "tyan_lcdm_"; /* API: functions for the server core */ -MODULE_EXPORT int tyan_lcdm_init (Driver * drvthis, char *device); -MODULE_EXPORT void tyan_lcdm_close (Driver * drvthis); -MODULE_EXPORT int tyan_lcdm_width (Driver * drvthis); -MODULE_EXPORT int tyan_lcdm_height (Driver * drvthis); -MODULE_EXPORT int tyan_lcdm_cellwidth (Driver * drvthis); -MODULE_EXPORT int tyan_lcdm_cellheight (Driver * drvthis); -MODULE_EXPORT void tyan_lcdm_clear (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_chr (Driver * drvthis, int x, int y, char c); +MODULE_EXPORT int tyan_lcdm_init (Driver *drvthis, char *device); +MODULE_EXPORT void tyan_lcdm_close (Driver *drvthis); +MODULE_EXPORT int tyan_lcdm_width (Driver *drvthis); +MODULE_EXPORT int tyan_lcdm_height (Driver *drvthis); +MODULE_EXPORT int tyan_lcdm_cellwidth (Driver *drvthis); +MODULE_EXPORT int tyan_lcdm_cellheight (Driver *drvthis); +MODULE_EXPORT void tyan_lcdm_clear (Driver *drvthis); +MODULE_EXPORT void tyan_lcdm_flush (Driver *drvthis); +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_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_num (Driver * drvthis, int x, int num); -MODULE_EXPORT int tyan_lcdm_icon(Driver * drvthis, int x, int y, int icon); +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_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_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 diff --git a/server/drivers/ula200.c b/server/drivers/ula200.c index 716153f..6fb7afa 100644 --- a/server/drivers/ula200.c +++ b/server/drivers/ula200.c @@ -456,7 +456,7 @@ ula200_ftdi_rawdata(Driver *drvthis, unsigned char flags, unsigned char ch) // Displays a string // 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; unsigned char buffer[128]; @@ -626,7 +626,7 @@ ula200_init(Driver *drvthis) EmptyKeyRing(&p->keyring); // 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) || (p->width <= 0) || (p->width > LCD_MAX_WIDTH) || (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 // 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; int i; @@ -806,11 +806,11 @@ ula200_string (Driver *drvthis, int x, int y, char *s) x --; // Convert 1-based coords to 0-based y --; - for (i = 0; s[i]; i++) { + for (i = 0; string[i] != '\0'; i++) { // Check for buffer overflows... if ((y * p->width) + x + i > (p->width * p->height)) break; - p->framebuf[(y*p->width) + x + i] = s[i]; + p->framebuf[(y*p->width) + x + i] = string[i]; } } diff --git a/server/drivers/ula200.h b/server/drivers/ula200.h index ea9a65a..529b4a8 100644 --- a/server/drivers/ula200.h +++ b/server/drivers/ula200.h @@ -32,15 +32,15 @@ MODULE_EXPORT int ula200_init(Driver *drvthis); MODULE_EXPORT void ula200_close (Driver *drvthis); MODULE_EXPORT int ula200_width (Driver *drvthis); MODULE_EXPORT int ula200_height (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_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_backlight (Driver * drvthis, int on); -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_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 int ula200_icon(Driver * drvthis, int x, int y, int icon); +MODULE_EXPORT void ula200_clear (Driver *drvthis); +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_set_char (Driver *drvthis, int n, char *dat); +MODULE_EXPORT void ula200_backlight (Driver *drvthis, int on); +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_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 int ula200_icon(Driver *drvthis, int x, int y, int icon); #endif /* ULA200_H */ diff --git a/server/drivers/wirz-sli.c b/server/drivers/wirz-sli.c index 71f0d43..829e247 100644 --- a/server/drivers/wirz-sli.c +++ b/server/drivers/wirz-sli.c @@ -261,7 +261,7 @@ sli_clear (Driver *drvthis) // upper-left is (1,1), and the lower right should be (20,4). // 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; int i; diff --git a/server/drivers/wirz-sli.h b/server/drivers/wirz-sli.h index 1ba247a..c02538b 100644 --- a/server/drivers/wirz-sli.h +++ b/server/drivers/wirz-sli.h @@ -17,7 +17,7 @@ MODULE_EXPORT int sli_cellwidth (Driver *drvthis); MODULE_EXPORT int sli_cellheight (Driver *drvthis); MODULE_EXPORT void sli_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int options); diff --git a/server/drivers/xosdlib_drv.c b/server/drivers/xosdlib_drv.c index 6cbeed4..5929d9a 100644 --- a/server/drivers/xosdlib_drv.c +++ b/server/drivers/xosdlib_drv.c @@ -228,7 +228,7 @@ xosdlib_drv_height (Driver *drvthis) * Clear screen */ MODULE_EXPORT void -xosdlib_drv_clear (Driver * drvthis) +xosdlib_drv_clear (Driver *drvthis) { 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). */ 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; int i; diff --git a/server/drivers/xosdlib_drv.h b/server/drivers/xosdlib_drv.h index ff290f3..530cdfd 100644 --- a/server/drivers/xosdlib_drv.h +++ b/server/drivers/xosdlib_drv.h @@ -40,7 +40,7 @@ MODULE_EXPORT int xosdlib_drv_width (Driver *drvthis); MODULE_EXPORT int xosdlib_drv_height (Driver *drvthis); MODULE_EXPORT void xosdlib_drv_clear (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_vbar (Driver *drvthis, int x, int y, int len, int promille, int pattern); diff --git a/server/input.c b/server/input.c index e6cc4ee..3bcac73 100644 --- a/server/input.c +++ b/server/input.c @@ -32,31 +32,31 @@ #include "render.h" /* For server_msg* */ -LinkedList * keylist; -char * toggle_rotate_key; -char * prev_screen_key; -char * next_screen_key; -char * scroll_up_key; -char * scroll_down_key; +LinkedList *keylist; +char *toggle_rotate_key; +char *prev_screen_key; +char *next_screen_key; +char *scroll_up_key; +char *scroll_down_key; /* Local functions */ -int server_input (int key); -void input_send_to_client (Client * c, const char * key); -void input_internal_key (const char * key); +int server_input(int key); +void input_send_to_client(Client *c, 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(); /* Get rotate/scroll keys from config file */ - toggle_rotate_key = strdup (config_get_string ("server", "ToggleRotateKey", 0, "Enter")); - prev_screen_key = strdup (config_get_string ("server", "PrevScreenKey", 0, "Left")); - next_screen_key = strdup (config_get_string ("server", "NextScreenKey", 0, "Right")); - scroll_up_key = strdup (config_get_string ("server", "ScrollUpKey", 0, "Up")); - scroll_down_key = strdup (config_get_string ("server", "ScrollDownKey", 0, "Down")); + toggle_rotate_key = strdup(config_get_string("server", "ToggleRotateKey", 0, "Enter")); + prev_screen_key = strdup(config_get_string("server", "PrevScreenKey", 0, "Left")); + next_screen_key = strdup(config_get_string("server", "NextScreenKey", 0, "Right")); + scroll_up_key = strdup(config_get_string("server", "ScrollUpKey", 0, "Up")); + scroll_down_key = strdup(config_get_string("server", "ScrollDownKey", 0, "Down")); return 0; } @@ -69,75 +69,75 @@ int input_shutdown() return -1; } - free (keylist); + free(keylist); - free (toggle_rotate_key); - free (prev_screen_key); - free (next_screen_key); - free (scroll_up_key); - free (scroll_down_key); + free(toggle_rotate_key); + free(prev_screen_key); + free(next_screen_key); + free(scroll_up_key); + free(scroll_down_key); return 0; } int -handle_input () +handle_input(void) { - const char * key; - Screen * current_screen; - Client * current_client; - Client * target; - KeyReservation * kr; + const char *key; + Screen *current_screen; + Client *current_client; + Client *target; + KeyReservation *kr; - debug (RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); current_screen = screenlist_current(); - if( current_screen ) + if (current_screen) current_client = current_screen->client; else current_client = NULL; /* Handle all keypresses */ - while ((key = drivers_get_key ()) != NULL ) { + while ((key = drivers_get_key()) != NULL) { /* Find what client wants the key */ - kr = input_find_key (key, current_client); + kr = input_find_key(key, current_client); if (kr) { /* A hit ! */ - report (RPT_DEBUG, "%s: reserved key: \"%.40s\"", __FUNCTION__, key ); + report(RPT_DEBUG, "%s: reserved key: \"%.40s\"", __FUNCTION__, key); target = kr->client; } 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 = NULL; /* left-over keys are always for internal client */ } if (target == NULL) { - report (RPT_DEBUG, "%s: key is for internal client", __FUNCTION__ ); - input_internal_key (key); + report(RPT_DEBUG, "%s: key is for internal client", __FUNCTION__); + input_internal_key(key); } else { /* It's an external client */ - report (RPT_DEBUG, "%s: key is for external client on socket %d", __FUNCTION__, target->sock ); - input_send_to_client (target, key); + report(RPT_DEBUG, "%s: key is for external client on socket %d", __FUNCTION__, target->sock); + input_send_to_client(target, key); } } 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 - 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 */ - s = calloc (1, size); + s = calloc(1, size); if (s != NULL) { snprintf(s, size, "key %s\n", key); sock_send_string(c->sock, s); - free (s); + free(s); } else report(RPT_ERR, "%s: malloc failure", __FUNCTION__); @@ -145,47 +145,47 @@ void input_send_to_client (Client * c, const char * key) 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); } else { /* Keys are for scrolling or rotating */ - if( strcmp(key,toggle_rotate_key) == 0 ) { + if (strcmp(key,toggle_rotate_key) == 0) { autorotate = !autorotate; - if( autorotate ) { - server_msg( "Rotate", 4 ); + if (autorotate) { + server_msg("Rotate", 4); } else { - server_msg( "Hold", 4 ); + server_msg("Hold", 4); } } - else if( strcmp(key,prev_screen_key) == 0 ) { - screenlist_goto_prev (); - server_msg( "Prev", 4 ); + else if (strcmp(key,prev_screen_key) == 0) { + screenlist_goto_prev(); + server_msg("Prev", 4); } - else if( strcmp(key,next_screen_key) == 0 ) { - screenlist_goto_next (); - server_msg( "Next", 4 ); + else if (strcmp(key,next_screen_key) == 0) { + screenlist_goto_next(); + 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 * with the new reservation. */ - for (kr=LL_GetFirst(keylist); kr; kr=LL_GetNext(keylist)) { - if (strcmp (kr->key, key) == 0) { + for (kr = LL_GetFirst(keylist); kr; kr = LL_GetNext(keylist)) { + if (strcmp(kr->key, key) == 0) { if (kr->exclusive || exclusive) { /* Sorry ! */ return -1; @@ -194,63 +194,63 @@ int input_reserve_key (const char * key, bool exclusive, Client * client) } /* We can now safely add it ! */ - kr = malloc (sizeof(KeyReservation)); - kr->key = strdup (key); + kr = malloc(sizeof(KeyReservation)); + kr->key = strdup(key); kr->exclusive = exclusive; kr->client = client; 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; } -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 - && strcmp (kr->key, key) == 0) { - free (kr->key); - free (kr); - 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)); + && strcmp(kr->key, key) == 0) { + free(kr->key); + free(kr); + 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)); 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); while (kr) { 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)); - free (kr->key); - free (kr); - LL_DeleteNode (keylist); - kr = LL_Get (keylist); + 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); + LL_DeleteNode(keylist); + kr = LL_Get(keylist); } else { 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)) { - if (strcmp (kr->key, key) == 0) { + for (kr = LL_GetFirst(keylist); kr; kr = LL_GetNext(keylist)) { + if (strcmp(kr->key, key) == 0) { if (kr->exclusive || client==kr->client) { return kr; } diff --git a/server/input.h b/server/input.h index 1abe398..c42f85b 100644 --- a/server/input.h +++ b/server/input.h @@ -16,7 +16,7 @@ #include /* Accepts and uses keypad input while displaying screens... */ -int handle_input (); +int handle_input(void); #ifndef bool # define bool short @@ -25,29 +25,29 @@ int handle_input (); #endif typedef struct KeyReservation { - char * key; + char *key; bool exclusive; - Client * client; /* NULL for internal clients */ + Client *client; /* NULL for internal clients */ } KeyReservation; -int input_init(); +int input_init(void); /* Init the input handling system */ -int input_shutdown(); +int input_shutdown(void); /* 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 */ /* 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 */ -void input_release_client_keys (Client * client); +void input_release_client_keys(Client *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'. * If the key was reserved exclusively, the client will be ignored. * If the key was reserved shared, the client must match. diff --git a/server/main.c b/server/main.c index c6ec04f..7cd5c45 100644 --- a/server/main.c +++ b/server/main.c @@ -162,8 +162,8 @@ static int interpret_boolean_arg(char *s); static void output_help_screen(void); static void output_GPL_notice(void); -#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(e,f) { if (e>=0) { e=(f); }} +#define CHAIN_END(e,msg) { if (e<0) { report(RPT_CRIT,(msg)); exit(e); }} int @@ -196,20 +196,20 @@ main(int argc, char **argv) */ /* 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", - build_date, protocol_version, api_version ); + build_date, protocol_version, api_version); clear_settings(); /* Read command line*/ - CHAIN( e, process_command_line(argc, argv) ); + CHAIN(e, process_command_line(argc, argv)); /* Read config file * If config file was not given on command line use default */ if (strcmp(configfile, UNSET_STR) == 0) strncpy(configfile, DEFAULT_CONFIGFILE, sizeof(configfile)); - CHAIN( e, process_configfile(configfile) ); + CHAIN(e, process_configfile(configfile)); /* Set default values*/ set_default_settings(); @@ -218,7 +218,7 @@ main(int argc, char **argv) set_reporting("LCDd", report_level, report_dest); report(RPT_INFO, "Set report level to %d, output to %s", report_level, ((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)... * 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. */ if (!foreground_mode) { report(RPT_INFO, "Server forking to background"); - CHAIN( e, parent_pid = daemonize() ); + CHAIN(e, parent_pid = daemonize()); } else { output_GPL_notice(); 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 */ /* Startup the subparts of the server */ - CHAIN( e, sock_init(bind_addr, bind_port) ); - CHAIN( e, screenlist_init() ); - CHAIN( e, init_drivers() ); - CHAIN( e, clients_init() ); - CHAIN( e, input_init() ); - CHAIN( e, menuscreens_init() ); - CHAIN( e, server_screen_init() ); - CHAIN_END( e, "Critical error while initializing, abort." ); + CHAIN(e, sock_init(bind_addr, bind_port)); + CHAIN(e, screenlist_init()); + CHAIN(e, init_drivers()); + CHAIN(e, clients_init()); + CHAIN(e, input_init()); + CHAIN(e, menuscreens_init()); + CHAIN(e, server_screen_init()); + CHAIN_END(e, "Critical error while initializing, abort."); if (!foreground_mode) { /* 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 signal to a process of a different user will fail */ @@ -262,12 +262,12 @@ clear_settings(void) { int i; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); bind_port = UNSET_INT; - strncpy( bind_addr, UNSET_STR, sizeof(bind_addr) ); - strncpy( configfile, UNSET_STR, sizeof(configfile) ); - strncpy( user, UNSET_STR, sizeof(user) ); + strncpy(bind_addr, UNSET_STR, sizeof(bind_addr)); + strncpy(configfile, UNSET_STR, sizeof(configfile)); + strncpy(user, UNSET_STR, sizeof(user)); foreground_mode = UNSET_INT; rotate_server_screen = UNSET_INT; backlight = UNSET_INT; @@ -276,8 +276,8 @@ clear_settings(void) report_dest = UNSET_INT; report_level = UNSET_INT; - for( i=0; i < num_drivers; i++ ) { - free( drivernames[i] ); + for (i = 0; i < num_drivers; i++) { + free(drivernames[i]); drivernames[i] = NULL; } num_drivers = 0; @@ -291,14 +291,14 @@ process_command_line(int argc, char **argv) int c, b; 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 */ opterr = 0; /* Prevent some messages to stderr */ /* Analyze options here.. (please try to keep list of options the * 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) { case 'h': help = 1; /* Continue to process the other @@ -320,7 +320,7 @@ process_command_line(int argc, char **argv) e = -1; } } else { - report( RPT_ERR, "Too many drivers!" ); + report(RPT_ERR, "Too many drivers!"); e = -1; } break; @@ -340,15 +340,15 @@ process_command_line(int argc, char **argv) break; case 'w': default_duration = (int) (atof(optarg) * 1e6 / TIME_UNIT); - if ( default_duration * TIME_UNIT < 2e6 ) { - report( RPT_ERR, "Waittime should be at least 2 (seconds), not %.8s", optarg ); + if (default_duration * TIME_UNIT < 2e6) { + report(RPT_ERR, "Waittime should be at least 2 (seconds), not %.8s", optarg); e = -1; } break; case 's': - b = interpret_boolean_arg( optarg ); - if( b == -1 ) { - report( RPT_ERR, "Not a boolean value: '%s'", optarg ); + b = interpret_boolean_arg(optarg); + if (b == -1) { + report(RPT_ERR, "Not a boolean value: '%s'", optarg); e = -1; } else { report_dest = (b) ? RPT_DEST_SYSLOG : RPT_DEST_STDERR; @@ -358,9 +358,9 @@ process_command_line(int argc, char **argv) report_level = atoi(optarg); break; case 'i': - b = interpret_boolean_arg( optarg ); - if( b == -1 ) { - report( RPT_ERR, "Not a boolean value: '%s'", optarg ); + b = interpret_boolean_arg(optarg); + if (b == -1) { + report(RPT_ERR, "Not a boolean value: '%s'", optarg); e = -1; } else { rotate_server_screen = b; @@ -369,18 +369,18 @@ process_command_line(int argc, char **argv) case '?': /* For some reason getopt also returns an '?' * when an option argument is mission... */ - report( RPT_ERR, "Unknown option: '%c'", optopt ); + report(RPT_ERR, "Unknown option: '%c'", optopt); e = -1; break; case ':': - report( RPT_ERR, "Missing option argument!" ); + report(RPT_ERR, "Missing option argument!"); e = -1; break; } } 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; } if (help) { @@ -398,58 +398,58 @@ process_configfile(char *configfile) const char *s; /*char buf[64];*/ - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); /* Read server settings*/ - if( config_read_file( configfile ) != 0 ) { - report( RPT_CRIT, "Could not read config file: %s", configfile ); + if (config_read_file(configfile) != 0) { + report(RPT_CRIT, "Could not read config file: %s", configfile); return -1; } - if( bind_port == UNSET_INT ) - bind_port = config_get_int( "server", "port", 0, UNSET_INT ); + if (bind_port == UNSET_INT) + bind_port = config_get_int("server", "port", 0, UNSET_INT); - if( strcmp( bind_addr, UNSET_STR ) == 0 ) - strncpy( bind_addr, config_get_string( "server", "bind", 0, UNSET_STR ), sizeof(bind_addr)); + if (strcmp(bind_addr, UNSET_STR) == 0) + strncpy(bind_addr, config_get_string("server", "bind", 0, UNSET_STR), sizeof(bind_addr)); - if( strcmp( user, UNSET_STR ) == 0 ) - strncpy( user, config_get_string( "server", "user", 0, UNSET_STR ), sizeof(user)); + if (strcmp(user, UNSET_STR) == 0) + strncpy(user, config_get_string("server", "user", 0, UNSET_STR), sizeof(user)); - if( default_duration == UNSET_INT ) { - default_duration = (config_get_float( "server", "waittime", 0, 0 ) * 1e6 / TIME_UNIT ); - if( default_duration == 0 ) + if (default_duration == UNSET_INT) { + default_duration = (config_get_float("server", "waittime", 0, 0) * 1e6 / TIME_UNIT); + if (default_duration == 0) default_duration = UNSET_INT; - else if( default_duration * TIME_UNIT < 2e6 ) { - report( RPT_WARNING, "Waittime should be at least 2 (seconds). Set to 2 seconds." ); + else if (default_duration * TIME_UNIT < 2e6) { + report(RPT_WARNING, "Waittime should be at least 2 (seconds). Set to 2 seconds."); default_duration = 2e6 / TIME_UNIT; } } - if( foreground_mode == UNSET_INT ) { - int fg = config_get_bool( "server", "foreground", 0, UNSET_INT ); + if (foreground_mode == UNSET_INT) { + int fg = config_get_bool("server", "foreground", 0, UNSET_INT); - if( fg != UNSET_INT ) + if (fg != UNSET_INT) foreground_mode = fg; } - if( rotate_server_screen == UNSET_INT ) { - rotate_server_screen = config_get_bool( "server", "serverscreen", 0, UNSET_INT ); + if (rotate_server_screen == UNSET_INT) { + rotate_server_screen = config_get_bool("server", "serverscreen", 0, UNSET_INT); } - if( backlight == UNSET_INT ) { - s = config_get_string( "server", "backlight", 0, UNSET_STR ); - if( strcmp( s, "on" ) == 0 ) { + if (backlight == UNSET_INT) { + s = config_get_string("server", "backlight", 0, UNSET_STR); + if (strcmp(s, "on") == 0) { backlight = BACKLIGHT_ON; } - else if( strcmp( s, "off" ) == 0 ) { + else if (strcmp(s, "off") == 0) { backlight = BACKLIGHT_OFF; } - else if( strcmp( s, "open" ) == 0 ) { + else if (strcmp(s, "open") == 0) { backlight = BACKLIGHT_OPEN; } - else if( strcmp( s, UNSET_STR ) != 0 ) { - report( RPT_WARNING, "Backlight state should be on, off or open" ); + else if (strcmp(s, UNSET_STR) != 0) { + report(RPT_WARNING, "Backlight state should be on, off or open"); } } @@ -459,8 +459,8 @@ process_configfile(char *configfile) if (rs != UNSET_INT) report_dest = (rs) ? RPT_DEST_SYSLOG : RPT_DEST_STDERR; } - if( report_level == UNSET_INT ) { - report_level = config_get_int( "server", "reportLevel", 0, UNSET_INT ); + if (report_level == 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 * use the driver list from the config file. */ - if( num_drivers == 0 ) { + if (num_drivers == 0) { /* read the drivernames*/ - while( 1 ) { - s = config_get_string( "server", "driver", num_drivers, NULL ); - if( !s ) + while(1) { + s = config_get_string("server", "driver", num_drivers, NULL); + if (!s) break; - if( s[0] != 0 ) { + if (s[0] != 0) { drivernames[num_drivers] = malloc(strlen(s)+1); - strcpy( drivernames[num_drivers], s ); + strcpy(drivernames[num_drivers], s); num_drivers++; } } @@ -491,15 +491,15 @@ process_configfile(char *configfile) static void set_default_settings(void) { - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); /* Set defaults into unfilled variables....*/ if (bind_port == UNSET_INT) bind_port = DEFAULT_BIND_PORT; - if (strcmp( bind_addr, UNSET_STR ) == 0) - strncpy (bind_addr, DEFAULT_BIND_ADDR, sizeof(bind_addr)); - if (strcmp( user, UNSET_STR ) == 0) + if (strcmp(bind_addr, UNSET_STR) == 0) + strncpy(bind_addr, DEFAULT_BIND_ADDR, sizeof(bind_addr)); + if (strcmp(user, UNSET_STR) == 0) strncpy(user, DEFAULT_USER, sizeof(user)); if (foreground_mode == UNSET_INT) @@ -512,14 +512,14 @@ set_default_settings(void) if (backlight == UNSET_INT) backlight = BACKLIGHT_OPEN; - if (report_dest == UNSET_INT ) + if (report_dest == UNSET_INT) report_dest = DEFAULT_REPORTDEST; - if( report_level == UNSET_INT ) + if (report_level == UNSET_INT) report_level = DEFAULT_REPORTLEVEL; /* Use default driver*/ - if( num_drivers == 0 ) { + if (num_drivers == 0) { drivernames[0] = malloc(strlen(DEFAULT_DRIVER)+1); strcpy(drivernames[0], DEFAULT_DRIVER); num_drivers = 1; @@ -537,20 +537,20 @@ install_signal_handlers(int allow_reload) 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 * default action is to kill the server. Just ignore it. */ sa.sa_handler = SIG_IGN; - sigaction (SIGPIPE, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); sa.sa_handler = exit_program; sa.sa_flags = SA_RESTART; - sigaction (SIGINT, &sa, NULL); /* Ctrl-C will cause a clean exit...*/ - sigaction (SIGTERM, &sa, NULL); /* and "kill"...*/ + sigaction(SIGINT, &sa, NULL); /* Ctrl-C will cause a clean exit...*/ + sigaction(SIGTERM, &sa, NULL); /* and "kill"...*/ if (allow_reload) { sa.sa_handler = catch_reload_signal; @@ -559,13 +559,13 @@ install_signal_handlers(int allow_reload) else { /* Treat this signal just like INT and TERM */ } - sigaction (SIGHUP, &sa, NULL); + sigaction(SIGHUP, &sa, NULL); #else /* Win32 does not support POSIX signals i.e. sigaction(). However, it does * support ANSI signals in mingw. */ - signal (SIGINT, exit_program); /* Ctrl-C will cause a clean exit...*/ - signal (SIGTERM, exit_program); /* and "kill"...*/ - signal (SIGPIPE, SIG_IGN); + signal(SIGINT, exit_program); /* Ctrl-C will cause a clean exit...*/ + signal(SIGTERM, exit_program); /* and "kill"...*/ + signal(SIGPIPE, SIG_IGN); /* REVISIT: implement SIGHUP on windows */ #endif @@ -577,10 +577,10 @@ child_ok_func(int signal) { /* 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( 0 ); /* Parent exits normally. */ + _exit(0); /* Parent exits normally. */ } @@ -599,49 +599,49 @@ daemonize(void) int child_status; struct sigaction sa; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); parent = getpid(); - debug( RPT_INFO, "parent = %d", parent ); + debug(RPT_INFO, "parent = %d", parent); /* Install handler at parent for child's signal */ /* sigaction should be more portable than signal, but it does not * work for some reason. */ sa.sa_handler = child_ok_func; - sigemptyset ( &(sa.sa_mask) ); + sigemptyset(&(sa.sa_mask)); sa.sa_flags = SA_RESTART; - sigaction (SIGUSR1, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); /* Do the fork */ - switch ((child = fork ()) ) { + switch ((child = fork())) { case -1: - report( RPT_ERR, "Could not fork" ); + report(RPT_ERR, "Could not fork"); return -1; case 0: /* We are the child */ break; default: /* We are the parent */ - debug( RPT_INFO, "child = %d", child ); - wait( &child_status ); + debug(RPT_INFO, "child = %d", child); + wait(&child_status); /* BUG? According to the man page wait() should also return * when a signal comes in that is caught. Instead it * continues to wait. */ - if( WIFEXITED(child_status) ) { + if (WIFEXITED(child_status)) { /* Child exited normally, probably because of some * error. */ - debug( RPT_INFO, "Child has terminated!" ); - exit( WEXITSTATUS(child_status) ); + debug(RPT_INFO, "Child has terminated!"); + exit(WEXITSTATUS(child_status)); /* Parent exits with same status as child did... */ } /* Child is still running and has signalled it's OK. * This means the parent can now rest in peace. */ - debug( RPT_INFO, "Got OK signal from child." ); - exit( 0 ); /* Parent exits normally. */ + debug(RPT_INFO, "Got OK signal from child."); + exit(0); /* Parent exits normally. */ } /* At this point we are always the child. */ /* Reset signal handler */ sa.sa_handler = SIG_DFL; - sigaction (SIGUSR1, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); setsid(); /* Create a new session because otherwise we'll * catch a SIGHUP when the shell is closed. */ @@ -655,9 +655,9 @@ static int wave_to_parent(pid_t parent_pid) { #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 return 0; @@ -671,15 +671,15 @@ init_drivers(void) int output_loaded = 0; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); for (i = 0; i < num_drivers; i++) { - res = drivers_load_driver (drivernames[i]); + res = drivers_load_driver(drivernames[i]); if (res >= 0) { /* Load went OK */ - switch( res ) { + switch(res) { case 0: /* Driver does input only */ break; case 1: /* Driver does output */ @@ -691,15 +691,15 @@ init_drivers(void) break; } } 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 ?*/ - if ( output_loaded ) { + if (output_loaded) { return 0; } else { - report( RPT_ERR, "There is no output driver" ); + report(RPT_ERR, "There is no output driver"); return -1; } } @@ -711,15 +711,15 @@ drop_privs(char *user) #ifndef WIN32 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 ((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; } else { 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; } } @@ -735,15 +735,15 @@ drop_privs(char *user) static int 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"); return -1; } /* Add the server screen */ - if (server_screen_init () < 0) { + if (server_screen_init() < 0) { report(RPT_ERR, "Error initializing server screens"); return -1; } @@ -761,37 +761,37 @@ do_reload(void) { int e = 0; - drivers_unload_all (); /* Close all drivers */ + drivers_unload_all(); /* Close all drivers */ config_clear(); clear_settings(); /* Reread command line*/ - CHAIN( e, process_command_line (stored_argc, stored_argv) ); + CHAIN(e, process_command_line(stored_argc, stored_argv)); /* Reread config file */ if (strcmp(configfile, UNSET_STR)==0) strncpy(configfile, DEFAULT_CONFIGFILE, sizeof(configfile)); - CHAIN( e, process_configfile (configfile) ); + CHAIN(e, process_configfile(configfile)); /* Set default values */ - CHAIN( e, ( set_default_settings(), 0 )); + CHAIN(e, (set_default_settings(), 0)); /* Set reporting values */ - CHAIN( e, set_reporting("LCDd", report_level, report_dest) ); - CHAIN( e, ( report(RPT_INFO, "Set report level to %d, output to %s", report_level, - ((report_dest == RPT_DEST_SYSLOG) ? "syslog" : "stderr")), 0 ) ); + CHAIN(e, set_reporting("LCDd", report_level, report_dest)); + CHAIN(e, (report(RPT_INFO, "Set report level to %d, output to %s", report_level, + ((report_dest == RPT_DEST_SYSLOG) ? "syslog" : "stderr")), 0)); /* And restart the drivers */ - CHAIN( e, init_drivers() ); - CHAIN_END( e, "Critical error while reloading, abort." ); + CHAIN(e, init_drivers()); + CHAIN_END(e, "Critical error while reloading, abort."); } static void do_mainloop(void) { - Screen * s; + Screen *s; #ifndef WIN32 struct timeval t; struct timeval last_t; @@ -805,10 +805,10 @@ do_mainloop(void) long int render_lag = 0; long int t_diff; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); #ifndef WIN32 - gettimeofday (&t, NULL); /* Get initial time */ + gettimeofday(&t, NULL); /* Get initial time */ #else QueryPerformanceFrequency(&perf_freq); /* scale perf_freq to number of cycles per micro-sec */ @@ -821,7 +821,7 @@ do_mainloop(void) /* Get current time */ last_t = t; #ifndef WIN32 - gettimeofday (&t, NULL); + gettimeofday(&t, NULL); t_diff = t.tv_sec - last_t.tv_sec; if ((t_diff + 1) > (LONG_MAX / 1e6)) { /* 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; if (process_lag > 0) { /* Time for a processing stroke */ - sock_poll_clients (); /* poll clients for input*/ - parse_all_client_messages (); /* analyze input from network clients*/ - handle_input (); /* handle key input from devices*/ + sock_poll_clients(); /* poll clients for input*/ + parse_all_client_messages(); /* analyze input from network clients*/ + handle_input(); /* handle key input from devices*/ /* We've done the job... */ process_lag = 0 - (1e6/PROCESS_FREQ); @@ -857,19 +857,19 @@ do_mainloop(void) if (render_lag > 0) { /* Time for a rendering stroke */ timer ++; - screenlist_process (); - s = screenlist_current (); + screenlist_process(); + s = screenlist_current(); /* TODO: Move this call to every client connection * and every screen add... */ - if( s == server_screen ) { - update_server_screen (timer); + if (s == server_screen) { + update_server_screen(); } - render_screen (s, timer); + render_screen(s, timer); /* 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 */ render_lag = (1e6/RENDER_FREQ) * MAX_RENDER_LAG_FRAMES; } @@ -878,10 +878,10 @@ do_mainloop(void) } /* Sleep just as long as needed */ - sleeptime = min (0-process_lag, 0-render_lag); - if( sleeptime > 0 ) { + sleeptime = min(0-process_lag, 0-render_lag); + if (sleeptime > 0) { #ifndef WIN32 - usleep (sleeptime); + usleep(sleeptime); #else /* Sleep in Windows takes milliseconds argument */ Sleep(sleeptime / 1000); @@ -889,14 +889,14 @@ do_mainloop(void) } /* Check if a SIGHUP has been caught */ - if( got_reload_signal ) { + if (got_reload_signal) { got_reload_signal = 0; - do_reload (); + do_reload(); } } /* Quit! */ - exit_program (0); + exit_program(0); } @@ -905,14 +905,14 @@ exit_program(int val) { 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 * things are shut down in shouldn't matter... */ - if( val > 0 ) { - strncpy(buf, "Server shutting down on ", sizeof (buf) ); + if (val > 0) { + strncpy(buf, "Server shutting down on ", sizeof(buf)); switch(val) { case 1: strcat(buf, "SIGHUP"); 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. */ - if (report_level == UNSET_INT ) + if (report_level == UNSET_INT) report_level = DEFAULT_REPORTLEVEL; - if (report_dest == UNSET_INT ) + if (report_dest == UNSET_INT) report_dest = DEFAULT_REPORTDEST; set_reporting("LCDd", report_level, report_dest); - goodbye_screen (); /* display goodbye screen on LCD display */ - drivers_unload_all (); /* release driver memory and file descriptors */ + goodbye_screen(); /* display goodbye screen on LCD display */ + drivers_unload_all(); /* release driver memory and file descriptors */ /* Shutdown things if server start was complete */ - clients_shutdown (); /* shutdown clients (must come first) */ - menuscreens_shutdown (); - screenlist_shutdown (); /* shutdown screens (must come after client_shutdown) */ - input_shutdown (); /* shutdown key input part */ + clients_shutdown(); /* shutdown clients (must come first) */ + menuscreens_shutdown(); + screenlist_shutdown(); /* shutdown screens (must come after client_shutdown) */ + input_shutdown(); /* shutdown key input part */ sock_shutdown(); /* shutdown the sockets server */ - report( RPT_INFO, "Exiting." ); - _exit (0); + report(RPT_INFO, "Exiting."); + _exit(0); } static void 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; } @@ -981,7 +981,7 @@ output_GPL_notice(void) */ fprintf(stderr, "LCDd %s, LCDproc Protocol %s\n", VERSION, PROTOCOL_VERSION); 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"); 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 * 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, "Copyright (c) 1999-2006 Scott Scriven, William Ferrell, and misc. contributors.\n"); diff --git a/server/menu.c b/server/menu.c index 10b2812..0f99f18 100644 --- a/server/menu.c +++ b/server/menu.c @@ -40,23 +40,23 @@ #include "widget.h" -extern Menu * custom_main_menu; +extern Menu *custom_main_menu; /** Basicly a patched version of LL_GetByIndex() that ignores hidden * entries completely. (But it takes a menu as an argument.) */ static void * -menu_get_subitem(Menu * menu, int index) +menu_get_subitem(Menu *menu, int index) { - MenuItem * item; + MenuItem *item; 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); for (item = LL_GetFirst(menu->data.menu.contents); item != NULL; item = LL_GetNext(menu->data.menu.contents)) { - if ( ! item->is_hidden) + if (! item->is_hidden) { if (i == index) return item; @@ -73,18 +73,18 @@ menu_get_subitem(Menu * menu, int index) * * @return index of subitem if found and -1 otherwise. */ 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; - 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); for (item = LL_GetFirst(menu->data.menu.contents); item != NULL; item = LL_GetNext(menu->data.menu.contents)) { - if ( ! item->is_hidden) + if (! item->is_hidden) { if (strcmp(item_id, item->id) == 0) return i; @@ -96,16 +96,16 @@ menu_get_index_of(Menu * menu, char * item_id) } static int -menu_visible_item_count(Menu * menu) +menu_visible_item_count(Menu *menu) { - MenuItem * item; + MenuItem *item; int i = 0; for (item = LL_GetFirst(menu->data.menu.contents); item != NULL; item = LL_GetNext(menu->data.menu.contents)) { - if ( ! item->is_hidden) + if (! item->is_hidden) ++i; } return i; @@ -113,15 +113,15 @@ menu_visible_item_count(Menu * menu) Menu * -menu_create (char *id, MenuEventFunc(*event_func), +menu_create(char *id, MenuEventFunc(*event_func), char *text, Client *client) { 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); - 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) { new_menu->data.menu.contents = LL_new(); @@ -132,9 +132,9 @@ menu_create (char *id, MenuEventFunc(*event_func), } 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)")); if (menu == NULL) @@ -143,17 +143,17 @@ menu_destroy (Menu *menu) if (custom_main_menu == menu) custom_main_menu = NULL; - menu_destroy_all_items (menu); - LL_Destroy (menu->data.menu.contents); + menu_destroy_all_items(menu); + LL_Destroy(menu->data.menu.contents); menu->data.menu.contents = NULL; /* After this the general menuitem routine destroys the rest... */ } 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)"), ((item != NULL) ? item->id : "(null)")); @@ -161,17 +161,17 @@ menu_add_item (Menu *menu, MenuItem *item) return; /* Add the item to the menu */ - LL_Push (menu->data.menu.contents, item); + LL_Push(menu->data.menu.contents, item); item->parent = menu; } void -menu_remove_item (Menu *menu, MenuItem *item) +menu_remove_item(Menu *menu, MenuItem *item) { 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)"), ((item != NULL) ? item->id : "(null)")); @@ -181,9 +181,9 @@ menu_remove_item (Menu *menu, MenuItem *item) /* Find the item */ for (item2 = LL_GetFirst(menu->data.menu.contents), i = 0; item2 != NULL; - item2 = LL_GetNext(menu->data.menu.contents), i++ ) { + item2 = LL_GetNext(menu->data.menu.contents), i++) { if (item == item2) { - LL_DeleteNode (menu->data.menu.contents); + LL_DeleteNode(menu->data.menu.contents); if (menu->data.menu.selector_pos >= i) { menu->data.menu.selector_pos--; if (menu->data.menu.scroll > 0) @@ -195,34 +195,34 @@ menu_remove_item (Menu *menu, MenuItem *item) } 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)")); if (menu == NULL) return; - for( item = menu_getfirst_item(menu); item != NULL; item = menu_getfirst_item(menu) ) { - menuitem_destroy (item); - LL_Remove (menu->data.menu.contents, item); + for (item = menu_getfirst_item(menu); item != NULL; item = menu_getfirst_item(menu)) { + menuitem_destroy(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) ? menu_get_subitem(menu, menu->data.menu.selector_pos) : 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); 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) return menu; - for( item = menu_getfirst_item(menu); item != NULL; item = menu_getnext_item(menu) ) { - if ( strcmp(item->id, id) == 0 ) { + for (item = menu_getfirst_item(menu); item != NULL; item = menu_getnext_item(menu)) { + if (strcmp(item->id, id) == 0) { return item; } else if (recursive && item->type == MENUITEM_MENU) { - MenuItem * res; - res = menu_find_item (item, id, recursive); + MenuItem *res; + res = menu_find_item(item, id, recursive); if (res) { return res; } @@ -250,9 +250,9 @@ void menu_set_association(Menu *menu, void *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)")); if (menu == NULL) @@ -262,13 +262,13 @@ void menu_reset (Menu *menu) menu->data.menu.scroll = 0; } -void menu_build_screen (MenuItem *menu, Screen *s) +void menu_build_screen(MenuItem *menu, Screen *s) { - Widget * w; - MenuItem * subitem; + Widget *w; + MenuItem *subitem; 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)"), ((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 */ /* Create menu title widget */ - w = widget_create ("title", WID_TITLE, s); + w = widget_create("title", WID_TITLE, s); if (w != NULL) { - screen_add_widget (s, w); + screen_add_widget(s, w); w->text = strdup(menu->text); w->x = 1; } /* 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 = LL_GetNext (menu->data.menu.contents), itemnr ++ ) + subitem = LL_GetNext(menu->data.menu.contents), itemnr ++) { char buf[10]; if (subitem->is_hidden) continue; - snprintf (buf, sizeof(buf)-1, "text%d", itemnr); + snprintf(buf, sizeof(buf)-1, "text%d", itemnr); buf[sizeof(buf)-1] = 0; - w = widget_create (buf, WID_STRING, s); + w = widget_create(buf, WID_STRING, s); /* (buf will be copied) */ if (w != NULL) { - screen_add_widget (s, w); + screen_add_widget(s, w); w->x = 2; switch (subitem->type) { case MENUITEM_CHECKBOX: /* Limit string length */ - w->text = strdup (subitem->text); + w->text = strdup(subitem->text); if (strlen(subitem->text) >= display_props->width-2) { (w->text)[display_props->width-2] = 0; } /* 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; - w = widget_create (buf, WID_ICON, s); + w = widget_create(buf, WID_ICON, s); /* (buf will be copied) */ - screen_add_widget (s, w); + screen_add_widget(s, w); w->x = display_props->width - 1; w->length = ICON_CHECKBOX_OFF; break; case MENUITEM_RING: /* Create string for text + ringtext */ - w->text = malloc (display_props->width); + w->text = malloc(display_props->width); break; case MENUITEM_MENU: /* Limit string length */ - w->text = malloc( strlen(subitem->text) + 4 ); - strcpy( w->text, subitem->text ); - strcat( w->text, " >" ); + w->text = malloc(strlen(subitem->text) + 4); + strcpy(w->text, subitem->text); + strcat(w->text, " >"); if (strlen(subitem->text) >= display_props->width-1) { (w->text)[display_props->width-1] = '\0'; } @@ -340,7 +340,7 @@ void menu_build_screen (MenuItem *menu, Screen *s) case MENUITEM_ALPHA: case MENUITEM_IP: /* Limit string length */ - w->text = strdup (subitem->text); + w->text = strdup(subitem->text); if (strlen(subitem->text) >= display_props->width-1) { (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 */ - w = widget_create ("selector", WID_ICON, s); + w = widget_create("selector", WID_ICON, s); if (w != NULL) { - screen_add_widget (s, w); + screen_add_widget(s, w); w->length = ICON_SELECTOR_AT_LEFT; w->x = 1; } /* Add scrollers on the right side on top and bottom */ /* 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) { - screen_add_widget (s, w); + screen_add_widget(s, w); w->length = ICON_ARROW_UP; w->x = display_props->width; w->y = 1; } - w = widget_create ("downscroller", WID_ICON, s); + w = widget_create("downscroller", WID_ICON, s); if (w != NULL) { - screen_add_widget (s, w); + screen_add_widget(s, w); w->length = ICON_ARROW_DOWN; w->x = display_props->width; 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; - MenuItem * subitem; + Widget *w; + MenuItem *subitem; int itemnr; 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)"), ((s != NULL) ? s->id : "(null)")); @@ -394,8 +394,8 @@ void menu_update_screen (MenuItem *menu, Screen *s) return; /* Update widgets for the title */ - w = screen_find_widget (s, "title"); - if (!w) report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "title"); + w = screen_find_widget(s, "title"); + if (!w) report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, "title"); w->y = 1 - menu->data.menu.scroll; /* 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 */ - for (subitem = LL_GetFirst (menu->data.menu.contents), itemnr = 0; + for (subitem = LL_GetFirst(menu->data.menu.contents), itemnr = 0; subitem; - subitem = LL_GetNext (menu->data.menu.contents), itemnr ++ ) + subitem = LL_GetNext(menu->data.menu.contents), itemnr ++) { char buf[10]; - char * p; + char *p; if (subitem->is_hidden) { @@ -420,10 +420,10 @@ void menu_update_screen (MenuItem *menu, Screen *s) ++hidden_count; continue; } - snprintf (buf, sizeof(buf)-1, "text%d", itemnr); + snprintf(buf, sizeof(buf)-1, "text%d", itemnr); buf[sizeof(buf)-1] = 0; - w = screen_find_widget (s, buf); - if (!w) report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf); + w = screen_find_widget(s, buf); + if (!w) report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf); w->y = 2 + itemnr - hidden_count - menu->data.menu.scroll; /* TODO: remove next 5 lines when rendering is safe */ @@ -437,10 +437,10 @@ void menu_update_screen (MenuItem *menu, Screen *s) case MENUITEM_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; - w = screen_find_widget (s, buf); - if (!w) report (RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf); + w = screen_find_widget(s, buf); + if (!w) report(RPT_ERR, "%s: could not find widget: %s", __FUNCTION__, buf); w->y = 2 + itemnr - menu->data.menu.scroll; 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: if (subitem->data.ring.value >= LL_Length(subitem->data.ring.strings)) { /* 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; } else { /* 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); if (strlen(p) > display_props->width - 3) { short a = display_props->width - 3; /* We need to limit the ring string and DON'T * display the item text */ - strcpy (w->text, " "); - memcpy (w->text + 1, p, a); + strcpy(w->text, " "); + memcpy(w->text + 1, p, a); w->text[a + 1] = 0; } else { - short b = display_props->width - 2 - strlen (p); - short c = min (strlen (subitem->text), b - 1); + short b = display_props->width - 2 - strlen(p); + short c = min(strlen(subitem->text), b - 1); /* We don't limit the ring string */ - memset (w->text, ' ', b); - memcpy (w->text, subitem->text, c); - strcpy (w->text + b, p); + memset(w->text, ' ', b); + memcpy(w->text, subitem->text, c); + strcpy(w->text + b, p); } } break; @@ -485,32 +485,32 @@ void menu_update_screen (MenuItem *menu, Screen *s) } /* Update selector position */ - w = screen_find_widget (s, "selector"); + w = screen_find_widget(s, "selector"); if (w != NULL) w->y = 2 + menu->data.menu.selector_pos - menu->data.menu.scroll; 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) */ - w = screen_find_widget (s, "upscroller"); + w = screen_find_widget(s, "upscroller"); if (w != NULL) w->type = (menu->data.menu.scroll > 0) ? WID_ICON : WID_NONE; 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) */ - w = screen_find_widget (s, "downscroller"); + w = screen_find_widget(s, "downscroller"); if (w != NULL) w->type = (menu_visible_item_count(menu) >= menu->data.menu.scroll + display_props->height) ? WID_ICON : WID_NONE; 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); - if ( ! subitem) + if (! subitem) return NULL; switch (subitem->type) { 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); - if ( ! subitem) + if (! subitem) return NULL; switch (subitem->type) { 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; - 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); if (menu == NULL) @@ -567,18 +567,18 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo switch (token) { case MENUTOKEN_MENU: subitem = menu_get_item_for_predecessor_check(menu); - if ( ! subitem) + if (! subitem) return MENURESULT_ERROR; return menuitem_predecessor2menuresult( subitem->predecessor_id, MENURESULT_CLOSE); 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) break; switch (subitem->type) { case MENUITEM_ACTION: if (subitem->event_func) - subitem->event_func (subitem, MENUEVENT_SELECT); + subitem->event_func(subitem, MENUEVENT_SELECT); return menuitem_successor2menuresult( subitem->successor_id, MENURESULT_NONE); 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; } if (subitem->event_func) - subitem->event_func (subitem, MENUEVENT_UPDATE); + subitem->event_func(subitem, MENUEVENT_UPDATE); return menuitem_successor2menuresult( subitem->successor_id, MENURESULT_NONE); 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) - subitem->event_func (subitem, MENUEVENT_UPDATE); + subitem->event_func(subitem, MENUEVENT_UPDATE); return menuitem_successor2menuresult( subitem->successor_id, MENURESULT_NONE); case MENUITEM_MENU: @@ -636,7 +636,7 @@ MenuResult menu_process_input(Menu *menu, MenuToken token, const char * key, boo if (!extended) 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) break; 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; } if (subitem->event_func) - subitem->event_func (subitem, MENUEVENT_UPDATE); + subitem->event_func(subitem, MENUEVENT_UPDATE); return MENURESULT_NONE; case MENUITEM_RING: /* ring: jump to the end if beginning is reached */ subitem->data.ring.value = (subitem->data.ring.value < 1) - ? LL_Length (subitem->data.ring.strings) - 1 - : (subitem->data.ring.value - 1) % LL_Length (subitem->data.ring.strings); + ? LL_Length(subitem->data.ring.strings) - 1 + : (subitem->data.ring.value - 1) % LL_Length(subitem->data.ring.strings); if (subitem->event_func) - subitem->event_func (subitem, MENUEVENT_UPDATE); + subitem->event_func(subitem, MENUEVENT_UPDATE); return MENURESULT_NONE; default: 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; } if (subitem->event_func) - subitem->event_func (subitem, MENUEVENT_UPDATE); + subitem->event_func(subitem, MENUEVENT_UPDATE); return MENURESULT_NONE; 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) - subitem->event_func (subitem, MENUEVENT_UPDATE); + subitem->event_func(subitem, MENUEVENT_UPDATE); return MENURESULT_NONE; case MENUITEM_MENU: 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 * 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); - debug(RPT_DEBUG, "%s( menu=[%s], subitem_id=\"%s\" )", __FUNCTION__, + debug(RPT_DEBUG, "%s(menu=[%s], subitem_id=\"%s\")", __FUNCTION__, menu->id, subitem_id); int position = menu_get_index_of(menu, subitem_id); if (position < 0) diff --git a/server/menu.h b/server/menu.h index fb41866..62463d5 100644 --- a/server/menu.h +++ b/server/menu.h @@ -38,28 +38,28 @@ typedef MenuItem Menu; #include "screen.h" /** Creates a new menu. */ -Menu *menu_create (char *id, MenuEventFunc(*event_func), +Menu *menu_create(char *id, MenuEventFunc(*event_func), char *text, Client *client); /** Deletes menu from memory. * Destructors will be called for all subitems. * 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 */ /** 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 */ -void menu_destroy_all_items (Menu *menu); +void menu_destroy_all_items(Menu *menu); /** Enumeration function. * 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) ? 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 * 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) ? 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 * 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. */ -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. */ 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. * 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. * 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 * 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 @@ -109,7 +109,7 @@ void menu_update_screen (Menu *menu, Screen *s); * predecessor and menu otherwise. * * @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 @@ -117,14 +117,14 @@ MenuItem * menu_get_item_for_predecessor_check(Menu *menu); * otherwise. * * @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. * key is only used if token is MENUTOKEN_OTHER. * 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. */ -void menu_select_subitem(Menu *menu, char * subitem_id); +void menu_select_subitem(Menu *menu, char *subitem_id); #endif diff --git a/server/menuitem.c b/server/menuitem.c index f95aac5..e2001d8 100644 --- a/server/menuitem.c +++ b/server/menuitem.c @@ -35,32 +35,32 @@ char *error_strs[] = {"", "Out of range", "Too long", "Too short", "Invalid Addr char *menuitemtypenames[] = {"menu", "action", "checkbox", "ring", "slider", "numeric", "alpha", "ip"}; char *menueventtypenames[] = {"select", "update", "plus", "minus", "enter", "leave"}; -void menuitem_destroy_action (MenuItem *item); -void menuitem_destroy_checkbox (MenuItem *item); -void menuitem_destroy_ring (MenuItem *item); -void menuitem_destroy_slider (MenuItem *item); -void menuitem_destroy_numeric (MenuItem *item); -void menuitem_destroy_alpha (MenuItem *item); -void menuitem_destroy_ip (MenuItem *item); +void menuitem_destroy_action(MenuItem *item); +void menuitem_destroy_checkbox(MenuItem *item); +void menuitem_destroy_ring(MenuItem *item); +void menuitem_destroy_slider(MenuItem *item); +void menuitem_destroy_numeric(MenuItem *item); +void menuitem_destroy_alpha(MenuItem *item); +void menuitem_destroy_ip(MenuItem *item); -void menuitem_reset_numeric (MenuItem *item); -void menuitem_reset_alpha (MenuItem *item); -void menuitem_reset_ip (MenuItem *item); +void menuitem_reset_numeric(MenuItem *item); +void menuitem_reset_alpha(MenuItem *item); +void menuitem_reset_ip(MenuItem *item); -void menuitem_rebuild_screen_slider (MenuItem *item, Screen *s); -void menuitem_rebuild_screen_numeric (MenuItem *item, Screen *s); -void menuitem_rebuild_screen_alpha (MenuItem *item, Screen *s); -void menuitem_rebuild_screen_ip (MenuItem *item, Screen *s); +void menuitem_rebuild_screen_slider(MenuItem *item, Screen *s); +void menuitem_rebuild_screen_numeric(MenuItem *item, Screen *s); +void menuitem_rebuild_screen_alpha(MenuItem *item, Screen *s); +void menuitem_rebuild_screen_ip(MenuItem *item, Screen *s); -void menuitem_update_screen_slider (MenuItem *item, Screen *s); -void menuitem_update_screen_numeric (MenuItem *item, Screen *s); -void menuitem_update_screen_alpha (MenuItem *item, Screen *s); -void menuitem_update_screen_ip (MenuItem *item, Screen *s); +void menuitem_update_screen_slider(MenuItem *item, Screen *s); +void menuitem_update_screen_numeric(MenuItem *item, Screen *s); +void menuitem_update_screen_alpha(MenuItem *item, Screen *s); +void menuitem_update_screen_ip(MenuItem *item, Screen *s); -MenuResult menuitem_process_input_slider (MenuItem *item, MenuToken token, const char * key, bool extended); -MenuResult menuitem_process_input_numeric (MenuItem *item, MenuToken token, const char * key, bool extended); -MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const char * key, bool extended); -MenuResult menuitem_process_input_ip (MenuItem *item, MenuToken token, const char * key, bool extended); +MenuResult menuitem_process_input_slider(MenuItem *item, MenuToken token, const char *key, bool extended); +MenuResult menuitem_process_input_numeric(MenuItem *item, MenuToken token, const char *key, bool extended); +MenuResult menuitem_process_input_alpha(MenuItem *item, MenuToken token, const char *key, bool extended); +MenuResult menuitem_process_input_ip(MenuItem *item, MenuToken token, const char *key, bool extended); /* information about string representation of IP addresses */ @@ -130,13 +130,13 @@ MenuItem *menuitem_search(char *menu_id, Client *client) MenuItem *top = client->menu; # endif /* LCDPROC_PERMISSIVE_MENU_GOTO */ - return menu_find_item (top, menu_id, true); + return menu_find_item(top, menu_id, true); } /******** FUNCTION TABLES ********/ /* Tables with functions to call for all different item types */ -void (*destructor_table[NUM_ITEMTYPES] ) (MenuItem *item) = +void (*destructor_table[NUM_ITEMTYPES]) (MenuItem *item) = { menu_destroy, NULL, @@ -147,7 +147,7 @@ void (*destructor_table[NUM_ITEMTYPES] ) (MenuItem *item) = menuitem_destroy_alpha, menuitem_destroy_ip }; -void (*reset_table[NUM_ITEMTYPES] ) (MenuItem *item) = +void (*reset_table[NUM_ITEMTYPES]) (MenuItem *item) = { menu_reset, NULL, @@ -158,7 +158,7 @@ void (*reset_table[NUM_ITEMTYPES] ) (MenuItem *item) = menuitem_reset_alpha, menuitem_reset_ip }; -void (*build_screen_table[NUM_ITEMTYPES] ) (MenuItem *item, Screen *s) = +void (*build_screen_table[NUM_ITEMTYPES]) (MenuItem *item, Screen *s) = { menu_build_screen, NULL, @@ -169,7 +169,7 @@ void (*build_screen_table[NUM_ITEMTYPES] ) (MenuItem *item, Screen *s) = menuitem_rebuild_screen_alpha, menuitem_rebuild_screen_ip }; -void (*update_screen_table[NUM_ITEMTYPES] ) (MenuItem *item, Screen *s) = +void (*update_screen_table[NUM_ITEMTYPES]) (MenuItem *item, Screen *s) = { menu_update_screen, NULL, @@ -181,7 +181,7 @@ void (*update_screen_table[NUM_ITEMTYPES] ) (MenuItem *item, Screen *s) = menuitem_update_screen_ip }; -MenuResult (*process_input_table[NUM_ITEMTYPES] ) (MenuItem *item, MenuToken token, const char *key, bool extended) = +MenuResult (*process_input_table[NUM_ITEMTYPES]) (MenuItem *item, MenuToken token, const char *key, bool extended) = { menu_process_input, NULL, @@ -195,62 +195,62 @@ MenuResult (*process_input_table[NUM_ITEMTYPES] ) (MenuItem *item, MenuToken tok /******** METHODS ********/ -MenuItem *menuitem_create (MenuItemType type, char *id, MenuEventFunc(*event_func), +MenuItem *menuitem_create(MenuItemType type, char *id, MenuEventFunc(*event_func), char *text, Client *client) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( type=%d, id=\"%s\", event_func=%p, text=\"%s\" )", + debug(RPT_DEBUG, "%s(type=%d, id=\"%s\", event_func=%p, text=\"%s\")", __FUNCTION__, type, id, event_func, text); if ((id == NULL) || (text == NULL)) { - // report (RPT_ERR, "%s: illegal id or text", __FUNCTION__); + // report(RPT_ERR, "%s: illegal id or text", __FUNCTION__); return NULL; } /* Allocate space and fill struct */ - new_item = malloc (sizeof(MenuItem)); + new_item = malloc(sizeof(MenuItem)); if (!new_item) { - report (RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); + report(RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); return NULL; } new_item->type = type; - new_item->id = strdup (id); + new_item->id = strdup(id); if (!new_item->id) { - report (RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); - free (new_item); + report(RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); + free(new_item); return NULL; } new_item->successor_id = NULL; new_item->predecessor_id = NULL; new_item->parent = NULL; new_item->event_func = event_func; - new_item->text = strdup (text); + new_item->text = strdup(text); if (!new_item->text) { - report (RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); - free (new_item->id); - free (new_item); + report(RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); + free(new_item->id); + free(new_item); return NULL; } new_item->client = client; new_item->is_hidden = false; /* Clear the type specific data part */ - memset ( &(new_item->data), '\0', sizeof(new_item->data)); + memset(&(new_item->data), '\0', sizeof(new_item->data)); return new_item; } // fixme: the menu_result arg is obsoleted (use char* successor_id) -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) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( id=[%s], event_func=%p, text=\"%s\", close_menu=%d )", + debug(RPT_DEBUG, "%s(id=[%s], event_func=%p, text=\"%s\", close_menu=%d)", __FUNCTION__, id, event_func, text, menu_result); - new_item = menuitem_create (MENUITEM_ACTION, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_ACTION, id, event_func, text, client); if (new_item != NULL) { switch (menu_result) @@ -272,15 +272,15 @@ MenuItem *menuitem_create_action (char *id, MenuEventFunc(*event_func), return new_item; } -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) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( id=[%s], event_func=%p, text=\"%s\", allow_gray=%d, value=%d )", + debug(RPT_DEBUG, "%s(id=[%s], event_func=%p, text=\"%s\", allow_gray=%d, value=%d)", __FUNCTION__, id, event_func, text, allow_gray, value); - new_item = menuitem_create (MENUITEM_CHECKBOX, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_CHECKBOX, id, event_func, text, client); if (new_item != NULL) { new_item->data.checkbox.allow_gray = allow_gray; new_item->data.checkbox.value = value; @@ -289,36 +289,36 @@ MenuItem *menuitem_create_checkbox (char *id, MenuEventFunc(*event_func), return new_item; } -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) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( id=[%s], event_func=%p, text=\"%s\", strings=\"%s\", value=%d )", + debug(RPT_DEBUG, "%s(id=[%s], event_func=%p, text=\"%s\", strings=\"%s\", value=%d)", __FUNCTION__, id, event_func, text, strings, value); - new_item = menuitem_create (MENUITEM_RING, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_RING, id, event_func, text, client); if (new_item != NULL) { - new_item->data.ring.strings = tablist2linkedlist (strings); + new_item->data.ring.strings = tablist2linkedlist(strings); new_item->data.ring.value = value; } return new_item; } -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, int minvalue, int maxvalue, int stepsize, int value) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( id=[%s], event_func=%p, text=\"%s\", mintext=\"%s\", maxtext=\"%s\", minvalue=%d, maxvalue=%d, stepsize=%d, value=%d )", + debug(RPT_DEBUG, "%s(id=[%s], event_func=%p, text=\"%s\", mintext=\"%s\", maxtext=\"%s\", minvalue=%d, maxvalue=%d, stepsize=%d, value=%d)", __FUNCTION__, id, event_func, text, mintext, maxtext, minvalue, maxvalue, stepsize, value); - new_item = menuitem_create (MENUITEM_SLIDER, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_SLIDER, id, event_func, text, client); if (new_item != NULL) { - new_item->data.slider.mintext = strdup (mintext); - new_item->data.slider.maxtext = strdup (maxtext); + new_item->data.slider.mintext = strdup(mintext); + new_item->data.slider.maxtext = strdup(maxtext); new_item->data.slider.minvalue = minvalue; new_item->data.slider.maxvalue = maxvalue; new_item->data.slider.stepsize = stepsize; @@ -328,36 +328,36 @@ MenuItem *menuitem_create_slider (char *id, MenuEventFunc(*event_func), return new_item; } -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) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( id=[%s], event_func=%p, text=\"%s\", minvalue=%d, maxvalue=%d, value=%d )", + debug(RPT_DEBUG, "%s(id=[%s], event_func=%p, text=\"%s\", minvalue=%d, maxvalue=%d, value=%d)", __FUNCTION__, id, event_func, text, minvalue, minvalue, value); - new_item = menuitem_create (MENUITEM_NUMERIC, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_NUMERIC, id, event_func, text, client); if (new_item != NULL) { new_item->data.numeric.maxvalue = maxvalue; new_item->data.numeric.minvalue = minvalue; - new_item->data.numeric.edit_str = malloc (MAX_NUMERIC_LEN); + new_item->data.numeric.edit_str = malloc(MAX_NUMERIC_LEN); new_item->data.numeric.value = value; } return new_item; } -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, bool allow_caps, bool allow_noncaps, bool allow_numbers, char *allowed_extra, char *value) { MenuItem *new_item; - debug (RPT_DEBUG, "%s( id=\"%s\", event_func=%p, text=\"%s\", password_char=%d, maxlength=%d, value=\"%s\" )", + debug(RPT_DEBUG, "%s(id=\"%s\", event_func=%p, text=\"%s\", password_char=%d, maxlength=%d, value=\"%s\")", __FUNCTION__, id, event_func, text, password_char, maxlength, value); - new_item = menuitem_create (MENUITEM_ALPHA, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_ALPHA, id, event_func, text, client); if (new_item != NULL) { new_item->data.alpha.password_char = password_char; new_item->data.alpha.minlength = minlength; @@ -366,35 +366,35 @@ MenuItem *menuitem_create_alpha (char *id, MenuEventFunc(*event_func), new_item->data.alpha.allow_caps = allow_caps; new_item->data.alpha.allow_noncaps = allow_noncaps; new_item->data.alpha.allow_numbers = allow_numbers; - new_item->data.alpha.allowed_extra = strdup (allowed_extra); + new_item->data.alpha.allowed_extra = strdup(allowed_extra); - new_item->data.alpha.value = malloc (maxlength + 1); + new_item->data.alpha.value = malloc(maxlength + 1); if (new_item->data.alpha.value != NULL) { - strncpy (new_item->data.alpha.value, value, maxlength); + strncpy(new_item->data.alpha.value, value, maxlength); new_item->data.alpha.value[maxlength] = 0; } - new_item->data.alpha.edit_str = malloc (maxlength + 1); + new_item->data.alpha.edit_str = malloc(maxlength + 1); } return new_item; } -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) { MenuItem *new_item; const IpSstringProperties *ipinfo; - debug (RPT_DEBUG, "%s( id=\"%s\", event_func=%p, text=\"%s\", v6=%d, value=\"%s\" )", + debug(RPT_DEBUG, "%s(id=\"%s\", event_func=%p, text=\"%s\", v6=%d, value=\"%s\")", __FUNCTION__, id, event_func, text, v6, value); - new_item = menuitem_create (MENUITEM_IP, id, event_func, text, client); + new_item = menuitem_create(MENUITEM_IP, id, event_func, text, client); new_item->data.ip.v6 = v6; ipinfo = (v6) ? &IPinfo[1] : &IPinfo[0]; new_item->data.ip.maxlength = ipinfo->maxlen;; - new_item->data.ip.value = malloc (new_item->data.ip.maxlength + 1); + new_item->data.ip.value = malloc(new_item->data.ip.maxlength + 1); strncpy(new_item->data.ip.value, value, new_item->data.ip.maxlength); new_item->data.ip.value[new_item->data.ip.maxlength] = '\0'; @@ -420,14 +420,14 @@ MenuItem *menuitem_create_ip (char *id, MenuEventFunc(*event_func), } } - new_item->data.ip.edit_str = malloc (new_item->data.ip.maxlength + 1); + new_item->data.ip.edit_str = malloc(new_item->data.ip.maxlength + 1); return new_item; } -void menuitem_destroy (MenuItem *item) +void menuitem_destroy(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { @@ -436,88 +436,88 @@ void menuitem_destroy (MenuItem *item) /* First destroy type specific data */ destructor = destructor_table[item->type]; if (destructor) - destructor (item); + destructor(item); /* Following strings should always be allocated */ - free (item->text); - free (item->id); + free(item->text); + free(item->id); /* And finally...*/ - free (item); + free(item); } } -void menuitem_destroy_ring (MenuItem *item) +void menuitem_destroy_ring(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { - char * s; + char *s; /* deallocate the strings */ for (s = LL_GetFirst(item->data.ring.strings); s != NULL; s = LL_GetNext(item->data.ring.strings)) { - free (s); + free(s); } /* and the list */ - LL_Destroy (item->data.ring.strings); + LL_Destroy(item->data.ring.strings); } } -void menuitem_destroy_slider (MenuItem *item) +void menuitem_destroy_slider(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { /* These strings should always be allocated */ - free (item->data.slider.mintext); - free (item->data.slider.maxtext); + free(item->data.slider.mintext); + free(item->data.slider.maxtext); } } -void menuitem_destroy_numeric (MenuItem *item) +void menuitem_destroy_numeric(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { /* This string should always be allocated */ - free (item->data.numeric.edit_str); + free(item->data.numeric.edit_str); } } -void menuitem_destroy_alpha (MenuItem *item) +void menuitem_destroy_alpha(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { /* These strings should always be allocated */ - free (item->data.alpha.allowed_extra); - free (item->data.alpha.value); - free (item->data.alpha.edit_str); + free(item->data.alpha.allowed_extra); + free(item->data.alpha.value); + free(item->data.alpha.edit_str); } } -void menuitem_destroy_ip (MenuItem *item) +void menuitem_destroy_ip(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); /* These strings should always be allocated */ - free (item->data.ip.value); - free (item->data.ip.edit_str); + free(item->data.ip.value); + free(item->data.ip.edit_str); } /******** MENU ITEM RESET FUNCTIONS ********/ -void menuitem_reset (MenuItem *item) +void menuitem_reset(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { @@ -526,53 +526,53 @@ void menuitem_reset (MenuItem *item) /* First destroy type specific data */ func = reset_table[item->type]; if (func) - func (item); + func(item); } } -void menuitem_reset_numeric (MenuItem *item) +void menuitem_reset_numeric(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { item->data.numeric.edit_pos = 0; item->data.numeric.edit_offs = 0; - memset (item->data.numeric.edit_str, '\0', MAX_NUMERIC_LEN); + memset(item->data.numeric.edit_str, '\0', MAX_NUMERIC_LEN); if (item->data.numeric.minvalue < 0) { - snprintf (item->data.numeric.edit_str, MAX_NUMERIC_LEN, + snprintf(item->data.numeric.edit_str, MAX_NUMERIC_LEN, "%+d", item->data.numeric.value); } else { - snprintf (item->data.numeric.edit_str, MAX_NUMERIC_LEN, + snprintf(item->data.numeric.edit_str, MAX_NUMERIC_LEN, "%d", item->data.numeric.value); } } } -void menuitem_reset_alpha (MenuItem *item) +void menuitem_reset_alpha(MenuItem *item) { - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); if (item != NULL) { item->data.alpha.edit_pos = 0; item->data.alpha.edit_offs = 0; - memset (item->data.alpha.edit_str, '\0', item->data.alpha.maxlength+1); - strcpy (item->data.alpha.edit_str, item->data.alpha.value); + memset(item->data.alpha.edit_str, '\0', item->data.alpha.maxlength+1); + strcpy(item->data.alpha.edit_str, item->data.alpha.value); } } -void menuitem_reset_ip (MenuItem *item) +void menuitem_reset_ip(MenuItem *item) { char *start = item->data.ip.value; const IpSstringProperties *ipinfo = (item->data.ip.v6) ? &IPinfo[1] : &IPinfo[0]; - debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)")); item->data.ip.edit_pos = 0; item->data.ip.edit_offs = 0; - memset (item->data.ip.edit_str, '\0', item->data.ip.maxlength+1); + memset(item->data.ip.edit_str, '\0', item->data.ip.maxlength+1); // normalize IP address string to e.g. 010.002.250.002 / 0001:0203:0405:0607:0809:0a0b:0c0d:0e0f while (start != NULL) { @@ -595,71 +595,71 @@ void menuitem_reset_ip (MenuItem *item) /******** MENU SCREEN BUILD FUNCTIONS ********/ -void menuitem_rebuild_screen (MenuItem *item, Screen *s) +void menuitem_rebuild_screen(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; void (*build_screen) (MenuItem *item, Screen *s); - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if (!display_props) { /* Nothing to build if no display size is known */ - report (RPT_ERR, "%s: display size unknown", __FUNCTION__ ); + report(RPT_ERR, "%s: display size unknown", __FUNCTION__); return; } if (s != NULL) { /* First remove all widgets from the screen */ - while ( (w = screen_getfirst_widget(s)) != NULL) { + while ((w = screen_getfirst_widget(s)) != NULL) { /* We know these widgets don't have subwidgets, so we can * easily remove them */ - screen_remove_widget (s, w); - widget_destroy (w); + screen_remove_widget(s, w); + widget_destroy(w); } if (item != NULL) { /* Call type specific screen building function */ build_screen = build_screen_table [item->type]; if (build_screen) { - build_screen (item, s); + build_screen(item, s); } else { - report (RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); + report(RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); return; } /* Also always call update_screen */ - menuitem_update_screen (item, s); + menuitem_update_screen(item, s); } } } -void menuitem_rebuild_screen_slider (MenuItem *item, Screen *s) +void menuitem_rebuild_screen_slider(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - if (display_props->height >= 2 ) { + if (display_props->height >= 2) { /* Only add a title if enough space... */ - w = widget_create ("text", WID_STRING, s); - screen_add_widget (s, w); + w = widget_create("text", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(item->text); w->x = 1; w->y = 1; } - w = widget_create ("bar", WID_HBAR, s); - screen_add_widget (s, w); + w = widget_create("bar", WID_HBAR, s); + screen_add_widget(s, w); w->width = display_props->width; - if (display_props->height > 2 ) { + if (display_props->height > 2) { /* This is option 1: we have enought space, so the bar and * min/max texts can be on separate lines. */ @@ -668,129 +668,129 @@ void menuitem_rebuild_screen_slider (MenuItem *item, Screen *s) w->width = display_props->width - 2; } - w = widget_create ("min", WID_STRING, s); - screen_add_widget (s, w); + w = widget_create("min", WID_STRING, s); + screen_add_widget(s, w); w->text = NULL; w->x = 1; - if (display_props->height > 2 ) { + if (display_props->height > 2) { w->y = display_props->height / 2 + 2; } else { w->y = display_props->height / 2 + 1; } - w = widget_create ("max", WID_STRING, s); - screen_add_widget (s, w); + w = widget_create("max", WID_STRING, s); + screen_add_widget(s, w); w->text = NULL; w->x = 1; - if (display_props->height > 2 ) { + if (display_props->height > 2) { w->y = display_props->height / 2 + 2; } else { w->y = display_props->height / 2 + 1; } } -void menuitem_rebuild_screen_numeric (MenuItem *item, Screen *s) +void menuitem_rebuild_screen_numeric(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - if (display_props->height >= 2 ) { + if (display_props->height >= 2) { /* Only add a title if enough space... */ - w = widget_create ("text", WID_STRING, s); - screen_add_widget (s, w); + w = widget_create("text", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(item->text); w->x = 1; w->y = 1; } - w = widget_create ("value", WID_STRING, s); - screen_add_widget (s, w); - w->text = malloc (MAX_NUMERIC_LEN); + w = widget_create("value", WID_STRING, s); + screen_add_widget(s, w); + w->text = malloc(MAX_NUMERIC_LEN); w->x = 2; w->y = display_props->height / 2 + 1; /* Only display error string if enough space... */ - if (display_props->height > 2 ) { - w = widget_create ("error", WID_STRING, s); - screen_add_widget (s, w); + if (display_props->height > 2) { + w = widget_create("error", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(""); w->x = 1; w->y = display_props->height; } } -void menuitem_rebuild_screen_alpha (MenuItem *item, Screen *s) +void menuitem_rebuild_screen_alpha(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - if (display_props->height >= 2 ) { + if (display_props->height >= 2) { /* Only add a title if enough space... */ - w = widget_create ("text", WID_STRING, s); - screen_add_widget (s, w); + w = widget_create("text", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(item->text); w->x = 1; w->y = 1; } - w = widget_create ("value", WID_STRING, s); - screen_add_widget (s, w); - w->text = malloc (item->data.alpha.maxlength+1); + w = widget_create("value", WID_STRING, s); + screen_add_widget(s, w); + w->text = malloc(item->data.alpha.maxlength+1); w->x = 2; w->y = display_props->height / 2 + 1; /* Only display error string if enough space... */ - if (display_props->height > 2 ) { - w = widget_create ("error", WID_STRING, s); - screen_add_widget (s, w); + if (display_props->height > 2) { + w = widget_create("error", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(""); w->x = 1; w->y = display_props->height; } } -void menuitem_rebuild_screen_ip (MenuItem *item, Screen *s) +void menuitem_rebuild_screen_ip(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - if (display_props->height >= 2 ) { + if (display_props->height >= 2) { /* Only add a title if enough space... */ - w = widget_create ("text", WID_STRING, s); - screen_add_widget (s, w); + w = widget_create("text", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(item->text); w->x = 1; w->y = 1; } - w = widget_create ("value", WID_STRING, s); - screen_add_widget (s, w); - w->text = malloc (item->data.ip.maxlength+1); + w = widget_create("value", WID_STRING, s); + screen_add_widget(s, w); + w->text = malloc(item->data.ip.maxlength+1); w->x = 2; w->y = display_props->height / 2 + 1; /* Only display error string if enough space... */ - if (display_props->height > 2 ) { - w = widget_create ("error", WID_STRING, s); - screen_add_widget (s, w); + if (display_props->height > 2) { + w = widget_create("error", WID_STRING, s); + screen_add_widget(s, w); w->text = strdup(""); w->x = 1; w->y = display_props->height; @@ -799,11 +799,11 @@ void menuitem_rebuild_screen_ip (MenuItem *item, Screen *s) /******** MENU SCREEN UPDATE FUNCTIONS ********/ -void menuitem_update_screen (MenuItem *item, Screen *s) +void menuitem_update_screen(MenuItem *item, Screen *s) { void (*update_screen) (MenuItem *item, Screen *s); - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); @@ -816,19 +816,19 @@ void menuitem_update_screen (MenuItem *item, Screen *s) /* Call type specific screen building function */ update_screen = update_screen_table [item->type]; if (update_screen) { - update_screen (item, s); + update_screen(item, s); } else { - report (RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); + report(RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); return; } } -void menuitem_update_screen_slider (MenuItem *item, Screen *s) +void menuitem_update_screen_slider(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; int min_len, max_len; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); @@ -836,13 +836,13 @@ void menuitem_update_screen_slider (MenuItem *item, Screen *s) return; /* Calculate the bar position and length by filling buffers */ - min_len = strlen (item->data.slider.mintext); - max_len = strlen (item->data.slider.maxtext); + min_len = strlen(item->data.slider.mintext); + max_len = strlen(item->data.slider.maxtext); /* And adjust the data */ - w = screen_find_widget (s, "bar"); - if (display_props->height <= 2 ) { + w = screen_find_widget(s, "bar"); + if (display_props->height <= 2) { /* This is option 2: we're tight on lines, so we put the bar * and min/max texts on the same line. */ @@ -856,60 +856,60 @@ void menuitem_update_screen_slider (MenuItem *item, Screen *s) * (item->data.slider.value - item->data.slider.minvalue) / (item->data.slider.maxvalue - item->data.slider.minvalue); - w = screen_find_widget (s, "min"); - if (w->text) free (w->text); + w = screen_find_widget(s, "min"); + if (w->text) free(w->text); w->text = strdup(item->data.slider.mintext); - w = screen_find_widget (s, "max"); - if (w->text) free (w->text); + w = screen_find_widget(s, "max"); + if (w->text) free(w->text); w->x = 1 + display_props->width - max_len; w->text = strdup(item->data.slider.maxtext); } -void menuitem_update_screen_numeric (MenuItem *item, Screen *s) +void menuitem_update_screen_numeric(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - w = screen_find_widget (s, "value"); - strcpy (w->text, item->data.numeric.edit_str + item->data.numeric.edit_offs); + w = screen_find_widget(s, "value"); + strcpy(w->text, item->data.numeric.edit_str + item->data.numeric.edit_offs); s->cursor = CURSOR_DEFAULT_ON; s->cursor_x = w->x + item->data.numeric.edit_pos - item->data.numeric.edit_offs; s->cursor_y = w->y; /* Only display error string if enough space... */ - if (display_props->height > 2 ) { - w = screen_find_widget (s, "error"); - free (w->text); - w->text = strdup (error_strs[item->data.numeric.error_code]); + if (display_props->height > 2) { + w = screen_find_widget(s, "error"); + free(w->text); + w->text = strdup(error_strs[item->data.numeric.error_code]); } } -void menuitem_update_screen_alpha (MenuItem *item, Screen *s) +void menuitem_update_screen_alpha(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - w = screen_find_widget (s, "value"); + w = screen_find_widget(s, "value"); if (item->data.alpha.password_char == '\0') { - strcpy (w->text, item->data.alpha.edit_str + item->data.alpha.edit_offs); + strcpy(w->text, item->data.alpha.edit_str + item->data.alpha.edit_offs); } else { int len = strlen(item->data.alpha.edit_str) - item->data.alpha.edit_offs; - memset (w->text, item->data.alpha.password_char, len); + memset(w->text, item->data.alpha.password_char, len); w->text[len] = '\0'; } @@ -918,47 +918,47 @@ void menuitem_update_screen_alpha (MenuItem *item, Screen *s) s->cursor_y = w->y; /* Only display error string if enough space... */ - if (display_props->height > 2 ) { - w = screen_find_widget (s, "error"); - free (w->text); - w->text = strdup (error_strs[item->data.alpha.error_code]); + if (display_props->height > 2) { + w = screen_find_widget(s, "error"); + free(w->text); + w->text = strdup(error_strs[item->data.alpha.error_code]); } } -void menuitem_update_screen_ip (MenuItem *item, Screen *s) +void menuitem_update_screen_ip(MenuItem *item, Screen *s) { - Widget * w; + Widget *w; - debug (RPT_DEBUG, "%s( item=[%s], screen=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if ((item == NULL) || (s == NULL)) return; - w = screen_find_widget (s, "value"); + w = screen_find_widget(s, "value"); if (w != NULL) - strcpy (w->text, item->data.ip.edit_str + item->data.ip.edit_offs); + strcpy(w->text, item->data.ip.edit_str + item->data.ip.edit_offs); s->cursor = CURSOR_DEFAULT_ON; s->cursor_x = w->x + item->data.ip.edit_pos - item->data.ip.edit_offs; s->cursor_y = w->y; /* Only display error string if enough space... */ - if (display_props->height > 2 ) { - w = screen_find_widget (s, "error"); - free (w->text); - w->text = strdup (error_strs[item->data.ip.error_code]); + if (display_props->height > 2) { + w = screen_find_widget(s, "error"); + free(w->text); + w->text = strdup(error_strs[item->data.ip.error_code]); } } /******** MENU SCREEN INPUT HANDLING FUNCTIONS ********/ -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) { - MenuResult (*process_input) (MenuItem *item, MenuToken token, const char * key, bool extended); + MenuResult (*process_input) (MenuItem *item, MenuToken token, const char *key, bool extended); - debug (RPT_DEBUG, "%s( item=[%s], token=%d, key=\"%s\" )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], token=%d, key=\"%s\")", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), token, key); if (item == NULL) @@ -966,17 +966,17 @@ MenuResult menuitem_process_input (MenuItem *item, MenuToken token, const char * /* Call type specific screen building function */ process_input = process_input_table [item->type]; - if (process_input ) { - return process_input (item, token, key, extended); + if (process_input) { + return process_input(item, token, key, extended); } else { - report (RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); + report(RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); return MENURESULT_ERROR; } } -MenuResult menuitem_process_input_slider (MenuItem *item, MenuToken token, const char * key, bool extended) +MenuResult menuitem_process_input_slider(MenuItem *item, MenuToken token, const char *key, bool extended) { - debug (RPT_DEBUG, "%s( item=[%s], token=%d, key=\"%s\" )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], token=%d, key=\"%s\")", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), token, key); if (item == NULL) @@ -991,17 +991,17 @@ MenuResult menuitem_process_input_slider (MenuItem *item, MenuToken token, const item->successor_id, MENURESULT_CLOSE); case MENUTOKEN_UP: case MENUTOKEN_RIGHT: - item->data.slider.value = min (item->data.slider.maxvalue, + item->data.slider.value = min(item->data.slider.maxvalue, item->data.slider.value + item->data.slider.stepsize); if (item->event_func) - item->event_func (item, MENUEVENT_PLUS); + item->event_func(item, MENUEVENT_PLUS); return MENURESULT_NONE; case MENUTOKEN_DOWN: case MENUTOKEN_LEFT: - item->data.slider.value = max (item->data.slider.minvalue, + item->data.slider.value = max(item->data.slider.minvalue, item->data.slider.value - item->data.slider.stepsize); if (item->event_func) - item->event_func (item, MENUEVENT_MINUS); + item->event_func(item, MENUEVENT_MINUS); return MENURESULT_NONE; case MENUTOKEN_OTHER: default: @@ -1011,14 +1011,14 @@ MenuResult menuitem_process_input_slider (MenuItem *item, MenuToken token, const return MENURESULT_ERROR; } -MenuResult menuitem_process_input_numeric (MenuItem *item, MenuToken token, const char * key, bool extended) +MenuResult menuitem_process_input_numeric(MenuItem *item, MenuToken token, const char *key, bool extended) { char buf1[MAX_NUMERIC_LEN]; char buf2[MAX_NUMERIC_LEN]; int max_len; - debug (RPT_DEBUG, "%s( item=[%s], token=%d, key=\"%s\" )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], token=%d, key=\"%s\")", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), token, key); if (item != NULL) { @@ -1028,10 +1028,10 @@ MenuResult menuitem_process_input_numeric (MenuItem *item, MenuToken token, cons int allow_signed = (item->data.numeric.minvalue < 0); char *format_str = (allow_signed) ? "%+d" : "%d"; - snprintf (buf1, MAX_NUMERIC_LEN, format_str, item->data.numeric.minvalue); - snprintf (buf2, MAX_NUMERIC_LEN, format_str, item->data.numeric.maxvalue); + snprintf(buf1, MAX_NUMERIC_LEN, format_str, item->data.numeric.minvalue); + snprintf(buf2, MAX_NUMERIC_LEN, format_str, item->data.numeric.maxvalue); - max_len = max (strlen(buf1), strlen(buf2)); + max_len = max(strlen(buf1), strlen(buf2)); /* Clear the error */ item->data.numeric.error_code = 0; @@ -1053,7 +1053,7 @@ MenuResult menuitem_process_input_numeric (MenuItem *item, MenuToken token, cons /* The user completed his input */ /* ...scan it */ - if (sscanf (str, "%d", &value) != 1) { + if (sscanf(str, "%d", &value) != 1) { return MENURESULT_ERROR; } /* Test the value */ @@ -1073,7 +1073,7 @@ MenuResult menuitem_process_input_numeric (MenuItem *item, MenuToken token, cons /* Inform client */ if (item->event_func) - item->event_func (item, MENUEVENT_UPDATE); + item->event_func(item, MENUEVENT_UPDATE); return menuitem_successor2menuresult( item->successor_id, MENURESULT_CLOSE); @@ -1168,12 +1168,12 @@ MenuResult menuitem_process_input_numeric (MenuItem *item, MenuToken token, cons return MENURESULT_ERROR; } -MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const char * key, bool extended) +MenuResult menuitem_process_input_alpha(MenuItem *item, MenuToken token, const char *key, bool extended) { - char * p; - static char * chars = NULL; + char *p; + static char *chars = NULL; - debug (RPT_DEBUG, "%s( item=[%s], token=%d, key=\"%s\" )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], token=%d, key=\"%s\")", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), token, key); if (item != NULL) { @@ -1182,15 +1182,15 @@ MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const int pos = item->data.alpha.edit_pos; /* Create list of allowed chars */ - chars = realloc (chars, 26 + 26 + 10 + strlen(item->data.alpha.allowed_extra) + 1); + chars = realloc(chars, 26 + 26 + 10 + strlen(item->data.alpha.allowed_extra) + 1); chars[0] = '\0'; /* clear string */ if (item->data.alpha.allow_caps) - strcat (chars, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + strcat(chars, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); if (item->data.alpha.allow_noncaps) - strcat (chars, "abcdefghijklmnopqrstuvwxyz"); + strcat(chars, "abcdefghijklmnopqrstuvwxyz"); if (item->data.alpha.allow_numbers) - strcat (chars, "0123456789"); - strcat (chars, item->data.alpha.allowed_extra); + strcat(chars, "0123456789"); + strcat(chars, item->data.alpha.allowed_extra); /* Clear the error */ item->data.alpha.error_code = 0; @@ -1211,17 +1211,17 @@ MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const /* The user completed his input */ /* It's not too short ? */ - if (strlen (item->data.alpha.edit_str) < item->data.alpha.minlength) { + if (strlen(item->data.alpha.edit_str) < item->data.alpha.minlength) { item->data.alpha.error_code = 3; return MENURESULT_NONE; } /* Store value */ - strcpy (item->data.alpha.value, item->data.alpha.edit_str); + strcpy(item->data.alpha.value, item->data.alpha.edit_str); /* Inform client */ if (item->event_func) - item->event_func (item, MENUEVENT_UPDATE); + item->event_func(item, MENUEVENT_UPDATE); return menuitem_successor2menuresult( item->successor_id, MENURESULT_CLOSE); @@ -1248,9 +1248,9 @@ MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const str[pos] = chars[0]; } else { /* We should have a symbol from our list */ - p = strchr (chars, str[pos]); + p = strchr(chars, str[pos]); if (p != NULL) { - str[pos] = * (++p); /* next symbol on list */ + str[pos] = *(++p); /* next symbol on list */ /* Might be '\0' now */ } else { str[pos] = '\0'; @@ -1270,9 +1270,9 @@ MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const str[pos] = chars[strlen(chars)-1]; } else { /* We should have a symbol from our list */ - p = strchr (chars, str[pos]); + p = strchr(chars, str[pos]); if ((p != NULL) && (p != chars)) { - str[pos] = * (--p); /* previous symbol on list */ + str[pos] = *(--p); /* previous symbol on list */ } else { str[pos] = '\0'; } @@ -1317,7 +1317,7 @@ MenuResult menuitem_process_input_alpha (MenuItem *item, MenuToken token, const } -MenuResult menuitem_process_input_ip (MenuItem *item, MenuToken token, const char * key, bool extended) +MenuResult menuitem_process_input_ip(MenuItem *item, MenuToken token, const char *key, bool extended) { /* To make life easy... */ char *str = item->data.ip.edit_str; @@ -1326,7 +1326,7 @@ MenuResult menuitem_process_input_ip (MenuItem *item, MenuToken token, const cha int pos = item->data.ip.edit_pos; const IpSstringProperties *ipinfo = (item->data.ip.v6) ? &IPinfo[1] : &IPinfo[0]; - debug (RPT_DEBUG, "%s( item=[%s], token=%d, key=\"%s\" )", __FUNCTION__, + debug(RPT_DEBUG, "%s(item=[%s], token=%d, key=\"%s\")", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), token, key); /* Clear the error */ @@ -1370,11 +1370,11 @@ MenuResult menuitem_process_input_ip (MenuItem *item, MenuToken token, const cha } // store value - strcpy (item->data.ip.value, tmp); + strcpy(item->data.ip.value, tmp); // Inform client if (item->event_func) - item->event_func (item, MENUEVENT_UPDATE); + item->event_func(item, MENUEVENT_UPDATE); return menuitem_successor2menuresult( item->successor_id, MENURESULT_CLOSE); @@ -1449,14 +1449,14 @@ MenuResult menuitem_process_input_ip (MenuItem *item, MenuToken token, const cha /** * get the Client that owns item. extracted from menu_commands_handler(). */ -Client * menuitem_get_client(MenuItem * item) +Client *menuitem_get_client(MenuItem *item) { return item->client; } -LinkedList * tablist2linkedlist (char *strings) +LinkedList *tablist2linkedlist(char *strings) { - LinkedList * list; + LinkedList *list; list = LL_new(); @@ -1469,30 +1469,30 @@ LinkedList * tablist2linkedlist (char *strings) int len = (int)(tabptr - p); /* Alloc and copy substring */ - new_s = malloc (len + 1); - strncpy (new_s, p, len); + new_s = malloc(len + 1); + strncpy(new_s, p, len); new_s[len] = 0; - LL_Push (list, new_s); + LL_Push(list, new_s); /* Go to next string */ p = tabptr + 1; } /* Add last string */ - new_s = strdup (p); - LL_Push (list, new_s); + new_s = strdup(p); + LL_Push(list, new_s); } return list; } -MenuItemType menuitem_typename_to_type (char *name) +MenuItemType menuitem_typename_to_type(char *name) { if (name != NULL) { MenuItemType type; for (type = 0; type < NUM_ITEMTYPES; type ++) { - if (strcmp (menuitemtypenames[type], name) == 0) { + if (strcmp(menuitemtypenames[type], name) == 0) { return type; } } @@ -1500,20 +1500,20 @@ MenuItemType menuitem_typename_to_type (char *name) return -1; } -char *menuitem_type_to_typename (MenuItemType type) +char *menuitem_type_to_typename(MenuItemType type) { return ((type >= 0 && type < NUM_ITEMTYPES) ? menuitemtypenames[type] : NULL); } -MenuEventType menuitem_eventtypename_to_eventtype (char *name) +MenuEventType menuitem_eventtypename_to_eventtype(char *name) { if (name != NULL) { MenuEventType type; for (type = 0; type < NUM_EVENTTYPES; type ++) { - if (strcmp (menueventtypenames[type], name) == 0) { + if (strcmp(menueventtypenames[type], name) == 0) { return type; } } @@ -1521,7 +1521,7 @@ MenuEventType menuitem_eventtypename_to_eventtype (char *name) return -1; } -char *menuitem_eventtype_to_eventtypename (MenuEventType type) +char *menuitem_eventtype_to_eventtypename(MenuEventType type) { return ((type >= 0 && type < NUM_EVENTTYPES) ? menueventtypenames[type] diff --git a/server/menuitem.h b/server/menuitem.h index 29a8d20..9ef3801 100644 --- a/server/menuitem.h +++ b/server/menuitem.h @@ -204,10 +204,10 @@ MenuResult menuitem_predecessor2menuresult(char *predecessor_id, MenuResult defa /** translates a successor_id into a MenuResult. */ 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 */ -MenuItem *menuitem_create (MenuItemType type, char *id, +MenuItem *menuitem_create(MenuItemType type, char *id, MenuEventFunc(*event_func), char *text, Client *client); /* 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: * 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); /** Creates a checkbox. * 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); /** 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. * 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); /** 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. * 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, 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. * 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); /** Creates a string value box. @@ -271,7 +271,7 @@ MenuItem *menuitem_create_numeric (char *id, MenuEventFunc(*event_func), * input. * 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, bool allow_caps, bool allow_noncaps, bool allow_numbers, 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 * 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); /** Deletes item from memory. * 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. * You should call menuitem_update after this to see the effects. * This call is useless on items that have immediate effect, like a slider. * 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. * Should be re-called if menuitem data has been changed. @@ -300,30 +300,30 @@ void menuitem_reset (MenuItem *item); * - the values * - 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 * 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. * 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 */ -Client * menuitem_get_client(MenuItem * item); +Client *menuitem_get_client(MenuItem *item); /** 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 diff --git a/server/menuscreens.c b/server/menuscreens.c index e68f419..94cb072 100644 --- a/server/menuscreens.c +++ b/server/menuscreens.c @@ -41,152 +41,152 @@ /* Next include files are needed for settings that we can modify */ #include "render.h" -char * menu_key; -char * enter_key; -char * up_key; -char * down_key; -char * left_key; -char * right_key; +char *menu_key; +char *enter_key; +char *up_key; +char *down_key; +char *left_key; +char *right_key; -Screen * menuscreen = NULL; -MenuItem * active_menuitem = NULL; +Screen *menuscreen = NULL; +MenuItem *active_menuitem = NULL; /** the "real" main_menu */ -Menu * main_menu = NULL; +Menu *main_menu = NULL; /** customizable entry point into the menu system (see menu_set_main()). */ -Menu * custom_main_menu = NULL; -Menu * screens_menu = NULL; +Menu *custom_main_menu = NULL; +Menu *screens_menu = NULL; /* Local prototypes */ -static void handle_quit(); -static void handle_close(); -static void handle_none(); -static void handle_enter(); -static void handle_successor(); -void menuscreen_switch_item (MenuItem * new_menuitem); -void menuscreen_create_menu (); -Menu* menuscreen_get_main (); -MenuEventFunc (heartbeat_handler); -MenuEventFunc (backlight_handler); -MenuEventFunc (contrast_handler); -MenuEventFunc (brightness_handler); +static void handle_quit(void); +static void handle_close(void); +static void handle_none(void); +static void handle_enter(void); +static void handle_successor(void); +void menuscreen_switch_item(MenuItem *new_menuitem); +void menuscreen_create_menu(void); +Menu *menuscreen_get_main(void); +MenuEventFunc(heartbeat_handler); +MenuEventFunc(backlight_handler); +MenuEventFunc(contrast_handler); +MenuEventFunc(brightness_handler); -int menuscreens_init() +int menuscreens_init(void) { const char *tmp; - debug (RPT_DEBUG, "%s()", __FUNCTION__); + debug(RPT_DEBUG, "%s()", __FUNCTION__); /* Get keys from config file */ - menu_key = strdup (config_get_string ("menu", "MenuKey", 0, "Menu")); - enter_key = strdup (config_get_string ("menu", "EnterKey", 0, "Enter")); - up_key = strdup (config_get_string ("menu", "UpKey", 0, "Up")); - down_key = strdup (config_get_string ("menu", "DownKey", 0, "Down")); + menu_key = strdup(config_get_string("menu", "MenuKey", 0, "Menu")); + enter_key = strdup(config_get_string("menu", "EnterKey", 0, "Enter")); + up_key = strdup(config_get_string("menu", "UpKey", 0, "Up")); + down_key = strdup(config_get_string("menu", "DownKey", 0, "Down")); /* if the user has specified in the conf file a left and right key */ left_key = right_key = NULL; - tmp = config_get_string ("menu", "LeftKey", 0, NULL); + tmp = config_get_string("menu", "LeftKey", 0, NULL); if (tmp) left_key = strdup(tmp); - tmp = config_get_string ("menu", "RightKey", 0, NULL); + tmp = config_get_string("menu", "RightKey", 0, NULL); if (tmp) right_key = strdup(tmp); /* Now reserve keys */ - input_reserve_key (menu_key, true, NULL); - input_reserve_key (enter_key, false, NULL); - input_reserve_key (up_key, false, NULL); - input_reserve_key (down_key, false, NULL); + input_reserve_key(menu_key, true, NULL); + input_reserve_key(enter_key, false, NULL); + input_reserve_key(up_key, false, NULL); + input_reserve_key(down_key, false, NULL); if (left_key) - input_reserve_key (left_key, false, NULL); + input_reserve_key(left_key, false, NULL); if (right_key) - input_reserve_key (right_key, false, NULL); + input_reserve_key(right_key, false, NULL); /* Create screen */ - menuscreen = screen_create ("_menu_screen", NULL); + menuscreen = screen_create("_menu_screen", NULL); if (menuscreen != NULL) menuscreen->priority = PRI_HIDDEN; active_menuitem = NULL; - screenlist_add (menuscreen); + screenlist_add(menuscreen); /* Build menu */ - menuscreen_create_menu (); + menuscreen_create_menu(); return 0; } -int menuscreens_shutdown() +int menuscreens_shutdown(void) { - debug (RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); /* Program shutdown before completed startup */ if (!menuscreen) return -1; /* Quit menu just to make sure */ - menuscreen_switch_item (NULL); + menuscreen_switch_item(NULL); /* Destroy the menuscreen */ - screenlist_remove (menuscreen); - screen_destroy (menuscreen); + screenlist_remove(menuscreen); + screen_destroy(menuscreen); menuscreen = NULL; /* Destroy all menus */ - menuitem_destroy (main_menu); + menuitem_destroy(main_menu); main_menu = NULL; custom_main_menu = NULL; screens_menu = NULL; /* Forget menu's key reservations */ - input_release_client_keys (NULL); + input_release_client_keys(NULL); - free (menu_key); - free (enter_key); - free (up_key); - free (down_key); + free(menu_key); + free(enter_key); + free(up_key); + free(down_key); if (left_key) - free (left_key); + free(left_key); if (right_key) - free (right_key); + free(right_key); 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)")); /* Are we currently in (a subitem of) the given item ? */ - for( i = active_menuitem; i != NULL; i = i->parent ) { - if( i == item ) { - menuscreen_switch_item (item->parent); + for (i = active_menuitem; i != NULL; i = i->parent) { + if (i == item) { + 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)")); if ((active_menuitem == NULL) || (item == NULL)) return; /* Are we currently in the item or the parent of the item ? */ - if( active_menuitem == item || active_menuitem == item->parent ) { - menuitem_rebuild_screen( active_menuitem, menuscreen ); + if (active_menuitem == item || active_menuitem == item->parent) { + 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; else return false; @@ -197,11 +197,11 @@ bool is_menu_key (const char * key) * 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. */ -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)"), ((old_menuitem != NULL) ? old_menuitem->id : "(null)")); @@ -216,16 +216,16 @@ void menuscreen_switch_item (MenuItem * new_menuitem) menuscreen->priority = PRI_HIDDEN; } else if (!old_menuitem && new_menuitem) { /* Menu is becoming active */ - menuitem_reset (active_menuitem); - menuitem_rebuild_screen (active_menuitem, menuscreen); + menuitem_reset(active_menuitem); + menuitem_rebuild_screen(active_menuitem, menuscreen); menuscreen->priority = PRI_INPUT; } else { /* We're left with the usual case: a menu level switch */ - if( old_menuitem->parent != new_menuitem) { - menuitem_reset (new_menuitem); + if (old_menuitem->parent != 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) @@ -236,27 +236,27 @@ void menuscreen_switch_item (MenuItem * new_menuitem) 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); } -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( (active_menuitem == menuscreen_get_main()) ? NULL : 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) { - menuitem_update_screen (active_menuitem, menuscreen); + menuitem_update_screen(active_menuitem, menuscreen); /* No rebuild needed, only value can be changed */ } /* Nothing extra to be done */ @@ -267,19 +267,19 @@ static void handle_none() * own screen. The menuitem_process_input function should do * things like toggling checkboxes ! */ -static void handle_enter() +static void handle_enter(void) { - debug (RPT_DEBUG, "%s: Entering subitem", __FUNCTION__); - menuscreen_switch_item (menu_get_current_item (active_menuitem)); + debug(RPT_DEBUG, "%s: Entering subitem", __FUNCTION__); + 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) ? menu_get_item_for_predecessor_check(active_menuitem) : active_menuitem; 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); MenuItem *predecessor = menuitem_search( item->predecessor_id, (Client*)active_menuitem->client); @@ -288,7 +288,7 @@ static void handle_predecessor() // note: if _quit_, _close_, _none_ get here this // would be an implementation error - they should // 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); 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) ? menu_get_item_for_successor_check(active_menuitem) : active_menuitem; 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); MenuItem *successor = menuitem_search( item->successor_id, (Client*)active_menuitem->client); @@ -329,7 +329,7 @@ static void handle_successor() // note: if _quit_, _close_, _none_ get here this // would be an implementation error - they should // 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); 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; 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; } - else if (strcmp (key, enter_key) == 0) { + else if (strcmp(key, enter_key) == 0) { token = MENUTOKEN_ENTER; } - else if (strcmp (key, up_key) == 0) { + else if (strcmp(key, up_key) == 0) { token = MENUTOKEN_UP; } - else if (strcmp (key, down_key) == 0) { + else if (strcmp(key, down_key) == 0) { token = MENUTOKEN_DOWN; } - else if (left_key && strcmp (key, left_key) == 0) { + else if (left_key && strcmp(key, left_key) == 0) { token = MENUTOKEN_LEFT; } - else if (right_key && strcmp (key, right_key) == 0) { + else if (right_key && strcmp(key, right_key) == 0) { token = MENUTOKEN_RIGHT; } else { @@ -386,17 +386,17 @@ void menuscreen_key_handler (const char *key) /* Is the menu already active ? */ 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()); return; } - res = menuitem_process_input (active_menuitem, token, key, + res = menuitem_process_input(active_menuitem, token, key, ((left_key || right_key) ? 1 : 0)); switch (res) { case MENURESULT_ERROR: - report (RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__); + report(RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__); break; case MENURESULT_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 * driver_menu; - MenuItem * checkbox; - MenuItem * slider; - Driver * driver; + Menu *options_menu; + Menu *driver_menu; + MenuItem *checkbox; + MenuItem *slider; + Driver *driver; #ifdef LCDPROC_TESTMENUS - MenuItem * test_item; - Menu * test_menu; + MenuItem *test_item; + Menu *test_menu; #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); - menu_add_item (main_menu, options_menu); + options_menu = menu_create("options", NULL, "Options", NULL); + menu_add_item(main_menu, options_menu); #ifdef LCDPROC_TESTMENUS - screens_menu = menu_create ("screens", NULL, "Screens", NULL); - menu_add_item (main_menu, screens_menu); + screens_menu = menu_create("screens", NULL, "Screens", NULL); + menu_add_item(main_menu, screens_menu); #endif /*LCDPROC_TESTMENUS*/ /* menu's client is NULL since we're in the server */ - checkbox = menuitem_create_checkbox ("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat); - menu_add_item (options_menu, checkbox); + checkbox = menuitem_create_checkbox("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat); + menu_add_item(options_menu, checkbox); /* menu's client is NULL since we're in the server */ - checkbox = menuitem_create_checkbox ("backlight", backlight_handler, "Backlight", NULL, true, backlight); - menu_add_item (options_menu, checkbox); + checkbox = menuitem_create_checkbox("backlight", backlight_handler, "Backlight", NULL, true, backlight); + menu_add_item(options_menu, checkbox); for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) { int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0; @@ -461,83 +461,83 @@ void menuscreen_create_menu () if (contrast_avail || brightness_avail) { /* 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_add_item (options_menu, driver_menu); + menu_add_item(options_menu, driver_menu); if (contrast_avail) { int contrast = driver->get_contrast(driver); /* 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); - menu_add_item (driver_menu, slider); + menu_add_item(driver_menu, slider); } if (brightness_avail) { - int onbrightness = driver->get_brightness (driver, BACKLIGHT_ON); - int offbrightness = driver->get_brightness (driver, BACKLIGHT_OFF); + int onbrightness = driver->get_brightness(driver, BACKLIGHT_ON); + 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); - 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); - menu_add_item (driver_menu, slider); + menu_add_item(driver_menu, slider); } } } #ifdef LCDPROC_TESTMENUS - test_menu = menu_create ("test", NULL, "Test menu", NULL); - menu_add_item (main_menu, test_menu); + test_menu = menu_create("test", NULL, "Test menu", NULL); + menu_add_item(main_menu, test_menu); /* menu's client is NULL since we're in the server */ - test_item = menuitem_create_action ("", NULL, "Action", NULL, MENURESULT_NONE); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_action ("", NULL, "Action,closing", NULL, MENURESULT_CLOSE); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_action ("", NULL, "Action,quitting", NULL, MENURESULT_QUIT); - menu_add_item (test_menu, test_item); + test_item = menuitem_create_action("", NULL, "Action", NULL, MENURESULT_NONE); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_action("", NULL, "Action,closing", NULL, MENURESULT_CLOSE); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_action("", NULL, "Action,quitting", NULL, MENURESULT_QUIT); + menu_add_item(test_menu, test_item); - test_item = menuitem_create_checkbox ("", NULL, "Checkbox", NULL, false, false); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_checkbox ("", NULL, "Checkbox, gray", NULL, true, false); - menu_add_item (test_menu, test_item); + test_item = menuitem_create_checkbox("", NULL, "Checkbox", NULL, false, false); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_checkbox("", NULL, "Checkbox, gray", NULL, true, false); + 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); - 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); + menu_add_item(test_menu, test_item); - test_item = menuitem_create_slider ("", NULL, "Slider", NULL, "mintext", "maxtext", -20, 20, 1, 0); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_slider ("", NULL, "Slider,step=5", NULL, "mintext", "maxtext", -20, 20, 5, 0); - menu_add_item (test_menu, test_item); + test_item = menuitem_create_slider("", NULL, "Slider", NULL, "mintext", "maxtext", -20, 20, 1, 0); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_slider("", NULL, "Slider,step=5", NULL, "mintext", "maxtext", -20, 20, 5, 0); + menu_add_item(test_menu, test_item); - test_item = menuitem_create_numeric ("", NULL, "Numeric", NULL, 1, 365, 15); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_numeric ("", NULL, "Numeric,signed", NULL, -20, +20, 15); - menu_add_item (test_menu, test_item); + test_item = menuitem_create_numeric("", NULL, "Numeric", NULL, 1, 365, 15); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_numeric("", NULL, "Numeric,signed", NULL, -20, +20, 15); + menu_add_item(test_menu, test_item); - test_item = menuitem_create_alpha ("", NULL, "Alpha", NULL, 0, 3, 12, true, true, true, ".-+@", "LCDproc-v0.5"); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_alpha ("", NULL, "Alpha, caps only", NULL, 0, 3, 12, true, false, false, "-", "LCDPROC"); - menu_add_item (test_menu, test_item); + test_item = menuitem_create_alpha("", NULL, "Alpha", NULL, 0, 3, 12, true, true, true, ".-+@", "LCDproc-v0.5"); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_alpha("", NULL, "Alpha, caps only", NULL, 0, 3, 12, true, false, false, "-", "LCDPROC"); + menu_add_item(test_menu, test_item); - test_item = menuitem_create_ip ("", NULL, "IPv4", NULL, 0, "192.168.1.245"); - menu_add_item (test_menu, test_item); - test_item = menuitem_create_ip ("", NULL, "IPv6", NULL, 1, "1080:0:0:0:8:800:200C:417A"); - menu_add_item (test_menu, test_item); + test_item = menuitem_create_ip("", NULL, "IPv4", NULL, 0, "192.168.1.245"); + menu_add_item(test_menu, test_item); + test_item = menuitem_create_ip("", NULL, "IPv6", NULL, 1, "1080:0:0:0:8:800:200C:417A"); + menu_add_item(test_menu, test_item); #endif /*LCDPROC_TESTMENUS*/ } 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); if (event == MENUEVENT_UPDATE) { /* Set heartbeat setting */ 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); } return 0; @@ -545,14 +545,14 @@ MenuEventFunc (heartbeat_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); if (event == MENUEVENT_UPDATE) { /* Set backlight setting */ 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); } return 0; @@ -560,7 +560,7 @@ MenuEventFunc (backlight_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); /* 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. */ if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) { /* Determine the driver */ - Driver * driver = item->parent->data.menu.association; + Driver *driver = item->parent->data.menu.association; + if (driver != NULL) { - driver->set_contrast (driver, item->data.slider.value); - report (RPT_INFO, "Menu: set contrast of [%.40s] to %d", + driver->set_contrast(driver, item->data.slider.value); + report(RPT_INFO, "Menu: set contrast of [%.40s] to %d", driver->name, item->data.slider.value); } } @@ -580,7 +581,7 @@ MenuEventFunc (contrast_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); /* 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. */ if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) { /* Determine the driver */ - Driver * driver = item->parent->data.menu.association; + Driver *driver = item->parent->data.menu.association; if (driver != NULL) { - if ( strcmp (item->id, "onbrightness") == 0) { - driver->set_brightness (driver, BACKLIGHT_ON, item->data.slider.value); + if (strcmp(item->id, "onbrightness") == 0) { + driver->set_brightness(driver, BACKLIGHT_ON, item->data.slider.value); } - else if ( strcmp (item->id, "offbrightness") == 0) { - driver->set_brightness (driver, BACKLIGHT_OFF, item->data.slider.value); + else if (strcmp(item->id, "offbrightness") == 0) { + driver->set_brightness(driver, BACKLIGHT_OFF, item->data.slider.value); } } } @@ -603,12 +604,12 @@ MenuEventFunc (brightness_handler) } void -menuscreen_add_screen (Screen * s) +menuscreen_add_screen(Screen *s) { - Menu * m; - MenuItem * mi; + Menu *m; + MenuItem *mi; - debug (RPT_DEBUG, "%s( s=[%s] )", __FUNCTION__, + debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__, ((s != NULL) ? s->id : "(null)")); /* screens have not been created or no screen given ... */ @@ -616,33 +617,33 @@ menuscreen_add_screen (Screen * s) return; /* 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_add_item (screens_menu, m); + menu_add_item(screens_menu, m); /* And add some items for it... */ - mi = menuitem_create_action ("", NULL, "(don't work yet)", s->client, MENURESULT_NONE); - menu_add_item (m, mi); + mi = menuitem_create_action("", NULL, "(don't work yet)", s->client, MENURESULT_NONE); + menu_add_item(m, mi); - mi = menuitem_create_action ("", NULL, "To Front", s->client, MENURESULT_QUIT); - menu_add_item (m, mi); + mi = menuitem_create_action("", NULL, "To Front", s->client, MENURESULT_QUIT); + menu_add_item(m, mi); - mi = menuitem_create_checkbox ("", NULL, "Visible", s->client, false, true); - menu_add_item (m, mi); + mi = menuitem_create_checkbox("", NULL, "Visible", s->client, false, true); + menu_add_item(m, mi); - mi = menuitem_create_numeric ("", NULL, "Duration", s->client, 2, 3600, s->duration); - menu_add_item (m, mi); + mi = menuitem_create_numeric("", NULL, "Duration", s->client, 2, 3600, s->duration); + 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); - menu_add_item (m, mi); + menu_add_item(m, mi); } 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)"); /* allow to remove the menuscreen itself */ @@ -650,36 +651,36 @@ menuscreen_remove_screen (Screen * s) return; 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); - menuitem_destroy (m); + menu_remove_item(screens_menu, m); + menuitem_destroy(m); } } 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)", (active_menuitem != NULL) ? active_menuitem->id : "(NULL)"); - menuscreen_switch_item (menu); + menuscreen_switch_item(menu); return 0; } /** sets custom main menu. Use NULL pointer to reset it to the "real" main * menu. */ 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)"); custom_main_menu = menu; return 0; } -Menu* -menuscreen_get_main() +Menu * +menuscreen_get_main(void) { return custom_main_menu ? custom_main_menu : main_menu; } diff --git a/server/menuscreens.h b/server/menuscreens.h index 8bdc0b1..c9acbd1 100644 --- a/server/menuscreens.h +++ b/server/menuscreens.h @@ -20,42 +20,42 @@ #include "menuitem.h" #include "screen.h" -extern Screen * menuscreen; -extern Menu * main_menu; +extern Screen *menuscreen; +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 * 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 * 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 * 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. */ -void menuscreen_key_handler (const char *key); +void menuscreen_key_handler(const char *key); /** 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 */ -void menuscreen_remove_screen (Screen * s); +void menuscreen_remove_screen(Screen *s); /** switches to menu. */ -int menuscreen_goto (Menu * menu); +int menuscreen_goto(Menu *menu); /** sets custom_main_menu. */ -int menuscreen_set_main (Menu * menu); +int menuscreen_set_main(Menu *menu); #endif diff --git a/server/parse.c b/server/parse.c index 47c893e..0f431fc 100644 --- a/server/parse.c +++ b/server/parse.c @@ -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; State state = ST_INITIAL; @@ -62,14 +62,14 @@ static int parse_message (const char *str, Client *c) int argpos = 0; 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 * the original string str. */ arg_space = malloc(strlen(str)+1); 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"); } @@ -109,7 +109,7 @@ static int parse_message (const char *str, Client *c) /* We solve quoted chars here right away */ const char escape_chars[] = "nrt"; 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 ? * Can the displays deal with them ? @@ -183,7 +183,7 @@ static int parse_message (const char *str, Client *c) if (error) { sock_send_error(c->sock, "Could not parse command\n"); - free( arg_space ); + free(arg_space); return 0; } @@ -198,37 +198,37 @@ static int parse_message (const char *str, Client *c) function = get_command_function(argv[0]); if (function != NULL) { - error = function (c, argc, argv); + error = function(c, argc, argv); if (error) { 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 { 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; } 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()) { - char * str; + char *str; /* And parse all its messages...*/ /*debug(RPT_DEBUG, "parse: Getting messages...");*/ - for (str = client_get_message (c); str != NULL; str = client_get_message (c)) { - parse_message (str, c); - free (str); + for (str = client_get_message(c); str != NULL; str = client_get_message(c)) { + parse_message(str, c); + free(str); } } return 0; diff --git a/server/parse.h b/server/parse.h index 7d378ee..d3680dc 100644 --- a/server/parse.h +++ b/server/parse.h @@ -13,6 +13,6 @@ #define PARSE_H // This should be pretty self-explanatory... -int parse_all_client_messages (); +int parse_all_client_messages(void); #endif diff --git a/server/render.c b/server/render.c index 0a40c24..7392e86 100644 --- a/server/render.c +++ b/server/render.c @@ -44,22 +44,22 @@ static int heartbeat_fallback = HEARTBEAT_ON; /* If no heartbeat setting has bee int backlight = BACKLIGHT_OPEN; static int backlight_fallback = BACKLIGHT_ON; /* If no backlight setting has been set at all */ int output_state = 0; -char * server_msg_text; +char *server_msg_text; int server_msg_expire = 0; static int reset; #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 -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; - 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; @@ -71,7 +71,7 @@ render_screen (Screen * s, long int timer) old_s = s; /* Clear the LCD screen... */ - drivers_clear (); + drivers_clear(); /* FIXME drivers_backlight -- * @@ -94,32 +94,32 @@ render_screen (Screen * s, long int timer) /* NOTE: dirty stripping of other options... */ /* Backlight flash: check timer and flip backlight as appropriate */ if (tmp_state & BACKLIGHT_FLASH) { - drivers_backlight ( + drivers_backlight( ( (tmp_state & BACKLIGHT_ON) ^ ((timer & 7) == 7) - ) ? BACKLIGHT_ON : BACKLIGHT_OFF ); + ) ? BACKLIGHT_ON : BACKLIGHT_OFF); /* Backlight blink: check timer and flip backlight as appropriate */ } else if (tmp_state & BACKLIGHT_BLINK) { - drivers_backlight ( + drivers_backlight( ( (tmp_state & BACKLIGHT_ON) ^ ((timer & 14) == 14) - ) ? BACKLIGHT_ON : BACKLIGHT_OFF ); + ) ? BACKLIGHT_ON : BACKLIGHT_OFF); } else { /* 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 */ - drivers_output (output_state); + drivers_output(output_state); /* 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 */ - drivers_cursor (s->cursor_x, s->cursor_y, s->cursor); + drivers_cursor(s->cursor_x, s->cursor_y, s->cursor); if (heartbeat != HEARTBEAT_OPEN) { tmp_state = heartbeat; @@ -133,19 +133,19 @@ render_screen (Screen * s, long int timer) drivers_heartbeat(tmp_state); /* If there is an server message that is not expired, display it */ - if( server_msg_expire > 0 ) { - drivers_string( display_props->width - strlen(server_msg_text) + 1, - display_props->height, server_msg_text ); + if (server_msg_expire > 0) { + drivers_string(display_props->width - strlen(server_msg_text) + 1, + display_props->height, server_msg_text); server_msg_expire --; - if( server_msg_expire == 0 ) { - free( server_msg_text ); + if (server_msg_expire == 0) { + free(server_msg_text); } } /* flush display out, frame and all... */ - drivers_flush (); + drivers_flush(); - debug(RPT_DEBUG, "==== END RENDERING ====" ); + debug(RPT_DEBUG, "==== END RENDERING ===="); 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... */ /* */ static int -render_frame (LinkedList * list, +render_frame(LinkedList *list, char fscroll, /* direction of scrolling */ int left, /* left edge of frame */ int top, /* top edge of frame */ @@ -177,10 +177,10 @@ render_frame (LinkedList * list, int str_length = BUFSIZE-1; int reset = 1; - debug( RPT_DEBUG, "%s( list=%p, fscroll='%c', left=%d, top=%d, " - "right=%d, bottom=%d, fwid=%d, fhgt=%d, fspeed=%d, timer=%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)", __FUNCTION__, list, fscroll, left,top, right, bottom, - fwid, fhgt, fspeed, timer ); + fwid, fhgt, fspeed, timer); /* return on no data or illegal height */ if (!list || (fhgt <= 0)) @@ -203,12 +203,12 @@ render_frame (LinkedList * list, } /* reset widget list */ - LL_Rewind (list); + LL_Rewind(list); /* loop over all widgets */ do { char str[BUFSIZE]; /* scratch buffer */ - Widget *w = (Widget *) LL_Get (list); + Widget *w = (Widget *) LL_Get(list); if (!w) return -1; @@ -220,9 +220,9 @@ render_frame (LinkedList * list, (w->y <= vis_height + fy) && (w->y > fy)) { w->x = min(w->x, vis_width); 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; - drivers_string (w->x + left, w->y + top - fy, str); + drivers_string(w->x + left, w->y + top - fy, str); } break; case WID_HBAR: @@ -233,17 +233,17 @@ render_frame (LinkedList * list, (w->y <= vis_height + fy) && (w->y > fy)) { if (w->length > 0) { 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 */ int full_len = display_props->width - w->x - left + 1; - 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); + 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); } 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 */ - 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); + 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); } } else if (w->length < 0) { /* 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 */ int full_len = display_props->height; 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) { /* TODO: Rearrange stuff to get down-extending * vbars to draw correctly... @@ -274,7 +274,7 @@ render_frame (LinkedList * list, } break; case WID_ICON: - drivers_icon (w->x, w->y, w->length); + drivers_icon(w->x, w->y, w->length); break; case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/ @@ -283,13 +283,13 @@ render_frame (LinkedList * list, if (vis_width < 8) break; - 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, 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); if (length <= vis_width - 6) { - strncpy (str, w->text, length); + strncpy(str, w->text, length); str[length] = 0; x = length + 5; } else /* Scroll the title, if it doesn't fit...*/ @@ -307,15 +307,15 @@ render_frame (LinkedList * list, x = (length - (vis_width - 6)) - x; str_length = abs(vis_width - 6); 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; 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++) { - 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; @@ -336,10 +336,10 @@ render_frame (LinkedList * list, * last letter in the string... (1-off error?) */ case 'm': // Marquee - length = strlen (w->text); + length = strlen(w->text); if (length <= screen_width) { /* 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 { int necessaryTimeUnits = 0; @@ -355,11 +355,11 @@ render_frame (LinkedList * list, if (offset <= length) { 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 (room > 0) { - strncat (str, w->text, room); + strncat(str, w->text, room); } str[screen_width] = '\0'; @@ -368,14 +368,14 @@ render_frame (LinkedList * list, } else { str[0] = '\0'; } - drivers_string (w->left, w->top, str); + drivers_string(w->left, w->top, str); } break; case 'h': - length = strlen (w->text) + 1; + length = strlen(w->text) + 1; if (length <= screen_width) { /* 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 { int effLength = length - screen_width; int necessaryTimeUnits = 0; @@ -405,13 +405,13 @@ render_frame (LinkedList * list, offset = 0; } if (offset <= length) { - strncpy (str, &((w->text)[offset]), screen_width); + strncpy(str, &((w->text)[offset]), screen_width); str[screen_width] = '\0'; /*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset); */ } else { str[0] = '\0'; } - drivers_string (w->left, w->top, str); + drivers_string(w->left, w->top, str); } break; /* FIXME: Vert scrollers don't always seem to scroll */ @@ -421,10 +421,10 @@ render_frame (LinkedList * list, { int i = 0; - length = strlen (w->text); + length = strlen(w->text); if (length <= screen_width) { /* no scrolling required... */ - drivers_string (w->left, w->top, w->text); + drivers_string(w->left, w->top, w->text); } else { int lines_required = (length / screen_width) + (length % screen_width ? 1 : 0); @@ -433,7 +433,7 @@ render_frame (LinkedList * list, if (lines_required <= available_lines) { /* easy...*/ 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'; 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); */ 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'; /*debug(RPT_DEBUG, "rendering: '%s' of %s", */ /*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); 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; case WID_NUM: /* FIXME: doesn't work in frames...*/ @@ -503,37 +503,37 @@ render_frame (LinkedList * list, if (reset) { reset = 0; } - drivers_num (w->x + left, w->y); + drivers_num(w->x + left, w->y); } break; case WID_NONE: default: break; } - } while (LL_Next (list) == 0); + } while (LL_Next(list) == 0); return 0; } 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; } /* Still a message active ? */ - if( server_msg_expire > 0 ) { - free( server_msg_text ); + if (server_msg_expire > 0) { + free(server_msg_text); } /* Store new message */ - server_msg_text = malloc( strlen(text) + 3 ); - strcpy( server_msg_text, "| " ); - strcat( server_msg_text, text ); + server_msg_text = malloc(strlen(text) + 3); + strcpy(server_msg_text, "| "); + strcat(server_msg_text, text); server_msg_expire = expire; diff --git a/server/render.h b/server/render.h index 901ed5b..505e0ea 100644 --- a/server/render.h +++ b/server/render.h @@ -34,10 +34,10 @@ extern int heartbeat; extern int backlight; extern int output_state; -int render_screen (Screen * s, long int timer); +int render_screen(Screen *s, long int timer); /* 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 * than 16 chars. */ diff --git a/server/screen.c b/server/screen.c index aac403e..e8e036b 100644 --- a/server/screen.c +++ b/server/screen.c @@ -43,19 +43,19 @@ char *pri_names[] = { }; Screen * -screen_create (char * id, Client * client) +screen_create(char *id, Client *client) { 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) { report(RPT_ERR, "%s: Error allocating", __FUNCTION__); return NULL; } if (!id) { - report (RPT_ERR, "%s: Need id string", __FUNCTION__); + report(RPT_ERR, "%s: Need id string", __FUNCTION__); return NULL; } /* 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_y = 1; - s->widgetlist = LL_new (); + s->widgetlist = LL_new(); if (!s->widgetlist) { report(RPT_ERR, "%s: Error allocating", __FUNCTION__); return NULL; } - menuscreen_add_screen (s); + menuscreen_add_screen(s); return s; } int -screen_destroy (Screen * s) +screen_destroy(Screen *s) { 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...*/ - widget_destroy (w); + widget_destroy(w); } - LL_Destroy (s->widgetlist); + LL_Destroy(s->widgetlist); if (s->id) - free (s->id); + free(s->id); if (s->name) - free (s->name); + free(s->name); - free (s); + free(s); return 0; } 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; } 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; } Widget * -screen_find_widget (Screen * s, char *id) +screen_find_widget(Screen *s, char *id) { - Widget * w; + Widget *w; if (!s) return NULL; if (!id) 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) ) { - if (0 == strcmp (w->id, id)) { - debug (RPT_DEBUG, "%s: Found %s", __FUNCTION__, id); + for (w = LL_GetFirst(s->widgetlist); w; w = LL_GetNext(s->widgetlist)) { + if (0 == strcmp(w->id, id)) { + debug(RPT_DEBUG, "%s: Found %s", __FUNCTION__, id); return w; } /* Search subscreens recursively */ if (w->type == WID_FRAME) { - w = widget_search_subs (w, id); + w = widget_search_subs(w, id); if (w) return w; } } - debug (RPT_DEBUG, "%s: Not found", __FUNCTION__); + debug(RPT_DEBUG, "%s: Not found", __FUNCTION__); return NULL; } Priority -screen_pri_name_to_pri (char * priname) +screen_pri_name_to_pri(char *priname) { Priority pri = WID_NONE; int i; for (i = 0; pri_names[i]; i++) { - if (strcmp (pri_names[i], priname) == 0) { + if (strcmp(pri_names[i], priname) == 0) { pri = i; break; /* it's valid: skip out...*/ } @@ -185,7 +185,7 @@ screen_pri_name_to_pri (char * priname) } char * -screen_pri_to_pri_name (Priority pri) +screen_pri_to_pri_name(Priority pri) { return pri_names[pri]; } diff --git a/server/screen.h b/server/screen.h index 8fef2c9..bf4ed0d 100644 --- a/server/screen.h +++ b/server/screen.h @@ -51,26 +51,26 @@ extern int default_priority ; #include "client.h" /* Creates a new screen */ -Screen * screen_create (char * id, Client * client); +Screen *screen_create(char *id, Client *client); /* Destroys a screen */ -int screen_destroy (Screen * s); +int screen_destroy(Screen *s); /* 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) */ -int screen_remove_widget (Screen * s, Widget * w); +int screen_remove_widget(Screen *s, Widget *w); /* List functions */ -static inline Widget * screen_getfirst_widget (Screen * s) +static inline Widget *screen_getfirst_widget(Screen *s) { return (Widget *) ((s != NULL) ? LL_GetFirst(s->widgetlist) : NULL); } -static inline Widget * screen_getnext_widget (Screen * s) +static inline Widget *screen_getnext_widget(Screen *s) { return (Widget *) ((s != NULL) ? LL_GetNext(s->widgetlist) @@ -79,10 +79,10 @@ static inline Widget * screen_getnext_widget (Screen * s) /* 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 */ -Priority screen_pri_name_to_pri (char * pri_name); -char * screen_pri_to_pri_name (Priority pri); +Priority screen_pri_name_to_pri(char *pri_name); +char *screen_pri_to_pri_name(Priority pri); #endif diff --git a/server/screenlist.c b/server/screenlist.c index c117e99..800234e 100644 --- a/server/screenlist.c +++ b/server/screenlist.c @@ -26,20 +26,20 @@ #include "main.h" /* for timer */ /* 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 */ LinkedList *screenlist = NULL; -Screen * current_screen = NULL; +Screen *current_screen = NULL; long int current_screen_start_time = 0; int -screenlist_init () +screenlist_init(void) { - report (RPT_DEBUG, "%s()", __FUNCTION__); + report(RPT_DEBUG, "%s()", __FUNCTION__); - screenlist = LL_new (); + screenlist = LL_new(); if (!screenlist) { report(RPT_ERR, "%s: Error allocating", __FUNCTION__); return -1; @@ -49,71 +49,71 @@ screenlist_init () 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 */ return -1; } - LL_Destroy (screenlist); + LL_Destroy(screenlist); return 0; } int -screenlist_add (Screen * s) +screenlist_add(Screen *s) { if (!screenlist) return -1; - return LL_Push (screenlist, s); + return LL_Push(screenlist, s); } 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) return -1; /* Are we trying to remove the current screen ? */ if (s == current_screen) { - screenlist_goto_next (); + screenlist_goto_next(); if (s == current_screen) { /* Hmm, no other screen had same priority */ - void * res = LL_Remove (screenlist, s); + void *res = LL_Remove(screenlist, s); /* And now once more */ - screenlist_goto_next (); + screenlist_goto_next(); return (res == NULL) ? -1 : 0; } } - return (LL_Remove (screenlist, s) == NULL) ? -1 : 0; + return (LL_Remove(screenlist, s) == NULL) ? -1 : 0; } void -screenlist_process () +screenlist_process(void) { - Screen * s; - Screen * f; + Screen *s; + Screen *f; - report (RPT_DEBUG, "%s()", __FUNCTION__); + report(RPT_DEBUG, "%s()", __FUNCTION__); if (!screenlist) return; /* Sort the list acfording to priority class */ - LL_Sort (screenlist, compare_priority); + LL_Sort(screenlist, compare_priority); f = LL_GetFirst(screenlist); /**** First we need to check out the current situation. ****/ /* Check whether there is an active screen */ - s = screenlist_current (); + s = screenlist_current(); if (!s) { /* We have no active screen yet. * Try to switch to the first screen in the list... */ @@ -123,7 +123,7 @@ screenlist_process () /* There was no screen in the list */ return; } - screenlist_switch (s); + screenlist_switch(s); return; } else { @@ -137,8 +137,8 @@ screenlist_process () if (s->timeout <= 0) { /* Expired, we can destroy it */ report(RPT_DEBUG, "Removing expired screen [%.40s]", s->id); - client_remove_screen (s->client, s); - screen_destroy (s); + client_remove_screen(s->client, s); + screen_destroy(s); } } } @@ -165,14 +165,14 @@ screenlist_process () void -screenlist_switch (Screen * s) +screenlist_switch(Screen *s) { - Client * c; + Client *c; char str[256]; 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) { /* Nothing to be done */ @@ -183,8 +183,8 @@ screenlist_switch (Screen * s) c = current_screen->client; if (c) { /* Tell the client we're not listening any more...*/ - snprintf (str, sizeof(str), "ignore %s\n", current_screen->id); - sock_send_string (c->sock, str); + snprintf(str, sizeof(str), "ignore %s\n", current_screen->id); + sock_send_string(c->sock, str); } else { /* It's a server screen, no need to inform it. */ } @@ -192,82 +192,82 @@ screenlist_switch (Screen * s) c = s->client; if (c) { /* Tell the client we're paying attention...*/ - snprintf (str, sizeof(str), "listen %s\n", s->id); - sock_send_string (c->sock, str); + snprintf(str, sizeof(str), "listen %s\n", s->id); + sock_send_string(c->sock, str); } else { /* 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_start_time = timer; } Screen * -screenlist_current () +screenlist_current(void) { return current_screen; } int -screenlist_goto_next () +screenlist_goto_next(void) { Screen *s; - debug (RPT_DEBUG, "%s()", __FUNCTION__); + debug(RPT_DEBUG, "%s()", __FUNCTION__); if (!current_screen) return -1; /* 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 */ 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 */ s = LL_GetFirst(screenlist); } - screenlist_switch (s); + screenlist_switch(s); return 0; } int -screenlist_goto_prev () +screenlist_goto_prev(void) { Screen *s; - debug (RPT_DEBUG, "%s()", __FUNCTION__); + debug(RPT_DEBUG, "%s()", __FUNCTION__); if (!current_screen) return -1; /* 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 */ s = LL_GetPrev(screenlist); - if( !s ) { + if (!s) { /* We're at the start of the screenlist. We should find the * last screen with the same priority as the first screen. */ - Screen * f = LL_GetFirst(screenlist); - Screen * n; + Screen *f = LL_GetFirst(screenlist); + Screen *n; s = f; - while( (n = LL_GetNext(screenlist)) && n->priority == f->priority ) { + while ((n = LL_GetNext(screenlist)) && n->priority == f->priority) { s = n; } } - screenlist_switch (s); + screenlist_switch(s); return 0; } /* Internal function for sorting. */ int -compare_priority (void *one, void *two) +compare_priority(void *one, void *two) { Screen *a, *b; diff --git a/server/screenlist.h b/server/screenlist.h index 4f88386..73a2c7d 100644 --- a/server/screenlist.h +++ b/server/screenlist.h @@ -25,33 +25,33 @@ /*extern int screenlist_action;*/ extern bool autorotate; -int screenlist_init (); +int screenlist_init(void); /* Initializes the screenlist. */ -int screenlist_shutdown (); +int screenlist_shutdown(void); /* Shuts down the screenlist. */ -int screenlist_add (Screen * s); +int screenlist_add(Screen *s); /* Adds a screen to the screenlist. */ -int screenlist_remove (Screen * s); +int screenlist_remove(Screen *s); /* 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 * screen. */ -void screenlist_switch (Screen * s); +void screenlist_switch(Screen *s); /* Switches to an other screen in the proper way. Informs clients of * the switch. ALWAYS USE THIS FUNCTION TO SWITCH SCREENS. */ -Screen *screenlist_current (); +Screen *screenlist_current(void); /* Returns the currently active screen. */ -int screenlist_goto_next (); +int screenlist_goto_next(void); /* Moves on to the next screen. */ -int screenlist_goto_prev (); +int screenlist_goto_prev(void); /* Moves on to the previous screen. */ #endif diff --git a/server/serverscreens.c b/server/serverscreens.c index 58884fb..ad722c9 100644 --- a/server/serverscreens.c +++ b/server/serverscreens.c @@ -35,79 +35,82 @@ #define UNSET_INT -1 -Screen * server_screen; -int rotate_server_screen = UNSET_INT; - #define MAX_SERVERSCREEN_WIDTH 40 + +Screen *server_screen; +int rotate_server_screen = UNSET_INT; + + int -server_screen_init () +server_screen_init(void) { - Widget * w; + Widget *w; int line; - debug (RPT_DEBUG, "server_screen_init"); + debug(RPT_DEBUG, "server_screen_init"); /* Create the screen */ - server_screen = screen_create ("_server_screen", NULL); + server_screen = screen_create("_server_screen", NULL); if (!server_screen) { - report (RPT_ERR, "server_screen_init: Error allocating screen"); + report(RPT_ERR, "server_screen_init: Error allocating screen"); return -1; } server_screen->name = "Server screen"; 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; } else { server_screen->priority = PRI_BACKGROUND; } /* Create all the widgets...*/ - for (line=1; line<=4; line++) { + for (line = 1; line <= 4; line++) { 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) { - report (RPT_ERR, "server_screen_init: Can't create a widget"); + report(RPT_ERR, "server_screen_init: Can't create a widget"); return -1; } - screen_add_widget (server_screen, w); + screen_add_widget(server_screen, w); w->x = 1; w->y = line; - w->text = malloc (MAX_SERVERSCREEN_WIDTH+1); + w->text = malloc(MAX_SERVERSCREEN_WIDTH+1); if (line == 1) { w->type = WID_TITLE; - strncpy (w->text, "LCDproc Server", MAX_SERVERSCREEN_WIDTH); + strncpy(w->text, "LCDproc Server", MAX_SERVERSCREEN_WIDTH); } else { - w->text[0] = 0; + w->text[0] = '\0'; } } /* 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; } int -server_screen_shutdown () +server_screen_shutdown(void) { - if (!server_screen) return -1; + if (!server_screen) + return -1; - screenlist_remove (server_screen); - screen_destroy (server_screen); + screenlist_remove(server_screen); + screen_destroy(server_screen); return 0; } int -update_server_screen () +update_server_screen(void) { - Client * c; - Widget * w; + Client *c; + Widget *w; int num_clients; int num_screens; @@ -116,33 +119,33 @@ update_server_screen () /* ... and screens */ 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); } /* Format strings for the appropriate size display... */ if (display_props->height >= 3) { - w = screen_find_widget (server_screen, "line2"); - snprintf (w->text, MAX_SERVERSCREEN_WIDTH, + w = screen_find_widget(server_screen, "line2"); + snprintf(w->text, MAX_SERVERSCREEN_WIDTH, "Clients: %i", num_clients); - w = screen_find_widget (server_screen, "line3"); - snprintf (w->text, MAX_SERVERSCREEN_WIDTH, + w = screen_find_widget(server_screen, "line3"); + snprintf(w->text, MAX_SERVERSCREEN_WIDTH, "Screens: %i", num_screens); } else { - w = screen_find_widget (server_screen, "line2"); - /*if (display_props->width >= 20)*/ - snprintf (w->text, MAX_SERVERSCREEN_WIDTH, - "Cli: %i Scr: %i", + w = screen_find_widget(server_screen, "line2"); + snprintf(w->text, MAX_SERVERSCREEN_WIDTH, + ((display_props->width >= 16) + ? "Cli: %i Scr: %i" + : "C: %i S: %i"), num_clients, num_screens); - /*else * 16x2 size */ } return 0; } int -goodbye_screen() +goodbye_screen(void) { - if(!display_props) + if (!display_props) return 0; drivers_clear(); diff --git a/server/serverscreens.h b/server/serverscreens.h index 99a7398..6258a26 100644 --- a/server/serverscreens.h +++ b/server/serverscreens.h @@ -14,13 +14,13 @@ #include "screen.h" -extern Screen * server_screen; +extern Screen *server_screen; extern int rotate_server_screen; -int server_screen_init (); -int server_screen_shutdown (); -int update_server_screen (); -int goodbye_screen (); +int server_screen_init(void); +int server_screen_shutdown(void); +int update_server_screen(void); +int goodbye_screen(void); #endif diff --git a/server/sock.c b/server/sock.c index ee7db3a..47a15fd 100644 --- a/server/sock.c +++ b/server/sock.c @@ -83,7 +83,7 @@ sock_init(char* bind_addr, int bind_port) #ifdef WINSOCK2 /* Initialize the Winsock dll */ WSADATA wsaData; - int startup = WSAStartup( MAKEWORD(2, 2), &wsaData ); + int startup = WSAStartup(MAKEWORD(2, 2), &wsaData); if (startup != 0) { 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(); */ #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. */ - listening_fd = sock_create_inet_socket (bind_addr, bind_port); + listening_fd = sock_create_inet_socket(bind_addr, bind_port); if (listening_fd < 0) { - report (RPT_ERR, "%s: Error creating socket - %s", + report(RPT_ERR, "%s: Error creating socket - %s", __FUNCTION__, sock_geterror()); return -1; } @@ -158,11 +158,11 @@ This code gets the send and receive buffer sizes. int -sock_shutdown () +sock_shutdown(void) { int retVal = 0; - debug( RPT_DEBUG, "%s()", __FUNCTION__ ); + debug(RPT_DEBUG, "%s()", __FUNCTION__); /*struct ClientSocketMap* clientIt;*/ @@ -183,7 +183,7 @@ sock_shutdown () } LL_Destroy(openSocketList); */ - close( listening_fd ); + close(listening_fd); LL_Destroy(freeClientSocketList); free(freeClientSocketPool); @@ -203,15 +203,15 @@ sock_shutdown () /****************************************************************************/ /* Creates a socket in internet space */ int -sock_create_inet_socket (char * addr, unsigned int port) +sock_create_inet_socket(char *addr, unsigned int port) { struct sockaddr_in name; 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. */ - sock = socket (PF_INET, SOCK_STREAM, 0); + sock = socket(PF_INET, SOCK_STREAM, 0); #ifdef WINSOCK2 if (sock == INVALID_SOCKET) #else @@ -230,9 +230,9 @@ sock_create_inet_socket (char * addr, unsigned int port) } /* Give the socket a name. */ - memset (&name, 0, sizeof (name)); + memset(&name, 0, sizeof(name)); name.sin_family = AF_INET; - name.sin_port = htons (port); + name.sin_port = htons(port); #ifndef WINSOCK2 /* REVISIT: can probably use the same code as under winsock */ 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); #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", __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); } - if (listen (sock, 1) < 0) { + if (listen(sock, 1) < 0) { report(RPT_ERR, "%s: error in attempting to listen to port " "%d at %s - %s", __FUNCTION__, port, addr, sock_geterror()); @@ -257,8 +257,8 @@ sock_create_inet_socket (char * addr, unsigned int port) } /* Initialize the set of active sockets. */ - FD_ZERO (&active_fd_set); - FD_SET (sock, &active_fd_set); + FD_ZERO(&active_fd_set); + FD_SET(sock, &active_fd_set); return sock; } @@ -266,14 +266,14 @@ sock_create_inet_socket (char * addr, unsigned int port) /* Service all clients with input pending...*/ int -sock_poll_clients () +sock_poll_clients(void) { int err; struct sockaddr_in clientname; struct timeval t; struct ClientSocketMap* clientSocket; - debug (RPT_DEBUG, "%s()", __FUNCTION__); + debug(RPT_DEBUG, "%s()", __FUNCTION__); t.tv_sec = 0; t.tv_usec = 0; @@ -281,7 +281,7 @@ sock_poll_clients () /* Block until input arrives on one or more active sockets. */ 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", __FUNCTION__, sock_geterror()); return -1; @@ -301,7 +301,7 @@ sock_poll_clients () Client* c; int new_sock; 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 if (new_sock == INVALID_SOCKET) #else @@ -312,9 +312,9 @@ sock_poll_clients () __FUNCTION__, sock_geterror()); return -1; } - report (RPT_NOTICE, "Connect from host %s:%hu on socket %i", - inet_ntoa (clientname.sin_addr), ntohs (clientname.sin_port), new_sock); - FD_SET (new_sock, &active_fd_set); + report(RPT_NOTICE, "Connect from host %s:%hu on socket %i", + inet_ntoa(clientname.sin_addr), ntohs(clientname.sin_port), new_sock); + FD_SET(new_sock, &active_fd_set); #ifdef WINSOCK2 { @@ -326,8 +326,8 @@ sock_poll_clients () #endif /* Create new client */ - if ((c = client_create (new_sock)) == NULL) { - report( RPT_ERR, "%s: Error creating client on socket %i - %s", + if ((c = client_create(new_sock)) == NULL) { + report(RPT_ERR, "%s: Error creating client on socket %i - %s", __FUNCTION__, clientSocket->socket, sock_geterror()); return -1; } else { @@ -347,17 +347,17 @@ sock_poll_clients () return -1; } } - if (clients_add_client (c) != 0) { - report( RPT_ERR, "%s: Could not add client on socket %i", __FUNCTION__, clientSocket->socket); + if (clients_add_client(c) != 0) { + report(RPT_ERR, "%s: Could not add client on socket %i", __FUNCTION__, clientSocket->socket); return -1; } } else { /* Data arriving on an already-connected socket. */ err = 0; do { - debug (RPT_DEBUG, "%s: reading...", __FUNCTION__); + debug(RPT_DEBUG, "%s: reading...", __FUNCTION__); err = sock_read_from_client(clientSocket); - debug (RPT_DEBUG, "%s: ...done", __FUNCTION__); + debug(RPT_DEBUG, "%s: ...done", __FUNCTION__); if (err < 0) { /* Client disconnected, destroy client data */ @@ -367,7 +367,7 @@ sock_poll_clients () struct ClientSocketMap* entry; /*sock_send_string(i, "bye\n");*/ - report (RPT_NOTICE, "Client on socket %i disconnected", + report(RPT_NOTICE, "Client on socket %i disconnected", clientSocket->socket); client_destroy(clientSocket->client); clients_remove_client(clientSocket->client); @@ -377,7 +377,7 @@ sock_poll_clients () entry = (struct ClientSocketMap*) LL_DeleteNode(openSocketList); LL_Push(freeClientSocketList, (void*) entry); } 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); } } @@ -394,7 +394,7 @@ sock_read_from_client(struct ClientSocketMap* clientSocketMap) char buffer[MAXMSG]; int nbytes, i; - debug (RPT_DEBUG, "%s()", __FUNCTION__); + debug(RPT_DEBUG, "%s()", __FUNCTION__); errno = 0; nbytes = sock_recv(clientSocketMap->socket, buffer, MAXMSG); @@ -419,7 +419,7 @@ sock_read_from_client(struct ClientSocketMap* clientSocketMap) if (buffer[i] == 0) buffer[i] = '\n'; /* 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) { client_add_message(clientSocketMap->client, buffer); } else { diff --git a/server/sock.h b/server/sock.h index 1d1f703..eeef28a 100644 --- a/server/sock.h +++ b/server/sock.h @@ -19,9 +19,9 @@ typedef struct sockaddr_in sockaddr_in; /* Server functions...*/ 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_poll_clients(); +int sock_poll_clients(void); int verify_ipv4(const char *addr); int verify_ipv6(const char *addr); diff --git a/server/widget.c b/server/widget.c index 21323ea..d956b29 100644 --- a/server/widget.c +++ b/server/widget.c @@ -69,22 +69,22 @@ struct icontable { 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 */ - w = malloc (sizeof (Widget)); + w = malloc(sizeof(Widget)); if (!w) { - report (RPT_DEBUG, "%s: Error allocating", __FUNCTION__); + report(RPT_DEBUG, "%s: Error allocating", __FUNCTION__); return NULL; } w->id = strdup(id); if (!w->id) { - report (RPT_DEBUG, "%s: Error allocating", __FUNCTION__); + report(RPT_DEBUG, "%s: Error allocating", __FUNCTION__); return NULL; } @@ -105,49 +105,49 @@ widget_create (char *id, WidgetType type, Screen * screen) if (w->type == WID_FRAME) { /* create a screen for the frame widget */ - char * frame_name; - frame_name = malloc (strlen("frame_") + strlen(id) + 1); - strcpy (frame_name, "frame_"); - strcat (frame_name, id); + char *frame_name; + frame_name = malloc(strlen("frame_") + strlen(id) + 1); + strcpy(frame_name, "frame_"); + 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; } 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) return -1; if (w->id) - free (w->id); + free(w->id); if (w->text) - free (w->text); + free(w->text); /* Free subscreen of frame widget too */ if (w->type == WID_FRAME) { - screen_destroy (w->frame_screen); + screen_destroy(w->frame_screen); } - free (w); + free(w); return 0; } WidgetType -widget_typename_to_type (char * typename) +widget_typename_to_type(char *typename) { WidgetType wid_type = WID_NONE; int i; for (i = 0; typenames[i]; i++) { - if (strcmp (typenames[i], typename) == 0) { + if (strcmp(typenames[i], typename) == 0) { wid_type = i; break; /* it's valid: skip out...*/ } @@ -156,26 +156,26 @@ widget_typename_to_type (char * typename) } char * -widget_type_to_typename (WidgetType t) +widget_type_to_typename(WidgetType t) { return typenames[t]; } Widget * -widget_search_subs (Widget * w, char * id) +widget_search_subs(Widget *w, char *id) { if (w->type == WID_FRAME) { - return screen_find_widget (w->frame_screen, id); + return screen_find_widget(w->frame_screen, id); } else { return NULL; /* no kids */ } } -char *widget_icon_to_iconname (int icon) +char *widget_icon_to_iconname(int icon) { int i; - for (i=0; icontable[i].iconname; i++) { + for (i = 0; icontable[i].iconname; i++) { if (icontable[i].icon == icon) { return icontable[i].iconname; } @@ -184,12 +184,12 @@ char *widget_icon_to_iconname (int icon) return NULL; } -int widget_iconname_to_icon (char *iconname) +int widget_iconname_to_icon(char *iconname) { int i; - for (i=0; icontable[i].iconname; i++) { - if (strcasecmp( icontable[i].iconname, iconname) == 0) { + for (i = 0; icontable[i].iconname; i++) { + if (strcasecmp(icontable[i].iconname, iconname) == 0) { return icontable[i].icon; } } diff --git a/server/widget.h b/server/widget.h index fc95da0..de8df60 100644 --- a/server/widget.h +++ b/server/widget.h @@ -33,38 +33,38 @@ typedef enum WidgetType { typedef struct Widget { char *id; WidgetType type; - Screen * screen; /* What screen is this widget in ? */ + Screen *screen; /* What screen is this widget in ? */ int x, y; /* Position */ int width, height; /* Visible size */ int left, top, right, bottom; /* bounding rectangle */ int length; /* size or direction */ int speed; /* For scroller... */ 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...*/ } Widget; #define WID_MAX_DIR 4 /* Create new widget */ -Widget * widget_create (char *id, WidgetType type, Screen * screen); +Widget *widget_create(char *id, WidgetType type, Screen *screen); /* Destroy a widget */ -int widget_destroy (Widget * w); +int widget_destroy(Widget *w); /* 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 */ -char *widget_type_to_typename (WidgetType t); +char *widget_type_to_typename(WidgetType t); /* 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 */ -char *widget_icon_to_iconname (int icon); +char *widget_icon_to_iconname(int icon); /* Convert iconname to icon number */ -int widget_iconname_to_icon (char *iconname); +int widget_iconname_to_icon(char *iconname); #endif