GRPC Core  4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cmdline.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_SUPPORT_CMDLINE_H
35 #define GRPC_SUPPORT_CMDLINE_H
36 
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
69 typedef struct gpr_cmdline gpr_cmdline;
70 
73 GPRAPI gpr_cmdline *gpr_cmdline_create(const char *description);
76 GPRAPI void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name,
77  const char *help, int *value);
79 GPRAPI void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name,
80  const char *help, int *value);
82 GPRAPI void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name,
83  const char *help, char **value);
86  gpr_cmdline *cl, const char *name, const char *help,
87  void (*on_extra_arg)(void *user_data, const char *arg), void *user_data);
93 GPRAPI int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv);
97 GPRAPI char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0);
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* GRPC_SUPPORT_CMDLINE_H */
struct gpr_cmdline gpr_cmdline
Simple command line parser.
Definition: cmdline.h:69
GPRAPI char * gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0)
Get a string describing usage.
GPRAPI int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv)
Parse the command line; returns 1 on success, on failure either dies (by default) or returns 0 if gpr...
#define GPRAPI
Definition: port_platform.h:416
GPRAPI void gpr_cmdline_destroy(gpr_cmdline *cl)
Destroy the parser.
GPRAPI gpr_cmdline * gpr_cmdline_create(const char *description)
Construct a command line parser: takes a short description of the tool doing the parsing.
GPRAPI void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name, const char *help, int *value)
Add an integer parameter, with a name (used on the command line) and some helpful text (used in the c...
GPRAPI void gpr_cmdline_on_extra_arg(gpr_cmdline *cl, const char *name, const char *help, void(*on_extra_arg)(void *user_data, const char *arg), void *user_data)
Set a callback for non-named arguments.
GPRAPI void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name, const char *help, int *value)
The same, for a boolean flag.
GPRAPI void gpr_cmdline_set_survive_failure(gpr_cmdline *cl)
Enable surviving failure: default behavior is to exit the process.
GPRAPI void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name, const char *help, char **value)
And for a string.