summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker/libstocks/currency.c
authorllornkcor <llornkcor>2002-10-31 00:09:31 (UTC)
committer llornkcor <llornkcor>2002-10-31 00:09:31 (UTC)
commit5a08fd92ac139820e1a1202d0b4b67190f24ccdb (patch) (unidiff)
treee9c0692cf445a886cd529b60f8e535922a7f5d4d /noncore/todayplugins/stockticker/libstocks/currency.c
parentad396dd7b58fc772423f95be050f645fc7a6d9b9 (diff)
downloadopie-5a08fd92ac139820e1a1202d0b4b67190f24ccdb.zip
opie-5a08fd92ac139820e1a1202d0b4b67190f24ccdb.tar.gz
opie-5a08fd92ac139820e1a1202d0b4b67190f24ccdb.tar.bz2
added - initial check in
Diffstat (limited to 'noncore/todayplugins/stockticker/libstocks/currency.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/libstocks/currency.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/currency.c b/noncore/todayplugins/stockticker/libstocks/currency.c
new file mode 100644
index 0000000..9a08a9d
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/libstocks/currency.c
@@ -0,0 +1,66 @@
1/* libstocks - Library to get current stock quotes from Yahoo Finance
2 *
3 * Copyright (C) 2000 Eric Laeuffer
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21#define __CURRENCY_C__
22
23
24#include <stdio.h>
25#include <string.h>
26#include <malloc.h>
27#include <stdlib.h>
28
29#include "stocks.h"
30
31/*****************************************************************************/
32/* returns the currency exchange rate of "from" currency into */
33/* "into" currency. */
34/*****************************************************************************/
35libstocks_return_code get_currency_exchange(char *from,
36 char *into,
37 float *exchange)
38{
39 char *symbol;
40 stock *data;
41 libstocks_return_code error;
42
43 if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL)
44 {
45 fprintf(stderr,"Memory allocating error (%s line %d)\n"
46 ,__FILE__, __LINE__);
47 exit(1);
48 }
49
50 strcpy(symbol, from);
51 strcat(symbol, into);
52 strcat(symbol, "=X");
53
54 error = get_stocks(symbol, &data);
55 if (error)
56 {
57 *exchange = 0;
58 return(error);
59 }
60
61 free_stocks(data);
62
63 *exchange = data->CurrentPrice;
64 return(error);
65
66}