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 @@ -10,5 +10,5 @@ * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * @@ -20,4 +20,5 @@ #define __HTTP_C__ +#define __UNIX__ #ifdef __UNIX__ @@ -86,7 +87,7 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) #ifdef DEBUG - printf(" gethostbyname : NOK\n"); + printf(" gethostbyname : NOK\n"); #endif - return ERRHOST; + return ERRHOST; } @@ -122,5 +123,5 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) { sprintf(header,"GET http://%.128s:80%.256s HTTP/1.0\015\012\015\012", - http_server, http_file); + http_server, http_file); } else @@ -139,5 +140,5 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) { #ifdef DEBUG - printf(" send header : NOK\n"); + printf(" send header : NOK\n"); #endif return ERRWHEA; @@ -158,34 +159,34 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) if (r) - { - if(!data_lgr) - { - if((data = malloc(r+1))==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } - - memcpy(data,buf,r); - data_lgr = r; - data[r]=0; - } - else - { - if((temp = malloc(r+data_lgr+1))==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } - memcpy(temp, data, data_lgr); - memcpy(temp+data_lgr, buf, r); - temp[r+data_lgr]=0; - data_lgr += r; - free(data); - data = temp; - } - } + { + if(!data_lgr) + { + if((data = malloc(r+1))==NULL) + { + fprintf(stderr,"Memory allocating error (%s line %d)\n" + ,__FILE__, __LINE__); + exit(1); + } + + memcpy(data,buf,r); + data_lgr = r; + data[r]=0; + } + else + { + if((temp = malloc(r+data_lgr+1))==NULL) + { + fprintf(stderr,"Memory allocating error (%s line %d)\n" + ,__FILE__, __LINE__); + exit(1); + } + memcpy(temp, data, data_lgr); + memcpy(temp+data_lgr, buf, r); + temp[r+data_lgr]=0; + data_lgr += r; + free(data); + data = temp; + } + } } @@ -211,12 +212,12 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) if( *temp==0x0A ) - { - /* test if it is the header end */ - temp ++; - if (*temp == 0x0D) temp++; - if (*temp == 0x0A) header_founded = 1; - } + { + /* test if it is the header end */ + temp ++; + if (*temp == 0x0D) temp++; + if (*temp == 0x0A) header_founded = 1; + } else - temp++; + temp++; } @@ -239,5 +240,5 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) free(data); fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); + ,__FILE__, __LINE__); exit(1); } |