Mapper
shdtype.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 06/07/94 at 17:00:46 */
2 /*FOR_C Options SET: c=2 com=u do=r4 ftn=2ln6k op=iv s=dvn str=l sq=i */
3 
4 #define _POSIX_SOURCE
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <ctype.h>
8 #include <dirent.h>
9 #include <unistd.h>
10 #include <math.h>
11 #include <string.h>
12 #include <fcntl.h>
13 #include <sys/stat.h>
14 #include "shef_structs_external.h"
15 
16 /*---------------------------------------------------------------------
17 
18  NAME
19  SUBROUTINE SHDTYPE(IFLAG,STATUS)
20 
21  PURPOSE
22 
23  This modual decodes the date and data type elements.
24  IFLAG is set to: 1 FOR .A FORMAT
25  2 .B
26  3 .E
27  4 .B WITHIN THE BODY
28  The routine will take the standard return if the
29  element is not valid.
30 
31  VERSION and UPDATES
32  1.0 JUN 82 GEOFFREY M BONNIN MBRFC
33  Original Version
34  1.1 JAN 84
35  Zero date relative on explicit date
36  1.2 AUG 84
37  Allow negative DI increments
38  Add seconds to times
39  1.3 FEB 87
40  Fix bug with date relative in .B body
41  2.0 JUN 94 David G. Brandon
42  Also Translated to 'C' using FOR_C
43  Allow for years 2000 thru 2020
44  Removed alternate returns in subroutines
45  2.1 Add iscore to t_codes array.
46  2.2 NOV 95 DGB
47  Allow for all valid qualifier codes excepting for
48  'O' and 'I'.
49  2.3 FEB 11 96 DGB
50  Modify code to accomodate century.
51  2.4 SEP 10 97 DGB
52  Add the use of MAX_SHEF_INPUT so that the input line can
53  be longer than 80 characters.
54  Check for variable duration, and keep duration code
55  as 'V'.
56  2.5 JAN 17 98 DGB
57  Fix increments of NULL values in .E type messages.
58  These messages are flagged with *flag = 3.
59  Previously, the NULL would be read, but the time
60  would not be incremented.
61  2.6 JAN 19 98 DGB
62  Previously a julian day with only two days specified
63  did not work. E.G. DJ09 ( although DJ009 did work ).
64  This was fixed.
65  2.7 JAN 18 99 DGB
66  Fix century/year overrides for certain cases when the
67  century/year is not explicitly stated in the positional data.
68 
69  *--------------------------------------------------------------------- */
70 
71 
72 void shdtype(iflag, status)
73 short int *iflag, *status;
74 {
75  static short int itest, jchar, jday, jflag, jsign, leap,
76  ndig, num, numa, total_ndig, k;
77  short int buffer_temp[MAX_SHEF_INPUT]; /* dgb:09/10/97 dgb:02/01/96 */
78  char tempc[4]; /* dgb:02/01/96 */
79  int DEBUG1, DEBUG2;
80 
81  /* OFFSET Vectors w/subscript range: 1 to dimension */
82  /* OFFSET Vectors w/subscript range: 1 to dimension */
83  short *const Idate = &datim_.idate[0] - 1;
84 
85  short *const Idstn = &data_.idstn[0] - 1;
86  short *const Msource = &data_.msource[0] - 1;
87 
88  DEBUG1 = 0;
89  DEBUG2 = 0;
90 
91  if ( DEBUG1 ) printf("\nshdtype:begin *******************************");
92  /* copy existing char buffer into temp buffer */
93  for ( ndig=0; ndig < MAX_SHEF_INPUT; ndig++) /* dgb:09/10/97 */
94  buffer_temp[ndig] = buffer_.ibuf[ndig];
95 
96  *status = 0;
97  dotbee_.nelem = 0;
98 
99  /* Look for the "D" of data and date type elements */
100 
101 L_20:
102  if ( DEBUG1 ) printf("\nshdtype:at 20");
103  if( xchar_.ichar != codes_.iblnk )
104  goto L_30;
105 L_25:
106  if ( DEBUG1 ) printf("\nshdtype:at 25");
107  nextch( &xchar_.ichar, status );
108  if( *status == 1 )
109  {
110  *status = 0;
111  goto L_9120;
112  }
113  else if( *status == 2 )
114  {
115  *status = 0;
116  goto L_9010;
117  }
118  goto L_20;
119 
120 L_30:
121  if ( DEBUG1 ) printf("\nshdtype:at 30 iflag = %d",*iflag);
122  if( xchar_.ichar == codes_.ichd )
123  goto L_35;
124  if( xchar_.ichar != codes_.islash )
125  goto L_600;
126  if( *iflag == 4 )
127  goto L_600;
128  goto L_25;
129 
130  /* Check for the element possibilities */
131 
132 L_35:
133  if ( DEBUG1 ) printf("\nshdtype:at 35");
134  nextch( &xchar_.ichar, status );
135  if( *status == 1 )
136  {
137  *status = 0;
138  goto L_9120;
139  }
140  else if( *status == 2 )
141  {
142  *status = 0;
143  goto L_9010;
144  }
145  ndig = 2;
146  dotbee_.nelem = 1;
147 
148 
149  /* DS - Second */
150 
151  if ( DEBUG1 ) printf("\nshdtype:getting DS");
152  if( xchar_.ichar != codes_.ichs )
153  goto L_37;
154 
155  shint( &data_.lsec, &ndig, 1, status );
156  if( *status == 1 )
157  {
158  *status = 0;
159  goto L_9120;
160  }
161  else if( *status == 2 )
162  {
163  *status = 0;
164  goto L_9010;
165  }
166  else if( *status == 3 )
167  {
168  *status = 0;
169  goto L_9030;
170  }
171  if( *status == 1 )
172  {
173  *status = 0;
174  goto L_9120;
175  }
176  else if( *status == 2 )
177  {
178  *status = 0;
179  goto L_9010;
180  }
181  else if( *status == 3 )
182  {
183  *status = 0;
184  goto L_9030;
185  }
186  if( data_.lsec > 59 )
187  {
188  goto L_9030;
189  }
190  if( data_.lsec < 0 )
191  {
192  goto L_9030;
193  }
194  if( data_.lhour == 24 )
195  goto L_36;
196  goto L_125;
197 
198 L_36:
199  if( (data_.lmin > 0) || (data_.lsec > 0) )
200  {
201  goto L_9030;
202  }
203  goto L_125;
204 
205  /* DN - Minute */
206 
207 L_37:
208  if ( DEBUG1 ) printf("\nshdtype:getting DN");
209  if( xchar_.ichar != codes_.ichn )
210  goto L_40;
211  shint( &data_.lmin, &ndig, 1, status );
212  if( *status == 1 )
213  {
214  *status = 0;
215  goto L_9120;
216  }
217  else if( *status == 2 )
218  {
219  *status = 0;
220  goto L_9010;
221  }
222  else if( *status == 3 )
223  {
224  *status = 0;
225  goto L_9030;
226  }
227  if( data_.lmin > 59 )
228  {
229  goto L_9030;
230  }
231  if( data_.lmin < 0 )
232  {
233  goto L_9030;
234  }
235  if( data_.lhour == 24 )
236  goto L_38;
237  goto L_115;
238 
239 L_38:
240  if( (data_.lmin > 0) || (data_.lsec > 0) )
241  {
242  goto L_9030;
243  }
244  goto L_115;
245 
246  /* DH - Hour */
247 
248 L_40:
249  if( xchar_.ichar != codes_.ichh )
250  goto L_50;
251  shint( &data_.lhour, &ndig, 1, status );
252  if( *status == 1 )
253  {
254  *status = 0;
255  goto L_9120;
256  }
257  else if( *status == 2 )
258  {
259  *status = 0;
260  goto L_9010;
261  }
262  else if( *status == 3 )
263  {
264  *status = 0;
265  goto L_9030;
266  }
267  if( data_.lhour > 24 )
268  {
269  goto L_9030;
270  }
271  if( data_.lhour < 0 )
272  {
273  goto L_9030;
274  }
275  if( data_.lhour == 24 )
276  goto L_41;
277  goto L_110;
278 
279 L_41:
280  if( (data_.lmin > 0) || (data_.lsec > 0) )
281  {
282  goto L_9030;
283  }
284  goto L_110;
285 
286  /* DD - Day */
287 
288 L_50:
289  if ( DEBUG1 ) printf("\nshdtype:getting DD");
290  if( xchar_.ichar != codes_.ichd )
291  goto L_60;
292  shint( &data_.lday, &ndig, 1, status );
293  if( *status == 1 )
294  {
295  *status = 0;
296  goto L_9120;
297  }
298  else if( *status == 2 )
299  {
300  *status = 0;
301  goto L_9010;
302  }
303  else if( *status == 3 )
304  {
305  *status = 0;
306  goto L_9030;
307  }
308  if( data_.lday > 31 )
309  {
310  goto L_9030;
311  }
312  if( data_.lday < 0 )
313  {
314  goto L_9030;
315  }
316  goto L_100;
317 
318  /* DM - Month */
319 
320 L_60:
321  if ( DEBUG1 ) printf("\nshdtype:getting DM");
322  if( xchar_.ichar != codes_.ichm )
323  goto L_70;
324  shint( &data_.lmon, &ndig, 1, status );
325  if( *status == 1 )
326  {
327  *status = 0;
328  goto L_9120;
329  }
330  else if( *status == 2 )
331  {
332  *status = 0;
333  goto L_9010;
334  }
335  else if( *status == 3 )
336  {
337  *status = 0;
338  goto L_9030;
339  }
340  if( data_.lmon > 12 )
341  {
342  goto L_9030;
343  }
344  if( data_.lmon < 1 )
345  {
346  goto L_9030;
347  }
348  data_.overmonth = data_.lmon; /* dgb:01/18/99 */
349  goto L_90;
350 
351  /* DY - Year */
352 
353 L_70:
354  if ( DEBUG1 ) printf("\nshdtype:getting DY");
355  if( xchar_.ichar != codes_.ichy )
356  goto L_80;
357  shint( &data_.lyear, &ndig, 1, status );
358  if( *status == 1 )
359  {
360  *status = 0;
361  goto L_9120;
362  }
363  else if( *status == 2 )
364  {
365  *status = 0;
366  goto L_9010;
367  }
368  else if( *status == 3 )
369  {
370  *status = 0;
371  goto L_9030;
372  }
373  if( data_.lyear < 0 )
374  {
375  goto L_9030;
376  }
377  if ( *iflag == 2 )
378  data_.posoveryear = data_.lyear; /* dgb:01/18/99 */
379  data_.overyear = data_.lyear; /* dgb:01/18/99 */
380  data_.lyear = (data_.lcent * 100) + data_.lyear;
381 
382  goto L_85;
383 
384 
385 
386  /* DT - Century */
387 
388 L_80:
389  if ( DEBUG1 ) printf("\nshdtype:getting DT");
390  if( xchar_.ichar != codes_.icht ) /* dgb:09/10/97 */
391  goto L_130;
392  shint( &data_.lcent, &ndig, 1, status );
393  if( *status == 1 )
394  {
395  *status = 0;
396  goto L_9120;
397  }
398  else if( *status == 2 )
399  {
400  *status = 0;
401  goto L_9010;
402  }
403  else if( *status == 3 )
404  {
405  *status = 0;
406  goto L_120;
407  }
408  if( data_.lcent > 30 )
409  {
410  goto L_9030;
411  }
412  if( data_.lcent < 17 )
413  {
414  goto L_9030;
415  }
416  if ( *iflag == 2 ) /* dgb:01/18/99 */
417  {
420  }
421  data_.overyear = data_.lyear; /* dgb:01/18/99 */
422  data_.overcentury = data_.lcent; /* dgb:01/1899 */
423 
424  data_.lyear =
425  ( data_.lcent * 100 ) + (data_.lyear - (( (int) (data_.lyear/100))*100)); /* dgb:01/18/99 */
426  /* DY - Year */
427 
428 
429  if ( DEBUG1 ) printf("\nshdtype: DY");
430  shint( &num, &ndig, 1, status );
431  if( *status == 1 )
432  {
433  *status = 0;
434  goto L_9120;
435  }
436  else if( *status == 2 )
437  {
438  *status = 0;
439  goto L_9010;
440  }
441  else if( *status == 3 )
442  {
443  *status = 0;
444  goto L_120;
445  }
446 
447  data_.lyear = (data_.lcent * 100) + num;
448 
449 L_85:
450  if ( DEBUG1 ) printf("\nshdtype:at 85");
451  shint( &num, &ndig, 1, status );
452  if( *status == 1 )
453  {
454  *status = 0;
455  goto L_9120;
456  }
457  else if( *status == 2 )
458  {
459  *status = 0;
460  goto L_9010;
461  }
462  else if( *status == 3 )
463  {
464  *status = 0;
465  goto L_120;
466  }
467 
468  data_.lmon = num;
469  if( data_.lmon > 12 )
470  {
471  goto L_9030;
472  }
473  if( data_.lmon < 1 )
474  {
475  goto L_9030;
476  }
477 
478 L_90:
479  if ( DEBUG1 ) printf("\nshdtype:at 90");
480  shint( &num, &ndig, 1, status );
481  if( *status == 1 )
482  {
483  *status = 0;
484  goto L_9120;
485  }
486  else if( *status == 2 )
487  {
488  *status = 0;
489  goto L_9010;
490  }
491  else if( *status == 3 )
492  {
493  *status = 0;
494  goto L_120;
495  }
496 
497  data_.lday = num;
498  if( data_.lday > 31 )
499  {
500  goto L_9030;
501  }
502  if( data_.lday < 0 )
503  {
504  goto L_9030;
505 }
506 
507 L_100:
508  if ( DEBUG1 ) printf("\nshdtype:at 100");
509  shint( &num, &ndig, 1, status );
510  if( *status == 1 )
511  {
512  *status = 0;
513  goto L_9120;
514  }
515  else if( *status == 2 )
516  {
517  *status = 0;
518  goto L_9010;
519  }
520  else if( *status == 3 )
521  {
522  *status = 0;
523  goto L_120;
524  }
525 
526  data_.lhour = num;
527  if( data_.lhour > 24 )
528  goto L_9030;
529  if( data_.lhour < 0 )
530  goto L_9030;
531 
532 L_110:
533  if ( DEBUG1 ) printf("\nshdtype:at 110");
534  shint( &num, &ndig, 1, status );
535  if( *status == 1 )
536  {
537  *status = 0;
538  goto L_9120;
539  }
540  else if( *status == 2 )
541  {
542  *status = 0;
543  goto L_9010;
544  }
545  else if( *status == 3 )
546  {
547  *status = 0;
548  goto L_120;
549  }
550 
551  data_.lmin = num;
552  if( data_.lmin > 59 )
553  goto L_9030;
554  if( data_.lmin < 0 )
555  goto L_9030;
556  if( (data_.lhour == 24) && (data_.lmin > 0) )
557  goto L_9030;
558 
559 L_115:
560  if ( DEBUG1 ) printf("\nshdtype:at 115");
561  shint( &num, &ndig, 1, status );
562  if( *status == 1 )
563  {
564  *status = 0;
565  goto L_9120;
566  }
567  else if( *status == 2 )
568  {
569  *status = 0;
570  goto L_9010;
571  }
572  else if( *status == 3 )
573  {
574  *status = 0;
575  goto L_120;
576  }
577 
578  data_.lsec = num;
579  if( data_.lsec > 59 )
580  goto L_9030;
581  if( data_.lsec < 0 )
582  goto L_9030;
583  if( data_.lhour == 24 )
584  goto L_116;
585  goto L_125;
586 
587 L_116:
588  if ( DEBUG1 ) printf("\nshdtype:at 116");
589  if( (data_.lmin > 0) || (data_.lsec > 0) )
590  goto L_9030;
591  goto L_125;
592 
593 L_120:
594  if ( DEBUG1 ) printf("\nshdtype:at 120");
595  if( data_.lhour == 24 )
596  goto L_121;
597  if( ndig != 0 )
598  goto L_9020;
599  goto L_122;
600 
601 L_121:
602  if ( DEBUG1 ) printf("\nshdtype:at 121");
603  if( (data_.lmin > 0) || (data_.lsec > 0) )
604  goto L_9030;
605 
606 
607  if( ndig != 0 )
608  goto L_9020;
609 
610  /* Zero date relatives */
611 
612 L_122:
613  if ( DEBUG1 ) printf("\nshdtype:at 122");
614  if( *iflag == 4 )
615  goto L_510;
616  datrel_.mcent = 0; /* dgb cent */
617  datrel_.myear = 0;
618  datrel_.mmon = 0;
619  datrel_.mday = 0;
620  datrel_.mhour = 0;
621  datrel_.mmin = 0;
622  datrel_.msec = 0;
623  datrel_.mend = 0;
624  goto L_510;
625 
626 L_125:
627  if ( DEBUG1 ) printf("\nshdtype:at 125 iflag = %d",*iflag);
628 
629  if( *iflag == 4 )
630  goto L_500;
631  datrel_.mcent = 0; /* dgb cent */
632  datrel_.myear = 0;
633  datrel_.mmon = 0;
634  datrel_.mday = 0;
635  datrel_.mhour = 0;
636  datrel_.mmin = 0;
637  datrel_.msec = 0;
638  datrel_.mend = 0;
639  goto L_500;
640 
641 
642  /* Decode the DC group */
643  /* Get the first two digits */
644 
645 L_130:
646 
647  /* DC Century */
648  if ( xchar_.ichar != codes_.ichc )
649  goto L_150;
650  ndig = 2;
651  shint( &data_.kcent, &ndig, 1, status );
652  if( *status == 1 )
653  {
654  *status = 0;
655  goto L_9120;
656  }
657  else if( *status == 2 )
658  {
659  *status = 0;
660  goto L_9010;
661  }
662  else if( *status == 3 )
663  {
664  *status = 0;
665  goto L_9020;
666  }
667  total_ndig = 2;
668  data_.dccentflag = 1; /* dgb:12/24/96 */
669 
670 
671  /* DC year */
672  /* Get the next two digits */
673  ndig = 2;
674  shint( &data_.kyear, &ndig, 1, status );
675  if( *status == 1 )
676  {
677  *status = 0;
678  goto L_9120;
679  }
680  else if( *status == 2 )
681  {
682  *status = 0;
683  goto L_9010;
684  }
685  else if( *status == 3 )
686  {
687  *status = 0;
688  jflag = 0;
689  goto L_75;
690  }
691  total_ndig = total_ndig + 2;
692 
693  /* Get the next two digits */
694  /* DC Month */
695 
696  ndig = 2;
697  shint( &data_.kmon, &ndig, 1, status );
698  if( *status == 1 )
699  {
700  *status = 0;
701  goto L_9120;
702  }
703  else if( *status == 2 )
704  {
705  *status = 0;
706  goto L_9010;
707  }
708  else if( *status == 3 )
709  {
710  *status = 0;
711  jflag = 0;
712  goto L_75;
713  }
714  total_ndig = total_ndig + 2;
715 
716  /* Get the next two digits */
717  /* DC Day */
718  ndig = 2;
719  shint( &data_.kday, &ndig, 1, status );
720  if( *status == 1 )
721  {
722  *status = 0;
723  goto L_9120;
724  }
725  else if( *status == 2 )
726  {
727  *status = 0;
728  goto L_9010;
729  }
730  else if( *status == 3 )
731  {
732  *status = 0;
733  jflag = 0;
734  goto L_75;
735  }
736  total_ndig = total_ndig + 2;
737 
738  /* Get the next two digits */
739  /* DC Hour */
740 
741  ndig = 2;
742  shint( &data_.khour, &ndig, 1, status );
743 
744  if( *status == 1 )
745  {
746  *status = 0;
747  goto L_9120;
748  }
749  else if( *status == 2 )
750  {
751  *status = 0;
752  goto L_9010;
753  }
754  else if( *status == 3 )
755  {
756  *status = 0;
757  jflag = 0;
758  goto L_75;
759  }
760  total_ndig = total_ndig + 2;
761 
762  /* Get the last two digits */
763  /* DC Minute */
764 
765  ndig = 2;
766  shint( &data_.kmin, &ndig, 1, status );
767  if( *status == 1 )
768  {
769  *status = 0;
770  goto L_9120;
771  }
772  else if( *status == 2 )
773  {
774  *status = 0;
775  goto L_9010;
776  }
777  else if( *status == 3 )
778  {
779  *status = 0;
780  jflag = 0;
781  goto L_75;
782  }
783  total_ndig = total_ndig + 2;
784  jflag = 1;
785 
786  /* if 12 digits decode-> CCYRMMDDHRMN */
787  /* id 10 digits decode -> YRMMDDHRMN */
788  /* if 8 digits decode -> MMDDHRMN */
789  /* If 6 digits decode -> MMDDHR */
790  /* If 4 digits decode -> MMDD */
791  /* any other combination -> error */
792 
793 L_75:
794  if ( DEBUG1 ) printf("\nshdtype:at 75");
795 
796  if ( DEBUG2 ) printf("\nshdtype: at L_75\n total_ndig = %d\n data_.kcent=%d\n data_.kyear=%d\n data_.kmon=%d\n data_.kday=%d\n data_.khour=%d\n data_.kmin=%d",
798  if ( total_ndig == 12 )
799  {}
800  else
801  if ( total_ndig == 10 )
802  {
803  data_.kmin = data_.khour;
804  data_.khour = data_.kday;
805  data_.kday = data_.kmon;
806  data_.kmon = data_.kyear;
808  data_.kcent = -1;
809  }
810  else
811  if ( total_ndig == 8 )
812  {
813  data_.kmin = data_.kday;
814  data_.khour = data_.kmon;
815  data_.kday = data_.kyear;
816  data_.kmon = data_.kcent;
817  data_.kyear = -1;
818  data_.kcent = -1;
819  }
820  else
821  if ( total_ndig == 6 )
822  {
823  data_.khour = data_.kmon;
824  data_.kday = data_.kyear;
825  data_.kmon = data_.kcent;
826  data_.kyear = -1;
827  data_.kcent = -1;
828  data_.kmin = -1;
829  }
830  else
831  if ( total_ndig == 4 )
832  {
833  data_.kday = data_.kyear;
834  data_.kmon = data_.kcent;
835  data_.khour = -1;
836  data_.kcent = -1;
837  data_.kyear = -1;
838  data_.kmin = -1;
839  }
840  else
841  goto L_240;
842 
843 
844  /* Now get defaults */
845 
846  if ( data_.kmin == -1 )
847  data_.kmin = 0;
848  if ( data_.khour == -1 )
849  data_.khour = 0;
850 
851 
852  if ( data_.kcent == -1 )
853  {
854  if ( data_.kyear >= 0 ) /* dgb:01/07/99 */
855  {
856  if ( data_.kyear <= 30 )
857  data_.kcent = 20; /* dgb:01/07/99 */
858  else
859  data_.kcent = 19;
860  }
861  data_.dccentflag = -1; /* dgb:12/21/97 */
862  }
863  else
864  {
866  data_.dccentflag = 1; /* dgb:12/21/97 */
867  }
868 
869  if ( data_.kyear == -1 )
870  {
871  data_.kyear = Idate[3] - ( (int) (Idate[3]/100)) * 100;
872  if ( data_.kyear >= 0 )
873  {
874  if ( data_.kyear <= 30 )
875  data_.kcent = 20;
876  else
877  data_.kcent = 19;
878  }
879  data_.kyear = ( data_.kcent *100) + data_.kyear;
880  itest = data_.kmon - Idate[1];
881  if( itest > 6 )
882  data_.kyear = data_.kyear - 1;
883  if( itest < -6 )
884  data_.kyear = data_.kyear + 1;
885  if( (itest == -6) && (data_.kday < Idate[2]) )
886  data_.kyear = data_.kyear + 1;
887  if( (itest == 6) && (data_.kday > Idate[2]) )
888  data_.kyear = data_.kyear - 1;
889  }
890  else
891  data_.kyear = ( data_.kcent *100) + data_.kyear;
892 
893 
894 /*
895  if ( data_.khour == 1 )
896  data_.khour = 0;
897 */
898 
899  if ( DEBUG2 ) printf("\nshdtype: at L_75\n data_.kcent=%d\n data_.kyear=%d\n data_.kmon=%d\n data_.kday=%d\n data_.khour=%d\n data_.kmin=%d",
901 
902 
903  /* Test for bad date */
904 
905 /* L_147: */
906  shtdat( &data_.kyear, &data_.kmon, &data_.kday, status );
907  if( *status == 1 )
908  {
909  *status = 0;
910  goto L_9020;
911  }
912  if( (data_.khour < 0) || (data_.khour > 24) )
913  goto L_9020;
914  if( (data_.kmin < 0) || (data_.kmin > 59) )
915  goto L_9020;
916  if( (data_.khour == 24) && (data_.kmin > 0) )
917  goto L_9020;
918  if( jflag == 0 )
919  goto L_510;
920  if( ndig == 0 )
921  goto L_510;
922  goto L_500;
923 
924  /* DJ - Julian date */
925 
926 L_150:
927  if ( DEBUG1 ) printf("\nshdtype:at 150");
928  if ( DEBUG2 ) printf("\nshdtype: xchar_.ichar = %d %c",xchar_.ichar,xchar_.ichar);
929  if( xchar_.ichar != codes_.ichj )
930  goto L_180;
931  total_ndig = 0;
932  k = buffer_.ip;
933 
934 L_151:
935  if ( DEBUG1 ) printf("\nshdtype:at 151");
936  /* count the digits */
937  irang(&buffer_temp[k],&codes_.ich0,&codes_.ich9,status);
938  if ( *status == 1 )
939  goto L_155;
940  total_ndig = total_ndig + 1;
941  k = k + 1;
942  goto L_151;
943 
944 L_155:
945  if ( DEBUG1 ) printf("\nshdtype:at 155");
946  if ( DEBUG2 ) printf("\nshdtype: total_ndig = %d",total_ndig);
947  /* look for 7 digits 'CCYRDDD' or 5 digits 'YRDDD' or 3 digits 'DDD' */
948  /* or 2 digits DD */
949 
950  if ( total_ndig != 7 && total_ndig != 5 && total_ndig != 3
951  && total_ndig != 2 )
952  goto L_9020;
953 
954  if ( total_ndig == 7 )
955  {
956  /* calculate 'CC' */
957  tempc[0] = buffer_temp[buffer_.ip];
958  tempc[1] = buffer_temp[buffer_.ip+1];
959  tempc[2] = 0;
960  data_.lcent = atoi(tempc);
961 
962  /* calculate 'YR' */
963  tempc[0] = buffer_temp[buffer_.ip+2];
964  tempc[1] = buffer_temp[buffer_.ip+3];
965  tempc[2] = 0;
966  data_.lyear = atoi(tempc);
967  data_.lyear = (data_.lcent * 100) + data_.lyear; /* dgb:01/18/99 */
968 
969  /* calculate 'DDD' */
970  tempc[0] = buffer_temp[buffer_.ip+4];
971  tempc[1] = buffer_temp[buffer_.ip+5];
972  tempc[2] = buffer_temp[buffer_.ip+6];
973  tempc[3] = 0;
974  jday = atoi(tempc);
975  buffer_.ip = buffer_.ip + 7;
976  }
977  else
978  if ( total_ndig == 5 )
979  {
980  /* calculate 'YR' */
981  tempc[0] = buffer_temp[buffer_.ip];
982  tempc[1] = buffer_temp[buffer_.ip+1];
983  tempc[2] = 0;
984  data_.lyear = atoi(tempc);
985  if ( data_.lyear <= 30 ) data_.lyear = data_.lyear + 2000; /* dgb:01/18/99 */
986  else
987  if ( data_.lyear > 29 ) data_.lyear = data_.lyear + 1900; /* dgb:01/18/99 */
988 
989  /* calculate 'DDD' */
990  tempc[0] = buffer_temp[buffer_.ip+2];
991  tempc[1] = buffer_temp[buffer_.ip+3];
992  tempc[2] = buffer_temp[buffer_.ip+4];
993  tempc[3] = 0;
994  jday = atoi(tempc);
995  buffer_.ip = buffer_.ip + 5;
996  }
997  else
998  if ( total_ndig == 3 )
999  {
1000  /* calculate 'DDD' */
1001  tempc[0] = buffer_temp[buffer_.ip];
1002  tempc[1] = buffer_temp[buffer_.ip+1];
1003  tempc[2] = buffer_temp[buffer_.ip+2];
1004  tempc[3] = 0;
1005  jday = atoi(tempc);
1006  buffer_.ip = buffer_.ip + 3;
1007 
1008  }
1009  else /* dgb:01/19/98 */
1010  if ( total_ndig == 2 ) /* dgb:01/19/98 */
1011  { /* dgb:01/19/98 */
1012  /* calculate 'DD' */ /* dgb:01/19/98 */
1013  tempc[0] = buffer_temp[buffer_.ip]; /* dgb:01/19/98 */
1014  tempc[1] = buffer_temp[buffer_.ip+1]; /* dgb:01/19/98 */
1015  tempc[2] = 0; /* dgb:01/19/98 */
1016  tempc[3] = 0; /* dgb:01/19/98 */
1017  jday = atoi(tempc); /* dgb:01/19/98 */
1018  buffer_.ip = buffer_.ip + 2; /* dgb:01/19/98 */
1019  }
1020 
1021 
1022 
1023  /* Convert julian day of LYEAR To month, day */
1024 
1025 /* L_170: */
1026  if ( DEBUG1 ) printf("\nshdtype:at 170");
1027  shleap( &data_.lyear, &leap );
1028  if( jday > 366 )
1029  goto L_9050;
1030  if( (leap == 0) && (jday > 365) )
1031  goto L_9050;
1032 
1033  shcal( &jday, &leap, &data_.lmon, &data_.lday );
1034  if( ndig != 2 )
1035  goto L_510;
1036  goto L_500;
1037 
1038  /* DQ - Data qualifier */
1039 
1040 L_180:
1041  if ( DEBUG1 ) printf("\nshdtype:at 180");
1042  if( xchar_.ichar != codes_.ichq )
1043  goto L_200;
1044  nextch( &xchar_.ichar, status );
1045  if( *status == 1 )
1046  {
1047  *status = 0;
1048  goto L_9120;
1049  }
1050  else if( *status == 2 )
1051  {
1052  *status = 0;
1053  goto L_9010;
1054  }
1055  /* pass all alphabetical characters except 'O' and 'I' dgb:11/13/95 */
1056  irang(&xchar_.ichar,&codes_.icha,&codes_.ichz,status);
1057 
1058  if ( !*status )
1059  {
1060  if ( xchar_.ichar == codes_.icho ) goto L_9060;
1061  if ( xchar_.ichar == codes_.ichi ) goto L_9060;
1062  *status = 0;
1063  goto L_190;
1064  }
1065 
1066  goto L_9060;
1067 
1068 L_190:
1069  data_.kwal = xchar_.ichar;
1070  goto L_500;
1071 
1072  /* DU - Units code */
1073 
1074 L_200:
1075  if ( DEBUG1 ) printf("\nshdtype:at 200");
1076  if( xchar_.ichar != codes_.ichu )
1077  goto L_220;
1078  nextch( &xchar_.ichar, status );
1079  if( *status == 1 )
1080  {
1081  *status = 0;
1082  goto L_9120;
1083  }
1084  else if( *status == 2 )
1085  {
1086  *status = 0;
1087  goto L_9010;
1088  }
1089  if( xchar_.ichar != codes_.ichs )
1090  goto L_210;
1091  data_.kodu = 0; /* STANDARD INTERNATIONAL UNITS */
1092  goto L_500;
1093 
1094 L_210:
1095  if( xchar_.ichar != codes_.iche )
1096  goto L_9070;
1097  data_.kodu = 1; /* ENGLISH UNITS (US SYSTEM) */
1098  goto L_500;
1099 
1100  /* DR - Date relative increment */
1101 
1102 L_220:
1103  if ( DEBUG1 ) printf("\nshdtype:at 220");
1104 
1105  if( xchar_.ichar != codes_.ichr )
1106  goto L_290;
1107  datrel_.mcent = 0; /* dgb cent */
1108  datrel_.myear = 0;
1109  datrel_.mmon = 0;
1110  datrel_.mday = 0;
1111  datrel_.mhour = 0;
1112  datrel_.mmin = 0;
1113  datrel_.msec = 0;
1114  datrel_.mend = 0;
1115  nextch( &jchar, status );
1116  if( *status == 1 )
1117  {
1118  *status = 0;
1119  goto L_9120;
1120  }
1121  else if( *status == 2 )
1122  {
1123  *status = 0;
1124  goto L_9010;
1125  }
1126  nextch( &num, status ); /* SIGN ? */
1127  if( *status == 1 )
1128  {
1129  *status = 0;
1130  goto L_9120;
1131  }
1132  else if( *status == 2 )
1133  {
1134  *status = 0;
1135  goto L_9010;
1136  }
1137  jflag = 0;
1138  jsign = 1;
1139  if( num != codes_.iplus )
1140  goto L_230;
1141  jflag = 1;
1142  goto L_240;
1143 
1144 L_230:
1145  if( num != codes_.iminus )
1146  goto L_9075;
1147  jsign = -1;
1148  jflag = 1;
1149 
1150 L_240:
1151  if ( DEBUG1 ) printf("\nshdtype:at 240");
1152  ndig = 2;
1153  shint( &num, &ndig, jflag, status ); /* NUMBER ? */
1154  if( *status == 1 )
1155  {
1156  *status = 0;
1157  goto L_9120;
1158  }
1159  else if( *status == 2 )
1160  {
1161  *status = 0;
1162  goto L_9010;
1163  }
1164  else if( *status == 3 )
1165  {
1166  *status = 0;
1167  goto L_245;
1168  }
1169 
1170 L_245:
1171  if ( DEBUG1 ) printf("\nshdtype:at 245");
1172  if( ndig == 0 )
1173  goto L_9075;
1174  num = num*jsign;
1175  if( jchar != codes_.ichs )
1176  goto L_247; /* SECONDS */
1177  datrel_.msec = num;
1178  if( ndig == 1 )
1179  goto L_510;
1180  goto L_500;
1181 
1182 L_247:
1183  if ( DEBUG1 ) printf("\nshdtype:at 247");
1184  if( jchar != codes_.ichn )
1185  goto L_250; /* MINUTES */
1186  datrel_.mmin = num;
1187  if( ndig == 1 )
1188  goto L_510;
1189  goto L_500;
1190 
1191 L_250:
1192  if ( DEBUG1 ) printf("\nshdtype:at 250");
1193  if( jchar != codes_.ichh )
1194  goto L_260; /* HOURS */
1195  datrel_.mhour = num;
1196  if( ndig == 1 )
1197  goto L_510;
1198  goto L_500;
1199 
1200 L_260:
1201  if ( DEBUG1 ) printf("\nshdtype:at 260");
1202  if( jchar != codes_.ichd )
1203  goto L_270; /* DAYS */
1204  datrel_.mday = num;
1205  if( ndig == 1 )
1206  goto L_510;
1207  goto L_500;
1208 
1209 L_270:
1210  if ( DEBUG1 ) printf("\nshdtype:at 270");
1211  if( jchar != codes_.ichm )
1212  goto L_280; /* MONTHS */
1213  datrel_.mmon = num;
1214  if( ndig == 1 )
1215  goto L_510;
1216  goto L_500;
1217 
1218 L_280:
1219 if ( DEBUG1 ) printf("\nshdtype: at 280");
1220 
1221  if( jchar != codes_.ichy )
1222  goto L_282; /* YEARS */
1223  datrel_.myear = num;
1224  if( ndig == 1 )
1225  goto L_510;
1226  goto L_500;
1227 
1228 /* dgb add cent */
1229 L_282:
1230 
1231  if ( jchar != codes_.ichz )
1232  goto L_285;
1233  datrel_.mcent = num;
1234  if ( ndig == 1 )
1235  goto L_510;
1236  goto L_500;
1237 
1238 L_285:
1239  if ( DEBUG1 ) printf("\nshdtype:at 285");
1240  if( jchar != codes_.iche )
1241  goto L_9075; /* END OF MONTH */
1242  datrel_.mend = num;
1243  if( ndig == 1 )
1244  goto L_510;
1245  goto L_500;
1246 
1247  /* DV - Duration code */
1248 
1249 L_290:
1250 
1251  if ( DEBUG1 ) printf("\nshdtype:at 290");
1252  if( xchar_.ichar != codes_.ichv )
1253  goto L_360;
1254  nextch( &xchar_.ichar, status );
1255  if( *status == 1 )
1256  {
1257  *status = 0;
1258  goto L_9120;
1259  }
1260  else if( *status == 2 )
1261  {
1262  *status = 0;
1263  goto L_9010;
1264  }
1265 
1266  if( xchar_.ichar != codes_.ichs )
1267  goto L_295;
1268  numa = 7000;
1269  goto L_350;
1270 
1271 L_295:
1272  if ( DEBUG1 ) printf("\nshdtype:at 295");
1273  if( xchar_.ichar != codes_.ichn )
1274  goto L_300;
1275  numa = 0;
1276  goto L_350;
1277 
1278 L_300:
1279  if ( DEBUG1 ) printf("\nshdtype:at 300");
1280  if( xchar_.ichar != codes_.ichh )
1281  goto L_310;
1282  numa = 1000;
1283  goto L_350;
1284 
1285 L_310:
1286  if ( DEBUG1 ) printf("\nshdtype:at 310");
1287  if( xchar_.ichar != codes_.ichd )
1288  goto L_320;
1289  numa = 2000;
1290  goto L_350;
1291 
1292 L_320:
1293  if ( DEBUG1 ) printf("\nshdtype:at 320");
1294  if( xchar_.ichar != codes_.ichm )
1295  goto L_330;
1296  numa = 3000;
1297  goto L_350;
1298 
1299 L_330:
1300  if ( DEBUG1 ) printf("\nshdtype:at 330");
1301 
1302  if( xchar_.ichar != codes_.ichy )
1303  goto L_340;
1304  numa = 4000;
1305  goto L_350;
1306 
1307 L_340:
1308  if ( DEBUG1 ) printf("\nshdtype:at 340");
1309  if( xchar_.ichar != codes_.ichz )
1310  goto L_9095;
1311  data_.idcodd = 5000;
1312  goto L_500;
1313 
1314  /* NOW GET THE DURATION */
1315 
1316 L_350:
1317  if ( DEBUG1 ) printf("\nshdtype:at 350");
1318  ndig = 2;
1319  jflag = 1;
1320  shint( &num, &ndig, 1, status );
1321  if( *status == 1 )
1322  {
1323  *status = 0;
1324  goto L_9120;
1325  }
1326  else if( *status == 2 )
1327  {
1328  *status = 0;
1329  goto L_9010;
1330  }
1331  else if( *status == 3 )
1332  {
1333  *status = 0;
1334  goto L_9095;
1335  }
1336 
1337  data_.idcodd = num + numa;
1338  goto L_500;
1339 
1340  /* DI - Time interval for .E format */
1341 
1342 L_360:
1343 
1344  if ( DEBUG1 ) printf("\nshdtype:360 getting DI for increnemtn iflag = %d",*iflag);
1345  if( *iflag != 3 )
1346  goto L_9080;
1347 
1348  if( xchar_.ichar != codes_.ichi )
1349  goto L_9080;
1350 
1351  nextch( &xchar_.ichar, status );
1352  if( *status == 1 )
1353  {
1354  *status = 0;
1355  goto L_9120;
1356  }
1357  else if( *status == 2 )
1358  {
1359  *status = 0;
1360  goto L_9010;
1361  }
1362 
1363  if( xchar_.ichar != codes_.ichs )
1364  goto L_365;
1365  numa = 6000;
1366  if ( DEBUG1 ) printf("\nshdtype:going to 410");
1367  goto L_410;
1368 
1369 L_365:
1370  if ( DEBUG1 ) printf("\nshdtype:at 365");
1371  if( xchar_.ichar != codes_.ichn )
1372  goto L_370;
1373  numa = 0;
1374  goto L_410;
1375 
1376 L_370:
1377  if ( DEBUG1 ) printf("\nshdtype:at 370");
1378  if( xchar_.ichar != codes_.ichh )
1379  goto L_380;
1380  numa = 1000;
1381  goto L_410;
1382 
1383 L_380:
1384  if ( DEBUG1 ) printf("\nshdtype:at 380");
1385  if( xchar_.ichar != codes_.ichd )
1386  goto L_390;
1387  numa = 2000;
1388  goto L_410;
1389 
1390 L_390:
1391  if ( DEBUG1 ) printf("\nshdtype:at 390");
1392  if( xchar_.ichar != codes_.ichm )
1393  goto L_400;
1394  numa = 3000;
1395  goto L_410;
1396 
1397 L_400:
1398  if ( DEBUG1 ) printf("\nshdtype:at 400");
1399  if( xchar_.ichar != codes_.ichy )
1400  goto L_405;
1401  numa = 4000;
1402  goto L_410;
1403 
1404 L_405:
1405  if ( DEBUG1 ) printf("\nshdtype:at 405");
1406  if( xchar_.ichar != codes_.iche )
1407  goto L_9085;
1408  numa = 5000;
1409 
1410  /* Now get the interval */
1411 
1412 L_410:
1413  if ( DEBUG1 ) printf("\nshdtype:at 410");
1414 
1415  ndig = 2;
1416  jflag = 0;
1417  jsign = 1;
1418  nextch( &xchar_.ichar, status );
1419  if( *status == 1 )
1420  {
1421  *status = 0;
1422  goto L_9120;
1423  }
1424  else if( *status == 2 )
1425  {
1426  *status = 0;
1427  goto L_9010;
1428  }
1429 
1430  if( xchar_.ichar != codes_.iplus )
1431  goto L_412;
1432  jflag = 1;
1433  goto L_414;
1434 
1435 L_412:
1436  if ( DEBUG1 ) printf("\nshdtype:at 412");
1437  if( xchar_.ichar != codes_.iminus )
1438  goto L_414;
1439  jsign = -1;
1440  jflag = 1;
1441 
1442 L_414:
1443 
1444  if ( DEBUG1 ) printf("\nshdtype:at 414");
1445  shint( &num, &ndig, jflag, status );
1446  if( *status == 1 )
1447  {
1448  *status = 0;
1449  goto L_9120;
1450  }
1451  else if( *status == 2 )
1452  {
1453  *status = 0;
1454  goto L_9010;
1455  }
1456  else if( *status == 3 )
1457  {
1458  *status = 0;
1459  goto L_420;
1460  }
1461  data_.itz = numa + num*jsign;
1462  goto L_500;
1463 
1464 L_420:
1465  if ( DEBUG1 ) printf("\nshdtype:at 420");
1466  if( ndig == 0 )
1467  goto L_9085;
1468  data_.itz = numa + num*jsign;
1469  goto L_510;
1470 
1471  /* Scan past blanks to the next slash */
1472 
1473 L_500:
1474  if ( DEBUG1 ) printf("\nshdtype:at 500 dtype_.ieee = %d",dtype_.ieee);
1475 
1476  dtype_.ieee = 1;
1477 
1478  nextch( &xchar_.ichar, status );
1479  if( *status == 1 )
1480  {
1481  *status = 0;
1482  goto L_9120;
1483  }
1484  else if( *status == 2 )
1485  {
1486  *status = 0;
1487  goto L_9010;
1488  }
1489 
1490 L_510:
1491  if ( DEBUG1 ) printf("\nshdtype:510 dtype_.ieee = %d iflag = %d",dtype_.ieee,*iflag);
1492  dtype_.ieee = 1;
1493  if( *iflag == 4 )
1494  goto L_600;
1495  if( xchar_.ichar == codes_.iblnk )
1496  goto L_500;
1497  if( xchar_.ichar == codes_.islash )
1498  goto L_25;
1499  goto L_9090;
1500 
1501  /* Not a date or data type element */
1502 
1503 L_600:
1504  if ( DEBUG1 ) printf("\nshdtype:at 600 returning dtype_.ieee = %d iflag = %d",dtype_.ieee,*iflag);
1505  return;
1506 
1507  /* Error returns */
1508 
1509 L_9010:
1510  *status = 2;
1511  return;
1512 
1513 L_9020:
1514  num = 7;
1515  goto L_700;
1516 
1517 L_9030:
1518  num = 8;
1519  goto L_700;
1520 
1521 L_9050:
1522  num = 10;
1523  goto L_700;
1524 
1525 L_9060:
1526  num = 11;
1527  goto L_700;
1528 
1529 L_9070:
1530  num = 12;
1531  goto L_700;
1532 
1533 L_9075:
1534  num = 9;
1535  goto L_700;
1536 
1537 L_9080:
1538  num = 13;
1539  goto L_700;
1540 
1541 L_9085:
1542  num = 27;
1543  goto L_700;
1544 
1545 L_9090:
1546  num = 14;
1547  goto L_700;
1548 
1549 L_9095:
1550  num = 26;
1551 
1552 L_700:
1553  sherr( &num );
1554  if( *iflag != 4 )
1555  format_.nerr = 1;
1556 
1557  *status = 1;
1558  return;
1559 
1560 L_9120:
1561  *status = 3;
1562  return;
1563 
1564 }
void irang(short int *i, short int *min_, short int *max_, short int *status)
Definition: irang.c:33
printf("fbuf is %s\n", fbuf)
int k
Definition: mapp2h.h:48
void nextch(short int *ichar, short int *status)
Definition: nextch.c:76
void shcal(short int *iord, short int *leap, short int *lmon, short int *lday)
Definition: shcal.c:35
void shdtype(short int *iflag, short int *status)
Definition: shdtype.c:72
#define MAX_SHEF_INPUT
Definition: shef.h:38
struct t_dtype_ dtype_
struct t_datim_ datim_
struct t_codes_ codes_
struct t_dotbee_ dotbee_
struct t_datrel_ datrel_
struct t_data_ data_
struct t_buffer_ buffer_
struct t_format_ format_
struct t_xchar_ xchar_
void sherr(short int *ier)
Definition: sherr.c:44
void shint(short int *inum, short int *ndig, short int iflag, short int *status)
Definition: shint.c:37
void shleap(short int *lyear, short int *leap)
Definition: shleap.c:42
void * leap
Definition: shleap.cc:39
void shtdat(short int *lyear, short int *lmon, short int *lday, short int *status)
Definition: shtdat.c:30
short int ip
Definition: shef_structs.h:109
short int ibuf[MAX_SHEF_INPUT]
Definition: shef_structs.h:109
short int iblnk
Definition: shef_structs.h:81
short int iche
Definition: shef_structs.h:78
short int ichq
Definition: shef_structs.h:79
short int ichs
Definition: shef_structs.h:79
short int ichz
Definition: shef_structs.h:80
short int ichy
Definition: shef_structs.h:80
short int ich0
Definition: shef_structs.h:80
short int ichd
Definition: shef_structs.h:78
short int icho
Definition: shef_structs.h:79
short int ichv
Definition: shef_structs.h:80
short int iplus
Definition: shef_structs.h:81
short int ichm
Definition: shef_structs.h:79
short int ichu
Definition: shef_structs.h:80
short int ichc
Definition: shef_structs.h:78
short int islash
Definition: shef_structs.h:81
short int ichi
Definition: shef_structs.h:78
short int icha
Definition: shef_structs.h:78
short int ichh
Definition: shef_structs.h:78
short int ichr
Definition: shef_structs.h:79
short int ichj
Definition: shef_structs.h:79
short int iminus
Definition: shef_structs.h:81
short int ich9
Definition: shef_structs.h:81
short int ichn
Definition: shef_structs.h:79
short int icht
Definition: shef_structs.h:79
short int kcent
Definition: shef_structs.h:178
short int dccentflag
Definition: shef_structs.h:185
short int overcentury
Definition: shef_structs.h:187
short int kodu
Definition: shef_structs.h:181
short int lmon
Definition: shef_structs.h:177
short int overyear
Definition: shef_structs.h:188
short int msource[8]
Definition: shef_structs.h:181
short int khour
Definition: shef_structs.h:178
short int lcent
Definition: shef_structs.h:177
short int kyear
Definition: shef_structs.h:178
short int posoveryear
Definition: shef_structs.h:191
short int lyear
Definition: shef_structs.h:177
short int lsec
Definition: shef_structs.h:177
short int kmin
Definition: shef_structs.h:178
short int lhour
Definition: shef_structs.h:177
short int itz
Definition: shef_structs.h:181
short int kday
Definition: shef_structs.h:178
short int lmin
Definition: shef_structs.h:177
short int idstn[8]
Definition: shef_structs.h:177
short int kmon
Definition: shef_structs.h:178
short int posovercentury
Definition: shef_structs.h:190
short int lday
Definition: shef_structs.h:177
short int overmonth
Definition: shef_structs.h:189
short int idcodd
Definition: shef_structs.h:179
short int kwal
Definition: shef_structs.h:181
short int idate[6]
Definition: shef_structs.h:100
short int msec
Definition: shef_structs.h:132
short int mmon
Definition: shef_structs.h:132
short int mhour
Definition: shef_structs.h:132
short int mcent
Definition: shef_structs.h:132
short int mmin
Definition: shef_structs.h:132
short int myear
Definition: shef_structs.h:132
short int mend
Definition: shef_structs.h:132
short int mday
Definition: shef_structs.h:132
short int nelem
Definition: shef_structs.h:165
short int ieee
Definition: shef_structs.h:168
short int nerr
Definition: shef_structs.h:129
short int ichar
Definition: shef_structs.h:112