|
|
| version 1.1.1.1, 2025/01/19 02:04:04 | version 1.5, 2025/03/22 18:43:54 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * fma_globals.c | |
| * fmadm - globals | * fmadm - globals |
| * | * |
| * | * |
| * 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.5 2025/03/22 18:43:54 snw | |
| * Make STRLEN 255 chars and add BIGSTR macro for larger buffers | |
| * | |
| * Revision 1.4 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 <stdlib.h> | #include <stdlib.h> |
| Line 54 void gl (char *global, short kf, short d | Line 52 void gl (char *global, short kf, short d |
| int gverify (char *gpath); | int gverify (char *gpath); |
| static short int g_collate (); /* if 't' follows 's' in MUMPS collating */ | static short int g_collate (); /* if 't' follows 's' in MUMPS collating */ |
| int key_check (char *key); | int key_check (char *key); |
| void check (); | void check (unsigned long blknbr); |
| void show (); | static short int g_collate (char s[], char t[]); /* if 't' follows 's' in MUMPS collating */ |
| void show (char key[]); | |
| /* global variables for gverify */ | /* global variables for gverify */ |
| short filedes; /* file descriptor */ | short filedes; /* file descriptor */ |
| Line 79 int fma_globals_list (int optc, char **o | Line 78 int fma_globals_list (int optc, char **o |
| DIR *dir; | DIR *dir; |
| struct dirent *ent; | struct dirent *ent; |
| char filename[STRLEN]; | char filename[PATHLEN]; |
| int ct = 0; | int ct = 0; |
| Line 96 int fma_globals_list (int optc, char **o | Line 95 int fma_globals_list (int optc, char **o |
| while ((ent = readdir (dir)) != NULL) { | while ((ent = readdir (dir)) != NULL) { |
| strncpy (filename, ent->d_name, STRLEN - 1); | strncpy (filename, ent->d_name, PATHLEN - 1); |
| if (filename[0] == '^' && filename[1] != '$') { | if (filename[0] == '^' && filename[1] != '$') { |
| printf (" %s\n", filename); | printf (" %s\n", filename); |
| Line 117 int fma_globals_examine (int optc, char | Line 116 int fma_globals_examine (int optc, char |
| DIR *dir; | DIR *dir; |
| struct dirent *ent; | struct dirent *ent; |
| char gpath[STRLEN]; | char gpath[PATHLEN]; |
| int i; | int i; |
| int ct = 0; | int ct = 0; |
| Line 152 int fma_globals_examine (int optc, char | Line 151 int fma_globals_examine (int optc, char |
| for (i = fma_base_opt; i < optc; i++) { | for (i = fma_base_opt; i < optc; i++) { |
| snprintf (gpath, STRLEN - 1, "%s/%s", fma_global_path, opts[i]); | snprintf (gpath, PATHLEN - 1, "%s/%s", fma_global_path, opts[i]); |
| gl (gpath, FALSE, FALSE, FALSE, strlen (fma_global_path)); | gl (gpath, FALSE, FALSE, FALSE, strlen (fma_global_path)); |
| ct++; | ct++; |
| Line 164 int fma_globals_examine (int optc, char | Line 163 int fma_globals_examine (int optc, char |
| while ((ent = readdir (dir)) != NULL) { | while ((ent = readdir (dir)) != NULL) { |
| strncpy (gpath, ent->d_name, STRLEN - 1); | strncpy (gpath, ent->d_name, PATHLEN - 1); |
| if (gpath[0] == '^' && gpath[1] != '$') { | if (gpath[0] == '^' && gpath[1] != '$') { |
| snprintf (gpath, STRLEN - 1, "%s/%s", fma_global_path, ent->d_name); | snprintf (gpath, PATHLEN - 1, "%s/%s", fma_global_path, ent->d_name); |
| gl (gpath, FALSE, FALSE, FALSE, strlen (fma_global_path)); | gl (gpath, FALSE, FALSE, FALSE, strlen (fma_global_path)); |
| Line 190 int fma_globals_examine (int optc, char | Line 189 int fma_globals_examine (int optc, char |
| int fma_globals_remove (int optc, char **opts) | int fma_globals_remove (int optc, char **opts) |
| { | { |
| char gpath[STRLEN]; | char gpath[PATHLEN]; |
| int i; | int i; |
| int ct = 0; | int ct = 0; |
| int er = 0; | int er = 0; |
| Line 205 int fma_globals_remove (int optc, char * | Line 204 int fma_globals_remove (int optc, char * |
| for (i = fma_base_opt; i < optc; i++) { | for (i = fma_base_opt; i < optc; i++) { |
| printf ("%-10s\t", opts[i]); | printf ("%-10s\t", opts[i]); |
| snprintf (gpath, STRLEN - 1, "%s/%s", fma_global_path, opts[i]); | snprintf (gpath, PATHLEN - 1, "%s/%s", fma_global_path, opts[i]); |
| if (unlink (gpath) == -1) { | if (unlink (gpath) == -1) { |
| printf ("[FAIL]\n"); | printf ("[FAIL]\n"); |
| Line 231 int fma_globals_verify (int optc, char * | Line 230 int fma_globals_verify (int optc, char * |
| DIR *dir; | DIR *dir; |
| struct dirent *ent; | struct dirent *ent; |
| char gpath[STRLEN]; | char gpath[PATHLEN]; |
| int i; | int i; |
| int ct = 0; | int ct = 0; |
| Line 265 int fma_globals_verify (int optc, char * | Line 264 int fma_globals_verify (int optc, char * |
| for (i = fma_base_opt; i < optc; i++) { | for (i = fma_base_opt; i < optc; i++) { |
| snprintf (gpath, STRLEN - 1, "%s/%s", fma_global_path, opts[i]); | snprintf (gpath, PATHLEN - 1, "%s/%s", fma_global_path, opts[i]); |
| exstat = 0; | exstat = 0; |
| gverify (gpath); | gverify (gpath); |
| Line 281 int fma_globals_verify (int optc, char * | Line 280 int fma_globals_verify (int optc, char * |
| while ((ent = readdir (dir)) != NULL) { | while ((ent = readdir (dir)) != NULL) { |
| strncpy (gpath, ent->d_name, STRLEN - 1); | strncpy (gpath, ent->d_name, PATHLEN - 1); |
| if (gpath[0] == '^') { | if (gpath[0] == '^') { |
| snprintf (gpath, STRLEN - 1, "%s/%s", fma_global_path, ent->d_name); | snprintf (gpath, PATHLEN - 1, "%s/%s", fma_global_path, ent->d_name); |
| exstat = 0; | exstat = 0; |
| gverify (gpath); | gverify (gpath); |
| Line 1008 showpath () | Line 1007 showpath () |
| for (i = 0; i < level; i++) | for (i = 0; i < level; i++) |
| printf (" path level(%d)=%ld\012\015", i, llink[i]); | printf (" path level(%d)=%ld\012\015", i, llink[i]); |
| if (++exstat >= ERRLIM) { | if (++exstat >= ERRLIM) { |
| fprintf (stderr, "Error limit exceeded (%hd errors)\012\015", exstat, ERRLIM); | fprintf (stderr, "Error limit exceeded (%hd errors)\012\015", exstat); |
| return; | return; |
| } | } |
| return; | return; |
| Line 1044 int key_check (char *key) /* checks a | Line 1043 int key_check (char *key) /* checks a |
| return 0; | return 0; |
| } /* end key_check */ | } /* end key_check */ |
| /******************************************************************************/ | /******************************************************************************/ |
| static short int | static short int g_collate (char s[], char t[]) /* if 't' follows 's' in MUMPS collating */ |
| g_collate (s, t) /* if 't' follows 's' in MUMPS collating */ | |
| char s[]; /* sequence a TRUE is returned */ | |
| char t[]; | |
| { | { |
| register int chs = *s; | register int chs = *s; |
| register int cht = *t; | register int cht = *t; |
| Line 1149 g_collate (s, t) /* if 't' follows 's' | Line 1144 g_collate (s, t) /* if 't' follows 's' |
| return dif > 0; | return dif > 0; |
| } /* end g_collate */ | } /* end g_collate */ |
| /******************************************************************************/ | /******************************************************************************/ |
| void | void show (char key[]) |
| show (key) | |
| char key[]; /* key in internal format to be expanded and shown */ | |
| { | { |
| int k, | int k, |
| ch, | ch, |