File:  [Coherent Logic Development] / freem / src / mpsdef0.h
Revision 1.9: download - view: text, annotated - select for diffs
Sat Mar 22 22:52:24 2025 UTC (4 months, 3 weeks ago) by snw
Branches: MAIN
CVS tags: v0-62-2, HEAD
Add STRLEN_GBL macro to manage global string length

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

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