178189Sbrian/*- 278189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 378189Sbrian * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 478189Sbrian * Internet Initiative Japan, Inc (IIJ) 578189Sbrian * All rights reserved. 66059Samurai * 778189Sbrian * Redistribution and use in source and binary forms, with or without 878189Sbrian * modification, are permitted provided that the following conditions 978189Sbrian * are met: 1078189Sbrian * 1. Redistributions of source code must retain the above copyright 1178189Sbrian * notice, this list of conditions and the following disclaimer. 1278189Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1378189Sbrian * notice, this list of conditions and the following disclaimer in the 1478189Sbrian * documentation and/or other materials provided with the distribution. 156059Samurai * 1678189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1778189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1878189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1978189Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2078189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2178189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2278189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2378189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2478189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2578189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2678189Sbrian * SUCH DAMAGE. 276059Samurai * 2850479Speter * $FreeBSD$ 296059Samurai */ 306059Samurai 3131343Sbrianstruct cmdtab; 3236285Sbrianstruct bundle; 3336285Sbrianstruct datalink; 3436285Sbrianstruct prompt; 3531343Sbrian 3631343Sbrianstruct cmdargs { 3736285Sbrian struct cmdtab const *cmdtab; /* The entire command table */ 3836285Sbrian struct cmdtab const *cmd; /* This command entry */ 3936285Sbrian int argc; /* Number of arguments (excluding cmd */ 4036285Sbrian int argn; /* Argument to start processing from */ 4136285Sbrian char const *const *argv; /* Arguments */ 4236285Sbrian struct bundle *bundle; /* Our bundle */ 4336285Sbrian struct datalink *cx; /* Our context */ 4436285Sbrian struct prompt *prompt; /* Who executed us */ 4531343Sbrian}; 4631343Sbrian 476059Samuraistruct cmdtab { 4831343Sbrian const char *name; 4931343Sbrian const char *alias; 5031343Sbrian int (*func) (struct cmdargs const *); 5128679Sbrian u_char lauth; 5231343Sbrian const char *helpmes; 5331343Sbrian const char *syntax; 5431343Sbrian const void *args; 556059Samurai}; 5629696Sbrian 5736285Sbrian#define NEG_ACCEPTED (1) 5836285Sbrian#define NEG_ENABLED (2) 5936285Sbrian#define IsAccepted(x) ((x) & NEG_ACCEPTED) 6036285Sbrian#define IsEnabled(x) ((x) & NEG_ENABLED) 6130715Sbrian 6236285Sbrianextern const char Version[]; 6330715Sbrian 6443888Sbrianextern void command_Expand(char **, int, char const *const *, struct bundle *, 6547849Sbrian int, pid_t); 6685991Sbrianextern void command_Free(int, char **); 6758045Sbrianextern int command_Expand_Interpret(char *, int, char *vector[MAXARGS], int); 6837009Sbrianextern int command_Interpret(char *, int, char *vector[MAXARGS]); 6936285Sbrianextern void command_Run(struct bundle *, int, char const *const *, 7037008Sbrian struct prompt *, const char *, struct datalink *); 7154914Sbrianextern int command_Decode(struct bundle *, char *, int, struct prompt *, 7236285Sbrian const char *); 7336285Sbrianextern struct link *command_ChooseLink(struct cmdargs const *); 7436285Sbrianextern const char *command_ShowNegval(unsigned); 7558045Sbrian 76