X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Fjim-nvp.h;h=05d79c4a7d899d5c519f908853c70bfa9895221c;hb=2a864a89c8296d67587b93a58996615e74fe9c31;hp=12ff889ac8f9f5d4ad4b1179b422b20778ac727e;hpb=ef885d3b2a3001325f525df250dadd570e5d743e;p=openocd.git diff --git a/src/helper/jim-nvp.h b/src/helper/jim-nvp.h index 12ff889ac8..05d79c4a7d 100644 --- a/src/helper/jim-nvp.h +++ b/src/helper/jim-nvp.h @@ -1,3 +1,46 @@ +/* Jim - A small embeddable Tcl interpreter + * + * Copyright 2005 Salvatore Sanfilippo + * Copyright 2005 Clemens Hintze + * Copyright 2005 patthoyts - Pat Thoyts + * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com + * Copyright 2008 Andrew Lunn + * Copyright 2008 Duane Ellis + * Copyright 2008 Uwe Klein + * Copyright 2008 Steve Bennett + * Copyright 2009 Nico Coesel + * Copyright 2009 Zachary T Welch zw@superlucidity.net + * Copyright 2009 David Brownell + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation + * are those of the authors and should not be interpreted as representing + * official policies, either expressed or implied, of the Jim Tcl Project. + */ + #ifndef JIM_NVP_H #define JIM_NVP_H @@ -40,34 +83,47 @@ */ typedef struct { const char *name; - int value; + int value; } Jim_Nvp; - -int Jim_GetNvp (Jim_Interp *interp, - Jim_Obj *objPtr, - const Jim_Nvp *nvp_table, - const Jim_Nvp **result); +int Jim_GetNvp(Jim_Interp *interp, + Jim_Obj *objPtr, + const Jim_Nvp *nvp_table, + const Jim_Nvp **result); /* Name Value Pairs Operations */ Jim_Nvp *Jim_Nvp_name2value_simple(const Jim_Nvp *nvp_table, const char *name); Jim_Nvp *Jim_Nvp_name2value_nocase_simple(const Jim_Nvp *nvp_table, const char *name); Jim_Nvp *Jim_Nvp_value2name_simple(const Jim_Nvp *nvp_table, int v); -int Jim_Nvp_name2value(Jim_Interp *interp, const Jim_Nvp *nvp_table, const char *name, Jim_Nvp **result); -int Jim_Nvp_name2value_nocase(Jim_Interp *interp, const Jim_Nvp *nvp_table, const char *name, Jim_Nvp **result); +int Jim_Nvp_name2value(Jim_Interp *interp, + const Jim_Nvp *nvp_table, + const char *name, + Jim_Nvp **result); +int Jim_Nvp_name2value_nocase(Jim_Interp *interp, + const Jim_Nvp *nvp_table, + const char *name, + Jim_Nvp **result); int Jim_Nvp_value2name(Jim_Interp *interp, const Jim_Nvp *nvp_table, int value, Jim_Nvp **result); -int Jim_Nvp_name2value_obj(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *name_obj, Jim_Nvp **result); -int Jim_Nvp_name2value_obj_nocase(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *name_obj, Jim_Nvp **result); -int Jim_Nvp_value2name_obj(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *value_obj, Jim_Nvp **result); +int Jim_Nvp_name2value_obj(Jim_Interp *interp, + const Jim_Nvp *nvp_table, + Jim_Obj *name_obj, + Jim_Nvp **result); +int Jim_Nvp_name2value_obj_nocase(Jim_Interp *interp, + const Jim_Nvp *nvp_table, + Jim_Obj *name_obj, + Jim_Nvp **result); +int Jim_Nvp_value2name_obj(Jim_Interp *interp, + const Jim_Nvp *nvp_table, + Jim_Obj *value_obj, + Jim_Nvp **result); /** prints a nice 'unknown' parameter error message to the 'result' */ void Jim_SetResult_NvpUnknown(Jim_Interp *interp, - Jim_Obj *param_name, - Jim_Obj *param_value, - const Jim_Nvp *nvp_table); - + Jim_Obj *param_name, + Jim_Obj *param_value, + const Jim_Nvp *nvp_table); /** Debug: convert argc/argv into a printable string for printf() debug * @@ -102,10 +158,10 @@ const char *Jim_Debug_ArgvString(Jim_Interp *interp, int argc, Jim_Obj *const *a */ typedef struct jim_getopt { - Jim_Interp *interp; - int argc; - Jim_Obj * const * argv; - int isconfigure; /* non-zero if configure */ + Jim_Interp *interp; + int argc; + Jim_Obj *const *argv; + int isconfigure; /* non-zero if configure */ } Jim_GetOptInfo; /** GetOpt - how to. @@ -165,9 +221,9 @@ typedef struct jim_getopt { */ int Jim_GetOpt_Setup(Jim_GetOptInfo *goi, - Jim_Interp *interp, - int argc, - Jim_Obj * const * argv); + Jim_Interp *interp, + int argc, + Jim_Obj *const *argv); /** Debug - Dump parameters to stderr @@ -175,8 +231,6 @@ int Jim_GetOpt_Setup(Jim_GetOptInfo *goi, */ void Jim_GetOpt_Debug(Jim_GetOptInfo *goi); - - /** Remove argv[0] from the list. * * \param goi - get opt info @@ -270,6 +324,6 @@ void Jim_GetOpt_NvpUnknown(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, int hadpr * \param puthere - where param is put. * */ -int Jim_GetOpt_Enum(Jim_GetOptInfo *goi, const char * const * lookup, int *puthere); +int Jim_GetOpt_Enum(Jim_GetOptInfo *goi, const char *const *lookup, int *puthere); #endif