version 1.1.1.1, 2025/01/19 02:04:04
|
version 1.6, 2025/04/09 19:52:02
|
Line 1
|
Line 1
|
/* |
/* |
* * |
* $Id$ |
* * * |
|
* * * |
|
* *************** |
|
* * * * * |
|
* * MUMPS * |
|
* * * * * |
|
* *************** |
|
* * * |
|
* * * |
|
* * |
|
* |
|
* cmd_write.c |
|
* Implementation of the WRITE command |
* Implementation of the WRITE command |
* |
* |
* |
* |
* 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) 2023 Coherent Logic Development LLC |
* Copyright (C) 2023 Coherent Logic Development LLC |
* |
* |
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.6 2025/04/09 19:52:02 snw |
|
* Eliminate as many warnings as possible while building with -Wall |
|
* |
|
* Revision 1.5 2025/03/24 04:05:36 snw |
|
* Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2 |
|
* |
|
* Revision 1.4 2025/03/22 18:43:54 snw |
|
* Make STRLEN 255 chars and add BIGSTR macro for larger buffers |
|
* |
|
* Revision 1.3 2025/03/09 19:14:24 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 |
**/ |
**/ |
|
|
#include <string.h> |
#include <string.h> |
Line 49 MRESULT cmd_write(MACTION *ra, int *i)
|
Line 53 MRESULT cmd_write(MACTION *ra, int *i)
|
{ |
{ |
char vn[255]; |
char vn[255]; |
char *wr_terminator = (char *) malloc (STRLEN * sizeof (char)); |
char *wr_terminator = (char *) malloc (STRLEN * sizeof (char)); |
char *sw_buf = (char *) malloc (STRLEN * sizeof (char)); |
char *sw_buf = (char *) malloc (BIGSTR * sizeof (char)); |
|
|
NULLPTRCHK(wr_terminator,"cmd_write"); |
NULLPTRCHK(wr_terminator,"cmd_write"); |
NULLPTRCHK(sw_buf,"cmd_write"); |
NULLPTRCHK(sw_buf,"cmd_write"); |
Line 57 MRESULT cmd_write(MACTION *ra, int *i)
|
Line 61 MRESULT cmd_write(MACTION *ra, int *i)
|
if (io > FIRSTSCK) msck_get_terminator (io, wr_terminator); |
if (io > FIRSTSCK) msck_get_terminator (io, wr_terminator); |
|
|
if (io != HOME && devopen[io] == 'r' && io < FIRSTSCK) { |
if (io != HOME && devopen[io] == 'r' && io < FIRSTSCK) { |
|
free (wr_terminator); |
free (sw_buf); |
free (sw_buf); |
return NOWRITE; |
return NOWRITE; |
} |
} |
|
|
if ((*i = (*codptr)) == SP || *i == EOL) { |
if ((*i = (*codptr)) == SP || *i == EOL) { |
|
free (wr_terminator); |
|
free (sw_buf); |
return ARGLIST; |
return ARGLIST; |
} |
} |
|
|
Line 74 writeproc:
|
Line 81 writeproc:
|
|
|
if (io < FIRSTSCK) { |
if (io < FIRSTSCK) { |
|
|
if (crlf[io]) { |
if (frm_crlf[io]) { |
write_m ("\012\201"); |
write_m ("\012\201"); |
} |
} |
else { |
else { |