summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/libstocks/csv.c2
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,118 +1,118 @@
1/* libstocks - Library to get current stock quotes from Yahoo Finance 1/* libstocks - Library to get current stock quotes from Yahoo Finance
2 * 2 *
3 * Copyright (C) 2000 Eric Laeuffer 3 * Copyright (C) 2000 Eric Laeuffer
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public 15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the 16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA. 18 * Boston, MA 02111-1307, USA.
19 */ 19 */
20 20
21#define __CSV_C__ 21#define __CSV_C__
22#ifdef __UNIX__ 22#define __UNIX__
23 23
24#include <string.h> 24#include <string.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <stdio.h> 26#include <stdio.h>
27 27
28#ifdef __WINDOWS__ 28#ifdef __WINDOWS__
29#include <mbstring.h> 29#include <mbstring.h>
30#endif 30#endif
31 31
32#include "csv.h" 32#include "csv.h"
33#include "stocks.h" 33#include "stocks.h"
34#include "lists.h" 34#include "lists.h"
35 35
36#define DATE_LENGTH 7 /*YYMMDD*/ 36#define DATE_LENGTH 7 /*YYMMDD*/
37 37
38const char *months[12]= 38const char *months[12]=
39{ 39{
40 "Jan", 40 "Jan",
41 "Feb", 41 "Feb",
42 "Mar", 42 "Mar",
43 "Apr", 43 "Apr",
44 "May", 44 "May",
45 "Jun", 45 "Jun",
46 "Jul", 46 "Jul",
47 "Aug", 47 "Aug",
48 "Sep", 48 "Sep",
49 "Oct", 49 "Oct",
50 "Nov", 50 "Nov",
51 "Dec" 51 "Dec"
52}; 52};
53 53
54/*****************************************************************************/ 54/*****************************************************************************/
55/* Replacement of the strtok function. This one forgets "delim" when it is */ 55/* Replacement of the strtok function. This one forgets "delim" when it is */
56/* between two commas. */ 56/* between two commas. */
57/* Thanks to Julio Lucas who has told me the bug and has proposed me a patch */ 57/* Thanks to Julio Lucas who has told me the bug and has proposed me a patch */
58/*****************************************************************************/ 58/*****************************************************************************/
59char *csv_strtok(char *s, char *delim) 59char *csv_strtok(char *s, char *delim)
60{ 60{
61 static char *next=NULL; 61 static char *next=NULL;
62 char *temp, *first; 62 char *temp, *first;
63 int comma=0; 63 int comma=0;
64 64
65 if (s!=NULL) first=s; 65 if (s!=NULL) first=s;
66 else first=next; 66 else first=next;
67 67
68 temp=first; 68 temp=first;
69 if (*temp=='\0') return NULL; 69 if (*temp=='\0') return NULL;
70 70
71 while (*temp!='\0' && ((*temp!=*delim) || comma)) 71 while (*temp!='\0' && ((*temp!=*delim) || comma))
72 { 72 {
73 if (*temp=='"') comma ^= 1; 73 if (*temp=='"') comma ^= 1;
74 temp++; 74 temp++;
75 } 75 }
76 76
77 if (*temp=='\0') next=temp; 77 if (*temp=='\0') next=temp;
78 else 78 else
79 { 79 {
80 *temp='\0'; 80 *temp='\0';
81 next=temp+1; 81 next=temp+1;
82 } 82 }
83 83
84 return first; 84 return first;
85} 85}
86 86
87/*****************************************************************************/ 87/*****************************************************************************/
88/* Parses the csv file and return a list of stocks structure. */ 88/* Parses the csv file and return a list of stocks structure. */
89/* *csv points on the csv file in memory */ 89/* *csv points on the csv file in memory */
90/* count defines the country, because csv depends on the country */ 90/* count defines the country, because csv depends on the country */
91/*****************************************************************************/ 91/*****************************************************************************/
92stock *parse_csv_file(char *csv) 92stock *parse_csv_file(char *csv)
93{ 93{
94 char *line; 94 char *line;
95 char *end_line; 95 char *end_line;
96 96
97 char *ptr; 97 char *ptr;
98 98
99 char *date; 99 char *date;
100 char *time; 100 char *time;
101 char *name; 101 char *name;
102 char *symbol; 102 char *symbol;
103 103
104 stock *StockPtr=NULL; 104 stock *StockPtr=NULL;
105 stock *LastStockPtr=NULL; 105 stock *LastStockPtr=NULL;
106 106
107 /* Used to return the pointer to the list */ 107 /* Used to return the pointer to the list */
108 stock *FirstStockPtr=NULL; 108 stock *FirstStockPtr=NULL;
109 109
110 /* used to see if symbol is valid */ 110 /* used to see if symbol is valid */
111 int valid; 111 int valid;
112 char *test; 112 char *test;
113 113
114 line = csv; 114 line = csv;
115 end_line = csv; 115 end_line = csv;
116 116
117 while ((end_line = strstr(line, "\n"))) 117 while ((end_line = strstr(line, "\n")))
118 { 118 {