version 1.1, 2025/01/19 02:04:04
|
version 1.9, 2025/04/13 04:22:43
|
Line 1
|
Line 1
|
/* |
/* |
* * |
* $Id$ |
* * * |
|
* * * |
|
* *************** |
|
* * * * * |
|
* * MUMPS * |
|
* * * * * |
|
* *************** |
|
* * * |
|
* * * |
|
* * |
|
* |
|
* io_socket.c |
|
* socket i/o support |
* socket i/o support |
* |
* |
* |
* |
* 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.9 2025/04/13 04:22:43 snw |
|
* Fix snprintf calls |
|
* |
|
* Revision 1.8 2025/04/10 01:24:38 snw |
|
* Remove C++ style comments |
|
* |
|
* Revision 1.7 2025/03/24 02:56:15 snw |
|
* Socket I/O compat fixes for OS/2 |
|
* |
|
* Revision 1.6 2025/03/24 02:55:26 snw |
|
* Socket I/O compat fixes for OS/2 |
|
* |
|
* Revision 1.5 2025/03/24 02:54:11 snw |
|
* Socket I/O compat fixes for 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: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 |
**/ |
**/ |
|
|
#include <stdio.h> |
#include <stdio.h> |
Line 84 io_socket *io_sockets[MAXSCK];
|
Line 97 io_socket *io_sockets[MAXSCK];
|
addr_string: server:port[:family:[udp|tcp]]*/ |
addr_string: server:port[:family:[udp|tcp]]*/ |
short msck_open (int channel, char *addr_string) |
short msck_open (int channel, char *addr_string) |
{ |
{ |
#if !defined(MSDOS) |
#if !defined(MSDOS) && !defined(__OS2__) |
char *addr = ""; |
char *addr = ""; |
char *port = ""; |
char *port = ""; |
char *family = ""; |
char *family = ""; |
Line 104 short msck_open (int channel, char *addr
|
Line 117 short msck_open (int channel, char *addr
|
|
|
short i = channel + FIRSTSCK; /* get index into io_sockets[] array */ |
short i = channel + FIRSTSCK; /* get index into io_sockets[] array */ |
|
|
finaddr = (char *) malloc (STRLEN * sizeof (char)); |
finaddr = (char *) malloc (256 * sizeof (char)); |
NULLPTRCHK(finaddr,"msck_open"); |
NULLPTRCHK(finaddr,"msck_open"); |
|
|
|
|
Line 125 short msck_open (int channel, char *addr
|
Line 138 short msck_open (int channel, char *addr
|
|
|
if (ct == 1) { |
if (ct == 1) { |
|
|
family = (char *) malloc (STRLEN * sizeof (char)); |
family = (char *) malloc (256 * sizeof (char)); |
NULLPTRCHK(family,"msck_open"); |
NULLPTRCHK(family,"msck_open"); |
|
|
typ = (char *) malloc (STRLEN * sizeof (char)); |
typ = (char *) malloc (256 * sizeof (char)); |
NULLPTRCHK(typ,"msck_open"); |
NULLPTRCHK(typ,"msck_open"); |
|
|
strcpy (family, "IPV4"); |
strcpy (family, "IPV4"); |
Line 138 short msck_open (int channel, char *addr
|
Line 151 short msck_open (int channel, char *addr
|
if (ct == 2) { |
if (ct == 2) { |
family = strtok (NULL, ":"); |
family = strtok (NULL, ":"); |
|
|
typ = (char *) malloc (STRLEN * sizeof (char)); |
typ = (char *) malloc (256 * sizeof (char)); |
NULLPTRCHK(typ,"msck_open"); |
NULLPTRCHK(typ,"msck_open"); |
|
|
strcpy (typ, "TCP"); |
strcpy (typ, "TCP"); |
Line 243 short msck_open (int channel, char *addr
|
Line 256 short msck_open (int channel, char *addr
|
short msck_connect (int channel) |
short msck_connect (int channel) |
{ |
{ |
|
|
#if !defined(MSDOS) |
#if !defined(MSDOS) && !defined(__OS2__) |
|
|
short i = channel + FIRSTSCK; |
short i = channel + FIRSTSCK; |
|
|
Line 281 short msck_connect (int channel)
|
Line 294 short msck_connect (int channel)
|
short msck_write (int channel, char *buf, short length) |
short msck_write (int channel, char *buf, short length) |
{ |
{ |
|
|
#if !defined(MSDOS) |
#if !defined(MSDOS) && !defined(__OS2__) |
|
|
ssize_t ct; |
ssize_t ct; |
short i = channel + FIRSTSCK; |
short i = channel + FIRSTSCK; |
Line 316 short msck_write (int channel, char *buf
|
Line 329 short msck_write (int channel, char *buf
|
short msck_read (int channel, char *buf, long sck_timeout, short sck_timeoutms, short length) |
short msck_read (int channel, char *buf, long sck_timeout, short sck_timeoutms, short length) |
{ |
{ |
|
|
#if !defined(MSDOS) |
#if !defined(MSDOS) && !defined(__OS2__) |
fd_set fds; |
fd_set fds; |
short i; |
short i; |
struct timeval t; |
struct timeval t; |
Line 420 read_done:
|
Line 433 read_done:
|
short msck_close (int channel) |
short msck_close (int channel) |
{ |
{ |
|
|
#if !defined(MSDOS) |
#if !defined(MSDOS) && !defined(__OS2__) |
short i = channel + FIRSTSCK; |
short i = channel + FIRSTSCK; |
|
|
|
|
Line 441 short msck_close (int channel)
|
Line 454 short msck_close (int channel)
|
short msck_get_terminator (int channel, char *buf) |
short msck_get_terminator (int channel, char *buf) |
{ |
{ |
char wr_io[9]; |
char wr_io[9]; |
char *wr_key;// = (char *) malloc (STRLEN * sizeof (char)); |
char *wr_key; |
//NULLPTRCHK(wr_key,"msck_get_terminator"); |
|
|
|
freem_ref_t *wrr = (freem_ref_t *) malloc (sizeof (freem_ref_t)); |
freem_ref_t *wrr = (freem_ref_t *) malloc (sizeof (freem_ref_t)); |
NULLPTRCHK(wrr,"msck_get_terminator"); |
NULLPTRCHK(wrr,"msck_get_terminator"); |
|
|
snprintf (wr_io, 8, "%d", channel); |
snprintf (wr_io, sizeof (wr_io) - 1, "%d", channel); |
|
|
/* get ^$DEVICE($IO,"TERMINATOR") */ |
/* get ^$DEVICE($IO,"TERMINATOR") */ |
|
|