Annotation of freem/src/mpsdef0.h, revision 1.14

1.1       snw         1: /*
1.14    ! snw         2:  *   $Id: mpsdef0.h,v 1.13 2025/03/24 04:13:11 snw Exp $
1.1       snw         3:  *    common constants definitions for all mumps modules
                      4:  *
                      5:  *  
1.6       snw         6:  *   Author: Serena Willis <snw@coherent-logic.com>
1.1       snw         7:  *    Copyright (C) 1998 MUG Deutschland
1.7       snw         8:  *    Copyright (C) 2020, 2023, 2025 Coherent Logic Development LLC
1.1       snw         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:  *
1.8       snw        26:  *   $Log: mpsdef0.h,v $
1.14    ! snw        27:  *   Revision 1.13  2025/03/24 04:13:11  snw
        !            28:  *   Replace action macro dat with fra_dat to avoid symbol conflict on OS/2
        !            29:  *
1.13      snw        30:  *   Revision 1.12  2025/03/24 01:48:40  snw
                     31:  *   Make symtab action defines more portable
                     32:  *
1.12      snw        33:  *   Revision 1.11  2025/03/24 01:47:38  snw
                     34:  *   Make symtab action defines more portable
                     35:  *
1.11      snw        36:  *   Revision 1.10  2025/03/24 01:35:23  snw
                     37:  *   Make symtab action defines more portable
                     38:  *
1.10      snw        39:  *   Revision 1.9  2025/03/22 22:52:24  snw
                     40:  *   Add STRLEN_GBL macro to manage global string length
                     41:  *
1.9       snw        42:  *   Revision 1.8  2025/03/22 18:43:54  snw
                     43:  *   Make STRLEN 255 chars and add BIGSTR macro for larger buffers
                     44:  *
1.8       snw        45:  *   Revision 1.7  2025/03/09 19:50:47  snw
                     46:  *   Second phase of REUSE compliance and header reformat
                     47:  *
1.7       snw        48:  *
                     49:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                     50:  * SPDX-License-Identifier: AGPL-3.0-or-later
1.1       snw        51:  **/
                     52: 
1.5       snw        53: /*#pragma GCC diagnostic ignored "-Wformat-contains-nul"*/
1.1       snw        54: 
                     55: #ifdef HAVE_CONFIG_H
                     56: # include <config.h>
                     57: #endif
                     58: 
                     59: #ifdef HAVE_WIRINGPI_H
                     60: #define register
                     61: #endif
                     62: 
                     63: #include <signal.h>
                     64: #include <stddef.h>
                     65: 
                     66: #ifndef        MDC_VENDOR_ID
                     67: #define MDC_VENDOR_ID 49
                     68: #endif/*MDC_VENDOR_ID*/
                     69: 
                     70: #define byte char
                     71: #define toggle(A) (A^=01)
                     72: 
                     73: /* if you do not want to run under SCO-UNIX, put the following in comment */
                     74: 
                     75: #define SCO
                     76: 
                     77: /* if you want mumps to run under XENIX, put the following in comment */
                     78: #define SYSFIVE
                     79: 
                     80: /* if you want mumps to run under LINUX, un-comment the following */
                     81: #define LINUX
                     82: 
                     83: /* rlf 01/15/99 If you want to compile under libc-6 (GLIBC), as on */
                     84: /*              RedHat Linux >= 5.0, define LINUX_GLIBC.           */
                     85: #define LINUX_GLIBC
                     86: 
                     87: /* spz 4/19/99 If you want to compile under FreeBSD 2.2.8+, define the */
                     88: /* following line... */
                     89: /*#define FREEBSD */
                     90: 
                     91: /* spz 5/24/99 use the new variable stack */
                     92: /* #define NEWSTACK   */
                     93: /* #define DEBUG_NEWSTACK */
                     94: 
                     95: /* rlf 01/16/99 If you want German error messages, define EM_GERMAN   */
                     96: /*              If you want English error messages, define EM_ENGLISH */
                     97: #define EM_ENGLISH
                     98: 
                     99: /* lmv 1999-05-09 define this if you want to use gmtoff timezone data in */
                    100: /*                struct tm instead of tzadj                             */
                    101: #define USE_GMTOFF
                    102: 
                    103: /* lmv 1999-05-09 define this if you want to include sys/time.h */
                    104: #define USE_SYS_TIME_H
                    105: 
                    106: /* lmv 1999-05-09 define this if you want to use the gettimeofday function */
                    107: /*                instead of the ftime function                            */
                    108: #define USE_GETTIMEOFDAY
                    109: 
                    110: 
                    111: /* if you do not want MUMPS to support color terminals, put this in comment */
                    112: #ifdef SCO
                    113: #define COLOR
                    114: #endif /* SCO */
                    115: 
                    116: /* if you do not want MUMPS to support automatic DEM <--> EUR conversion, */
                    117: /* put this in comment */
                    118: #define EUR2DEM "1.95583\201"
                    119: 
                    120: /* end of line symbol  0201/-127 */
                    121: #define EOL ((char)'\201')
                    122: 
                    123: /* end of line symbol  0202/-126/130 */
                    124: #define DELIM ((char)'\202')
                    125: 
                    126: /* default size of a 'partition' i.e. intermediate result stack+local vars */
                    127: #define DEFPSIZE 8388608L
                    128: 
                    129: /* default size of 'userdefined special variable table' */
                    130: #define DEFUDFSVSIZ 1000
                    131: 
                    132: /* default size of the NEW stack */
                    133: #define DEFNSIZE 4096
                    134: 
                    135: /* default number & size of alternate routine buffers */
                    136: /* maximum number of routine buffers */
                    137: #define MAXNO_OF_RBUF 128
                    138: #define DEFNO_OF_RBUF 128
                    139: #define DEFPSIZE0 10001
                    140: 
                    141: /* number of global files concurrently open */
                    142: #define NO_GLOBLS 6
                    143: 
                    144: /* length of global blocks */
                    145: #define BLOCKLEN 1024
                    146: 
                    147: /* number of global buffers */
                    148: #define NO_OF_GBUF 6
                    149: 
                    150: /* number of DO_FOR_XECUTE levels; i.e. depth of gosub-stack */
                    151: #define NESTLEVLS 80
                    152: 
                    153: /* depth of parser stack; each pending operation/argument requires one entry */
                    154: #define PARDEPTH 128
                    155: 
                    156: /* pattern match stack; maximum number of pattern atoms */
                    157: #define PATDEPTH 14
                    158: 
                    159: /* trace limit in globals module, i.e. trees wo'nt grow to the sky */
                    160: #define TRLIM 32
                    161: 
                    162: /* arguments in an ESC_sequence */
                    163: #define ARGS_IN_ESC 5
                    164: 
                    165: /* maximum length of a string, 0 <= $L() <= 255 */
1.8       snw       166: #define STRLEN 255
1.9       snw       167: #define STRLEN_GBL 252
1.8       snw       168: #define BIGSTR 65535
1.1       snw       169: 
1.14    ! snw       170: /* length of destructors */
        !           171: #define OBJ_DSTRSIZE 50
        !           172: 
1.1       snw       173: /* length of $ZTRAP variable */
                    174: #define ZTLEN 20
                    175: 
                    176: /* length of $ZF (function key) variable */
                    177: #define FUNLEN 128
                    178: 
                    179: /* length of $V(3)...$V(8) i.e. path names */
                    180: #define PATHLEN 4096
                    181: 
                    182: /* length of error message */
                    183: #define ERRLEN 180
                    184: 
                    185: /* number of DATE types */
                    186: #define NO_DATETYPE 8
                    187: #define NO_TIMETYPE 2
                    188: #define MONTH_LEN 10
                    189: 
                    190: /* object stuff */
                    191: #define MAX_PRIVATE_KEYS 100
                    192: #define MAX_DESTRUCTORS 10
                    193: #define SC_UNCHANGED 0
                    194: #define SC_PUBLIC 1
                    195: #define SC_PRIVATE 2
                    196: 
                    197: 
                    198: /* number of zkey() production rules */
                    199: #define NO_V93 8
                    200: 
                    201: /* depth of CS/CRST (cursor save/restore) stack */
                    202: #define CSLEN 1
                    203: 
                    204: /* HOME device: number of lines and columns */
                    205: #define N_LINES 2000
                    206: #define N_COLUMNS 2000
                    207: 
                    208: #if !defined(FALSE)
                    209: # define FALSE   0
                    210: #endif
                    211: 
                    212: #if !defined(TRUE)
                    213: # define TRUE    1
                    214: #endif
                    215: 
                    216: #define DISABLE 0
                    217: #define ENABLE  1
                    218: 
                    219: /* parameters for set_io() */
                    220: #define UNIX    0
                    221: #define MUMPS   1
                    222: 
                    223: #include "merr.h"
                    224: 
                    225: /* HOME = default device */
                    226: #define HOME 0
                    227: /* number of devices/units */
                    228: #define MAXDEV 256
                    229: #define MAXSEQ 99       /* last sequential I/O channel */
                    230: #define FIRSTSCK 100    /* first socket I/O channel */
                    231: #define SCKCNT 155
                    232: #define MAXSCK SCKCNT-1
                    233: 
                    234: /* if tab_clear TBC (CSI 3g) and tab_set HTS (ESC H) are not processed */
                    235: /* by the 'HOME' device, define the symbol PROC_TAB to emulate them    */
                    236: /* #define PROC_TAB          #otherwise make it comment !!!            */
                    237: #define PROC_TAB
                    238: 
                    239: /* ASCII control character mnemonics */
                    240: #define NUL 0
                    241: #define SOH 1
                    242: #define STX 2
                    243: #define ETX 3
                    244: #define EOT 4
                    245: #define ENQ 5
                    246: #define ACK 6
                    247: #define BEL 7
                    248: #define BS 8
                    249: #if defined(TAB)
                    250: # undef TAB
                    251: #endif
                    252: #define TAB 9
                    253: #define LF 10
                    254: #define VT 11
                    255: #define FF 12
                    256: #define CR 13
                    257: #define SO 14
                    258: #define SI 15
                    259: #define DLE 16
                    260: #define DC1 17
                    261: #define DC2 18
                    262: #define DC3 19
                    263: #define DC4 20
                    264: #define NAK 21
                    265: #define SYN 22
                    266: #define ETB 23
                    267: #define CAN 24
                    268: #define EM 25
                    269: #define SUB 26
                    270: #if defined(ESC)
                    271: # undef ESC
                    272: #endif
                    273: #define ESC 27
                    274: #define FS 28
                    275: #define GS 29
                    276: #define RS 30
                    277: #define US 31
                    278: #define SP 32
                    279: #define DEL 127
                    280: 
                    281: /* function select in expr evaluator */
                    282: #define STRING 0
                    283: #define NAME 1
                    284: #define LABEL 2
                    285: #define OFFSET 3
                    286: #define ARGIND 4
                    287: 
                    288: /* function select in global/local/ssv variables management */
                    289: /* even numbers require 'read/write' access, odd numbers 'read' access */
                    290: #define set_sym  0
                    291: #define kill_sym 2
                    292: #define kill_all 4
                    293: #define killexcl 6
1.10      snw       294: #define new_sym 8
1.1       snw       295: #define new_all 10
                    296: #define newexcl 12
                    297: #define killone 14
                    298: #define merge_sym 16
                    299: #define lock_inc 24
                    300: #define lock_dec 26
                    301: #define lock_old 28
                    302: 
1.10      snw       303: #define get_sym 1
1.13      snw       304: #define fra_dat 3
1.10      snw       305: #define fra_order 5
                    306: #define fra_query 7
1.1       snw       307: #define bigquery 9
1.10      snw       308: #define getinc 11
1.1       snw       309: #define getnext 13
                    310: #define m_alias 15
1.10      snw       311: #define zdata 17
1.1       snw       312: 
                    313: /* sets 8th bit in A */
                    314: #define SETBIT(A) ((A)|0200)
                    315: /* needed if byte data are to be interpreted as unsigned integer */
                    316: 
                    317: #define UNSIGN(A) ((A)&0377)
                    318: 
                    319: /* Fail if pointer null */
                    320: extern void m_fatal(char *s);
                    321: #define NULLPTRCHK(p,s) if (p == NULL) m_fatal(s)
                    322: 
                    323: /* device control for terminal I/O */
                    324: 
                    325: #define ECHOON      (~DSW&BIT0)
                    326: #define DELMODE     (DSW&BIT2)
                    327: #define ESCSEQPROC  (DSW&BIT6)
                    328: #define CONVUPPER   (DSW&BIT14)
                    329: #define DELEMPTY    (DSW&BIT19)
                    330: #define NOCTRLS     (DSW&BIT20)
                    331: #define CTRLOPROC   (DSW&BIT21)
                    332: #define NOTYPEAHEAD (DSW&BIT25)
                    333: 
                    334: #define BIT0  1
                    335: #define BIT1  2
                    336: #define BIT2  4
                    337: #define BIT3  8
                    338: #define BIT4  16
                    339: #define BIT5  32
                    340: #define BIT6  64
                    341: #define BIT7  128
                    342: #define BIT8  256
                    343: #define BIT9  512
                    344: #define BIT10 1024
                    345: #define BIT11 2048
                    346: #define BIT12 4096
                    347: #define BIT13 8192
                    348: #define BIT14 16384
                    349: #define BIT15 32768
                    350: #define BIT16 65536
                    351: #define BIT17 131072
                    352: #define BIT18 262144
                    353: #define BIT19 524288
                    354: #define BIT20 1048576
                    355: #define BIT21 2097152
                    356: #define BIT22 4194304
                    357: #define BIT23 8388608
                    358: #define BIT24 16777216
                    359: #define BIT25 33554432
                    360: #define BIT26 67108864
                    361: #define BIT27 134217728
                    362: #define BIT28 268435456
                    363: #define BIT29 536870912
                    364: #define BIT30 1073741824
                    365: #define BIT31 2147483648
                    366: 
                    367: /* functions from mumps.c */
                    368: void    unnew (void);
                    369: 
                    370: #include "sighnd.h"
                    371: 
                    372: /* functions from expr.c */
                    373: void    expr (short extyp);
1.2       snw       374: void    zsyntax (char *a);
                    375: void    zkey (char *a, long type);
1.1       snw       376: short   is_horolog(char *s);
                    377: 
                    378: /* functions from ssvn.c */
                    379: void    ssvn (short action, char *key, char *data);
                    380: 
                    381: /* functions from ssvn_character.c */
                    382: void    ssvn_character(short action, char *key, char *data);
                    383: 
                    384: /* functions from ssvn_device.c */
                    385: void    ssvn_device(short action, char *key, char *data);
                    386: 
                    387: /* functions from ssvn_display.c */
                    388: void    ssvn_display_update(void);
                    389: void    ssvn_display(short action, char *key, char *data);
                    390: 
                    391: /* functions from ssvn_event.c */
                    392: void    ssvn_event(short action, char *key, char *data);
                    393: 
                    394: /* functions from ssvn_global.c */
                    395: void    ssvn_global(short action, char *key, char *data);
                    396: 
                    397: /* functions from ssvn_job.c */
                    398: void ssvn_job_add_device(int channel, char *device);
                    399: void ssvn_job_remove_device(int channel);
                    400: void    ssvn_job_update(void);
                    401: void    ssvn_job(short action, char *key, char *data);
                    402: void    frm_process_alias (char *key);
                    403: 
                    404: /* functions from ssvn_library.c */
                    405: void    ssvn_library(short action, char *key, char *data);
                    406: void    ssvn_library_update(void);
                    407: 
                    408: /* functions from ssvn_object.c */
                    409: void    ssvn_object(short action, char *key, char *data);
                    410: 
                    411: /* functions from ssvn_lock.c */
                    412: void    ssvn_lock_add(char *key, pid_t owner_job, int count);
                    413: void    ssvn_lock_remove(char *key);
                    414: void    ssvn_lock(short action, char *key, char *data);
                    415: 
                    416: /* functions from ssvn_routine.c */
                    417: void    ssvn_routine(short action, char *key, char *data);
                    418: void    ssvn_routine_update(void);
                    419: 
                    420: /* functions from ssvn_system.c */
                    421: void    ssvn_system(short action, char *key, char *data);
                    422: void    ssvn_system_update(void);
                    423: /* functions from ssvn_window.c */
                    424: void    ssvn_window(short action, char *key, char *data);
                    425: 
                    426: /* functions from ssvn_z.c */
                    427: void    ssvn_z(short action, char *key, char *data);
                    428: 
                    429: /* functions from ssvn_zos.c */
                    430: void    ssvn_zos(short action, char *key, char *data);
                    431: 
                    432: /* functions from ssvn_zfreem.c */
                    433: void    ssvn_zfreem(short action, char *key, char *data);
                    434: 
                    435: /* functions from ssvn_zprocess.c */
                    436: void    ssvn_zprocess(short action, char *key, char *data);
                    437: 
                    438: /* functions from ssvn_routine.c */
                    439: void    ssvn_routine_date(void);
                    440: 
                    441: #include "ssvn_zrpi.h"
                    442: 
                    443: /* functions from symtab_dispatch.c */
                    444: void symtab (short action, char *key, char *data);
1.2       snw       445: 
                    446: /* functions from symtab_bltin.c */
                    447: short int collate (char *s, char *t);
                    448: short int numeric (char *str);
                    449: short int comp (char *s, char *t);
                    450: void    intstr (char *str, short integ);
                    451: void    lintstr (char * str, long integ);
                    452: void    udfsvn (short action, char *key, char *data);
                    453: long    getpmore (void);
                    454: long    getumore (void);
                    455: long    getrmore (void);
                    456: short int getnewmore (void);
1.1       snw       457: 
                    458: /* functions from init.c */
                    459: void reset_terminal(void);
                    460: 
                    461: /* functions from symtab_bltin.c */
1.2       snw       462: void symtab_init (void);
1.1       snw       463: short symtab_get_sem(void);
                    464: void symtab_release_sem(void);
                    465: void symtab_shm (short action, char *key, char *data);
                    466: void symtab_bltin (short action, char *key, char *data);
                    467: 
                    468: /* functions from global_dispatch.c */
                    469: void global_set_engine(char ns, char *engine);
                    470: void global (short action, char *key, char *data);
                    471: void close_all_globals ();
                    472: 
                    473: /* functions from global_bltin.c */
                    474: void global_bltin (short action, char *key, char *data);
                    475: void gbl_dump_stat (void);
                    476: 
                    477: /* functions from operator.c */
1.2       snw       478: short int pattern (char *a, char *b);
                    479: void    pminmax (char *str, int *min, int *max);
                    480: void    add (char *a, char *b);
                    481: void    mul (char *a, char *b);
                    482: void    mdiv (char *uu, char *v, short typ);
                    483: void    power (char *a, char *b);
                    484: void    g_sqrt (char *a);
                    485: void    root (char *a, long n);
                    486: int     numlit (char *str);
                    487: long    intexpr (char *str);
                    488: short int tvexpr (char *str);
                    489: void    m_op (char *a, char *b, short op);
1.3       snw       490: void mround (char *a, int digits);
1.1       snw       491: 
                    492: /* functions from service.c */
1.2       snw       493: long int find (char *string, char *pattern);
                    494: short int kill_ok (char *exceptions, char *);
                    495: void    write_f (char *intext);
                    496: void    writeHOME (char *text);
                    497: void    m_output (char *text);
                    498: void    write_m (char *text);
1.1       snw       499: void    write_t (short int col);
1.2       snw       500: void    ontimo (void);
1.1       snw       501: void    read_m (char *stuff, long read_timeout, short read_timeoutms, short length);
1.2       snw       502: int     rdchk0 (int *data);
                    503: int     locking (int fd, int action, long count);
1.1       snw       504: void    set_io (short action);
                    505: void    set_break (short break_char);
                    506: void    set_zbreak (short quit_char);
                    507: void    lock (char *lockarg, long time_out, char type);
                    508: 
                    509: /* functions from routine.c */
                    510: #include "routine.h"
1.2       snw       511: void    lineref (char **addr);
                    512: void    zi (char *line, char *position);
1.1       snw       513: 
                    514: /* functions from strings.c */
                    515: long int stlen (const char *source);
                    516: long int stnlen (const char *source, size_t siz);
                    517: long int stcpy (char *dest, const char *source);
                    518: long int stncpy (char *dest, const char *source, size_t siz);
                    519: void stcpy0 (char *dest, const char *source, long length);
                    520: void stcpy1 (char *dest, const char *source, long length);
                    521: short int stcat (char *dest, const char *source);
                    522: long int stncat (char *dest, const char *source, size_t siz);
                    523: short int stcmp (char *str1, char *str2);
                    524: char *trim (char *s);
                    525: void stcnv_m2c (char *mstr);
                    526: void stncnv_m2c(char *mstr, size_t siz);
                    527: void stcnv_c2m (char *cstr);
                    528: void stncnv_c2m(char *cstr, size_t siz);
                    529: size_t key_to_name (char *buf, const char *key, size_t count);
                    530: size_t name_to_key (char *buf, const char *name, size_t count);
                    531: void create_var_key (char *buf, int subct, char *nam, ...);
                    532: void trim_decimal (char *s);
                    533: void uuid_v4 (char *buf);
                    534: 
                    535: short is_standard(void);
                    536: int rtn_dialect(void);
                    537: 
                    538: /* CRT screen */
                    539: struct vtstyp {
                    540:     unsigned char screenx[N_LINES + 1][N_COLUMNS];     /* characters */
                    541:     unsigned char screena[N_LINES + 1][N_COLUMNS];     /* attributes */
                    542: #ifdef COLOR
                    543:     unsigned char screenc[N_LINES + 1][N_COLUMNS];     /* colors     */
                    544: #endif                                 /* COLOR */
                    545:     char    sclines[N_LINES + 1];      /* lines translation table   */
                    546:     char    rollflag;                  /* Roll or Page mode */
                    547:     char    lin24;                     /* 24 lines or 25 lines mode */
                    548:     char    savarg;
                    549:     char    tabs[N_COLUMNS];
                    550:     unsigned char Xpos;
                    551:     unsigned char Ypos;
                    552:     unsigned char sc_up;
                    553:     unsigned int sc_lo; /* jpw */
                    554:     unsigned char csx[CSLEN];
                    555:     unsigned char csy[CSLEN];
                    556:     short   cssgr[CSLEN];              /* save SGR flag */
                    557:     short   cscol[CSLEN];              /* save SGR flag */
                    558:     short   cs;
                    559:     unsigned char att;
                    560: #ifdef COLOR
                    561:     unsigned char col;                 /* color byte */
                    562: #endif                                 /* COLOR */
                    563: #ifdef SCO
                    564:     unsigned char bw;                  /* black_on_white flag */
                    565: #endif                                 /* SCO */
                    566: };
                    567: 
                    568: /* functions from views.c */
1.2       snw       569: void    view_com (void);
                    570: void    view_fun (int f, char *a);
                    571: short int newpsize (long size);
                    572: short int newusize (long size);
                    573: short int newrsize (long size, long nbrbuf);
                    574: void    zreplace (char *a, char *b, char *c);
                    575: short int tstglvn (char *a);
                    576: void    zname (char *a, char *b);
                    577: short int znamenumeric (char *str);
                    578: void    procv22 (char *key);
                    579: void    v25 (char *a, int i);
                    580: void    m_tolower (char *str);
1.1       snw       581: void    part_ref (struct vtstyp *scr, short from, short to);
                    582: 
                    583: #define D_FREEM 0
                    584: #define D_M77 1
                    585: #define D_M84 2
                    586: #define D_M90 3
                    587: #define D_M95 4
                    588: #define D_MDS 5
                    589: #define D_M5  6
                    590: 
                    591: /* per-routine flags */
                    592: typedef struct rtn_flags {
                    593:     short standard;
                    594:     short dialect;
                    595: } rtn_flags;
                    596: 
                    597: 

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