jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / helper / jim-nvp.h
index 05d79c4a7d899d5c519f908853c70bfa9895221c..11824cabf4e0d272a3b31da2271a98dcea233329 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Views */
+
 /* Jim - A small embeddable Tcl interpreter
  *
  * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
  * Copyright 2009 Nico Coesel <ncoesel@dealogic.nl>
  * 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.
+ * Copyright (c) 2005-2011 Jim Tcl Project. All rights reserved.
  */
 
-#ifndef JIM_NVP_H
-#define JIM_NVP_H
+#ifndef OPENOCD_HELPER_JIM_NVP_H
+#define OPENOCD_HELPER_JIM_NVP_H
 
 #include <jim.h>
 
@@ -62,7 +37,7 @@
  *
  * Example:
  * \code
- *      const Jim_Nvp yn[] = {
+ *      const struct jim_nvp yn[] = {
  *          { "yes", 1 },
  *          { "no" , 0 },
  *          { "yep", 1 },
  *          { NULL, -1 },
  *      };
  *
- *  Jim_Nvp *result
- *  e = Jim_Nvp_name2value(interp, yn, "y", &result);
+ *  struct jim_nvp *result
+ *  e = jim_nvp_name2value(interp, yn, "y", &result);
  *         returns &yn[0];
- *  e = Jim_Nvp_name2value(interp, yn, "n", &result);
+ *  e = jim_nvp_name2value(interp, yn, "n", &result);
  *         returns &yn[1];
- *  e = Jim_Nvp_name2value(interp, yn, "Blah", &result);
+ *  e = jim_nvp_name2value(interp, yn, "Blah", &result);
  *         returns &yn[4];
  * \endcode
  *
  * During the number2name operation, the first matching value is returned.
  */
-typedef struct {
+struct jim_nvp {
        const char *name;
        int value;
-} Jim_Nvp;
+};
 
-int Jim_GetNvp(Jim_Interp *interp,
-               Jim_Obj *objPtr,
-               const Jim_Nvp *nvp_table,
-               const Jim_Nvp **result);
+int jim_get_nvp(Jim_Interp *interp,
+               Jim_Obj *objptr,
+               const struct jim_nvp *nvp_table,
+               const struct 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);
+struct jim_nvp *jim_nvp_name2value_simple(const struct jim_nvp *nvp_table, const char *name);
+struct jim_nvp *jim_nvp_name2value_nocase_simple(const struct jim_nvp *nvp_table, const char *name);
+struct jim_nvp *jim_nvp_value2name_simple(const struct jim_nvp *nvp_table, int v);
 
-int Jim_Nvp_name2value(Jim_Interp *interp,
-               const Jim_Nvp *nvp_table,
+int jim_nvp_name2value(Jim_Interp *interp,
+               const struct jim_nvp *nvp_table,
                const char *name,
-               Jim_Nvp **result);
-int Jim_Nvp_name2value_nocase(Jim_Interp *interp,
-               const Jim_Nvp *nvp_table,
+               struct jim_nvp **result);
+int jim_nvp_name2value_nocase(Jim_Interp *interp,
+               const struct 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);
+               struct jim_nvp **result);
+int jim_nvp_value2name(Jim_Interp *interp, const struct jim_nvp *nvp_table, int value, struct jim_nvp **result);
 
-int Jim_Nvp_name2value_obj(Jim_Interp *interp,
-               const Jim_Nvp *nvp_table,
+int jim_nvp_name2value_obj(Jim_Interp *interp,
+               const struct 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,
+               struct jim_nvp **result);
+int jim_nvp_name2value_obj_nocase(Jim_Interp *interp,
+               const struct jim_nvp *nvp_table,
                Jim_Obj *name_obj,
-               Jim_Nvp **result);
-int Jim_Nvp_value2name_obj(Jim_Interp *interp,
-               const Jim_Nvp *nvp_table,
+               struct jim_nvp **result);
+int jim_nvp_value2name_obj(Jim_Interp *interp,
+               const struct jim_nvp *nvp_table,
                Jim_Obj *value_obj,
-               Jim_Nvp **result);
+               struct jim_nvp **result);
 
 /** prints a nice 'unknown' parameter error message to the 'result' */
-void Jim_SetResult_NvpUnknown(Jim_Interp *interp,
+void jim_set_result_nvp_unknown(Jim_Interp *interp,
                Jim_Obj *param_name,
                Jim_Obj *param_value,
-               const Jim_Nvp *nvp_table);
+               const struct jim_nvp *nvp_table);
 
 /** Debug: convert argc/argv into a printable string for printf() debug
  *
- * \param interp - the interpeter
+ * \param interp - the interpreter
  * \param argc   - arg count
  * \param argv   - the objects
  *
@@ -142,7 +117,7 @@ void Jim_SetResult_NvpUnknown(Jim_Interp *interp,
  *     fclose(fp);
  * \endcode
  */
-const char *Jim_Debug_ArgvString(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
+const char *jim_debug_argv_string(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
 
 
 /** A TCL -ish GetOpt like code.
@@ -150,32 +125,32 @@ const char *Jim_Debug_ArgvString(Jim_Interp *interp, int argc, Jim_Obj *const *a
  * Some TCL objects have various "configuration" values.
  * For example - in Tcl/Tk the "buttons" have many options.
  *
- * Usefull when dealing with command options.
+ * Useful when dealing with command options.
  * that may come in any order...
  *
  * Does not support "-foo = 123" type options.
  * Only supports tcl type options, like "-foo 123"
  */
 
-typedef struct jim_getopt {
+struct jim_getopt_info {
        Jim_Interp *interp;
        int argc;
        Jim_Obj *const *argv;
        int isconfigure;                /* non-zero if configure */
-} Jim_GetOptInfo;
+};
 
 /** GetOpt - how to.
  *
  * Example (short and incomplete):
  * \code
- *   Jim_GetOptInfo goi;
+ *   struct jim_getopt_info goi;
  *
- *   Jim_GetOpt_Setup(&goi, interp, argc, argv);
+ *   jim_getopt_setup(&goi, interp, argc, argv);
  *
  *   while (goi.argc) {
- *         e = Jim_GetOpt_Nvp(&goi, nvp_options, &n);
+ *         e = jim_getopt_nvp(&goi, nvp_options, &n);
  *         if (e != JIM_OK) {
- *               Jim_GetOpt_NvpUnknown(&goi, nvp_options, 0);
+ *               jim_getopt_nvp_unknown(&goi, nvp_options, 0);
  *               return e;
  *         }
  *
@@ -187,16 +162,16 @@ typedef struct jim_getopt {
  *             if (goi.argc < 1) {
  *                     .. not enough args error ..
  *             }
- *             Jim_GetOpt_String(&goi, &cp, NULL);
+ *             jim_getopt_string(&goi, &cp, NULL);
  *             printf("FIRSTNAME: %s\n", cp);
  *         case AGE:
- *             Jim_GetOpt_Wide(&goi, &w);
+ *             jim_getopt_wide(&goi, &w);
  *             printf("AGE: %d\n", (int)(w));
  *             break;
  *         case POLITICS:
- *             e = Jim_GetOpt_Nvp(&goi, nvp_politics, &n);
+ *             e = jim_getopt_nvp(&goi, nvp_politics, &n);
  *             if (e != JIM_OK) {
- *                 Jim_GetOpt_NvpUnknown(&goi, nvp_politics, 1);
+ *                 jim_getopt_nvp_unknown(&goi, nvp_politics, 1);
  *                 return e;
  *             }
  *         }
@@ -214,13 +189,13 @@ typedef struct jim_getopt {
  * \param argv   - argv (will be copied)
  *
  * \code
- *     Jim_GetOptInfo  goi;
+ *     struct jim_getopt_info  goi;
  *
  *     Jim_GetOptSetup(&goi, interp, argc, argv);
  * \endcode
  */
 
-int Jim_GetOpt_Setup(Jim_GetOptInfo *goi,
+int jim_getopt_setup(struct jim_getopt_info *goi,
                Jim_Interp *interp,
                int argc,
                Jim_Obj *const *argv);
@@ -229,7 +204,7 @@ int Jim_GetOpt_Setup(Jim_GetOptInfo *goi,
 /** Debug - Dump parameters to stderr
  * \param goi - current parameters
  */
-void Jim_GetOpt_Debug(Jim_GetOptInfo *goi);
+void jim_getopt_debug(struct jim_getopt_info *goi);
 
 /** Remove argv[0] from the list.
  *
@@ -237,7 +212,7 @@ void Jim_GetOpt_Debug(Jim_GetOptInfo *goi);
  * \param puthere - where param is put
  *
  */
-int Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere);
+int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere);
 
 /** Remove argv[0] as string.
  *
@@ -245,7 +220,7 @@ int Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere);
  * \param puthere - where param is put
  * \param len     - return its length
  */
-int Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len);
+int jim_getopt_string(struct jim_getopt_info *goi, const char **puthere, int *len);
 
 /** Remove argv[0] as double.
  *
@@ -253,14 +228,14 @@ int Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len);
  * \param puthere - where param is put.
  *
  */
-int Jim_GetOpt_Double(Jim_GetOptInfo *goi, double *puthere);
+int jim_getopt_double(struct jim_getopt_info *goi, double *puthere);
 
 /** Remove argv[0] as wide.
  *
  * \param goi     - get opt info
  * \param puthere - where param is put.
  */
-int Jim_GetOpt_Wide(Jim_GetOptInfo *goi, jim_wide *puthere);
+int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere);
 
 /** Remove argv[0] as NVP.
  *
@@ -269,7 +244,7 @@ int Jim_GetOpt_Wide(Jim_GetOptInfo *goi, jim_wide *puthere);
  * \param puthere - where param is put.
  *
  */
-int Jim_GetOpt_Nvp(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, Jim_Nvp **puthere);
+int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *lookup, struct jim_nvp **puthere);
 
 /** Create an appropriate error message for an NVP.
  *
@@ -289,20 +264,20 @@ int Jim_GetOpt_Nvp(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, Jim_Nvp **puthere
  *
  *  while (goi.argc) {
  *     // Get the next option
- *     e = Jim_GetOpt_Nvp(&goi, cmd_options, &n);
+ *     e = jim_getopt_nvp(&goi, cmd_options, &n);
  *     if (e != JIM_OK) {
  *          // option was not recognized
  *          // pass 'hadprefix = 0' because there is no prefix
- *          Jim_GetOpt_NvpUnknown(&goi, cmd_options, 0);
+ *          jim_getopt_nvp_unknown(&goi, cmd_options, 0);
  *          return e;
  *     }
  *
  *     switch (n->value) {
  *     case OPT_SEX:
  *          // handle:  --sex male | female | lots | needmore
- *          e = Jim_GetOpt_Nvp(&goi, &nvp_sex, &n);
+ *          e = jim_getopt_nvp(&goi, &nvp_sex, &n);
  *          if (e != JIM_OK) {
- *               Jim_GetOpt_NvpUnknown(&ogi, nvp_sex, 1);
+ *               jim_getopt_nvp_unknown(&ogi, nvp_sex, 1);
  *               return e;
  *          }
  *          printf("Code: (%d) is %s\n", n->value, n->name);
@@ -314,7 +289,7 @@ int Jim_GetOpt_Nvp(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, Jim_Nvp **puthere
  * \endcode
  *
  */
-void Jim_GetOpt_NvpUnknown(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, int hadprefix);
+void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *lookup, int hadprefix);
 
 
 /** Remove argv[0] as Enum
@@ -324,6 +299,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(struct jim_getopt_info *goi, const char *const *lookup, int *puthere);
 
-#endif
+#endif /* OPENOCD_HELPER_JIM_NVP_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)