ThingWorx C SDK
cfuopt.h
1 /*
2  * cfuopt.h - This file is part of the libcfu library
3  *
4  * Copyright (c) 2005 Don Owens. All rights reserved.
5  *
6  * This code is released under the BSD license:
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  *
20  * * Neither the name of the author nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
35  * OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include <cfu.h>
39 
40 #ifndef CFU_OPT_H_
41 #define CFU_OPT_H_
42 
43 CFU_BEGIN_DECLS
44 
45 typedef struct cfuopt_struct cfuopt_t;
46 
47 /* Returns a new options context */
48 cfuopt_t *cfuopt_new(void);
49 
50 /* Adds to the list of known options. */
51 void cfuopt_add_entry(cfuopt_t *context, const char *opt_str, void *arg_data,
52  const char *description, const char *arg_description);
53 
54 /* Parses the command line and modifies argc and argv to account for
55  * left over arguments.
56  */
57 void cfuopt_parse(cfuopt_t *context, int *argc, char ***argv, char **error);
58 
59 /* Returns a help string built from the entries added with
60  * cfuopt_add_entry().
61  */
62 char * cfuopt_get_help_str(cfuopt_t *context);
63 
64 /* Frees up resources used by the option parser. */
65 void cfuopt_destroy(cfuopt_t *context);
66 
67 CFU_END_DECLS
68 
69 #endif
Definition: cfuopt.c:48