Small cosmetics

First, now cmake project manages either to use debugging or not (use
cmake-gui or ccmake to determine what is customizable, or just read
CMakeLists.txt, is is really short).

Second, small changes like 'static inline' instead of just 'inline'
and a bit of the same changes, like changing 'if' into ternary stmt
applied.
exp
Alexey N. Vinogradov 6 years ago
parent d80dd2d1df
commit 67c4a00749

@ -7,12 +7,9 @@
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
// uncomment next line in order to have verbose dump in DEBUGFILE #ifndef DEBUGFILE
// after print
//#define DEBUGP
#define DEBUGFILE "/tmp/debugraster.txt" #define DEBUGFILE "/tmp/debugraster.txt"
#endif
struct settings_ { struct settings_ {
int cashDrawer1; int cashDrawer1;
@ -40,38 +37,40 @@ static const struct command cashDrawerEject[2] = {
static const struct command rasterModeStartCommand = { static const struct command rasterModeStartCommand = {
4, (char[4]){0x1d, 0x76, 0x30, 0}}; 4, (char[4]){0x1d, 0x76, 0x30, 0}};
#ifdef DEBUGP #ifndef DEBUGP
FILE *lfd = 0;
#endif static inline void mputchar(char c) { putchar(c); }
#else
FILE *lfd = 0;
// putchar with debug wrapper // putchar with debug wrapper
inline void mputchar(char c) { static inline void mputchar(char c) {
unsigned char m = c; unsigned char m = c;
#ifdef DEBUGP
if (lfd) if (lfd)
fprintf(lfd, "%02x ", m); fprintf(lfd, "%02x ", m);
#endif
putchar(m); putchar(m);
} }
#endif
// procedure to output an array // procedure to output an array
inline void outputarray(const char *array, int length) { static inline void outputarray(const char *array, int length) {
int i = 0; int i = 0;
for (; i < length; ++i) for (; i < length; ++i)
mputchar(array[i]); mputchar(array[i]);
} }
// output a command // output a command
inline void outputCommand(struct command output) { static inline void outputCommand(struct command output) {
outputarray(output.command, output.length); outputarray(output.command, output.length);
} }
inline int lo(int val) { return val & 0xFF; } static inline int lo(int val) { return val & 0xFF; }
inline int hi(int val) { return lo(val >> 8); } static inline int hi(int val) { return lo(val >> 8); }
// enter raster mode and set up x and y dimensions // enter raster mode and set up x and y dimensions
inline void rasterheader(int xsize, int ysize) { static inline void rasterheader(int xsize, int ysize) {
outputCommand(rasterModeStartCommand); outputCommand(rasterModeStartCommand);
mputchar(lo(xsize)); mputchar(lo(xsize));
mputchar(hi(xsize)); mputchar(hi(xsize));
@ -81,14 +80,15 @@ inline void rasterheader(int xsize, int ysize) {
// print all unprinted (i.e. flush the buffer) // print all unprinted (i.e. flush the buffer)
// then feed given number of lines // then feed given number of lines
inline void skiplines(int size) { static inline void skiplines(int size) {
mputchar(0x1b); mputchar(0x1b);
mputchar(0x4a); mputchar(0x4a);
mputchar(size); mputchar(size);
} }
// get an option // get an option
inline int getOptionChoiceIndex(const char *choiceName, ppd_file_t *ppd) { static inline int getOptionChoiceIndex(const char *choiceName,
ppd_file_t *ppd) {
ppd_choice_t *choice; ppd_choice_t *choice;
ppd_option_t *option; ppd_option_t *option;
@ -104,7 +104,7 @@ inline int getOptionChoiceIndex(const char *choiceName, ppd_file_t *ppd) {
return atoi(choice->choice); return atoi(choice->choice);
} }
void initializeSettings(char *commandLineOptionSettings) { static void initializeSettings(char *commandLineOptionSettings) {
ppd_file_t *ppd = NULL; ppd_file_t *ppd = NULL;
cups_option_t *options = NULL; cups_option_t *options = NULL;
int numOptions = 0; int numOptions = 0;
@ -161,7 +161,7 @@ void EndPage() {
} }
// sent on job canceling // sent on job canceling
void cancelJob(int foo) { void cancelJob() {
int i = 0; int i = 0;
for (; i < 0x258; ++i) for (; i < 0x258; ++i)
mputchar(0); mputchar(0);
@ -273,7 +273,7 @@ int main(int argc, char *argv[]) {
} }
#ifdef DEBUGP #ifdef DEBUGP
if (lfd) if (lfd)
fprintf(lfd, "\nReaded %d lines\n", j); fprintf(lfd, "\nRead %d lines\n", j);
#endif #endif
if (j < rest) if (j < rest)
continue; continue;
@ -311,23 +311,20 @@ int main(int argc, char *argv[]) {
ShutDown(); ShutDown();
if (originalRasterDataPtr != NULL) if (originalRasterDataPtr)
free(originalRasterDataPtr); free(originalRasterDataPtr);
cupsRasterClose(ras); cupsRasterClose(ras);
if (fd != 0) if (fd)
close(fd); close(fd);
if (page == 0) fputs(page ? "INFO: Ready to print.\n" : "ERROR: No pages found!\n", stderr);
fputs("ERROR: No pages found!\n", stderr);
else
fputs("INFO: Ready to print.\n", stderr);
#ifdef DEBUGP #ifdef DEBUGP
if (lfd) if (lfd)
fclose(lfd); fclose(lfd);
#endif #endif
return (page == 0) ? EXIT_FAILURE : EXIT_SUCCESS; return page ? EXIT_SUCCESS : EXIT_FAILURE;
} }
// end of rastertozj.c // end of rastertozj.c

Loading…
Cancel
Save