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

Last change on this file since 11599 was 11599, checked in by charles, 11 years ago

(trunk) Join the 21st century and use only 1 space at the end sentences. This commit is nearly as important as the semi-annual ones that remove trailing spaces from the ends of lines of code... :)

  • Property svn:keywords set to Date Rev Author Id
File size: 1.9 KB
Line 
1/*
2 * This file Copyright (C) 2008-2010 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 11599 2010-12-27 19:18:17Z charles $
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 */
Note: See TracBrowser for help on using the repository browser.