wmcalc: Remove C++ style comments.
This commit is contained in:
parent
c3bef2f247
commit
773c07acd7
|
@ -50,9 +50,9 @@
|
||||||
#include "wmcalc_g.h"
|
#include "wmcalc_g.h"
|
||||||
#include "wmcalc_f.h"
|
#include "wmcalc_f.h"
|
||||||
|
|
||||||
#include "backdrop.xpm" // background graphic
|
#include "backdrop.xpm" /* background graphic */
|
||||||
#include "calcbuttons.xpm" // graphic of buttons
|
#include "calcbuttons.xpm" /* graphic of buttons */
|
||||||
#include "charmap.xpm" // pixmap of characters
|
#include "charmap.xpm" /* pixmap of characters */
|
||||||
#include "mask.xbm"
|
#include "mask.xbm"
|
||||||
|
|
||||||
/* Global Variables */
|
/* Global Variables */
|
||||||
|
@ -108,10 +108,10 @@ int main( int argc, char **argv ) {
|
||||||
int bufsize = 20;
|
int bufsize = 20;
|
||||||
|
|
||||||
|
|
||||||
strcpy(configfile, getenv("HOME")); // Added to wmbutton by Casey Harkin, 3/6/99
|
strcpy(configfile, getenv("HOME")); /* Added to wmbutton by Casey Harkin, 3/6/99 */
|
||||||
strcat(configfile, CONFFILENAME); // Fixed Bug - didn't look in home directory
|
strcat(configfile, CONFFILENAME); /* Fixed Bug - didn't look in home directory */
|
||||||
// but startup directory
|
/* but startup directory */
|
||||||
strcat(tempfile, CONFTEMPFILE); // Setup name for temp file
|
strcat(tempfile, CONFTEMPFILE); /* Setup name for temp file */
|
||||||
|
|
||||||
/* Clear the Calculator Display */
|
/* Clear the Calculator Display */
|
||||||
for(i=0; i<DISPSIZE; i++) DispString[i] = ' ';
|
for(i=0; i<DISPSIZE; i++) DispString[i] = ' ';
|
||||||
|
@ -121,28 +121,28 @@ int main( int argc, char **argv ) {
|
||||||
for ( i=1; i < argc; i++ ) {
|
for ( i=1; i < argc; i++ ) {
|
||||||
if ( *argv[i] == '-' ) {
|
if ( *argv[i] == '-' ) {
|
||||||
switch ( *(argv[i]+1) ) {
|
switch ( *(argv[i]+1) ) {
|
||||||
case 'v': // Turn on Verbose (debugging) Mode
|
case 'v': /* Turn on Verbose (debugging) Mode */
|
||||||
Verbose = 1;
|
Verbose = 1;
|
||||||
break;
|
break;
|
||||||
case 'g': // Set Geometry Options
|
case 'g': /* Set Geometry Options */
|
||||||
if ( ++i >= argc ) show_usage();
|
if ( ++i >= argc ) show_usage();
|
||||||
sscanf(argv[i], "%s", Geometry_str);
|
sscanf(argv[i], "%s", Geometry_str);
|
||||||
if ( Verbose ) printf("Geometry is: %s\n", Geometry_str);
|
if ( Verbose ) printf("Geometry is: %s\n", Geometry_str);
|
||||||
break;
|
break;
|
||||||
case 'd': // Set display
|
case 'd': /* Set display */
|
||||||
if ( ++i >= argc ) show_usage();
|
if ( ++i >= argc ) show_usage();
|
||||||
sscanf(argv[i], "%s", Display_str);
|
sscanf(argv[i], "%s", Display_str);
|
||||||
if ( Verbose ) printf("Display is: %s\n", Display_str);
|
if ( Verbose ) printf("Display is: %s\n", Display_str);
|
||||||
break;
|
break;
|
||||||
case 'h': // Show Help Message
|
case 'h': /* Show Help Message */
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'f': // use config file <filename>
|
case 'f': /* use config file <filename> */
|
||||||
if ( ++i >= argc ) show_usage();
|
if ( ++i >= argc ) show_usage();
|
||||||
sscanf(argv[i], "%s", configfile);
|
sscanf(argv[i], "%s", configfile);
|
||||||
if ( Verbose ) printf("Using Config File: %s\n", configfile);
|
if ( Verbose ) printf("Using Config File: %s\n", configfile);
|
||||||
break;
|
break;
|
||||||
default: // other, unknown, parameters
|
default: /* other, unknown, parameters */
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -292,14 +292,14 @@ int main( int argc, char **argv ) {
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
if ( Verbose ) printf("Event: ConfigureNotify\n");
|
if ( Verbose ) printf("Event: ConfigureNotify\n");
|
||||||
// redraw();
|
/* redraw(); */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
if (Verbose) printf("Event: Key state: 0x%x Key: 0x%x\n",
|
if (Verbose) printf("Event: Key state: 0x%x Key: 0x%x\n",
|
||||||
report.xkey.state, report.xkey.keycode);
|
report.xkey.state, report.xkey.keycode);
|
||||||
|
|
||||||
// ksym = XLookupKeysym(&(report.xkey), report.xkey.state);
|
/* ksym = XLookupKeysym(&(report.xkey), report.xkey.state); */
|
||||||
/* KeywithMask - this allows Left, middle, and right button functions
|
/* KeywithMask - this allows Left, middle, and right button functions
|
||||||
to be implemented via keyboard */
|
to be implemented via keyboard */
|
||||||
XLookupString(&(report.xkey), buffer, bufsize, &ksym, &compose);
|
XLookupString(&(report.xkey), buffer, bufsize, &ksym, &compose);
|
||||||
|
@ -315,7 +315,7 @@ int main( int argc, char **argv ) {
|
||||||
N = whichButton(report.xbutton.x, report.xbutton.y );
|
N = whichButton(report.xbutton.x, report.xbutton.y );
|
||||||
if ( (N >= 0) && (N <= NUM_BUTTONS) ) {
|
if ( (N >= 0) && (N <= NUM_BUTTONS) ) {
|
||||||
button_pressed = N + LMASK;
|
button_pressed = N + LMASK;
|
||||||
// redraw();
|
/* redraw(); */
|
||||||
}
|
}
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
printf("Button 1:x=%d y=%d N=%d\n",
|
printf("Button 1:x=%d y=%d N=%d\n",
|
||||||
|
@ -326,7 +326,7 @@ int main( int argc, char **argv ) {
|
||||||
N = whichButton(report.xbutton.x, report.xbutton.y );
|
N = whichButton(report.xbutton.x, report.xbutton.y );
|
||||||
if ( (N >= 0) && (N <= NUM_BUTTONS) ) {
|
if ( (N >= 0) && (N <= NUM_BUTTONS) ) {
|
||||||
button_pressed = N + MMASK;
|
button_pressed = N + MMASK;
|
||||||
// redraw();
|
/* redraw(); */
|
||||||
}
|
}
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
printf("Button 2:x=%d y=%d N=%d\n",
|
printf("Button 2:x=%d y=%d N=%d\n",
|
||||||
|
@ -337,7 +337,7 @@ int main( int argc, char **argv ) {
|
||||||
N = whichButton(report.xbutton.x, report.xbutton.y );
|
N = whichButton(report.xbutton.x, report.xbutton.y );
|
||||||
if ( (N >= 0) && (N <= NUM_BUTTONS) ) {
|
if ( (N >= 0) && (N <= NUM_BUTTONS) ) {
|
||||||
button_pressed = N + RMASK;
|
button_pressed = N + RMASK;
|
||||||
// redraw();
|
/* redraw(); */
|
||||||
}
|
}
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
printf("Button 3:x=%d y=%d N=%d\n",
|
printf("Button 3:x=%d y=%d N=%d\n",
|
||||||
|
@ -429,7 +429,7 @@ void redraw() {
|
||||||
flush_expose( iconwin );
|
flush_expose( iconwin );
|
||||||
XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0,
|
XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0,
|
||||||
visible.attributes.width, visible.attributes.height, 0, 0 );
|
visible.attributes.width, visible.attributes.height, 0, 0 );
|
||||||
// if ( Verbose ) printf("In Redraw()\n");
|
/* if ( Verbose ) printf("In Redraw()\n"); */
|
||||||
displaystr();
|
displaystr();
|
||||||
} /***** End of function redraw() ********************************/
|
} /***** End of function redraw() ********************************/
|
||||||
|
|
||||||
|
@ -697,44 +697,44 @@ int flush_expose(Window w) {
|
||||||
void defineButtonRegions(void) {
|
void defineButtonRegions(void) {
|
||||||
int ndx = 0; /* button index */
|
int ndx = 0; /* button index */
|
||||||
|
|
||||||
button_region[0].x = 1; // Define display region button
|
button_region[0].x = 1; /* Define display region button */
|
||||||
button_region[0].i = 62;
|
button_region[0].i = 62;
|
||||||
button_region[0].y = 6;
|
button_region[0].y = 6;
|
||||||
button_region[0].j = 17;
|
button_region[0].j = 17;
|
||||||
|
|
||||||
for (ndx = 1; ndx <= 5; ndx++) { // Define y coord's for top row
|
for (ndx = 1; ndx <= 5; ndx++) { /* Define y coord's for top row */
|
||||||
button_region[ndx].y = 20;
|
button_region[ndx].y = 20;
|
||||||
button_region[ndx].j = 29;
|
button_region[ndx].j = 29;
|
||||||
}
|
}
|
||||||
for (ndx = 6; ndx <= 10; ndx++) { // Define y coord's for 2nd row
|
for (ndx = 6; ndx <= 10; ndx++) { /* Define y coord's for 2nd row */
|
||||||
button_region[ndx].y = 30;
|
button_region[ndx].y = 30;
|
||||||
button_region[ndx].j = 39;
|
button_region[ndx].j = 39;
|
||||||
}
|
}
|
||||||
for (ndx = 11; ndx <= 15; ndx++) { // Define y coord's for 3rd row
|
for (ndx = 11; ndx <= 15; ndx++) { /* Define y coord's for 3rd row */
|
||||||
button_region[ndx].y = 40;
|
button_region[ndx].y = 40;
|
||||||
button_region[ndx].j = 49;
|
button_region[ndx].j = 49;
|
||||||
}
|
}
|
||||||
for (ndx = 16; ndx <= 20; ndx++) { // Define y coord's for bottom row
|
for (ndx = 16; ndx <= 20; ndx++) { /* Define y coord's for bottom row */
|
||||||
button_region[ndx].y = 50;
|
button_region[ndx].y = 50;
|
||||||
button_region[ndx].j = 59;
|
button_region[ndx].j = 59;
|
||||||
}
|
}
|
||||||
for (ndx = 1; ndx <= 16; ndx+=5) { // Define x coord's for Left column
|
for (ndx = 1; ndx <= 16; ndx+=5) { /* Define x coord's for Left column */
|
||||||
button_region[ndx].x = 5;
|
button_region[ndx].x = 5;
|
||||||
button_region[ndx].i = 16;
|
button_region[ndx].i = 16;
|
||||||
}
|
}
|
||||||
for (ndx = 2; ndx <= 17; ndx+=5) { // Define x coord's for 2nd Left column
|
for (ndx = 2; ndx <= 17; ndx+=5) { /* Define x coord's for 2nd Left column */
|
||||||
button_region[ndx].x = 17;
|
button_region[ndx].x = 17;
|
||||||
button_region[ndx].i = 26;
|
button_region[ndx].i = 26;
|
||||||
}
|
}
|
||||||
for (ndx = 3; ndx <= 18; ndx+=5) { // Define x coord's for middle column
|
for (ndx = 3; ndx <= 18; ndx+=5) { /* Define x coord's for middle column */
|
||||||
button_region[ndx].x = 27;
|
button_region[ndx].x = 27;
|
||||||
button_region[ndx].i = 36;
|
button_region[ndx].i = 36;
|
||||||
}
|
}
|
||||||
for (ndx = 4; ndx <= 19; ndx+=5) { // Define x coord's for 2nd right column
|
for (ndx = 4; ndx <= 19; ndx+=5) { /* Define x coord's for 2nd right column */
|
||||||
button_region[ndx].x = 37;
|
button_region[ndx].x = 37;
|
||||||
button_region[ndx].i = 46;
|
button_region[ndx].i = 46;
|
||||||
}
|
}
|
||||||
for (ndx = 5; ndx <= 20; ndx+=5) { // Define x coord's for 2nd right column
|
for (ndx = 5; ndx <= 20; ndx+=5) { /* Define x coord's for 2nd right column */
|
||||||
button_region[ndx].x = 47;
|
button_region[ndx].x = 47;
|
||||||
button_region[ndx].i = 57;
|
button_region[ndx].i = 57;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
#define MMASK 200
|
#define MMASK 200
|
||||||
#define RMASK 300
|
#define RMASK 300
|
||||||
|
|
||||||
#define CALCDONE 20 // Anything >= 10 should work
|
#define CALCDONE 20 /* Anything >= 10 should work */
|
||||||
#define DISPSIZE 10 // Number of characters in display
|
#define DISPSIZE 10 /* Number of characters in display */
|
||||||
#define NUM_BUTTONS 21
|
#define NUM_BUTTONS 21
|
||||||
#define NUM_MEM_CELLS 10
|
#define NUM_MEM_CELLS 10
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,15 @@
|
||||||
#include "wmcalc_x.h"
|
#include "wmcalc_x.h"
|
||||||
#include "wmcalc_t.h"
|
#include "wmcalc_t.h"
|
||||||
|
|
||||||
void ExecFunc(int val); // function to run app N as found in conf file
|
void ExecFunc(int val); /* function to run app N as found in conf file */
|
||||||
void redraw(void);
|
void redraw(void);
|
||||||
void getPixmaps(void);
|
void getPixmaps(void);
|
||||||
int whichButton(int x, int y); // determine which button has been pressed
|
int whichButton(int x, int y); /* determine which button has been pressed */
|
||||||
int whichKey(KeySym keysym); // determine which key has been pressed
|
int whichKey(KeySym keysym); /* determine which key has been pressed */
|
||||||
int flush_expose(Window w);
|
int flush_expose(Window w);
|
||||||
void show_usage(void); // show usage message to stderr
|
void show_usage(void); /* show usage message to stderr */
|
||||||
char *readln(FILE *fp); // read line from file, return pointer to it
|
char *readln(FILE *fp); /* read line from file, return pointer to it */
|
||||||
void defineButtonRegions(void); // Define boundaries for each button
|
void defineButtonRegions(void); /* Define boundaries for each button */
|
||||||
void displaystr(void);
|
void displaystr(void);
|
||||||
void displaychar(char ch, int location);
|
void displaychar(char ch, int location);
|
||||||
ButtonArea getboundaries(char ch);
|
ButtonArea getboundaries(char ch);
|
||||||
|
@ -58,23 +58,23 @@ void recallmem(int mem_loc);
|
||||||
|
|
||||||
/* Future functions yet to be implemented */
|
/* Future functions yet to be implemented */
|
||||||
|
|
||||||
//void scinotation(void);
|
/*void scinotation(void); */
|
||||||
//void clearmem(void);
|
/*void clearmem(void); */
|
||||||
//void userdef201(void);
|
/*void userdef201(void); */
|
||||||
//void userdef205(void);
|
/*void userdef205(void); */
|
||||||
//void userdef206(void);
|
/*void userdef206(void); */
|
||||||
//void userdef210(void);
|
/*void userdef210(void); */
|
||||||
//void userdef211(void);
|
/*void userdef211(void); */
|
||||||
//void userdef215(void);
|
/*void userdef215(void); */
|
||||||
//void userdef218(void);
|
/*void userdef218(void); */
|
||||||
//void userdef220(void);
|
/*void userdef220(void); */
|
||||||
//void userdef301(void);
|
/*void userdef301(void); */
|
||||||
//void userdef305(void);
|
/*void userdef305(void); */
|
||||||
//void userdef306(void);
|
/*void userdef306(void); */
|
||||||
//void userdef310(void);
|
/*void userdef310(void); */
|
||||||
//void userdef315(void);
|
/*void userdef315(void); */
|
||||||
//void userdef318(void);
|
/*void userdef318(void); */
|
||||||
//void userdef320(void);
|
/*void userdef320(void); */
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,7 +80,7 @@ void ExecFunc( int val ) {
|
||||||
multnums();
|
multnums();
|
||||||
break;
|
break;
|
||||||
case 111:
|
case 111:
|
||||||
// scinotation();
|
/* scinotation(); */
|
||||||
startcalc();
|
startcalc();
|
||||||
break;
|
break;
|
||||||
case 112:
|
case 112:
|
||||||
|
@ -115,7 +115,7 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 201:
|
case 201:
|
||||||
sqrtnum();
|
sqrtnum();
|
||||||
// userdef201();
|
/* userdef201(); */
|
||||||
break;
|
break;
|
||||||
case 202:
|
case 202:
|
||||||
recallmem(7);
|
recallmem(7);
|
||||||
|
@ -128,11 +128,11 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 205:
|
case 205:
|
||||||
divnums();
|
divnums();
|
||||||
// userdef205();
|
/* userdef205(); */
|
||||||
break;
|
break;
|
||||||
case 206:
|
case 206:
|
||||||
sqrnum();
|
sqrnum();
|
||||||
// userdef206();
|
/* userdef206(); */
|
||||||
break;
|
break;
|
||||||
case 207:
|
case 207:
|
||||||
recallmem(4);
|
recallmem(4);
|
||||||
|
@ -145,7 +145,7 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 210:
|
case 210:
|
||||||
multnums();
|
multnums();
|
||||||
// userdef210();
|
/* userdef210(); */
|
||||||
break;
|
break;
|
||||||
case 211:
|
case 211:
|
||||||
startcalc();
|
startcalc();
|
||||||
|
@ -161,7 +161,7 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 215:
|
case 215:
|
||||||
subtnums();
|
subtnums();
|
||||||
// userdef215();
|
/* userdef215(); */
|
||||||
break;
|
break;
|
||||||
case 216:
|
case 216:
|
||||||
chgsignnum();
|
chgsignnum();
|
||||||
|
@ -170,21 +170,21 @@ void ExecFunc( int val ) {
|
||||||
recallmem(0);
|
recallmem(0);
|
||||||
break;
|
break;
|
||||||
case 218:
|
case 218:
|
||||||
// userdef218();
|
/* userdef218(); */
|
||||||
break;
|
break;
|
||||||
case 219:
|
case 219:
|
||||||
equalfunc();
|
equalfunc();
|
||||||
break;
|
break;
|
||||||
case 220:
|
case 220:
|
||||||
addnums();
|
addnums();
|
||||||
// userdef220();
|
/* userdef220(); */
|
||||||
break;
|
break;
|
||||||
case 300:
|
case 300:
|
||||||
clearnum();
|
clearnum();
|
||||||
break;
|
break;
|
||||||
case 301:
|
case 301:
|
||||||
sqrtnum();
|
sqrtnum();
|
||||||
// userdef301();
|
/* userdef301(); */
|
||||||
break;
|
break;
|
||||||
case 302:
|
case 302:
|
||||||
stormem(7);
|
stormem(7);
|
||||||
|
@ -197,11 +197,11 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 305:
|
case 305:
|
||||||
divnums();
|
divnums();
|
||||||
// userdef305();
|
/* userdef305(); */
|
||||||
break;
|
break;
|
||||||
case 306:
|
case 306:
|
||||||
sqrnum();
|
sqrnum();
|
||||||
// userdef306();
|
/* userdef306(); */
|
||||||
break;
|
break;
|
||||||
case 307:
|
case 307:
|
||||||
stormem(4);
|
stormem(4);
|
||||||
|
@ -214,7 +214,7 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 310:
|
case 310:
|
||||||
multnums();
|
multnums();
|
||||||
// userdef310();
|
/* userdef310(); */
|
||||||
break;
|
break;
|
||||||
case 311:
|
case 311:
|
||||||
startcalc();
|
startcalc();
|
||||||
|
@ -230,7 +230,7 @@ void ExecFunc( int val ) {
|
||||||
break;
|
break;
|
||||||
case 315:
|
case 315:
|
||||||
subtnums();
|
subtnums();
|
||||||
// userdef315();
|
/* userdef315(); */
|
||||||
break;
|
break;
|
||||||
case 316:
|
case 316:
|
||||||
chgsignnum();
|
chgsignnum();
|
||||||
|
@ -239,14 +239,14 @@ void ExecFunc( int val ) {
|
||||||
stormem(0);
|
stormem(0);
|
||||||
break;
|
break;
|
||||||
case 318:
|
case 318:
|
||||||
// userdef318();
|
/* userdef318(); */
|
||||||
break;
|
break;
|
||||||
case 319:
|
case 319:
|
||||||
equalfunc();
|
equalfunc();
|
||||||
break;
|
break;
|
||||||
case 320:
|
case 320:
|
||||||
addnums();
|
addnums();
|
||||||
// userdef320();
|
/* userdef320(); */
|
||||||
break;
|
break;
|
||||||
} /* End of switch statement */
|
} /* End of switch statement */
|
||||||
|
|
||||||
|
@ -398,35 +398,35 @@ int write_config(void) {
|
||||||
char movefilecmd[2 * CONFIGFILEMAX + 10]; /* make sure enough room in string */
|
char movefilecmd[2 * CONFIGFILEMAX + 10]; /* make sure enough room in string */
|
||||||
|
|
||||||
/* Open current Config file */
|
/* Open current Config file */
|
||||||
if ((fp = fopen(configfile, "r")) == NULL) { // Can't find config file
|
if ((fp = fopen(configfile, "r")) == NULL) { /* Can't find config file */
|
||||||
printf("%s: Cannot create configuration file\n", configfile);
|
printf("%s: Cannot create configuration file\n", configfile);
|
||||||
return(ERR_FILE_NOT_FOUND);
|
return(ERR_FILE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We cannot write to the global config-file... */
|
/* We cannot write to the global config-file... */
|
||||||
if(!strcmp(configfile, CONFIGGLOBAL)) {
|
if(!strcmp(configfile, CONFIGGLOBAL)) {
|
||||||
strcpy(configfile, getenv("HOME")); // Added to wmbutton by Gordon Fraser, 9/21/01
|
strcpy(configfile, getenv("HOME")); /* Added to wmbutton by Gordon Fraser, 9/21/01 */
|
||||||
strcat(configfile, CONFFILENAME);
|
strcat(configfile, CONFFILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open Temporary File */
|
/* Open Temporary File */
|
||||||
if ((fptmp = fopen(tempfile, "w")) == NULL) { // Can't open file in /tmp
|
if ((fptmp = fopen(tempfile, "w")) == NULL) { /* Can't open file in /tmp */
|
||||||
fprintf(stderr, "%s: Temporary File Open Failed\n", tempfile);
|
fprintf(stderr, "%s: Temporary File Open Failed\n", tempfile);
|
||||||
strcpy(tempfile, getenv("HOME"));
|
strcpy(tempfile, getenv("HOME"));
|
||||||
strcat(tempfile, "wmcalc.tmp");
|
strcat(tempfile, "wmcalc.tmp");
|
||||||
if ((fptmp = fopen(tempfile, "w")) == NULL) { // Can't open file in HOME
|
if ((fptmp = fopen(tempfile, "w")) == NULL) { /* Can't open file in HOME */
|
||||||
fprintf(stderr, "%s: Temporary File Open Failed\n", tempfile);
|
fprintf(stderr, "%s: Temporary File Open Failed\n", tempfile);
|
||||||
return(ERR_TMP_FILE_FAILED);
|
return(ERR_TMP_FILE_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((line = readln(fp)) != NULL) { // Read Lines in config file
|
while ((line = readln(fp)) != NULL) { /* Read Lines in config file */
|
||||||
if (Verbose) printf("line:%s", line);
|
if (Verbose) printf("line:%s", line);
|
||||||
|
|
||||||
if ((strncmp(line, CfgVarList[MEM_LABEL_0],
|
if ((strncmp(line, CfgVarList[MEM_LABEL_0],
|
||||||
strlen(CfgVarList[MEM_LABEL_0]) - 1) == 0)) {
|
strlen(CfgVarList[MEM_LABEL_0]) - 1) == 0)) {
|
||||||
// -1 to generalize to all Mem? strings
|
/* -1 to generalize to all Mem? strings */
|
||||||
// If we've found a memory entry
|
/* If we've found a memory entry */
|
||||||
mem_ndx = atoi(line+strlen(CfgVarList[MEM_LABEL_0])-1);
|
mem_ndx = atoi(line+strlen(CfgVarList[MEM_LABEL_0])-1);
|
||||||
if ((mem_ndx >= 0) && (mem_ndx <= (NUM_MEM_CELLS - 1))) {
|
if ((mem_ndx >= 0) && (mem_ndx <= (NUM_MEM_CELLS - 1))) {
|
||||||
fprintf(fptmp, "%s\t%f\n", CfgVarList[mem_ndx],
|
fprintf(fptmp, "%s\t%f\n", CfgVarList[mem_ndx],
|
||||||
|
@ -483,23 +483,23 @@ int read_config(void) {
|
||||||
char *cfg_var_ptr = NULL;
|
char *cfg_var_ptr = NULL;
|
||||||
|
|
||||||
|
|
||||||
if ((fp = fopen(configfile, "r")) == NULL) { // Can't find config file
|
if ((fp = fopen(configfile, "r")) == NULL) { /* Can't find config file */
|
||||||
strcpy(configfile, CONFIGGLOBAL); // ...so try to open global config
|
strcpy(configfile, CONFIGGLOBAL); /* ...so try to open global config */
|
||||||
if ((fp = fopen(configfile, "r")) == NULL) { // Can't find global config file
|
if ((fp = fopen(configfile, "r")) == NULL) { /* Can't find global config file */
|
||||||
fprintf(stderr, "%s: Configuration File not found\n", configfile);
|
fprintf(stderr, "%s: Configuration File not found\n", configfile);
|
||||||
return(ERR_FILE_NOT_FOUND);
|
return(ERR_FILE_NOT_FOUND);
|
||||||
} else {
|
} else {
|
||||||
write_config(); // if global config opened, save in homedir
|
write_config(); /* if global config opened, save in homedir */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Verbose) printf("%s: Found Configuration File\n", configfile);
|
if (Verbose) printf("%s: Found Configuration File\n", configfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
do { // Read Lines in config file
|
do { /* Read Lines in config file */
|
||||||
line = readln(fp);
|
line = readln(fp);
|
||||||
if (Verbose) printf("Line Read:%s\n", line);
|
if (Verbose) printf("Line Read:%s\n", line);
|
||||||
if (line == NULL) break; // if end of file, quit
|
if (line == NULL) break; /* if end of file, quit */
|
||||||
if ( (line[0] != '#') && (line[0] != '\n')) { /* Ignore comments and
|
if ( (line[0] != '#') && (line[0] != '\n')) { /* Ignore comments and
|
||||||
blanks */
|
blanks */
|
||||||
if (strchr(line, sep_ch) != NULL) { /* The line has a tab, so let's
|
if (strchr(line, sep_ch) != NULL) { /* The line has a tab, so let's
|
||||||
|
@ -517,7 +517,7 @@ int read_config(void) {
|
||||||
|
|
||||||
/* Point to the 'tab' character, to read the value */
|
/* Point to the 'tab' character, to read the value */
|
||||||
cfg_var_ptr = strchr(line, sep_ch);
|
cfg_var_ptr = strchr(line, sep_ch);
|
||||||
cfg_var_ptr++; // ++ to avoid tab character itself
|
cfg_var_ptr++; /* ++ to avoid tab character itself */
|
||||||
|
|
||||||
/* Now set the appropriate variable */
|
/* Now set the appropriate variable */
|
||||||
switch(i) {
|
switch(i) {
|
||||||
|
|
Loading…
Reference in a new issue