Annotation of freem/src/ssvn_library.c, revision 1.7
1.1 snw 1: /*
1.7 ! snw 2: * $Id: ssvn_library.c,v 1.6 2025/04/09 19:52:02 snw Exp $
1.3 snw 3: * ^$LIBRARY ssvn
1.1 snw 4: *
5: *
1.2 snw 6: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 7: * Copyright (C) 1998 MUG Deutschland
1.3 snw 8: * Copyright (C) 2020, 2023, 2025 Coherent Logic Development LLC
1.1 snw 9: *
10: *
11: * This file is part of FreeM.
12: *
13: * FreeM is free software: you can redistribute it and/or modify
14: * it under the terms of the GNU Affero Public License as published by
15: * the Free Software Foundation, either version 3 of the License, or
16: * (at your option) any later version.
17: *
18: * FreeM is distributed in the hope that it will be useful,
19: * but WITHOUT ANY WARRANTY; without even the implied warranty of
20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: * GNU Affero Public License for more details.
22: *
23: * You should have received a copy of the GNU Affero Public License
24: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
25: *
1.4 snw 26: * $Log: ssvn_library.c,v $
1.7 ! snw 27: * Revision 1.6 2025/04/09 19:52:02 snw
! 28: * Eliminate as many warnings as possible while building with -Wall
! 29: *
1.6 snw 30: * Revision 1.5 2025/03/24 04:13:11 snw
31: * Replace action macro dat with fra_dat to avoid symbol conflict on OS/2
32: *
1.5 snw 33: * Revision 1.4 2025/03/22 18:43:54 snw
34: * Make STRLEN 255 chars and add BIGSTR macro for larger buffers
35: *
1.4 snw 36: * Revision 1.3 2025/03/09 19:50:47 snw
37: * Second phase of REUSE compliance and header reformat
38: *
1.3 snw 39: *
40: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
41: * SPDX-License-Identifier: AGPL-3.0-or-later
1.1 snw 42: **/
43:
44: #include <stdio.h>
45: #include <stdlib.h>
46: #include <string.h>
47: #include <dirent.h>
48: #include <time.h>
49: #include <unistd.h>
50: #include <sys/types.h>
51: #include <sys/stat.h>
52: #include <ctype.h>
53: #include <errno.h>
54:
55: #include "mpsdef.h"
56: #include "mref.h"
57:
58: void ssvn_library_add_dir(char *);
59:
60: void ssvn_library_add_dir(char *libdir)
61: {
62:
63: DIR *dir;
64: struct dirent *ent;
1.4 snw 65: char filename[PATHLEN];
1.1 snw 66: char rtnname[256];
67: char *rtnext;
68:
69: char k_buf[512];
70: char d_buf[512];
71: register int i;
72:
73: dir = opendir (libdir);
74: while ((ent = readdir (dir)) != NULL) {
75:
1.4 snw 76: strncpy (filename, ent->d_name, PATHLEN);
1.1 snw 77:
78: rtnext = ent->d_name + (strlen (ent->d_name) - 2);
79:
80: if ((strcmp (rtnext, ".m") == 0) && (strncmp (filename, "%ul", 3) == 0)) {
81:
82: strcpy (rtnname, ent->d_name + 3);
83: rtnname[strlen (ent->d_name) - 5] = '\0';
84:
85: for (i = 0; i < strlen (rtnname); i++) {
86: if (rtnname[i] >= 'a' && rtnname[i] <= 'z') {
87: rtnname[i] -= 32;
88: }
89: }
90:
1.7 ! snw 91: snprintf (k_buf, sizeof (k_buf) - 1, "^$LIBRARY\202%s\201", rtnname);
! 92: snprintf (d_buf, sizeof (d_buf) - 1, " \201");
1.1 snw 93: symtab_bltin (set_sym, k_buf, d_buf);
94:
95: }
96:
97: }
98:
99: closedir (dir);
100:
101: }
102:
103: void ssvn_library_update(void)
104: {
1.4 snw 105: char t_buf[PATHLEN];
1.1 snw 106:
107: stcpy (t_buf, rou0plib);
108: stcnv_m2c (t_buf);
109:
110: ssvn_library_add_dir (t_buf);
111:
112: return;
113:
114: }
115:
116: void ssvn_library(short action, char *key, char *data)
117: {
118: freem_ref_t *r = (freem_ref_t *) malloc (sizeof (freem_ref_t));
119: NULLPTRCHK(r,"ssvn_routine");
120:
121: mref_init (r, MREF_RT_SSV, "^$ROUTINE");
122: internal_to_mref (r, key);
123:
124: ssvn_routine_update ();
125:
126: switch (action) {
127:
128: case get_sym:
129: case fra_order:
130: case fra_query:
131: case bigquery:
1.5 snw 132: case fra_dat:
1.1 snw 133:
134: symtab_bltin (action, key, data);
135: goto done;
136:
137: default:
138:
139: merr_raise (M38);
140: goto done;
141:
142: }
143:
144: done:
145: free (r);
146:
147: return;
148: }
149:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>