Daily_QC
build_list.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 extern _SQCURSOR *_iqnprep();
3 
4 #if !defined(__STDC__)
5 #define const
6 #endif
7 
8 #line 1 "build_list.ec"
9 #include "prototypes.h"
10 /*
11  * EXEC SQL include sqlca.h;
12  */
13 #line 2 "build_list.ec"
14 #line 2 "build_list.ec"
15 #line 1 "/opt/informix/incl/esql/sqlca.h"
16 /***************************************************************************
17  *
18  * INFORMIX SOFTWARE, INC.
19  *
20  * PROPRIETARY DATA
21  *
22  * THIS DOCUMENT CONTAINS TRADE SECRET DATA WHICH IS THE PROPERTY OF
23  * INFORMIX SOFTWARE, INC. THIS DOCUMENT IS SUBMITTED TO RECIPIENT IN
24  * CONFIDENCE. INFORMATION CONTAINED HEREIN MAY NOT BE USED, COPIED OR
25  * DISCLOSED IN WHOLE OR IN PART EXCEPT AS PERMITTED BY WRITTEN AGREEMENT
26  * SIGNED BY AN OFFICER OF INFORMIX SOFTWARE, INC.
27  *
28  * THIS MATERIAL IS ALSO COPYRIGHTED AS AN UNPUBLISHED WORK UNDER
29  * SECTIONS 104 AND 408 OF TITLE 17 OF THE UNITED STATES CODE.
30  * UNAUTHORIZED USE, COPYING OR OTHER REPRODUCTION IS PROHIBITED BY LAW.
31  *
32  *
33  * Title: sqlca.h
34  * Sccsid: @(#)sqlca.h 9.4 1/18/93 11:09:48
35  * Description:
36  * SQL Control Area
37  *
38  ***************************************************************************
39  */
40 
41 #ifndef SQLCA_INCL
42 
43 #define SQLCA_INCL
44 
45 struct sqlca_s
46  {
47  long sqlcode;
48  char sqlerrm[72]; /* error message parameters */
49  char sqlerrp[8];
50  long sqlerrd[6];
51  /* 0 - estimated number of rows returned */
52  /* 1 - serial value after insert or ISAM error code */
53  /* 2 - number of rows processed */
54  /* 3 - estimated cost */
55  /* 4 - offset of the error into the SQL statement */
56  /* 5 - rowid after insert */
57 #ifdef _FGL_
58  char sqlawarn[8];
59 #else
60  struct sqlcaw_s
61  {
62  char sqlwarn0; /* = W if any of sqlwarn[1-7] = W */
63  char sqlwarn1; /* = W if any truncation occurred or
64  database has transactions or
65  no privileges revoked */
66  char sqlwarn2; /* = W if a null value returned or
67  ANSI database */
68  char sqlwarn3; /* = W if no. in select list != no. in into list or
69  turbo backend or no privileges granted */
70  char sqlwarn4; /* = W if no where clause on prepared update, delete or
71  incompatible float format */
72  char sqlwarn5; /* = W if non-ANSI statement */
73  char sqlwarn6; /* = W if server is in data replication secondary mode */
74  char sqlwarn7; /* = W if database locale is different from proc_locale
75  */
77 #endif
78  };
79 
80 /* NOTE: 4gl assumes that the sqlwarn structure can be defined as
81  * sqlawarn -- an 8 character string, because single-char
82  * variables are not recognized in 4gl.
83  *
84  * If this structure should change, the code generated by 4gl compiler
85  * must also change
86  */
87 
88 #ifdef VMS
89 noshare
90 #endif /* VMS */
91 
92 #ifndef IFX_THREAD
93 extern struct sqlca_s sqlca;
94 
95 extern long SQLCODE;
96 
97 extern char SQLSTATE[];
98 #else /* IFX_THREAD */
99 
100 #ifndef __cplusplus
101 extern long * ifx_sqlcode();
102 extern struct sqlca_s * ifx_sqlca();
103 #endif
104 
105 #define SQLCODE (*(ifx_sqlcode()))
106 #define SQLSTATE ((char *)(ifx_sqlstate()))
107 #define sqlca (*(ifx_sqlca()))
108 #endif /* IFX_THREAD */
109 
110 #define SQLNOTFOUND 100
111 
112 #endif /* SQLCA_INCL */
113 #line 97 "/opt/informix/incl/esql/sqlca.h"
114 #line 3 "build_list.ec"
115 
116 /*
117  * EXEC SQL BEGIN DECLARE SECTION;
118  */
119 #line 4 "build_list.ec"
120 
121 #line 5 "build_list.ec"
122 char t, s, pe1, pe2, dur;
123 char sbuf[10];
124 struct etn_rec
125  {
126  char id[6];
127  char plat[9];
128  char des[51];
129  char det[41];
130  char init[9];
131  char lat[7];
132  char lng[8];
133  int elev;
134  char stat[3];
135  char huc[9];
136  char cou[4];
137  char zon[5];
138  char hsa[4];
139  char cwa[4];
140  int post;
141  char dbsource[4];
143 /*
144  * EXEC SQL END DECLARE SECTION;
145  */
146 #line 30 "build_list.ec"
147 
148 
149 void main(int argc, char **argv)
150 
151 {
152 int i,j,h;
153 struct stim btim;
154 struct stim etim;
155 struct stim btim1;
156 struct stim etim1;
157 struct stim etim2;
158 char oldstat[10];
159 char *s[5];
160 FILE *fp,*fw;
161 char pc[10];
162 char qual[10];
163 int k;
164 char mbuf[100];
165 char dbuf[80],ts1[80];
166 char ozon[20];
167 char zbuf[1000],abuf[100];
168 char name[60];
169 int zdate[10],ztime[10];
170 int bflag;
171 char *add,file[50],*key;
172 int maxdays;
173 time_t itime[20];
174 int qtotal,dtotal;
175 extern int optind,opterr,optopt;
176 extern char *optarg;
177 int c;
178 char *p,*q;
179 int month,day,year,hour,idflag;
180 char *directory,fname[50];
181 int fflag;
182 time_t tim2;
183 int qual_flag;
184 char qbuf[10];
185 double flng,flat;
186 int itemp,itemp1,itemp2,ival,len;
187 int l,ii;
188 int tip;
189 
190 fp=fopen("junkfile","r");
191 
192 fw=fopen("outfile","w");
193 
194 /*
195  * EXEC SQL database fastetc;
196  */
197 #line 77 "build_list.ec"
198  {
199 #line 77 "build_list.ec"
200  _iqdbase("fastetc", 0);
201 #line 77 "build_list.ec"
202  }
203 
204 if(sqlca.sqlcode < 0){
205 
206  printf("informix error %d\n",sqlca.sqlcode);
207  exit(1);
208 
209  }
210 
211 for(;;) {
212 
213 
214  p=fgets(sbuf,80,fp);
215 
216  if(p==NULL)
217  break;
218 
219 
220  printf("here it is %s\n",sbuf);
221 
222  sbuf[5]=0;
223 
224 
225 /*
226  * EXEC SQL select *
227  * into :btn_rec
228  * from stn
229  * where id=:sbuf;
230  */
231 #line 100 "build_list.ec"
232  {
233 #line 100 "build_list.ec"
234  static const char *sqlcmdtxt[] =
235 #line 100 "build_list.ec"
236  {
237 #line 100 "build_list.ec"
238  " select * from stn where id = ?",
239  0
240  };
241 #line 103 "build_list.ec"
242  static _SQCURSOR _SQ0 = {0};
243  static struct sqlvar_struct _sqibind[] =
244  {
245  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
246 #line 103 "build_list.ec"
247  };
248  static struct sqlvar_struct _sqobind[] =
249  {
250  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
251  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
252  { 100, 51, 0, 0, 0, 0, 0, 0, 0 },
253  { 100, 41, 0, 0, 0, 0, 0, 0, 0 },
254  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
255  { 100, 7, 0, 0, 0, 0, 0, 0, 0 },
256  { 100, 8, 0, 0, 0, 0, 0, 0, 0 },
257  { 102, sizeof((btn_rec).elev), 0, 0, 0, 0, 0, 0, 0 },
258  { 100, 3, 0, 0, 0, 0, 0, 0, 0 },
259  { 100, 9, 0, 0, 0, 0, 0, 0, 0 },
260  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
261  { 100, 5, 0, 0, 0, 0, 0, 0, 0 },
262  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
263  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
264  { 102, sizeof((btn_rec).post), 0, 0, 0, 0, 0, 0, 0 },
265  { 100, 4, 0, 0, 0, 0, 0, 0, 0 },
266 #line 103 "build_list.ec"
267  };
268 #line 103 "build_list.ec"
269  _sqibind[0].sqldata = sbuf;
270 #line 103 "build_list.ec"
271  _sqobind[0].sqldata = (btn_rec).id;
272 #line 103 "build_list.ec"
273  _sqobind[1].sqldata = (btn_rec).plat;
274 #line 103 "build_list.ec"
275  _sqobind[2].sqldata = (btn_rec).des;
276 #line 103 "build_list.ec"
277  _sqobind[3].sqldata = (btn_rec).det;
278 #line 103 "build_list.ec"
279  _sqobind[4].sqldata = (btn_rec).init;
280 #line 103 "build_list.ec"
281  _sqobind[5].sqldata = (btn_rec).lat;
282 #line 103 "build_list.ec"
283  _sqobind[6].sqldata = (btn_rec).lng;
284 #line 103 "build_list.ec"
285  _sqobind[7].sqldata = (char *) &(btn_rec).elev;
286 #line 103 "build_list.ec"
287  _sqobind[8].sqldata = (btn_rec).stat;
288 #line 103 "build_list.ec"
289  _sqobind[9].sqldata = (btn_rec).huc;
290 #line 103 "build_list.ec"
291  _sqobind[10].sqldata = (btn_rec).cou;
292 #line 103 "build_list.ec"
293  _sqobind[11].sqldata = (btn_rec).zon;
294 #line 103 "build_list.ec"
295  _sqobind[12].sqldata = (btn_rec).hsa;
296 #line 103 "build_list.ec"
297  _sqobind[13].sqldata = (btn_rec).cwa;
298 #line 103 "build_list.ec"
299  _sqobind[14].sqldata = (char *) &(btn_rec).post;
300 #line 103 "build_list.ec"
301  _sqobind[15].sqldata = (btn_rec).dbsource;
302 #line 103 "build_list.ec"
303  _iqslct(&_SQ0, (char **) sqlcmdtxt, 1, _sqibind, 16, _sqobind, 0);
304 #line 103 "build_list.ec"
305  }
306 
307 
308  if(sqlca.sqlcode < 0){
309 
310  printf("informix error %d\n",sqlca.sqlcode);
311  exit(1);
312 
313  }
314 
315  if(sqlca.sqlcode != 0) {
316  printf("no hb5 entry %s\n",sbuf);
317  continue;
318  }
319 
320 
321  strcpy(name,btn_rec.des);
322 
323  ival=atoi(btn_rec.lat);
324  len=strlen(btn_rec.lat);
325 
326  if(ival < 10000) {
327 
328  itemp=ival/100;
329 
330  itemp1=ival-itemp*100;
331 
332  flat=(float)itemp+(float)itemp1/60;
333 
334 
335  }
336 
337  else if(ival > 10000) {
338 
339  itemp=ival/10000;
340 
341  itemp1=(ival-itemp*10000)/100;
342 
343  itemp2=ival-itemp*10000-itemp1*100;
344 
345  flat=(float)itemp+(float)itemp1/60 + (float)itemp2/3600;
346 
347 
348 
349  }
350 
351  else {
352 
353  printf("error\n");
354 
355  continue;
356 
357  }
358 
359 
360  ival=atoi(btn_rec.lng);
361  len=strlen(btn_rec.lng);
362 
363  if(ival < 100000) {
364 
365  itemp=ival/100;
366 
367  itemp1=ival-itemp*100;
368 
369  flng=(float)itemp+(float)itemp1/60;
370 
371 
372  }
373 
374  else if(ival >=100000) {
375 
376  itemp=ival/10000;
377 
378  itemp1=(ival-itemp*10000)/100;
379 
380  itemp2=ival-itemp*10000-itemp1*100;
381 
382  flng=(float)itemp+(float)itemp1/60 + (float)itemp2/3600;
383 
384  }
385 
386 
387  btn_rec.des[20]=0;
388 
389  fprintf(fw,"%s %5.2f %6.2f %4d. 01 CARD %s\n",
390  sbuf,flat,flng,btn_rec.elev,btn_rec.des);
391 
392  fprintf(fw,"lasvegas/%s.PPH5RZZ\n",sbuf);
393 
394 
395  }
396 
397 fclose(fw);
398 fclose(fp);
399 
400 
401 }
402 
403 
404 #line 200 "build_list.ec"
char sbuf[10]
Definition: build_list.c:123
long SQLCODE
char pe2
Definition: build_list.c:122
char s
Definition: build_list.c:122
void main(int argc, char **argv)
Definition: build_list.c:149
char pe1
Definition: build_list.c:122
char SQLSTATE[]
struct sqlca_s sqlca
_SQCURSOR * _iqnprep()
char dur
Definition: build_list.c:122
char t
Definition: build_list.c:122
struct etn_rec btn_rec
int maxdays
Definition: daily_qc.c:85
time_t btim
Definition: daily_qc.c:140
int hour
Definition: display_data.c:30
char qual[10]
Definition: display_data.c:29
int day
Definition: display_data.c:30
struct stim etim
Definition: display_data.c:21
int year
Definition: display_data.c:30
int month
Definition: display_data.c:30
printf("pcp %d\n", pcp_in_use[103])
exit(1)
char det[41]
Definition: build_list.c:129
char huc[9]
Definition: build_list.c:135
char init[9]
Definition: build_list.c:130
int elev
Definition: build_list.c:133
char plat[9]
Definition: build_list.c:127
char des[51]
Definition: build_list.c:128
char lng[8]
Definition: build_list.c:132
char cwa[4]
Definition: build_list.c:139
char dbsource[4]
Definition: build_list.c:141
char lat[7]
Definition: build_list.c:131
char cou[4]
Definition: build_list.c:136
char zon[5]
Definition: build_list.c:137
int post
Definition: build_list.c:140
char hsa[4]
Definition: build_list.c:138
char stat[3]
Definition: build_list.c:134
long sqlerrd[6]
Definition: build_list.c:50
long sqlcode
Definition: build_list.c:47
struct sqlca_s::sqlcaw_s sqlwarn
char sqlerrm[72]
Definition: build_list.c:48
char sqlerrp[8]
Definition: build_list.c:49
Definition: misc.h:55