File:  [Coherent Logic Development] / freem / src / mpsdef.h
Revision 1.11: download - view: text, annotated - select for diffs
Wed Apr 30 17:19:16 2025 UTC (3 months ago) by snw
Branches: MAIN
CVS tags: HEAD
Improve backtraces in debugger

    1: /*
    2:  *   $Id: mpsdef.h,v 1.11 2025/04/30 17:19:16 snw Exp $
    3:  *    common external 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: mpsdef.h,v $
   27:  *   Revision 1.11  2025/04/30 17:19:16  snw
   28:  *   Improve backtraces in debugger
   29:  *
   30:  *   Revision 1.10  2025/04/28 19:38:55  snw
   31:  *   Add trace mode
   32:  *
   33:  *   Revision 1.9  2025/04/13 04:22:43  snw
   34:  *   Fix snprintf calls
   35:  *
   36:  *   Revision 1.8  2025/04/10 01:24:38  snw
   37:  *   Remove C++ style comments
   38:  *
   39:  *   Revision 1.7  2025/04/04 19:43:18  snw
   40:  *   Switch to using environment catalog to determine user and group for environment, and remove -u and -g flags from freem
   41:  *
   42:  *   Revision 1.6  2025/04/02 03:02:42  snw
   43:  *   Stop requiring users to pass -e to fmadm when -u or -g are passed
   44:  *
   45:  *   Revision 1.5  2025/03/24 04:05:36  snw
   46:  *   Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2
   47:  *
   48:  *   Revision 1.4  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: #include <stdio.h>
   57: #include <setjmp.h>
   58: #include <signal.h>
   59: #include <float.h>
   60: 
   61: #if !defined(DBL_DIG)
   62: # define DBL_DIG 15
   63: #endif
   64: 
   65: /* constants definition module */
   66: #include "mpsdef0.h"
   67: 
   68: #if defined(HAVE_MWAPI_MOTIF)
   69: # include <Xm/Xm.h>
   70: extern XtAppContext mwapi_context;
   71: #endif
   72: 
   73: /*      c-global variables as external definitions */
   74: 
   75: /* NOTE: this is a constant if SYSFIVE is undefined (in mumps.c) */
   76: /* needs to be resolved: djw 3/15/99				    */
   77: #ifdef SYSFIVE
   78: extern  long     FreeM_timezone;              /* time zone */
   79: #endif
   80: 
   81: extern short run_daemon;
   82: extern short nofork;
   83: extern char *pid_file_path;
   84: extern int pid_fd;
   85: 
   86: /* USING and WITH */
   87: extern char i_using[STRLEN];
   88: extern char i_with[STRLEN];
   89: 
   90: extern int errno;			/* external error code for systemcalls */
   91: 
   92: extern int m_argc;			/* arguments count     */
   93: extern char **m_argv;			/* arguments string    */
   94: extern char **m_envp;			/* environment pointer */
   95: 
   96: extern short frm_throw_all_errors;      /* allow non-U errors to be raised by setting $ECODE */
   97: 
   98: extern union four_fl {
   99:     long unsigned all;
  100:     char    one[4];
  101: } glvnflag;				/* [0] unique name chars          0=no limit */
  102: 
  103: 					/* [1] case sensitivity flag      0=sensitive */
  104: 					/* [2] max. name+subscripts       0=no limit */
  105: 					/* [3] max. length of a subscript 0=no limit */
  106: extern int libflag;                     /* are we running as library? */
  107: extern int lonelyflag;			/* single user flag */
  108: extern int lowerflag;			/* lowercase everywhere flag */
  109: extern int killerflag;			/* SIGTERM handling flag */
  110: extern int huperflag;			/* SIGHUP handling flag */
  111: extern int s_fun_flag;			/* VIEW 70: ZSORT/ZSYNTAX flag */
  112: extern int n_fun_flag;			/* VIEW 71: ZNEXT/ZNAME flag */
  113: extern int p_fun_flag;			/* VIEW 72: ZPREVIOUS/ZPIECE flag */
  114: extern int d_fun_flag;			/* VIEW 73: ZDATE/ZDATA flag */
  115: extern int zjobflag;			/* VIEW 79: old ZJOB vs. new ZJOB flag */
  116: extern int eightbit;			/* VIEW 80: 7 vs. 8 bit flag */
  117: extern int PF1flag;			/* VIEW 81: PF1 flag */
  118: extern int ordercounter;		/* VIEW 82: order counter */
  119: extern int etxtflag;			/* VIEW 83: text in $ZE flag */
  120: extern char lvndefault[256];		/* VIEW 89: UNDEF lvn default */
  121: extern char gvndefault[256];		/* VIEW 90: UNDEF gvn default */
  122: extern char exfdefault[256];		/* VIEW 91: missig QUIT expr default */
  123: extern int typemmflag;			/* VIEW 92: DEM2EUR: type mismatch error */
  124: extern int namespace;			/* VIEW 200: namespace index */
  125: extern int config;			/* VIEW 201: configuration index */
  126: extern char WHR[12][4];			/* names of currencies */
  127: extern char EUR2WHR[12][9];		/* conversion factors EUR to ... */
  128: 
  129: extern char glo_prefix[MONTH_LEN];	/* VIEW 96: global prefix */
  130: extern char glo_ext[MONTH_LEN];		/* VIEW 97: global postfix */
  131: extern char rou_ext[MONTH_LEN];		/* VIEW 98: routine extention */
  132: extern long tzoffset;			/* VIEW 99: timer offset */
  133: extern int v100;			/* VIEW 100: return value of kill */
  134: extern char l_o_val[256];		/* VIEW 110: local $o/$q data value */
  135: extern char g_o_val[256];		/* VIEW 111: global $o/$q data value */
  136: extern int zsavestrategy;		/* VIEW 133: remember ZLOAD directory on ZSAVE */
  137: extern long v93;			/* VIEW 93: zkey prod. default */
  138: extern char v93a[NO_V93][256];		/* VIEW 93: production rules   */
  139: 
  140: extern struct vtstyp *screen;		/* active screen */
  141: extern short jour_flag;			/* journal flag 0/1/-1          */
  142: 
  143: 					/* trace variables for global.c */
  144: extern unsigned long traceblk[TRLIM];	/* trace stack - block numbers */
  145: extern short traceadr[TRLIM];		/*             - status        */
  146: extern short trx;			/*             - stack pointer */
  147: extern char compactkey[256];		/* internal form of key in global.c */
  148: 
  149: extern short mcmnd;			/* mumps command letter */
  150: extern short arg;			/* stack pointer (expr.c)     */
  151: extern char *argstck[PARDEPTH + 1];	/* stack of pointers to       */
  152: 
  153: 					/*       intermediate results */
  154: 
  155: extern long ordercnt;			/* repeater for $order/$query */
  156: extern short setpiece;			/* =1 set$piece executing  */
  157: extern short setop;			/* SET op flag             */
  158: extern char rou_name[];			/* $T(+0)/$ZN routine name */
  159: extern char *namstck;			/* routine name stack */
  160: extern char *namptr;			/* routine name stack pointer */
  161: extern char *framstck;			/* DO_frame stack                 */
  162: extern char *dofrmptr;			/* DO_frame stack pointer           */
  163: extern char zb[40];			/* $ZB last ESC_sequence */
  164: extern char zerror[];			/* $ZERROR last error */
  165: extern char ztrap[NESTLEVLS + 2][ZTLEN];	/* $ZTRAP to be xecuted on error */
  166: extern short DSM2err;			/* enable normal error processing   */
  167: extern short nesterr;			/* nesterr and callerr contain info */
  168: extern char callerr[NESTLEVLS + 1][40];	/* about call situation at error   */
  169: extern short zerr;			/* $ZE numeric error code */
  170: 
  171: extern char stack0[];
  172:     
  173: extern char zmc[];			/* $ZMC loadable match 'controls' */
  174: extern char zmn[];			/* $ZMN loadable match 'numeric' */
  175: extern char zmp[];			/* $ZMP loadable match 'punctuation' */
  176: extern char zml[];			/* $ZML loadable match 'lowercase' */
  177: extern char zmu[];			/* $ZMU loadable match 'uppercase' */
  178: 
  179: 
  180: extern char zloc[256];			/* $ZL last local reference  */
  181: extern char zref[256];			/* $ZR last global reference */
  182: extern short nakoffs;			/* offset to naked reference */
  183: extern char zfunkey[44][FUNLEN];	/* $ZF function key */
  184: extern short xpos[MAXDEV + 1];		/* $X-vector */
  185: extern short ypos[MAXDEV + 1];		/* $Y-vector */
  186: extern short frm_crlf[MAXDEV + 1];		/* CR/LF flag vector               */
  187: extern short fm_nodelay[MAXDEV + 1];	/* nodelay flag vector             */
  188: extern int SIflag[MAXDEV + 1];		/* SI/SO flag                      */
  189: extern int ESCflag[MAXDEV + 1];		/* ESC flag                        */
  190: extern short RightMargin;		/* Output Margin. Default no       */
  191: 
  192: 					/*  automatic CR/LF                */
  193: extern short InFieldLen;		/* Input Field length Def: 255 char */
  194: extern long DSW;			/* Device Status word (Terminal)   */
  195: extern char LineTerm[];			/* Input Line Terminator chars     */
  196: extern char BrkKey;			/* <INTERRUPT> key Def: CTRL/C     */
  197: extern char ug_buf[MAXDEV + 1][256];	/* ungetc-buffers                  */
  198: extern char devopen[MAXDEV + 1];	/*  0         not open */
  199: 
  200: 					/* 'r'        input    */
  201: 					/* 'w' or 'a' output   */
  202: 
  203: 
  204: extern short fp_mode;                   /* 0 = fixed, 1 = IEEE 754 */
  205: extern short en_revstrf;                /* if 1, reverse $E, $P, $N enabled */
  206: 
  207: typedef struct frm_devstat {
  208:     short mdc_err;
  209:     short frm_err;
  210:     char err_txt[80];
  211: } frm_devstat;
  212: 
  213: extern frm_devstat devstat[MAXDEV + 1]; /* device error statuses */
  214: 
  215: extern char dev[MAXDEV + 1][40];	/* names of IO devices */
  216: 
  217: extern char G0I[MAXDEV + 1][257];	/* G0 input translation table */
  218: extern char G0O[MAXDEV + 1][257];	/* G0 output translation table */
  219: extern char G1I[MAXDEV + 1][257];	/* G1 input translation table */
  220: extern char G1O[MAXDEV + 1][257];	/* G1 output translation table */
  221: 
  222: extern FILE *opnfile[];
  223: extern char sq_modes[MAXDEV + 1];
  224: extern char act_oucpath[MAXDEV + 1][40];	/* actual path of currently used device */
  225: 
  226: extern short olddes[NO_GLOBLS];		/* filedescr of open global files */
  227: extern char oldfil[NO_GLOBLS][1024];	/* names of open global files */
  228: extern short usage[NO_GLOBLS];		/* usage count of global files */
  229: extern long g_ages[NO_GLOBLS];		/* last access of global files */
  230: extern short inuse;			/* file in use */
  231: 
  232: extern int lio_mode;
  233: extern short io;			/* $IO */
  234: extern short test;			/* $TEST */
  235: extern short pattrnflag;		/* incomplete match flag */
  236: extern char pattrnchar;			/* incomplete match flag supplement */
  237: extern int zsystem;			/* $ZSYSTEM return status of UNIX call */
  238: extern short zcc;			/* $ZC (ControlC-Flag)         */
  239: extern char *rouptr;			/* pointer to begin of routine */
  240: extern char *roucur;			/* cursor into routine         */
  241: extern char *rouend;			/* pointer to end of pgm       */
  242: extern char *rouins;			/* pointer for direct mode insert */
  243: 
  244: extern short breakon;			/* BREAK enable/disable-flag   */
  245: extern short zbreakon;			/* ZBREAK enable/disable-flag  */
  246: extern short zbflag;			/* 'ZBREAK from terminal'-flag */
  247: extern short zprecise;			/* $ZPRECICION of arithmetic   */
  248: extern char fp_conversion[10];          /* sprintf conversion constant for ieee754 support */
  249: extern long nrandom;			/* random number */
  250: extern long ran_a;			/* random number parameter a      */
  251: extern long ran_b;			/* random number parameter b      */
  252: extern long ran_c;			/* random number parameter c      */
  253: extern short usermode;			/* 0=user mode 1=programmer mode */
  254: extern int restricted_mode;                /* TRUE=restricted mode FALSE=unrestricted mode */
  255: extern short demomode;			/* 0=no demo   1=demo mode        */
  256: extern int d0char;			/* demomode ouput character       */
  257: extern int d1char;			/* demomode '!'   character       */
  258: extern short cset;			/* 0=mumps set 1='C' set flag     */
  259: extern int hardcopy;			/* hardcopy flag */
  260: extern int frm_filter;			/* filter flag                    */
  261: extern int noclear;
  262: extern int standard;			/* 1=standard only,               */
  263: extern int quiet_mode;                  /* quiet mode                     */
  264: extern char config_file[4096];          /* path to configuration file */
  265: extern char env_config_file[4096];  /* path to environment config file */
  266: extern char shm_env[255];               /* shared memory environment       */
  267: 					/* 0=non standard features enabled */
  268: extern short ierr;
  269: extern short deferred_ierr;
  270: extern char err_suppl[255];
  271: extern char errmes[MAXERR][ERRLEN];	/* error messages                  */
  272: 
  273: extern long PSIZE;			/* size of 'partition'             */
  274: extern char *mbpartition;
  275: extern char *partition;
  276: extern short writing_mb;
  277: extern unsigned long alphptr[];		/* pointers into symbol table     */
  278: extern long symlen;			/* 'lower' bound of symbol table   */
  279: extern char *apartition;		/* alternate partition             */
  280: extern long asymlen;			/* 'lower' bound of symbol table   */
  281: extern unsigned long aalphptr[];	/* pointers into symbol table      */
  282: 
  283: extern short autopsize;			/* automatic increase of PSIZE     */
  284: extern long svnlen;			/* 'lower' bound of udf_svn_tab    */
  285: extern long UDFSVSIZ;			/* size of userdef special var tab. */
  286: extern short autousize;			/* automatic increase of UDFSVSIZ  */
  287: extern char *svntable;			/* udf special variable table      */
  288: extern unsigned long svnaptr[];		/* pointers into udf_svn_tab       */
  289: extern long NO_OF_RBUF;			/* number of routine buffers       */
  290: extern long PSIZE0;			/* size of routine buffers         */
  291: extern short autorsize;			/* automatic increase of PSIZE0    */
  292: extern short aliases;			/* aliases pointer                 */
  293: extern char ali[];			/* aliases table                   */
  294: extern long v22ptr;			/* view 22 aliases pointer         */
  295: extern char *v22ali;			/* view 22 aliases field           */
  296: extern long v22size;			/* current size of aliases field   */
  297: 
  298: extern char *buff;			/* alternate buffers */
  299: extern char code[];			/* currently interpreted code */
  300: extern long NSIZE;			/* size of newstack                */
  301: extern char *newstack;			/* stack for NEWed variables */
  302: extern char *newptr;			/* pointer to NEW stack */
  303: extern char *newlimit;			/* pointer to NEW stack end        */
  304: extern int errfunlvl;			/* avoid wrong error message in $$FUN */
  305: extern short nstx;			/* nest stack:       */
  306: extern short nestc[];			/* - command (DO...) */
  307: extern char *nestp[];			/* - cmdptr          */
  308: extern char *nestn[];			/* - namptr          */
  309: extern long nestr[];			/* - roucur          */
  310: extern char *nestnew[];			/* - newptr          */
  311: extern char neste[];			/* - was this frame entered as the result of an error? */
  312: extern short repQUIT;			/* QUIT repeater     */
  313: 
  314: extern char *argptr;			/* pointer to beg of tmp storage */
  315: extern char *s;				/* pointer to symlen_offset      */
  316: extern char *codptr;			/* pointer within code[] */
  317: extern char dosave[20];			/* in a FOR range save DO label  */
  318: extern char *xdosave;
  319: 
  320: extern char varnam[];			/* variable/array/function name  */
  321: extern char varerr[256];		/* reference in error message    */
  322: extern char pgms[MAXNO_OF_RBUF + 1][40];	/* names of alt.pgms */
  323: extern long ages[];			/* last call to this pgm */
  324: extern char *ends[];			/* saved rouend-pointer */
  325: extern char path[MAXNO_OF_RBUF][256];	/* directory where routine was loaded */
  326: extern rtn_flags rbuf_flags[MAXNO_OF_RBUF]; /* per-routine flags */
  327: extern char glopath[PATHLEN];		/* path to access globals     */
  328: extern char rou0path[PATHLEN];		/* routine access with DO,GOTO,JOB */
  329: extern char rou1path[PATHLEN];		/* routine access with ZL,ZS  */
  330: 
  331: extern char gloplib[PATHLEN];		/* path to access %globals    */
  332: extern char rou0plib[PATHLEN];		/* %routine path (DO..)       */
  333: extern char rou1plib[PATHLEN];		/* %routine path (ZL..)       */
  334: 
  335: extern char gbl_u_engine[255];          /* user global engine */
  336: extern char gbl_s_engine[255];          /* system global engine */
  337: extern char loc_engine[255];            /* local engine */
  338: 
  339: extern unsigned long int bdb_flush_threshold;
  340: 
  341: extern char oucpath[PATHLEN];		/* OPEN/USE/CLOSE path */
  342: extern char rgafile[PATHLEN];		/* routine/global access protocol file */
  343: extern char zargdefname[PATHLEN];	/* default varname for Zcommands */
  344: extern FILE *rgaccess;			/* dto. filedes */
  345: extern FILE *jouraccess;		/* dto. filedes */
  346: 
  347: extern char curdir[PATHLEN];			/* current directory */
  348: extern char startuprou[PATHLEN];
  349: extern char zcommds[256];		/* intrinsic z-commands */
  350: extern char zfunctions[256];		/* intrinsic z-functions */
  351: extern char zsvn[256];			/* intrinsic z-special variables */
  352: extern char brkaction[256];		/* action in case of BREAK       */
  353: extern pid_t father;			/* JOB-ID of father process      */
  354: 
  355: 					  /* date types parameters */
  356: extern char month[NO_DATETYPE][12][MONTH_LEN];	/* month names or numbers */
  357: extern char dat1char[NO_DATETYPE][MONTH_LEN];	/* date 1st delimiter */
  358: extern char dat2char[NO_DATETYPE][MONTH_LEN];	/* date 2nd delimmiter */
  359: extern char dat3char[NO_DATETYPE];	/* date day justify char */
  360: extern char dat4flag[NO_DATETYPE];	/* 0=DMY, 1=MDY, 2=YMD */
  361: extern char dat5flag[NO_DATETYPE];	/* suppress century digits */
  362: extern long int datGRbeg[NO_DATETYPE];	/* first day of gregorian calendar 15-OCT-1582 */
  363: extern int datetype;			/* type for $zd special variable */
  364: 
  365: extern char tim1char[NO_TIMETYPE];	/* time 1st delimiter */
  366: extern char tim2char[NO_TIMETYPE];	/* time 2nd delimiter */
  367: extern char tim3char[NO_TIMETYPE];	/* time hour justify char */
  368: extern char tim4flag[NO_TIMETYPE];	/* 0=12 Hrs 1=24 Hrs */
  369: extern char tim5flag[NO_TIMETYPE];	/* suppress seconds */
  370: extern int timetype;			/* type for $zt special variable */
  371: 
  372: extern jmp_buf sjbuf;			/* on timeout */
  373: extern char *roucu0;
  374: extern char *dofram0;
  375: 
  376: extern short forx;			/* FOR stack pointer */
  377: extern char forvar[NESTLEVLS + 1][40],	/* FOR variable */
  378:     forinc[NESTLEVLS + 1][40],	/* FOR increment */
  379:     forpost[NESTLEVLS + 1][128],/* FOR postconditional */
  380:     forlim[NESTLEVLS + 1][40];	/* FOR limit value */
  381: extern short fortyp[NESTLEVLS + 1];	/* 0 = forever    1 = single,     */
  382: 
  383: 					  /* 2 = unlim.iter,3 = limit iter. */
  384: 					  /* 4 =  "" +inc=1 5 =  "" + inc=1 */
  385: extern short fori[NESTLEVLS + 1];	/* if fortyp=5 length of forlimit */
  386: 
  387: extern char *fvar;			/* current forvar */
  388: extern char *finc;			/* current forinc */
  389: extern char *fpost;                     /* current forpost */
  390: extern char *flim;			/* current forlim */
  391: extern short ftyp;			/* current fortyp */
  392: extern short fi;			/* current fori   */
  393: extern short forsw;			/* FOR switch */
  394: extern short argless_forsw_quit; /* QUIT from argumentless FOR */
  395: extern short sigint_in_for; /* SIGINT occurred in FOR loop */
  396: extern short direct_mode;
  397: extern short loadsw;			/* flag to avoid redundant loads */
  398: extern short extr_types[NESTLEVLS + 1]; /* return types of extrinsic functions */
  399: 
  400: extern char destructors[10][OBJ_DSTRSIZE];
  401: extern int destructor_ct;
  402: extern char private_keys[MAX_PRIVATE_KEYS][255];
  403: 
  404: /* after XECUTEs */
  405: extern short promflag;			/* prompt execute flag */
  406: extern short privflag;			/* extrinsic z-command flag */
  407: 
  408: extern short brkstk[NESTLEVLS + 1];	/* stack for BREAK information   */
  409: 
  410: extern char *cmdstack;
  411: extern char *cmdptr;
  412: 
  413: extern short offset;
  414: extern long frm_timeout;
  415: extern short timeoutms;
  416: extern char tmp4[80];
  417: extern short param;			/* parameter count */
  418: extern short paramx;			/* current parameter */
  419: extern short level;			/* level count */
  420: extern short nestlt[NESTLEVLS + 1];	/* stack $T / stack levelcount */
  421: extern pid_t pid;			/* $J = process ID */
  422: 
  423: extern char jour_hostid[256];
  424: 
  425: extern char nsroot[4096]; /* root path of namespace */
  426: extern char nsname[256];  /* namespace name */ 
  427: extern char *freem_path;  /* path to the running instance of FreeM */
  428: extern char history_file[256];
  429: extern int n_lines;         /* rows in screen */
  430: extern int n_columns;       /* columns in screen */
  431: extern short ipc_pending;   /* 1 if an incoming IPC is pending, 0 otherwise */
  432: 
  433: extern int strict_mode;
  434: extern short first_process;
  435: extern size_t shm_init_size;
  436: extern short inrpt_after_async;
  437: extern int trace_mode;
  438: extern short debug_mode;
  439: extern short lasterr[NESTLEVLS + 1];
  440: /* Macros */
  441: /* Create a new variable of type (datatype) with space for qty instances */
  442: #define NEW(datatype,qty)  ((datatype *)calloc(qty,sizeof(datatype)))
  443: 
  444: /* End of $Source: /home/cvsroot/freem/src/mpsdef.h,v $ */

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