Added support for the "Driver" keyword in a global section of
the configuration file.
This commit is contained in:
+14
-30
@@ -131,7 +131,7 @@ main (int argc, char **argv)
|
|||||||
char *user = DEFAULT_USER;
|
char *user = DEFAULT_USER;
|
||||||
char c, buf[64], *driverlist[MAX_DRIVERS], *driverargs[MAX_DRIVERS];
|
char c, buf[64], *driverlist[MAX_DRIVERS], *driverargs[MAX_DRIVERS];
|
||||||
char linebuf[128], driver_name[64];
|
char linebuf[128], driver_name[64];
|
||||||
int driver_index;
|
int driver_index, list_index;
|
||||||
//char *nullargs[64];
|
//char *nullargs[64];
|
||||||
|
|
||||||
signal (SIGINT, exit_program); // Ctrl-C will cause a clean exit...
|
signal (SIGINT, exit_program); // Ctrl-C will cause a clean exit...
|
||||||
@@ -193,12 +193,6 @@ main (int argc, char **argv)
|
|||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
fprintf(stderr, "non-option arguments!! BAD...");
|
fprintf(stderr, "non-option arguments!! BAD...");
|
||||||
|
|
||||||
// Default driver: curses
|
|
||||||
if (driverlist[0] == NULL) {
|
|
||||||
driverlist[0] = malloc(MAX_DRIVER_NAME_SIZE);
|
|
||||||
strcpy(driverlist[0], DEFAULT_DRIVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
openlog("LCDd", LOG_PID, LOG_DAEMON);
|
openlog("LCDd", LOG_PID, LOG_DAEMON);
|
||||||
syslog(LOG_NOTICE, "server version %s starting up (protocol version %s)",
|
syslog(LOG_NOTICE, "server version %s starting up (protocol version %s)",
|
||||||
version, protocol_version);
|
version, protocol_version);
|
||||||
@@ -209,6 +203,7 @@ main (int argc, char **argv)
|
|||||||
syslog(LOG_WARNING, "no configuration file found... using defaults");
|
syslog(LOG_WARNING, "no configuration file found... using defaults");
|
||||||
} else {
|
} else {
|
||||||
driver_index = -1;
|
driver_index = -1;
|
||||||
|
list_index = 0;
|
||||||
|
|
||||||
memset(linebuf, '\0', sizeof(linebuf));
|
memset(linebuf, '\0', sizeof(linebuf));
|
||||||
|
|
||||||
@@ -263,40 +258,29 @@ main (int argc, char **argv)
|
|||||||
fprintf(stderr, "could not allocate memory for driver arguments!");
|
fprintf(stderr, "could not allocate memory for driver arguments!");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
;
|
|
||||||
|
|
||||||
// Strip out string quotes
|
|
||||||
|
|
||||||
//char *p;
|
|
||||||
|
|
||||||
//p = linebuf + 10;
|
|
||||||
//if (*p == '\"') {
|
|
||||||
// char *q;
|
|
||||||
|
|
||||||
// p++;
|
|
||||||
// q = p;
|
|
||||||
// while ((*q) || (*q != '\"'))
|
|
||||||
// q++;
|
|
||||||
|
|
||||||
// if (! (*q)) {
|
|
||||||
// fprintf(stderr, "unterminated string!");
|
|
||||||
// exit (1);
|
|
||||||
// } else {
|
|
||||||
// q == '\0';
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
strncpy(driverargs[driver_index], linebuf + 9, strlen(linebuf));
|
strncpy(driverargs[driver_index], linebuf + 9, strlen(linebuf));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unknown command line: %s\n", linebuf);
|
fprintf(stderr, "unknown command line: %s\n", linebuf);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// not in a driver section...
|
||||||
|
if (strncasecmp(linebuf, "Driver ", 7) == 0) {
|
||||||
|
driverlist[list_index] = malloc(MAX_DRIVER_NAME_SIZE);
|
||||||
|
snprintf(driverlist[list_index++], MAX_DRIVER_NAME_SIZE, "%s", linebuf + 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(config);
|
fclose(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use default driver
|
||||||
|
if (driverlist[0] == NULL) {
|
||||||
|
driverlist[0] = malloc(MAX_DRIVER_NAME_SIZE);
|
||||||
|
strcpy(driverlist[0], DEFAULT_DRIVER);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_DRIVERS; i++) {
|
for (i = 0; i < MAX_DRIVERS; i++) {
|
||||||
if (driverlist[i] == NULL)
|
if (driverlist[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user