* coding style harmonization in servers/

- explicitely declare void arguments
  - make a few string args const
* better support for shorter displays in server screen
* make target to create top level tag file
This commit is contained in:
marschap
2007-04-02 21:29:53 +00:00
parent a63ae89eb7
commit 6a1511bb72
100 changed files with 2180 additions and 2170 deletions
+115 -115
View File
@@ -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;
}
}