Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 May 2006 12:05:37 +0900
From:      Ganbold <ganbold@micom.mng.net>
To:        Gleb Smirnoff <glebius@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/ngctl config.c connect.c debug.c dot.c list.c main.c mkpeer.c msg.c name.c ngctl.h rmhook.c show.c shutdown.c status.c types.c write.c
Message-ID:  <44751F01.4030702@micom.mng.net>
In-Reply-To: <200605241446.k4OEkvo0011251@repoman.freebsd.org>
References:  <200605241446.k4OEkvo0011251@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040302050803050800090308
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gleb Smirnoff wrote:
> glebius     2006-05-24 14:46:56 UTC
>
>   FreeBSD src repository
>
>   Modified files:
>     usr.sbin/ngctl       config.c connect.c debug.c dot.c list.c 
>                          main.c mkpeer.c msg.c name.c ngctl.h 
>                          rmhook.c show.c shutdown.c status.c 
>                          types.c write.c 
>   Log:
>   Unnest includes before forthcoming editing.
>   
>   Revision  Changes    Path
>   1.4       +7 -0      src/usr.sbin/ngctl/config.c
>   1.4       +4 -0      src/usr.sbin/ngctl/connect.c
>   1.3       +5 -0      src/usr.sbin/ngctl/debug.c
>   1.4       +5 -0      src/usr.sbin/ngctl/dot.c
>   1.7       +6 -0      src/usr.sbin/ngctl/list.c
>   1.19      +16 -0     src/usr.sbin/ngctl/main.c
>   1.3       +4 -0      src/usr.sbin/ngctl/mkpeer.c
>   1.6       +8 -0      src/usr.sbin/ngctl/msg.c
>   1.3       +5 -0      src/usr.sbin/ngctl/name.c
>   1.13      +0 -20     src/usr.sbin/ngctl/ngctl.h
>   1.4       +4 -0      src/usr.sbin/ngctl/rmhook.c
>   1.5       +6 -0      src/usr.sbin/ngctl/show.c
>   1.3       +5 -1      src/usr.sbin/ngctl/shutdown.c
>   1.3       +5 -0      src/usr.sbin/ngctl/status.c
>   1.5       +6 -0      src/usr.sbin/ngctl/types.c
>   1.2       +10 -0     src/usr.sbin/ngctl/write.c
> _______________________________________________
> cvs-all@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/cvs-all
> To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
>
>
>
>   
Gleb,

I modified my previous patch accordingly. Hopefully it follows style(9) 
more; removed typedef, changed function names to follow original 
function naming styles in code, space after return statements according 
to style(9).

thanks,

Ganbold


--------------040302050803050800090308
Content-Type: text/x-patch;
 name="ngctl.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ngctl.patch"

diff -u /usr/src/usr.sbin/ngctl/config.c /usr/home/tsgan/ngctl/config.c
--- /usr/src/usr.sbin/ngctl/config.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/config.c	Thu May 25 10:29:53 2006
@@ -69,7 +69,7 @@
 
 	/* Get arguments */
 	if (ac < 2)
-		return(CMDRTN_USAGE);
+		return (CMDRTN_USAGE);
 	path = av[1];
 
 	*buf = '\0';
@@ -93,7 +93,7 @@
 			break;
 		default:
 			warn("send msg");
-			return(CMDRTN_ERROR);
+			return (CMDRTN_ERROR);
 		}
 	} else {
 		if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
@@ -106,6 +106,6 @@
 		printf("No config available for \"%s\"\n", path);
 	else
 		printf("Config for \"%s\":\n%s\n", path, status);
-	return(CMDRTN_OK);
+	return (CMDRTN_OK);
 }
 
diff -u /usr/src/usr.sbin/ngctl/connect.c /usr/home/tsgan/ngctl/connect.c
--- /usr/src/usr.sbin/ngctl/connect.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/connect.c	Thu May 25 10:30:13 2006
@@ -76,15 +76,15 @@
 		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);
 }
 
diff -u /usr/src/usr.sbin/ngctl/debug.c /usr/home/tsgan/ngctl/debug.c
--- /usr/src/usr.sbin/ngctl/debug.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/debug.c	Thu May 25 10:30:31 2006
@@ -70,15 +70,15 @@
 		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);
 }
 
diff -u /usr/src/usr.sbin/ngctl/list.c /usr/home/tsgan/ngctl/list.c
--- /usr/src/usr.sbin/ngctl/list.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/list.c	Thu May 25 10:31:59 2006
@@ -83,7 +83,7 @@
 			break;
 		case '?':
 		default:
-			return(CMDRTN_USAGE);
+			return (CMDRTN_USAGE);
 			break;
 		}
 	}
@@ -95,18 +95,18 @@
 	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 */
diff -u /usr/src/usr.sbin/ngctl/main.c /usr/home/tsgan/ngctl/main.c
--- /usr/src/usr.sbin/ngctl/main.c	Wed May 24 23:46:55 2006
+++ /usr/home/tsgan/ngctl/main.c	Thu May 25 11:47:59 2006
@@ -50,6 +50,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sysexits.h>
+#include <termios.h>
 #include <unistd.h>
 
 #include <netgraph.h>
@@ -61,6 +62,13 @@
 #define WHITESPACE		" \t\r\n\v\f"
 #define DUMP_BYTES_PER_LINE	16
 
+/* Previously issued commands list */
+struct cmdlist {
+	char		*cmd;	/* command */
+	struct cmdlist	*prev;	/* previous command */
+	struct cmdlist	*next;	/* next command */
+};
+
 /* Internal functions */
 static int	ReadFile(FILE *fp);
 static int	DoParseCommand(char *line);
@@ -72,6 +80,11 @@
 static int	ReadCmd(int ac, char **av);
 static int	HelpCmd(int ac, char **av);
 static int	QuitCmd(int ac, char **av);
+static int	ScanCmd(char *cmd, struct cmdlist **curr);
+static struct	cmdlist *AddCmd(char *cmd);
+static struct	cmdlist *GetNextCmd(struct cmdlist *curr);
+static struct	cmdlist *GetPrevCmd(struct cmdlist *curr);
+static void	RemoveCmd(struct cmdlist *p);
 
 /* List of commands */
 static const struct ngcmd *const cmds[] = {
@@ -118,9 +131,16 @@
 	{ "exit" }
 };
 
+/* Head and tail commands in commands list */
+struct cmdlist *headcmd = NULL;
+struct cmdlist *tailcmd = NULL;
+
 /* Our control and data sockets */
 int	csock, dsock;
 
+/* this variable must be set go to previous command in history list */
+int	goprev;
+
 /*
  * main()
  */
@@ -188,7 +208,7 @@
 		rtn = EX_OSERR;
 		break;
 	}
-	return(rtn);
+	return (rtn);
 }
 
 /*
@@ -205,10 +225,10 @@
 			continue;
 		if ((rtn = DoParseCommand(line)) != 0) {
 			warnx("line %d: error in file", num);
-			return(rtn);
+			return (rtn);
 		}
 	}
-	return(CMDRTN_OK);
+	return (CMDRTN_OK);
 }
 
 /*
@@ -218,12 +238,25 @@
 DoInteractive(void)
 {
 	const int maxfd = MAX(csock, dsock) + 1;
+	struct cmdlist *curr;
+	int scan_status = 0;
+	struct termios new_settings;
+	struct termios stored_settings;
 
 	(*help_cmd.func)(0, NULL);
 	while (1) {
 		struct timeval tv;
 		fd_set rfds;
 
+               /* record the old settings to restore the terminal when finished */
+		tcgetattr(0, &stored_settings);
+		new_settings = stored_settings;
+
+		/* set things up for character-at-a-time */
+		new_settings.c_lflag &= ~(ECHO | ECHOK | ICANON);
+		new_settings.c_cc[VTIME] = 1;
+		tcsetattr(0, TCSANOW, &new_settings);
+
 		/* See if any data or control messages are arriving */
 		FD_ZERO(&rfds);
 		FD_SET(csock, &rfds);
@@ -272,15 +305,27 @@
 		if (FD_ISSET(0, &rfds)) {
 			char buf[LINE_MAX];
 
-			if (fgets(buf, sizeof(buf), stdin) == NULL) {
-				printf("\n");
-				break;
+			/* always begin from last command */
+			goprev = 0;
+			memset(buf, 0, LINE_MAX);
+
+			scan_status = ScanCmd(buf, &curr);
+			if (scan_status == 0) {
+				rewind(stdin);
+				continue;
 			}
+			snprintf(buf, LINE_MAX, "%s", curr->cmd);
 			if (DoParseCommand(buf) == CMDRTN_QUIT)
 				break;
 		}
+		/* restore the old settings */
+		tcsetattr(0, TCSANOW, &stored_settings);
 	}
-	return(CMDRTN_QUIT);
+	/* destroy commands */
+	while (headcmd != NULL)
+		RemoveCmd(headcmd);
+
+	return (CMDRTN_QUIT);
 }
 
 /*
@@ -298,7 +343,7 @@
 	    av[++ac] = strtok(NULL, WHITESPACE));
 
 	/* Do command */
-	return(DoCommand(ac, av));
+	return (DoCommand(ac, av));
 }
 
 /*
@@ -311,12 +356,12 @@
 	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 +376,16 @@
 		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 +428,17 @@
 	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 +464,7 @@
 			*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 +507,7 @@
 			}
 		}
 	}
-	return(CMDRTN_OK);
+	return (CMDRTN_OK);
 }
 
 /*
@@ -471,7 +516,179 @@
 static int
 QuitCmd(int ac __unused, char **av __unused)
 {
-	return(CMDRTN_QUIT);
+	return (CMDRTN_QUIT);
+}
+
+/*
+ * Get commands from stdin, up/down arrow keys handling
+ */
+static int
+ScanCmd(char *cmd, struct cmdlist **curr)
+{
+	struct cmdlist *p;
+	int c, i, j, finished;
+
+	p = *curr;
+	c = 1; i = 0; finished = 0;
+
+	while (c && !finished && i < LINE_MAX) {
+		c = getchar();
+		switch (c) {
+			case '\t':
+				printf("tab\n");
+				break;
+			case '\n':
+				finished = 1;
+				putchar('\n');
+				if (i > 0) {
+					cmd[i] = '\0';
+					p = AddCmd(cmd);
+				}
+				break;
+			case 8:
+				/* backspace */
+			case 127:
+				/* delete */
+				if (i > 0) {
+					cmd[--i] = '\0';
+					putchar(8); putchar(' '); putchar(8);
+				}
+				break;
+			case 27:
+				/* ESC
+				 * Check up/down arrow keys
+				 */
+				c = getchar();
+				if (c == 91) {
+					/* it looks like we have an arrow key here */
+					c = getchar();
+					if (c > 68 || c < 65) {
+						/* ignore right/left arrow keys, put the characters back in the queue
+						 *(except for the ESC)
+						 */
+						ungetc(c, stdin);
+						ungetc(91, stdin);
+					} else if (c == 65) {
+						/* up arrow key */
+						for (j=0 ; j < i; j++) {
+							putchar(8); putchar(' '); putchar(8);
+						}
+						p = GetPrevCmd(p);
+						if (p != NULL) {
+							printf("%s", p->cmd);
+							cmd = strdup(p->cmd);
+							i = strlen(cmd);
+						}
+					} else if (c == 66) {
+						/* down arrow key */
+						for (j=0 ; j < i; j++) {
+							putchar(8); putchar(' '); putchar(8);
+						}
+						p = GetNextCmd(p);
+						if(p != NULL) {
+							printf("%s", p->cmd);
+							cmd = strdup(p->cmd);
+							i = strlen(cmd);
+						}
+					}
+				} else
+					/* not an arrow key, put the char back */
+					ungetc(c, stdin);
+				break;
+
+			default:
+				cmd[i++] = c;
+				putchar(c);
+				break;
+		}
+	}
+	*curr = p;
+
+	return (strlen(cmd));
+}
+
+/*
+ * add new command to the command list
+ */
+static struct cmdlist
+*AddCmd(char *cmd)
+{
+	struct cmdlist *p;
+
+	p = (struct cmdlist *) malloc(sizeof(struct cmdlist));
+
+	if (p == NULL || (p->cmd = strdup(cmd)) == NULL) {
+		warn("malloc");
+		exit (CMDRTN_ERROR);
+	}
+
+	if (headcmd == NULL) {
+		headcmd = p;
+		p->prev = NULL;
+	} else {
+		tailcmd->next = p;
+		p->prev = tailcmd;
+	}
+	tailcmd = p;
+	p->next = NULL;
+	return (p);
+ }
+
+/*
+ * Get next command from the command list
+ */
+static struct cmdlist
+*GetNextCmd(struct cmdlist *curr)
+{
+	struct cmdlist *p;
+
+	p = curr;
+
+	/* if current command is not latest in a command list, get next command */
+	if (p != tailcmd && p != NULL)
+		p = p->next;
+
+	return (p);
+}
+
+/*
+ * Get previous command from the command list
+ */
+static struct cmdlist
+*GetPrevCmd(struct cmdlist *curr)
+{
+	struct cmdlist *p;
+
+	p = curr;
+
+	if (p == tailcmd && goprev != 1) {
+		goprev = 1;
+		return (p);
+	}
+
+	/* if current command is not first in a command list, get previous command */
+	if (goprev && p != headcmd && p != NULL)
+		p = p->prev;
+
+	return (p);
+}
+
+/*
+ * remove commands from the list
+ */
+static void
+RemoveCmd(struct cmdlist *p)
+{
+
+	if (p->prev == NULL)
+		headcmd = p->next;
+	else
+		p->prev->next = p->next;
+
+	if (p->next == NULL)
+		tailcmd = p->prev;
+	else
+		p->next->prev = p->prev;
 }
 
 /*
diff -u /usr/src/usr.sbin/ngctl/mkpeer.c /usr/home/tsgan/ngctl/mkpeer.c
--- /usr/src/usr.sbin/ngctl/mkpeer.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/mkpeer.c	Thu May 25 10:33:38 2006
@@ -76,15 +76,15 @@
 		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);
 }
 
diff -u /usr/src/usr.sbin/ngctl/msg.c /usr/home/tsgan/ngctl/msg.c
--- /usr/src/usr.sbin/ngctl/msg.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/msg.c	Thu May 25 10:34:03 2006
@@ -70,7 +70,7 @@
 
 	/* Get arguments */
 	if (ac < 3)
-		return(CMDRTN_USAGE);
+		return (CMDRTN_USAGE);
 	path = av[1];
 	cmdstr = av[2];
 
@@ -79,7 +79,7 @@
 		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 @@
 	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 @@
 	}
 
 	/* Done */
-	return(CMDRTN_OK);
+	return (CMDRTN_OK);
 }
 
 /*
diff -u /usr/src/usr.sbin/ngctl/name.c /usr/home/tsgan/ngctl/name.c
--- /usr/src/usr.sbin/ngctl/name.c	Thu May 25 10:26:32 2006
+++ /usr/home/tsgan/ngctl/name.c	Thu May 25 10:34:32 2006
@@ -67,15 +67,15 @@
 		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);
 }
 
Only in /usr/home/tsgan/ngctl: ngctl.patch
diff -u /usr/src/usr.sbin/ngctl/rmhook.c /usr/home/tsgan/ngctl/rmhook.c
--- /usr/src/usr.sbin/ngctl/rmhook.c	Thu May 25 10:26:33 2006
+++ /usr/home/tsgan/ngctl/rmhook.c	Thu May 25 10:34:46 2006
@@ -72,15 +72,15 @@
 		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);
 }
 
diff -u /usr/src/usr.sbin/ngctl/show.c /usr/home/tsgan/ngctl/show.c
--- /usr/src/usr.sbin/ngctl/show.c	Thu May 25 10:26:33 2006
+++ /usr/home/tsgan/ngctl/show.c	Thu May 25 10:35:06 2006
@@ -77,7 +77,7 @@
 			break;
 		case '?':
 		default:
-			return(CMDRTN_USAGE);
+			return (CMDRTN_USAGE);
 			break;
 		}
 	}
@@ -90,18 +90,18 @@
 		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 @@
 		}
 	}
 	free(resp);
-	return(CMDRTN_OK);
+	return (CMDRTN_OK);
 }
 
 
diff -u /usr/src/usr.sbin/ngctl/shutdown.c /usr/home/tsgan/ngctl/shutdown.c
--- /usr/src/usr.sbin/ngctl/shutdown.c	Thu May 25 10:26:33 2006
+++ /usr/home/tsgan/ngctl/shutdown.c	Thu May 25 10:35:47 2006
@@ -64,16 +64,16 @@
 		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);
 }
 
 
diff -u /usr/src/usr.sbin/ngctl/status.c /usr/home/tsgan/ngctl/status.c
--- /usr/src/usr.sbin/ngctl/status.c	Thu May 25 10:26:33 2006
+++ /usr/home/tsgan/ngctl/status.c	Thu May 25 10:36:03 2006
@@ -71,7 +71,7 @@
 		path = av[1];
 		break;
 	default:
-		return(CMDRTN_USAGE);
+		return (CMDRTN_USAGE);
 	}
 
 	/* Get node status summary */
@@ -83,7 +83,7 @@
 			break;
 		default:
 			warn("send msg");
-			return(CMDRTN_ERROR);
+			return (CMDRTN_ERROR);
 		}
 	} else {
 		if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
@@ -96,6 +96,6 @@
 		printf("No status available for \"%s\"\n", path);
 	else
 		printf("Status for \"%s\":\n%s\n", path, status);
-	return(CMDRTN_OK);
+	return (CMDRTN_OK);
 }
 
diff -u /usr/src/usr.sbin/ngctl/types.c /usr/home/tsgan/ngctl/types.c
--- /usr/src/usr.sbin/ngctl/types.c	Thu May 25 10:26:33 2006
+++ /usr/home/tsgan/ngctl/types.c	Thu May 25 10:36:22 2006
@@ -68,18 +68,18 @@
 	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 */
diff -u /usr/src/usr.sbin/ngctl/write.c /usr/home/tsgan/ngctl/write.c
--- /usr/src/usr.sbin/ngctl/write.c	Thu May 25 10:26:33 2006
+++ /usr/home/tsgan/ngctl/write.c	Thu May 25 10:37:01 2006
@@ -72,16 +72,16 @@
 
 	/* 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 @@
 			else
 				warnx("file \"%s\" is empty", av[3]);
 			fclose(fp);
-			return(CMDRTN_ERROR);
+			return (CMDRTN_ERROR);
 		}
 		fclose(fp);
 	} else {
@@ -97,12 +97,12 @@
 			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 @@
 	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);
 }
 

--------------040302050803050800090308--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44751F01.4030702>