Diffstat (limited to 'noncore/todayplugins/stockticker/libstocks/http.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/http.c | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c index 462080d..3078746 100644 --- a/noncore/todayplugins/stockticker/libstocks/http.c +++ b/noncore/todayplugins/stockticker/libstocks/http.c | |||
@@ -11,3 +11,3 @@ | |||
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. |
@@ -21,2 +21,3 @@ | |||
21 | #define __HTTP_C__ | 21 | #define __HTTP_C__ |
22 | #define __UNIX__ | ||
22 | 23 | ||
@@ -87,5 +88,5 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
87 | #ifdef DEBUG | 88 | #ifdef DEBUG |
88 | printf(" gethostbyname : NOK\n"); | 89 | printf(" gethostbyname : NOK\n"); |
89 | #endif | 90 | #endif |
90 | return ERRHOST; | 91 | return ERRHOST; |
91 | } | 92 | } |
@@ -123,3 +124,3 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
123 | sprintf(header,"GET http://%.128s:80%.256s HTTP/1.0\015\012\015\012", | 124 | sprintf(header,"GET http://%.128s:80%.256s HTTP/1.0\015\012\015\012", |
124 | http_server, http_file); | 125 | http_server, http_file); |
125 | } | 126 | } |
@@ -140,3 +141,3 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
140 | #ifdef DEBUG | 141 | #ifdef DEBUG |
141 | printf(" send header : NOK\n"); | 142 | printf(" send header : NOK\n"); |
142 | #endif | 143 | #endif |
@@ -159,32 +160,32 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
159 | if (r) | 160 | if (r) |
160 | { | 161 | { |
161 | if(!data_lgr) | 162 | if(!data_lgr) |
162 | { | 163 | { |
163 | if((data = malloc(r+1))==NULL) | 164 | if((data = malloc(r+1))==NULL) |
164 | { | 165 | { |
165 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 166 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
166 | ,__FILE__, __LINE__); | 167 | ,__FILE__, __LINE__); |
167 | exit(1); | 168 | exit(1); |
168 | } | 169 | } |
169 | 170 | ||
170 | memcpy(data,buf,r); | 171 | memcpy(data,buf,r); |
171 | data_lgr = r; | 172 | data_lgr = r; |
172 | data[r]=0; | 173 | data[r]=0; |
173 | } | 174 | } |
174 | else | 175 | else |
175 | { | 176 | { |
176 | if((temp = malloc(r+data_lgr+1))==NULL) | 177 | if((temp = malloc(r+data_lgr+1))==NULL) |
177 | { | 178 | { |
178 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 179 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
179 | ,__FILE__, __LINE__); | 180 | ,__FILE__, __LINE__); |
180 | exit(1); | 181 | exit(1); |
181 | } | 182 | } |
182 | memcpy(temp, data, data_lgr); | 183 | memcpy(temp, data, data_lgr); |
183 | memcpy(temp+data_lgr, buf, r); | 184 | memcpy(temp+data_lgr, buf, r); |
184 | temp[r+data_lgr]=0; | 185 | temp[r+data_lgr]=0; |
185 | data_lgr += r; | 186 | data_lgr += r; |
186 | free(data); | 187 | free(data); |
187 | data = temp; | 188 | data = temp; |
188 | } | 189 | } |
189 | } | 190 | } |
190 | } | 191 | } |
@@ -212,10 +213,10 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
212 | if( *temp==0x0A ) | 213 | if( *temp==0x0A ) |
213 | { | 214 | { |
214 | /* test if it is the header end */ | 215 | /* test if it is the header end */ |
215 | temp ++; | 216 | temp ++; |
216 | if (*temp == 0x0D) temp++; | 217 | if (*temp == 0x0D) temp++; |
217 | if (*temp == 0x0A) header_founded = 1; | 218 | if (*temp == 0x0A) header_founded = 1; |
218 | } | 219 | } |
219 | else | 220 | else |
220 | temp++; | 221 | temp++; |
221 | } | 222 | } |
@@ -240,3 +241,3 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
240 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 241 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
241 | ,__FILE__, __LINE__); | 242 | ,__FILE__, __LINE__); |
242 | exit(1); | 243 | exit(1); |