1 /* 2 * Name: cmdline.h 3 * Author: Pietro Belotti 4 * 5 * This code is published under the Eclipse Public License (EPL). 6 * See http://www.eclipse.org/legal/epl-v10.html 7 * 8 */ 9 10 #ifndef PAR_H 11 #define PAR_H 12 13 enum etype {TTOGGLE, TCHAR, TINT, TDOUBLE, TSTRING}; 14 15 /** \struct tpar 16 * \brief argv option struct 17 * 18 * For each program argument there is a short/long option string, 19 * (possible) the address of a variable to modify on finding this 20 * option, and a help message to be displayed on "--help". 21 */ 22 23 typedef struct { 24 25 char shortopt; /**< Short option character */ 26 char *longopt; /**< Long option string */ 27 28 double initial; /**< Option's default value */ 29 30 void *par; /**< Address of the changed parameter (may be NULL) */ 31 enum etype type; /**< What type is the option? [toggle|int|double...] */ 32 33 char *help; /**< A help message */ 34 35 } tpar; 36 37 char **readargs (int, char **, tpar *); /* parse command line arguments */ 38 39 int act (char ***, int *, enum etype, void *); /* type-based parameter assigned */ 40 41 void print_help (char *, tpar *); /* print help message */ 42 43 void set_default_args (tpar *); /* set default values in options */ 44 45 #endif 46