File:  [Coherent Logic Development] / freem / src / mpsdef0.h
Revision 1.13: download - view: text, annotated - select for diffs
Mon Mar 24 04:13:11 2025 UTC (6 months, 1 week ago) by snw
Branches: MAIN
CVS tags: v0-63-1-rc1, v0-63-0-rc1, v0-63-0, v0-62-3, HEAD
Replace action macro dat with fra_dat to avoid symbol conflict on OS/2

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

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