Diffstat (limited to 'noncore/todayplugins/stockticker/libstocks/stocks.c') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/stocks.c | 23 |
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 | |||
@@ -234,23 +234,22 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) | |||
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 | ||
@@ -260,33 +259,32 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) | |||
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 | ||
@@ -295,14 +293,14 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) | |||
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 | } |
@@ -311,19 +309,21 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) | |||
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; |
@@ -335,13 +335,14 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) | |||
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 | } |