File:  [ELWIX - Embedded LightWeight unIX -] / gpl / axl / knife / exarg.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Fri Feb 17 12:50:02 2012 UTC (12 years, 4 months ago) by misho
Branches: axl, MAIN
CVS tags: HEAD, AXL0_6_7
version 0.6.7

    1: /*  LibExploreArguments: a library to parse command line options
    2:  *  Copyright (C) 2005 Advanced Software Production Line, S.L.
    3:  * 
    4:  *  This program is free software; you can redistribute it and/or
    5:  *  modify it under the terms of the GNU Lesser General Public License
    6:  *  as published by the Free Software Foundation; either version 2.1 of
    7:  *  the License, or (at your option) any later version.
    8:  *
    9:  *  This program is distributed in the hope that it will be useful,
   10:  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
   11:  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
   12:  *  GNU Lesser General Public License for more details.
   13:  *
   14:  *  You should have received a copy of the GNU Lesser General Public
   15:  *  License along with this program; if not, write to the Free
   16:  *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   17:  *  02111-1307 USA
   18:  *  
   19:  *  You may find a copy of the license under this software is released
   20:  *  at COPYING file. This is LGPL software: you are wellcome to
   21:  *  develop propietary applications using this library withtout any
   22:  *  royalty or fee but returning back any change, improvement or
   23:  *  addition in the form of source code, project image, documentation
   24:  *  patches, etc. 
   25:  *
   26:  *  Contact us at:
   27:  *          
   28:  *      Postal address:
   29:  *         Advanced Software Production Line, S.L.
   30:  *         C/ Dr. Michavila NÂș 14
   31:  *         Coslada 28820 Madrid
   32:  *         Spain
   33:  *
   34:  *      Email address:
   35:  *         info@aspl.es - http://fact.aspl.es
   36:  *
   37:  */
   38: #ifndef __EXARG_H__
   39: #define __EXARG_H__
   40: 
   41: /** 
   42:  * \addtogroup exarg
   43:  * @{
   44:  */
   45: 
   46: /** 
   47:  * @brief Enum type which defines how a argument must be interpreted.
   48:  * 
   49:  * This enumeration is used to figure out what type of argument is been installed.
   50:  * You can also see the documentation \ref exarg_install_arg to get more info about
   51:  * this enumeration.
   52:  */
   53: typedef enum { 
   54: 	/**
   55: 	 * @brief Defines an argument with no option. 
   56: 	 *
   57: 	 * \ref EXARG_NONE arguments are those with are switches for
   58: 	 * the program and receives not additional arguments to
   59: 	 * work. Examples of this types of arguments are usually
   60: 	 * <b>--help</b> and <b>--verson</b> options.
   61: 	 */
   62: 	EXARG_NONE, 
   63: 	/**
   64: 	 * @brief Defines an argument with is expected to receive an
   65: 	 * additional integer value.
   66: 	 *
   67: 	 * \ref EXARG_INT arguments are those used to instruct some
   68: 	 * value to the system. An example of this type of argument
   69: 	 * can be: <b>--column-size 17</b>
   70: 	 *
   71: 	 * Because you are using an argument with expects to receive
   72: 	 * an interger, LibExArg will check this for you.
   73: 	 * 
   74: 	 */
   75: 
   76: 	EXARG_INT, 
   77: 	/**
   78: 	 * @brief Defines an argument with is expected to receive an
   79: 	 * additional string value.
   80: 	 *
   81: 	 * \ref EXARG_STRING arguments are those used to instruct some
   82: 	 * value to the system. An example of this type of argument
   83: 	 * can be: <b>--column-name "Test"</b>
   84: 	 *
   85: 	 * Because you are using an argument with expects to receive
   86: 	 * an string, LibExArg will check this for you.
   87: 	 *
   88: 	 * 
   89: 	 */
   90: 	EXARG_STRING
   91: } ExArgType;
   92: 
   93: /** 
   94:  * @brief Free argument definition. 
   95:  *
   96:  * This type represents an argument that is provided to the program
   97:  * without options (not part of data associated to a option and not an
   98:  * option itself. Once you get the first argument using \ref
   99:  * exarg_get_params, you can get the data inside using:
  100:  * 
  101:  *  - \ref exarg_param_get (to get the string value)
  102:  *
  103:  * To get next parameters you can use:
  104:  * 
  105:  *  - \ref exarg_param_next (will return the next param to the provided param).
  106:  * 
  107:  */
  108: typedef struct _ExArgument ExArgument;
  109: 
  110: void         exarg_parse        (int         argc,
  111: 			       char     ** argv);
  112: 
  113: void         exarg_end          (void);
  114: 
  115: void         exarg_disable_help (void);
  116: 
  117: void         exarg_add_usage_header  (char * header);
  118: 
  119: void         exarg_add_help_header   (char * header);
  120: 
  121: void         exarg_post_usage_header (char * post_header);
  122: 
  123: void         exarg_post_help_header  (char * post_header);
  124: 
  125: void         exarg_install_arg  (const char     * arg_name, 
  126: 				 const char     * arg_short_name, 
  127: 				 ExArgType   type,
  128: 				 const char     * description);
  129: 
  130: void         exarg_install_argv     (int num_arg, ...);
  131: 
  132: void         exarg_add_dependency   (const char * arg_name, 
  133: 				     const char * arg_dependency);
  134: 
  135: void         exarg_add_exclusion    (const char * arg_name, 
  136: 				     const char * arg_excluded);
  137: 
  138: void         exarg_set_obligatory   (char * arg_name);
  139: 
  140: void         exarg_accept_free_args (int accept);
  141: 
  142: void         exarg_define           (char * arg_name,
  143: 				     char * value);
  144: 
  145: void         exarg_undef            (char * arg_name);
  146: 
  147: int          exarg_is_defined       (char     * arg_name);
  148: 
  149: int          exarg_is_definedv      (char * first_value, ...);
  150: 
  151: char       * exarg_get_string       (char * arg_name);
  152: 
  153: char       * exarg_get_string_alloc (char * arg_name);
  154: 
  155: int          exarg_get_int          (char * arg_name);
  156: 
  157: ExArgument * exarg_get_params       (void);
  158: 
  159: const char * exarg_param_get        (ExArgument * arg);
  160: 
  161: ExArgument * exarg_param_next       (ExArgument * arg);
  162: 
  163: int          exarg_get_params_num   (void);
  164: 
  165: #endif
  166: 
  167: /* @} */

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