Mapper
exp.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 extern _SQCURSOR *_iqnprep();
3 static char *_Cn2 = "sensorcursor"; static _SQCURSOR *_SQ2 = 0;
4 static char *_Cn1 = "selectsensor"; static _SQCURSOR *_SQ1 = 0;
5 #line 1 "exp.ec"
6 #include <stdio.h>
7 #include "rate_table.h"
8 #include "math.h"
9 /*
10  * EXEC SQL include sqlca.h;
11  */
12 #line 4 "exp.ec"
13 #line 1 "/usr/informix/incl/esql/sqlca.h"
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 #ifndef SQLCA_INCL
40 
41 #define SQLCA_INCL
42 
43 struct sqlca_s
44  {
45  long sqlcode;
46  char sqlerrm[72];
47  char sqlerrp[8];
48  long sqlerrd[6];
49 
50 
51 
52 
53 
54 
55  struct sqlcaw_s
56  {
57  char sqlwarn0;
58  char sqlwarn1;
59 
60  char sqlwarn2;
61 
62  char sqlwarn3;
63 
64  char sqlwarn4;
65 
66  char sqlwarn5;
67  char sqlwarn6;
68  char sqlwarn7;
69  } sqlwarn;
70  };
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 #ifdef VMS
81 noshare
82 #endif
83 extern struct sqlca_s sqlca;
84 
85 extern long SQLCODE;
86 
87 #define SQLNOTFOUND 100
88 
89 #endif
90 #line 5 "exp.ec"
91 
93 {
94 FILE *fp;
95 int err, flow, warning,i,j;
96 double stage;
98 char c;
99 
100 /*
101  * EXEC SQL BEGIN DECLARE SECTION;
102  */
103 #line 14 "exp.ec"
104 
105 char astring[10];
106 char ihb5[10];
107 /*
108  * EXEC SQL END DECLARE SECTION;
109  */
110 #line 18 "exp.ec"
111 
112 
113 /*
114  * EXEC SQL database rawdb;
115  */
116 #line 20 "exp.ec"
117  {
118 #line 20 "exp.ec"
119  _iqdbase("rawdb", 0);
120 #line 20 "exp.ec"
121  }
122 
123 strcpy(astring, "H");
124 
125 i=0;
126 while(astring[i] !=0)
127  astring[i++]=toupper(astring[i]);
128 
129 /*
130  * EXEC SQL prepare selectsensor from
131  * "select id
132  * from sens
133  * where pe1 matches ?";
134  */
135 #line 28 "exp.ec"
136  {
137 #line 28 "exp.ec"
138 #line 28 "exp.ec"
139  _SQ1 = _iqnprep(_Cn1, "select id from sens where pe1 matches ?", 0);
140 #line 31 "exp.ec"
141  }
142 
143 if(sqlca.sqlcode < 0)
144  return(sqlca.sqlcode);
145 
146 /*
147  * EXEC SQL declare sensorcursor cursor for selectsensor;
148  */
149 #line 36 "exp.ec"
150  {
151 #line 36 "exp.ec"
152 #line 36 "exp.ec"
153  if (!_SQ2) _SQ2 = _iqlocate_cursor(_Cn2, 0, 0, 0);
154 #line 36 "exp.ec"
155  if (!_SQ1) _SQ1 = _iqlocate_cursor(_Cn1, 1, 1, 0);
156 #line 36 "exp.ec"
157  _iqcddcl(_SQ2, _Cn2, _SQ1, 0);
158 #line 36 "exp.ec"
159  }
160 
161 if(sqlca.sqlcode < 0)
162  return(sqlca.sqlcode);
163 
164 /*
165  * EXEC SQL open sensorcursor using: astring;
166  */
167 #line 41 "exp.ec"
168  {
169 #line 41 "exp.ec"
170  static struct sqlvar_struct _sqibind[] =
171  {
172  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
173 #line 41 "exp.ec"
174  };
175  static struct sqlda _SD0 = { 1, _sqibind, 0, 1, 0 };
176 #line 41 "exp.ec"
177  _sqibind[0].sqldata = astring;
178 #line 41 "exp.ec"
179  if (!_SQ2) _SQ2 = _iqlocate_cursor(_Cn2, 0, 1, 0);
180 #line 41 "exp.ec"
181  _iqdcopen(_SQ2, &_SD0, (char *)0, (char *)0, 1);
182 #line 41 "exp.ec"
183  }
184 
185 if(sqlca.sqlcode < 0)
186  return(sqlca.sqlcode);
187 
188 if ((fp = fopen("rc","w"))== NULL)
189  printf("\nunable to open rc\n");
190 
191 fprintf(fp,"\nDEF-RC");
192 for(i=0;i<1000;i++)
193  {
194 /*
195  * EXEC SQL fetch sensorcursor into :ihb5;
196  */
197 #line 52 "exp.ec"
198  {
199 #line 52 "exp.ec"
200  static struct sqlvar_struct _sqobind[] =
201  {
202  { 100, 10, 0, 0, 0, 0, 0, 0, 0 },
203 #line 52 "exp.ec"
204  };
205  static struct sqlda _SD0 = { 1, _sqobind, 0, 1, 0 };
206  static _FetchSpec _FS1 = { 0, 1, 0 };
207 #line 52 "exp.ec"
208  _sqobind[0].sqldata = ihb5;
209 #line 52 "exp.ec"
210  if (!_SQ2) _SQ2 = _iqlocate_cursor(_Cn2, 0, 1, 0);
211 #line 52 "exp.ec"
212  _iqcftch(_SQ2, (struct sqlda *)0, &_SD0, (char *)0, &_FS1);
213 #line 52 "exp.ec"
214  }
215 
216  if(sqlca.sqlcode < 0)
217  return(sqlca.sqlcode);
218 
219  if(sqlca.sqlcode !=0)
220  break;
221 
222 printf("\nihb5 is %s\n", ihb5);
223 
224 rate_table = getrc(ihb5,19020126, &warning);
225 
226 printf("HI2\n");
227 
228 fprintf(fp,"\n%s REPLHQ\n %d ENGL %5.2lf",
230 
231 for ( j = 0; j < rate_table.AryMax; j++)
232  {
233  if(rate_table.RatStg[j] != 0)
234  {
235  if(j%3 == 0)
236  fprintf(fp,"\n");
237  fprintf(fp," %5.2lf %5d",
239  }
240  }
241 }
242 
243 fprintf(fp, "\nEND\n");
244 
245 /*
246  * EXEC SQL close sensorcursor;
247  */
248 #line 83 "exp.ec"
249  {
250 #line 83 "exp.ec"
251 #line 83 "exp.ec"
252  if (!_SQ2) _SQ2 = _iqlocate_cursor(_Cn2, 0, 1, 0);
253 #line 83 "exp.ec"
254  _iqclose(_SQ2);
255 #line 83 "exp.ec"
256  }
257 
258 exit(1);
259 }
static int i
static _SQCURSOR * _SQ2
Definition: exp.c:3
long SQLCODE
static char * _Cn2
Definition: exp.c:3
main()
Definition: exp.c:92
static _SQCURSOR * _SQ1
Definition: exp.c:4
struct sqlca_s sqlca
static char * _Cn1
Definition: exp.c:4
_SQCURSOR * _iqnprep()
char astring[50]
RatingTable getrc(char *, char, char, int, int *)
Definition: rat.c:2343
static RatingTable rate_table
Definition: rat.c:131
printf("fbuf is %s\n", fbuf)
fp
Definition: make_NEXRAD.c:339
fprintf(fp,"%d %d %d %d 1\n", iminx, iminy, maxi, maxj)
int j
Definition: mapp2h.h:48
int RatQ[100]
Definition: rate_table.h:13
double HMin
Definition: rate_table.h:15
double RatStg[100]
Definition: rate_table.h:12
char sqlwarn5
Definition: db.c:65
char sqlwarn3
Definition: db.c:61
char sqlwarn4
Definition: db.c:63
char sqlwarn7
Definition: db.c:67
char sqlwarn1
Definition: db.c:57
char sqlwarn6
Definition: db.c:66
char sqlwarn2
Definition: db.c:59
char sqlwarn0
Definition: db.c:56
Definition: db.c:43
long sqlerrd[6]
Definition: db.c:47
struct sqlca_s::sqlcaw_s sqlwarn
long sqlcode
Definition: db.c:44
char sqlerrm[72]
Definition: db.c:45
char sqlerrp[8]
Definition: db.c:46