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