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