Revert "transmission: update from 2.13 to 2.22"
[tomato.git] / release / src / router / transmission / libtransmission / tr-getopt.h
blob6b77cead5a6dd0582bb4ea3f067b6013a9517016
1 /*
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 $
13 #ifndef TR_GETOPT_H
14 #define TR_GETOPT_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 /**
21 * @addtogroup utils Utilities
22 * @{
25 /** @brief Similar to optind, this is the current index into argv */
26 extern int tr_optind;
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() */
37 tr_option;
39 enum
41 /* all options have been processed */
42 TR_OPT_DONE = 0,
44 /* a syntax error was detected, such as a missing
45 * argument for an option that requires one */
46 TR_OPT_ERR = -1,
48 /* an unknown option was reached */
49 TR_OPT_UNK = -2
52 /**
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,
57 int argc,
58 const char ** argv,
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 );
67 #ifdef __cplusplus
68 } /* extern "C" */
69 #endif
71 /** @} */
73 #endif /* TR_GETOPT_H */