Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144964066
D55257.id171867.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
27 KB
Referenced Files
None
Subscribers
None
D55257.id171867.diff
View Options
diff --git a/usr.sbin/ngctl/config.c b/usr.sbin/ngctl/config.c
--- a/usr.sbin/ngctl/config.c
+++ b/usr.sbin/ngctl/config.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -14,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -94,8 +94,8 @@
return (CMDRTN_ERROR);
}
} else {
- if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
- || (resp->header.flags & NGF_RESP) == 0)
+ if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0 ||
+ (resp->header.flags & NGF_RESP) == 0)
nostat = 1;
}
@@ -106,4 +106,3 @@
printf("Config for \"%s\":\n%s\n", path, status);
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/connect.c b/usr.sbin/ngctl/connect.c
--- a/usr.sbin/ngctl/connect.c
+++ b/usr.sbin/ngctl/connect.c
@@ -1,10 +1,9 @@
-
/*
* connect.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -85,4 +84,3 @@
}
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/debug.c b/usr.sbin/ngctl/debug.c
--- a/usr.sbin/ngctl/debug.c
+++ b/usr.sbin/ngctl/debug.c
@@ -1,10 +1,9 @@
-
/*
* debug.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -79,4 +78,3 @@
}
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/dot.c b/usr.sbin/ngctl/dot.c
--- a/usr.sbin/ngctl/dot.c
+++ b/usr.sbin/ngctl/dot.c
@@ -1,4 +1,3 @@
-
/*
* dot.c
*
@@ -6,7 +5,7 @@
* Copyright (c) 2004 Brian Fundakowski Feldman
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -17,7 +16,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -71,13 +70,13 @@
u_int i;
/* Get options */
+ optreset = 1;
optind = 1;
while ((ch = getopt(ac, av, "c")) != -1) {
switch (ch) {
case 'c':
compact = 1;
break;
- case '?':
default:
return (CMDRTN_USAGE);
break;
diff --git a/usr.sbin/ngctl/list.c b/usr.sbin/ngctl/list.c
--- a/usr.sbin/ngctl/list.c
+++ b/usr.sbin/ngctl/list.c
@@ -1,10 +1,9 @@
-
/*
* list.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -70,6 +69,7 @@
int ch, rtn = CMDRTN_OK;
/* Get options */
+ optreset = 1;
optind = 1;
while ((ch = getopt(ac, av, "ln")) != -1) {
switch (ch) {
@@ -79,7 +79,6 @@
case 'n':
named_only = 1;
break;
- case '?':
default:
return (CMDRTN_USAGE);
break;
@@ -114,11 +113,11 @@
ninfo = nlist->nodeinfo;
if (list_hooks) {
char path[NG_PATHSIZ];
- char *argv[2] = { "show", path };
+ char *argv[] = { "show", path, NULL };
while (nlist->numnames > 0) {
- snprintf(path, sizeof(path),
- "[%lx]:", (u_long)ninfo->id);
+ snprintf(path, sizeof(path), "[%lx]:",
+ (unsigned long)ninfo->id);
if ((rtn = (*show_cmd.func)(2, argv)) != CMDRTN_OK)
break;
ninfo++;
@@ -143,4 +142,3 @@
free(resp);
return (rtn);
}
-
diff --git a/usr.sbin/ngctl/main.c b/usr.sbin/ngctl/main.c
--- a/usr.sbin/ngctl/main.c
+++ b/usr.sbin/ngctl/main.c
@@ -1,10 +1,9 @@
-
/*
* main.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -39,12 +38,12 @@
#include <sys/param.h>
#include <sys/socket.h>
-#include <sys/select.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -71,7 +70,8 @@
/* Internal functions */
static int ReadFile(FILE *fp);
-static void ReadSockets(fd_set *);
+static void ReadCtrlSocket(void);
+static void ReadDataSocket(void);
static int DoParseCommand(const char *line);
static int DoCommand(int ac, char **av);
static int DoInteractive(void);
@@ -146,6 +146,7 @@
FILE *fp = NULL;
#ifdef JAIL
const char *jail_name = NULL;
+ int jid;
#endif
int ch, rtn = 0;
@@ -174,7 +175,6 @@
case 'n':
snprintf(name, sizeof(name), "%s", optarg);
break;
- case '?':
default:
Usage((char *)NULL);
break;
@@ -185,8 +185,6 @@
#ifdef JAIL
if (jail_name != NULL) {
- int jid;
-
if (jail_name[0] == '\0')
Usage("invalid jail name");
@@ -239,18 +237,25 @@
static int
ReadFile(FILE *fp)
{
- char line[LINE_MAX];
- int num, rtn;
-
- for (num = 1; fgets(line, sizeof(line), fp) != NULL; num++) {
+ char *line = NULL;
+ ssize_t len;
+ size_t sz = 0;
+ unsigned int lineno = 0;
+ int rtn = CMDRTN_OK;
+
+ while ((len = getline(&line, &sz, fp)) > 0) {
+ lineno++;
if (*line == '#')
continue;
- if ((rtn = DoParseCommand(line)) != 0) {
- warnx("line %d: error in file", num);
- return (rtn);
+ if ((rtn = DoParseCommand(line)) != CMDRTN_OK) {
+ warnx("line %d: error in file", lineno);
+ break;
}
}
- return (CMDRTN_OK);
+ if (len < 0)
+ rtn = CMDRTN_ERROR;
+ free(line);
+ return (rtn);
}
#ifdef EDITLINE
@@ -258,7 +263,6 @@
static void
Unblock(int signal __unused)
{
-
unblock = 1;
}
@@ -269,8 +273,11 @@
static void *
Monitor(void *v __unused)
{
+ struct pollfd pfds[2] = {
+ { .fd = csock, .events = POLLIN },
+ { .fd = dsock, .events = POLLIN },
+ };
struct sigaction act;
- const int maxfd = MAX(csock, dsock) + 1;
act.sa_handler = Unblock;
sigemptyset(&act.sa_mask);
@@ -279,22 +286,19 @@
pthread_mutex_lock(&mutex);
for (;;) {
- fd_set rfds;
-
- /* See if any data or control messages are arriving. */
- FD_ZERO(&rfds);
- FD_SET(csock, &rfds);
- FD_SET(dsock, &rfds);
unblock = 0;
- if (select(maxfd, &rfds, NULL, NULL, NULL) <= 0) {
+ if (poll(pfds, 2, INFTIM) <= 0) {
if (errno == EINTR) {
if (unblock == 1)
pthread_cond_wait(&cond, &mutex);
continue;
}
- err(EX_OSERR, "select");
+ err(EX_OSERR, "poll");
}
- ReadSockets(&rfds);
+ if (pfds[0].revents != 0)
+ ReadCtrlSocket();
+ if (pfds[1].revents != 0)
+ ReadDataSocket();
}
return (NULL);
@@ -303,7 +307,6 @@
static char *
Prompt(EditLine *el __unused)
{
-
return (PROMPT);
}
@@ -376,49 +379,48 @@
static int
DoInteractive(void)
{
- const int maxfd = MAX(csock, dsock) + 1;
+ struct pollfd pfds[3] = {
+ { .fd = csock, .events = POLLIN },
+ { .fd = dsock, .events = POLLIN },
+ { .fd = STDIN_FILENO, .events = POLLIN },
+ };
+ char *line = NULL;
+ ssize_t len;
+ size_t sz = 0;
(*help_cmd.func)(0, NULL);
- while (1) {
- struct timeval tv;
- fd_set rfds;
-
+ for (;;) {
/* See if any data or control messages are arriving */
- FD_ZERO(&rfds);
- FD_SET(csock, &rfds);
- FD_SET(dsock, &rfds);
- memset(&tv, 0, sizeof(tv));
- if (select(maxfd, &rfds, NULL, NULL, &tv) <= 0) {
-
+ if (poll(pfds, 2, 0) <= 0) {
/* Issue prompt and wait for anything to happen */
printf("%s", PROMPT);
fflush(stdout);
- FD_ZERO(&rfds);
- FD_SET(0, &rfds);
- FD_SET(csock, &rfds);
- FD_SET(dsock, &rfds);
- if (select(maxfd, &rfds, NULL, NULL, NULL) < 0)
- err(EX_OSERR, "select");
-
- /* If not user input, print a newline first */
- if (!FD_ISSET(0, &rfds))
- printf("\n");
+ if (poll(pfds, 3, INFTIM) < 0 && errno != EINTR)
+ err(EX_OSERR, "poll");
+ } else {
+ pfds[2].revents = 0;
}
- ReadSockets(&rfds);
+ /* If not user input, print a newline first */
+ if (pfds[2].revents == 0)
+ printf("\n");
+
+ if (pfds[0].revents != 0)
+ ReadCtrlSocket();
+ if (pfds[1].revents != 0)
+ ReadDataSocket();
/* Get any user input */
- if (FD_ISSET(0, &rfds)) {
- char buf[LINE_MAX];
-
- if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ if (pfds[2].revents != 0) {
+ if ((len = getline(&line, &sz, stdin)) <= 0) {
printf("\n");
break;
}
- if (DoParseCommand(buf) == CMDRTN_QUIT)
+ if (DoParseCommand(line) == CMDRTN_QUIT)
break;
}
}
+ free(line);
return (CMDRTN_QUIT);
}
#endif /* !EDITLINE */
@@ -427,29 +429,28 @@
* Read and process data on netgraph control and data sockets.
*/
static void
-ReadSockets(fd_set *rfds)
+ReadCtrlSocket(void)
{
- /* Display any incoming control message. */
- if (FD_ISSET(csock, rfds))
- MsgRead();
-
- /* Display any incoming data packet. */
- if (FD_ISSET(dsock, rfds)) {
- char hook[NG_HOOKSIZ];
- u_char *buf;
- int rl;
-
- /* Read packet from socket. */
- if ((rl = NgAllocRecvData(dsock, &buf, hook)) < 0)
- err(EX_OSERR, "reading hook \"%s\"", hook);
- if (rl == 0)
- errx(EX_OSERR, "EOF from hook \"%s\"?", hook);
-
- /* Write packet to stdout. */
- printf("Rec'd data packet on hook \"%s\":\n", hook);
- DumpAscii(buf, rl);
- free(buf);
- }
+ MsgRead();
+}
+
+static void
+ReadDataSocket(void)
+{
+ char hook[NG_HOOKSIZ];
+ u_char *buf;
+ int rl;
+
+ /* Read packet from socket. */
+ if ((rl = NgAllocRecvData(dsock, &buf, hook)) < 0)
+ err(EX_OSERR, "reading hook \"%s\"", hook);
+ if (rl == 0)
+ errx(EX_OSERR, "EOF from hook \"%s\"?", hook);
+
+ /* Write packet to stdout. */
+ printf("Rec'd data packet on hook \"%s\":\n", hook);
+ DumpAscii(buf, rl);
+ free(buf);
}
/*
@@ -561,6 +562,8 @@
/* Process it */
rtn = ReadFile(fp);
+ if (ferror(fp))
+ warn("%s", av[1]);
fclose(fp);
return (rtn);
}
@@ -572,7 +575,9 @@
HelpCmd(int ac, char **av)
{
const struct ngcmd *cmd;
- int k;
+ const char *s;
+ const int maxcol = 63;
+ int a, k, len;
switch (ac) {
case 0:
@@ -580,13 +585,11 @@
/* Show all commands */
printf("Available commands:\n");
for (k = 0; cmds[k] != NULL; k++) {
- char *s, buf[100];
-
cmd = cmds[k];
- snprintf(buf, sizeof(buf), "%s", cmd->cmd);
- for (s = buf; *s != '\0' && !isspace(*s); s++);
- *s = '\0';
- printf(" %-10s %s\n", buf, cmd->desc);
+ for (s = cmd->cmd; *s != '\0' && !isspace(*s); s++)
+ /* nothing */;
+ printf(" %.*s%*s %s\n", (int)(s - cmd->cmd), cmd->cmd,
+ (int)(10 - (s - cmd->cmd)), "", cmd->desc);
}
return (CMDRTN_OK);
default:
@@ -594,40 +597,29 @@
if ((cmd = FindCommand(av[1])) != NULL) {
printf("usage: %s\n", cmd->cmd);
if (cmd->aliases[0] != NULL) {
- int a = 0;
-
printf("Aliases: ");
- while (1) {
- printf("%s", cmd->aliases[a++]);
- if (a == MAX_CMD_ALIAS
- || cmd->aliases[a] == NULL) {
- printf("\n");
- break;
- }
- printf(", ");
+ for (a = 0; a < MAX_CMD_ALIAS &&
+ cmd->aliases[a] != NULL; a++) {
+ if (a > 0)
+ printf(", ");
+ printf("%s", cmd->aliases[a]);
}
+ printf("\n");
}
printf("Summary: %s\n", cmd->desc);
- if (cmd->help != NULL) {
- const char *s;
- char buf[65];
- int tot, len, done;
-
- printf("Description:\n");
- for (s = cmd->help; *s != '\0'; s += len) {
- while (isspace(*s))
- s++;
- tot = snprintf(buf,
- sizeof(buf), "%s", s);
- len = strlen(buf);
- done = len == tot;
- if (!done) {
- while (len > 0
- && !isspace(buf[len-1]))
- buf[--len] = '\0';
- }
- printf(" %s\n", buf);
- }
+ if (cmd->help == NULL)
+ break;
+ printf("Description:\n");
+ for (s = cmd->help; *s != '\0'; s += len) {
+ while (isspace(*s))
+ s++;
+ /* advance to the column limit */
+ for (len = 0; s[len] && len < maxcol; len++)
+ /* nothing */;
+ /* back up to previous interword space */
+ while (len > 0 && s[len] && !isblank(s[len]))
+ len--;
+ printf(" %.*s\n", len, s);
}
}
}
@@ -649,34 +641,27 @@
void
DumpAscii(const u_char *buf, int len)
{
- char ch, sbuf[100];
int k, count;
for (count = 0; count < len; count += DUMP_BYTES_PER_LINE) {
- snprintf(sbuf, sizeof(sbuf), "%04x: ", count);
+ printf("%04x: ", count);
for (k = 0; k < DUMP_BYTES_PER_LINE; k++) {
if (count + k < len) {
- snprintf(sbuf + strlen(sbuf),
- sizeof(sbuf) - strlen(sbuf),
- "%02x ", buf[count + k]);
+ printf("%02x ", buf[count + k]);
} else {
- snprintf(sbuf + strlen(sbuf),
- sizeof(sbuf) - strlen(sbuf), " ");
+ printf(" ");
}
}
- snprintf(sbuf + strlen(sbuf), sizeof(sbuf) - strlen(sbuf), " ");
+ printf(" ");
for (k = 0; k < DUMP_BYTES_PER_LINE; k++) {
if (count + k < len) {
- ch = isprint(buf[count + k]) ?
- buf[count + k] : '.';
- snprintf(sbuf + strlen(sbuf),
- sizeof(sbuf) - strlen(sbuf), "%c", ch);
+ printf("%c", isprint(buf[count + k]) ?
+ buf[count + k] : '.');
} else {
- snprintf(sbuf + strlen(sbuf),
- sizeof(sbuf) - strlen(sbuf), " ");
+ printf(" ");
}
}
- printf("%s\n", sbuf);
+ printf("\n");
}
}
diff --git a/usr.sbin/ngctl/mkpeer.c b/usr.sbin/ngctl/mkpeer.c
--- a/usr.sbin/ngctl/mkpeer.c
+++ b/usr.sbin/ngctl/mkpeer.c
@@ -1,10 +1,9 @@
-
/*
* mkpeer.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -85,4 +84,3 @@
}
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/msg.c b/usr.sbin/ngctl/msg.c
--- a/usr.sbin/ngctl/msg.c
+++ b/usr.sbin/ngctl/msg.c
@@ -1,10 +1,9 @@
-
/*
* msg.c
*
* Copyright (c) 1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -37,9 +36,9 @@
* $Whistle: msg.c,v 1.2 1999/11/29 23:38:35 archie Exp $
*/
-#include <sys/cdefs.h>
#include <err.h>
#include <netgraph.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -64,6 +63,9 @@
static int
MsgCmd(int ac, char **av)
{
+ struct pollfd pfds[1] = {
+ { .fd = csock, .events = POLLIN },
+ };
char *buf;
char *path, *cmdstr;
int i, len;
@@ -95,22 +97,14 @@
free(buf);
/* See if a synchronous reply awaits */
- {
- struct timeval tv;
- fd_set rfds;
-
- FD_ZERO(&rfds);
- FD_SET(csock, &rfds);
- memset(&tv, 0, sizeof(tv));
- switch (select(csock + 1, &rfds, NULL, NULL, &tv)) {
- case -1:
- err(EX_OSERR, "select");
- case 0:
- break;
- default:
- MsgRead();
- break;
- }
+ switch (poll(pfds, 1, 0)) {
+ case -1:
+ err(EX_OSERR, "poll");
+ case 0:
+ break;
+ default:
+ MsgRead();
+ break;
}
/* Done */
@@ -135,8 +129,8 @@
/* Ask originating node to convert message to ASCII */
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
- NGM_BINARY2ASCII, m, sizeof(*m) + m->header.arglen) < 0
- || NgAllocRecvMsg(csock, &m2, NULL) < 0) {
+ NGM_BINARY2ASCII, m, sizeof(*m) + m->header.arglen) < 0 ||
+ NgAllocRecvMsg(csock, &m2, NULL) < 0) {
printf("Rec'd %s %d from \"%s\":\n",
(m->header.flags & NGF_RESP) != 0 ? "response" : "command",
m->header.cmd, path);
@@ -160,4 +154,3 @@
printf("No arguments\n");
free(m2);
}
-
diff --git a/usr.sbin/ngctl/name.c b/usr.sbin/ngctl/name.c
--- a/usr.sbin/ngctl/name.c
+++ b/usr.sbin/ngctl/name.c
@@ -1,10 +1,9 @@
-
/*
* name.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -76,4 +75,3 @@
}
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/rmhook.c b/usr.sbin/ngctl/rmhook.c
--- a/usr.sbin/ngctl/rmhook.c
+++ b/usr.sbin/ngctl/rmhook.c
@@ -1,10 +1,9 @@
-
/*
* rmhook.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -81,4 +80,3 @@
}
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/show.c b/usr.sbin/ngctl/show.c
--- a/usr.sbin/ngctl/show.c
+++ b/usr.sbin/ngctl/show.c
@@ -1,10 +1,9 @@
-
/*
* show.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -67,13 +66,13 @@
int ch, no_hooks = 0;
/* Get options */
+ optreset = 1;
optind = 1;
while ((ch = getopt(ac, av, "n")) != -1) {
switch (ch) {
case 'n':
no_hooks = 1;
break;
- case '?':
default:
return (CMDRTN_USAGE);
break;
@@ -133,5 +132,3 @@
free(resp);
return (CMDRTN_OK);
}
-
-
diff --git a/usr.sbin/ngctl/shutdown.c b/usr.sbin/ngctl/shutdown.c
--- a/usr.sbin/ngctl/shutdown.c
+++ b/usr.sbin/ngctl/shutdown.c
@@ -1,10 +1,9 @@
-
/*
* shutdown.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -73,5 +72,3 @@
}
return (CMDRTN_OK);
}
-
-
diff --git a/usr.sbin/ngctl/status.c b/usr.sbin/ngctl/status.c
--- a/usr.sbin/ngctl/status.c
+++ b/usr.sbin/ngctl/status.c
@@ -1,10 +1,9 @@
-
/*
* status.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -84,8 +83,8 @@
return (CMDRTN_ERROR);
}
} else {
- if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
- || (resp->header.flags & NGF_RESP) == 0)
+ if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0 ||
+ (resp->header.flags & NGF_RESP) == 0)
nostat = 1;
}
@@ -96,4 +95,3 @@
printf("Status for \"%s\":\n%s\n", path, status);
return (CMDRTN_OK);
}
-
diff --git a/usr.sbin/ngctl/types.c b/usr.sbin/ngctl/types.c
--- a/usr.sbin/ngctl/types.c
+++ b/usr.sbin/ngctl/types.c
@@ -1,10 +1,9 @@
-
/*
* types.c
*
* Copyright (c) 1996-1999 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
@@ -15,7 +14,7 @@
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -96,4 +95,3 @@
free(resp);
return (rtn);
}
-
diff --git a/usr.sbin/ngctl/write.c b/usr.sbin/ngctl/write.c
--- a/usr.sbin/ngctl/write.c
+++ b/usr.sbin/ngctl/write.c
@@ -1,17 +1,16 @@
-
/*
* write.c
*
* Copyright (c) 2002 Archie L. Cobbs
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Archie L. Cobbs;
* provided, however, that:
* 1. Any and all reproductions of the source or object code must include the
* copyright notice above and the following disclaimer of warranties
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY ARCHIE L. COBBS AS IS", AND TO
* THE MAXIMUM EXTENT PERMITTED BY LAW, ARCHIE L. COBBS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
@@ -92,8 +91,8 @@
fclose(fp);
} else {
for (i = 2, len = 0; i < ac && len < sizeof(buf); i++, len++) {
- if (sscanf(av[i], "%i", &byte) != 1
- || (byte < -128 || byte > 255)) {
+ if (sscanf(av[i], "%i", &byte) != 1 ||
+ byte < -128 || byte > 255) {
warnx("invalid byte \"%s\"", av[i]);
return (CMDRTN_ERROR);
}
@@ -116,4 +115,3 @@
/* Done */
return (CMDRTN_OK);
}
-
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 15, 1:32 PM (5 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28743022
Default Alt Text
D55257.id171867.diff (27 KB)
Attached To
Mode
D55257: ngctl: Modernize code somewhat
Attached
Detach File
Event Timeline
Log In to Comment