|
|
| version 1.1.1.1, 2025/01/19 02:04:04 | version 1.4, 2025/03/22 18:43:54 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | * ^$ZPROCESS ssvn |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * ssvn_zprocess.c | |
| * ^$ZPROCESS ssv | |
| * | * |
| * | * |
| * 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.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: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 <stdlib.h> | #include <stdlib.h> |
| Line 52 void ssvn_zprocess (short action, char * | Line 50 void ssvn_zprocess (short action, char * |
| char *kbuf = (char *) malloc (STRLEN * sizeof(char)); | char *kbuf = (char *) malloc (STRLEN * sizeof(char)); |
| char *verb = (char *) malloc (STRLEN * sizeof(char)); | char *verb = (char *) malloc (STRLEN * sizeof(char)); |
| char *proc_path = (char *) malloc (STRLEN * sizeof(char)); | char *proc_path = (char *) malloc (PATHLEN * sizeof(char)); |
| pid_t t_pid; | pid_t t_pid; |
| Line 76 void ssvn_zprocess (short action, char * | Line 74 void ssvn_zprocess (short action, char * |
| } | } |
| t_pid = atol(ref->subscripts[0]); | t_pid = atol(ref->subscripts[0]); |
| snprintf (proc_path, STRLEN - 1, "/proc/%d", t_pid); | snprintf (proc_path, PATHLEN, "/proc/%d", t_pid); |
| strncpy (verb, ref->subscripts[1], STRLEN - 1); | strncpy (verb, ref->subscripts[1], STRLEN); |
| stcpy (kbuf, key); | stcpy (kbuf, key); |
| Line 90 void ssvn_zprocess (short action, char * | Line 88 void ssvn_zprocess (short action, char * |
| if (strcmp (verb, "EXISTS") == 0) { | if (strcmp (verb, "EXISTS") == 0) { |
| if (kill (t_pid, 0) == 0) { | if (kill (t_pid, 0) == 0) { |
| snprintf (data, STRLEN - 1, "%d\201", 1); | snprintf (data, STRLEN, "%d\201", 1); |
| } | } |
| else { | else { |
| snprintf (data, STRLEN - 1, "%d\201", 0); | snprintf (data, STRLEN, "%d\201", 0); |
| } | } |
| free (kbuf); | free (kbuf); |
| Line 107 void ssvn_zprocess (short action, char * | Line 105 void ssvn_zprocess (short action, char * |
| } | } |
| else if (strcmp (verb, "ATTRIBUTE") == 0) { | else if (strcmp (verb, "ATTRIBUTE") == 0) { |
| char attrib[256]; | char attrib[STRLEN]; |
| char fpath[4096]; | char fpath[PATHLEN]; |
| FILE *fp; | FILE *fp; |
| strncpy (attrib, ref->subscripts[2], 255); | strncpy (attrib, ref->subscripts[2], 255); |
| snprintf (fpath, 4095, "/proc/%d/%s", t_pid, attrib); | snprintf (fpath, PATHLEN, "/proc/%d/%s", t_pid, attrib); |
| if ((fp = fopen (fpath, "r")) == NULL) { | if ((fp = fopen (fpath, "r")) == NULL) { |
| Line 127 void ssvn_zprocess (short action, char * | Line 125 void ssvn_zprocess (short action, char * |
| return; | return; |
| } | } |
| fgets (data, 256, fp); | fgets (data, STRLEN, fp); |
| stcnv_c2m (data); | stcnv_c2m (data); |
| fclose (fp); | fclose (fp); |