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) (side-by-side diff)
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) (ignore 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 @@
+/* libstocks - Library to get current stock quotes from Yahoo Finance
+ *
+ * Copyright (C) 2000 Eric Laeuffer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#define __CURRENCY_C__
+
+
+#include <stdio.h>
+#include <string.h>
+#include <malloc.h>
+#include <stdlib.h>
+
+#include "stocks.h"
+
+/*****************************************************************************/
+/* returns the currency exchange rate of "from" currency into */
+/* "into" currency. */
+/*****************************************************************************/
+libstocks_return_code get_currency_exchange(char *from,
+ char *into,
+ float *exchange)
+{
+ char *symbol;
+ stock *data;
+ libstocks_return_code error;
+
+ if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL)
+ {
+ fprintf(stderr,"Memory allocating error (%s line %d)\n"
+ ,__FILE__, __LINE__);
+ exit(1);
+ }
+
+ strcpy(symbol, from);
+ strcat(symbol, into);
+ strcat(symbol, "=X");
+
+ error = get_stocks(symbol, &data);
+ if (error)
+ {
+ *exchange = 0;
+ return(error);
+ }
+
+ free_stocks(data);
+
+ *exchange = data->CurrentPrice;
+ return(error);
+
+}