explicitely declare void function argg and static functions
This commit is contained in:
@@ -29,9 +29,11 @@ short last_vc_cursor_x = 0;
|
|||||||
short last_lcd_cursor_x = 0;
|
short last_lcd_cursor_x = 0;
|
||||||
short last_lcd_cursor_y = 0;
|
short last_lcd_cursor_y = 0;
|
||||||
|
|
||||||
int read_connect_string();
|
static int read_connect_string(void);
|
||||||
|
static int split(char *str, char delim, char *parts[], int maxparts);
|
||||||
|
|
||||||
int connect_and_setup()
|
|
||||||
|
int connect_and_setup(void)
|
||||||
{
|
{
|
||||||
char buf[200];
|
char buf[200];
|
||||||
int i;
|
int i;
|
||||||
@@ -80,7 +82,8 @@ int connect_and_setup()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_connect_string()
|
|
||||||
|
static int read_connect_string(void)
|
||||||
{
|
{
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@@ -123,11 +126,44 @@ int read_connect_string()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int split(char *str, char delim, char *parts[], int maxparts)
|
||||||
|
/* Splits a string into parts, to which pointers will be returned in &parts.
|
||||||
|
* The return value is the number of parts.
|
||||||
|
* maxparts is the maximum number of parts returned. If more parts exist
|
||||||
|
* they are (unsplit) in the last part.
|
||||||
|
* The parts are split at the character delim.
|
||||||
|
* No new space will be allocated, the string str will be mutated !
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
char *p1 = str;
|
||||||
|
char *p2;
|
||||||
|
int part_nr = 0;
|
||||||
|
|
||||||
|
/* Find the delim char to end the current part */
|
||||||
|
while (part_nr < maxparts - 1 && (p2 = strchr(p1, delim))) {
|
||||||
|
|
||||||
|
/* subsequent parts... */
|
||||||
|
*p2 = 0;
|
||||||
|
parts[part_nr] = p1;
|
||||||
|
|
||||||
|
p1 = p2 + 1; /* Just after the delim char */
|
||||||
|
part_nr ++;
|
||||||
|
}
|
||||||
|
/* and the last part... */
|
||||||
|
parts[part_nr] = p1;
|
||||||
|
part_nr ++;
|
||||||
|
|
||||||
|
return part_nr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int read_response(char *buf, int maxsize)
|
int read_response(char *buf, int maxsize)
|
||||||
{
|
{
|
||||||
return sock_recv_string(sock, buf, maxsize);
|
return sock_recv_string(sock, buf, maxsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int process_response(char *str)
|
int process_response(char *str)
|
||||||
{
|
{
|
||||||
char *argv[10];
|
char *argv[10];
|
||||||
@@ -205,7 +241,8 @@ int process_response(char * str)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int update_display()
|
|
||||||
|
int update_display(void)
|
||||||
{
|
{
|
||||||
//int bytes_read;
|
//int bytes_read;
|
||||||
short line;
|
short line;
|
||||||
@@ -311,7 +348,8 @@ int update_display()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int send_nop()
|
|
||||||
|
int send_nop(void)
|
||||||
{
|
{
|
||||||
return sock_send_string(sock, "\n");
|
return sock_send_string(sock, "\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
extern char *address;
|
extern char *address;
|
||||||
extern int port;
|
extern int port;
|
||||||
|
|
||||||
int connect_and_setup();
|
int connect_and_setup(void);
|
||||||
int read_response(char *str, int maxsize);
|
int read_response(char *str, int maxsize);
|
||||||
int process_response(char *str);
|
int process_response(char *str);
|
||||||
int update_display();
|
int update_display(void);
|
||||||
int send_nop();
|
int send_nop(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+9
-38
@@ -62,12 +62,10 @@ char *vcs_device = UNSET_STR;
|
|||||||
char *keys[4];
|
char *keys[4];
|
||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
int process_command_line(int argc, char ** argv);
|
static int process_command_line(int argc, char **argv);
|
||||||
int process_configfile(char * configfile);
|
static int process_configfile(char *configfile);
|
||||||
int connect_and_setup();
|
static int main_loop(void);
|
||||||
int update_display();
|
|
||||||
int process_response(char * str);
|
|
||||||
int main_loop();
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -99,7 +97,8 @@ int main( int argc, char ** argv )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_command_line( int argc, char ** argv )
|
|
||||||
|
static int process_command_line(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@@ -166,7 +165,8 @@ int process_command_line( int argc, char ** argv )
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_configfile( char * configfile )
|
|
||||||
|
static int process_configfile(char *configfile)
|
||||||
{
|
{
|
||||||
if (strcmp(configfile, UNSET_STR) == 0) {
|
if (strcmp(configfile, UNSET_STR) == 0) {
|
||||||
configfile = DEFAULT_CONFIGFILE;
|
configfile = DEFAULT_CONFIGFILE;
|
||||||
@@ -205,37 +205,8 @@ int process_configfile( char * configfile )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int split( char * str, char delim, char * parts[], int maxparts )
|
|
||||||
/* Splits a string into parts, to which pointers will be returned in &parts.
|
|
||||||
* The return value is the number of parts.
|
|
||||||
* maxparts is the maximum number of parts returned. If more parts exist
|
|
||||||
* they are (unsplit) in the last part.
|
|
||||||
* The parts are split at the character delim.
|
|
||||||
* No new space will be allocated, the string str will be mutated !
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
char * p1 = str;
|
|
||||||
char * p2;
|
|
||||||
int part_nr = 0;
|
|
||||||
|
|
||||||
/* Find the delim char to end the current part */
|
static int main_loop(void)
|
||||||
while (part_nr < maxparts - 1 && (p2 = strchr(p1, delim))) {
|
|
||||||
|
|
||||||
/* subsequent parts... */
|
|
||||||
*p2 = 0;
|
|
||||||
parts[part_nr] = p1;
|
|
||||||
|
|
||||||
p1 = p2 + 1; /* Just after the delim char */
|
|
||||||
part_nr ++;
|
|
||||||
}
|
|
||||||
/* and the last part... */
|
|
||||||
parts[part_nr] = p1;
|
|
||||||
part_nr ++;
|
|
||||||
|
|
||||||
return part_nr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main_loop()
|
|
||||||
{
|
{
|
||||||
int num_bytes;
|
int num_bytes;
|
||||||
char buf[80];
|
char buf[80];
|
||||||
|
|||||||
@@ -23,6 +23,4 @@ extern char *keys[4];
|
|||||||
|
|
||||||
extern char *progname;
|
extern char *progname;
|
||||||
|
|
||||||
int split(char * str, char delim, char * parts[], int maxparts);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+14
-6
@@ -16,7 +16,8 @@ unsigned short vc_width = 0, vc_height = 0;
|
|||||||
unsigned short vc_cursor_x = 0, vc_cursor_y = 0;
|
unsigned short vc_cursor_x = 0, vc_cursor_y = 0;
|
||||||
char *vc_buf = NULL;
|
char *vc_buf = NULL;
|
||||||
|
|
||||||
int open_vcs()
|
|
||||||
|
int open_vcs(void)
|
||||||
{
|
{
|
||||||
/* Open the /dev/vcsX and /dev/vcsaX devices */
|
/* Open the /dev/vcsX and /dev/vcsaX devices */
|
||||||
vcs0 = open(vcs_device, O_RDONLY);
|
vcs0 = open(vcs_device, O_RDONLY);
|
||||||
@@ -32,7 +33,8 @@ int open_vcs()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_vcdata()
|
|
||||||
|
int read_vcdata(void)
|
||||||
{
|
{
|
||||||
unsigned short new_vc_height;
|
unsigned short new_vc_height;
|
||||||
unsigned short new_vc_width;
|
unsigned short new_vc_width;
|
||||||
@@ -53,14 +55,20 @@ int read_vcdata()
|
|||||||
vc_cursor_y = buf[3];
|
vc_cursor_y = buf[3];
|
||||||
|
|
||||||
/* Screen resize or initial buffer allocation ? */
|
/* Screen resize or initial buffer allocation ? */
|
||||||
if (new_vc_width != vc_width || new_vc_height != vc_height) {
|
if ((new_vc_width != vc_width) || (new_vc_height != vc_height)) {
|
||||||
vc_width = new_vc_width;
|
vc_width = new_vc_width;
|
||||||
vc_height = new_vc_height;
|
vc_height = new_vc_height;
|
||||||
if (vc_buf)
|
|
||||||
free(vc_buf);
|
if (vc_width * vc_height > 0) {
|
||||||
vc_buf = malloc(vc_width * vc_height);
|
vc_buf = realloc(vc_buf, vc_width * vc_height);
|
||||||
|
|
||||||
|
if (vc_buf == NULL) {
|
||||||
|
report(RPT_ERR, "malloc failure: %s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
memset(vc_buf, ' ', vc_width * vc_height);
|
memset(vc_buf, ' ', vc_width * vc_height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Read characters from /dev/cvs0 */
|
/* Read characters from /dev/cvs0 */
|
||||||
lseek(vcs0, 0, SEEK_SET);
|
lseek(vcs0, 0, SEEK_SET);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ extern unsigned short vc_width, vc_height;
|
|||||||
extern unsigned short vc_cursor_x, vc_cursor_y;
|
extern unsigned short vc_cursor_x, vc_cursor_y;
|
||||||
extern char *vc_buf;
|
extern char *vc_buf;
|
||||||
|
|
||||||
int open_vcs();
|
int open_vcs(void);
|
||||||
int read_vcdata();
|
int read_vcdata(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user