• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/transmission/transmission-2.73/libtransmission/
1/*
2 * This file Copyright (C) Mnemosyne LLC
3 *
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.
9 *
10 * $Id: tr-getopt.h 11709 2011-01-19 13:48:47Z jordan $
11 */
12
13#ifndef TR_GETOPT_H
14#define TR_GETOPT_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/**
21 * @addtogroup utils Utilities
22 * @{
23 */
24
25/** @brief Similar to optind, this is the current index into argv */
26extern int tr_optind;
27
28typedef struct tr_option
29{
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() */
36}
37tr_option;
38
39enum
40{
41    /* all options have been processed */
42    TR_OPT_DONE = 0,
43
44    /* a syntax error was detected, such as a missing
45     * argument for an option that requires one */
46    TR_OPT_ERR = -1,
47
48    /* an unknown option was reached */
49    TR_OPT_UNK = -2
50};
51
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
55 */
56int  tr_getopt( const char       * summary,
57                int                argc,
58                const char      ** argv,
59                const tr_option  * opts,
60                const char      ** setme_optarg );
61
62/** @brief prints the `Usage' help section to stdout */
63void tr_getopt_usage( const char       * appName,
64                      const char       * description,
65                      const tr_option  * opts );
66
67#ifdef __cplusplus
68} /* extern "C" */
69#endif
70
71/** @} */
72
73#endif /* TR_GETOPT_H */
74