helper: nvp: add openocd nvp files
[openocd.git] / src / helper / nvp.c
1 // SPDX-License-Identifier: BSD-2-Clause-Views
2
3 /*
4 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
5 * Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
6 * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
7 * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
8 * Copyright 2008 Andrew Lunn <andrew@lunn.ch>
9 * Copyright 2008 Duane Ellis <openocd@duaneellis.com>
10 * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
11 * Copyright 2008 Steve Bennett <steveb@workware.net.au>
12 * Copyright 2009 Nico Coesel <ncoesel@dealogic.nl>
13 * Copyright 2009 Zachary T Welch zw@superlucidity.net
14 * Copyright 2009 David Brownell
15 * Copyright (c) 2005-2011 Jim Tcl Project. All rights reserved.
16 *
17 * This file is extracted from jim_nvp.c, originally part of jim TCL code.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <string.h>
25
26 #include <helper/command.h>
27 #include <helper/nvp.h>
28
29 const struct nvp *nvp_name2value(const struct nvp *p, const char *name)
30 {
31 while (p->name) {
32 if (strcmp(name, p->name) == 0)
33 break;
34 p++;
35 }
36 return p;
37 }
38
39 const struct nvp *nvp_value2name(const struct nvp *p, int value)
40 {
41 while (p->name) {
42 if (value == p->value)
43 break;
44 p++;
45 }
46 return p;
47 }
48
49 void nvp_unknown_command_print(struct command_invocation *cmd, const struct nvp *nvp,
50 const char *param_name, const char *param_value)
51 {
52 if (param_name)
53 command_print_sameline(cmd, "%s: Unknown: %s, try one of: ", param_name, param_value);
54 else
55 command_print_sameline(cmd, "Unknown param: %s, try one of: ", param_value);
56
57 while (nvp->name) {
58 if ((nvp + 1)->name)
59 command_print_sameline(cmd, "%s, ", nvp->name);
60 else
61 command_print(cmd, "or %s", nvp->name);
62
63 nvp++;
64 }
65
66 /* We assume nvp to be not empty and loop has been taken; no need to add a '\n' */
67 }

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)