~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to libsrc/st/scdx.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
  Copyright (C) 1995-2009 European Southern Observatory (ESO)
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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, 
 
17
  MA 02139, USA.
 
18
 
 
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 
 
25
                        GERMANY
 
26
===========================================================================*/
 
27
 
 
28
/*+++++++++++++++++++++++++++ SC interface module SCDX +++++++++++++++++++++++
 
29
.LANGUAGE C
 
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...
 
36
 
 
37
.VERSION  [1.00] 920211:  pulled out from scd.c
 
38
 090327         last modification
 
39
 
 
40
----------------------------------------------------------------------------*/
 
41
 
 
42
#include <stdlib.h>
 
43
#include <fileexts.h>
 
44
 
 
45
 
 
46
 
 
47
static char   dtype[4], help[72];
 
48
static char   realdescr[52];
 
49
 
 
50
static int    dblock, dindx, dunit, helpflag=0;
 
51
 
 
52
static struct FCT_STRUCT  *fctpntr;
 
53
 
 
54
/*
 
55
 
 
56
*/
 
57
 
 
58
int xwdscdir(imno,descr,bytelem,nval)
 
59
 
 
60
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
61
.PURPOSE
 
62
hdnale lower level descr directory stuff common to all descr tytpes
 
63
.ALGORITHM
 
64
.RETURNS
 
65
return status  ( 0 = o.k. )
 
66
--------------------------------------------------*/
 
67
 
 
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 */;
 
72
 
 
73
{
 
74
int   status, dsclen;
 
75
 
 
76
 
 
77
 
 
78
 
 
79
dunit = 0;                      /* not used yet */
 
80
 
 
81
fctpntr = FCT.ENTRIES + imno;
 
82
dsclen = DSCNAM_COPY(realdescr,descr);  /* build uppercase name */
 
83
 
 
84
status = MID_YDSCDIR(imno,'a',realdescr,dtype,&bytelem,
 
85
                     &nval,&dunit,&dblock,&dindx,help);      /* add descr */
 
86
 
 
87
if (dtype[0] == 'H') dtype[0] = 'h';            /* to indicate Yformat... */
 
88
 
 
89
fctpntr->KAUX[2] = 1;
 
90
 
 
91
return status;
 
92
}
 
93
/*
 
94
 
 
95
*/
 
96
 
 
97
int xSCDWRH(imno,descr,values,felem,nval)
 
98
 
 
99
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
100
.PURPOSE
 
101
Write help text of a descriptor
 
102
.ALGORITHM
 
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!
 
106
.RETURNS
 
107
return status  ( 0 = o.k. )
 
108
.REMARKS
 
109
if 'felem' = -1, descriptor values are appended to existing ones
 
110
--------------------------------------------------*/
 
111
 
 
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 */;
 
117
 
 
118
{
 
119
int   status;
 
120
 
 
121
 
 
122
 
 
123
 
 
124
 
 
125
dtype[0] = 'H';
 
126
helpflag = 0;                           /* only needed for old Zformat) */
 
127
status = xwdscdir(imno,descr,1,nval); 
 
128
 
 
129
if (status == ERR_NORMAL)
 
130
   {
 
131
   if (dtype[0] == 'H')
 
132
      (void) MID_WDSCRC(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);  
 
133
   }
 
134
else
 
135
   MID_E2(5,imno,descr,status,1);     
 
136
 
 
137
return (status);
 
138
}
 
139
/*
 
140
 
 
141
*/
 
142
 
 
143
int xSCDHWC(imno,descr,noelm,values,felem,nval,unit,htext)
 
144
 
 
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 */;
 
153
 
 
154
{
 
155
help[0] = '\0';
 
156
if (htext != (char *) 0)
 
157
   {
 
158
   if (htext[0] != '\0')
 
159
      {
 
160
      (void) memcpy(help,htext,(size_t)71);
 
161
      help[71] = '\0';
 
162
      }
 
163
   }
 
164
 
 
165
 
 
166
helpflag = 1;
 
167
return (xSCDWRC(imno,descr,noelm,values,felem,nval,unit));
 
168
}
 
169
 
 
170
 
 
171
int xSCDWRC(imno,descr,noelm,values,felem,nval,unit)
 
172
 
 
173
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
174
.PURPOSE
 
175
Write a descriptor and its data
 
176
.ALGORITHM
 
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.
 
180
.RETURNS
 
181
return status  ( 0 = o.k. )
 
182
.REMARKS
 
183
if 'felem' = -1, descriptor values are appended to existing ones
 
184
--------------------------------------------------*/
 
185
 
 
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 */;
 
193
 
 
194
{
 
195
int   status, newl;
 
196
register int  nr;
 
197
 
 
198
 
 
199
 
 
200
dtype[0] = 'C'; 
 
201
status = xwdscdir(imno,descr,noelm,nval);
 
202
 
 
203
if (status == ERR_NORMAL)
 
204
   {
 
205
   newl = nval * noelm;         /* char array -> flat string */
 
206
   for (nr=0; nr<newl; nr++)
 
207
      {
 
208
      if (values[nr] == '\0')           /* we don't have enough data */
 
209
         {
 
210
         char  *xpntr, *zpntr;
 
211
         int   kk;
 
212
         register int mr;
 
213
 
 
214
         kk = nr;
 
215
         xpntr = malloc((size_t)newl);
 
216
         if (xpntr == (char *) 0)
 
217
            {
 
218
            xpntr = values;
 
219
            newl = kk;                  /* all what we can do ...  */
 
220
            }
 
221
         else
 
222
            {
 
223
            zpntr = xpntr;
 
224
            (void) strcpy(zpntr,values);        /* first, copy the data */
 
225
            zpntr += kk;
 
226
            for (mr=kk; mr<newl; mr++)  /* then, pad with blanks */
 
227
               *zpntr++ = ' ';
 
228
            }
 
229
 
 
230
         (void) MID_WDSCRC(fctpntr->IOCHAN,dblock,dindx,xpntr,0,1,newl);
 
231
         free(xpntr);           /* free allocated memory again */
 
232
         return status;
 
233
         }
 
234
      }
 
235
 
 
236
   (void) MID_WDSCRC(fctpntr->IOCHAN,dblock,dindx,values,0,1,newl);
 
237
   }
 
238
else
 
239
   MID_E2(5,imno,descr,status,1);
 
240
 
 
241
return (status);
 
242
}
 
243
/*
 
244
 
 
245
*/
 
246
 
 
247
int xSCDHWD(imno,descr,values,felem,nval,unit,htext)
 
248
 
 
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 */;
 
256
 
 
257
{
 
258
help[0] = '\0';
 
259
if (htext != (char *) 0)
 
260
   {
 
261
   if (htext[0] != '\0')
 
262
      {
 
263
      (void) memcpy(help,htext,(size_t)71);
 
264
      help[71] = '\0';
 
265
      }
 
266
   }
 
267
 
 
268
helpflag = 1;
 
269
return (xSCDWRD(imno,descr,values,felem,nval,unit));
 
270
}
 
271
 
 
272
 
 
273
int xSCDWRD(imno,descr,values,felem,nval,unit)
 
274
 
 
275
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
276
.PURPOSE
 
277
Write a descriptor and its data
 
278
.ALGORITHM
 
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.
 
282
.RETURNS
 
283
return status  ( 0 = o.k. )
 
284
.REMARKS
 
285
if 'felem' = -1, descriptor values are appended to existing ones
 
286
--------------------------------------------------*/
 
287
 
 
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 */;
 
294
 
 
295
{
 
296
int   n, newlen, status, *ipntr;
 
297
 
 
298
 
 
299
        
 
300
 
 
301
dtype[0] = 'D'; 
 
302
status = xwdscdir(imno,descr,DD_SIZE,nval);
 
303
 
 
304
if (status == ERR_NORMAL) 
 
305
   {                 /* use MID_WDSCRI to write double precision descr... */
 
306
   n = DD_SIZE/II_SIZE;
 
307
   newlen = n * nval;
 
308
   ipntr = (int *) values;
 
309
   (void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,ipntr,0,1,newlen);
 
310
   }
 
311
else
 
312
   MID_E2(5,imno,descr,status,1);
 
313
return (status);
 
314
}
 
315
/*
 
316
 
 
317
*/
 
318
 
 
319
int xSCDHWS(imno,descr,values,felem,nval,unit,htext)
 
320
 
 
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 */;
 
328
 
 
329
{
 
330
help[0] = '\0';
 
331
if (htext != (char *) 0)
 
332
   {
 
333
   if (htext[0] != '\0')
 
334
      {
 
335
      (void) memcpy(help,htext,(size_t)71);
 
336
      help[71] = '\0';
 
337
      }
 
338
   }
 
339
 
 
340
helpflag = 1;
 
341
return (xSCDWRS(imno,descr,values,felem,nval,unit));
 
342
}
 
343
 
 
344
 
 
345
int xSCDWRS(imno,descr,values,felem,nval,unit)
 
346
 
 
347
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
348
.PURPOSE
 
349
Write a descriptor and its data
 
350
.ALGORITHM
 
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.
 
354
.RETURNS
 
355
return status  ( 0 = o.k. )
 
356
.REMARKS
 
357
if 'felem' = -1, descriptor values are appended to existing ones
 
358
--------------------------------------------------*/
 
359
 
 
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 */;
 
366
 
 
367
{
 
368
int   n, newlen, status, *ipntr;
 
369
 
 
370
 
 
371
        
 
372
 
 
373
dtype[0] = 'S'; 
 
374
status = xwdscdir(imno,descr,SS_SIZE,nval);
 
375
 
 
376
if (status == ERR_NORMAL) 
 
377
   {                 /* use MID_WDSCRI to write size_t descr... */
 
378
   n = SS_SIZE/II_SIZE;
 
379
   newlen = n * nval;
 
380
   ipntr = (int *) values;
 
381
   (void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,ipntr,0,1,newlen);
 
382
   }
 
383
else
 
384
   MID_E2(5,imno,descr,status,1);
 
385
return (status);
 
386
}
 
387
/*
 
388
 
 
389
*/
 
390
 
 
391
int xSCDHWL(imno,descr,values,felem,nval,unit,htext)
 
392
 
 
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 */;
 
400
 
 
401
{
 
402
help[0] = '\0';
 
403
if (htext != (char *) 0)
 
404
   {
 
405
   if (htext[0] != '\0')
 
406
      {
 
407
      (void) memcpy(help,htext,(size_t)71);
 
408
      help[71] = '\0';
 
409
      }
 
410
   }
 
411
 
 
412
helpflag = 1;
 
413
return (xSCDWRL(imno,descr,values,felem,nval,unit));
 
414
}
 
415
 
 
416
 
 
417
int xSCDWRL(imno,descr,values,felem,nval,unit)
 
418
 
 
419
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
420
.PURPOSE
 
421
Write a descriptor and its data
 
422
.ALGORITHM
 
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.
 
426
.RETURNS
 
427
return status  ( 0 = o.k. )
 
428
.REMARKS
 
429
if 'felem' = -1, descriptor values are appended to existing ones
 
430
--------------------------------------------------*/
 
431
 
 
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 */;
 
438
 
 
439
{
 
440
int   status;
 
441
 
 
442
 
 
443
 
 
444
 
 
445
dtype[0] = 'L';
 
446
status = xwdscdir(imno,descr,II_SIZE,nval);
 
447
 
 
448
if (status == ERR_NORMAL)
 
449
   (void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
 
450
else
 
451
   MID_E2(5,imno,descr,status,1);
 
452
return (status);
 
453
}
 
454
/*
 
455
 
 
456
*/
 
457
 
 
458
int xSCDHWI(imno,descr,values,felem,nval,unit,htext)
 
459
 
 
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 */;
 
467
 
 
468
{
 
469
help[0] = '\0';
 
470
if (htext != (char *) 0)
 
471
   {
 
472
   if (htext[0] != '\0')
 
473
      {
 
474
      (void) memcpy(help,htext,(size_t)71);
 
475
      help[71] = '\0';
 
476
      }
 
477
   }
 
478
 
 
479
helpflag = 1;
 
480
return (xSCDWRI(imno,descr,values,felem,nval,unit));
 
481
}
 
482
 
 
483
 
 
484
int xSCDWRI(imno,descr,values,felem,nval,unit)
 
485
 
 
486
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
487
.PURPOSE
 
488
Write a descriptor and its data
 
489
.ALGORITHM
 
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.
 
493
.RETURNS
 
494
return status  ( 0 = o.k. )
 
495
.REMARKS
 
496
if 'felem' = -1, descriptor values are appended to existing ones
 
497
--------------------------------------------------*/
 
498
 
 
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 */;
 
505
 
 
506
{
 
507
int   status;
 
508
 
 
509
 
 
510
 
 
511
 
 
512
dtype[0] = 'I';
 
513
status = xwdscdir(imno,descr,II_SIZE,nval);
 
514
        
 
515
if (status == ERR_NORMAL)
 
516
   (void) MID_WDSCRI(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
 
517
else
 
518
   MID_E2(5,imno,descr,status,1);
 
519
return (status);
 
520
}
 
521
/*
 
522
 
 
523
*/
 
524
 
 
525
int xSCDHWR(imno,descr,values,felem,nval,unit,htext)
 
526
 
 
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 */;
 
534
 
 
535
{
 
536
help[0] = '\0';
 
537
if (htext != (char *) 0)
 
538
   {
 
539
   if (htext[0] != '\0')
 
540
      {
 
541
      (void) memcpy(help,htext,(size_t)71);
 
542
      help[71] = '\0';
 
543
      }
 
544
   }
 
545
 
 
546
helpflag = 1;
 
547
return (xSCDWRR(imno,descr,values,felem,nval,unit));
 
548
}
 
549
 
 
550
 
 
551
 
 
552
int xSCDWRR(imno,descr,values,felem,nval,unit)
 
553
 
 
554
/*++++++++++++++++++++++++++++++++++++++++++++++++++
 
555
.PURPOSE
 
556
Write a descriptor and its data
 
557
.ALGORITHM
 
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.
 
561
.RETURNS
 
562
return status  ( 0 = o.k. )
 
563
.REMARKS
 
564
if 'felem' = -1, descriptor values are appended to existing ones
 
565
--------------------------------------------------*/
 
566
 
 
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 */;
 
573
 
 
574
{
 
575
int   status;
 
576
 
 
577
 
 
578
 
 
579
 
 
580
dtype[0] = 'R';
 
581
status = xwdscdir(imno,descr,RR_SIZE,nval);
 
582
        
 
583
 
 
584
if (status == ERR_NORMAL)
 
585
      (void) MID_WDSCRR(fctpntr->IOCHAN,dblock,dindx,values,0,1,nval);
 
586
else
 
587
    MID_E2(5,imno,descr,status,1);
 
588
return (status);
 
589
}
 
590