command.c (43333) | command.c (43888) |
---|---|
1/* 2 * PPP User command processing module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * | 1/* 2 * PPP User command processing module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: command.c,v 1.178 1999/01/28 01:56:31 brian Exp $ | 20 * $Id: command.c,v 1.179 1999/01/28 09:40:15 brian Exp $ |
21 * 22 */ 23#include <sys/param.h> 24#include <netinet/in_systm.h> 25#include <netinet/in.h> 26#include <netinet/ip.h> 27#include <arpa/inet.h> 28#include <sys/socket.h> --- 104 unchanged lines hidden (view full) --- 133#define NEG_PPPDDEFLATE 45 134#define NEG_PRED1 46 135#define NEG_PROTOCOMP 47 136#define NEG_SHORTSEQ 48 137#define NEG_VJCOMP 49 138#define NEG_DNS 50 139 140const char Version[] = "2.1"; | 21 * 22 */ 23#include <sys/param.h> 24#include <netinet/in_systm.h> 25#include <netinet/in.h> 26#include <netinet/ip.h> 27#include <arpa/inet.h> 28#include <sys/socket.h> --- 104 unchanged lines hidden (view full) --- 133#define NEG_PPPDDEFLATE 45 134#define NEG_PRED1 46 135#define NEG_PROTOCOMP 47 136#define NEG_SHORTSEQ 48 137#define NEG_VJCOMP 49 138#define NEG_DNS 50 139 140const char Version[] = "2.1"; |
141const char VersionDate[] = "$Date: 1999/01/28 01:56:31 $"; | 141const char VersionDate[] = "$Date: 1999/01/28 09:40:15 $"; |
142 143static int ShowCommand(struct cmdargs const *); 144static int TerminalCommand(struct cmdargs const *); 145static int QuitCommand(struct cmdargs const *); 146static int OpenCommand(struct cmdargs const *); 147static int CloseCommand(struct cmdargs const *); 148static int DownCommand(struct cmdargs const *); 149static int SetCommand(struct cmdargs const *); --- 233 unchanged lines hidden (view full) --- 383 if (lnewstr > loldstr) 384 bcopy(word + loldstr, word + lnewstr, ltgt - pos - loldstr); 385 bcopy(newstr, word, lnewstr); 386 } while ((word = strstrword(word, oldstr))); 387 388 return tgt; 389} 390 | 142 143static int ShowCommand(struct cmdargs const *); 144static int TerminalCommand(struct cmdargs const *); 145static int QuitCommand(struct cmdargs const *); 146static int OpenCommand(struct cmdargs const *); 147static int CloseCommand(struct cmdargs const *); 148static int DownCommand(struct cmdargs const *); 149static int SetCommand(struct cmdargs const *); --- 233 unchanged lines hidden (view full) --- 383 if (lnewstr > loldstr) 384 bcopy(word + loldstr, word + lnewstr, ltgt - pos - loldstr); 385 bcopy(newstr, word, lnewstr); 386 } while ((word = strstrword(word, oldstr))); 387 388 return tgt; 389} 390 |
391static void 392expand(char **nargv, int argc, char const *const *oargv, struct bundle *bundle, 393 int inc0) | 391void 392command_Expand(char **nargv, int argc, char const *const *oargv, 393 struct bundle *bundle, int inc0) |
394{ 395 int arg; 396 char pid[12]; 397 398 if (inc0) 399 arg = 0; /* Start at arg 0 */ 400 else { 401 nargv[0] = strdup(oargv[0]); --- 77 unchanged lines hidden (view full) --- 479 /* substitute pseudo args */ 480 char *argv[MAXARGS]; 481 int argc = arg->argc - arg->argn; 482 483 if (argc >= sizeof argv / sizeof argv[0]) { 484 argc = sizeof argv / sizeof argv[0] - 1; 485 log_Printf(LogWARN, "Truncating shell command to %d args\n", argc); 486 } | 394{ 395 int arg; 396 char pid[12]; 397 398 if (inc0) 399 arg = 0; /* Start at arg 0 */ 400 else { 401 nargv[0] = strdup(oargv[0]); --- 77 unchanged lines hidden (view full) --- 479 /* substitute pseudo args */ 480 char *argv[MAXARGS]; 481 int argc = arg->argc - arg->argn; 482 483 if (argc >= sizeof argv / sizeof argv[0]) { 484 argc = sizeof argv / sizeof argv[0] - 1; 485 log_Printf(LogWARN, "Truncating shell command to %d args\n", argc); 486 } |
487 expand(argv, argc, arg->argv + arg->argn, arg->bundle, 0); | 487 command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 0); |
488 if (bg) { 489 pid_t p; 490 491 p = getpid(); 492 if (daemon(1, 1) == -1) { 493 log_Printf(LogERROR, "%d: daemon: %s\n", (int)p, strerror(errno)); 494 exit(1); 495 } --- 1972 unchanged lines hidden (view full) --- 2468 arg->bundle->argv[1] = arg->bundle->argv1; 2469 return 0; 2470 } 2471 2472 if (argc >= sizeof argv / sizeof argv[0]) { 2473 argc = sizeof argv / sizeof argv[0] - 1; 2474 log_Printf(LogWARN, "Truncating proc title to %d args\n", argc); 2475 } | 488 if (bg) { 489 pid_t p; 490 491 p = getpid(); 492 if (daemon(1, 1) == -1) { 493 log_Printf(LogERROR, "%d: daemon: %s\n", (int)p, strerror(errno)); 494 exit(1); 495 } --- 1972 unchanged lines hidden (view full) --- 2468 arg->bundle->argv[1] = arg->bundle->argv1; 2469 return 0; 2470 } 2471 2472 if (argc >= sizeof argv / sizeof argv[0]) { 2473 argc = sizeof argv / sizeof argv[0] - 1; 2474 log_Printf(LogWARN, "Truncating proc title to %d args\n", argc); 2475 } |
2476 expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1); | 2476 command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1); |
2477 2478 ptr = title; 2479 remaining = sizeof title - 1; 2480 for (f = 0; f < argc && remaining; f++) { 2481 if (f) { 2482 *ptr++ = ' '; 2483 remaining--; 2484 } --- 14 unchanged lines hidden --- | 2477 2478 ptr = title; 2479 remaining = sizeof title - 1; 2480 for (f = 0; f < argc && remaining; f++) { 2481 if (f) { 2482 *ptr++ = ' '; 2483 remaining--; 2484 } --- 14 unchanged lines hidden --- |