diff --git a/server/client.c b/server/client.c index f0119aa..2596022 100644 --- a/server/client.c +++ b/server/client.c @@ -14,7 +14,9 @@ #include #include -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "client.h" #include "screenlist.h" diff --git a/server/driver.c b/server/driver.c index 51d3648..1b5c965 100644 --- a/server/driver.c +++ b/server/driver.c @@ -17,15 +17,15 @@ #include #include #ifndef WIN32 -#include -#include +# include +# include #else -#include +# include #endif #include #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include "main.h" /* for timer */ diff --git a/server/drivers.c b/server/drivers.c index c7914d4..363d7f1 100644 --- a/server/drivers.c +++ b/server/drivers.c @@ -20,7 +20,7 @@ #include #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include "shared/LL.h" diff --git a/server/drivers/CFontz633io.c b/server/drivers/CFontz633io.c index d63a331..8e04372 100644 --- a/server/drivers/CFontz633io.c +++ b/server/drivers/CFontz633io.c @@ -46,8 +46,7 @@ #include #include #include - -#include "config.h" +#include /* only required for debugging */ #if defined(HAVE_SYS_SELECT_H) # include @@ -56,7 +55,12 @@ # include #endif /* defined(HAVE_SYS_SELECT_H) */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "CFontz633io.h" +#include "report.h" #define TRY_AGAIN 0 @@ -75,7 +79,9 @@ static void send_packet(int fd, COMMAND_PACKET *out, COMMAND_PACKET *in); static int get_crc(unsigned char *buf, int len, int seed); static int test_packet(int fd, unsigned char response, COMMAND_PACKET *in); static int check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length); +#ifdef DEBUG static void print_packet(COMMAND_PACKET *packet); +#endif /* global variables */ @@ -101,7 +107,7 @@ void EmptyKeyRing(KeyRing *kr) int AddKeyToKeyRing(KeyRing *kr, unsigned char key) { if (((kr->head + 1) % KEYRINGSIZE) != (kr->tail % KEYRINGSIZE)) { - /* fprintf(stderr, "We add key: %d\n", key); */ + debug(RPT_DEBUG, "%s: add key: %d", __FUNCTION__, key); kr->contents[kr->head % KEYRINGSIZE] = key; kr->head = (kr->head + 1) % KEYRINGSIZE; @@ -125,7 +131,8 @@ unsigned char GetKeyFromKeyRing(KeyRing *kr) kr->tail = (kr->tail + 1) % KEYRINGSIZE; } - /* if (retval) fprintf(stderr, "We remove key: %d\n", retval); */ + if (retval) + debug(RPT_DEBUG, "%s: remove key: %d", __FUNCTION__, retval); return retval; } @@ -302,26 +309,25 @@ void SyncReceiveBuffer(ReceiveBuffer *rb, int fd, unsigned int number) BytesRead = read(fd, buffer, number); if (BytesRead == -1) { - /* this shouldnot happen with the select() above */ - /* fprintf(stderr, "~~~Problem reading: %s .\n", strerror(errno)); */ + /* this should not happen with the select() above */ + debug(RPT_WARNING, "%s: ~~~Problem reading: %s", __FUNCTION__, strerror(errno)); } else { int i; - /* fprintf(stderr, "Read %d Bytes:", BytesRead); */ + debug(RPT_DEBUG, "%s: read %d bytes:", __FUNCTION__, BytesRead); /* wrap write pointer to the receive buffer */ rb->head %= RECEIVEBUFFERSIZE; /* store the bytes read */ for (i = 0; i < BytesRead; i++) { - /* fprintf(stderr, " %02x", buffer[i]); */ + debug(RPT_DEBUG, "%s: reading byte %02x", __FUNCTION__, buffer[i]); rb->contents[rb->head] = buffer[i]; /* increment write pointer (wrap if needed) */ rb->head = (rb->head + 1) % RECEIVEBUFFERSIZE; } - /* fprintf(stderr, "\n"); */ } } @@ -480,7 +486,7 @@ check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length) //First off, there must be at least 4 bytes available in the input stream //for there to be a valid command in it (command, length, no data, CRC). if (BytesAvail(&receivebuffer) < 4) { - /* fprintf(stderr, "Not enough bytes available for even the smallest message.\n"); */ + debug(RPT_INFO, "%s: not enough bytes available for even the smallest message", __FUNCTION__); return(GIVE_UP); /* We don't need to retry before more byte are received */ } @@ -494,7 +500,7 @@ check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length) if (MAX_COMMAND < (0x3F & in->command)) { /* Throw out one byte of garbage. Next pass through should re-sync. */ GetByte(&receivebuffer); - /* fprintf(stderr, "###: Unknown command.\n"); */ + debug(RPT_INFO, "%s: unknown command", __FUNCTION__); return(TRY_AGAIN); } @@ -505,7 +511,7 @@ check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length) if (MAX_DATA_LENGTH < in->data_length) { //Throw out one byte of garbage. Next pass through should re-sync. GetByte(&receivebuffer); - /* fprintf(stderr, "###: Too long packet: %d.\n", in->data_length); */ + debug(RPT_INFO, "%s: too long packet: %d", __FUNCTION__, in->data_length); return(TRY_AGAIN); } @@ -514,7 +520,7 @@ check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length) if ((int) PeekBytesAvail(&receivebuffer) < (in->data_length + 2)) { //It looked like a valid start of a packet, but it does not look //like the complete packet has been received yet. - /* fprintf(stderr, "Not enough read to check the complete message.\n"); */ + debug(RPT_INFO, "%s: not enough read to check the complete message", __FUNCTION__); return(GIVE_UP); /* Let's not return until more byte are available */ } @@ -534,7 +540,7 @@ check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length) //This is a good packet. Remove the packet from the serial buffer. AcceptPeekedData(&receivebuffer); //Let our caller know that incoming_command has good stuff in it. - /* print_packet(&outgoing_response); */ + /* print_packet(in); */ return(GOOD_MSG); } @@ -543,12 +549,13 @@ check_for_packet(int fd, COMMAND_PACKET *in, unsigned char expected_length) * Next pass through should re-sync. */ GetByte(&receivebuffer); - /* fprintf(stderr, "###: Wrong CheckSum. computed/real %04x:%04x \n", - testcrc, incoming_command.crc); */ + debug(RPT_INFO, "%s: wrong CheckSum: computed %04x / real %04x", + __FUNCTION__, testcrc, in->crc); return(TRY_AGAIN); } +#ifdef DEBUG /* * This is a debugging function. * It should be removed or compiled in conditionally. @@ -571,4 +578,4 @@ print_packet(COMMAND_PACKET *packet) fprintf(stderr, " ] %02x %02x .\n", packet->crc & 0xFF, (packet->crc >> 8) & 0xFF); } - +#endif /* DEBUG */ diff --git a/server/drivers/EyeboxOne.c b/server/drivers/EyeboxOne.c index 1405156..64de7e4 100644 --- a/server/drivers/EyeboxOne.c +++ b/server/drivers/EyeboxOne.c @@ -217,7 +217,7 @@ EyeboxOne_init (Driver *drvthis) /* keypad test mode? */ if (drvthis->config_get_bool(drvthis->name, "keypad_test_mode", 0, 0)) { - fprintf( stdout, "EyeBO: Entering keypad test mode...\n"); + fprintf(stdout, "EyeBO: Entering keypad test mode...\n"); p->keypad_test_mode = 1; stay_in_foreground = 1; } diff --git a/server/drivers/MtxOrb.c b/server/drivers/MtxOrb.c index 80c75bf..9c2e296 100644 --- a/server/drivers/MtxOrb.c +++ b/server/drivers/MtxOrb.c @@ -311,7 +311,7 @@ MtxOrb_init (Driver *drvthis) /* keypad test mode? */ if (drvthis->config_get_bool(drvthis->name, "keypad_test_mode", 0, 0)) { - fprintf( stdout, "MtxOrb: Entering keypad test mode...\n"); + fprintf(stdout, "MtxOrb: Entering keypad test mode...\n"); p->keypad_test_mode = 1; stay_in_foreground = 1; } diff --git a/server/drivers/irmanin.c b/server/drivers/irmanin.c index 1093f8b..2362932 100644 --- a/server/drivers/irmanin.c +++ b/server/drivers/irmanin.c @@ -2,7 +2,7 @@ /* Copyright (C) 1999 David Glaude loosely based on workmanir.c */ /* workmanir.c - test/demo of LIBIR's high level command functions */ /* Copyright (C) 1998 Tom Wheeley, see file COPYING for details */ -#include + #include #include #include @@ -22,6 +22,10 @@ #define NAME_LENGTH 128 +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "lcd.h" #include "irmanin.h" #include "report.h" diff --git a/server/drivers/lcd_lib.c b/server/drivers/lcd_lib.c index 012151f..2c16bd9 100644 --- a/server/drivers/lcd_lib.c +++ b/server/drivers/lcd_lib.c @@ -5,7 +5,7 @@ #include "lcd.h" #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif diff --git a/server/drivers/lcd_sem.c b/server/drivers/lcd_sem.c index cf424f8..9b4fe52 100644 --- a/server/drivers/lcd_sem.c +++ b/server/drivers/lcd_sem.c @@ -20,7 +20,6 @@ * */ -#include #include #include #include /* for semaphore functions */ @@ -28,6 +27,10 @@ #include #include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "lcd_sem.h" // according to X/OPEN we have to define it ourselves diff --git a/server/drivers/lis.c b/server/drivers/lis.c index d96691b..53771ed 100644 --- a/server/drivers/lis.c +++ b/server/drivers/lis.c @@ -464,7 +464,7 @@ lis_init(Driver *drvthis) err = ftdi_usb_open(&p->ftdic, p->VendorID, p->ProductID); if (err < 0) { report(RPT_ERR, "%s: cannot open USB device %x:%x", - drvthis->name + drvthis->name, p->VendorID, p->ProductID); goto err_framebuf; diff --git a/server/drivers/port.h b/server/drivers/port.h index c223809..0791313 100644 --- a/server/drivers/port.h +++ b/server/drivers/port.h @@ -52,7 +52,7 @@ not be in this file but in lpt-port.h ... #define PORT_H #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif #include diff --git a/server/drivers/pylcd.c b/server/drivers/pylcd.c index ffb8968..08c33aa 100644 --- a/server/drivers/pylcd.c +++ b/server/drivers/pylcd.c @@ -897,7 +897,7 @@ pyramid_icon (Driver *drvthis, int x, int y, int icon) // // Leaving this in the code as notification for other similar cases if (p->custom == bign) { - printf("Switching to beat\n"); + debug(RPT_DEBUG, "%s: Switching to beat", __FUNCTION__); p->custom = beat; } #endif @@ -958,7 +958,7 @@ pyramid_icon (Driver *drvthis, int x, int y, int icon) break; default: - printf("x=%d, y=%d, icon=%x\n", x,y,icon); + debug(RPT_INFO, "%s: x=%d, y=%d, icon=%x", __FUNCTION__, x, y, icon); return -1; } return 0; diff --git a/server/drivers/svgalib_drv.c b/server/drivers/svgalib_drv.c index e4e6e4a..f9c17af 100644 --- a/server/drivers/svgalib_drv.c +++ b/server/drivers/svgalib_drv.c @@ -29,7 +29,9 @@ #include #include -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "lcd.h" #include "report.h" diff --git a/server/main.c b/server/main.c index 9338614..29374b5 100644 --- a/server/main.c +++ b/server/main.c @@ -25,7 +25,9 @@ * */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include #include diff --git a/server/menu.c b/server/menu.c index 7b49f00..d418131 100644 --- a/server/menu.c +++ b/server/menu.c @@ -29,7 +29,9 @@ #include #include -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "menuitem.h" #include "menu.h" diff --git a/server/serverscreens.c b/server/serverscreens.c index a5a556c..cc0fc2c 100644 --- a/server/serverscreens.c +++ b/server/serverscreens.c @@ -19,7 +19,7 @@ #include #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include "shared/report.h" diff --git a/shared/configfile.c b/shared/configfile.c index 677efdd..87623c8 100644 --- a/shared/configfile.c +++ b/shared/configfile.c @@ -13,13 +13,15 @@ * */ -#include "config.h" - #include #include #include #include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "shared/report.h" diff --git a/shared/debug.h b/shared/debug.h index 0c030a3..71af9fa 100644 --- a/shared/debug.h +++ b/shared/debug.h @@ -5,7 +5,7 @@ #include #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif /* DEBUGGING diff --git a/shared/getopt.c b/shared/getopt.c index 7de2c53..5b6fe98 100644 --- a/shared/getopt.c +++ b/shared/getopt.c @@ -26,7 +26,7 @@ #endif #ifdef HAVE_CONFIG_H -# include +# include "config.h" #else # if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems diff --git a/shared/getopt1.c b/shared/getopt1.c index a025954..fb13992 100644 --- a/shared/getopt1.c +++ b/shared/getopt1.c @@ -19,7 +19,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #else #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems diff --git a/shared/report.h b/shared/report.h index a1be7c1..b9b30c7 100644 --- a/shared/report.h +++ b/shared/report.h @@ -56,7 +56,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #include diff --git a/shared/snprintf.c b/shared/snprintf.c index fd1d50f..80e8989 100644 --- a/shared/snprintf.c +++ b/shared/snprintf.c @@ -218,7 +218,9 @@ * the fact that this work is dual licensed. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif /* Define HAVE_SNPRINTF if your system already has snprintf and vsnprintf. * diff --git a/shared/snprintf.h b/shared/snprintf.h index e000118..f567ba6 100644 --- a/shared/snprintf.h +++ b/shared/snprintf.h @@ -5,7 +5,7 @@ #define PORTABLE_SNPRINTF_VERSION_MINOR 2 #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #ifdef HAVE_SNPRINTF diff --git a/shared/sockets.c b/shared/sockets.c index 0a5dd57..91c8308 100644 --- a/shared/sockets.c +++ b/shared/sockets.c @@ -1,4 +1,3 @@ -#include "config.h" #include #include #include @@ -7,17 +6,21 @@ #include #include #ifndef WINSOCK2 -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include #else -#include +# include #endif #include #include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "report.h" #include "sockets.h"