File:  [Coherent Logic Development] / freem / src / ssvn_character.c
Revision 1.3: download - view: text, annotated - select for diffs
Sun Mar 9 19:50:47 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
Second phase of REUSE compliance and header reformat

/*
 *   $Id: ssvn_character.c,v 1.3 2025/03/09 19:50:47 snw Exp $
 *    ^$CHARACTER ssvn
 *
 *  
 *   Author: Serena Willis <snw@coherent-logic.com>
 *    Copyright (C) 1998 MUG Deutschland
 *    Copyright (C) 2020, 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: ssvn_character.c,v $
 *   Revision 1.3  2025/03/09 19:50:47  snw
 *   Second phase of REUSE compliance and header reformat
 *
 *
 * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
 * SPDX-License-Identifier: AGPL-3.0-or-later
 **/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mref.h"
#include "mpsdef.h"

void ssvn_character(short action, char *key, char *data)
{
    freem_ref_t *r = (freem_ref_t *) malloc (sizeof (freem_ref_t));
    NULLPTRCHK(r,"ssvn_character");

    mref_init (r, MREF_RT_SSV, "^$CHARACTER");
    internal_to_mref (r, key);

    switch (action) {

        case get_sym:

            if (strcmp (mref_get_subscript (r, 0), "M") != 0) {
                merr_raise (M38);
                goto done;
            }

            if (strcmp (mref_get_subscript (r, 1), "PATCODE") == 0) {
                merr_raise (M38);
                goto done;
            }
            
            if (strcmp (mref_get_subscript (r, 1), "IDENT") == 0) {
                merr_raise (OK);
                *data = '\201';
                goto done;
            }
            else if (strcmp (mref_get_subscript (r, 1), "COLLATE") == 0) {
                merr_raise (OK);
                *data = '\201';
                goto done;
            }
            else if (strcmp (mref_get_subscript (r, 1), "INPUT") == 0) {

                if (strcmp (mref_get_subscript (r, 2), "M") != 0) {
                    merr_raise (M38);
                    goto done;
                }

                *data = '\201';
                merr_raise (OK);
                goto done;
                
            }
            else if (strcmp (mref_get_subscript (r, 1), "OUTPUT") == 0) {

                if (strcmp (mref_get_subscript (r, 2), "M") != 0) {
                    merr_raise (M38);
                    goto done;
                }

                *data = '\201';
                merr_raise (OK);
                goto done;
                
            }
            
            merr_raise (OK);
            goto done;
            
        default:
            merr_raise (M29);
            goto done;
    }


done:
    free (r);
    
    return;
}

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