2 * This file Copyright (C) 2008-2014 Mnemosyne LLC
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
7 * $Id: tr-getopt.h 14241 2014-01-21 03:10:30Z jordan $
18 * @addtogroup utils Utilities
22 /** @brief Similar to optind, this is the current index into argv */
25 typedef struct tr_option
27 int val
; /* the value to return from tr_getopt () */
28 const char * longName
; /* --long-form */
29 const char * description
; /* option's description for tr_getopt_usage () */
30 const char * shortName
; /* short form */
31 int has_arg
; /* 0 for no argument, 1 for argument */
32 const char * argName
; /* argument's description for tr_getopt_usage () */
38 /* all options have been processed */
41 /* a syntax error was detected, such as a missing
42 * argument for an option that requires one */
45 /* an unknown option was reached */
50 * @brief similar to getopt ()
51 * @return TR_GETOPT_DONE, TR_GETOPT_ERR, TR_GETOPT_UNK, or the matching tr_option's `val' field
53 int tr_getopt (const char * summary
,
56 const tr_option
* opts
,
57 const char ** setme_optarg
);
59 /** @brief prints the `Usage' help section to stdout */
60 void tr_getopt_usage (const char * appName
,
61 const char * description
,
62 const tr_option
* opts
);
70 #endif /* TR_GETOPT_H */