author | llornkcor <llornkcor> | 2002-10-31 20:33:18 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-31 20:33:18 (UTC) |
commit | 88310c7207b84c79dbb11ab3c3afeded1874c10b (patch) (side-by-side diff) | |
tree | 6933dd40e2333854523e25edbefdf00b78145300 | |
parent | 73b03f932dd43d684e67db1837bf506ee015f2eb (diff) | |
download | opie-88310c7207b84c79dbb11ab3c3afeded1874c10b.zip opie-88310c7207b84c79dbb11ab3c3afeded1874c10b.tar.gz opie-88310c7207b84c79dbb11ab3c3afeded1874c10b.tar.bz2 |
fix
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/csv.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/csv.c b/noncore/todayplugins/stockticker/libstocks/csv.c index 27bcce6..f45af52 100644 --- a/noncore/todayplugins/stockticker/libstocks/csv.c +++ b/noncore/todayplugins/stockticker/libstocks/csv.c @@ -1,150 +1,150 @@ /* 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 __CSV_C__ -#ifdef __UNIX__ +#define __UNIX__ #include <string.h> #include <stdlib.h> #include <stdio.h> #ifdef __WINDOWS__ #include <mbstring.h> #endif #include "csv.h" #include "stocks.h" #include "lists.h" #define DATE_LENGTH 7 /*YYMMDD*/ const char *months[12]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; /*****************************************************************************/ /* Replacement of the strtok function. This one forgets "delim" when it is */ /* between two commas. */ /* Thanks to Julio Lucas who has told me the bug and has proposed me a patch */ /*****************************************************************************/ char *csv_strtok(char *s, char *delim) { static char *next=NULL; char *temp, *first; int comma=0; if (s!=NULL) first=s; else first=next; temp=first; if (*temp=='\0') return NULL; while (*temp!='\0' && ((*temp!=*delim) || comma)) { if (*temp=='"') comma ^= 1; temp++; } if (*temp=='\0') next=temp; else { *temp='\0'; next=temp+1; } return first; } /*****************************************************************************/ /* Parses the csv file and return a list of stocks structure. */ /* *csv points on the csv file in memory */ /* count defines the country, because csv depends on the country */ /*****************************************************************************/ stock *parse_csv_file(char *csv) { char *line; char *end_line; char *ptr; char *date; char *time; char *name; char *symbol; stock *StockPtr=NULL; stock *LastStockPtr=NULL; /* Used to return the pointer to the list */ stock *FirstStockPtr=NULL; /* used to see if symbol is valid */ int valid; char *test; line = csv; end_line = csv; while ((end_line = strstr(line, "\n"))) { *end_line = 0; /* Check if symbol valid */ /* if 1 "N/A" then ok because Indices have N/A for volume */ /* if 4 "N/A" then ok because Mutual funds have */ /* if 5 "N/A" then ok because currencies have */ /* So if >5 then stock not valid */ test = line; valid = 0; while ( (test = strstr(test, "N/A")) ) { valid ++; test = test +3; } if (valid < 6) { /* This Symbol is valid */ StockPtr = malloc_stock(); ptr = csv_strtok(line, ","); if (!ptr) return 0; symbol = (char *)malloc(strlen(ptr)+1); if (symbol==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } |