author | llornkcor <llornkcor> | 2002-10-31 20:32:13 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-31 20:32:13 (UTC) |
commit | 73b03f932dd43d684e67db1837bf506ee015f2eb (patch) (unidiff) | |
tree | 87be47c236586177c65b38216818951337c0b59a /noncore/todayplugins/stockticker/libstocks/http.c | |
parent | 50f1091ee877020c9864ce24202951f49bec8cd7 (diff) | |
download | opie-73b03f932dd43d684e67db1837bf506ee015f2eb.zip opie-73b03f932dd43d684e67db1837bf506ee015f2eb.tar.gz opie-73b03f932dd43d684e67db1837bf506ee015f2eb.tar.bz2 |
make define __UNIX__ inherent
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 | |||
@@ -9,7 +9,7 @@ | |||
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 |
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define __HTTP_C__ | 21 | #define __HTTP_C__ |
22 | #define __UNIX__ | ||
22 | 23 | ||
23 | #ifdef __UNIX__ | 24 | #ifdef __UNIX__ |
24 | #include <sys/socket.h> | 25 | #include <sys/socket.h> |
@@ -85,9 +86,9 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
85 | { | 86 | { |
86 | 87 | ||
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 | } |
92 | 93 | ||
93 | /* create socket */ | 94 | /* create socket */ |
@@ -121,7 +122,7 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
121 | if (http_proxy_server) | 122 | if (http_proxy_server) |
122 | { | 123 | { |
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 | } |
126 | else | 127 | else |
127 | { | 128 | { |
@@ -138,7 +139,7 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
138 | #endif | 139 | #endif |
139 | { | 140 | { |
140 | #ifdef DEBUG | 141 | #ifdef DEBUG |
141 | printf(" send header : NOK\n"); | 142 | printf(" send header : NOK\n"); |
142 | #endif | 143 | #endif |
143 | return ERRWHEA; | 144 | return ERRWHEA; |
144 | } | 145 | } |
@@ -157,36 +158,36 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
157 | #endif | 158 | #endif |
158 | 159 | ||
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 | } |
191 | 192 | ||
192 | /* close socket */ | 193 | /* close socket */ |
@@ -210,14 +211,14 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
210 | if (*temp==0) return ERRRHEA; | 211 | if (*temp==0) return ERRRHEA; |
211 | 212 | ||
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 | } |
222 | 223 | ||
223 | *temp = 0; | 224 | *temp = 0; |
@@ -238,7 +239,7 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) | |||
238 | { | 239 | { |
239 | free(data); | 240 | free(data); |
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); |
243 | } | 244 | } |
244 | 245 | ||