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

Last change on this file since 8561 was 8561, checked in by charles, 13 years ago

(trunk libT) re-start work on making libT doxygen friendly. still a long ways to go on this.

File size: 2.5 KB
Line 
1/*
2 * This file Copyright (C) 2008-2009 Charles Kerr <charles@transmissionbt.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 *
22 * $Id:$
23 */
24
25#ifndef TR_GETOPT_H
26#define TR_GETOPT_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * @addtogroup utils Utilities
34 * @{
35 */
36
37extern int tr_optind;
38
39typedef struct tr_option
40{
41    int           val;          /* the value to return from tr_getopt() */
42    const char *  longName;     /* --long-form */
43    const char *  description;  /* option's description for tr_getopt_usage() */
44    const char *  shortName;    /* short form */
45    int           has_arg;      /* 0 for no argument, 1 for argument */
46    const char *  argName;      /* argument's description for tr_getopt_usage() */
47}
48tr_option;
49
50enum
51{
52    /* all options have been processed */
53    TR_OPT_DONE = 0,
54
55    /* a syntax error was detected, such as a missing
56     * argument for an option that requires one */
57    TR_OPT_ERR = -1,
58
59    /* an unknown option was reached */
60    TR_OPT_UNK = -2
61};
62
63/**
64 * @return TR_GETOPT_DONE, TR_GETOPT_ERR, TR_GETOPT_UNK,
65 *         or the matching tr_option's `val' field
66 */
67int  tr_getopt( const char *      summary,
68                int               argc,
69                const char **     argv,
70                const tr_option * opts,
71                const char **     setme_optarg );
72
73void tr_getopt_usage( const char *      appName,
74                      const char *      description,
75                      const tr_option * opts );
76
77#ifdef __cplusplus
78} /* extern "C" */
79#endif
80
81/** @} */
82
83#endif /* TR_GETOPT_H */
Note: See TracBrowser for help on using the repository browser.