Style: space after "return".
This commit is contained in:
parent
fe0e43d648
commit
9caee2ece7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160002
@ -69,7 +69,7 @@ ConfigCmd(int ac, char **av)
|
||||
|
||||
/* Get arguments */
|
||||
if (ac < 2)
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
path = av[1];
|
||||
|
||||
*buf = '\0';
|
||||
@ -93,7 +93,7 @@ ConfigCmd(int ac, char **av)
|
||||
break;
|
||||
default:
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
|
||||
@ -106,6 +106,6 @@ ConfigCmd(int ac, char **av)
|
||||
printf("No config available for \"%s\"\n", path);
|
||||
else
|
||||
printf("Config for \"%s\":\n%s\n", path, status);
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -76,15 +76,15 @@ ConnectCmd(int ac, char **av)
|
||||
snprintf(con.peerhook, sizeof(con.peerhook), "%s", av[3]);
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Send message */
|
||||
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
|
||||
NGM_CONNECT, &con, sizeof(con)) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -70,15 +70,15 @@ DebugCmd(int ac, char **av)
|
||||
else if (!strcmp(av[1], "-"))
|
||||
level = NgSetDebug(-1) - 1;
|
||||
else if ((level = atoi(av[1])) < 0)
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
NgSetDebug(level);
|
||||
break;
|
||||
case 1:
|
||||
printf("Current debug level is %d\n", NgSetDebug(-1));
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ ListCmd(int ac, char **av)
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -95,18 +95,18 @@ ListCmd(int ac, char **av)
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Get list of nodes */
|
||||
if (NgSendMsg(csock, ".", NGM_GENERIC_COOKIE,
|
||||
named_only ? NGM_LISTNAMES : NGM_LISTNODES, NULL, 0) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
if (NgAllocRecvMsg(csock, &resp, NULL) < 0) {
|
||||
warn("recv msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
|
||||
/* Show each node */
|
||||
|
@ -188,7 +188,7 @@ main(int ac, char *av[])
|
||||
rtn = EX_OSERR;
|
||||
break;
|
||||
}
|
||||
return(rtn);
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -205,10 +205,10 @@ ReadFile(FILE *fp)
|
||||
continue;
|
||||
if ((rtn = DoParseCommand(line)) != 0) {
|
||||
warnx("line %d: error in file", num);
|
||||
return(rtn);
|
||||
return (rtn);
|
||||
}
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -280,7 +280,7 @@ DoInteractive(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(CMDRTN_QUIT);
|
||||
return (CMDRTN_QUIT);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -298,7 +298,7 @@ DoParseCommand(char *line)
|
||||
av[++ac] = strtok(NULL, WHITESPACE));
|
||||
|
||||
/* Do command */
|
||||
return(DoCommand(ac, av));
|
||||
return (DoCommand(ac, av));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -311,12 +311,12 @@ DoCommand(int ac, char **av)
|
||||
int rtn;
|
||||
|
||||
if (ac == 0 || *av[0] == 0)
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
if ((cmd = FindCommand(av[0])) == NULL)
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
if ((rtn = (*cmd->func)(ac, av)) == CMDRTN_USAGE)
|
||||
warnx("usage: %s", cmd->cmd);
|
||||
return(rtn);
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -331,16 +331,16 @@ FindCommand(const char *string)
|
||||
if (MatchCommand(cmds[k], string)) {
|
||||
if (found != -1) {
|
||||
warnx("\"%s\": ambiguous command", string);
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
found = k;
|
||||
}
|
||||
}
|
||||
if (found == -1) {
|
||||
warnx("\"%s\": unknown command", string);
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
return(cmds[found]);
|
||||
return (cmds[found]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -383,17 +383,17 @@ ReadCmd(int ac, char **av)
|
||||
case 2:
|
||||
if ((fp = fopen(av[1], "r")) == NULL) {
|
||||
warn("%s", av[1]);
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Process it */
|
||||
rtn = ReadFile(fp);
|
||||
fclose(fp);
|
||||
return(rtn);
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -419,7 +419,7 @@ HelpCmd(int ac, char **av)
|
||||
*s = '\0';
|
||||
printf(" %-10s %s\n", buf, cmd->desc);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
default:
|
||||
/* Show help on a specific command */
|
||||
if ((cmd = FindCommand(av[1])) != NULL) {
|
||||
@ -462,7 +462,7 @@ HelpCmd(int ac, char **av)
|
||||
}
|
||||
}
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -471,7 +471,7 @@ HelpCmd(int ac, char **av)
|
||||
static int
|
||||
QuitCmd(int ac __unused, char **av __unused)
|
||||
{
|
||||
return(CMDRTN_QUIT);
|
||||
return (CMDRTN_QUIT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -76,15 +76,15 @@ MkPeerCmd(int ac, char **av)
|
||||
snprintf(mkp.peerhook, sizeof(mkp.peerhook), "%s", av[3]);
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Send message */
|
||||
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
|
||||
NGM_MKPEER, &mkp, sizeof(mkp)) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ MsgCmd(int ac, char **av)
|
||||
|
||||
/* Get arguments */
|
||||
if (ac < 3)
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
path = av[1];
|
||||
cmdstr = av[2];
|
||||
|
||||
@ -79,7 +79,7 @@ MsgCmd(int ac, char **av)
|
||||
len += strlen(av[i]) + 1;
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
warn("malloc");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
for (*buf = '\0', i = 3; i < ac; i++) {
|
||||
snprintf(buf + strlen(buf),
|
||||
@ -90,7 +90,7 @@ MsgCmd(int ac, char **av)
|
||||
if (NgSendAsciiMsg(csock, path, "%s%s", cmdstr, buf) < 0) {
|
||||
free(buf);
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
free(buf);
|
||||
|
||||
@ -114,7 +114,7 @@ MsgCmd(int ac, char **av)
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -67,15 +67,15 @@ NameCmd(int ac, char **av)
|
||||
snprintf(name.name, sizeof(name.name), "%s", av[2]);
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Send message */
|
||||
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
|
||||
NGM_NAME, &name, sizeof(name)) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -72,15 +72,15 @@ RmHookCmd(int ac, char **av)
|
||||
snprintf(rmh.ourhook, sizeof(rmh.ourhook), "%s", av[1]);
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Send message */
|
||||
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
|
||||
NGM_RMHOOK, &rmh, sizeof(rmh)) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ ShowCmd(int ac, char **av)
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -90,18 +90,18 @@ ShowCmd(int ac, char **av)
|
||||
path = av[0];
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Get node info and hook list */
|
||||
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
|
||||
NGM_LISTHOOKS, NULL, 0) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
if (NgAllocRecvMsg(csock, &resp, NULL) < 0) {
|
||||
warn("recv msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
|
||||
/* Show node information */
|
||||
@ -133,7 +133,7 @@ ShowCmd(int ac, char **av)
|
||||
}
|
||||
}
|
||||
free(resp);
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,16 +64,16 @@ ShutdownCmd(int ac, char **av)
|
||||
path = av[1];
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Shutdown node */
|
||||
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
|
||||
NGM_SHUTDOWN, NULL, 0) < 0) {
|
||||
warn("shutdown");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ StatusCmd(int ac, char **av)
|
||||
path = av[1];
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Get node status summary */
|
||||
@ -83,7 +83,7 @@ StatusCmd(int ac, char **av)
|
||||
break;
|
||||
default:
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
|
||||
@ -96,6 +96,6 @@ StatusCmd(int ac, char **av)
|
||||
printf("No status available for \"%s\"\n", path);
|
||||
else
|
||||
printf("Status for \"%s\":\n%s\n", path, status);
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
@ -68,18 +68,18 @@ TypesCmd(int ac, char **av __unused)
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Get list of types */
|
||||
if (NgSendMsg(csock, ".", NGM_GENERIC_COOKIE,
|
||||
NGM_LISTTYPES, NULL, 0) < 0) {
|
||||
warn("send msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
if (NgAllocRecvMsg(csock, &resp, NULL) < 0) {
|
||||
warn("recv msg");
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
|
||||
/* Show each type */
|
||||
|
@ -72,16 +72,16 @@ WriteCmd(int ac, char **av)
|
||||
|
||||
/* Get arguments */
|
||||
if (ac < 3)
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
hook = av[1];
|
||||
|
||||
/* Get data */
|
||||
if (strcmp(av[2], "-f") == 0) {
|
||||
if (ac != 4)
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
if ((fp = fopen(av[3], "r")) == NULL) {
|
||||
warn("can't read file \"%s\"", av[3]);
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
if ((len = fread(buf, 1, sizeof(buf), fp)) == 0) {
|
||||
if (ferror(fp))
|
||||
@ -89,7 +89,7 @@ WriteCmd(int ac, char **av)
|
||||
else
|
||||
warnx("file \"%s\" is empty", av[3]);
|
||||
fclose(fp);
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
fclose(fp);
|
||||
} else {
|
||||
@ -97,12 +97,12 @@ WriteCmd(int ac, char **av)
|
||||
if (sscanf(av[i], "%i", &byte) != 1
|
||||
|| (byte < -128 || byte > 255)) {
|
||||
warnx("invalid byte \"%s\"", av[i]);
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
buf[len] = (u_char)byte;
|
||||
}
|
||||
if (len == 0)
|
||||
return(CMDRTN_USAGE);
|
||||
return (CMDRTN_USAGE);
|
||||
}
|
||||
|
||||
/* Send data */
|
||||
@ -112,10 +112,10 @@ WriteCmd(int ac, char **av)
|
||||
if (sendto(dsock, buf, len,
|
||||
0, (struct sockaddr *)sag, sag->sg_len) == -1) {
|
||||
warn("writing to hook \"%s\"", hook);
|
||||
return(CMDRTN_ERROR);
|
||||
return (CMDRTN_ERROR);
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return(CMDRTN_OK);
|
||||
return (CMDRTN_OK);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user