Annotation of freem/src/ssvn_job.c, revision 1.5
1.1 snw 1: /*
1.5 ! snw 2: * $Id: ssvn_job.c,v 1.4 2025/03/09 19:50:47 snw Exp $
1.4 snw 3: * ^$JOB ssvn
1.1 snw 4: *
5: *
1.3 snw 6: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 7: * Copyright (C) 1998 MUG Deutschland
1.4 snw 8: * Copyright (C) 2020, 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.5 ! snw 26: * $Log: ssvn_job.c,v $
! 27: * Revision 1.4 2025/03/09 19:50:47 snw
! 28: * Second phase of REUSE compliance and header reformat
! 29: *
1.4 snw 30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
1.1 snw 33: **/
34:
35: #include <stdio.h>
36: #include <string.h>
37: #include <stdlib.h>
38: #include <signal.h>
39: #include <sys/types.h>
40: #include <unistd.h>
41: #include <errno.h>
42: #include <sys/time.h>
43: #include <sys/resource.h>
44: #include <ctype.h>
45: #include <time.h>
46:
47: #include "config.h"
48: #include "mpsdef.h"
49: #include "transact.h"
50: #include "namespace.h"
51: #include "freem.h"
52: #include "mref.h"
53: #include "jobtab.h"
54:
55: short cur_symtab = 0;
56:
57: void ssvn_job_add_device(int channel, char *device)
58: {
59: char *k_buf;
60: char *d_buf;
61:
62: k_buf = (char *) malloc (STRLEN * sizeof (char));
63: NULLPTRCHK(k_buf,"ssvn_job_add_device");
64:
65: d_buf = (char *) malloc (STRLEN * sizeof (char));
66: NULLPTRCHK(k_buf,"ssvn_job_add_device");
67:
68: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202OPEN\202%d\201", pid, channel);
69: snprintf (d_buf, 512 - 1, "%s\201", device);
70:
71: symtab_shm (set_sym, k_buf, d_buf);
72:
73: free (k_buf);
74: free (d_buf);
75:
76: return;
77: }
78:
79: void ssvn_job_remove_device(int channel)
80: {
81: char *k_buf;
82: char *d_buf;
83:
84: k_buf = (char *) malloc (STRLEN * sizeof (char));
85: NULLPTRCHK(k_buf,"ssvn_job_add_device");
86:
87: d_buf = (char *) malloc (STRLEN * sizeof (char));
88: NULLPTRCHK(k_buf,"ssvn_job_add_device");
89:
90: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202OPEN\202%d\201", pid, channel);
91: snprintf (d_buf, 512 - 1, "\201");
92:
93: symtab_shm (kill_sym, k_buf, d_buf);
94:
95: free (k_buf);
96: free (d_buf);
97:
98: return;
99:
100: }
101:
102: void ssvn_job_update(void)
103: {
104:
105: char k_buf[512];
106: char d_buf[512];
107:
108: char tk_buf[512];
109: char td_buf[512];
110:
111: #ifndef AMIGA68K
112: uid_t uid;
113: gid_t gid;
114: #else
115: int uid;
116: int gid;
117: #endif
118:
119: int ierr_sav;
120: int tf;
121:
122: #if !defined(AMIGA68K)
123: uid = getuid ();
124: gid = getgid ();
125: #else
126: uid = 0;
127: gid = 0;
128: #endif
129:
130: ierr_sav = ierr;
131:
132: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202PIPE_GLVN\201", pid);
133: snprintf (d_buf, 5, "%%\201");
134: symtab_shm (set_sym, k_buf, d_buf);
135:
136: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ZCOMMANDS\201", pid);
137: stcpy (d_buf, zcommds);
138: symtab_shm (set_sym, k_buf, d_buf);
139:
140: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ZFUNCTIONS\201", pid);
141: stcpy (d_buf, zfunctions);
142: symtab_shm (set_sym, k_buf, d_buf);
143:
144: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ZSVS\201", pid);
145: stcpy (d_buf, zsvn);
146: symtab_shm (set_sym, k_buf, d_buf);
147:
148: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202BREAK_HANDLER\201", pid);
149: stcpy (d_buf, brkaction);
150: symtab_shm (set_sym, k_buf, d_buf);
151:
152: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ROUTINE_BUFFER_SIZE\201", pid);
153: snprintf (d_buf, 512 - 1, "%ld\201", PSIZE0 - 1);
154: symtab_shm (set_sym, k_buf, d_buf);
155:
156: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ROUTINE_BUFFER_COUNT\201", pid);
1.2 snw 157: snprintf (d_buf, 512 - 1, "%ld\201", NO_OF_RBUF);
1.1 snw 158: symtab_shm (set_sym, k_buf, d_buf);
159:
160: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ROUTINE_BUFFER_AUTO_ADJUST\201", pid);
161: snprintf (d_buf, 512 - 1, "%d\201", autorsize);
162: symtab_shm (set_sym, k_buf, d_buf);
163:
164: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202SYMBOL_TABLE_SIZE\201", pid);
165: snprintf (d_buf, 512 - 1, "%ld\201", PSIZE);
166: symtab_shm (set_sym, k_buf, d_buf);
167:
168: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202SYMBOL_TABLE_AUTO_ADJUST\201", pid);
169: snprintf (d_buf, 512 - 1, "%d\201", autopsize);
170: symtab_shm (set_sym, k_buf, d_buf);
171:
172: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202USER_DEFINED_ISV_TABLE_SIZE\201", pid);
173: snprintf (d_buf, 512 - 1, "%ld\201", UDFSVSIZ);
174: symtab_shm (set_sym, k_buf, d_buf);
175:
176: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202USER_DEFINED_ISV_TABLE_AUTO_ADJUST\201", pid);
177: snprintf (d_buf, 512 - 1, "%d\201", autousize);
178: symtab_shm (set_sym, k_buf, d_buf);
179:
180: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GVN_UNIQUE_CHARS\201", pid);
181: snprintf (d_buf, 512 - 1, "%d\201", (glvnflag.one[0] == 0) ? 255 : glvnflag.one[0]);
182: symtab_shm (set_sym, k_buf, d_buf);
183:
184: tf = UNSIGN (glvnflag.one[1]);
185: toggle (tf);
186:
187: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GVN_CASE_SENSITIVE\201", pid);
188: snprintf (d_buf, 512 - 1, "%d\201", tf);
189: symtab_shm (set_sym, k_buf, d_buf);
190:
191: tf = UNSIGN (glvnflag.one[2]);
192: if (tf == 0) tf = 255;
193: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GVN_NAME_SUB_LENGTH\201", pid);
194: snprintf (d_buf, 512 - 1, "%d\201", tf);
195: symtab_shm (set_sym, k_buf, d_buf);
196:
197: tf = UNSIGN (glvnflag.one[3]);
198: if (tf == 0) tf = 255;
199: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GVN_SUB_LENGTH\201", pid);
200: snprintf (d_buf, 512 - 1, "%d\201", tf);
201: symtab_shm (set_sym, k_buf, d_buf);
202:
203: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202SINGLE_USER\201", pid);
204: snprintf (d_buf, 512 - 1, "%d\201", lonelyflag);
205: symtab_shm (set_sym, k_buf, d_buf);
206:
207: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202LOWERCASE_EVERYWHERE\201", pid);
208: snprintf (d_buf, 512 - 1, "%d\201", lowerflag);
209: symtab_shm (set_sym, k_buf, d_buf);
210:
211: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ZCOMMAND_ARGUMENT_NAME\201", pid);
212: stcpy (d_buf, zargdefname);
213: symtab_shm (set_sym, k_buf, d_buf);
214:
215: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202TIMEZONE_OFFSET\201", pid);
216: lintstr (d_buf, tzoffset);
217: symtab_shm (set_sym, k_buf, d_buf);
218:
219: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ENGINES\202GLOBAL\202%s\201", pid, nsname);
220: snprintf (d_buf, 512 - 1, "%s\201", gbl_u_engine);
221: symtab_shm (set_sym, k_buf, d_buf);
222:
223: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ENGINES\202GLOBAL\202SYSTEM\201", pid);
224: snprintf (d_buf, 512 - 1, "%s\201", gbl_s_engine);
225: symtab_shm (set_sym, k_buf, d_buf);
226:
227: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ENGINES\202LOCAL\201", pid);
228: snprintf (d_buf, 512 - 1, "%s\201", loc_engine);
229: symtab_shm (set_sym, k_buf, d_buf);
230:
231: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202CHARACTER\201", pid);
232: symtab_shm (set_sym, k_buf, "M\201");
233:
234: snprintf (d_buf, 512 - 1, "%s\201", curdir);
235: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202CWD\201", pid);
236: symtab_shm (set_sym, k_buf, d_buf);
237:
238: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GLOBAL\201", pid);
239: symtab_shm (set_sym, k_buf, " \201");
240:
241: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202LOCK\201", pid);
242: symtab_shm (set_sym, k_buf, " \201");
243:
244: snprintf (d_buf, 512 - 1, "%s\201", oucpath);
245: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202IOPATH\201", pid);
246: symtab_shm (set_sym, k_buf, d_buf);
247:
248: #if !defined(MSDOS)
249: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202PRIORITY\201", pid);
250: snprintf (d_buf, 512 - 1, "%d\201", getpriority (PRIO_PROCESS, pid));
251: symtab_shm (set_sym, k_buf, d_buf);
252: #endif
253:
254: snprintf (d_buf, 512 - 1, "%s\201", rou_name);
255: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ROUTINE\201", pid);
256: symtab_shm (set_sym, k_buf, d_buf);
257:
258: snprintf (d_buf, 512 - 1, "0:\"%s\"\201", dev[HOME]);
259: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202$PRINCIPAL\201", pid);
260: symtab_shm (set_sym, k_buf, d_buf);
261:
262: snprintf (d_buf, 512 - 1, "%d\201", tp_level);
263: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202$TLEVEL\201", pid);
264: symtab_shm (set_sym, k_buf, d_buf);
265:
266: snprintf (d_buf, 512 - 1, "0:\"%s\"\201", dev[HOME]);
267: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202$IO\201", pid);
268: symtab_shm (set_sym, k_buf, d_buf);
269:
270: snprintf (d_buf, 512 -1, "%s\201", gvndefault);
271: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GVNDEFAULT\201", pid);
272: symtab_shm (set_sym, k_buf, d_buf);
273:
274: snprintf (d_buf, 512 -1, "%s\201", lvndefault);
275: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202LVNDEFAULT\201", pid);
276: symtab_shm (set_sym, k_buf, d_buf);
277:
278: ssvn_job_add_device (HOME, dev[HOME]);
279:
280: snprintf (d_buf, 512 - 1, "%d\201", uid);
281: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202USER\201", pid);
282: symtab_shm (set_sym, k_buf, d_buf);
283:
284: snprintf (d_buf, 512 - 1, "%d\201", gid);
285: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202GROUP\201", pid);
286: symtab_shm (set_sym, k_buf, d_buf);
287:
288: snprintf (d_buf, 512 - 1, "%s\201", nsname);
289: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202NAMESPACE\201", pid);
290: symtab_shm (set_sym, k_buf, d_buf);
291:
292: snprintf (d_buf, 512 - 1, "%d\201", cur_symtab);
293: snprintf (k_buf, 512 - 1, "^$JOB\202\%d\202SYMTAB\201", pid);
294: symtab_shm (set_sym, k_buf, d_buf);
295:
296: snprintf (d_buf, 512 - 1, "%d\201", pid);
297: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202PID\201", pid);
298: symtab_shm (set_sym, k_buf, d_buf);
299:
300: snprintf (d_buf, 512 - 1, "%d\201", frm_throw_all_errors);
301: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202SET_ALL_ECODES\201", pid);
302: symtab_shm (set_sym, k_buf, d_buf);
303:
304: snprintf (tk_buf, 512 - 1, "^$SYSTEM\202ZDATE_FORMAT\201");
305: ssvn (get_sym, tk_buf, td_buf);
306:
307: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ZDATE_FORMAT\201", pid);
308: symtab_shm (set_sym, k_buf, td_buf);
309:
310: snprintf (tk_buf, 512 - 1, "^$SYSTEM\202ZTIME_FORMAT\201");
311: ssvn (get_sym, tk_buf, td_buf);
312:
313: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ZTIME_FORMAT\201", pid);
314: symtab_shm (set_sym, k_buf, td_buf);
315:
316: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202ENVIRONMENT\201", pid);
317: snprintf (d_buf, 512 - 1, "%s\201", shm_env);
318: symtab_shm (set_sym, k_buf, d_buf);
319:
320: switch (fp_mode) {
321:
322: case 0:
323:
324: snprintf (d_buf, 512 - 1, "FIXED\201");
325: break;
326:
327: default:
328:
329: snprintf (d_buf, 512 - 1, "IEEE754\201");
330: snprintf (fp_conversion, 9, "%%.%df\201", DBL_DIG);
331: zprecise = DBL_DIG;
332:
333: break;
334:
335: }
336:
337: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202MATH\201", pid);
338: symtab_shm (set_sym, k_buf, d_buf);
339:
340: snprintf (d_buf, 512 - 1, "%d\201", en_revstrf);
341: snprintf (k_buf, 512 - 1, "^$JOB\202%d\202REVSTR\201", pid);
342: symtab_shm (set_sym, k_buf, d_buf);
343:
344: stcpy (d_buf, rou_name);
345: stcnv_m2c (d_buf);
346:
347: #if !defined(__FreeBSD__)
348:
349: if (run_daemon == FALSE) {
350: sprintf (k_buf, " freem: namespace %s routine %s", nsname, d_buf);
351: }
352: else {
353: sprintf (k_buf, " freem: %s environment daemon", shm_env);
354: }
355: if (!libflag) {
356: strcpy (m_argv[0], k_buf);
357: }
358:
359: #endif
360:
361: merr_raise (ierr_sav);
362:
363: }
364:
365:
366: void ssvn_job(short action, char *key, char *data)
367: {
368: int errsav;
369: pid_t t_pid;
370: int i;
371: char ch;
372: job_slot_t *slot;
373: freem_ref_t *r;
374: char *kbuf;
375: char *tbuf;
376:
377: r = (freem_ref_t *) malloc (sizeof (freem_ref_t));
378: NULLPTRCHK(r,"ssvn_job");
379:
380: kbuf = (char *) malloc (STRLEN * sizeof(char));
381: NULLPTRCHK(kbuf,"ssvn_job");
382:
383: tbuf = (char *) malloc (STRLEN * sizeof(char));
384: NULLPTRCHK(tbuf,"ssvn_job");
385:
386: stcpy (kbuf, key);
387:
388: mref_init (r, MREF_RT_SSVN, "^$JOB");
389: internal_to_mref (r, kbuf);
390:
391: t_pid = atol (mref_get_subscript (r, 0));
392:
393: slot = job_get (t_pid);
394:
395: if (r->subscript_count > 1) {
396: for (i = 0; i < strlen (r->subscripts[1]); i++) {
397: r->subscripts[1][i] = toupper (r->subscripts[1][i]);
398: }
399: }
400:
401: key = mref_to_internal (r);
402: stcpy (kbuf, key);
403:
404: switch (action) {
405:
406: case set_sym:
407:
408: {
409: char cbuf[STRLEN];
410:
411: snprintf (cbuf, STRLEN - 1, "^$JOB\202%d\202NAMESPACE\201", pid);
412:
413: if (stcmp (kbuf, cbuf) == 0) {
414:
415: stcpy (tbuf, data);
416: stcnv_m2c (tbuf);
417:
418: if (validate_namespace (tbuf) == FALSE) {
419: merr_raise (M26);
420: }
421: else {
422: set_namespace (tbuf, FALSE);
423: }
424:
425: goto done;
426:
427: }
428:
429:
430: if (strcmp (mref_get_subscript (r, 1), "ZCOMMANDS") == 0) {
431:
432: m_tolower (data);
433:
434: stcpy (zcommds, data);
435: symtab_shm (action, key, data);
436:
437: merr_clear ();
438: goto done;
439:
440: }
441: else if (strcmp (mref_get_subscript (r, 1), "LVNQOVAL") == 0) {
442: stcpy (l_o_val, data);
443:
444: merr_clear ();
445: goto done;
446: }
447: else if (strcmp (mref_get_subscript (r, 1), "GVNQOVAL") == 0) {
448: stcpy (l_o_val, data);
449:
450: merr_clear ();
451: goto done;
452: }
453: else if (strcmp (mref_get_subscript (r, 1), "GVNDEFAULT") == 0) {
454:
455: stcpy (gvndefault, data);
456:
457: merr_clear ();
458: goto done;
459: }
460: else if (strcmp (mref_get_subscript (r, 1), "LVNDEFAULT") == 0) {
461:
462: stcpy (lvndefault, data);
463:
464: merr_clear ();
465: goto done;
466: }
467: else if (strcmp (mref_get_subscript (r, 1), "PIPE_GLVN") == 0) {
468:
469: symtab_shm (action, key, data);
470:
471: merr_clear ();
472: goto done;
473:
474: }
475: else if (strcmp (mref_get_subscript (r, 1), "ZFUNCTIONS") == 0) {
476:
477: m_tolower (data);
478:
479: stcpy (zfunctions, data);
480: symtab_shm (action, key, data);
481:
482: merr_clear ();
483: goto done;
484:
485: }
486: else if (strcmp (mref_get_subscript (r, 1), "ZSVS") == 0) {
487:
488: m_tolower (data);
489:
490: stcpy (zsvn, data);
491: symtab_shm (action, key, data);
492:
493: merr_clear ();
494: goto done;
495:
496: }
497: else if (strcmp (mref_get_subscript (r, 1), "LOWERCASE_EVERYWHERE") == 0) {
498:
499: int tf = tvexpr (data);
500:
501: lowerflag = tf;
502: snprintf (data, 512 - 1, "%d\n", tf);
503:
504: symtab_shm (action, key, data);
505:
506: merr_clear ();
507: goto done;
508:
509: }
510: else if (strcmp (mref_get_subscript (r, 1), "ZCOMMAND_ARGUMENT_NAME") == 0) {
511:
512: stcpy (zargdefname, data);
513: symtab_shm (action, key, data);
514:
515: merr_clear ();
516: goto done;
517:
518: }
519: else if (strcmp (mref_get_subscript (r, 1), "BREAK_HANDLER") == 0) {
520:
521: stcpy (brkaction, data);
522: symtab_shm (action, key, data);
523:
524: merr_clear ();
525: goto done;
526:
527: }
528: else if (strcmp (mref_get_subscript (r, 1), "ROUTINE_BUFFER_SIZE") == 0) {
529:
530: if (intexpr (data) <= 0) {
531: merr_raise (ARGER);
532: goto done;
533: }
534:
535: newrsize (intexpr (data) + 1, NO_OF_RBUF);
536: symtab_shm (action, key, data);
537:
538: merr_clear ();
539: goto done;
540:
541: }
542: else if (strcmp (mref_get_subscript (r, 1), "ROUTINE_BUFFER_COUNT") == 0) {
543:
544: if (intexpr (data) <= 0) {
545: merr_raise (ARGER);
546: goto done;
547: }
548:
549: newrsize (PSIZE0, intexpr (data));
550: symtab_shm (action, key, data);
551:
552: merr_clear ();
553: goto done;
554:
555: }
556: else if (strcmp (mref_get_subscript (r, 1), "ROUTINE_BUFFER_AUTO_ADJUST") == 0) {
557:
558: autorsize = tvexpr (data);
559: snprintf (data, 512 - 1, "%d\201", tvexpr (data));
560:
561: symtab_shm (action, key, data);
562:
563: merr_clear ();
564: goto done;
565:
566: }
567: else if (strcmp (mref_get_subscript (r, 1), "SYMBOL_TABLE_SIZE") == 0) {
568:
569: if (intexpr (data) <= 0) {
570: merr_raise (ARGER);
571: goto done;
572: }
573:
574: newpsize (intexpr (data));
575:
576: symtab_shm (action, key, data);
577:
578: merr_clear ();
579: goto done;
580:
581: }
582: else if (strcmp (mref_get_subscript (r, 1), "SYMBOL_TABLE_AUTO_ADJUST") == 0) {
583:
584: autopsize = tvexpr (data);
585: snprintf (data, 512 - 1, "%d\201", tvexpr (data));
586:
587: symtab_shm (action, key, data);
588:
589: merr_clear ();
590: goto done;
591:
592: }
593: else if (strcmp (mref_get_subscript (r, 1), "USER_DEFINED_ISV_TABLE_SIZE") == 0) {
594:
595: if (intexpr (data) <= 0) {
596: merr_raise (ARGER);
597: goto done;
598: }
599:
600: newusize (intexpr (data));
601:
602: symtab_shm (action, key, data);
603:
604: merr_clear ();
605: goto done;
606:
607: }
608: else if (strcmp (mref_get_subscript (r, 1), "USER_DEFINED_ISV_TABLE_AUTO_ADJUST") == 0) {
609: autousize = tvexpr (data);
610: snprintf (data, 512 - 1, "%d\201", tvexpr (data));
611:
612: symtab_shm (action, key, data);
613:
614: merr_clear ();
615: goto done;
616: }
617: else if (strcmp (mref_get_subscript (r, 1), "GVN_UNIQUE_CHARS") == 0) {
618:
619: int t = intexpr (data) & 0377;
620:
621: if (t == 255) t = 0;
622:
623: if (merr () != MXNUM) {
624:
625: glvnflag.one[0] = (char) t;
626:
627: snprintf (data, 512 - 1, "%d\201", t);
628: symtab_shm (action, key, data);
629:
630: merr_clear ();
631:
632: }
633: else {
634: merr_raise (ARGER);
635: }
636:
637: goto done;
638:
639: }
640: else if (strcmp (mref_get_subscript (r, 1), "GVN_CASE_SENSITIVE") == 0) {
641: int t = tvexpr (data);
642: toggle (t);
643:
644: if (merr () != MXNUM) {
645:
646: glvnflag.one[1] = t;
647:
648: snprintf (data, 512 - 1, "%d\201", t);
649: symtab_shm (action, key, data);
650:
651: merr_clear ();
652:
653: }
654: else {
655: merr_raise (ARGER);
656: }
657:
658: goto done;
659:
660: }
661: else if (strcmp (mref_get_subscript (r, 1), "GVN_NAME_SUB_LENGTH") == 0) {
662: int t = intexpr (data) & 0377;
663:
664: if (t == 255) t = 0;
665:
666: if (merr () != MXNUM) {
667: glvnflag.one[2] = (char) t;
668:
669: snprintf (data, 512 - 1, "%d\201", t);
670: symtab_shm (action, key, data);
671:
672: merr_clear ();
673: }
674: else {
675: merr_raise (ARGER);
676: }
677:
678: goto done;
679:
680: }
681: else if (strcmp (mref_get_subscript (r, 1), "GVN_SUB_LENGTH") == 0) {
682: int t = intexpr (data) & 0377;
683:
684: if (t == 255) t = 0;
685:
686: if (merr () != MXNUM) {
687: glvnflag.one[3] = (char) t;
688:
689: snprintf (data, 512 - 1, "%d\201", t);
690: symtab_shm (action, key, data);
691:
692: merr_clear ();
693: }
694: else {
695: merr_raise (ARGER);
696: }
697:
698: goto done;
699:
700: }
701: else if (strcmp (mref_get_subscript (r, 1), "SINGLE_USER") == 0) {
702: int tf = tvexpr (data);
703: close_all_globals ();
704:
705: snprintf (data, 512 - 1, "%d\201", tf);
706: symtab_shm (action, key, data);
707:
708: merr_clear ();
709: goto done;
710: }
711: else if (stcmp (mref_get_subscript (r, 1), "TIMEZONE_OFFSET") == 0) {
712: long tzo = intexpr (data);
713: long tzj;
714:
715: if (merr () > OK) goto done;
716:
717: tzj = time (0L);
718:
719: if ((tzoffset > 0 && ((tzj + 86400 + tzoffset) < 0 || (tzj + tzoffset) < 0)) ||
720: (tzoffset < 0 && ((tzj + 86400 + tzoffset ) > (tzj + 86400) ||
721: (tzj + tzoffset) > tzj))) {
722: merr_raise (ARGER);
723: goto done;
724: }
725:
726: tzoffset = tzo;
727:
1.2 snw 728: snprintf (data, 512 - 1, "%ld\201", tzoffset);
1.1 snw 729: symtab_shm (action, key, data);
730:
731: goto done;
732: }
733: else if (strcmp (mref_get_subscript (r, 1), "ENGINES") == 0) {
734:
735: if (strcmp (mref_get_subscript (r, 2), "GLOBAL") == 0) {
736:
737: if ((strcmp (mref_get_subscript (r, 3), nsname) == 0) && (strcmp (mref_get_subscript (r, 3), "SYSTEM") != 0)) {
738: stcpy (tbuf, data);
739: stcnv_m2c (tbuf);
740:
741: global_set_engine ('u', tbuf);
742:
743: goto done;
744:
745: }
746: else if (strcmp (mref_get_subscript (r, 3), "SYSTEM") == 0) {
747:
748: stcpy (tbuf, data);
749: stcnv_m2c (tbuf);
750:
751: global_set_engine ('s', tbuf);
752:
753: goto done;
754:
755: }
756:
757: }
758:
759: merr_raise (M29);
760: goto done;
761:
762: }
763: else if (strcmp (mref_get_subscript (r, 1), "USER_ERRORS") == 0) {
764:
765: symtab_shm (set_sym, key, data);
766:
767: merr_clear ();
768: goto done;
769:
770: }
771: else if (strcmp (mref_get_subscript (r, 1), "SET_ALL_ECODES") == 0) {
772:
773: frm_throw_all_errors = atol (data);
774: symtab_shm (set_sym, key, data);
775:
776: merr_clear ();
777: goto done;
778:
779: }
780: else if (strcmp (mref_get_subscript (r, 1), "ALIASES") == 0) {
781: symtab_shm (set_sym, key, data);
782:
783: merr_clear ();
784: goto done;
785: }
786: else if (strcmp (mref_get_subscript (r, 1), "CWD") == 0) {
787:
788: stcpy (tbuf, data);
789: stcnv_m2c (tbuf);
790:
791: if (chdir (tbuf) != 0) {
792: merr_raise (PROTECT);
793: goto done;
794: }
795: else {
796: strcpy (curdir, tbuf);
797: symtab_shm (set_sym, kbuf, data);
798:
799: merr_clear ();
800: goto done;
801: }
802:
803: }
804: else if (strcmp (mref_get_subscript (r, 1), "EVENT") == 0) {
805: symtab_shm (set_sym, kbuf, data);
806:
807: merr_clear ();
808: goto done;
809: }
810: else if (strcmp (mref_get_subscript (r, 1), "PRIORITY") == 0) {
811:
812: int new_pri;
813:
814: stcpy (tbuf, data);
815: stcnv_m2c (tbuf);
816:
817: new_pri = atoi (tbuf);
818:
819:
820: i = nice (40);
821: nice ((int) (new_pri - 40));
822:
823: symtab_shm (set_sym, kbuf, data);
824:
825: merr_clear ();
826: goto done;
827:
828: }
829: else if (strcmp (mref_get_subscript (r, 1), "IOPATH") == 0) {
830:
831: stcpy (oucpath, data);
832: symtab_shm (set_sym, kbuf, data);
833:
834: merr_clear ();
835: goto done;
836:
837: }
838: else if (strcmp (mref_get_subscript (r, 1), "REVSTR") == 0) {
839:
840: short tres = tvexpr (data);
841:
842: if (tres == TRUE) {
843: en_revstrf = 1;
844: }
845: else {
846: en_revstrf = 0;
847: }
848:
849: symtab_shm (set_sym, kbuf, data);
850:
851: merr_clear ();
852: goto done;
853:
854: }
855: else if (strcmp (mref_get_subscript (r, 1), "ZDATE_FORMAT") == 0) {
856: symtab_shm (set_sym, key, data);
857: merr_clear ();
858: goto done;
859:
860: }
861: else if (strcmp (mref_get_subscript (r, 1), "ZTIME_FORMAT") == 0) {
862: symtab_shm (set_sym, key, data);
863: merr_clear ();
864: goto done;
865:
866: }
867: else if (strcmp (mref_get_subscript (r, 1), "SYMTAB") == 0) {
868:
869: int itmp = atoi (data);
870:
871: if ((data[0] < '0') || (data[0] > '9')) {
872: merr_raise (INVEXPR);
873: goto done;
874: }
875:
876: if (itmp != 0 && itmp != 1) {
877: merr_raise (INVEXPR);
878: goto done;
879: }
880:
881: if (cur_symtab == itmp) {
882: merr_clear ();
883: goto done;
884: }
885:
886: if (cur_symtab == 0) {
887: cur_symtab = 1;
888: }
889: else {
890: cur_symtab = 0;
891: }
892:
893: if (apartition == NULL) {
894:
895: apartition = calloc ((unsigned) PSIZE + 1, 1);
896: asymlen = PSIZE;
897:
898: for (i = 0; i < 128; i++) aalphptr[i] = 0L;
899:
900: }
901:
902: {
903:
904: char *x;
905:
906: x = apartition;
907: apartition = partition;
908: partition = x;
909:
910: }
911:
912: ch = asymlen;
913: asymlen = symlen;
914: symlen = ch;
915:
916: for (i = 0; i < 128; i++) {
917: ch = aalphptr[i];
918: aalphptr[i] = alphptr[i];
919: alphptr[i] = ch;
920: }
921:
922: s = &partition[symlen] - 256; /* pointer to symlen_offset */
923: argptr = partition; /* pointer to beg of tmp-storage */
924:
925: symtab_shm (set_sym, key, data);
926:
927: merr_clear ();
928: goto done;
929:
930:
931: }
932: else if (strcmp (mref_get_subscript (r, 1), "MATH") == 0) {
933:
934: #if !defined(_AIX)
935: if (stcmp (data, "IEEE754\201") == 0) {
936:
937: fp_mode = 1;
938: symtab_shm (set_sym, kbuf, data);
939:
940: snprintf (fp_conversion, 9, "%%.%df\201", DBL_DIG);
941: zprecise = DBL_DIG;
942:
943: merr_clear ();
944: goto done;
945:
946: }
947: else if (stcmp (data, "FIXED\201") == 0) {
948:
949: fp_mode = 0;
950: symtab_shm (set_sym, kbuf, data);
951:
952: zprecise = 100;
953:
954: merr_clear ();
955: goto done;
956:
957: }
958: else {
959: merr_raise (M29);
960: goto done;
961: }
962: #endif
963:
964: }
965:
966: merr_raise (M29);
967: goto done;
968: }
969:
970: case get_sym:
971: if (strcmp (mref_get_subscript (r, 1), "LVNQOVAL") == 0) {
972: stcpy (data, l_o_val);
973: goto done;
974: }
975: else if (strcmp (mref_get_subscript (r, 1), "GVNQOVAL") == 0) {
976: stcpy (data, g_o_val);
977: goto done;
978: }
1.5 ! snw 979: case fra_dat:
1.1 snw 980: case fra_order:
981: case fra_query:
982: if (strcmp (mref_get_subscript (r, 1), "LVNQOVAL") == 0) {
983: merr_raise (M38);
984: goto done;
985: }
986: if (strcmp (mref_get_subscript (r, 1), "GVNQOVAL") == 0) {
987: merr_raise (M38);
988: goto done;
989: }
990: case bigquery:
991: case getnext:
992: case m_alias:
993: case zdata:
994:
995: if (action == get_sym) {
996:
997: if (strcmp (mref_get_subscript (r, 1), "PROCESS_START") == 0) {
998:
999: unsigned long ilong;
1000: unsigned long ilong1;
1001:
1002: ilong1 = slot->start_time + tzoffset;
1003: ilong = ilong1 / 86400;
1004:
1005: lintstr (data, ilong + 47117);
1006: i = stlen (data);
1007:
1008: data[i++] = ',';
1009: ilong = ilong1 - (ilong * 86400);
1010:
1011: lintstr (&data[i], ilong);
1012:
1013: merr_clear ();
1014: goto done;
1015:
1016: }
1017:
1018: }
1019:
1020: symtab_shm (action, kbuf, data);
1021:
1022: /* here, we need to convert the data on the way out too */
1023: if ((action == fra_query) && (stlen (data) > 0)) {
1024: if (strncmp (data, "^$JOB", 5) != 0) {
1025: snprintf (kbuf, STRLEN - 1, "^$JOB%s\201", data);
1026: stcpy (data, kbuf);
1027: }
1028: }
1029:
1030: merr_clear ();
1031: goto done;
1032:
1033: case killone:
1034: case kill_sym:
1035:
1036: if (strcmp (mref_get_subscript (r, 1), "ALIASES") == 0) {
1037:
1038: symtab_shm (action, key, data);
1039:
1040: goto done;
1041:
1042: }
1043: else if (strcmp (mref_get_subscript (r, 1), "LVNQOVAL") == 0) {
1044: l_o_val[0] = '\201';
1045: merr_clear ();
1046: goto done;
1047: }
1048: else if (strcmp (mref_get_subscript (r, 1), "GVNQOVAL") == 0) {
1049: g_o_val[0] = '\201';
1050: merr_clear ();
1051: goto done;
1052: }
1053: else if (strcmp (mref_get_subscript (r, 1), "GVNDEFAULT") == 0) {
1054: gvndefault[0] = '\201';
1055: symtab_shm (action, key, data);
1056: symtab_shm (set_sym, key, gvndefault);
1057: merr_clear ();
1058: goto done;
1059: }
1060: else if (strcmp (mref_get_subscript (r, 1), "LVNDEFAULT") == 0) {
1061: lvndefault[0] = '\201';
1062: symtab_shm (action, key, data);
1063: symtab_shm (set_sym, key, lvndefault);
1064: merr_clear ();
1065: goto done;
1066: }
1067: else {
1068: job_request_stop (t_pid);
1069: }
1070:
1071: goto done;
1072:
1073:
1074: default:
1075: merr_raise (INVREF);
1076: goto done;
1077:
1078: }
1079:
1080:
1081: done:
1082:
1083: free (r);
1084: free (kbuf);
1085: free (tbuf);
1086: free (key);
1087: return;
1088: }
1089:
1090: void frm_process_alias (char *key)
1091: {
1092: int ierr_sav;
1093: char *ptr;
1094: char name[256];
1095: char *subprt;
1096: register int i;
1097: register char ch;
1098:
1099: char *k_buf;
1100: char *d_buf;
1101: char *t_buf;
1102:
1103: k_buf = (char *) malloc (STRLEN * sizeof (char));
1104: NULLPTRCHK(k_buf,"frm_process_alias");
1105:
1106: d_buf = (char *) malloc (STRLEN * sizeof (char));
1107: NULLPTRCHK(d_buf,"frm_process_alias");
1108:
1109: t_buf = (char *) malloc (STRLEN * sizeof (char));
1110: NULLPTRCHK(t_buf,"frm_process_alias");
1111:
1112: ierr_sav = ierr;
1113: ptr = key;
1114: i = 0;
1115:
1116: while ((ch = *(ptr++)) != DELIM && ch != EOL && i < 256) {
1117: name[i++] = ch;
1118: }
1119:
1120: name[i] = '\0';
1121: subprt = key + i;
1122:
1.2 snw 1123: snprintf (k_buf, STRLEN - 1, "^$JOB\202%ld\202ALIASES\202%s\201", (long) pid, name);
1.1 snw 1124: symtab_shm (get_sym, k_buf, d_buf);
1125:
1126: stcnv_m2c (d_buf);
1127:
1128: if (merr () == OK) {
1129: snprintf (t_buf, STRLEN - 1, "%s%s\201", d_buf, subprt);
1130: stcpy (key, t_buf);
1131: }
1132:
1133: free (k_buf);
1134: free (d_buf);
1135: free (t_buf);
1136:
1137: merr_raise (ierr_sav);
1138:
1139: return;
1140:
1141: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>