File:  [Coherent Logic Development] / freem / src / mpsdef0.h
Revision 1.6: download - view: text, annotated - select for diffs
Sun Mar 9 15:20:18 2025 UTC (5 months, 1 week ago) by snw
Branches: MAIN
CVS tags: HEAD
Begin formatting overhaul and REUSE compliance

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

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