xref: /freebsd/usr.sbin/ppp/command.h (revision b3e76948)
165309e5cSBrian Somers /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro F. Giffuni  *
465309e5cSBrian Somers  * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
565309e5cSBrian Somers  *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
665309e5cSBrian Somers  *                           Internet Initiative Japan, Inc (IIJ)
765309e5cSBrian Somers  * All rights reserved.
8af57ed9fSAtsushi Murai  *
965309e5cSBrian Somers  * Redistribution and use in source and binary forms, with or without
1065309e5cSBrian Somers  * modification, are permitted provided that the following conditions
1165309e5cSBrian Somers  * are met:
1265309e5cSBrian Somers  * 1. Redistributions of source code must retain the above copyright
1365309e5cSBrian Somers  *    notice, this list of conditions and the following disclaimer.
1465309e5cSBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
1565309e5cSBrian Somers  *    notice, this list of conditions and the following disclaimer in the
1665309e5cSBrian Somers  *    documentation and/or other materials provided with the distribution.
17af57ed9fSAtsushi Murai  *
1865309e5cSBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1965309e5cSBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2065309e5cSBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2165309e5cSBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2265309e5cSBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2365309e5cSBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2465309e5cSBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2565309e5cSBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2665309e5cSBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2765309e5cSBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2865309e5cSBrian Somers  * SUCH DAMAGE.
29af57ed9fSAtsushi Murai  */
30af57ed9fSAtsushi Murai 
31b6e82f33SBrian Somers struct cmdtab;
322764b86aSBrian Somers struct bundle;
332764b86aSBrian Somers struct datalink;
342764b86aSBrian Somers struct prompt;
35b6e82f33SBrian Somers 
36b6e82f33SBrian Somers struct cmdargs {
37aef795ccSBrian Somers   struct cmdtab const *cmdtab;		/* The entire command table */
38aef795ccSBrian Somers   struct cmdtab const *cmd;		/* This command entry */
39b6217683SBrian Somers   int argc;				/* Number of arguments (excluding cmd */
4025092092SBrian Somers   int argn;				/* Argument to start processing from */
41b6217683SBrian Somers   char const *const *argv;		/* Arguments */
42b6217683SBrian Somers   struct bundle *bundle;		/* Our bundle */
43b6217683SBrian Somers   struct datalink *cx;			/* Our context */
44b6217683SBrian Somers   struct prompt *prompt;		/* Who executed us */
45b6e82f33SBrian Somers };
46b6e82f33SBrian Somers 
47af57ed9fSAtsushi Murai struct cmdtab {
48b6e82f33SBrian Somers   const char *name;
49b6e82f33SBrian Somers   const char *alias;
50b6e82f33SBrian Somers   int (*func) (struct cmdargs const *);
5153c9f6c0SAtsushi Murai   u_char lauth;
52b6e82f33SBrian Somers   const char *helpmes;
53b6e82f33SBrian Somers   const char *syntax;
54b6e82f33SBrian Somers   const void *args;
55af57ed9fSAtsushi Murai };
5635495becSBrian Somers 
571342caedSBrian Somers #define NEG_ACCEPTED (1)
581342caedSBrian Somers #define NEG_ENABLED (2)
591342caedSBrian Somers #define IsAccepted(x) ((x) & NEG_ACCEPTED)
601342caedSBrian Somers #define IsEnabled(x) ((x) & NEG_ENABLED)
6175240ed1SBrian Somers 
626f384573SBrian Somers extern const char Version[];
6375240ed1SBrian Somers 
6458330d7bSBrian Somers extern void command_Expand(char **, int, char const *const *, struct bundle *,
658fb106c6SBrian Somers                            int, pid_t);
6646df5aa7SBrian Somers extern void command_Free(int, char **);
672a30e2acSBrian Somers extern int command_Expand_Interpret(char *, int, char *vector[MAXARGS], int);
68c9e11a11SBrian Somers extern int command_Interpret(char *, int, char *vector[MAXARGS]);
69dd7e2610SBrian Somers extern void command_Run(struct bundle *, int, char const *const *,
7030291ffbSBrian Somers                         struct prompt *, const char *, struct datalink *);
71c39aa54eSBrian Somers extern int command_Decode(struct bundle *, char *, int, struct prompt *,
72b6217683SBrian Somers                            const char *);
73dd7e2610SBrian Somers extern struct link *command_ChooseLink(struct cmdargs const *);
74dd7e2610SBrian Somers extern const char *command_ShowNegval(unsigned);
752a30e2acSBrian Somers 
76