source: trunk/libtransmission/tr-getopt.h

Last change on this file was 14724, checked in by jordan, 5 years ago

use '#pragma once' instead of #ifndef..#define..#endif guards

  • 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 14724 2016-03-29 16:37:21Z mikedld $
8 */
9
10#pragma once
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/**
17 * @addtogroup utils Utilities
18 * @{
19 */
20
21/** @brief Similar to optind, this is the current index into argv */
22extern int tr_optind;
23
24typedef struct tr_option
25{
26    int           val;          /* the value to return from tr_getopt () */
27    const char *  longName;     /* --long-form */
28    const char *  description;  /* option's description for tr_getopt_usage () */
29    const char *  shortName;    /* short form */
30    int           has_arg;      /* 0 for no argument, 1 for argument */
31    const char *  argName;      /* argument's description for tr_getopt_usage () */
32}
33tr_option;
34
35enum
36{
37    /* all options have been processed */
38    TR_OPT_DONE = 0,
39
40    /* a syntax error was detected, such as a missing
41     * argument for an option that requires one */
42    TR_OPT_ERR = -1,
43
44    /* an unknown option was reached */
45    TR_OPT_UNK = -2
46};
47
48/**
49 * @brief similar to getopt ()
50 * @return TR_GETOPT_DONE, TR_GETOPT_ERR, TR_GETOPT_UNK, or the matching tr_option's `val' field
51 */
52int  tr_getopt (const char          * summary,
53                int                   argc,
54                const char * const  * argv,
55                const tr_option     * opts,
56                const char         ** setme_optarg);
57
58/** @brief prints the `Usage' help section to stdout */
59void tr_getopt_usage (const char       * appName,
60                      const char       * description,
61                      const tr_option  * opts);
62
63#ifdef __cplusplus
64} /* extern "C" */
65#endif
66
67/** @} */
68
Note: See TracBrowser for help on using the repository browser.