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