Mapper
shdecb.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 06/07/94 at 16:59:59 */
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 SHDECB(IREV,STATUS)
20 
21  PURPOSE
22  Decode SHEF .B Format
23  IREV = 1 for Revised, IREV = 0 for New Data
24 
25  VERSION and UPDATES
26  1.0 AUG 82 Geoffrey M. Bonnin
27  Original Version
28  1.1 JAN 84
29  Force Error for No .END at end of file
30  1.2 AUG 84
31  Add seconds to time
32  1.3 NOV 84
33  Virtual buffering of DOTBTEMP
34  1.4 MAR 86
35  Fix error in subsequent revision continuation
36  2.0 JUN 94 David G. Brandon
37  Also Translated to 'C' using FOR_C
38  Removed alternate returns in subroutines
39  2.1 Add iscore to t_codes array.
40  2.2 JAN 24 96 DGB
41  Add lcent to data_ structure to accomodate century.
42  2.3x SEP 10 97 DGB
43  Add the use of MAX_SHEF_INPUT so that the input line can
44  be longer than 80 characters.
45  2.4 JAN 18 99 DGB
46  Add changes so that century and year can be determined
47  correctly if there is no explicit century/year specified
48  in the positional data, but overrides do occur.
49 
50  *--------------------------------------------------------------------- */
51 
52 void shdecb(irev, status)
53 short int *irev, *status;
54 {
55  int DEBUG1;
56  static short int _i0, ibod, idote, iend_, lerr, num, flag;
57  static double factor;
58 
59  /* OFFSET Vectors w/subscript range: 1 to dimension */
60  short *const Idate = &datim_.idate[0] - 1; /* dgb cent */
61  short *const Ibuf = &buffer_.ibuf[0] - 1;
62  short *const Idstn = &data_.idstn[0] - 1;
63  short *const Msource = &data_.msource[0] - 1;
64 
65  DEBUG1 = 0;
66  if ( DEBUG1 ) printf("\nshdecb:begin");
67  /* Initialise */
68 
69  Msource[1] = codes_.iblnk; /* dgb:09/10/97 */
70  Msource[2] = codes_.iblnk; /* dgb:09/10/97 */
71  Msource[3] = codes_.iblnk; /* dgb:09/10/97 */
72  Msource[4] = codes_.iblnk; /* dgb:09/10/97 */
73  Msource[5] = codes_.iblnk; /* dgb:09/10/97 */
74  Msource[6] = codes_.iblnk; /* dgb:09/10/97 */
75  Msource[7] = codes_.iblnk; /* dgb:09/10/97 */
76  Msource[8] = codes_.iblnk; /* dgb:09/10/97 */
77 
78  *status = 0;
79  data_.itz = 0;
80  idote = 0;
81  lerr = 0;
82  ibod = 0;
83 
84  /* get default century */
85  data_.lcent = ( Idate[3]/100 ) ; /* dgb cent */
86 
87  /* Check for Continuation */
88 
89  if( format_.iform > 0 )
90  goto L_10;
92  if( (format_.lform != 3) && (format_.lform != 4) )
93  goto L_9020;
94  if( (format_.iform == 4) && (format_.lform == 3) )
95  goto L_9030;
96  if( (format_.iform == 3) && (format_.lform == 4) )
97  *irev = 1;
98  if( (format_.iform == 3) && (format_.lform == 4) )
99  format_.iform = 4;
100  if( format_.nerr > 0 )
101  goto L_9040;
102  goto L_30;
103 
104  /* Defaults */
105 
106 L_10:
107  data_.kcent = 0; /* dgb cent */
108  data_.kyear = 0;
109  data_.kmon = 0;
110  data_.kday = 0;
111  data_.khour = 0;
112  data_.kmin = 0;
113  data_.ksec = 0;
114  data_.kwal = codes_.ichz;
115  data_.kodu = 1;
116  datrel_.mcent = 0; /* dgb cent */
117  datrel_.myear = 0;
118  datrel_.mmon = 0;
119  datrel_.mday = 0;
120  datrel_.mhour = 0;
121  datrel_.mmin = 0;
122  datrel_.msec = 0;
123  datrel_.mend = 0;
124  data_.idcodd = 5000;
125  dotbee_.nerror = 0;
126  luns_.mrec = 0;
127  format_.nerr = 0;
128  bbuf1_.nmrec = 0;
129 
130  /* Get the Positional Data */
131 
132 
133  shpos( status );
134  if( *status == 1 )
135  {
136  *status = 0;
137  goto L_9050;
138  }
139  else if( *status == 2 )
140  {
141  *status = 0;
142  goto L_9010;
143  }
144 
145  /* Get the Date and Data Type Elements */
146 
147 L_30:
148 
149  flag = 2;
150  shdtype( &flag, status );
151  if( *status == 1 )
152  {
153  *status = 0;
154  goto L_150;
155  }
156  else if( *status == 2 )
157  {
158  *status = 0;
159  goto L_9010;
160  }
161  else if( *status == 3 )
162  {
163  *status = 0;
164  goto L_130;
165  }
166 
167  /* Get the Parameter Code */
168 
169 
171  &data_.kods, &data_.kodex, &data_.codp, &factor, status );
172  if( *status == 1 )
173  {
174  *status = 0;
175  goto L_150;
176  }
177  else if( *status == 2 )
178  {
179  *status = 0;
180  goto L_9010;
181  }
182  else if( *status == 3 )
183  {
184  *status = 0;
185  goto L_50;
186  }
187  iend_ = 0;
188  if( xchar_.ichar == codes_.iblnk )
189  goto L_90;
190  if( xchar_.ichar == codes_.islash )
191  goto L_90;
192  goto L_9080;
193 L_50:
194  iend_ = 1;
195 
196  /* Write the Data to the Buffer */
197 
198 L_90:
199  if ( data_.posoveryear > -1 && data_.posovercentury == -1 ) /*dgb:01/18/99 */
200  {
201  if ( data_.posoveryear < 30 )
202  data_.lyear = data_.posoveryear + 2000;
203  else
204  data_.lyear = data_.posoveryear + 1900;
205  /*
206  if ( data_.lcent == 19 && data_.lyear < 1930 )
207  data_.lyear = ( data_.lyear - ((int) data_.lyear/100 )*100) + 2000;
208  */
209  }
210 
211  /* dgb add data_.lcent, data_.kcent, datrel_.mcent */
218  &data_.kwal, &data_.nadjtz, &data_.kodu, &factor, irev, &durprob_.kodd,
219  &durprob_.kodpr );
220 
221  data_.posoveryear = -1; /* dgb:01/18/99 */
222  data_.posovercentury = -1; /* dgb:01/18/99 */
223 
224  luns_.mrec = luns_.mrec + 1;
225  if( iend_ == 1 )
226  goto L_130;
227  goto L_120;
228 
229  /* Clear Past the Next Slash */
230 
231 L_110:
232 
233  nextch( &xchar_.ichar, status );
234  if( *status == 1 )
235  {
236  *status = 0;
237  goto L_130;
238  }
239  else if( *status == 2 )
240  {
241  *status = 0;
242  goto L_9010;
243  }
244 L_120:
245  if( xchar_.ichar == codes_.iblnk )
246  goto L_110;
247  if( xchar_.ichar != codes_.islash )
248  goto L_9080;
249  nextch( &xchar_.ichar, status );
250  if( *status == 1 )
251  {
252  *status = 0;
253  goto L_130;
254  }
255  else if( *status == 2 )
256  {
257  *status = 0;
258  goto L_9010;
259  }
260  goto L_30;
261 
262  /* Check Next Line to See if it Should be Searched for Data */
263 
264 L_125:
265 
266  buffer_.ip = MAX_SHEF_INPUT + 1; /* dgb:09/10/97 */
267 
268 L_130:
269 
270  nextch( &xchar_.ichar, status );
271  if( *status == 1 )
272  {
273  *status = 0;
274  goto L_130;
275  }
276  else if( *status == 2 )
277  {
278  *status = 0;
279  goto L_9010;
280  }
281  if( xchar_.ichar != codes_.idot )
282  goto L_140;
283  nextch( &xchar_.ichar, status );
284  if( *status == 1 )
285  {
286  *status = 0;
287  goto L_9060;
288  }
289  else if( *status == 2 )
290  {
291  *status = 0;
292  goto L_9010;
293  }
294  if( xchar_.ichar != codes_.iche )
295  goto L_135;
296  nextch( &xchar_.ichar, status );
297  if( *status == 1 )
298  {
299  *status = 0;
300  goto L_9060;
301  }
302  else if( *status == 2 )
303  {
304  *status = 0;
305  goto L_9010;
306  }
307  if( xchar_.ichar != codes_.ichn )
308  goto L_9070;
309  nextch( &xchar_.ichar, status );
310  if( *status == 1 )
311  {
312  *status = 0;
313  goto L_9060;
314  }
315  else if( *status == 2 )
316  {
317  *status = 0;
318  goto L_9010;
319  }
320  if( xchar_.ichar != codes_.ichd )
321  goto L_9070;
322  goto L_900;
323 
324 L_135:
325 
326  if( ibod == 1 )
327  goto L_9070;
328  if( xchar_.ichar != codes_.ichb )
329  goto L_9070;
330  nextch( &xchar_.ichar, status );
331  if( *status == 1 )
332  {
333  *status = 0;
334  goto L_9060;
335  }
336  else if( *status == 2 )
337  {
338  *status = 0;
339  goto L_9010;
340  }
341  irang( &xchar_.ichar, &codes_.ich1, &codes_.ich9, status );
342  if( *status == 1 )
343  {
344  *status = 0;
345  goto L_137;
346  }
347  goto L_139;
348 
349 L_137:
350  if( xchar_.ichar != codes_.ichr )
351  goto L_9070;
352  nextch( &xchar_.ichar, status );
353  if( *status == 1 )
354  {
355  *status = 0;
356  goto L_9060;
357  }
358  else if( *status == 2 )
359  {
360  *status = 0;
361  goto L_9010;
362  }
363  irang( &xchar_.ichar, &codes_.ich1, &codes_.ich9, &_i0 );
364  switch( _i0 )
365  {
366  case 1: goto L_9070;
367  }
368  if( *status == 1 )
369  {
370  *status = 0;
371  goto L_9070;
372  }
373 
374 L_139:
375  buffer_.ip = 0;
376  nextch( &xchar_.ichar, status );
377  if( *status == 1 )
378  {
379  *status = 0;
380  goto L_9060;
381  }
382  else if( *status == 2 )
383  {
384  *status = 0;
385  goto L_9010;
386  }
387  *status = 3;
388  return;
389 
390 L_140:
391  ibod = 1;
392  shdotb( status );
393  if( *status == 1 )
394  {
395  *status = 0;
396  goto L_160;
397  }
398  else if( *status == 2 )
399  {
400  *status = 0;
401  goto L_9010;
402  }
403 
404  lerr = 0;
405  goto L_130;
406 
407  /* Error Checking */
408 
409 L_150:
411 L_160:
412  if( lerr == 1 )
413  goto L_9000;
414  lerr = 1;
415  if( dotbee_.nerror >= 3 )
416  goto L_9000;
417  goto L_125;
418 
419 
420 L_900:
421  return;
422 
423  /* Error Return - Stop Looking at this Format */
424 
425 L_9000:
426  *status = 1;
427  return;
428 
429  /* Error Return - Stop Looking at this File */
430 
431 L_9010:
432  flag = 34;
433  sherr( &flag );
434  *status = 2;
435  return;
436 
437 L_9020:
438  num = 19;
439  goto L_9200;
440 
441 L_9030:
442  num = 20;
443  goto L_9200;
444 
445 L_9040:
446  flag = 21;
447  sherr( &flag );
448  goto L_125;
449 
450 L_9050:
451  format_.nerr = 1;
452  goto L_9000;
453 
454 L_9060:
455  num = 34;
456  goto L_9200;
457 
458 L_9070:
459  buffer_.ip = 0;
460  nextch( &xchar_.ichar, status );
461  if( *status == 1 )
462  {
463  *status = 0;
464  goto L_9060;
465  }
466  else if( *status == 2 )
467  {
468  *status = 0;
469  goto L_9010;
470  }
471  flag = 34;
472  sherr( &flag );
473  *status = 3;
474  return;
475 
476 L_9080:
477  flag = 31;
478  sherr( &flag );
479  format_.nerr = 1;
480  goto L_125;
481 
482 L_9200:
483  sherr( &num );
484  goto L_9000;
485 
486 }
487 
488 
void irang(short int *i, short int *min_, short int *max_, short int *status)
Definition: irang.c:33
printf("fbuf is %s\n", fbuf)
void nextch(short int *ichar, short int *status)
Definition: nextch.c:76
void shbfw(msource, *lcent, *lyear, *lmon, *lday, *lhour, *lmin, *lsec, *kcent, *kyear, *kmon, *kday, *khour, *kmin, *ksec, *mcent, *myear, *mmon, *mday, *mhour, *mmin, *msec, *mend, *kodp, *kode, *icodd, *idcodd, *kodt, *kods, *kodex, float *codp, short int *kwal, short int *nadjtz, short int *kodu, double *factor, short int *irev, short int *kodd, short int *kodpr)
Definition: shbfw.c:41
void shdecb(short int *irev, short int *status)
Definition: shdecb.c:52
void shdotb(short int *status)
Definition: shdotb.c:112
void shdtype(short int *iflag, short int *status)
Definition: shdtype.c:72
#define MAX_SHEF_INPUT
Definition: shef.h:38
struct t_luns luns_
struct t_datim_ datim_
struct t_codes_ codes_
struct t_dotbee_ dotbee_
struct t_bbuf1_ bbuf1_
struct t_datrel_ datrel_
struct t_data_ data_
struct t_buffer_ buffer_
struct t_format_ format_
struct t_xchar_ xchar_
struct t_durprob_ durprob_
void sherr(short int *ier)
Definition: sherr.c:44
void shpcode(short int *kodp, short int *kode, short int *icodd, short int *kodt, short int *kods, short int *kodex, float *codp, double *factor, short int *status)
Definition: shpcode.c:43
void shpos(short int *status)
Definition: shpos.c:62
short int nmrec
Definition: shef_structs.h:118
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 ichz
Definition: shef_structs.h:80
short int ichd
Definition: shef_structs.h:78
short int islash
Definition: shef_structs.h:81
short int ich1
Definition: shef_structs.h:80
short int ichr
Definition: shef_structs.h:79
short int ich9
Definition: shef_structs.h:81
short int ichn
Definition: shef_structs.h:79
short int ichb
Definition: shef_structs.h:78
short int idot
Definition: shef_structs.h:82
short int kcent
Definition: shef_structs.h:178
short int kodu
Definition: shef_structs.h:181
short int lmon
Definition: shef_structs.h:177
short int kods
Definition: shef_structs.h:179
short int msource[8]
Definition: shef_structs.h:181
short int ksec
Definition: shef_structs.h:178
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 icodd
Definition: shef_structs.h:178
short int kodex
Definition: shef_structs.h:179
short int posoveryear
Definition: shef_structs.h:191
short int nadjtz
Definition: shef_structs.h:181
float codp
Definition: shef_structs.h:180
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 kodt
Definition: shef_structs.h:179
short int kmon
Definition: shef_structs.h:178
short int posovercentury
Definition: shef_structs.h:190
short int kodp
Definition: shef_structs.h:178
short int lday
Definition: shef_structs.h:177
short int idcodd
Definition: shef_structs.h:179
short int kode
Definition: shef_structs.h:178
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 nerror
Definition: shef_structs.h:165
short int kodd
Definition: shef_structs.h:97
short int kodpr
Definition: shef_structs.h:97
short int lform
Definition: shef_structs.h:129
short int nerr
Definition: shef_structs.h:129
short int iform
Definition: shef_structs.h:129
short int mrec
Definition: shef_structs.h:215
short int ichar
Definition: shef_structs.h:112