-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvexf_get.c
1876 lines (1724 loc) · 51.7 KB
/
vexf_get.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2020-2021 NVI, Inc.
*
* This file is part of VLBI Field System
* (see http://github.com/nvi-inc/fs).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* vexf.c FORTRAN VEX library */
/* ----------------------------------------------------------------------- */
#include <stdio.h>
#include <math.h>
#include <string.h>
#include<stdlib.h>
#ifdef F2C
#include "f2c.h"
#else
typedef long int integer;
typedef int ftnlen;
typedef double doublereal;
#endif
#include "vex.h"
#include "y.tab.h"
#define LOOKUP(found,units,table,out) { int i; if(!found)\
for (i=0; table[i].str !=NULL; i++)\
if(strcmp(units,table[i].str)==0) {\
out=table[i].factor;\
found=1; } }
static void *save_ptr=NULL;
static int save_type=0;
static char *save_units=NULL;
static Llist *save_lowls=NULL;
static int
field_copy(char *field,int field_len,char *ptr);
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fvex_open__
#else
fvex_open
#endif
(name, vex)
char **name;
integer *vex;
/*
* integer function fvex_open(ptr_ch(name),vex)
* character*(*) name
* integer vex
*
* Opens a VEX file and reads it into memory.
*
* Input:
* character*(*) name - pathname to file to be read in,
* zero terminated
*
* Output:
* integer vex - VEX file reference, for subsequent calls
* NOTE: on 64-bit machines this is 64-bit
* integer, calling FORTRAN source should use
* compile option -fdefault-integer-8 and/or
* possibly -finteger-4-integer-8 or an
* array with at least 64-bits
*
* integer (return value) - error code
* - non-zero indicates error
*/
{
return vex_open(*name,(struct vex **)vex);
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_vex_rev__
#else
fget_vex_rev
#endif
(version, version_len, vex)
char **version;
integer *version_len, *vex;
/*
* integer function fget_vex_rev(ptr_ch(version),len(version),
* vex)
* implicit none
* character*(*) version
* integer vex
*
* Returns the VEX_rev string of the VEX file.
*
* Input:
* integer vex - VEX file reference
* use value returned open_vex()
*
* Output:
* character*(*) version - VEX_rev string
* use fvex_len() to determine useful length
* should be at least 1 byte longer than
* longest expected value to accommodate
* zero termination
* integer (return value) - error code, zero indicates no error
* otherwise errors determined by bits, if
* bit is on the error occurred, bits are
* numbered from 0 and correspond to
* the value of the corresponding power of 2,
* e.g., bit 0 is decimal 1
* bit 0 - VEX_rev did not fit in version
* bit 1 - vex was NULL
*/
{
char *ptr;
integer len, clen;
if(*vex!=0)
ptr=get_vex_rev((struct vex *)*vex);
else
return 2;
if(ptr==NULL) {
if(*version_len>0)
*version[0]='\0';
return 0;
}
len=strlen(ptr)+1;
clen=len > *version_len ? *version_len : len;
memcpy(*version,ptr,clen);
if((len-1)>*version_len)
return 1;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_station_def__
#else
fget_station_def
#endif
(station, station_len, vex)
char **station;
integer *station_len, *vex;
/*
* integer function fget_station_def(ptr_ch(station),len(station),
* vex)
* implicit none
* character*(*) station
* integer vex
*
* Returns the station defs in the $STATION section of the VEX file.
*
* To retrieve the list of station defs, call this routine the first time with
* vex set to the value returned by open_vex(), on subsequent calls use 0. If
* fvex_len() reports that the returned character string has zero length then
* all the stations have been returned.
*
* Use fget_station_lowls() to find lowls for the found station def.
*
* Input:
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* character*(*) station - station def name
* use fvex_len() to determine useful length
* should be at least 1 byte longer than
* longest expected to value to accommodate
* zero termination
*
* integer (return value) - error code, zero indicates no error
* otherwise errors determined by bits, if
* bit is on the error occurred, bits are
* numbered from 0 and correspond to
* the value of the corresponding power of 2,
* e.g., bit 0 is decimal 1
* bit 0 - station def name did not fit in station
*/
{
char *ptr;
integer len, clen;
if(*vex!=0)
ptr=get_station_def((struct vex *)*vex);
else
ptr=get_station_def_next();
if(ptr==NULL) {
if(*station_len>0)
*station[0]='\0';
return 0;
}
len=strlen(ptr)+1;
clen=len > *station_len ? *station_len : len;
memcpy(*station,ptr,clen);
if((len-1)>*station_len)
return 1;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_mode_def__
#else
fget_mode_def
#endif
(mode, mode_len, vex)
char **mode;
integer *mode_len,*vex;
/*
* integer function fget_mode_def(ptr_ch(mode),len(mode),vex)
* implicit none
* character*(*) mode
* integer vex
*
* Returns the mode def names from the $MODE section of the VEX file.
*
* To retrieve the list of mode defs, call this routine the first time with vex
* set to the value returned by open_vex(), on subsequent calls use 0. If
* fvex_len() reports that the returned character string has zero length then
* all the modes have been returned.
*
* Input:
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* character*(*) mode - mode def name
* use fvex_len() to determine useful length
* should be at least 1 byte longer than
* longest expected to value to accommodate
* zero termination
* integer (return value) - error code, zero indicates no error
* otherwise errors determined by bits, if
* bit is on the error occurred, bits are
* numbered from 0 and correspond to
* the value of the corresponding power of 2,
* e.g., bit 0 is decimal 1
* bit 0 - mode def name did not fit in mode
*/
{
char *ptr;
integer len, clen;
if(*vex!=0)
ptr=get_mode_def((struct vex *)*vex);
else
ptr=get_mode_def_next();
if(ptr==NULL) {
if(*mode_len>0)
*mode[0]='\0';
return 0;
}
len=strlen(ptr)+1;
clen=len > *mode_len ? *mode_len : len;
memcpy(*mode,ptr,clen);
if((len-1)>*mode_len)
return 1;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_source_def__
#else
fget_source_def
#endif
(source, source_len, vex)
char **source;
integer *source_len,*vex;
/*
* integer function fget_source_def(ptr_ch(source),len(source),vex)
* implicit none
* character*(*) source
* integer vex
*
* Returns the source defs in the $SOURCE section of the VEX file.
*
* To retrieve the list of source defs, call this routine the first time with
* vex set to the value returned by open_vex(), on subsequent calls use 0. If
* fvex_len() reports that the returned character string has zero length then
* all the sources have been returned.
*
* Use fget_source_lowls() to find lowls for the found source def
*
* Input:
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* character*(*) source - source def name
* use fvex_len() to determine useful length
* should be at least 1 byte longer than
* longest expected to value to accommodate
* zero termination
* integer (return value) - error code, zero indicates no error
* otherwise errors determined by bits, if
* bit is on the error occurred, bits are
* numbered from 0 and correspond to
* the value of the corresponding power of 2,
* e.g., bit 0 is decimal 1
* bit 0 - source def name did not fit in source
*/
{
char *ptr;
integer len, clen;
if(*vex!=0)
ptr=get_source_def((struct vex *)*vex);
else
ptr=get_source_def_next();
if(ptr==NULL) {
if(*source_len>0)
*source[0]='\0';
return 0;
}
len=strlen(ptr)+1;
clen=len > *source_len ? *source_len : len;
memcpy(*source,ptr,clen);
if((len-1)>*source_len)
return 1;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_all_lowl__
#else
fget_all_lowl
#endif
(station, mode, statement, primitive, vex)
char **station, **mode, **statement, **primitive;
integer *vex;
/*
* integer function fget_all_lowl(ptr_ch(station),
* & ptr_ch(mode),
* & ptr_ch(statement),
* & ptr_ch(primitive),
* & vex)
* implicit none
* character*(*) station,mode,statement,primitive
* integer vex
*
* Get the low-level statement associated with a mode for a given station.
*
* This routine can be used to retrieve all the low-level statements associated
* with a given mode for a given station. Call this routine the first time with
* vex set to the value returned by open_vex(), on subsequent calls use 0. The
* call with vex nonzero should specify the station, mode, statement, and
* primitive block (containing the statement). When vex is zero, station, mode,
* statement, and primitive are ignored.
*
* When this routine does not return an error, the fields can be accessed using
* fvex_field() and fvex_units().
*
* Statements are returned in order of $MODE, $STATION, $GLOBAL.
*
* Input:
* character*(*) station - station def name, zero terminated
* character*(*) mode - mode def name, zero terminated
* character*(*) statement - the statement to be retrieved
* zero terminated
* character*(*) primitive - primitive block from which the statement
* should be retrieved, omit the leading "$"
* zero terminated
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* integer (return value) - error code, zero indicates no error
*/
{
int iprimitive;
if(*vex!=0) {
save_type=lowl2int(*statement);
iprimitive=block2int(*primitive);
save_ptr=get_all_lowl(*station,*mode,save_type,iprimitive,(Vex *)*vex);
} else
save_ptr=get_all_lowl_next();
if(save_ptr==NULL)
return -3;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_mode_lowl__
#else
fget_mode_lowl
#endif
(station, mode, statement, primitive, vex)
char **station, **mode, **statement, **primitive;
integer *vex;
/*
* integer function fget_mode_lowl(ptr_ch(station),
* & ptr_ch(mode),
* & ptr_ch(statement),
* & ptr_ch(primitive),
* & vex)
* implicit none
* character*(*) station,mode,statement,primitive
* integer vex
*
* Get the low-level statement associated with a mode for a given statement.
*
* This routine can be used to retrieve the $MODE specified low-level
* statements associated with a given mode for a given station. Call this
* routine the first time with vex set to the value returned by open_vex(), on
* subsequent calls use 0. The call with vex nonzero should specify the station,
* mode, statement, and primitive block (containing the statement). When vex is
* zero, station, mode, statement, and primitive are ignored.
*
* When this routine does not return an error, the fields can be accessed
* using fvex_field() and fvex_units().
*
* Information specified in the $STATION and $GLOBAL blocks is not returned. In
* general this routine is not useful, fget_all_lowl() is usually what is
* wanted.
*
* Input:
* character*(*) station - station def name, zero terminated
* character*(*) mode - mode def name, zero terminated
* character*(*) statement - the statement to be retrieved,
* zero terminated
* character*(*) primitive - primitive block from which the statement
* should be retrieved, omit the leading "$"
* zero terminated
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* integer (return value) - error code, zero indicates no error
* -3 = no more statements to return
*/
{
int iprimitive;
if(*vex!=0) {
save_type=lowl2int(*statement);
iprimitive=block2int(*primitive);
save_ptr=get_mode_lowl(*station,*mode,save_type,iprimitive,(Vex *)*vex);
} else
save_ptr=get_mode_lowl_next();
if(save_ptr==NULL)
return -3;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_station_lowl__
#else
fget_station_lowl
#endif
( station, statement, primitive, vex)
char **station, **statement, **primitive;
integer *vex;
/*
* integer function fget_station_lowl(ptr_ch(station),
* & ptr_ch(statement),
* & ptr_ch(primitive),
* & vex)
* implicit none
* character*(*) station,statement,primitive
* integer vex
*
* Get the low-level statement associated with a mode for a given statement.
*
* This routine can be used to retrieve the $STATION specified low-level
* statements associated with a station. Call this routine the first time
* with vex set to the value returned by open_vex(), on subsequent calls
* use 0. The call with vex nonzero should specify the station, statement,
* and primitive block (containing the statement). When vex is zero,
* station, statement, and primitive are ignored.
*
* When this routine does not return an error, the fields can be accessed
* using fvex_field() and fvex_units().
*
* Information specified in the $MODE and $GLOBAL blocks is not returned. In
* general this routine is not useful, fget_all_lowl() is usually what is
* wanted.
*
* Input:
* character*(*) station - station def name, zero terminated
* character*(*) statement - the statement to be retrieved,
* zero terminated
* character*(*) primitive - primitive block from which the statement
* should be retrieved, omit the leading "$"
* zero terminated
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* integer (return value) - error code, zero indicates no error
* -3 = no more statements to return
*/
{
int iprimitive;
if(*vex!=0) {
save_type=lowl2int(*statement);
iprimitive=block2int(*primitive);
save_ptr=get_station_lowl(*station,save_type,iprimitive,(Vex *)*vex);
} else
save_ptr=get_station_lowl_next();
if(save_ptr==NULL)
return -3;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_global_lowl__
#else
fget_global_lowl
#endif
(statement, primitive, vex)
char **statement, **primitive;
integer *vex;
/*
* integer function fget_global_lowl(ptr_ch(statement),
* & ptr_ch(primitive),
* & vex)
* implicit none
* character*(*) statement,primitive
* integer vex
*
* Get the low-level statement associated with a mode for a given statement.
*
* This routine can be used to retrieve all the low-level statements
* globally referenced. Call this routine the first time with vex set to the
* value returned by open_vex(), on subsequent calls use 0. The call with vex
* nonzero should specify the statement and primitive block (containing
* the statement). When vex is zero statement and primitive are ignored.
*
* When this routine does not return an error, the fields can be accessed
* using fvex_field() and fvex_units().
*
* Information specified in the $MODE and $STATION blocks is not returned. In
* general this routine is not useful, fget_all_low() is usually what is
* wanted.
*
* Input:
* character*(*) statement - the statement to be retrieved,
* zero terminated
* character*(*) primitive - primitive block from which the statement
* should be retrieved, omit the leading "$"
* zero terminated
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* integer (return value) - error code, zero indicates no error
* -3 = no more statements to return
*/
{
int iprimitive;
if(*vex!=0) {
save_type=lowl2int(*statement);
iprimitive=block2int(*primitive);
save_ptr=get_global_lowl(save_type,iprimitive,(Vex *)*vex);
} else
save_ptr=get_global_lowl_next();
if(save_ptr==NULL)
return -3;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_scan_station__
#else
fget_scan_station
#endif
(start, start_len, mode, mode_len, scanid, scanid_len, station, vex)
char **start, **mode, **station, **scanid;
integer *start_len, *mode_len, *scanid_len, *vex;
/*
* integer function fget_scan_station(ptr_ch(start), len(start),
* & ptr_ch(mode), len(mode),
* & ptr_ch(scanid), len(scanid),
* & ptr_ch(station),
* & vex)
* implicit none
* character*(*) start,mode,station,scanid
* integer vex
*
* This routine can be used to retrieve all of the station statements
* associated with a station. Call this routine the first time with vex set
* to the value returned by open_vex(), on subsequent calls use 0. When vex
* is zero, station is ignored. The call with vex nonzero should specify
* the station.
*
* The fields of the station statement can be accessed using fvex_field() and
* fvex_units().
*
* Other lowls associated with the scan can be retrieved with the fget_scan_*()
* routines, except use fget_station_scan() and fget_data_transfer_scan()
* instead of fget_scan_station() and fget_scan_data_transfer().
*
* Input:
* character*(*) station - the station to return station statements for,
* zero terminated
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* character*(*) start - nominal start time for this scan
* use fvex_len() to determine useful length
* character*(*) mode - mode for this scan
* use fvex_len() to determine useful length
* character*(*) scanid - scanid for this scan
* use fvex_len() to determine useful length
* integer (return value) - error code, zero indicates no error
* -3 = no more statements to return
* -4 = start did not fit in start
* -5 = mode did not fit in mode
* -6 = scanid did not fit in scanid
*/
{
int ierr;
void *ptr;
char *sidptr;
save_type=T_STATION;
if(*vex!=0)
save_ptr=get_scan_station(&save_lowls,&sidptr,*station,(Vex *)*vex);
else
save_ptr=get_scan_station_next(&save_lowls,&sidptr);
if(save_ptr==NULL)
return -3;
ptr=get_scan_mode(save_lowls);
ierr=field_copy(*mode,*mode_len,ptr);
if(ierr==-1)
return -4;
ptr=get_scan_start(save_lowls);
ierr=field_copy(*start,*start_len,ptr);
if(ierr==-1)
return -5;
ierr=field_copy(*scanid,*scanid_len,sidptr);
if(ierr==-1)
return -6;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_scan_data_transfer__
#else
fget_scan_data_transfer
#endif
(start, start_len, mode, mode_len, scanid, scanid_len, station, vex)
char **start, **mode, **station, **scanid;
integer *start_len, *mode_len, *scanid_len, *vex;
/*
* integer function fget_scan_data_transfer(ptr_ch(start), len(start),
* & ptr_ch(mode), len(mode),
* & ptr_ch(scanid), len(scanid),
* & ptr_ch(station),
* & vex)
* implicit none
* character*(*) start,mode,station,scanid
* integer vex
*
* This routine can be used to retrieve all of the data_transfer statements
* associated with a station. Call this routine the first time with vex set
* to the value returned by open_vex(), on subsequent calls use 0. When vex
* is zero, station is ignored. The call with vex nonzero should specify
* the station.
*
* The fields of the data_transfer statement can be accessed using fvex_field()
* and fvex_units().
*
* Other lowls associated with the scan can be retrieved with the fget_scan_*()
* routines, except use fget_station_scan() and fget_data_transfer_scan()
* instead of fget_scan_station() and fget_scan_data_transfer().
*
* Input:
* character*(*) station - the station to return data_transfer
* statements for, zero terminated
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* character*(*) start - nominal start time for this scan
* use fvex_len() to determine useful length
* character*(*) mode - mode for this scan
* use fvex_len() to determine useful length
* character*(*) scanid - scanid for this scan
* use fvex_len() to determine useful length
* integer (return value) - error code, zero indicates no error
* -3 = no more statements to return
* -4 = start did not fit in start
* -5 = mode did not fit in mode
* -6 = scanid did not fit in scanid
*/
{
int ierr;
void *ptr;
char *sidptr;
if(*vex!=0) {
save_type=T_DATA_TRANSFER;
save_ptr=get_scan_data_transfer(&save_lowls,&sidptr,*station,(Vex *)*vex);
} else
save_ptr=get_scan_data_transfer_next(&save_lowls,&sidptr);
if(save_ptr==NULL)
return -3;
ptr=get_scan_mode(save_lowls);
ierr=field_copy(*mode,*mode_len,ptr);
if(ierr==-1)
return -4;
ptr=get_scan_start(save_lowls);
ierr=field_copy(*start,*start_len,ptr);
if(ierr==-1)
return -5;
ierr=field_copy(*scanid,*scanid_len,sidptr);
if(ierr==-1)
return -6;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_scan__
#else
fget_scan
#endif
(start, start_len, mode, mode_len, scanid, scanid_len, vex)
char **start, **mode, **scanid;
integer *start_len, *mode_len, *scanid_len,*vex;
/*
* integer function fget_scan(ptr_ch(start),len(start),
* & ptr_ch(mode),len(mode),
* & ptr_ch(scanid),len(scanid),
* & vex)
* implicit none
* character*(*) start,mode,station,scanid
* integer vex
*
* This routine can be used to retrieve all the scans, one-by-one. Call this
* routine the first time with vex set to the value returned by open_vex(), on
* subsequent calls use 0.
*
* The lowls associated with the scan can be retrieved with the fget_scan_*()
* routines, except use fget_station_scan() and fget_data_transfer_scan()
* instead of fget_scan_station() and fget_scan_data_transfer().
*
* Input:
* integer vex - VEX file reference
* use value returned open_vex() for first call,
* use 0 for subsequent calls
*
* Output:
* character*(*) start - nominal start time for this scan
* use fvex_len() to determine useful length
* should be at least 1 character larger than
* longest possible value to hold zero
* termination
* character*(*) mode - mode for this scan
* use fvex_len() to determine useful length
* should be at least 1 character larger than
* longest possible value to hold zero
* termination
* character*(*) scanid - scanid for this scan
* use fvex_len() to determine useful length
* should be at least 1 character larger than
* longest possible value to hold zero
* termination
* integer (return value) - error code, zero indicates no error
* -2 = no more scans
* -4 = start time did not fit in start
* -5 = mode did not fit in mode
* -6 = scanid did not fit in scanid
*/
{
int ierr;
void *ptr;
char *cptr;
if(*vex!=0) {
save_lowls=get_scan(&cptr,(Vex *)*vex);
} else
save_lowls=get_scan_next(&cptr);
if(save_lowls==NULL)
return -2;
ptr=get_scan_mode(save_lowls);
ierr=field_copy(*mode,*mode_len,ptr);
if(ierr==-1)
return -4;
ptr=get_scan_start(save_lowls);
ierr=field_copy(*start,*start_len,ptr);
if(ierr==-1)
return -5;
ierr=field_copy(*scanid,*scanid_len,cptr);
if(ierr==-1)
return -6;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_station_scan__
#else
fget_station_scan
#endif
(n)
integer *n;
/*
* integer function fget_station_scan(n)
* implicit none
* integer n
*
* This routine can be used to retrieve the n-th station statement in a scan
* block found by fget_scan(), fget_scan_station(), or
* fget_scan_data_transfer().
*
* The fields in the station statement can be accessed using fvex_field() and
* fvex_units().
*
* This is highly efficient when n increases by one on each call.
*
* Input:
* integer n - the number of the station statement in this
*
* Output:
* integer (return value) - error code, zero indicates no error
* -2 = no such station statement in this scan
*/
{
int i;
static int save_n=0;
static Llist *save2_lowls=NULL;
save_type=T_STATION;
if(*n!=1 && *n==save_n+1 && save_lowls == save2_lowls)
save_ptr=get_station_scan_next();
else {
save_ptr=get_station_scan(save_lowls);
save2_lowls=save_lowls;
for (i=1;i<*n && save_ptr!=NULL;i++)
save_ptr=get_station_scan_next();
}
if(save_ptr==NULL)
return -2;
save_n=*n;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_data_transfer_scan__
#else
fget_data_transfer_scan
#endif
(n)
integer *n;
/*
* integer function fget_data_transfer_scan(n)
* implicit none
* integer n
*
* This routine can be used to retrieve the n-th data_transfer statement in a
* scan block found by fget_scan(), fget_scan_station(), or
* fget_scan_data_transfer().
*
* The fields in the data_transfer statement can be accessed using fvex_field()
* and fvex_units().
*
* This is highly efficient when n increases by one on each call.
*
* Input:
* integer n - the number of the data_transfer statement in this
*
* Output:
* integer (return value) - error code, zero indicates no error
* -2 = no such data_transfer statement in this scan
*/
{
int i;
static int save_n=0;
static Llist *save2_lowls=NULL;
save_type=T_DATA_TRANSFER;
if(*n!=1 && *n==save_n+1 && save_lowls == save2_lowls)
save_ptr=get_data_transfer_scan_next();
else {
save_ptr=get_data_transfer_scan(save_lowls);
save2_lowls=save_lowls;
for (i=1;i<*n && save_ptr!=NULL;i++)
save_ptr=get_data_transfer_scan_next();
}
if(save_ptr==NULL)
return -2;
save_n=*n;
return 0;
}
/* ----------------------------------------------------------------------- */
integer
#ifdef F2C
fget_source_lowl__
#else
fget_source_lowl
#endif
(source, statement, vex)
char **source, **statement;
integer *vex;
/*
* integer function fget_source_lowl(ptr_chr(source),
* & ptr_chr(statement),
* & vex)
* implicit none
* character*(*) source,statement
* integer vex
*
* Get a low-level statement associated with a source.
*
* This routine is used to retrieve the $SOURCE low-level statements associated
* with a given source def. Call this routine the first time with vex set to
* the value returned by open_vex(), on subsequent calls use 0. The call with
* vex nonzero should specify the source and the statement. When vex is zero,
* source and statement are ignored are ignored.
*
* When this routine does not return an error, the fields can be accessed using
* fvex_field() and fvex_units().
*
* Input:
* character*(*) source - source def name, zero terminated
* character*(*) statement - the statement to be retrieved,
* zero terminated
* integer vex - VEX file reference