source: trunk/libtransmission/tr-getopt.h @ 14615

Last change on this file since 14615 was 14615, checked in by jordan, 6 years ago

fix const warnings

In particular, in passing argv around as a "const char * const *"
instead of a "const char *".

  • Property svn:keywords set to Date Rev Author Id
File size: 1.7 KB
Line 
1/*
2 * This file Copyright (C) 2008-2014 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: tr-getopt.h 14615 2015-12-06 22:39:14Z jordan $
8 */
9
10#ifndef TR_GETOPT_H
11#define TR_GETOPT_H
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/**
18 * @addtogroup utils Utilities
19 * @{
20 */
21
22/** @brief Similar to optind, this is the current index into argv */
23extern int tr_optind;
24
25typedef struct tr_option
26{
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 () */
33}
34tr_option;
35
36enum
37{
38    /* all options have been processed */
39    TR_OPT_DONE = 0,
40
41    /* a syntax error was detected, such as a missing
42     * argument for an option that requires one */
43    TR_OPT_ERR = -1,
44
45    /* an unknown option was reached */
46    TR_OPT_UNK = -2
47};
48
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
52 */
53int  tr_getopt (const char          * summary,
54                int                   argc,
55                const char * const  * argv,
56                const tr_option     * opts,
57                const char         ** setme_optarg);
58
59/** @brief prints the `Usage' help section to stdout */
60void tr_getopt_usage (const char       * appName,
61                      const char       * description,
62                      const tr_option  * opts);
63
64#ifdef __cplusplus
65} /* extern "C" */
66#endif
67
68/** @} */
69
70#endif /* TR_GETOPT_H */
Note: See TracBrowser for help on using the repository browser.