1: /*
2: * $Id: cmd_kvalue.c,v 1.3 2025/03/09 19:14:24 snw Exp $
3: * Implementation of the KVALUE command
4: *
5: *
6: * Author: Serena Willis <snw@coherent-logic.com>
7: * Copyright (C) 1998 MUG Deutschland
8: * Copyright (C) 2023, 2025 Coherent Logic Development LLC
9: *
10: *
11: * This file is part of FreeM.
12: *
13: * FreeM is free software: you can redistribute it and/or modify
14: * it under the terms of the GNU Affero Public License as published by
15: * the Free Software Foundation, either version 3 of the License, or
16: * (at your option) any later version.
17: *
18: * FreeM is distributed in the hope that it will be useful,
19: * but WITHOUT ANY WARRANTY; without even the implied warranty of
20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: * GNU Affero Public License for more details.
22: *
23: * You should have received a copy of the GNU Affero Public License
24: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
25: *
26: * $Log: cmd_kvalue.c,v $
27: * Revision 1.3 2025/03/09 19:14:24 snw
28: * First phase of REUSE compliance and header reformat
29: *
30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
33: **/
34:
35: #include <string.h>
36: #include <stdlib.h>
37: #include "mpsdef.h"
38: #include "mcommand.h"
39: #include "consttbl.h"
40:
41: MRESULT cmd_kvalue(MACTION *ra)
42: {
43: register char ch;
44: char vn[255];
45:
46: if ((rtn_dialect () != D_FREEM) &&
47: (rtn_dialect () != D_MDS)) {
48: return NOSTAND;
49: }
50:
51: /* argumentless: KVALUE nukleurrr winturr */
52: if (((ch = *codptr) == SP) || ch == EOL) {
53: write_m ("Argumentless KVALUE not yet implemented.\201");
54: *ra = RA_NEXTCMND;
55: return OK;
56: }
57:
58:
59: if (ch != '(') { /* inclusive KVALUE */
60:
61: for (;;) {
62:
63: expr (NAME); /* try to interpret an mname */
64: if (merr ()) return merr ();
65:
66: stcpy (vn, varnam);
67:
68: if (vn[0] != '^') {
69: symtab (killone, vn, NULL);
70: }
71: else {
72: if (vn[1] == '$') {
73: ssvn (killone, vn, NULL);
74: }
75: else {
76: global (killone, vn, NULL);
77: }
78: }
79:
80: if (merr ()) return merr ();
81:
82: if ((ch = *(codptr + 1)) == EOL) {
83: codptr++;
84: break;
85: }
86: else if (ch == ',') {
87: codptr += 2;
88: }
89: else {
90: return CMMND;
91: }
92: }
93:
94: }
95: else { /* exclusive KVALUE */
96:
97: write_m ("Exclusive KVALUE not yet implemented.\201");
98:
99: while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */
100:
101: }
102:
103: *ra = RA_NEXTCMND;
104: return OK;
105: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>