Deleted Added
full compact
main.c (166529) main.c (180076)
1
2/*
3 * main.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 20 unchanged lines hidden (view full) ---

29 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
1
2/*
3 * main.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 20 unchanged lines hidden (view full) ---

29 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * $FreeBSD: head/usr.sbin/ngctl/main.c 166529 2007-02-06 08:48:28Z kevlo $
37 * $FreeBSD: head/usr.sbin/ngctl/main.c 180076 2008-06-28 12:31:30Z mtm $
38 * $Whistle: main.c,v 1.12 1999/11/29 19:17:46 archie Exp $
39 */
40
41#include <sys/param.h>
42#include <sys/socket.h>
43#include <sys/select.h>
44
45#include <ctype.h>

--- 18 unchanged lines hidden (view full) ---

64#define PROMPT "+ "
65#define MAX_ARGS 512
66#define WHITESPACE " \t\r\n\v\f"
67#define DUMP_BYTES_PER_LINE 16
68
69/* Internal functions */
70static int ReadFile(FILE *fp);
71static void ReadSockets(fd_set *);
38 * $Whistle: main.c,v 1.12 1999/11/29 19:17:46 archie Exp $
39 */
40
41#include <sys/param.h>
42#include <sys/socket.h>
43#include <sys/select.h>
44
45#include <ctype.h>

--- 18 unchanged lines hidden (view full) ---

64#define PROMPT "+ "
65#define MAX_ARGS 512
66#define WHITESPACE " \t\r\n\v\f"
67#define DUMP_BYTES_PER_LINE 16
68
69/* Internal functions */
70static int ReadFile(FILE *fp);
71static void ReadSockets(fd_set *);
72static int DoParseCommand(char *line);
72static int DoParseCommand(const char *line);
73static int DoCommand(int ac, char **av);
74static int DoInteractive(void);
75static const struct ngcmd *FindCommand(const char *string);
76static int MatchCommand(const struct ngcmd *cmd, const char *s);
77static void Usage(const char *msg);
78static int ReadCmd(int ac, char **av);
79static int HelpCmd(int ac, char **av);
80static int QuitCmd(int ac, char **av);

--- 236 unchanged lines hidden (view full) ---

317
318 if ((buf = el_gets(el, &count)) == NULL) {
319 printf("\n");
320 break;
321 }
322 history(hist, &hev, H_ENTER, buf);
323 pthread_kill(monitor, SIGUSR1);
324 pthread_mutex_lock(&mutex);
73static int DoCommand(int ac, char **av);
74static int DoInteractive(void);
75static const struct ngcmd *FindCommand(const char *string);
76static int MatchCommand(const struct ngcmd *cmd, const char *s);
77static void Usage(const char *msg);
78static int ReadCmd(int ac, char **av);
79static int HelpCmd(int ac, char **av);
80static int QuitCmd(int ac, char **av);

--- 236 unchanged lines hidden (view full) ---

317
318 if ((buf = el_gets(el, &count)) == NULL) {
319 printf("\n");
320 break;
321 }
322 history(hist, &hev, H_ENTER, buf);
323 pthread_kill(monitor, SIGUSR1);
324 pthread_mutex_lock(&mutex);
325 if (DoParseCommand((char *)buf) == CMDRTN_QUIT)
325 if (DoParseCommand(buf) == CMDRTN_QUIT)
326 break;
327 pthread_cond_signal(&cond);
328 pthread_mutex_unlock(&mutex);
329 }
330
331 history_end(hist);
332 el_end(el);
333 pthread_cancel(monitor);

--- 84 unchanged lines hidden (view full) ---

418 free(buf);
419 }
420}
421
422/*
423 * Parse a command line and execute the command
424 */
425static int
326 break;
327 pthread_cond_signal(&cond);
328 pthread_mutex_unlock(&mutex);
329 }
330
331 history_end(hist);
332 el_end(el);
333 pthread_cancel(monitor);

--- 84 unchanged lines hidden (view full) ---

418 free(buf);
419 }
420}
421
422/*
423 * Parse a command line and execute the command
424 */
425static int
426DoParseCommand(char *line)
426DoParseCommand(const char *line)
427{
428 char *av[MAX_ARGS];
429 int ac;
430
431 /* Parse line */
427{
428 char *av[MAX_ARGS];
429 int ac;
430
431 /* Parse line */
432 for (ac = 0, av[0] = strtok(line, WHITESPACE);
432 for (ac = 0, av[0] = strtok((char *)line, WHITESPACE);
433 ac < MAX_ARGS - 1 && av[ac];
434 av[++ac] = strtok(NULL, WHITESPACE));
435
436 /* Do command */
437 return (DoCommand(ac, av));
438}
439
440/*

--- 221 unchanged lines hidden ---
433 ac < MAX_ARGS - 1 && av[ac];
434 av[++ac] = strtok(NULL, WHITESPACE));
435
436 /* Do command */
437 return (DoCommand(ac, av));
438}
439
440/*

--- 221 unchanged lines hidden ---