File:  [Coherent Logic Development] / freem / src / cmd_throw.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_throw.c,v 1.3 2025/03/09 19:14:24 snw Exp $
 *    Implementation of the THROW 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_throw.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_throw(MACTION *ra)
{
    char *throw_buf;
    register char ch;
    
    if (rtn_dialect () != D_FREEM) {
        return NOSTAND;
    }
    
    throw_buf = (char *) malloc (STRLEN * sizeof (char));
    NULLPTRCHK (throw_buf, "cmd_throw");
    
    expr (STRING);
    if (merr ()) return merr ();
    
    stcnv_m2c (argptr);
    
    snprintf (throw_buf, STRLEN - 1, ",%s,\201", argptr);
    
    merr_raise (merr_set_ecode (throw_buf));   
    
    free (throw_buf);
    
    if (merr ()) return merr ();
    
    while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */

    *ra = RA_NEXTCMND;
    return merr ();
}

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