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 (4 months, 3 weeks ago) by snw
Branches: MAIN
CVS tags: v0-63-1-rc1, v0-63-0-rc1, v0-63-0, v0-62-3, v0-62-2, v0-62-1, v0-62-0, HEAD
Second phase of REUSE compliance and header reformat

    1: /*
    2:  *   $Id: ssvn_character.c,v 1.3 2025/03/09 19:50:47 snw Exp $
    3:  *    ^$CHARACTER ssvn
    4:  *
    5:  *  
    6:  *   Author: Serena Willis <snw@coherent-logic.com>
    7:  *    Copyright (C) 1998 MUG Deutschland
    8:  *    Copyright (C) 2020, 2025 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: ssvn_character.c,v $
   27:  *   Revision 1.3  2025/03/09 19:50:47  snw
   28:  *   Second phase of REUSE compliance and header reformat
   29:  *
   30:  *
   31:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
   32:  * SPDX-License-Identifier: AGPL-3.0-or-later
   33:  **/
   34: 
   35: #include <stdio.h>
   36: #include <stdlib.h>
   37: #include <string.h>
   38: #include "mref.h"
   39: #include "mpsdef.h"
   40: 
   41: void ssvn_character(short action, char *key, char *data)
   42: {
   43:     freem_ref_t *r = (freem_ref_t *) malloc (sizeof (freem_ref_t));
   44:     NULLPTRCHK(r,"ssvn_character");
   45: 
   46:     mref_init (r, MREF_RT_SSV, "^$CHARACTER");
   47:     internal_to_mref (r, key);
   48: 
   49:     switch (action) {
   50: 
   51:         case get_sym:
   52: 
   53:             if (strcmp (mref_get_subscript (r, 0), "M") != 0) {
   54:                 merr_raise (M38);
   55:                 goto done;
   56:             }
   57: 
   58:             if (strcmp (mref_get_subscript (r, 1), "PATCODE") == 0) {
   59:                 merr_raise (M38);
   60:                 goto done;
   61:             }
   62:             
   63:             if (strcmp (mref_get_subscript (r, 1), "IDENT") == 0) {
   64:                 merr_raise (OK);
   65:                 *data = '\201';
   66:                 goto done;
   67:             }
   68:             else if (strcmp (mref_get_subscript (r, 1), "COLLATE") == 0) {
   69:                 merr_raise (OK);
   70:                 *data = '\201';
   71:                 goto done;
   72:             }
   73:             else if (strcmp (mref_get_subscript (r, 1), "INPUT") == 0) {
   74: 
   75:                 if (strcmp (mref_get_subscript (r, 2), "M") != 0) {
   76:                     merr_raise (M38);
   77:                     goto done;
   78:                 }
   79: 
   80:                 *data = '\201';
   81:                 merr_raise (OK);
   82:                 goto done;
   83:                 
   84:             }
   85:             else if (strcmp (mref_get_subscript (r, 1), "OUTPUT") == 0) {
   86: 
   87:                 if (strcmp (mref_get_subscript (r, 2), "M") != 0) {
   88:                     merr_raise (M38);
   89:                     goto done;
   90:                 }
   91: 
   92:                 *data = '\201';
   93:                 merr_raise (OK);
   94:                 goto done;
   95:                 
   96:             }
   97:             
   98:             merr_raise (OK);
   99:             goto done;
  100:             
  101:         default:
  102:             merr_raise (M29);
  103:             goto done;
  104:     }
  105: 
  106: 
  107: done:
  108:     free (r);
  109:     
  110:     return;
  111: }

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