|
|
| version 1.1, 2025/01/19 02:04:04 | version 1.14, 2025/04/28 19:38:55 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * frmgbl.c | |
| * freem global C variables | * freem global C variables |
| * | * |
| * | * |
| * Author: Serena Willis <jpw@coherent-logic.com> | * Author: Serena Willis <snw@coherent-logic.com> |
| * Copyright (C) 1998 MUG Deutschland | * Copyright (C) 1998 MUG Deutschland |
| * Copyright (C) 2020 Coherent Logic Development LLC | * Copyright (C) 2020, 2025 Coherent Logic Development LLC |
| * | * |
| * | * |
| * This file is part of FreeM. | * This file is part of FreeM. |
| Line 35 | Line 23 |
| * You should have received a copy of the GNU Affero Public License | * You should have received a copy of the GNU Affero Public License |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | |
| * Revision 1.14 2025/04/28 19:38:55 snw | |
| * Add trace mode | |
| * | |
| * Revision 1.13 2025/04/17 14:34:27 snw | |
| * Further logging improvements | |
| * | |
| * Revision 1.12 2025/04/16 17:36:12 snw | |
| * Add FreeBSD shm cleanup script | |
| * | |
| * Revision 1.11 2025/04/13 04:22:43 snw | |
| * Fix snprintf calls | |
| * | |
| * Revision 1.10 2025/04/10 01:24:38 snw | |
| * Remove C++ style comments | |
| * | |
| * Revision 1.9 2025/04/03 01:41:02 snw | |
| * New features frozen; prepare 0.63.0-rc1 | |
| * | |
| * Revision 1.8 2025/04/02 03:02:42 snw | |
| * Stop requiring users to pass -e to fmadm when -u or -g are passed | |
| * | |
| * Revision 1.7 2025/04/01 16:37:12 snw | |
| * Configure DEFAULT environment the same as others, and set permissions/ownership directly in fmadm configure. Add env.conf file as a centralized configuration listing all environments. | |
| * | |
| * Revision 1.6 2025/03/24 04:05:36 snw | |
| * Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2 | |
| * | |
| * Revision 1.5 2025/03/09 19:14:25 snw | |
| * First phase of REUSE compliance and header reformat | |
| * | |
| * | |
| * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC | |
| * SPDX-License-Identifier: AGPL-3.0-or-later | |
| **/ | **/ |
| /* needed if byte data are to be interpreted as unsigned integer */ | /* needed if byte data are to be interpreted as unsigned integer */ |
| Line 48 | Line 70 |
| #include <string.h> | #include <string.h> |
| #include <sys/types.h> | #include <sys/types.h> |
| #include <sys/wait.h> | #include <sys/wait.h> |
| #include <errno.h> | |
| #include "transact.h" | #include "transact.h" |
| #include "locktab.h" | #include "locktab.h" |
| #include <errno.h> | #include "log.h" |
| #ifdef LIBFREEM | #ifdef LIBFREEM |
| # include "errmsg.h" | # include "errmsg.h" |
| #endif | #endif |
| #if defined HAVE_NCURSESW_CURSES_H | |
| # include <ncursesw/curses.h> | |
| #elif defined HAVE_NCURSESW_H | |
| # include <ncursesw.h> | |
| #elif defined HAVE_NCURSES_CURSES_H | |
| # include <ncurses/curses.h> | |
| #elif defined HAVE_NCURSES_H | |
| # include <ncurses.h> | |
| #elif defined HAVE_CURSES_H | |
| # include <curses.h> | |
| #else | |
| # error "SysV or X/Open-compatible Curses header file required" | |
| #endif | |
| #define UNSIGN(A) ((A)&0377) | #define UNSIGN(A) ((A)&0377) |
| #define g_EOL 30 | #define g_EOL 30 |
| Line 135 | Line 144 |
| #define VIEW 'v' | #define VIEW 'v' |
| #define WRITE 'w' | #define WRITE 'w' |
| #define XECUTE 'x' | #define XECUTE 'x' |
| #define ZALLOCATE 'A' | |
| #define ZBREAK 'B' | #define ZBREAK 'B' |
| #define ZDEALLOCATE 'D' | |
| #define ZGO 'G' | #define ZGO 'G' |
| #define ZHALT 'H' | #define ZHALT 'H' |
| #define ZINSERT 'I' | #define ZINSERT 'I' |
| Line 349 frm_devstat devstat[MAXDEV + 1]; /* chan | Line 355 frm_devstat devstat[MAXDEV + 1]; /* chan |
| short xpos[MAXDEV + 1]; /* $X-vector */ | short xpos[MAXDEV + 1]; /* $X-vector */ |
| short ypos[MAXDEV + 1]; /* $Y-vector */ | short ypos[MAXDEV + 1]; /* $Y-vector */ |
| short crlf[MAXDEV + 1]; /* CR/LF flag vector */ | short frm_crlf[MAXDEV + 1]; /* CR/LF flag vector */ |
| short fm_nodelay[MAXDEV + 1]; /* nodelay flag vector */ | short fm_nodelay[MAXDEV + 1]; /* nodelay flag vector */ |
| int ESCflag[MAXDEV + 1] = | int ESCflag[MAXDEV + 1] = |
| Line 429 int noclear = FALSE; /* nocle | Line 435 int noclear = FALSE; /* nocle |
| int standard = D_FREEM; /* default dialect */ | int standard = D_FREEM; /* default dialect */ |
| int quiet_mode = FALSE; /* quiet mode */ | int quiet_mode = FALSE; /* quiet mode */ |
| char config_file[4096]; /* path to configuration file */ | char config_file[4096]; /* path to configuration file */ |
| char env_config_file[4096]; /* path to environment config file */ | |
| char env_user[255]; | |
| char env_group[255]; | |
| char env_enabled[10]; | |
| char shm_env[255]; /* shared memory environment */ | char shm_env[255]; /* shared memory environment */ |
| short fp_mode = 0; /* set to 0 for fixed-point math, 1 for IEEE754 floating point */ | short fp_mode = 0; /* set to 0 for fixed-point math, 1 for IEEE754 floating point */ |
| Line 533 char rou0plib[PATHLEN]; /* % | Line 543 char rou0plib[PATHLEN]; /* % |
| char rou1plib[PATHLEN]; /* %routine path (ZL..) */ | char rou1plib[PATHLEN]; /* %routine path (ZL..) */ |
| char oucpath[PATHLEN] = "\201"; /* OPEN/USE/CLOSE path */ | char oucpath[PATHLEN] = "\201"; /* OPEN/USE/CLOSE path */ |
| char zargdefname[PATHLEN]= "%\201"; /* default varname for Z-commands */ | char zargdefname[PATHLEN]= "%\201"; /* default varname for Z-commands */ |
| char jourfile[PATHLEN] = "/usr/tmp/ioprotocol"; /* journal file */ | |
| FILE *jouraccess; /* dto. filedes */ | FILE *jouraccess; /* dto. filedes */ |
| char curdir[256] = "."; /* current directory */ | char curdir[256] = "."; /* current directory */ |
| char startuprou[PATHLEN] = "\201"; /* start up routine from cmdline*/ | char startuprou[PATHLEN] = "\201"; /* start up routine from cmdline*/ |
| char zcommds[256] = | char zcommds[256] = |
| " za zas zb zd zg zh zi zj zl zn zp zq zr zs zt zwr zallocate zbreak zdeallocate \ | " za zas zb zd zg zh zi zj zl zn zp zq zr zs zt zwr zbreak \ |
| zgo zhalt zinsert zjob zload znamespace zprint zquit zremove zsave ztrap zwrite \201"; /* intrinsic z-commands */ | zgo zhalt zinsert zjob zload znamespace zprint zquit zremove zsave ztrap zwrite \201"; /* intrinsic z-commands */ |
| char zfunctions[256] = /* intrinsic z-functions */ | char zfunctions[256] = /* intrinsic z-functions */ |
| " zb zc zd ze zh zht zk zl zm zn zo zp zr zs zt zboolean zcall zcr zcrc zdata zdate zedit zhorolog \ | " zb zc zd ze zh zht zk zl zm zn zo zp zr zs zt zboolean zcall zcr zcrc zdata zdate zedit zhorolog \ |
| Line 618 short sigint_in_for = FALSE; | Line 627 short sigint_in_for = FALSE; |
| short direct_mode = TRUE; /* are we in direct mode? */ | short direct_mode = TRUE; /* are we in direct mode? */ |
| short extr_types[NESTLEVLS + 1]; /* return types of extrinsic functions */ | short extr_types[NESTLEVLS + 1]; /* return types of extrinsic functions */ |
| char destructors[MAX_DESTRUCTORS][50]; | char destructors[MAX_DESTRUCTORS][OBJ_DSTRSIZE]; |
| int destructor_ct; | int destructor_ct; |
| char private_keys[MAX_PRIVATE_KEYS][255]; | char private_keys[MAX_PRIVATE_KEYS][255]; |
| Line 636 short timeoutms; | Line 645 short timeoutms; |
| char tmp4[80] = "\201"; | char tmp4[80] = "\201"; |
| short param = 0; /* parameter count */ | short param = 0; /* parameter count */ |
| short paramx = 0; /* current parameter */ | short paramx = 0; /* current parameter */ |
| char *ttyname (); | |
| short level = 0; /* level count */ | short level = 0; /* level count */ |
| pid_t pid; /* $J = process ID */ | pid_t pid; /* $J = process ID */ |
| Line 651 short ipc_pending = 0; /* 1 if an inco | Line 659 short ipc_pending = 0; /* 1 if an inco |
| int strict_mode = 0; | int strict_mode = 0; |
| short first_process = FALSE; | int trace_mode = 0; |
| size_t shm_init_size = 16777216; | |
| short first_process = FALSE; | |
| #if defined(__FreeBSD__) | |
| size_t shm_init_size = 4194304; | |
| #else | |
| size_t shm_init_size = 16777216; | |
| #endif | |
| short inrpt_after_async = FALSE; | short inrpt_after_async = FALSE; |
| //#ifdef USE_SIGACTION | |
| // struct sigaction act = {0}; /* signals stuff */ | |
| //#endif/*USE_SIGACTION*/ | |
| void unnew (void) | void unnew (void) |
| { | { |
| char *xptr; | char *xptr; |
| Line 740 void m_fatal(char *s) | Line 749 void m_fatal(char *s) |
| if (tp_level) { | if (tp_level) { |
| fprintf (stderr, "freem [FATAL]: memory allocation failure in %s; rolling back %d transactions [errno %d %s]\n", s, tp_level, errno_sav, strerror (errno_sav)); | /* TODO: make this FM_LOG_FATAL (logger will need to do a tp_trollback) */ |
| logprintf (FM_LOG_ERROR, "freem: memory allocation failure in %s; rolling back %d transactions (error code %d [%s])", s, tp_level, errno_sav, strerror (errno_sav)); | |
| tp_trollback (tp_level); | tp_trollback (tp_level); |
| } | } |
| else { | else { |
| fprintf (stderr, "freem [FATAL]: memory allocation failure in %s [errno %d %s]\n", s, errno_sav, strerror (errno_sav)); | logprintf (FM_LOG_FATAL, "freem: memory allocation failure in %s (error code %d [%s])", s, errno_sav, strerror (errno_sav)); |
| } | } |
| exit (3); | exit (3); |