/*
* $Id: mpsdef.h,v 1.5 2025/03/24 04:05:36 snw Exp $
* common external definitions for all mumps modules
*
*
* Author: Serena Willis <snw@coherent-logic.com>
* Copyright (C) 1998 MUG Deutschland
* Copyright (C) 2020, 2023, 2025 Coherent Logic Development LLC
*
*
* This file is part of FreeM.
*
* FreeM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with FreeM. If not, see <https://www.gnu.org/licenses/>.
*
* $Log: mpsdef.h,v $
* Revision 1.5 2025/03/24 04:05:36 snw
* Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2
*
* Revision 1.4 2025/03/09 19:50:47 snw
* Second phase of REUSE compliance and header reformat
*
*
* SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
* SPDX-License-Identifier: AGPL-3.0-or-later
**/
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include <float.h>
#if !defined(DBL_DIG)
# define DBL_DIG 15
#endif
/* constants definition module */
#include "mpsdef0.h"
#if defined(HAVE_MWAPI_MOTIF)
# include <Xm/Xm.h>
extern XtAppContext mwapi_context;
#endif
/* c-global variables as external definitions */
/* NOTE: this is a constant if SYSFIVE is undefined (in mumps.c) */
/* needs to be resolved: djw 3/15/99 */
#ifdef SYSFIVE
extern long FreeM_timezone; /* time zone */
#endif
extern short run_daemon;
extern short nofork;
extern char *pid_file_path;
extern int pid_fd;
/* USING and WITH */
extern char i_using[STRLEN];
extern char i_with[STRLEN];
extern int errno; /* external error code for systemcalls */
extern int m_argc; /* arguments count */
extern char **m_argv; /* arguments string */
extern char **m_envp; /* environment pointer */
extern short frm_throw_all_errors; /* allow non-U errors to be raised by setting $ECODE */
extern union four_fl {
long unsigned all;
char one[4];
} glvnflag; /* [0] unique name chars 0=no limit */
/* [1] case sensitivity flag 0=sensitive */
/* [2] max. name+subscripts 0=no limit */
/* [3] max. length of a subscript 0=no limit */
extern int libflag; /* are we running as library? */
extern int lonelyflag; /* single user flag */
extern int lowerflag; /* lowercase everywhere flag */
extern int killerflag; /* SIGTERM handling flag */
extern int huperflag; /* SIGHUP handling flag */
extern int s_fun_flag; /* VIEW 70: ZSORT/ZSYNTAX flag */
extern int n_fun_flag; /* VIEW 71: ZNEXT/ZNAME flag */
extern int p_fun_flag; /* VIEW 72: ZPREVIOUS/ZPIECE flag */
extern int d_fun_flag; /* VIEW 73: ZDATE/ZDATA flag */
extern int zjobflag; /* VIEW 79: old ZJOB vs. new ZJOB flag */
extern int eightbit; /* VIEW 80: 7 vs. 8 bit flag */
extern int PF1flag; /* VIEW 81: PF1 flag */
extern int ordercounter; /* VIEW 82: order counter */
extern int etxtflag; /* VIEW 83: text in $ZE flag */
extern char lvndefault[256]; /* VIEW 89: UNDEF lvn default */
extern char gvndefault[256]; /* VIEW 90: UNDEF gvn default */
extern char exfdefault[256]; /* VIEW 91: missig QUIT expr default */
extern int typemmflag; /* VIEW 92: DEM2EUR: type mismatch error */
extern int namespace; /* VIEW 200: namespace index */
extern int config; /* VIEW 201: configuration index */
extern char WHR[12][4]; /* names of currencies */
extern char EUR2WHR[12][9]; /* conversion factors EUR to ... */
extern char glo_prefix[MONTH_LEN]; /* VIEW 96: global prefix */
extern char glo_ext[MONTH_LEN]; /* VIEW 97: global postfix */
extern char rou_ext[MONTH_LEN]; /* VIEW 98: routine extention */
extern long tzoffset; /* VIEW 99: timer offset */
extern int v100; /* VIEW 100: return value of kill */
extern char l_o_val[256]; /* VIEW 110: local $o/$q data value */
extern char g_o_val[256]; /* VIEW 111: global $o/$q data value */
extern int zsavestrategy; /* VIEW 133: remember ZLOAD directory on ZSAVE */
extern long v93; /* VIEW 93: zkey prod. default */
extern char v93a[NO_V93][256]; /* VIEW 93: production rules */
extern struct vtstyp *screen; /* active screen */
extern short jour_flag; /* journal flag 0/1/-1 */
/* trace variables for global.c */
extern unsigned long traceblk[TRLIM]; /* trace stack - block numbers */
extern short traceadr[TRLIM]; /* - status */
extern short trx; /* - stack pointer */
extern char compactkey[256]; /* internal form of key in global.c */
extern short mcmnd; /* mumps command letter */
extern short arg; /* stack pointer (expr.c) */
extern char *argstck[PARDEPTH + 1]; /* stack of pointers to */
/* intermediate results */
extern long ordercnt; /* repeater for $order/$query */
extern short setpiece; /* =1 set$piece executing */
extern short setop; /* SET op flag */
extern char rou_name[]; /* $T(+0)/$ZN routine name */
extern char *namstck; /* routine name stack */
extern char *namptr; /* routine name stack pointer */
extern char *framstck; /* DO_frame stack */
extern char *dofrmptr; /* DO_frame stack pointer */
extern char zb[40]; /* $ZB last ESC_sequence */
extern char zerror[]; /* $ZERROR last error */
extern char ztrap[NESTLEVLS + 2][ZTLEN]; /* $ZTRAP to be xecuted on error */
extern short DSM2err; /* enable normal error processing */
extern short nesterr; /* nesterr and callerr contain info */
extern char callerr[NESTLEVLS + 1][40]; /* about call situation at error */
extern short zerr; /* $ZE numeric error code */
extern char stack0[];
extern char zmc[]; /* $ZMC loadable match 'controls' */
extern char zmn[]; /* $ZMN loadable match 'numeric' */
extern char zmp[]; /* $ZMP loadable match 'punctuation' */
extern char zml[]; /* $ZML loadable match 'lowercase' */
extern char zmu[]; /* $ZMU loadable match 'uppercase' */
extern char zloc[256]; /* $ZL last local reference */
extern char zref[256]; /* $ZR last global reference */
extern short nakoffs; /* offset to naked reference */
extern char zfunkey[44][FUNLEN]; /* $ZF function key */
extern short xpos[MAXDEV + 1]; /* $X-vector */
extern short ypos[MAXDEV + 1]; /* $Y-vector */
extern short frm_crlf[MAXDEV + 1]; /* CR/LF flag vector */
extern short fm_nodelay[MAXDEV + 1]; /* nodelay flag vector */
extern int SIflag[MAXDEV + 1]; /* SI/SO flag */
extern int ESCflag[MAXDEV + 1]; /* ESC flag */
extern short RightMargin; /* Output Margin. Default no */
/* automatic CR/LF */
extern short InFieldLen; /* Input Field length Def: 255 char */
extern long DSW; /* Device Status word (Terminal) */
extern char LineTerm[]; /* Input Line Terminator chars */
extern char BrkKey; /* <INTERRUPT> key Def: CTRL/C */
extern char ug_buf[MAXDEV + 1][256]; /* ungetc-buffers */
extern char devopen[MAXDEV + 1]; /* 0 not open */
/* 'r' input */
/* 'w' or 'a' output */
extern short fp_mode; /* 0 = fixed, 1 = IEEE 754 */
extern short en_revstrf; /* if 1, reverse $E, $P, $N enabled */
typedef struct frm_devstat {
short mdc_err;
short frm_err;
char err_txt[80];
} frm_devstat;
extern frm_devstat devstat[MAXDEV + 1]; /* device error statuses */
extern char dev[MAXDEV + 1][40]; /* names of IO devices */
extern char G0I[MAXDEV + 1][257]; /* G0 input translation table */
extern char G0O[MAXDEV + 1][257]; /* G0 output translation table */
extern char G1I[MAXDEV + 1][257]; /* G1 input translation table */
extern char G1O[MAXDEV + 1][257]; /* G1 output translation table */
extern FILE *opnfile[];
extern char sq_modes[MAXDEV + 1];
extern char act_oucpath[MAXDEV + 1][40]; /* actual path of currently used device */
extern short olddes[NO_GLOBLS]; /* filedescr of open global files */
extern char oldfil[NO_GLOBLS][1024]; /* names of open global files */
extern short usage[NO_GLOBLS]; /* usage count of global files */
extern long g_ages[NO_GLOBLS]; /* last access of global files */
extern short inuse; /* file in use */
extern int lio_mode;
extern short io; /* $IO */
extern short test; /* $TEST */
extern short pattrnflag; /* incomplete match flag */
extern char pattrnchar; /* incomplete match flag supplement */
extern int zsystem; /* $ZSYSTEM return status of UNIX call */
extern short zcc; /* $ZC (ControlC-Flag) */
extern char *rouptr; /* pointer to begin of routine */
extern char *roucur; /* cursor into routine */
extern char *rouend; /* pointer to end of pgm */
extern char *rouins; /* pointer for direct mode insert */
extern short breakon; /* BREAK enable/disable-flag */
extern short zbreakon; /* ZBREAK enable/disable-flag */
extern short zbflag; /* 'ZBREAK from terminal'-flag */
extern short zprecise; /* $ZPRECICION of arithmetic */
extern char fp_conversion[10]; /* sprintf conversion constant for ieee754 support */
extern long nrandom; /* random number */
extern long ran_a; /* random number parameter a */
extern long ran_b; /* random number parameter b */
extern long ran_c; /* random number parameter c */
extern short usermode; /* 0=user mode 1=programmer mode */
extern int restricted_mode; /* TRUE=restricted mode FALSE=unrestricted mode */
extern short demomode; /* 0=no demo 1=demo mode */
extern int d0char; /* demomode ouput character */
extern int d1char; /* demomode '!' character */
extern short cset; /* 0=mumps set 1='C' set flag */
extern int hardcopy; /* hardcopy flag */
extern int frm_filter; /* filter flag */
extern int noclear;
extern int standard; /* 1=standard only, */
extern int quiet_mode; /* quiet mode */
extern char config_file[4096]; /* path to configuration file */
extern char shm_env[255]; /* shared memory environment */
/* 0=non standard features enabled */
extern short ierr;
extern short deferred_ierr;
extern char err_suppl[255];
extern char errmes[MAXERR][ERRLEN]; /* error messages */
extern long PSIZE; /* size of 'partition' */
extern char *mbpartition;
extern char *partition;
extern short writing_mb;
extern unsigned long alphptr[]; /* pointers into symbol table */
extern long symlen; /* 'lower' bound of symbol table */
extern char *apartition; /* alternate partition */
extern long asymlen; /* 'lower' bound of symbol table */
extern unsigned long aalphptr[]; /* pointers into symbol table */
extern short autopsize; /* automatic increase of PSIZE */
extern long svnlen; /* 'lower' bound of udf_svn_tab */
extern long UDFSVSIZ; /* size of userdef special var tab. */
extern short autousize; /* automatic increase of UDFSVSIZ */
extern char *svntable; /* udf special variable table */
extern unsigned long svnaptr[]; /* pointers into udf_svn_tab */
extern long NO_OF_RBUF; /* number of routine buffers */
extern long PSIZE0; /* size of routine buffers */
extern short autorsize; /* automatic increase of PSIZE0 */
extern short aliases; /* aliases pointer */
extern char ali[]; /* aliases table */
extern long v22ptr; /* view 22 aliases pointer */
extern char *v22ali; /* view 22 aliases field */
extern long v22size; /* current size of aliases field */
extern char *buff; /* alternate buffers */
extern char code[]; /* currently interpreted code */
extern long NSIZE; /* size of newstack */
extern char *newstack; /* stack for NEWed variables */
extern char *newptr; /* pointer to NEW stack */
extern char *newlimit; /* pointer to NEW stack end */
extern int errfunlvl; /* avoid wrong error message in $$FUN */
extern short nstx; /* nest stack: */
extern short nestc[]; /* - command (DO...) */
extern char *nestp[]; /* - cmdptr */
extern char *nestn[]; /* - namptr */
extern long nestr[]; /* - roucur */
extern char *nestnew[]; /* - newptr */
extern char neste[]; /* - was this frame entered as the result of an error? */
extern short repQUIT; /* QUIT repeater */
extern char *argptr; /* pointer to beg of tmp storage */
extern char *s; /* pointer to symlen_offset */
extern char *codptr; /* pointer within code[] */
extern char dosave[20]; /* in a FOR range save DO label */
extern char *xdosave;
extern char varnam[]; /* variable/array/function name */
extern char varerr[256]; /* reference in error message */
extern char pgms[MAXNO_OF_RBUF + 1][40]; /* names of alt.pgms */
extern long ages[]; /* last call to this pgm */
extern char *ends[]; /* saved rouend-pointer */
extern char path[MAXNO_OF_RBUF][256]; /* directory where routine was loaded */
extern rtn_flags rbuf_flags[MAXNO_OF_RBUF]; /* per-routine flags */
extern char glopath[PATHLEN]; /* path to access globals */
extern char rou0path[PATHLEN]; /* routine access with DO,GOTO,JOB */
extern char rou1path[PATHLEN]; /* routine access with ZL,ZS */
extern char gloplib[PATHLEN]; /* path to access %globals */
extern char rou0plib[PATHLEN]; /* %routine path (DO..) */
extern char rou1plib[PATHLEN]; /* %routine path (ZL..) */
extern char gbl_u_engine[255]; /* user global engine */
extern char gbl_s_engine[255]; /* system global engine */
extern char loc_engine[255]; /* local engine */
extern unsigned long int bdb_flush_threshold;
extern char oucpath[PATHLEN]; /* OPEN/USE/CLOSE path */
extern char rgafile[PATHLEN]; /* routine/global access protocol file */
extern char zargdefname[PATHLEN]; /* default varname for Zcommands */
extern FILE *rgaccess; /* dto. filedes */
extern char locktab[PATHLEN]; /* file with LOCKs */
extern char zallotab[PATHLEN]; /* file with ZALLOCATE */
extern char hcpyfile[PATHLEN]; /* hardcopy file */
extern char jourfile[PATHLEN]; /* journal file */
extern FILE *jouraccess; /* dto. filedes */
extern char curdir[PATHLEN]; /* current directory */
extern char startuprou[PATHLEN];
extern char zcommds[256]; /* intrinsic z-commands */
extern char zfunctions[256]; /* intrinsic z-functions */
extern char zsvn[256]; /* intrinsic z-special variables */
extern char brkaction[256]; /* action in case of BREAK */
extern pid_t father; /* JOB-ID of father process */
/* date types parameters */
extern char month[NO_DATETYPE][12][MONTH_LEN]; /* month names or numbers */
extern char dat1char[NO_DATETYPE][MONTH_LEN]; /* date 1st delimiter */
extern char dat2char[NO_DATETYPE][MONTH_LEN]; /* date 2nd delimmiter */
extern char dat3char[NO_DATETYPE]; /* date day justify char */
extern char dat4flag[NO_DATETYPE]; /* 0=DMY, 1=MDY, 2=YMD */
extern char dat5flag[NO_DATETYPE]; /* suppress century digits */
extern long int datGRbeg[NO_DATETYPE]; /* first day of gregorian calendar 15-OCT-1582 */
extern int datetype; /* type for $zd special variable */
extern char tim1char[NO_TIMETYPE]; /* time 1st delimiter */
extern char tim2char[NO_TIMETYPE]; /* time 2nd delimiter */
extern char tim3char[NO_TIMETYPE]; /* time hour justify char */
extern char tim4flag[NO_TIMETYPE]; /* 0=12 Hrs 1=24 Hrs */
extern char tim5flag[NO_TIMETYPE]; /* suppress seconds */
extern int timetype; /* type for $zt special variable */
extern jmp_buf sjbuf; /* on timeout */
extern char *roucu0;
extern char *dofram0;
extern short forx; /* FOR stack pointer */
extern char forvar[NESTLEVLS + 1][40], /* FOR variable */
forinc[NESTLEVLS + 1][40], /* FOR increment */
forpost[NESTLEVLS + 1][128],/* FOR postconditional */
forlim[NESTLEVLS + 1][40]; /* FOR limit value */
extern short fortyp[NESTLEVLS + 1]; /* 0 = forever 1 = single, */
/* 2 = unlim.iter,3 = limit iter. */
/* 4 = "" +inc=1 5 = "" + inc=1 */
extern short fori[NESTLEVLS + 1]; /* if fortyp=5 length of forlimit */
extern char *fvar; /* current forvar */
extern char *finc; /* current forinc */
extern char *fpost; /* current forpost */
extern char *flim; /* current forlim */
extern short ftyp; /* current fortyp */
extern short fi; /* current fori */
extern short forsw; /* FOR switch */
extern short argless_forsw_quit; /* QUIT from argumentless FOR */
extern short sigint_in_for; /* SIGINT occurred in FOR loop */
extern short direct_mode;
extern short loadsw; /* flag to avoid redundant loads */
extern short extr_types[NESTLEVLS + 1]; /* return types of extrinsic functions */
extern char destructors[10][50];
extern int destructor_ct;
extern char private_keys[MAX_PRIVATE_KEYS][255];
/* after XECUTEs */
extern short promflag; /* prompt execute flag */
extern short privflag; /* extrinsic z-command flag */
extern short brkstk[NESTLEVLS + 1]; /* stack for BREAK information */
extern char *cmdstack;
extern char *cmdptr;
extern short offset;
extern long frm_timeout;
extern short timeoutms;
extern char tmp4[80];
extern short param; /* parameter count */
extern short paramx; /* current parameter */
//extern char *calloc ();
extern short level; /* level count */
extern short nestlt[NESTLEVLS + 1]; /* stack $T / stack levelcount */
extern pid_t pid; /* $J = process ID */
extern char jour_hostid[256];
extern char nsroot[4096]; /* root path of namespace */
extern char nsname[256]; /* namespace name */
extern char *freem_path; /* path to the running instance of FreeM */
extern char history_file[256];
extern int n_lines; /* rows in screen */
extern int n_columns; /* columns in screen */
extern short ipc_pending; /* 1 if an incoming IPC is pending, 0 otherwise */
extern int strict_mode;
extern short first_process;
extern size_t shm_init_size;
extern short inrpt_after_async;
//#ifndef OLDUNIX
// extern struct sigaction act; /* signals stuff */
//#endif /* OLDUNIX */
/* Macros */
/* Create a new variable of type (datatype) with space for qty instances */
#define NEW(datatype,qty) ((datatype *)calloc(qty,sizeof(datatype)))
/* End of $Source: /home/cvsroot/freem/src/mpsdef.h,v $ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>