OpenOCD
jim-nvp.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause-Views */
2 
3 /* Jim - A small embeddable Tcl interpreter
4  *
5  * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
6  * Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
7  * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
8  * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
9  * Copyright 2008 Andrew Lunn <andrew@lunn.ch>
10  * Copyright 2008 Duane Ellis <openocd@duaneellis.com>
11  * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
12  * Copyright 2008 Steve Bennett <steveb@workware.net.au>
13  * Copyright 2009 Nico Coesel <ncoesel@dealogic.nl>
14  * Copyright 2009 Zachary T Welch zw@superlucidity.net
15  * Copyright 2009 David Brownell
16  * Copyright (c) 2005-2011 Jim Tcl Project. All rights reserved.
17  */
18 
19 #ifndef OPENOCD_HELPER_JIM_NVP_H
20 #define OPENOCD_HELPER_JIM_NVP_H
21 
22 #include <jim.h>
23 
59 struct jim_nvp {
60  const char *name;
61  int value;
62 };
63 
64 int jim_get_nvp(Jim_Interp *interp,
65  Jim_Obj *objptr,
66  const struct jim_nvp *nvp_table,
67  const struct jim_nvp **result);
68 
69 /* Name Value Pairs Operations */
70 struct jim_nvp *jim_nvp_name2value_simple(const struct jim_nvp *nvp_table, const char *name);
71 struct jim_nvp *jim_nvp_name2value_nocase_simple(const struct jim_nvp *nvp_table, const char *name);
72 struct jim_nvp *jim_nvp_value2name_simple(const struct jim_nvp *nvp_table, int v);
73 
74 int jim_nvp_name2value(Jim_Interp *interp,
75  const struct jim_nvp *nvp_table,
76  const char *name,
77  struct jim_nvp **result);
78 int jim_nvp_name2value_nocase(Jim_Interp *interp,
79  const struct jim_nvp *nvp_table,
80  const char *name,
81  struct jim_nvp **result);
82 int jim_nvp_value2name(Jim_Interp *interp, const struct jim_nvp *nvp_table, int value, struct jim_nvp **result);
83 
84 int jim_nvp_name2value_obj(Jim_Interp *interp,
85  const struct jim_nvp *nvp_table,
86  Jim_Obj *name_obj,
87  struct jim_nvp **result);
88 int jim_nvp_name2value_obj_nocase(Jim_Interp *interp,
89  const struct jim_nvp *nvp_table,
90  Jim_Obj *name_obj,
91  struct jim_nvp **result);
92 int jim_nvp_value2name_obj(Jim_Interp *interp,
93  const struct jim_nvp *nvp_table,
94  Jim_Obj *value_obj,
95  struct jim_nvp **result);
96 
98 void jim_set_result_nvp_unknown(Jim_Interp *interp,
99  Jim_Obj *param_name,
100  Jim_Obj *param_value,
101  const struct jim_nvp *nvp_table);
102 
120 const char *jim_debug_argv_string(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
121 
122 
136  Jim_Interp *interp;
137  int argc;
138  Jim_Obj *const *argv;
139  int isconfigure; /* non-zero if configure */
140 };
141 
198 int jim_getopt_setup(struct jim_getopt_info *goi,
199  Jim_Interp *interp,
200  int argc,
201  Jim_Obj *const *argv);
202 
203 
207 void jim_getopt_debug(struct jim_getopt_info *goi);
208 
215 int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere);
216 
223 int jim_getopt_string(struct jim_getopt_info *goi, const char **puthere, int *len);
224 
231 int jim_getopt_double(struct jim_getopt_info *goi, double *puthere);
232 
238 int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere);
239 
247 int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *lookup, struct jim_nvp **puthere);
248 
292 void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *lookup, int hadprefix);
293 
294 
302 int jim_getopt_enum(struct jim_getopt_info *goi, const char *const *lookup, int *puthere);
303 
304 #endif /* OPENOCD_HELPER_JIM_NVP_H */
const char * name
Definition: armv4_5.c:76
int jim_nvp_value2name(Jim_Interp *interp, const struct jim_nvp *nvp_table, int value, struct jim_nvp **result)
Definition: jim-nvp.c:133
void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *lookup, int hadprefix)
Create an appropriate error message for an NVP.
Definition: jim-nvp.c:252
int jim_nvp_value2name_obj(Jim_Interp *interp, const struct jim_nvp *nvp_table, Jim_Obj *value_obj, struct jim_nvp **result)
Definition: jim-nvp.c:111
int jim_nvp_name2value_obj_nocase(Jim_Interp *interp, const struct jim_nvp *nvp_table, Jim_Obj *name_obj, struct jim_nvp **result)
Definition: jim-nvp.c:87
void jim_set_result_nvp_unknown(Jim_Interp *interp, Jim_Obj *param_name, Jim_Obj *param_value, const struct jim_nvp *nvp_table)
prints a nice 'unknown' parameter error message to the 'result'
Definition: jim-nvp.c:274
struct jim_nvp * jim_nvp_name2value_simple(const struct jim_nvp *nvp_table, const char *name)
Definition: jim-nvp.c:45
int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
Remove argv[0] as wide.
Definition: jim-nvp.c:221
void jim_getopt_debug(struct jim_getopt_info *goi)
Debug - Dump parameters to stderr.
Definition: jim-nvp.c:158
int jim_get_nvp(Jim_Interp *interp, Jim_Obj *objptr, const struct jim_nvp *nvp_table, const struct jim_nvp **result)
Definition: jim-nvp.c:26
int jim_getopt_string(struct jim_getopt_info *goi, const char **puthere, int *len)
Remove argv[0] as string.
Definition: jim-nvp.c:187
int jim_getopt_enum(struct jim_getopt_info *goi, const char *const *lookup, int *puthere)
Remove argv[0] as Enum.
Definition: jim-nvp.c:260
int jim_getopt_setup(struct jim_getopt_info *goi, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
Definition: jim-nvp.c:148
int jim_nvp_name2value(Jim_Interp *interp, const struct jim_nvp *nvp_table, const char *name, struct jim_nvp **result)
Definition: jim-nvp.c:70
int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *lookup, struct jim_nvp **puthere)
Remove argv[0] as NVP.
Definition: jim-nvp.c:236
int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
Definition: jim-nvp.c:168
const char * jim_debug_argv_string(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Debug: convert argc/argv into a printable string for printf() debug.
Definition: jim-nvp.c:300
int jim_nvp_name2value_obj(Jim_Interp *interp, const struct jim_nvp *nvp_table, Jim_Obj *name_obj, struct jim_nvp **result)
Definition: jim-nvp.c:65
int jim_nvp_name2value_nocase(Jim_Interp *interp, const struct jim_nvp *nvp_table, const char *name, struct jim_nvp **result)
Definition: jim-nvp.c:95
struct jim_nvp * jim_nvp_name2value_nocase_simple(const struct jim_nvp *nvp_table, const char *name)
Definition: jim-nvp.c:55
int jim_getopt_double(struct jim_getopt_info *goi, double *puthere)
Remove argv[0] as double.
Definition: jim-nvp.c:203
struct jim_nvp * jim_nvp_value2name_simple(const struct jim_nvp *nvp_table, int v)
Definition: jim-nvp.c:123
A TCL -ish GetOpt like code.
Definition: jim-nvp.h:135
Jim_Interp * interp
Definition: jim-nvp.h:136
Jim_Obj *const * argv
Definition: jim-nvp.h:138
Name Value Pairs, aka: NVP.
Definition: jim-nvp.h:59
const char * name
Definition: jim-nvp.h:60
int value
Definition: jim-nvp.h:61