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