Debian Codegraph @

libsrc/st/osyvmsa.c

raw
1 /* @(#)osyvmsa.c 19.1 (ESO-DMD) 02/25/03 13:57:20 */
2 /*===========================================================================
3 Copyright (C) 1995 European Southern Observatory (ESO)
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free
17 Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
18 MA 02139, USA.
19
20 Correspondence concerning ESO-MIDAS should be addressed as follows:
21 Internet e-mail: [email protected]
22 Postal address: European Southern Observatory
23 Data Management Division
24 Karl-Schwarzschild-Strasse 2
25 D 85748 Garching bei Muenchen
26 GERMANY
27
28 02021129 last update
29
30 ===========================================================================*/
31
32
33 #include <midas_def.h>
34 #include <secdef.h>
35 #include <ssdef.h>
36 #include <descrip.h>
37 #include <iodef.h>
38
39 #include <string.h>
40
41 #include <fctext.h>
42
43
44 #define BIT_0 0x1
45
46 static int status;
47
48 struct FCT_STRUCT *fctpntr;
49
50
51 /*
52
53 */
54
55 int OSY_ASCTIM(time)
56 /* ++++++++++++++++++++++++++++++++++++++++++++++++++
57
58 .IDENTIFICATION
59 function OSY_ASCTIM version 1.10 880112
60 K. Banse ESO - Garching
61
62 .KEYWORDS
63 time
64
65 .PURPOSE
66 get current time as ASCII string
67
68 .ALGORITHM
69 use system services SYS$ASCTIM
70
71 .INPUT/OUTPUT
72 use as status = OSY_ASCTIM(TIME)
73
74 output par:
75 TIME: char. string will hold the returned time in ASCII
76 terminated by \0
77
78 -------------------------------------------------- */
79
80 char *time;
81
82 {
83
84 struct dsc$descriptor_s name_descr;
85
86 char mytime[24];
87 int ii,status;
88
89 mytime[23] = '\0'; /* make sure, we have an end */
90
91
92 /* set up the VAX-11 descriptor structure */
93
94 name_descr.dsc$w_length = 23;
95 name_descr.dsc$a_pointer = mytime;
96 name_descr.dsc$b_class = DSC$K_CLASS_S;
97 name_descr.dsc$b_dtype = DSC$K_DTYPE_T;
98
99
100 /* now execute the system service */
101
102 status = SYS$ASCTIM(&ii,&name_descr,0,0);
103 strcpy(time,mytime); /* copy the char. string */
104
105 return status;
106 }
107
108 /*
109
110 */
111
112 int OSY_ASSIGN(devnam,ldev,chanl)
113 /* ++++++++++++++++++++++++++++++++++++++++++++++++++
114
115 .IDENTIFICATION
116 function OSY_ASSIGN C-version 1.00 860620
117 function OSY_DASSGN C-version 1.00 890510
118 K. Banse ESO - Garching
119 on source file OSYASSIGN.C
120
121 .KEYWORDS
122 exit
123
124 .PURPOSE
125 a) assign an I/O channel
126 b) deassign an I/O channel
127
128 .ALGORITHM
129 use system service SYS$ASSIGN, SYS$DASSGN
130 !!! this code is operating system dependant !!!
131
132 .INPUT/OUTPUT
133 use as a) status = OSY_ASSIGN(DEVNAM,LDEV,CHANL)
134 b) status = OSY_DASSGN(FCT_entry,iochan)
135
136 a)
137 input par:
138 DEVNAM: char.exp. device name
139 LDEV: I*4 length of DEVNAM
140
141 output par:
142 CHANL: I*4 I/O channel number
143
144 return value:
145 status: I*4 MIDAS error code
146
147 b)
148 input par:
149 FCT_ENTRY: I*4 entry no. of file in FCT, -1 if not applicable
150 iochan: I*4 channel no.
151
152 return value:
153 status: I*4 MIDAS error code
154
155 -------------------------------------------------- */
156
157 char *devnam;
158 int ldev, *chanl;
159
160 {
161
162 struct dsc$descriptor_s name_descr;
163
164
165 /* set up the VAX-11 descriptor structure */
166
167 name_descr.dsc$w_length = ldev;
168 name_descr.dsc$a_pointer = devnam;
169 name_descr.dsc$b_class = DSC$K_CLASS_S;
170 name_descr.dsc$b_dtype = DSC$K_DTYPE_T;
171
172
173 /* now execute the system service */
174
175 status = SYS$ASSIGN(&name_descr,chanl,0,0);
176
177 if (status & BIT_0)
178 status = ERR_NORMAL;
179 else
180 {
181 MID_ERROR("OSY","OSY_ASSIGN",status,0);
182 status = ERR_OPSSYS;
183 }
184
185 return status;
186
187 }
188
189 /*
190
191 */
192
193 int OSY_CANCEL(iochan)
194
195 int iochan;
196
197 {
198
199
200 status = SYS$CANCEL(iochan);
201
202 /* check return status from system service calls */
203
204 if (status & BIT_0)
205 status = ERR_NORMAL;
206 else
207 {
208 MID_ERROR("OSY","OSY_CANCEL",status,0);
209 status = ERR_INPINV;
210 }
211
212 return status;
213
214 }
215
216 /*
217
218 */
219
220 int OSY_CREMBX(mailbox,chan)
221
222 char *mailbox;
223 int *chan;
224
225 {
226
227 struct dsc$descriptor_s name_descr;
228
229
230 /* set up the VAX-11 descriptor structure */
231
232 name_descr.dsc$w_length = strlen(mailbox);
233 name_descr.dsc$a_pointer = mailbox;
234 name_descr.dsc$b_class = DSC$K_CLASS_S;
235 name_descr.dsc$b_dtype = DSC$K_DTYPE_T;
236
237 status = SYS$CREMBX(0,chan,0,0,0,255,&name_descr);
238
239 /* check return status from system service calls */
240
241 if (status & BIT_0)
242 status = ERR_NORMAL;
243 else
244 {
245 MID_ERROR("OSY","OSY_CREMBX",status,1);
246 status = ERR_INPINV;
247 }
248
249 return status;
250
251 }
252
253 /*
254
255 */
256
257 int OSY_DASSGN(entrx,chanl)
258
259 int entrx, chanl;
260
261 {
262
263
264 /* if entrx is a FCT entry, pull out channel from there */
265
266 if (entrx >= 0)
267 {
268 fctpntr = FCT.ENTRIES + entrx;
269 chanl = fctpntr->IOCHAN;
270
271 if (chanl < 0) /* it's a memory file */
272 {
273 int idx;
274
275 idx = -1 - chanl; /* recalculate VMEM index */
276 (void) MID_VMEM(3,idx,&status);
277 return (ERR_NORMAL);
278 }
279
280 }
281 status = SYS$DASSGN(chanl);
282
283 if (status & BIT_0)
284 status = ERR_NORMAL;
285 else
286 {
287 MID_ERROR("OSY","OSY_DASSGN",status,0);
288 status = ERR_OPSSYS;
289 }
290
291 return status;
292
293 }
294
295 /*
296
297 */
298
299 int OSY_DCLEXH(fct)
300
301 int (* fct)();
302
303 {
304
305 static int ixh[4], iadr;
306
307 /* fill exit control block */
308
309
310 ixh[1] = (int) fct;
311 ixh[2] = 1;
312 ixh[3] = (int) &iadr;
313
314 status = SYS$DCLEXH(ixh);
315
316 if (status & BIT_0)
317 status = ERR_NORMAL;
318 else
319 {
320 MID_ERROR("OSY","OSY_DCLEXH",status,0);
321 status = ERR_INPINV;
322 }
323
324 return status;
325 }
326
327 /*
328
329 */
330
331 int OSY_DELPRC(pid)
332
333 int *pid;
334
335 {
336
337
338 /* delete process */
339
340 status = SYS$DELPRC(pid,0);
341
342 if (status & BIT_0)
343 status = ERR_NORMAL;
344 else
345 {
346 MID_ERROR("OSY","OSY_DELPRC",status,0);
347 status = ERR_INPINV;
348 }
349
350 return status;
351 }
352
353 /*
354
355 */
356
357 int OSY_ENAST(iochan,function,astmodule,astparm)
358
359 int iochan, (* astmodule)(), astparm;
360 char *function;
361
362 {
363
364 short int iosb[4];
365 int aux;
366
367 /* use QIOW calls to do the job */
368
369 if (strcmp(function,"READATT") == 0)
370 aux = IO$_SETMODE | IO$M_READATTN;
371 else if (strcmp(function,"CNTRLC") == 0)
372 aux = IO$_SETMODE | IO$M_CTRLCAST;
373 else
374 return ERR_INPINV;
375
376 status = SYS$QIOW(0,iochan,aux,iosb,0,0,astmodule,astparm,0,0,0,0);
377
378 if (status & BIT_0)
379 status = ERR_NORMAL;
380 else
381 {
382 MID_ERROR("OSY","OSY_ENAST",status,0);
383 status = ERR_INPINV;
384 }
385
386 return status;
387 }
388
389 /*
390
391 */
392
393 int OSY_FORCEX(process)
394
395 char *process;
396
397 {
398
399 struct dsc$descriptor_s name_descr;
400
401
402 name_descr.dsc$w_length = strlen(process);
403 name_descr.dsc$a_pointer = process;
404 name_descr.dsc$b_class = DSC$K_CLASS_S;
405 name_descr.dsc$b_dtype = DSC$K_DTYPE_T;
406
407 status = SYS$FORCEX(0,&name_descr,1);
408
409 /* check return status from system service calls */
410
411 if (status & BIT_0)
412 status = ERR_NORMAL;
413 else
414 {
415 MID_ERROR("OSY","OSY_FORCEX",status,0);
416 status = ERR_INPINV;
417 }
418
419 return status;
420
421 }
422
423 /*
424
425 */
426
427 void OSY_GETSYMB(symbol,name,lname)
428 /* ++++++++++++++++++++++++++++++++++++++++++++++++++
429
430 .IDENTIFICATION
431 OSY_GETSYMB C-version 1.10 870709
432 K. Banse ESO - Garching
433
434 .KEYWORDS
435 symbols
436
437 .PURPOSE
438 get symbols from hosa system
439
440 .ALGORITHM
441 is done via LIB$GET_SYMBOL
442
443 .INPUT/OUTPUT
444 use as OSY_GETSYMB(symbol,name,lname)
445
446 input par:
447 symbol: char. string symbol name (terminated)
448 lname: I*4 length of 'name'
449
450 output par:
451 name: char. string returned name
452
453 ------------------------------------------------------- */
454
455 int lname;
456 char *name, *symbol;
457
458 {
459 struct dsc$descriptor_s name_descr1, name_descr2;
460
461 int mm;
462
463
464
465 /* set up the VAX-11 descriptor structure */
466
467 name_descr1.dsc$w_length = strlen(symbol);
468 name_descr1.dsc$a_pointer = symbol;
469 name_descr1.dsc$b_class = DSC$K_CLASS_S;
470 name_descr1.dsc$b_dtype = DSC$K_DTYPE_T;
471
472
473 /* clear result name */
474
475 memset((void*)name,32,(size_t)lname);
476
477 name_descr2.dsc$w_length = lname;
478 name_descr2.dsc$a_pointer = name;
479 name_descr2.dsc$b_class = DSC$K_CLASS_S;
480 name_descr2.dsc$b_dtype = DSC$K_DTYPE_T;
481
482
483 /* now execute the system service */
484
485 status = LIB$GET_SYMBOL(&name_descr1,&name_descr2,&mm,&mm);
486
487 *(name+lname-1) = '\0';
488 }
489
490 /*
491
492 */
493
494 int OSY_TRANSLA(name,sysname,lsysout)
495 /*++++++++++++++++++++++++++ Function OSY_TRNLOG +++++++++++++++++++++++++
496 .PURPOSE Do logical name translation.
497 .REMARKS uses the os interface service osftranslate.
498 .RETURNS
499 length of translated name (if > lsysout, sysname not filled)
500 < 1 if no translation
501 -------------------------------------------------------------------------*/
502 char *name; /* IN: logical file name */
503 char *sysname; /* OUT: physical (system dependant) file name */
504 int lsysout; /* OUT: max. length of sysname */
505
506 {
507 int ret;
508
509 char tmp[256];
510
511
512
513
514 /* translate first into temp_buf + get length */
515
516 ret = osftranslate(name,tmp);
517 if ((ret > 0) && (ret < lsysout))
518 { /* fits into result */
519 (void) memcpy(sysname,tmp,(size_t)(ret+1));
520 }
521
522 return (ret);
523 }
524
525 /*
526
527 */
528
529 int OSY_HIBER()
530
531 {
532 status = SYS$HIBER();
533
534 if (status & BIT_0)
535 return ERR_NORMAL;
536 else
537 return ERR_OPSSYS;
538 }
539