From 0656695583cd0231f6b7e87bdc5345567e62016b Mon Sep 17 00:00:00 2001 From: ddouthitt Date: Fri, 28 Sep 2001 17:00:01 +0000 Subject: [PATCH] Updates to main.c: * Fixed up help screen to reflect added options * Added -u option and User directive to configuration file * Massaged help output to keep it under 24 lines (one typical screenful). * Removed some unused code. --- server/main.c | 57 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/server/main.c b/server/main.c index 9fd8e6c..e9a7828 100644 --- a/server/main.c +++ b/server/main.c @@ -65,23 +65,23 @@ int lcd_port = 0; // The parameter structure and args[] should // be removed when getopt(3) is implemented, // as there won't be any need for them then. -typedef struct parameter { - char *sh, *lg; // short and long versions -} parameter; +//typedef struct parameter { +// char *sh, *lg; // short and long versions +//} parameter; // This is currently only a list of available arguments, but doesn't // really *do* anything. It just helps to figure out which parameters // go to the server, and which ones go to individual drivers... -static parameter args[] = { - {"-h", "--help"}, - {"-d", "--driver"}, - {"-t", "--type"}, - {"-f", "--foreground"}, - {"-b", "--backlight"}, - {"-i", "--serverinfo"}, - {"-w", "--waittime"}, - {NULL, NULL}, -}; +//static parameter args[] = { +// {"-h", "--help"}, +// {"-d", "--driver"}, +// {"-t", "--type"}, +// {"-f", "--foreground"}, +// {"-b", "--backlight"}, +// {"-i", "--serverinfo"}, +// {"-w", "--waittime"}, +// {NULL, NULL}, +//}; void exit_program (int val); void HelpScreen (); @@ -128,7 +128,7 @@ main (int argc, char **argv) int disable_server_screen = 1; screen *s = NULL; char *str, *ing; // strings for commandline handling - char *user = DEFAULT_USER; + char user[64]; char c, buf[64], *driverlist[MAX_DRIVERS], *driverargs[MAX_DRIVERS]; char linebuf[128], driver_name[64]; int driver_index, list_index; @@ -145,6 +145,7 @@ main (int argc, char **argv) memset(driverlist, '\0', sizeof(driverlist)); memset(bind_addr, '\0', sizeof(bind_addr)); + memset(user, '\0', sizeof(user)); /* * Settings in order of preference: @@ -168,7 +169,7 @@ main (int argc, char **argv) i = 0; // analyze options here.. - while ((c = getopt(argc, argv, "a:p:d:hfiw:c:")) > 0) { + while ((c = getopt(argc, argv, "a:p:d:hfiw:c:u:")) > 0) { switch(c) { case 'd': // Add to a list of drivers to be initialized later... @@ -182,6 +183,9 @@ main (int argc, char **argv) case 'p': lcd_port = atoi(optarg); break; + case 'u': + strncpy(user, optarg, sizeof(user)); + break; case 'a': strncpy(bind_addr, optarg, sizeof(bind_addr)); break; @@ -295,6 +299,12 @@ main (int argc, char **argv) exit(1); } } else { + + /* + * Global settings.. + * + */ + // not in a driver section... if (strncasecmp(linebuf, "Driver ", 7) == 0) { if (driverlist[0] == NULL) { // check for arguments: override conf file drivers... @@ -304,6 +314,9 @@ main (int argc, char **argv) } else if (strncasecmp(linebuf, "Bind ", 5) == 0) { if (bind_addr[0] == '\0') strncpy(bind_addr, linebuf + 5, sizeof(bind_addr)); + } else if (strncasecmp(linebuf, "User ", 5) == 0) { + if (user[0] == '\0') + strncpy(user, linebuf + 5, sizeof(user)); } else if (strncasecmp(linebuf, "Port ", 5) == 0) { if (lcd_port == 0) lcd_port = atoi(linebuf + 5); @@ -335,6 +348,8 @@ main (int argc, char **argv) debug_level); // set defaults.... + if (user[0] == '\0') + strncpy(user, DEFAULT_USER, sizeof(user)); if (bind_addr[0] == '\0') strncpy(bind_addr, DEFAULT_ADDR, sizeof(bind_addr)); if (lcd_port == 0) @@ -696,11 +711,11 @@ HelpScreen () if (lcd_ptr->framebuf != NULL) lcd_ptr->close(); - printf ("\nLCDproc server daemon, %s\n", version); + printf ("\nLCDd Server Daemon (part of lcdproc), %s\n", version); printf ("Copyright (c) 1999 Scott Scriven, William Ferrell, and misc contributors\n"); printf ("This program is freely redistributable under the terms of the GNU Public License\n\n"); - printf ("Usage: LCDd [ -hfiw ] [ -c ] [ -d ]\n\n"); - printf ("Available options are:\n\n"); + printf ("Usage: LCDd [ -hfiw ] [ -c ] [ -d ] [ -a ] \\\n\t[ -p ] [ -u ] [ -w