From 735631539ca8ab74056894b653a8fee785262854 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Thu, 19 Nov 1998 21:17:58 +0000 Subject: update testparm with -s option so it doesn't require a carriage return also allow specifying [host hostip] without [configfile] updated man page (This used to be commit 85fbd401026e7f1464c9a125cbaa505b768f8a10) --- source3/utils/testparm.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 92bf5cb384..9bf741e24f 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -72,8 +72,12 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); int main(int argc, char *argv[]) { + extern char *optarg; + extern int optind; pstring configfile; + int opt; int s; + BOOL silent_mode = False; TimeInit(); @@ -81,10 +85,20 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); charset_initialise(); - if (argc < 2) + while ((opt = getopt(argc, argv,"s")) != EOF) { + switch (opt) { + case 's': + silent_mode = True; + break; + } + } + + argc += (1 - optind); + + if ((argc == 1) || (argc == 3)) pstrcpy(configfile,CONFIGFILE); - else - pstrcpy(configfile,argv[1]); + else if ((argc == 2) || (argc == 4)) + pstrcpy(configfile,argv[optind]); dbf = stdout; DEBUGLEVEL = 2; @@ -116,19 +130,29 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); break; } - if (argc < 4) + if (argc < 3) { - printf("Press enter to see a dump of your service definitions\n"); - fflush(stdout); - getc(stdin); + if (!silent_mode) { + printf("Press enter to see a dump of your service definitions\n"); + fflush(stdout); + getc(stdin); + } lp_dump(stdout,True); } - if (argc == 4) + if (argc >= 3) { - char *cname = argv[2]; - char *caddr = argv[3]; + char *cname; + char *caddr; + if (argc == 3) { + cname = argv[optind]; + caddr = argv[optind+1]; + } else if (argc == 4) { + cname = argv[optind+1]; + caddr = argv[optind+2]; + } + /* this is totally ugly, a real `quick' hack */ for (s=0;s<1000;s++) if (VALID_SNUM(s)) -- cgit