2 * This file Copyright (C) 2008-2010 Mnemosyne LLC
4 * This file is licensed by the GPL version 2. Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
10 * $Id: tr-getopt.h 9931 2010-01-14 14:20:49Z charles $
21 * @addtogroup utils Utilities
25 /** @brief Similar to optind, this is the current index into argv */
28 typedef struct tr_option
30 int val
; /* the value to return from tr_getopt() */
31 const char * longName
; /* --long-form */
32 const char * description
; /* option's description for tr_getopt_usage() */
33 const char * shortName
; /* short form */
34 int has_arg
; /* 0 for no argument, 1 for argument */
35 const char * argName
; /* argument's description for tr_getopt_usage() */
41 /* all options have been processed */
44 /* a syntax error was detected, such as a missing
45 * argument for an option that requires one */
48 /* an unknown option was reached */
53 * @brief similar to getopt()
54 * @return TR_GETOPT_DONE, TR_GETOPT_ERR, TR_GETOPT_UNK, or the matching tr_option's `val' field
56 int tr_getopt( const char * summary
,
59 const tr_option
* opts
,
60 const char ** setme_optarg
);
62 /** @brief prints the `Usage' help section to stdout */
63 void tr_getopt_usage( const char * appName
,
64 const char * description
,
65 const tr_option
* opts
);
73 #endif /* TR_GETOPT_H */