1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*+++++++++++++++++++++++++++ SC interface module SCDX +++++++++++++++++++++++
30
.IDENTIFICATION Module SCDB
31
.AUTHOR K. Banse ESO - Garching
32
.KEYWORDS standard interfaces, descriptors
33
.ENVIRONMENT VMS and UNIX
34
.COMMENTS holds xwdscdir, xSCDWRi, xSCDHWi
35
.NOTE the xSCDHWi routines work only for the Yformat...
37
.VERSION [1.00] 920211: pulled out from scd.c
38
090327 last modification
40
----------------------------------------------------------------------------*/
47
static char dtype[4], help[72];
48
static char realdescr[52];
50
static int dblock, dindx, dunit, helpflag=0;
52
static struct FCT_STRUCT *fctpntr;
58
int xwdscdir(imno,descr,bytelem,nval)
60
/*++++++++++++++++++++++++++++++++++++++++++++++++++
62
hdnale lower level descr directory stuff common to all descr tytpes
65
return status ( 0 = o.k. )
66
--------------------------------------------------*/
68
int imno /* IN : no. of data frame */;
69
char *descr /* IN : descriptor name */;
70
int bytelem /* IN : CHAR*noelm */;
71
int nval /* IN : no. of data values to write */;
79
dunit = 0; /* not used yet */
81
fctpntr = FCT.ENTRIES + imno;
82
dsclen = DSCNAM_COPY(realdescr,descr); /* build uppercase name */
84
status = MID_YDSCDIR(imno,'a',realdescr,dtype,&bytelem,
85
&nval,&dunit,&dblock,&dindx,help); /* add descr */
87
if (dtype[0] == 'H') dtype[0] = 'h'; /* to indicate Yformat... */
97
int xSCDWRH(imno,descr,values,felem,nval)
99
/*++++++++++++++++++++++++++++++++++++++++++++++++++
101
Write help text of a descriptor
103
The help text is added and linked into the descr. entry. This routine
104
must be called directly after the descr itself has been written,
105
otherwise it is NOT safe!
107
return status ( 0 = o.k. )
109
if 'felem' = -1, descriptor values are appended to existing ones
110
--------------------------------------------------*/
112
int imno /* IN : no. of data frame */;
113
char *descr /* IN : descriptor name (max. 48 char.) */;
114
char *values /* IN : buffer with descriptor data */;
115
int felem /* IN : position of 1st descriptor value to be accessed */;
116
int nval /* IN : no. of data values to write */;
126
helpflag = 0; /* only needed for old Zformat) */
127
status = xwdscdir(imno,descr,1,nval);
129
if (status == ERR_NORMAL)
132
(void) MID_WDSCRC(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
135
MID_E2(5,imno,descr,status,1);
143
int xSCDHWC(imno,descr,noelm,values,felem,nval,unit,htext)
145
int imno /* IN : no. of data frame */;
146
char *descr /* IN : descriptor name (max. 48 char.) */;
147
int noelm /* IN : CHAR*noelm */;
148
char *values /* IN : buffer with descriptor data */;
149
int felem /* IN : position of 1st descriptor value to be accessed */;
150
int nval /* IN : no. of data values to write */;
151
int *unit /* IN : unit-pointer */;
152
char *htext /* IN : help text */;
156
if (htext != (char *) 0)
158
if (htext[0] != '\0')
160
(void) memcpy(help,htext,(size_t)71);
167
return (xSCDWRC(imno,descr,noelm,values,felem,nval,unit));
171
int xSCDWRC(imno,descr,noelm,values,felem,nval,unit)
173
/*++++++++++++++++++++++++++++++++++++++++++++++++++
175
Write a descriptor and its data
177
A new descriptor is written at the end of the existing
178
descriptor area or exisitng descriptor data is modified
179
and extended, if necessary.
181
return status ( 0 = o.k. )
183
if 'felem' = -1, descriptor values are appended to existing ones
184
--------------------------------------------------*/
186
int imno /* IN : no. of data frame */;
187
char *descr /* IN : descriptor name (max. 48 char.) */;
188
int noelm /* IN : CHAR*noelm */;
189
char *values /* IN : buffer with descriptor data */;
190
int felem /* IN : position of 1st descriptor value to be accessed */;
191
int nval /* IN : no. of data values to write */;
192
int *unit /* IN : unit-pointer */;
201
status = xwdscdir(imno,descr,noelm,nval);
203
if (status == ERR_NORMAL)
205
newl = nval * noelm; /* char array -> flat string */
206
for (nr=0; nr<newl; nr++)
208
if (values[nr] == '\0') /* we don't have enough data */
215
xpntr = malloc((size_t)newl);
216
if (xpntr == (char *) 0)
219
newl = kk; /* all what we can do ... */
224
(void) strcpy(zpntr,values); /* first, copy the data */
226
for (mr=kk; mr<newl; mr++) /* then, pad with blanks */
230
(void) MID_WDSCRC(fctpntr->IOCHAN,dblock,dindx,xpntr,0,1,newl);
231
free(xpntr); /* free allocated memory again */
236
(void) MID_WDSCRC(fctpntr->IOCHAN,dblock,dindx,values,0,1,newl);
239
MID_E2(5,imno,descr,status,1);
247
int xSCDHWD(imno,descr,values,felem,nval,unit,htext)
249
int imno /* IN : no. of data frame */;
250
char *descr /* IN : descriptor name (max. 48 char.) */;
251
double *values /* IN : buffer with descriptor data */;
252
int felem /* IN : position of 1st descriptor value to be accessed */;
253
int nval /* IN : no. of data values to write */;
254
int *unit /* IN : unit-pointer */;
255
char *htext /* IN : help text */;
259
if (htext != (char *) 0)
261
if (htext[0] != '\0')
263
(void) memcpy(help,htext,(size_t)71);
269
return (xSCDWRD(imno,descr,values,felem,nval,unit));
273
int xSCDWRD(imno,descr,values,felem,nval,unit)
275
/*++++++++++++++++++++++++++++++++++++++++++++++++++
277
Write a descriptor and its data
279
A new descriptor is written at the end of the existing
280
descriptor area or existing descriptor data is modified
281
and extended, if necessary.
283
return status ( 0 = o.k. )
285
if 'felem' = -1, descriptor values are appended to existing ones
286
--------------------------------------------------*/
288
int imno /* IN : no. of data frame */;
289
char *descr /* IN : descriptor name (max. 48 char.) */;
290
double *values /* IN : buffer with descriptor data */;
291
int felem /* IN : position of 1st descriptor value to be accessed */;
292
int nval /* IN : no. of data values to write */;
293
int *unit /* IN : unit-pointer */;
296
int n, newlen, status, *ipntr;
302
status = xwdscdir(imno,descr,DD_SIZE,nval);
304
if (status == ERR_NORMAL)
305
{ /* use MID_WDSCRI to write double precision descr... */
308
ipntr = (int *) values;
309
(void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,ipntr,0,1,newlen);
312
MID_E2(5,imno,descr,status,1);
319
int xSCDHWS(imno,descr,values,felem,nval,unit,htext)
321
int imno /* IN : no. of data frame */;
322
char *descr /* IN : descriptor name (max. 48 char.) */;
323
size_t *values /* IN : buffer with descriptor data */;
324
int felem /* IN : position of 1st descriptor value to be accessed */;
325
int nval /* IN : no. of data values to write */;
326
int *unit /* IN : unit-pointer */;
327
char *htext /* IN : help text */;
331
if (htext != (char *) 0)
333
if (htext[0] != '\0')
335
(void) memcpy(help,htext,(size_t)71);
341
return (xSCDWRS(imno,descr,values,felem,nval,unit));
345
int xSCDWRS(imno,descr,values,felem,nval,unit)
347
/*++++++++++++++++++++++++++++++++++++++++++++++++++
349
Write a descriptor and its data
351
A new descriptor is written at the end of the existing
352
descriptor area or existing descriptor data is modified
353
and extended, if necessary.
355
return status ( 0 = o.k. )
357
if 'felem' = -1, descriptor values are appended to existing ones
358
--------------------------------------------------*/
360
int imno /* IN : no. of data frame */;
361
char *descr /* IN : descriptor name (max. 48 char.) */;
362
size_t *values /* IN : buffer with descriptor data */;
363
int felem /* IN : position of 1st descriptor value to be accessed */;
364
int nval /* IN : no. of data values to write */;
365
int *unit /* IN : unit-pointer */;
368
int n, newlen, status, *ipntr;
374
status = xwdscdir(imno,descr,SS_SIZE,nval);
376
if (status == ERR_NORMAL)
377
{ /* use MID_WDSCRI to write size_t descr... */
380
ipntr = (int *) values;
381
(void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,ipntr,0,1,newlen);
384
MID_E2(5,imno,descr,status,1);
391
int xSCDHWL(imno,descr,values,felem,nval,unit,htext)
393
int imno /* IN : no. of data frame */;
394
char *descr /* IN : descriptor name (max. 48 char.) */;
395
int *values /* IN : buffer with descriptor data */;
396
int felem /* IN : position of 1st descriptor value to be accessed */;
397
int nval /* IN : no. of data values to write */;
398
int *unit /* IN : unit-pointer */;
399
char *htext /* IN : help text */;
403
if (htext != (char *) 0)
405
if (htext[0] != '\0')
407
(void) memcpy(help,htext,(size_t)71);
413
return (xSCDWRL(imno,descr,values,felem,nval,unit));
417
int xSCDWRL(imno,descr,values,felem,nval,unit)
419
/*++++++++++++++++++++++++++++++++++++++++++++++++++
421
Write a descriptor and its data
423
A new descriptor is written at the end of the existing
424
descriptor area or exisitng descriptor data is modified
425
and extended, if necessary.
427
return status ( 0 = o.k. )
429
if 'felem' = -1, descriptor values are appended to existing ones
430
--------------------------------------------------*/
432
int imno /* IN : no. of data frame */;
433
char *descr /* IN : descriptor name (max. 48 char.) */;
434
int *values /* IN : buffer with descriptor data */;
435
int felem /* IN : position of 1st descriptor value to be accessed */;
436
int nval /* IN : no. of data values to write */;
437
int *unit /* IN : unit-pointer */;
446
status = xwdscdir(imno,descr,II_SIZE,nval);
448
if (status == ERR_NORMAL)
449
(void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
451
MID_E2(5,imno,descr,status,1);
458
int xSCDHWI(imno,descr,values,felem,nval,unit,htext)
460
int imno /* IN : no. of data frame */;
461
char *descr /* IN : descriptor name (max. 48 char.) */;
462
int *values /* IN : buffer with descriptor data */;
463
int felem /* IN : position of 1st descriptor value to be accessed */;
464
int nval /* IN : no. of data values to write */;
465
int *unit /* IN : unit-pointer */;
466
char *htext /* IN : help text */;
470
if (htext != (char *) 0)
472
if (htext[0] != '\0')
474
(void) memcpy(help,htext,(size_t)71);
480
return (xSCDWRI(imno,descr,values,felem,nval,unit));
484
int xSCDWRI(imno,descr,values,felem,nval,unit)
486
/*++++++++++++++++++++++++++++++++++++++++++++++++++
488
Write a descriptor and its data
490
A new descriptor is written at the end of the existing
491
descriptor area or exisitng descriptor data is modified
492
and extended, if necessary.
494
return status ( 0 = o.k. )
496
if 'felem' = -1, descriptor values are appended to existing ones
497
--------------------------------------------------*/
499
int imno /* IN : no. of data frame */;
500
char *descr /* IN : descriptor name (max. 48 char.) */;
501
int *values /* IN : buffer with descriptor data */;
502
int felem /* IN : position of 1st descriptor value to be accessed */;
503
int nval /* IN : no. of data values to write */;
504
int *unit /* IN : unit-pointer */;
513
status = xwdscdir(imno,descr,II_SIZE,nval);
515
if (status == ERR_NORMAL)
516
(void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
518
MID_E2(5,imno,descr,status,1);
525
int xSCDHWR(imno,descr,values,felem,nval,unit,htext)
527
int imno /* IN : no. of data frame */;
528
char *descr /* IN : descriptor name (max. 48 char.) */;
529
float *values /* IN : buffer with descriptor data */;
530
int felem /* IN : position of 1st descriptor value to be accessed */;
531
int nval /* IN : no. of data values to write */;
532
int *unit /* IN : unit-pointer */;
533
char *htext /* IN : help text */;
537
if (htext != (char *) 0)
539
if (htext[0] != '\0')
541
(void) memcpy(help,htext,(size_t)71);
547
return (xSCDWRR(imno,descr,values,felem,nval,unit));
552
int xSCDWRR(imno,descr,values,felem,nval,unit)
554
/*++++++++++++++++++++++++++++++++++++++++++++++++++
556
Write a descriptor and its data
558
A new descriptor is written at the end of the existing
559
descriptor area or exisitng descriptor data is modified
560
and extended, if necessary.
562
return status ( 0 = o.k. )
564
if 'felem' = -1, descriptor values are appended to existing ones
565
--------------------------------------------------*/
567
int imno /* IN : no. of data frame */;
568
char *descr /* IN : descriptor name (max. 48 char.) */;
569
float *values /* IN : buffer with descriptor data */;
570
int felem /* IN : position of 1st descriptor value to be accessed */;
571
int nval /* IN : no. of data values to write */;
572
int *unit /* IN : unit-pointer */;
581
status = xwdscdir(imno,descr,RR_SIZE,nval);
584
if (status == ERR_NORMAL)
585
(void) MID_WDSCRR(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
587
MID_E2(5,imno,descr,status,1);