transmission 2.83
[tomato.git] / release / src / router / transmission / libtransmission / tr-getopt.h
blob5a0f657e3386c7f8f39c24858128aa5fdcb83db0
1 /*
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 $
8 */
10 #ifndef TR_GETOPT_H
11 #define TR_GETOPT_H
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
17 /**
18 * @addtogroup utils Utilities
19 * @{
22 /** @brief Similar to optind, this is the current index into argv */
23 extern int tr_optind;
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 () */
34 tr_option;
36 enum
38 /* all options have been processed */
39 TR_OPT_DONE = 0,
41 /* a syntax error was detected, such as a missing
42 * argument for an option that requires one */
43 TR_OPT_ERR = -1,
45 /* an unknown option was reached */
46 TR_OPT_UNK = -2
49 /**
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,
54 int argc,
55 const char ** argv,
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);
64 #ifdef __cplusplus
65 } /* extern "C" */
66 #endif
68 /** @} */
70 #endif /* TR_GETOPT_H */