Annotation of freem/src/cmd_map.c, revision 1.4
1.1 snw 1: /*
1.4 ! snw 2: * $Id: cmd_map.c,v 1.3 2025/03/09 19:14:24 snw Exp $
1.1 snw 3: * Implementation of the MAP command
4: *
5: *
1.2 snw 6: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 7: * Copyright (C) 1998 MUG Deutschland
8: * Copyright (C) 2023 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: *
1.4 ! snw 26: * $Log: cmd_map.c,v $
! 27: * Revision 1.3 2025/03/09 19:14:24 snw
! 28: * First phase of REUSE compliance and header reformat
! 29: *
1.3 snw 30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
1.1 snw 33: **/
34:
35: #include <string.h>
36: #include <stdlib.h>
37: #include "mpsdef.h"
38: #include "mcommand.h"
39:
40: MRESULT cmd_map(MACTION *ra)
41: {
42: char mapping_obj[256];
43: char mapping_ns[256];
44: char tmp_key[256];
45:
46: if (rtn_dialect () != D_FREEM) {
47: return NOSTAND;
48: }
49:
50: if (is_standard ()) {
51: return NOSTAND;
52: }
53:
54: expr (NAME);
55:
1.4 ! snw 56: if (stcmp (varnam, "GLOBAL\201") != 0 && stcmp (varnam, "global\201") != 0 && stcmp (varnam, "ROUTINE\201") != 0 && stcmp (varnam, "routine\201") != 0) {
1.1 snw 57: return ARGLIST;
58: }
59:
60: codptr += 2;
61:
62: expr (NAME);
63: if (merr ()) return merr ();
64:
65: stcpy (mapping_obj, varnam);
66: stcnv_m2c (mapping_obj);
67:
68: codptr++;
69:
70: if (*codptr != '=') {
71: return ASSIGNER;
72: }
73:
74: codptr++;
75:
76: expr (STRING);
77: if (merr ()) return merr ();
78:
79: stcpy (mapping_ns, argptr);
80:
81: snprintf (tmp_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202%s\201", mapping_obj);
82: global (set_sym, tmp_key, mapping_ns);
83:
84: *ra = RA_CONTINUE;
85: return OK;
86:
87: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>