Annotation of embedaddon/strongswan/src/pki/command.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2009 Martin Willi
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  *
        !             5:  * This program is free software; you can redistribute it and/or modify it
        !             6:  * under the terms of the GNU General Public License as published by the
        !             7:  * Free Software Foundation; either version 2 of the License, or (at your
        !             8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !             9:  *
        !            10:  * This program is distributed in the hope that it will be useful, but
        !            11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            13:  * for more details.
        !            14:  */
        !            15: 
        !            16: /**
        !            17:  * @defgroup command command
        !            18:  * @{ @ingroup pki
        !            19:  */
        !            20: 
        !            21: #ifndef COMMAND_H_
        !            22: #define COMMAND_H_
        !            23: 
        !            24: /**
        !            25:  * Maximum number of commands (+1).
        !            26:  */
        !            27: #define MAX_COMMANDS 14
        !            28: 
        !            29: /**
        !            30:  * Maximum number of options in a command (+3)
        !            31:  */
        !            32: #define MAX_OPTIONS 36
        !            33: 
        !            34: /**
        !            35:  * Maximum number of usage summary lines (+1)
        !            36:  */
        !            37: #define MAX_LINES 13
        !            38: 
        !            39: typedef struct command_t command_t;
        !            40: typedef struct command_option_t command_option_t;
        !            41: typedef enum command_type_t command_type_t;
        !            42: 
        !            43: /**
        !            44:  * Option specification
        !            45:  */
        !            46: struct command_option_t {
        !            47:        /** long option string of the option */
        !            48:        char *name;
        !            49:        /** short option character of the option */
        !            50:        char op;
        !            51:        /** expected argument to option, no/req/opt_argument */
        !            52:        int arg;
        !            53:        /** description of the option */
        !            54:        char *desc;
        !            55: };
        !            56: 
        !            57: /**
        !            58:  * Command specification.
        !            59:  */
        !            60: struct command_t {
        !            61:        /** Function implementing the command */
        !            62:        int (*call)();
        !            63:        /** short option character */
        !            64:        char op;
        !            65:        /** long option string */
        !            66:        char *cmd;
        !            67:        /** description of the command */
        !            68:        char *description;
        !            69:        /** usage summary of the command */
        !            70:        char *line[MAX_LINES];
        !            71:        /** list of options the command accepts */
        !            72:        command_option_t options[MAX_OPTIONS];
        !            73: };
        !            74: 
        !            75: /**
        !            76:  * Get the next option, as with getopt.
        !            77:  */
        !            78: int command_getopt(char **arg);
        !            79: 
        !            80: /**
        !            81:  * Register a command.
        !            82:  */
        !            83: void command_register(command_t command);
        !            84: 
        !            85: /**
        !            86:  * Dispatch commands.
        !            87:  */
        !            88: int command_dispatch(int argc, char *argv[]);
        !            89: 
        !            90: /**
        !            91:  * Show usage information of active command.
        !            92:  */
        !            93: int command_usage(char *error);
        !            94: 
        !            95: #endif /** COMMAND_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>