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

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

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