diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-05-14 20:30:28 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-05-14 20:30:28 +0000 |
commit | 07f4b003675260004c49755dde413944a16ca2d3 (patch) | |
tree | 11050b4c7fbe1d7c63a38f5f9a6b5ba6d8260ae1 /src/htscatchurl.c | |
parent | b09def438c5e47305e4a5ab18d8a646a3b004fdc (diff) |
Indenting cleanup for all *.[ch] files, except htsparse.c (too ugly to be automatically indented for now) and /minizip/, /mmsrip/ (external files)
setup:
indent -l80 -lc80 -nhnl -nut -bad -bap -bbo -br -brf -bli2 -brs -bls -br -ss -sai -pmt -nsaw -nsaf -nprs -i2 -ce -npsl -npcs -cs -sob -cdw -nbc -lp
logs:
indent: ./src/htsback.c:157: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1417: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1826: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1833: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1981: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:2685: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:2747: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:2861: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:3128: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:3512: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:597: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:598: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:611: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:97: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:256: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:262: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:935: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:271: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:272: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:273: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:274: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:275: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:276: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:277: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:278: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:279: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:280: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:281: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:662: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:752: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:413: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:414: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:415: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:416: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:417: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:418: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:419: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:420: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:421: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:422: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:423: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:507: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:508: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:509: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:510: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:511: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:512: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:580: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:581: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:115: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:246: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:247: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:248: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:249: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:250: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:251: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:314: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:315: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:151: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:158: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:161: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:166: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:174: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:243: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:245: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:248: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:257: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:647: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsbauth.c:364: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsbauth.c:387: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscache.c:473: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsserver.h:112: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsserver.h:187: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsjava.c:312: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsjava.c:379: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsjava.c:407: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsjava.c:472: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsjava.c:483: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htslib.c:593: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:809: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1743: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1874: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1896: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1984: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2085: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2604: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2605: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2606: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2607: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2608: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2609: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2672: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2673: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2906: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2928: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2996: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:4802: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htslib.c:5353: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5354: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5355: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5357: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5429: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5435: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscore.c:208: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscore.c:277: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscore.c:279: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscore.c:357: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htscore.c:394: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htscore.c:1544: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscore.c:3330: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscore.c:3361: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htshash.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htshash.c:217: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsname.c:733: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsname.c:749: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsname.c:933: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsname.c:1520: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htszlib.c:76: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htszlib.c:81: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscatchurl.c:268: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsinthash.c:156: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:159: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:176: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:179: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:226: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:253: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsftp.c:169: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsftp.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsfilters.c:67: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsfilters.c:80: Warning:old style assignment ambiguity in "=*". Assuming "= *"
Diffstat (limited to 'src/htscatchurl.c')
-rw-r--r-- | src/htscatchurl.c | 193 |
1 files changed, 103 insertions, 90 deletions
diff --git a/src/htscatchurl.c b/src/htscatchurl.c index 0d486ac..f015a75 100644 --- a/src/htscatchurl.c +++ b/src/htscatchurl.c @@ -17,18 +17,15 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Important notes: - We hereby ask people using this source NOT to use it in purpose of grabbing emails addresses, or collecting any other private information on persons. This would disgrace our work, and spoil the many hours we spent on it. - Please visit our Website: http://www.httrack.com */ - /* ------------------------------------------------------------ */ /* File: URL catch .h */ /* Author: Xavier Roche */ @@ -62,57 +59,60 @@ Please visit our Website: http://www.httrack.com /* catch url */ #include "htscatchurl.h" - // URL Link catcher // 0- Init the URL catcher with standard port // catch_url_init(&port,&return_host); -HTSEXT_API T_SOC catch_url_init_std(int* port_prox,char* adr_prox) { +HTSEXT_API T_SOC catch_url_init_std(int *port_prox, char *adr_prox) { T_SOC soc; - int try_to_listen_to[]={8080,3128,80,81,82,8081,3129,31337,0,-1}; - int i=0; + int try_to_listen_to[] = { 8080, 3128, 80, 81, 82, 8081, 3129, 31337, 0, -1 }; + int i = 0; + do { - soc=catch_url_init(&try_to_listen_to[i],adr_prox); - *port_prox=try_to_listen_to[i]; + soc = catch_url_init(&try_to_listen_to[i], adr_prox); + *port_prox = try_to_listen_to[i]; i++; - } while( (soc == INVALID_SOCKET) && (try_to_listen_to[i]>=0)); + } while((soc == INVALID_SOCKET) && (try_to_listen_to[i] >= 0)); return soc; } - // 1- Init the URL catcher // catch_url_init(&port,&return_host); -HTSEXT_API T_SOC catch_url_init(int* port,char* adr) { +HTSEXT_API T_SOC catch_url_init(int *port, char *adr) { T_SOC soc = INVALID_SOCKET; - char h_loc[256+2]; + char h_loc[256 + 2]; - if (gethostname(h_loc,256)==0) { // host name + if (gethostname(h_loc, 256) == 0) { // host name SOCaddr server; - int server_size=sizeof(server); - t_hostent* hp_loc; + int server_size = sizeof(server); + t_hostent *hp_loc; t_fullhostent buffer; // effacer structure memset(&server, 0, sizeof(server)); - - if ( (hp_loc=vxgethostbyname(h_loc, &buffer)) ) { // notre host + + if ((hp_loc = vxgethostbyname(h_loc, &buffer))) { // notre host // copie adresse - SOCaddr_copyaddr(server, server_size, hp_loc->h_addr_list[0], hp_loc->h_length); + SOCaddr_copyaddr(server, server_size, hp_loc->h_addr_list[0], + hp_loc->h_length); - if ( (soc = (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, 0)) != INVALID_SOCKET) { + if ((soc = + (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, + 0)) != INVALID_SOCKET) { SOCaddr_initport(server, *port); - if ( bind(soc,(struct sockaddr*) &server,server_size) == 0 ) { + if (bind(soc, (struct sockaddr *) &server, server_size) == 0) { SOCaddr server2; SOClen len; - len=sizeof(server2); + + len = sizeof(server2); // effacer structure memset(&server2, 0, sizeof(server2)); - if (getsockname(soc,(struct sockaddr*) &server2,&len) == 0) { - *port=ntohs(SOCaddr_sinport(server)); // récupérer port - if (listen(soc,10)>=0) { // au pif le 10 + if (getsockname(soc, (struct sockaddr *) &server2, &len) == 0) { + *port = ntohs(SOCaddr_sinport(server)); // récupérer port + if (listen(soc, 10) >= 0) { // au pif le 10 SOCaddr_inetntoa(adr, 128, server2, len); } else { #ifdef _WIN32 @@ -120,27 +120,25 @@ HTSEXT_API T_SOC catch_url_init(int* port,char* adr) { #else close(soc); #endif - soc=INVALID_SOCKET; + soc = INVALID_SOCKET; } - - + } else { #ifdef _WIN32 closesocket(soc); #else close(soc); #endif - soc=INVALID_SOCKET; + soc = INVALID_SOCKET; } - - + } else { #ifdef _WIN32 closesocket(soc); #else close(soc); #endif - soc=INVALID_SOCKET; + soc = INVALID_SOCKET; } } } @@ -154,31 +152,34 @@ HTSEXT_API T_SOC catch_url_init(int* port,char* adr) { // returns 0 if error // url: buffer where URL must be stored - or ip:port in case of failure // data: 32Kb -HTSEXT_API int catch_url(T_SOC soc,char* url,char* method,char* data) { - int retour=0; +HTSEXT_API int catch_url(T_SOC soc, char *url, char *method, char *data) { + int retour = 0; // connexion (accept) if (soc != INVALID_SOCKET) { T_SOC soc2; - while ( (soc2 = (T_SOC) accept(soc, NULL, NULL)) == INVALID_SOCKET); - /* -#ifdef _WIN32 - closesocket(soc); -#else - close(soc); -#endif - */ + + while((soc2 = (T_SOC) accept(soc, NULL, NULL)) == INVALID_SOCKET) ; + /* + #ifdef _WIN32 + closesocket(soc); + #else + close(soc); + #endif + */ soc = soc2; /* INFOS */ { SOCaddr server2; SOClen len = sizeof(server2); + // effacer structure memset(&server2, 0, sizeof(server2)); - if (getpeername(soc,(struct sockaddr*) &server2,&len) == 0) { - char dot[256+2]; + if (getpeername(soc, (struct sockaddr *) &server2, &len) == 0) { + char dot[256 + 2]; + SOCaddr_inetntoa(dot, 256, server2, sizeof(server2)); - sprintf(url,"%s:%d", dot, htons(SOCaddr_sinport(server2))); + sprintf(url, "%s:%d", dot, htons(SOCaddr_sinport(server2))); } } /* INFOS */ @@ -187,65 +188,71 @@ HTSEXT_API int catch_url(T_SOC soc,char* url,char* method,char* data) { if (soc != INVALID_SOCKET) { char line[1000]; char protocol[256]; - line[0]=protocol[0]='\0'; + + line[0] = protocol[0] = '\0'; // - socinput(soc,line,1000); + socinput(soc, line, 1000); if (strnotempty(line)) { - if (sscanf(line,"%s %s %s",method,url,protocol) == 3) { - char BIGSTK url_adr[HTS_URLMAXSIZE*2]; - char BIGSTK url_fil[HTS_URLMAXSIZE*2]; + if (sscanf(line, "%s %s %s", method, url, protocol) == 3) { + char BIGSTK url_adr[HTS_URLMAXSIZE * 2]; + char BIGSTK url_fil[HTS_URLMAXSIZE * 2]; + // méthode en majuscule - int i,r=0; - url_adr[0]=url_fil[0]='\0'; + int i, r = 0; + + url_adr[0] = url_fil[0] = '\0'; // - for(i=0;i<(int) strlen(method);i++) { - if ((method[i]>='a') && (method[i]<='z')) - method[i]-=('a'-'A'); + for(i = 0; i < (int) strlen(method); i++) { + if ((method[i] >= 'a') && (method[i] <= 'z')) + method[i] -= ('a' - 'A'); } // adresse du lien - if (ident_url_absolute(url,url_adr,url_fil)>=0) { + if (ident_url_absolute(url, url_adr, url_fil) >= 0) { // Traitement des en-têtes - char BIGSTK loc[HTS_URLMAXSIZE*2]; + char BIGSTK loc[HTS_URLMAXSIZE * 2]; htsblk blkretour; + hts_init_htsblk(&blkretour); //memset(&blkretour, 0, sizeof(htsblk)); // effacer - blkretour.location=loc; // si non nul, contiendra l'adresse véritable en cas de moved xx + blkretour.location = loc; // si non nul, contiendra l'adresse véritable en cas de moved xx // Lire en têtes restants - sprintf(data,"%s %s %s\r\n",method,url_fil,protocol); + sprintf(data, "%s %s %s\r\n", method, url_fil, protocol); while(strnotempty(line)) { - socinput(soc,line,1000); - treathead(NULL,NULL,NULL,&blkretour,line); // traiter - strcatbuff(data,line); - strcatbuff(data,"\r\n"); + socinput(soc, line, 1000); + treathead(NULL, NULL, NULL, &blkretour, line); // traiter + strcatbuff(data, line); + strcatbuff(data, "\r\n"); } // CR/LF final de l'en tête inutile car déja placé via la ligne vide juste au dessus //strcatbuff(data,"\r\n"); - if (blkretour.totalsize>0) { - int len=(int)min(blkretour.totalsize,32000); + if (blkretour.totalsize > 0) { + int len = (int) min(blkretour.totalsize, 32000); int pos = (int) strlen(data); + // Copier le reste (post éventuel) - while((len>0) && ((r=recv(soc,(char*) data+pos,len,0))>0) ) { - pos+=r; - len-=r; - data[pos]='\0'; // terminer par NULL + while((len > 0) + && ((r = recv(soc, (char *) data + pos, len, 0)) > 0)) { + pos += r; + len -= r; + data[pos] = '\0'; // terminer par NULL } } // Envoyer page - sprintf(line,CATCH_RESPONSE); - send(soc,line,(int)strlen(line),0); + sprintf(line, CATCH_RESPONSE); + send(soc, line, (int) strlen(line), 0); // OK! - retour=1; + retour = 1; } } - } // sinon erreur + } // sinon erreur } } if (soc != INVALID_SOCKET) { #ifdef _WIN32 closesocket(soc); /* - WSACleanup(); - */ + WSACleanup(); + */ #else close(soc); #endif @@ -253,25 +260,31 @@ HTSEXT_API int catch_url(T_SOC soc,char* url,char* method,char* data) { return retour; } - - // Lecture de ligne sur socket -void socinput(T_SOC soc,char* s,int max) { +void socinput(T_SOC soc, char *s, int max) { int c; - int j=0; + int j = 0; + do { unsigned char b; - if (recv(soc,(char*) &b,1,0)==1) { - c=b; - switch(c) { - case 13: break; // sauter CR - case 10: c=-1; break; - case 9: case 12: break; // sauter ces caractères - default: s[j++]=(char) c; break; + + if (recv(soc, (char *) &b, 1, 0) == 1) { + c = b; + switch (c) { + case 13: + break; // sauter CR + case 10: + c = -1; + break; + case 9: + case 12: + break; // sauter ces caractères + default: + s[j++] = (char) c; + break; } } else - c=EOF; - } while((c!=-1) && (c!=EOF) && (j<(max-1))); - s[j++]='\0'; + c = EOF; + } while((c != -1) && (c != EOF) && (j < (max - 1))); + s[j++] = '\0'; } - |