File:  [Coherent Logic Development] / freem / src / cmd_map.c
Revision 1.5: download - view: text, annotated - select for diffs
Sun Apr 13 04:22:43 2025 UTC (3 months, 2 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Fix snprintf calls

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

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