command.h revision 706e567fc5ff6b79738a5f470e5aa7b2cae76459
1706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh/*- 2706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * Internet Initiative Japan, Inc (IIJ) 5706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * All rights reserved. 6706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 7706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * Redistribution and use in source and binary forms, with or without 8706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * modification, are permitted provided that the following conditions 9706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * are met: 10706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 1. Redistributions of source code must retain the above copyright 11706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * notice, this list of conditions and the following disclaimer. 12706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 2. Redistributions in binary form must reproduce the above copyright 13706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * notice, this list of conditions and the following disclaimer in the 14706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * documentation and/or other materials provided with the distribution. 15706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 16706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * SUCH DAMAGE. 27706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 28706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * $FreeBSD: src/usr.sbin/ppp/command.h,v 1.23.40.1 2010/12/21 17:10:29 kensmith Exp $ 29706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh */ 30706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 31706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct cmdtab; 32706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct bundle; 33706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct datalink; 34706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct prompt; 35706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 36706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct cmdargs { 37706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct cmdtab const *cmdtab; /* The entire command table */ 38706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct cmdtab const *cmd; /* This command entry */ 39706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int argc; /* Number of arguments (excluding cmd */ 40706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int argn; /* Argument to start processing from */ 41706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh char const *const *argv; /* Arguments */ 42706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct bundle *bundle; /* Our bundle */ 43706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct datalink *cx; /* Our context */ 44706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct prompt *prompt; /* Who executed us */ 45706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh}; 46706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 47706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct cmdtab { 48706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const char *name; 49706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const char *alias; 50706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int (*func) (struct cmdargs const *); 51706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh u_char lauth; 52706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const char *helpmes; 53706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const char *syntax; 54706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const void *args; 55706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh}; 56706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 57706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define NEG_ACCEPTED (1) 58706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define NEG_ENABLED (2) 59706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define IsAccepted(x) ((x) & NEG_ACCEPTED) 60706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define IsEnabled(x) ((x) & NEG_ENABLED) 61706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 62706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern const char Version[]; 63706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 64706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void command_Expand(char **, int, char const *const *, struct bundle *, 65706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int, pid_t); 66706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void command_Free(int, char **); 67706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern int command_Expand_Interpret(char *, int, char *vector[MAXARGS], int); 68706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern int command_Interpret(char *, int, char *vector[MAXARGS]); 69706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void command_Run(struct bundle *, int, char const *const *, 70706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct prompt *, const char *, struct datalink *); 71706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern int command_Decode(struct bundle *, char *, int, struct prompt *, 72706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const char *); 73706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern struct link *command_ChooseLink(struct cmdargs const *); 74706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern const char *command_ShowNegval(unsigned); 75706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 76