Mapper
get_sensor_info.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 static const char _Cn2[] = "loop_c";
4 static const char _Cn1[] = "qid";
5 #line 1 "get_sensor_info.ec"
6 #include "prototypes.h"
7 
8 int get_sensor_info(char *stn_id, char *shef, struct sensor_file *sfile)
9 {
10 /* general variable definitions */
11 char *caller="get_stn_info: ";
12 char deg[3];
13 char min[2];
14 char sec[2];
15 
16 /* declare informix host variables */
17 /*
18  * exec sql begin declare section;
19  */
20 #line 12 "get_sensor_info.ec"
21 #line 13 "get_sensor_info.ec"
22  char query[1000];
23  char stn_des[31];
24  char stn_lat[7];
25  char stn_lon[8];
26 int stn_elev;
27 /*
28  * exec sql end declare section;
29  */
30 #line 18 "get_sensor_info.ec"
31 
32 
33 /* build loop to find the entry for station */
34 sprintf(query,"select elev, lat, lng, des from stn where "
35  "id = \"%s\" ", stn_id);
36 
37 /*
38  * $prepare qid from $query;
39  */
40 #line 24 "get_sensor_info.ec"
41  {
42 #line 24 "get_sensor_info.ec"
43  sqli_prep(ESQLINTVERSION, _Cn1, query,(ifx_literal_t *)0, (ifx_namelist_t *)0, -1, 0, 0 );
44 #line 24 "get_sensor_info.ec"
45  }
46 if(sqlca.sqlcode)
47 {
48  printf("%sprepare qid (%d)\n",caller,sqlca.sqlcode);
49  return(-1);
50 }
51 
52 /*
53  * $declare loop_c cursor for qid;
54  */
55 #line 31 "get_sensor_info.ec"
56  {
57 #line 31 "get_sensor_info.ec"
58  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 512), _Cn2, sqli_curs_locate(ESQLINTVERSION, _Cn1, 513), 0, 0);
59 #line 31 "get_sensor_info.ec"
60  }
61 if(sqlca.sqlcode)
62 {
63  printf("%sdeclare loop_c (%d)\n",caller,sqlca.sqlcode);
64 /*
65  * $free qid;
66  */
67 #line 35 "get_sensor_info.ec"
68  {
69 #line 35 "get_sensor_info.ec"
70  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 770));
71 #line 35 "get_sensor_info.ec"
72  }
73  return(-1);
74 }
75 
76 /*
77  * $open loop_c;
78  */
79 #line 39 "get_sensor_info.ec"
80  {
81 #line 39 "get_sensor_info.ec"
82  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
83 #line 39 "get_sensor_info.ec"
84  }
85 if(sqlca.sqlcode)
86 {
87  printf("%sopen loop_c (%d)\n",caller,sqlca.sqlcode);
88 /*
89  * $free loop_c;
90  */
91 #line 43 "get_sensor_info.ec"
92  {
93 #line 43 "get_sensor_info.ec"
94  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 770));
95 #line 43 "get_sensor_info.ec"
96  }
97 /*
98  * $free qid;
99  */
100 #line 44 "get_sensor_info.ec"
101  {
102 #line 44 "get_sensor_info.ec"
103  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 770));
104 #line 44 "get_sensor_info.ec"
105  }
106  return(-1);
107 }
108 
109 /*
110  * $fetch loop_c into $stn_elev, $stn_lat, $stn_lon, $stn_des;
111  */
112 #line 48 "get_sensor_info.ec"
113  {
114 #line 48 "get_sensor_info.ec"
115  static ifx_sqlvar_t _sqobind[] =
116  {
117  { 102, sizeof(stn_elev), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
118  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
119  { 100, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
120  { 100, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
121 #line 48 "get_sensor_info.ec"
122  };
123  static ifx_sqlda_t _SD0 = { 4, _sqobind, {0}, 4, 0 };
124  static _FetchSpec _FS1 = { 0, 1, 0 };
125 #line 48 "get_sensor_info.ec"
126  _sqobind[0].sqldata = (char *) &stn_elev;
127 #line 48 "get_sensor_info.ec"
128  _sqobind[1].sqldata = stn_lat;
129 #line 48 "get_sensor_info.ec"
130  _sqobind[2].sqldata = stn_lon;
131 #line 48 "get_sensor_info.ec"
132  _sqobind[3].sqldata = stn_des;
133  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
134 #line 48 "get_sensor_info.ec"
135  }
136 if(sqlca.sqlcode)
137 {
138  printf("%sfetch loop_c (%d)\n",caller,sqlca.sqlcode);
139 /*
140  * $free loop_c;
141  */
142 #line 52 "get_sensor_info.ec"
143  {
144 #line 52 "get_sensor_info.ec"
145  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 770));
146 #line 52 "get_sensor_info.ec"
147  }
148 /*
149  * $free qid;
150  */
151 #line 53 "get_sensor_info.ec"
152  {
153 #line 53 "get_sensor_info.ec"
154  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 770));
155 #line 53 "get_sensor_info.ec"
156  }
157  return(-1);
158 }
159 sfile->sid=(char)NULL;
160 sprintf(sfile->name,"%s",stn_des);
161 sprintf(sfile->hb5_id,stn_id);
162 sprintf(sfile->pc,shef);
163 sfile->lat_ord=atoi(stn_lat);
164 sfile->long_ord=atoi(stn_lon);
165 sfile->hemisphere_lat='W';
167 sfile->elevation = (float)stn_elev;
168 /*
169 sfile->elevation_units="feet";
170 */
171 
172 /*
173  * $close loop_c;
174  */
175 #line 69 "get_sensor_info.ec"
176  {
177 #line 69 "get_sensor_info.ec"
178  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768));
179 #line 69 "get_sensor_info.ec"
180  }
181 /*
182  * $free loop_c;
183  */
184 #line 70 "get_sensor_info.ec"
185  {
186 #line 70 "get_sensor_info.ec"
187  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 770));
188 #line 70 "get_sensor_info.ec"
189  }
190 /*
191  * $free qid;
192  */
193 #line 71 "get_sensor_info.ec"
194  {
195 #line 71 "get_sensor_info.ec"
196  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 770));
197 #line 71 "get_sensor_info.ec"
198  }
199 return 0;
200 }
201 
202 
203 #line 74 "get_sensor_info.ec"
struct sqlca_s sqlca
static const char _Cn1[]
static const char _Cn2[]
int get_sensor_info(char *stn_id, char *shef, struct sensor_file *sfile)
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)
struct sensor_file * sfile
Definition: mapper.c:126
float value
float elevation
Definition: database.h:447
signed long long_ord
Definition: database.h:445
char hb5_id[HB5_ID_LEN]
Definition: database.h:436
char name[NAME_LEN]
Definition: database.h:435
unsigned long int sid
Definition: database.h:434
unsigned char hemisphere_lat
Definition: database.h:444
signed long lat_ord
Definition: database.h:443
unsigned char hemisphere_long
Definition: database.h:446
char pc[PC_LEN]
Definition: database.h:437
long sqlcode
Definition: db.c:44