make get_key() result const char *, so that it is not modified

This commit is contained in:
marschap
2006-04-06 13:25:14 +00:00
parent bc01f2e012
commit 743871cff3
36 changed files with 76 additions and 77 deletions
+2 -2
View File
@@ -348,12 +348,12 @@ drivers_output( int state )
}
char *
const char *
drivers_get_key()
{
/* Find the first input keystroke, if any */
Driver *drv;
char * keystroke;
const char * keystroke;
debug( RPT_DEBUG, "%s()", __FUNCTION__ );
+1 -1
View File
@@ -98,7 +98,7 @@ drivers_backlight( int brightness );
void
drivers_output( int state );
char *
const char *
drivers_get_key();
extern LinkedList * loaded_drivers;
+1 -1
View File
@@ -439,7 +439,7 @@ CFontz633_flush (Driver *drvthis)
/*
* Return one char from the KeyRing
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
CFontz633_get_key (Driver *drvthis)
{
// PrivateData *p = drvthis->private_data;
+1 -1
View File
@@ -29,7 +29,7 @@ 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_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT char *CFontz633_get_key (Driver *drvthis);
MODULE_EXPORT const char *CFontz633_get_key (Driver *drvthis);
MODULE_EXPORT void CFontz633_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void CFontz633_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+1 -1
View File
@@ -581,7 +581,7 @@ CFontzPacket_flush (Driver *drvthis)
/*
* Return one char from the KeyRing
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
CFontzPacket_get_key (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
+1 -1
View File
@@ -29,7 +29,7 @@ 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_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT char *CFontzPacket_get_key (Driver *drvthis);
MODULE_EXPORT const char *CFontzPacket_get_key (Driver *drvthis);
MODULE_EXPORT void CFontzPacket_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void CFontzPacket_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+1 -1
View File
@@ -1468,7 +1468,7 @@ CwLnx_string(Driver * drvthis, int x, int y, char *string)
/*********************************************************
* API: Get a key translated into a string.
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
CwLnx_get_key(Driver * drvthis)
{
PrivateData * p = drvthis->private_data;
+1 -1
View File
@@ -1241,7 +1241,7 @@ MtxOrb_icon (Driver *drvthis, int x, int y, int icon)
/*
* Return one char from the KeyRing
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
MtxOrb_get_key (Driver *drvthis)
{
char in = 0;
+1 -1
View File
@@ -19,7 +19,7 @@ MODULE_EXPORT void MtxOrb_set_contrast (Driver *drvthis, int promille);
MODULE_EXPORT void MtxOrb_backlight (Driver *drvthis, int on);
MODULE_EXPORT void MtxOrb_output (Driver *drvthis, int on);
MODULE_EXPORT char * MtxOrb_get_key (Driver *drvthis);
MODULE_EXPORT const char * MtxOrb_get_key (Driver *drvthis);
MODULE_EXPORT char * MtxOrb_get_info (Driver *drvthis);
MODULE_EXPORT void MtxOrb_num (Driver *drvthis, int x, int num);
+1 -1
View File
@@ -770,7 +770,7 @@ bayrad_icon(Driver * drvthis, int x, int y, int icon)
//
// Return 0 for "nothing available".
//
MODULE_EXPORT char *
MODULE_EXPORT const char *
bayrad_get_key(Driver * drvthis)
{
fd_set brfdset;
+1 -1
View File
@@ -27,7 +27,7 @@ MODULE_EXPORT void bayrad_set_char(Driver * drvthis, int n, char *dat);
MODULE_EXPORT void bayrad_backlight(Driver * drvthis, int promille);
MODULE_EXPORT char *bayrad_get_key(Driver * drvthis);
MODULE_EXPORT const char *bayrad_get_key(Driver * drvthis);
MODULE_EXPORT void bayrad_init_vbar(Driver * drvthis);
MODULE_EXPORT void bayrad_init_hbar(Driver * drvthis);
+1 -1
View File
@@ -585,7 +585,7 @@ curses_drv_flush (Driver *drvthis)
}
MODULE_EXPORT char *
MODULE_EXPORT const char *
curses_drv_get_key (Driver *drvthis)
{
static char ret_val[2] = {0,0};
+1 -1
View File
@@ -20,7 +20,7 @@ MODULE_EXPORT int curses_drv_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void curses_drv_backlight (Driver *drvthis, int on);
MODULE_EXPORT char *curses_drv_get_key (Driver *drvthis);
MODULE_EXPORT const char *curses_drv_get_key (Driver *drvthis);
MODULE_EXPORT void curses_drv_init_num (Driver *drvthis);
+1 -1
View File
@@ -247,7 +247,7 @@ debug_icon (Driver *drvthis, int x, int y, int icon)
/////////////////////////////////////////////////////////////////
// Return a keypress
//
MODULE_EXPORT char *
MODULE_EXPORT const char *
debug_get_key (Driver *drvthis)
{
report (RPT_INFO, "get_key()");
+1 -1
View File
@@ -22,7 +22,7 @@ MODULE_EXPORT void debug_set_char (Driver *drvthis, int n, char *dat);
MODULE_EXPORT void debug_set_contrast (Driver *drvthis, int promille);
MODULE_EXPORT void debug_backlight (Driver *drvthis, int promille);
MODULE_EXPORT char *debug_get_key (Driver *drvthis);
MODULE_EXPORT const char *debug_get_key (Driver *drvthis);
MODULE_EXPORT void debug_init_vbar (Driver *drvthis);
MODULE_EXPORT void debug_init_hbar (Driver *drvthis);
+1 -1
View File
@@ -1110,7 +1110,7 @@ HD44780_icon (Driver *drvthis, int x, int y, int icon)
/////////////////////////////////////////////////////////////
// Get a key from the keypad (if there is one)
//
MODULE_EXPORT char *
MODULE_EXPORT const char *
HD44780_get_key(Driver *drvthis)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
+1 -1
View File
@@ -37,7 +37,7 @@ MODULE_EXPORT void HD44780_set_char (Driver *drvthis, int n, char *dat);
MODULE_EXPORT void HD44780_backlight (Driver *drvthis, int on);
MODULE_EXPORT void HD44780_output (Driver *drvthis, int state);
MODULE_EXPORT char * HD44780_get_key (Driver *drvthis);
MODULE_EXPORT const char * HD44780_get_key (Driver *drvthis);
static void HD44780_init_vbar (Driver *drvthis);
static void HD44780_init_hbar (Driver *drvthis);
+2 -2
View File
@@ -129,7 +129,7 @@ irmanin_init (Driver *drvthis)
return 1; // return success
}
void
MODULE_EXPORT void
irmanin_close (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -147,7 +147,7 @@ irmanin_close (Driver *drvthis)
//
// Return NULL for "nothing available".
//
char *
MODULE_EXPORT const char *
irmanin_get_key (Driver *drvthis)
{
int cmd;
+1 -1
View File
@@ -14,6 +14,6 @@ typedef struct driver_private_data {
MODULE_EXPORT int irmanin_init (Driver *drvthis);
MODULE_EXPORT void irmanin_close (Driver *drvthis);
MODULE_EXPORT char *irmanin_get_key (Driver *drvthis);
MODULE_EXPORT const char *irmanin_get_key (Driver *drvthis);
#endif
+1 -1
View File
@@ -161,7 +161,7 @@ typedef struct lcd_logical_driver {
void (*output) (struct lcd_logical_driver* drvthis, int state);
/* Key functions */
char *(*get_key) (struct lcd_logical_driver* drvthis);
const char *(*get_key) (struct lcd_logical_driver* drvthis);
/* Returns a string. Server cannot modify
this string. */
+15 -15
View File
@@ -288,7 +288,6 @@ lcdm001_flush (Driver *drvthis)
MODULE_EXPORT void
lcdm001_chr (Driver *drvthis, int x, int y, char c)
{
char buf[64]; // char out[10];
int offset;
ValidX(x);
@@ -304,8 +303,7 @@ lcdm001_chr (Driver *drvthis, int x, int y, char c)
offset = (y * width) + x;
framebuf[offset] = c;
snprintf(buf, sizeof(buf), "LCDM001: writing character %02X to position (%d,%d)", c, x, y);
debug (RPT_DEBUG, buf);
debug (RPT_DEBUG, "LCDM001: writing character %02X to position (%d,%d)", c, x, y);
}
/////////////////////////////////////////////////////////////////
@@ -437,25 +435,27 @@ lcdm001_old_icon (Driver *drvthis, int which, char dest)
//////////////////////////////////////////////////////////////////////
// Tries to read a character from an input device...
//
// Return 0 for "nothing available".
// Return NULL for "nothing available".
//
/* TODO: write for net API function (get_key) that returns a string */
MODULE_EXPORT char
lcdm001_getkey (Driver *drvthis)
MODULE_EXPORT const char *
lcdm001_get_key (Driver *drvthis)
{
char in = 0;
char in = '\0';
const char *key = NULL;
read (fd, &in, 1);
if (in == pause_key) {
in='A';
key = "Escape";
} else if (in == back_key) {
in='B';
key = "Left";
} else if (in == forward_key) {
in='C';
key = "Right";
} else if (in == main_menu_key) {
in='D';
key = "Enter";
}
/*debug: if(in) fprintf(stderr,"key: %c",in); */
return in;
debug(RPT_DEBUG, "%s, get_key: %s",
drvthis->name, (key != NULL) ? key : "<null>");
return key;
}
+1 -1
View File
@@ -185,7 +185,7 @@ lircin_close (Driver *drvthis)
*
* Return NULL for "nothing available".
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
lircin_get_key (Driver *drvthis)
{
PrivateData * p = drvthis->private_data;
+1 -1
View File
@@ -23,7 +23,7 @@
MODULE_EXPORT int lircin_init (Driver *drvthis);
MODULE_EXPORT void lircin_close (Driver *drvthis);
MODULE_EXPORT char * lircin_get_key (Driver *drvthis);
MODULE_EXPORT const char * lircin_get_key (Driver *drvthis);
#define LIRCIN_VERBOSELY 0
+14 -15
View File
@@ -58,8 +58,6 @@ static struct timeval selectTimeout = { 0, 0 };
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int does_input = 1;
MODULE_EXPORT int does_output = 1;
MODULE_EXPORT char *symbol_prefix = "ms6931_";
@@ -422,49 +420,50 @@ ms6931_heartbeat (Driver *drvthis, int state)
// controls the keys
//
MODULE_EXPORT char
MODULE_EXPORT const char *
ms6931_get_key (Driver *drvthis)
{
int ret;
char buf;
const char *key = NULL;
if ((ret = select (FD_SETSIZE, &fdset, NULL, NULL, &selectTimeout)) < 0) {
if ((ret = select(FD_SETSIZE, &fdset, NULL, NULL, &selectTimeout)) < 0) {
report(RPT_DEBUG, "ms6931_getkey: select() failed (%s)", strerror(errno));
return 0;
return NULL;
}
if (!ret) {
FD_SET(fd, &fdset);
return 0;
return NULL;
}
if (!FD_ISSET(fd, &fdset))
return 0;
return NULL;
if ((ret = read(fd, &buf, 1)) < 0) {
report(RPT_DEBUG, "ms6931_getkey: read() failed (%s)", strerror(errno));
return 0;
return NULL;
}
if (ret == 1) {
switch (buf) {
case 'L':
buf = 'B';
key = "Escape";
break;
case 'M':
buf = 'A';
key = "Enter";
break;
case 'R':
buf = 'C';
key = "Down";
break;
default:
report(RPT_DEBUG, "ms6931_getkey: illegal key 0x%02x", (int)buf);
return 0;
return NULL;
}
report(RPT_DEBUG, "ms6931_getkey: returning %c", buf);
return buf;
report(RPT_DEBUG, "ms6931_getkey: returning %s", key);
return key;
}
return 0;
return NULL;
}
+1 -1
View File
@@ -46,7 +46,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 char ms6931_get_key (Driver *drvthis);
MODULE_EXPORT const char *ms6931_get_key (Driver *drvthis);
MODULE_EXPORT void ms6931_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern);
MODULE_EXPORT void ms6931_heartbeat (Driver *drvthis, int state);
+1 -1
View File
@@ -430,7 +430,7 @@ MODULE_EXPORT void pylcd_output (Driver *drvthis, int state)
/* Key functions */
MODULE_EXPORT char *pylcd_get_key (Driver *drvthis)
MODULE_EXPORT const char *pylcd_get_key (Driver *drvthis)
{
/* supports only one key at a time */
+1 -1
View File
@@ -958,7 +958,7 @@ sed1330_icon( Driver * drvthis, int x, int y, int icon )
/////////////////////////////////////////////////////////////
// Get a key from the keypad (if there is one)
//
MODULE_EXPORT char *
MODULE_EXPORT const char *
sed1330_get_key(Driver *drvthis)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
+1 -1
View File
@@ -25,6 +25,6 @@ MODULE_EXPORT void sed1330_heartbeat( Driver * drvthis, int type );
MODULE_EXPORT int sed1330_icon( Driver * drvthis, int x, int y, int icon);
MODULE_EXPORT void sed1330_backlight( Driver * drvthis, int on );
MODULE_EXPORT char * sed1330_get_key(Driver *drvthis);
MODULE_EXPORT const char * sed1330_get_key(Driver *drvthis);
#endif
+1 -1
View File
@@ -572,7 +572,7 @@ svgalib_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int patt
/**
* Return a keypress
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
svgalib_drv_get_key (Driver *drvthis)
{
static char buf[2] = " ";
+1 -1
View File
@@ -41,7 +41,7 @@ MODULE_EXPORT void svgalib_drv_vbar (Driver *drvthis, int x, int y, int len, int
MODULE_EXPORT void svgalib_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern);
MODULE_EXPORT void svgalib_drv_num (Driver *drvthis, int x, int num);
MODULE_EXPORT char * svgalib_drv_get_key (Driver *drvthis);
MODULE_EXPORT const char * svgalib_drv_get_key (Driver *drvthis);
MODULE_EXPORT int svgalib_drv_get_contrast (Driver *drvthis);
MODULE_EXPORT void svgalib_drv_set_contrast (Driver *drvthis, int promille);
+1 -1
View File
@@ -258,7 +258,7 @@ for (i=0; i<width; i++) {
/*
* Return one char from the KeyRing
*/
MODULE_EXPORT char *
MODULE_EXPORT const char *
tyan_lcdm_get_key (Driver *drvthis)
{
unsigned char akey;
+1 -1
View File
@@ -974,7 +974,7 @@ ula200_icon (Driver *drvthis, int x, int y, int icon)
///////////////////////////////////////////////////////////////////////////////
// Set default icon into a userdef char
//
MODULE_EXPORT char *
MODULE_EXPORT const char *
ula200_get_key (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
+8 -8
View File
@@ -41,8 +41,8 @@ char * scroll_down_key;
/* Local functions */
int server_input (int key);
void input_send_to_client (Client * c, char * key);
void input_internal_key (char * key);
void input_send_to_client (Client * c, const char * key);
void input_internal_key (const char * key);
int input_init()
@@ -84,7 +84,7 @@ int input_shutdown()
int
handle_input ()
{
char * key;
const char * key;
Screen * current_screen;
Client * current_client;
Client * target;
@@ -125,7 +125,7 @@ handle_input ()
}
void input_send_to_client (Client * c, char * key)
void input_send_to_client (Client * c, const char * key)
{
char * s;
@@ -140,7 +140,7 @@ void input_send_to_client (Client * c, char * key)
void
input_internal_key (char * key)
input_internal_key (const char * key)
{
if( is_menu_key(key) || screenlist_current() == menuscreen ) {
menuscreen_key_handler(key);
@@ -170,7 +170,7 @@ input_internal_key (char * key)
}
}
int input_reserve_key (char * key, bool exclusive, Client * client)
int input_reserve_key (const char * key, bool exclusive, Client * client)
{
KeyReservation * kr;
@@ -200,7 +200,7 @@ int input_reserve_key (char * key, bool exclusive, Client * client)
return 0;
}
void input_release_key (char * key, Client * client)
void input_release_key (const char * key, Client * client)
{
KeyReservation * kr;
@@ -238,7 +238,7 @@ void input_release_client_keys (Client * client)
}
}
KeyReservation * input_find_key (char * key, Client * client)
KeyReservation * input_find_key (const char * key, Client * client)
{
KeyReservation * kr;
+3 -3
View File
@@ -47,17 +47,17 @@ int input_init();
int input_shutdown();
/* Shut it down */
int input_reserve_key (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 (char * key, Client * client);
void input_release_key (const char * key, Client * client);
/* Releases a key reservation */
void input_release_client_keys (Client * client);
/* Releases all key reservations for a given client */
KeyReservation * input_find_key (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.
+2 -2
View File
@@ -184,7 +184,7 @@ void menuscreen_inform_item_modified (MenuItem * item)
}
}
bool is_menu_key (char * key)
bool is_menu_key (const char * key)
{
if (menu_key && key && strcmp (key, menu_key) == 0)
return true;
@@ -355,7 +355,7 @@ static void handle_successor()
}
}
void menuscreen_key_handler (char *key)
void menuscreen_key_handler (const char *key)
{
char token = 0;
MenuResult res;
+2 -2
View File
@@ -30,7 +30,7 @@ int menuscreens_shutdown();
/** This function indicates to the input part whether this key was the
* reserved menu key.
*/
bool is_menu_key (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.
@@ -44,7 +44,7 @@ void menuscreen_inform_item_modified (MenuItem * item);
/** This handler handles the keypresses for the menu.
*/
void menuscreen_key_handler (char *key);
void menuscreen_key_handler (const char *key);
/** Adds a menu for the given screen */
void menuscreen_add_screen (Screen * s);