/*
* $Id: cmd_map.c,v 1.3 2025/03/09 19:14:24 snw Exp $
* Implementation of the MAP command
*
*
* Author: Serena Willis <snw@coherent-logic.com>
* Copyright (C) 1998 MUG Deutschland
* Copyright (C) 2023 Coherent Logic Development LLC
*
*
* This file is part of FreeM.
*
* FreeM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with FreeM. If not, see <https://www.gnu.org/licenses/>.
*
* $Log: cmd_map.c,v $
* Revision 1.3 2025/03/09 19:14:24 snw
* First phase of REUSE compliance and header reformat
*
*
* SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
* SPDX-License-Identifier: AGPL-3.0-or-later
**/
#include <string.h>
#include <stdlib.h>
#include "mpsdef.h"
#include "mcommand.h"
MRESULT cmd_map(MACTION *ra)
{
char mapping_type;
char mapping_obj[256];
char mapping_ns[256];
char tmp_key[256];
if (rtn_dialect () != D_FREEM) {
return NOSTAND;
}
if (is_standard ()) {
return NOSTAND;
}
expr (NAME);
if (stcmp (varnam, "GLOBAL\201") == 0 || stcmp (varnam, "global\201") == 0) {
mapping_type = 'g';
}
else if (stcmp (varnam, "ROUTINE\201") == 0 || stcmp (varnam, "routine\201") == 0) {
mapping_type = 'r';
return ARGLIST;
}
else {
return ARGLIST;
}
codptr += 2;
expr (NAME);
if (merr ()) return merr ();
stcpy (mapping_obj, varnam);
stcnv_m2c (mapping_obj);
codptr++;
if (*codptr != '=') {
return ASSIGNER;
}
codptr++;
expr (STRING);
if (merr ()) return merr ();
stcpy (mapping_ns, argptr);
snprintf (tmp_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202%s\201", mapping_obj);
global (set_sym, tmp_key, mapping_ns);
*ra = RA_CONTINUE;
return OK;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>