Sort cases in getopt switch statement.

Remove extra parens from my host selection commit.
Add white space after if, while, for and switch.
Get rid of braces around a single statement if.

There should be no functional changes in this commit.

Reviewed by:	sheldonh
This commit is contained in:
dwmalone 2000-08-03 15:19:27 +00:00
parent 91c8cf2367
commit 09a589b8f1

View File

@ -312,17 +312,24 @@ main(argc, argv)
socklen_t len; socklen_t len;
while ((ch = getopt(argc, argv, "a:dl:f:m:p:rsuv")) != -1) while ((ch = getopt(argc, argv, "a:dl:f:m:p:rsuv")) != -1)
switch(ch) { switch (ch) {
case 'd': /* debug */
Debug++;
break;
case 'a': /* allow specific network addresses only */ case 'a': /* allow specific network addresses only */
if (allowaddr(optarg) == -1) if (allowaddr(optarg) == -1)
usage(); usage();
break; break;
case 'd': /* debug */
Debug++;
break;
case 'f': /* configuration file */ case 'f': /* configuration file */
ConfFile = optarg; ConfFile = optarg;
break; break;
case 'l':
if (nfunix < MAXFUNIX)
funixn[nfunix++] = optarg;
else
warnx("out of descriptors, ignoring %s",
optarg);
break;
case 'm': /* mark interval */ case 'm': /* mark interval */
MarkInterval = atoi(optarg) * 60; MarkInterval = atoi(optarg) * 60;
break; break;
@ -335,13 +342,6 @@ main(argc, argv)
case 's': /* no network mode */ case 's': /* no network mode */
SecureMode++; SecureMode++;
break; break;
case 'l':
if (nfunix < MAXFUNIX)
funixn[nfunix++] = optarg;
else
warnx("out of descriptors, ignoring %s",
optarg);
break;
case 'u': /* only log specified priority */ case 'u': /* only log specified priority */
UniquePriority++; UniquePriority++;
break; break;
@ -713,7 +713,7 @@ logmsg(pri, msg, from, flags)
} }
/* skip leading blanks */ /* skip leading blanks */
while(isspace(*msg)) { while (isspace(*msg)) {
msg++; msg++;
msglen--; msglen--;
} }
@ -726,8 +726,8 @@ logmsg(pri, msg, from, flags)
prilev = LOG_PRI(pri); prilev = LOG_PRI(pri);
/* extract program name */ /* extract program name */
for(i = 0; i < NAME_MAX; i++) { for (i = 0; i < NAME_MAX; i++) {
if(!isalnum(msg[i])) if (!isalnum(msg[i]))
break; break;
prog[i] = msg[i]; prog[i] = msg[i];
} }
@ -764,18 +764,18 @@ logmsg(pri, msg, from, flags)
if (f->f_host) if (f->f_host)
switch (f->f_host[0]) { switch (f->f_host[0]) {
case '+': case '+':
if((strcmp(from, f->f_host + 1) != 0) ) if (strcmp(from, f->f_host + 1) != 0)
continue; continue;
break; break;
case '-': case '-':
if((strcmp(from, f->f_host + 1) == 0) ) if (strcmp(from, f->f_host + 1) == 0)
continue; continue;
break; break;
} }
/* skip messages with the incorrect program name */ /* skip messages with the incorrect program name */
if(f->f_program) if (f->f_program)
if(strcmp(prog, f->f_program) != 0) if (strcmp(prog, f->f_program) != 0)
continue; continue;
if (f->f_type == F_CONSOLE && (flags & IGN_CONS)) if (f->f_type == F_CONSOLE && (flags & IGN_CONS))
@ -1292,7 +1292,7 @@ init(signo)
break; break;
} }
next = f->f_next; next = f->f_next;
if(f->f_program) free(f->f_program); if (f->f_program) free(f->f_program);
if (f->f_host) free(f->f_host); if (f->f_host) free(f->f_host);
free((char *)f); free((char *)f);
} }
@ -1326,7 +1326,7 @@ init(signo)
continue; continue;
if (*p == 0) if (*p == 0)
continue; continue;
if(*p == '#') { if (*p == '#') {
p++; p++;
if (*p != '!' && *p != '+' && *p != '-') if (*p != '!' && *p != '+' && *p != '-')
continue; continue;
@ -1348,15 +1348,15 @@ init(signo)
host[i] = '\0'; host[i] = '\0';
continue; continue;
} }
if(*p=='!') { if (*p == '!') {
p++; p++;
while(isspace(*p)) p++; while (isspace(*p)) p++;
if((!*p) || (*p == '*')) { if ((!*p) || (*p == '*')) {
strcpy(prog, "*"); strcpy(prog, "*");
continue; continue;
} }
for(i = 0; i < NAME_MAX; i++) { for (i = 0; i < NAME_MAX; i++) {
if(!isalnum(p[i])) if (!isalnum(p[i]))
break; break;
prog[i] = p[i]; prog[i] = p[i];
} }
@ -1408,9 +1408,8 @@ init(signo)
printf("%s, ", f->f_un.f_uname[i]); printf("%s, ", f->f_un.f_uname[i]);
break; break;
} }
if(f->f_program) { if (f->f_program)
printf(" (%s)", f->f_program); printf(" (%s)", f->f_program);
}
printf("\n"); printf("\n");
} }
} }
@ -1444,14 +1443,16 @@ cfline(line, f, prog, host)
f->f_pmask[i] = INTERNAL_NOPRI; f->f_pmask[i] = INTERNAL_NOPRI;
/* save hostname if any */ /* save hostname if any */
if (host && *host == '*') host = NULL; if (host && *host == '*')
host = NULL;
if (host) if (host)
f->f_host = strdup(host); f->f_host = strdup(host);
/* save program name if any */ /* save program name if any */
if(prog && *prog=='*') prog = NULL; if (prog && *prog == '*')
if(prog) prog = NULL;
f->f_program = strdup(host); if (prog)
f->f_program = strdup(prog);
/* scan through the list of selectors */ /* scan through the list of selectors */
for (p = line; *p && *p != '\t' && *p != ' ';) { for (p = line; *p && *p != '\t' && *p != ' ';) {