File:  [Coherent Logic Development] / freem / src / mpsdef0.h
Revision 1.14: download - view: text, annotated - select for diffs
Sun Apr 13 04:22:43 2025 UTC (3 months, 2 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Fix snprintf calls

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

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