File:  [Coherent Logic Development] / freem / src / cmd_unmap.c
Revision 1.3: download - view: text, annotated - select for diffs
Sun Mar 9 19:14:24 2025 UTC (3 weeks, 2 days ago) by snw
Branches: MAIN
CVS tags: v0-62-3, v0-62-2, v0-62-1, v0-62-0, HEAD
First phase of REUSE compliance and header reformat

/*
 *   $Id: cmd_unmap.c,v 1.3 2025/03/09 19:14:24 snw Exp $
 *    Implementation of the UNMAP command
 *
 *  
 *   Author: Serena Willis <snw@coherent-logic.com>
 *    Copyright (C) 1998 MUG Deutschland
 *    Copyright (C) 2023, 2025 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_unmap.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_unmap(MACTION *ra)
{
    char mapping_type;
    char mapping_obj[256];
    char tmp_data[256];
    char tmp_key[256];
    
    if (rtn_dialect () != D_FREEM) {
        return NOSTAND;
    }
    
    if (is_standard ()) {
        return NOSTAND;
    }
    
    expr (NAME);
    if (merr ()) return merr ();
    
    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);
    
    snprintf (tmp_key, 255, "^$SYSTEM\202MAPPINGS\202GLOBAL\202%s\201", mapping_obj);
    global (kill_sym, tmp_key, tmp_data);
    
    codptr++;
    
    *ra = RA_CONTINUE;
    return OK;
    
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>