|
|
| version 1.1, 2025/01/19 02:04:04 | version 1.12, 2025/03/24 04:05:36 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * service.c | |
| * terminal and sequential I/O handling, | * terminal and sequential I/O handling, |
| * file and global locking | * file and global locking |
| * | * |
| * | * |
| * 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 36 | Line 24 |
| * 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.12 2025/03/24 04:05:36 snw | |
| * Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2 | |
| * | |
| * Revision 1.11 2025/03/24 02:00:30 snw | |
| * Work around some OS/2 incompatibilities in service.c | |
| * | |
| * Revision 1.10 2025/03/24 01:55:46 snw | |
| * Work around some OS/2 incompatibilities in service.c | |
| * | |
| * Revision 1.9 2025/03/24 01:54:09 snw | |
| * Work around some OS/2 incompatibilities in set_break and set_zbreak | |
| * | |
| * Revision 1.8 2025/03/24 01:52:30 snw | |
| * Work around some OS/2 incompatibilities in set_break and set_zbreak | |
| * | |
| * Revision 1.7 2025/03/09 19:50:47 snw | |
| * Second phase of REUSE compliance and header reformat | |
| * | |
| * | |
| * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC | |
| * SPDX-License-Identifier: AGPL-3.0-or-later | |
| **/ | **/ |
| #include <errno.h> | #include <errno.h> |
| Line 65 | Line 75 |
| #include "events.h" | #include "events.h" |
| long int tell (); | long int tell (); |
| unsigned alarm (); | void ris (struct vtstyp *scr); |
| void ris (); | |
| #ifdef SCO | #ifdef SCO |
| int scosgr (short att, short bwflag); | int scosgr (short att, short bwflag); |
| #endif | #endif |
| /* system services */ | /* system services */ |
| #include <termios.h> | #if !defined(__APPLE__) && !defined(__gnu_hurd__) && !defined(EMSCRIPTEN) |
| # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__AMIGA) | |
| # include <termios.h> | |
| # if !defined(__AMIGA) | |
| # define TCGETA TIOCGETA | |
| # define TCSETA TIOCSETA | |
| # endif | |
| # define termio termios | |
| # else | |
| # if !defined(MSDOS) | |
| # include <termio.h> | |
| # endif | |
| # if defined(__OS2__) | |
| # include <termios.h> | |
| # define termio termios | |
| # endif | |
| # endif | |
| #else | |
| # include <termios.h> | |
| #endif | |
| #include <fcntl.h> | #include <fcntl.h> |
| /* search 'string' for occurence of 'pattrn' | /* search 'string' for occurence of 'pattrn' |
| Line 972 end: | Line 1000 end: |
| void writeHOME (char *text) | void writeHOME (char *text) |
| { | { |
| #if !defined(__OS2__) | |
| struct winsize terminal_window; | struct winsize terminal_window; |
| #endif | |
| static char initflag = TRUE; /* initialisation flag */ | static char initflag = TRUE; /* initialisation flag */ |
| static char esc = 0; /* esc processing flag */ | static char esc = 0; /* esc processing flag */ |
| static char dcs = 0; /* device control processing flag */ | static char dcs = 0; /* device control processing flag */ |
| Line 1033 void writeHOME (char *text) | Line 1063 void writeHOME (char *text) |
| * and the 'hardcopy function' | * and the 'hardcopy function' |
| */ | */ |
| if (initflag) { | if (initflag) { |
| #if !defined(__OS2__) | |
| /* TODO: why are we casting to void here? */ | /* TODO: why are we casting to void here? */ |
| (void) ioctl(STDOUT_FILENO, TIOCGWINSZ, &terminal_window); | (void) ioctl(STDOUT_FILENO, TIOCGWINSZ, &terminal_window); |
| n_lines = terminal_window.ws_row; | n_lines = terminal_window.ws_row; |
| n_columns = terminal_window.ws_col; | n_columns = terminal_window.ws_col; |
| #else | |
| n_lines = 25; | |
| n_columns = 80; | |
| #endif | |
| screen = (struct vtstyp *) calloc (1, sizeof (struct vtstyp)); | screen = (struct vtstyp *) calloc (1, sizeof (struct vtstyp)); |
| ris (screen); | ris (screen); |
| Line 3287 void write_m (char *text) | Line 3322 void write_m (char *text) |
| ypos[io]++; | ypos[io]++; |
| if (crlf[io]) xpos[io] = 0; | if (frm_crlf[io]) xpos[io] = 0; |
| continue; | continue; |
| Line 3352 void write_t (short int col) | Line 3387 void write_t (short int col) |
| } /* end of write_t() */ | } /* end of write_t() */ |
| void ontimo () | void ontimo (void) |
| { /* handle timeout (for read) */ | { /* handle timeout (for read) */ |
| longjmp (sjbuf, 1); | longjmp (sjbuf, 1); |
| } /* end of ontimo() */ | } /* end of ontimo() */ |
| Line 4118 void read_m (char *stuff, long read_time | Line 4153 void read_m (char *stuff, long read_time |
| if (single) break; | if (single) break; |
| if (ch == LF && crlf[io]) { | if (ch == LF && frm_crlf[io]) { |
| i--; | i--; |
| continue; | continue; |
| } | } |
| Line 4422 void set_io (short action) | Line 4457 void set_io (short action) |
| /* DEL = UNIX quit */ | /* DEL = UNIX quit */ |
| void set_break (short break_char) | void set_break (short break_char) |
| { | { |
| #if !defined(__OS2__) | |
| struct termio arg; | struct termio arg; |
| ioctl (0, TCGETA, &arg); | ioctl (0, TCGETA, &arg); |
| Line 4429 void set_break (short break_char) | Line 4465 void set_break (short break_char) |
| arg.c_cc[VINTR] = break_char; /* interrupt = CTRL/C */ | arg.c_cc[VINTR] = break_char; /* interrupt = CTRL/C */ |
| ioctl (0, TCSETA, &arg); | ioctl (0, TCSETA, &arg); |
| #endif | |
| return; | return; |
| } /* end of set_break() */ | } /* end of set_break() */ |
| Line 4440 void set_break (short break_char) | Line 4476 void set_break (short break_char) |
| /* DEL = UNIX quit */ | /* DEL = UNIX quit */ |
| void set_zbreak (short quit_char) | void set_zbreak (short quit_char) |
| { | { |
| #if !defined(__OS2__) | |
| struct termio arg; | struct termio arg; |
| ioctl (0, TCGETA, &arg); | ioctl (0, TCGETA, &arg); |
| Line 4447 void set_zbreak (short quit_char) | Line 4484 void set_zbreak (short quit_char) |
| arg.c_cc[VQUIT] = quit_char; | arg.c_cc[VQUIT] = quit_char; |
| ioctl (0, TCSETA, &arg); | ioctl (0, TCSETA, &arg); |
| #endif | |
| return; | return; |
| } /* end of set_zbreak() */ | } /* end of set_zbreak() */ |
| Line 4492 void set_io (short action) /* set io_ | Line 4529 void set_io (short action) /* set io_ |
| void set_break (short break_char) | void set_break (short break_char) |
| { | { |
| #if !defined(__OS2__) | |
| struct termios termios_p; | struct termios termios_p; |
| tcgetattr (0, &termios_p); | tcgetattr (0, &termios_p); |
| Line 4499 void set_break (short break_char) | Line 4538 void set_break (short break_char) |
| termios_p.c_cc[VINTR] = break_char; /* interrupt = CTRL/C */ | termios_p.c_cc[VINTR] = break_char; /* interrupt = CTRL/C */ |
| tcsetattr (0, TCSADRAIN, &termios_p); /* set paramters */ | tcsetattr (0, TCSADRAIN, &termios_p); /* set paramters */ |
| #endif | |
| return; | return; |
| } /* end of set_break() */ | } /* end of set_break() */ |
| void set_zbreak (short quit_char) | void set_zbreak (short quit_char) |
| { | { |
| #if !defined(__OS2__) | |
| struct termios termios_p; | struct termios termios_p; |
| tcgetattr (0, &termios_p); | tcgetattr (0, &termios_p); |
| Line 4514 void set_zbreak (short quit_char) | Line 4553 void set_zbreak (short quit_char) |
| termios_p.c_cc[VQUIT] = quit_char; | termios_p.c_cc[VQUIT] = quit_char; |
| tcsetattr (0, TCSADRAIN, &termios_p); /* set paramters */ | tcsetattr (0, TCSADRAIN, &termios_p); /* set paramters */ |
| #endif | |
| return; | return; |
| } /* end of set_zbreak() */ | } /* end of set_zbreak() */ |