source: branches/1.5x/libtransmission/tr-getopt.h @ 8204

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

(1.5x libT) various backports for 1.52:
(1) recognize Aria2 as a client
(2) remove jhujhiti's tr_suspectAddress(), since he removed it from trunka
(3) on Mac, better detection of where the Web UI files are located
(4) reintroduce the web task queue
(5) various minor formatting changes to reduce the diffs between 1.52 and trunk

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
32extern int tr_optind;
33
34typedef struct tr_option
35{
36    int           val;          /* the value to return from tr_getopt() */
37    const char *  longName;     /* --long-form */
38    const char *  description;  /* option's description for tr_getopt_usage() */
39    const char *  shortName;    /* short form */
40    int           has_arg;      /* 0 for no argument, 1 for argument */
41    const char *  argName;      /* argument's description for tr_getopt_usage() */
42}
43tr_option;
44
45enum
46{
47    /* all options have been processed */
48    TR_OPT_DONE = 0,
49
50    /* a syntax error was detected, such as a missing
51     * argument for an option that requires one */
52    TR_OPT_ERR = -1,
53
54    /* an unknown option was reached */
55    TR_OPT_UNK = -2
56};
57
58/**
59 * @return TR_GETOPT_DONE, TR_GETOPT_ERR, TR_GETOPT_UNK,
60 *         or the matching tr_option's `val' field
61 */
62int  tr_getopt( const char *      summary,
63                int               argc,
64                const char **     argv,
65                const tr_option * opts,
66                const char **     setme_optarg );
67
68void tr_getopt_usage( const char *      appName,
69                      const char *      description,
70                      const tr_option * opts );
71
72#ifdef __cplusplus
73} /* extern "C" */
74#endif
75
76#endif /* TR_GETOPT_H */
Note: See TracBrowser for help on using the repository browser.