summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2020-07-24 10:03:40 +0200
committerDidier Raboud <odyx@debian.org>2020-07-24 10:10:30 +0200
commit9165e110e6026497331193d7c8d3d28a0da79709 (patch)
tree0242f8c0791f8c91c6916e65653b7984a3167aad
parent0e9faa9dc5e3f17d7013dea10bee9b5e9a69aee2 (diff)
Namespace overlapping global variable names
-rw-r--r--src/c2espcommon.c28
-rw-r--r--src/command2esp.c20
2 files changed, 24 insertions, 24 deletions
diff --git a/src/c2espcommon.c b/src/c2espcommon.c
index 0c83471..47c8f9a 100644
--- a/src/c2espcommon.c
+++ b/src/c2espcommon.c
@@ -42,11 +42,11 @@
* Globals...
*/
char CallerName[50]; /* String that identifies the calling program */
-int DoBack; /* Enables the back channel comms */
+int CommDoBack; /* Enables the back channel comms */
char BackBuf[32000]; //for the back channel replies from the printer
int BackBufLen=sizeof(BackBuf)-1;
FILE *LogFile = NULL; //file descriptor for log file
-time_t StartTime;
+time_t CommStartTime;
int BlackPercent, ColourPercent;
time_t KeepAwake(time_t Start, int Interval, FILE *PrintFile)
@@ -56,17 +56,17 @@ time_t KeepAwake(time_t Start, int Interval, FILE *PrintFile)
if(time(NULL) - Start > Interval)
{
DoLog("Keeping printer awake by DeviceStatus?\n",0,0);
- GoodExchange(PrintFile, "DeviceStatus?", "0101,DeviceStatus.ImageDevice", DoBack, 1, 1.0);
+ GoodExchange(PrintFile, "DeviceStatus?", "0101,DeviceStatus.ImageDevice", CommDoBack, 1, 1.0);
return (time(NULL));
}
else return (Start);
}
-void SetupLogging(char *ExtCallerName, int ExtDoBack, char *ExtLogFileName)
+void SetupLogging(char *ExtCallerName, int ExtCommDoBack, char *ExtLogFileName)
{
strcpy(CallerName,ExtCallerName);
- DoBack=ExtDoBack;
+ CommDoBack=ExtCommDoBack;
if(strlen(ExtLogFileName)>0)
{
remove(ExtLogFileName); //to be sure I only see the latest
@@ -76,7 +76,7 @@ void SetupLogging(char *ExtCallerName, int ExtDoBack, char *ExtLogFileName)
setbuf(LogFile, NULL);
fprintf(LogFile, "KodakPrintLog %s\n",ExtCallerName);
}
- StartTime = time(NULL);
+ CommStartTime = time(NULL);
}
void CloseLogging()
@@ -98,8 +98,8 @@ void DoLog(char *PrintFormat, int I1, int I2)
strncat(CupsFormat,PrintFormat,150); //crop PrintFormat to avoid FAILING WITH BUFFER OVERFLOW
// add \n if not \n at the end of cupsformat
if(CupsFormat[strlen(CupsFormat)-1] != NL) strcat(CupsFormat,"\n");
- fprintf(stderr, CupsFormat, time(NULL)-StartTime, I1, I2);
- if (LogFile != NULL) fprintf(LogFile, CupsFormat, time(NULL)-StartTime, I1, I2);
+ fprintf(stderr, CupsFormat, time(NULL)-CommStartTime, I1, I2);
+ if (LogFile != NULL) fprintf(LogFile, CupsFormat, time(NULL)-CommStartTime, I1, I2);
}
void DoLogString(char *PrintFormat, char *String)
@@ -110,8 +110,8 @@ void DoLogString(char *PrintFormat, char *String)
strcat(CupsFormat,CallerName);
strcat(CupsFormat,":%d : ");
strncat(CupsFormat,PrintFormat,150); //crop PrintFormat to avoid FAILING WITH BUFFER OVERFLOW
- fprintf(stderr, CupsFormat, time(NULL)-StartTime, String);
- if (LogFile != NULL) fprintf(LogFile, CupsFormat, time(NULL)-StartTime, String);
+ fprintf(stderr, CupsFormat, time(NULL)-CommStartTime, String);
+ if (LogFile != NULL) fprintf(LogFile, CupsFormat, time(NULL)-CommStartTime, String);
}
/* DoOutJob used to enable one call to send to the specified job file and to stdout (if not testing)
@@ -135,7 +135,7 @@ void DoOutJob(FILE *OutFile, char *PrintFormat, int I1, int I2)
fprintf(stdout, PrintFormat, I1, I2); //and to the output
fflush(stdout);
- if(DoBack)
+ if(CommDoBack)
{
BytesRead = cupsBackChannelRead(BackBuf, BackBufLen, 0.5); //read the reply from printer
if(BytesRead >= 1)
@@ -160,7 +160,7 @@ int FlushBackChannel(char *IdString, float DrainTime)
cups_sc_status_t status;
char BackBuf[2]; //useless buffer to satisfy cupsSideChannelDoRequest
int BackBufLen=sizeof(BackBuf)-1;
- if(DoBack)
+ if(CommDoBack)
{
status = cupsSideChannelDoRequest(CUPS_SC_CMD_DRAIN_OUTPUT, BackBuf, &BackBufLen, DrainTime);
if(status == CUPS_SC_STATUS_OK)
@@ -188,7 +188,7 @@ int FlushBackChannel(char *IdString, float DrainTime)
otherwise -(the number of bytes read) if the reply did not include Expect, or 0 if there was no reply */
-int GoodExchange(FILE *PrintFile, char *Command, char *Expect, int DoBack, unsigned int SleepTime, float ReplyTime)
+int GoodExchange(FILE *PrintFile, char *Command, char *Expect, int CommDoBack, unsigned int SleepTime, float ReplyTime)
{
int BytesRead = 0; //int because cupsBackChannel can return -1
char Display[80];
@@ -212,7 +212,7 @@ int GoodExchange(FILE *PrintFile, char *Command, char *Expect, int DoBack, unsi
fflush(stdout); //force a packet to the printer so it can reply
sleep(SleepTime); //give it a chance to reply before trying to read the reply (may not be needed)
- if(DoBack)
+ if(CommDoBack)
{
BytesRead = cupsBackChannelRead(BackBuf, BackBufLen, ReplyTime); //read the reply from printer
if(BytesRead < 1)
diff --git a/src/command2esp.c b/src/command2esp.c
index e30357e..0fc7260 100644
--- a/src/command2esp.c
+++ b/src/command2esp.c
@@ -58,12 +58,12 @@ Maintenance=003?
#include "c2espcommon.h" //the common library
-time_t StartTime;
+time_t CmdStartTime;
//FILE *LogFile = NULL; //file descriptor for log file
FILE *PrintFile = NULL; //file descriptor for debug file
//char BackBuf[32000]; //for the back channel replies from the printer
//int BackBufLen=sizeof(BackBuf)-1,
-int DoBack=1; /* Enables the back channel comms */
+int CmdDoBack=1; /* Enables the back channel comms */
/*
time_t KeepAwake(time_t Start, int Interval)
@@ -73,7 +73,7 @@ time_t KeepAwake(time_t Start, int Interval)
if(time(NULL) - Start > Interval)
{
DoLog("Keeping printer awake by DeviceStatus?\n",0,0);
- GoodExchange(PrintFile, "DeviceStatus?", "0101,DeviceStatus.ImageDevice", DoBack, 1, 1.0);
+ GoodExchange(PrintFile, "DeviceStatus?", "0101,DeviceStatus.ImageDevice", CmdDoBack, 1, 1.0);
return (time(NULL));
}
else return (Start);
@@ -109,12 +109,12 @@ main(int argc, /* I - Number of command-line arguments */
int StatusLength;
fputs("INFO: command2esp running\n", stderr);
- StartTime = time(NULL);
+ CmdStartTime = time(NULL);
#if DEBUGFILES == 1
- SetupLogging("c2espCommand",DoBack,"/tmp/KodakCommandLog");
+ SetupLogging("c2espCommand",CmdDoBack,"/tmp/KodakCommandLog");
#else
- SetupLogging("c2espCommand",DoBack,"");
+ SetupLogging("c2espCommand",CmdDoBack,"");
#endif
/*
@@ -183,7 +183,7 @@ main(int argc, /* I - Number of command-line arguments */
/* Clean heads...*/
fputs("INFO: command2esp Clean print head\n", stderr);
DoLog("Clean print head\n",0,0);
- GoodExchange(PrintFile, "Maintenance=003?", "0096, OK, Maintenance Started;", DoBack, 1, 1.0);
+ GoodExchange(PrintFile, "Maintenance=003?", "0096, OK, Maintenance Started;", CmdDoBack, 1, 1.0);
KeepAwakeFor(80,10);
}
@@ -193,7 +193,7 @@ main(int argc, /* I - Number of command-line arguments */
fputs("INFO: command2esp Print alignment page\n", stderr);
DoLog("Print alignment page\n",0,0);
- GoodExchange(PrintFile, "Maintenance=006?", "0096, OK, Maintenance Started;", DoBack, 1, 1.0);
+ GoodExchange(PrintFile, "Maintenance=006?", "0096, OK, Maintenance Started;", CmdDoBack, 1, 1.0);
KeepAwakeFor(80,10);
}
@@ -201,7 +201,7 @@ main(int argc, /* I - Number of command-line arguments */
{
fputs("INFO: command2esp Print Self Test Page\n", stderr);
DoLog("Print Self Test Page\n",0,0);
- GoodExchange(PrintFile, "Maintenance=002?", "0096, OK, Maintenance Started;", DoBack, 1, 1.0);
+ GoodExchange(PrintFile, "Maintenance=002?", "0096, OK, Maintenance Started;", CmdDoBack, 1, 1.0);
// Hero 9.1 does not need to be kept awake. ESP 5250 does?
//sleep(80); //did not work for ESP 5250
KeepAwakeFor(80,15);
@@ -211,7 +211,7 @@ main(int argc, /* I - Number of command-line arguments */
{
/* Report ink levels... */
- StatusLength=abs(GoodExchange(PrintFile, "DeviceStatus?", "0101,DeviceStatus.ImageDevice", DoBack, 1, 1.0));
+ StatusLength=abs(GoodExchange(PrintFile, "DeviceStatus?", "0101,DeviceStatus.ImageDevice", CmdDoBack, 1, 1.0));
DoLog("StatusLength=%d\n",StatusLength,0);
/* you can get unexpected reply if there is an ink low warning then GoodExchange will be -ve */
/* aquire ink levels here? DeviceStatus.Printer.InkLevelPercent.Colour=nn%&DeviceStatus.Printer.InkLevelPercent.Black=nn% */