summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker/libstocks/stocks.c
Unidiff
Diffstat (limited to 'noncore/todayplugins/stockticker/libstocks/stocks.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/libstocks/stocks.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/stocks.c b/noncore/todayplugins/stockticker/libstocks/stocks.c
index eb04ba9..3a26a47 100644
--- a/noncore/todayplugins/stockticker/libstocks/stocks.c
+++ b/noncore/todayplugins/stockticker/libstocks/stocks.c
@@ -228,120 +228,121 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas)
228 228
229 while( (symbol = strtok(tok_ptr, "+"))!=0) 229 while( (symbol = strtok(tok_ptr, "+"))!=0)
230 { 230 {
231 /* clear tok_ptr for next strtok */ 231 /* clear tok_ptr for next strtok */
232 tok_ptr = NULL; 232 tok_ptr = NULL;
233 233
234 /* look for "." in the symbol */ 234 /* look for "." in the symbol */
235 source = find_yahoo_source(symbol); 235 source = find_yahoo_source(symbol);
236 236
237 switch (source) 237 switch (source)
238 { 238 {
239 case YAHOO_US: 239 case YAHOO_US:
240
241 if (us_quotes) 240 if (us_quotes)
242 { 241 {
243 lgr_us_quotes = strlen(us_quotes); 242 lgr_us_quotes = strlen(us_quotes);
244 lgr_symbol = strlen(symbol); 243 lgr_symbol = strlen(symbol);
245 244
246 us_quotes_temp = malloc(lgr_us_quotes + lgr_symbol +2); 245 us_quotes_temp = malloc(lgr_us_quotes + lgr_symbol +2);
247 if(us_quotes_temp==NULL) 246 if(us_quotes_temp==NULL)
248 { 247 {
249 fprintf(stderr,"Memory allocating error (%s line %d)\n" 248 fprintf(stderr,"Memory allocating error (%s line %d)\n",
250 ,__FILE__, __LINE__); 249 __FILE__, __LINE__);
251 exit(1); 250 exit(1);
252 } 251 }
253 strcpy(us_quotes_temp, us_quotes); 252 strcpy(us_quotes_temp, us_quotes);
254 strcat(us_quotes_temp,"+"); 253 strcat(us_quotes_temp,"+");
255 strcat(us_quotes_temp,symbol); 254 strcat(us_quotes_temp,symbol);
256 255
257 free(us_quotes); 256 free(us_quotes);
258 us_quotes = us_quotes_temp; 257 us_quotes = us_quotes_temp;
259 } 258 }
260 else 259 else
261 { 260 {
262 us_quotes = malloc(strlen(symbol)+1); 261 us_quotes = malloc(strlen(symbol)+1);
263 262
264 if(us_quotes==NULL) 263 if(us_quotes==NULL)
265 { 264 {
266 fprintf(stderr,"Memory allocating error (%s line %d)\n" 265 fprintf(stderr,"Memory allocating error (%s line %d)\n",
267 ,__FILE__, __LINE__); 266 __FILE__, __LINE__);
268 exit(1); 267 exit(1);
269 } 268 }
270 strcpy(us_quotes, symbol); 269 strcpy(us_quotes, symbol);
271 } 270 }
272 271
273 break; 272 break;
274 273
275 case YAHOO_EUROPE: 274 case YAHOO_EUROPE:
276
277 if (eu_quotes) 275 if (eu_quotes)
278 { 276 {
279 lgr_eu_quotes = strlen(eu_quotes); 277 lgr_eu_quotes = strlen(eu_quotes);
280 lgr_symbol = strlen(symbol); 278 lgr_symbol = strlen(symbol);
281 279
282 eu_quotes_temp = malloc(lgr_eu_quotes + lgr_symbol +2); 280 eu_quotes_temp = malloc(lgr_eu_quotes + lgr_symbol +2);
283 if(eu_quotes_temp==NULL) 281 if(eu_quotes_temp==NULL)
284 { 282 {
285 fprintf(stderr,"Memory allocating error (%s line %d)\n" 283 fprintf(stderr,"Memory allocating error (%s line %d)\n",
286 ,__FILE__, __LINE__); 284 __FILE__, __LINE__);
287 exit(1); 285 exit(1);
288 } 286 }
289 strcpy(eu_quotes_temp, eu_quotes); 287 strcpy(eu_quotes_temp, eu_quotes);
290 strcat(eu_quotes_temp, "+"); 288 strcat(eu_quotes_temp, "+");
291 strcat(eu_quotes_temp, symbol); 289 strcat(eu_quotes_temp, symbol);
292 290
293 free(eu_quotes); 291 free(eu_quotes);
294 eu_quotes = eu_quotes_temp; 292 eu_quotes = eu_quotes_temp;
295 } 293 }
296 else 294 else
297 { 295 {
298 eu_quotes = malloc(strlen(symbol)+1); 296 eu_quotes = malloc(strlen(symbol)+1);
299 if(eu_quotes==NULL) 297 if(eu_quotes==NULL)
300 { 298 {
301 fprintf(stderr,"Memory allocating error (%s line %d)\n" 299 fprintf(stderr,"Memory allocating error (%s line %d)\n",
302 ,__FILE__, __LINE__); 300 __FILE__, __LINE__);
303 exit(1); 301 exit(1);
304 } 302 }
305 strcpy(eu_quotes, symbol); 303 strcpy(eu_quotes, symbol);
306 } 304 }
307 break; 305 break;
308 } 306 }
309 } 307 }
310 308
311 free(tok_ptr); 309 free(tok_ptr);
312 310
313 if (us_quotes) 311 if (us_quotes)
314 { 312 {
315 /* Gets us quotes */ 313 /* Gets us quotes */
316 error = download_stocks(us_quotes, &stocks_tmp, YAHOO_US); 314 error = download_stocks(us_quotes, &stocks_tmp, YAHOO_US);
315 free(us_quotes);
317 if (error) return error; 316 if (error) return error;
318 } 317 }
319 318
320 if (eu_quotes) 319 if (eu_quotes)
321 { 320 {
322 /* Gets european quotes */ 321 /* Gets european quotes */
323 error = download_stocks(eu_quotes, &stocks_getted, YAHOO_EUROPE); 322 error = download_stocks(eu_quotes, &stocks_getted, YAHOO_EUROPE);
323 free(eu_quotes);
324 if (error) return error; 324 if (error) return error;
325 325
326 /* concats lists if needed */ 326 /* concats lists if needed */
327 if (stocks_tmp) 327 if (stocks_tmp)
328 { 328 {
329 stocks_tmp2 = stocks_tmp; 329 stocks_tmp2 = stocks_tmp;
330 330
331 while(stocks_tmp2 != NULL) 331 while(stocks_tmp2 != NULL)
332 { 332 {
333 last_stock = stocks_tmp2; 333 last_stock = stocks_tmp2;
334 stocks_tmp2 = next_stock(stocks_tmp2); 334 stocks_tmp2 = next_stock(stocks_tmp2);
335 } 335 }
336 336
337 last_stock->NextStock = stocks_getted; 337 last_stock->NextStock = stocks_getted;
338 stocks_getted->PreviousStock = last_stock; 338 stocks_getted->PreviousStock = last_stock;
339 339
340 } 340 }
341 else (stocks_tmp = stocks_getted); 341 else
342 (stocks_tmp = stocks_getted);
342 } 343 }
343 344
344 *stock_datas = stocks_tmp; 345 *stock_datas = stocks_tmp;
345 346
346 return(0); 347 return(0);
347} 348}