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/httrack.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/httrack.c')
-rw-r--r-- | src/httrack.c | 843 |
1 files changed, 463 insertions, 380 deletions
diff --git a/src/httrack.c b/src/httrack.c index eaea638..e149948 100644 --- a/src/httrack.c +++ b/src/httrack.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: htsshow.c console progress info */ /* Only used on Linux & FreeBSD versions */ @@ -51,9 +48,8 @@ Please visit our Website: http://www.httrack.com #include "htslib.h" /* Static definitions */ -static int fexist(const char* s); -static int linput(FILE* fp,char* s,int max); - +static int fexist(const char *s); +static int linput(FILE * fp, char *s, int max); // htswrap_add #include "htswrap.h" @@ -76,29 +72,69 @@ static int linput(FILE* fp,char* s,int max); #include <ctype.h> /* END specific definitions */ -static void __cdecl htsshow_init(t_hts_callbackarg *carg); -static void __cdecl htsshow_uninit(t_hts_callbackarg *carg); -static int __cdecl htsshow_start(t_hts_callbackarg *carg, httrackp* opt); -static int __cdecl htsshow_chopt(t_hts_callbackarg *carg, httrackp* opt); -static int __cdecl htsshow_end(t_hts_callbackarg *carg, httrackp* opt); -static int __cdecl htsshow_preprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file); -static int __cdecl htsshow_postprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file); -static int __cdecl htsshow_checkhtml(t_hts_callbackarg *carg, httrackp *opt, char* html,int len,const char* url_address,const char* url_file); -static int __cdecl htsshow_loop(t_hts_callbackarg *carg, httrackp *opt, lien_back* back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats); -static const char* __cdecl htsshow_query(t_hts_callbackarg *carg, httrackp *opt, const char* question); -static const char* __cdecl htsshow_query2(t_hts_callbackarg *carg, httrackp *opt, const char* question); -static const char* __cdecl htsshow_query3(t_hts_callbackarg *carg, httrackp *opt, const char* question); -static int __cdecl htsshow_check(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,int status); -static int __cdecl htsshow_check_mime(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,const char* mime,int status); -static void __cdecl htsshow_pause(t_hts_callbackarg *carg, httrackp *opt, const char* lockfile); -static void __cdecl htsshow_filesave(t_hts_callbackarg *carg, httrackp *opt, const char* file); -static void __cdecl htsshow_filesave2(t_hts_callbackarg *carg, httrackp *opt, const char* adr, const char* fil, const char* save, int is_new, int is_modified,int not_updated); -static int __cdecl htsshow_linkdetected(t_hts_callbackarg *carg, httrackp *opt, char* link); -static int __cdecl htsshow_linkdetected2(t_hts_callbackarg *carg, httrackp *opt, char* link, const char* start_tag); -static int __cdecl htsshow_xfrstatus(t_hts_callbackarg *carg, httrackp *opt, lien_back* back); -static int __cdecl htsshow_savename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete,const char* fil_complete,const char* referer_adr,const char* referer_fil,char* save); -static int __cdecl htsshow_sendheader(t_hts_callbackarg *carg, httrackp *opt, char* buff, const char* adr, const char* fil, const char* referer_adr, const char* referer_fil, htsblk* outgoing); -static int __cdecl htsshow_receiveheader(t_hts_callbackarg *carg, httrackp *opt, char* buff, const char* adr, const char* fil, const char* referer_adr, const char* referer_fil, htsblk* incoming); +static void __cdecl htsshow_init(t_hts_callbackarg * carg); +static void __cdecl htsshow_uninit(t_hts_callbackarg * carg); +static int __cdecl htsshow_start(t_hts_callbackarg * carg, httrackp * opt); +static int __cdecl htsshow_chopt(t_hts_callbackarg * carg, httrackp * opt); +static int __cdecl htsshow_end(t_hts_callbackarg * carg, httrackp * opt); +static int __cdecl htsshow_preprocesshtml(t_hts_callbackarg * carg, + httrackp * opt, char **html, int *len, + const char *url_address, + const char *url_file); +static int __cdecl htsshow_postprocesshtml(t_hts_callbackarg * carg, + httrackp * opt, char **html, + int *len, const char *url_address, + const char *url_file); +static int __cdecl htsshow_checkhtml(t_hts_callbackarg * carg, httrackp * opt, + char *html, int len, + const char *url_address, + const char *url_file); +static int __cdecl htsshow_loop(t_hts_callbackarg * carg, httrackp * opt, + lien_back * back, int back_max, int back_index, + int lien_n, int lien_tot, int stat_time, + hts_stat_struct * stats); +static const char *__cdecl htsshow_query(t_hts_callbackarg * carg, + httrackp * opt, const char *question); +static const char *__cdecl htsshow_query2(t_hts_callbackarg * carg, + httrackp * opt, const char *question); +static const char *__cdecl htsshow_query3(t_hts_callbackarg * carg, + httrackp * opt, const char *question); +static int __cdecl htsshow_check(t_hts_callbackarg * carg, httrackp * opt, + const char *adr, const char *fil, int status); +static int __cdecl htsshow_check_mime(t_hts_callbackarg * carg, httrackp * opt, + const char *adr, const char *fil, + const char *mime, int status); +static void __cdecl htsshow_pause(t_hts_callbackarg * carg, httrackp * opt, + const char *lockfile); +static void __cdecl htsshow_filesave(t_hts_callbackarg * carg, httrackp * opt, + const char *file); +static void __cdecl htsshow_filesave2(t_hts_callbackarg * carg, httrackp * opt, + const char *adr, const char *fil, + const char *save, int is_new, + int is_modified, int not_updated); +static int __cdecl htsshow_linkdetected(t_hts_callbackarg * carg, + httrackp * opt, char *link); +static int __cdecl htsshow_linkdetected2(t_hts_callbackarg * carg, + httrackp * opt, char *link, + const char *start_tag); +static int __cdecl htsshow_xfrstatus(t_hts_callbackarg * carg, httrackp * opt, + lien_back * back); +static int __cdecl htsshow_savename(t_hts_callbackarg * carg, httrackp * opt, + const char *adr_complete, + const char *fil_complete, + const char *referer_adr, + const char *referer_fil, char *save); +static int __cdecl htsshow_sendheader(t_hts_callbackarg * carg, httrackp * opt, + char *buff, const char *adr, + const char *fil, const char *referer_adr, + const char *referer_fil, + htsblk * outgoing); +static int __cdecl htsshow_receiveheader(t_hts_callbackarg * carg, + httrackp * opt, char *buff, + const char *adr, const char *fil, + const char *referer_adr, + const char *referer_fil, + htsblk * incoming); static void vt_clear(void); static void vt_home(void); @@ -140,13 +176,13 @@ static void vt_home(void); // #define csi(X) printf(s_csi( X )); static void vt_clear(void) { - printf("%s%s%s",VT_RESET,VT_CLRSCR,VT_GOTOXY("1","0")); + printf("%s%s%s", VT_RESET, VT_CLRSCR, VT_GOTOXY("1", "0")); } static void vt_home(void) { - printf("%s%s",VT_RESET,VT_GOTOXY("1","0")); + printf("%s%s", VT_RESET, VT_GOTOXY("1", "0")); } -// +// /* #define STYLE_STATVALUES VT_COLOR(VT_COL_TEXT_BLACK) @@ -169,15 +205,16 @@ int main(int argc, char **argv) { #ifdef _WIN32 { - WORD wVersionRequested; // requested version WinSock API + WORD wVersionRequested; // requested version WinSock API WSADATA wsadata; // Windows Sockets API data int stat; + wVersionRequested = 0x0101; - stat = WSAStartup( wVersionRequested, &wsadata ); + stat = WSAStartup(wVersionRequested, &wsadata); if (stat != 0) { printf("Winsock not found!\n"); return; - } else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) { + } else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) { printf("WINSOCK.DLL does not support version 1.1\n"); WSACleanup(); return; @@ -185,7 +222,7 @@ int main(int argc, char **argv) { } #endif - signal_handlers(); + signal_handlers(); hts_init(); opt = global_opt = hts_create_opt(); @@ -213,289 +250,293 @@ int main(int argc, char **argv) { CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, NULL); - ret = hts_main2(argc, argv, opt); + ret = hts_main2(argc, argv, opt); if (ret) { fprintf(stderr, "* %s\n", hts_errmsg(opt)); } - global_opt = NULL; - hts_free_opt(opt); - htsthread_wait(); /* wait for pending threads */ - hts_uninit(); + global_opt = NULL; + hts_free_opt(opt); + htsthread_wait(); /* wait for pending threads */ + hts_uninit(); #ifdef _WIN32 WSACleanup(); #endif - return ret; + return ret; } - /* CALLBACK FUNCTIONS */ /* Initialize the Winsock */ -static void __cdecl htsshow_init(t_hts_callbackarg *carg) { +static void __cdecl htsshow_init(t_hts_callbackarg * carg) { } -static void __cdecl htsshow_uninit(t_hts_callbackarg *carg) { +static void __cdecl htsshow_uninit(t_hts_callbackarg * carg) { } -static int __cdecl htsshow_start(t_hts_callbackarg *carg, httrackp* opt) { - use_show=0; - if (opt->verbosedisplay==2) { - use_show=1; +static int __cdecl htsshow_start(t_hts_callbackarg * carg, httrackp * opt) { + use_show = 0; + if (opt->verbosedisplay == 2) { + use_show = 1; vt_clear(); } - return 1; + return 1; } -static int __cdecl htsshow_chopt(t_hts_callbackarg *carg, httrackp* opt) { +static int __cdecl htsshow_chopt(t_hts_callbackarg * carg, httrackp * opt) { return htsshow_start(carg, opt); } -static int __cdecl htsshow_end(t_hts_callbackarg *carg, httrackp* opt) { - return 1; +static int __cdecl htsshow_end(t_hts_callbackarg * carg, httrackp * opt) { + return 1; } -static int __cdecl htsshow_preprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) { +static int __cdecl htsshow_preprocesshtml(t_hts_callbackarg * carg, + httrackp * opt, char **html, int *len, + const char *url_address, + const char *url_file) { return 1; } -static int __cdecl htsshow_postprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) { +static int __cdecl htsshow_postprocesshtml(t_hts_callbackarg * carg, + httrackp * opt, char **html, + int *len, const char *url_address, + const char *url_file) { return 1; } -static int __cdecl htsshow_checkhtml(t_hts_callbackarg *carg, httrackp *opt, char* html,int len,const char* url_address,const char* url_file) { +static int __cdecl htsshow_checkhtml(t_hts_callbackarg * carg, httrackp * opt, + char *html, int len, + const char *url_address, + const char *url_file) { return 1; } -static int __cdecl htsshow_loop(t_hts_callbackarg *carg, httrackp *opt, lien_back* back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time, hts_stat_struct* stats) { // appelé à chaque boucle de HTTrack - static TStamp prev_mytime=0; /* ok */ - static t_InpInfo SInfo; /* ok */ +static int __cdecl htsshow_loop(t_hts_callbackarg * carg, httrackp * opt, lien_back * back, int back_max, int back_index, int lien_n, int lien_tot, int stat_time, hts_stat_struct * stats) { // appelé à chaque boucle de HTTrack + static TStamp prev_mytime = 0; /* ok */ + static t_InpInfo SInfo; /* ok */ + // TStamp mytime; - long int rate=0; + long int rate = 0; char st[256]; + // - int stat_written=-1; - int stat_updated=-1; - int stat_errors=-1; - int stat_warnings=-1; - int stat_infos=-1; - int nbk=-1; - LLint nb=-1; - int stat_nsocket=-1; - LLint stat_bytes=-1; - LLint stat_bytes_recv=-1; - int irate=-1; + int stat_written = -1; + int stat_updated = -1; + int stat_errors = -1; + int stat_warnings = -1; + int stat_infos = -1; + int nbk = -1; + LLint nb = -1; + int stat_nsocket = -1; + LLint stat_bytes = -1; + LLint stat_bytes_recv = -1; + int irate = -1; + if (stats) { - stat_written=stats->stat_files; - stat_updated=stats->stat_updated_files; - stat_errors=stats->stat_errors; - stat_warnings=stats->stat_warnings; - stat_infos=stats->stat_infos; - nbk=stats->nbk; - stat_nsocket=stats->stat_nsocket; - irate=(int)stats->rate; - nb=stats->nb; - stat_bytes=stats->nb; - stat_bytes_recv=stats->HTS_TOTAL_RECV; + stat_written = stats->stat_files; + stat_updated = stats->stat_updated_files; + stat_errors = stats->stat_errors; + stat_warnings = stats->stat_warnings; + stat_infos = stats->stat_infos; + nbk = stats->nbk; + stat_nsocket = stats->stat_nsocket; + irate = (int) stats->rate; + nb = stats->nb; + stat_bytes = stats->nb; + stat_bytes_recv = stats->HTS_TOTAL_RECV; } if (!use_show) return 1; - mytime=mtime_local(); - if ((stat_time>0) && (stat_bytes_recv>0)) - rate=(int)(stat_bytes_recv/stat_time); + mytime = mtime_local(); + if ((stat_time > 0) && (stat_bytes_recv > 0)) + rate = (int) (stat_bytes_recv / stat_time); else - rate=0; // pas d'infos + rate = 0; // pas d'infos /* Infos */ - if (stat_bytes>=0) SInfo.stat_bytes=stat_bytes; // bytes - if (stat_time>=0) SInfo.stat_time=stat_time; // time - if (lien_tot>=0) SInfo.lien_tot=lien_tot; // nb liens - if (lien_n>=0) SInfo.lien_n=lien_n; // scanned - SInfo.stat_nsocket=stat_nsocket; // socks - if (rate>0) SInfo.rate=rate; // rate - if (irate>=0) SInfo.irate=irate; // irate - if (SInfo.irate<0) SInfo.irate=SInfo.rate; - if (nbk>=0) SInfo.stat_back=nbk; - if (stat_written>=0) SInfo.stat_written=stat_written; - if (stat_updated>=0) SInfo.stat_updated=stat_updated; - if (stat_errors>=0) SInfo.stat_errors=stat_errors; - if (stat_warnings>=0) SInfo.stat_warnings=stat_warnings; - if (stat_infos>=0) SInfo.stat_infos=stat_infos; - - - if ( ((mytime - prev_mytime)>100) || ((mytime - prev_mytime)<0) ) { - strc_int2bytes2 strc, strc2, strc3; - prev_mytime=mytime; - - - st[0]='\0'; - qsec2str(st,stat_time); + if (stat_bytes >= 0) + SInfo.stat_bytes = stat_bytes; // bytes + if (stat_time >= 0) + SInfo.stat_time = stat_time; // time + if (lien_tot >= 0) + SInfo.lien_tot = lien_tot; // nb liens + if (lien_n >= 0) + SInfo.lien_n = lien_n; // scanned + SInfo.stat_nsocket = stat_nsocket; // socks + if (rate > 0) + SInfo.rate = rate; // rate + if (irate >= 0) + SInfo.irate = irate; // irate + if (SInfo.irate < 0) + SInfo.irate = SInfo.rate; + if (nbk >= 0) + SInfo.stat_back = nbk; + if (stat_written >= 0) + SInfo.stat_written = stat_written; + if (stat_updated >= 0) + SInfo.stat_updated = stat_updated; + if (stat_errors >= 0) + SInfo.stat_errors = stat_errors; + if (stat_warnings >= 0) + SInfo.stat_warnings = stat_warnings; + if (stat_infos >= 0) + SInfo.stat_infos = stat_infos; + + if (((mytime - prev_mytime) > 100) || ((mytime - prev_mytime) < 0)) { + strc_int2bytes2 strc, strc2, strc3; + + prev_mytime = mytime; + + st[0] = '\0'; + qsec2str(st, stat_time); vt_home(); - printf( - VT_GOTOXY("1","1") - VT_CLREOL - STYLE_STATTEXT "Bytes saved:" - STYLE_STATVALUES " \t%s" - "\t" - VT_CLREOL - VT_GOTOXY("40","1") - STYLE_STATTEXT "Links scanned:" - STYLE_STATVALUES " \t%d/%d (+%d)" - VT_CLREOL"\n"VT_CLREOL - VT_GOTOXY("1","2") - STYLE_STATTEXT "Time:" - " \t" - STYLE_STATVALUES "%s" - "\t" - VT_CLREOL - VT_GOTOXY("40","2") - STYLE_STATTEXT "Files written:" - " \t" - STYLE_STATVALUES "%d" - VT_CLREOL"\n"VT_CLREOL - VT_GOTOXY("1","3") - STYLE_STATTEXT "Transfer rate:" - " \t" - STYLE_STATVALUES "%s (%s)" - "\t" - VT_CLREOL - VT_GOTOXY("40","3") - STYLE_STATTEXT "Files updated:" - " \t" - STYLE_STATVALUES "%d" - VT_CLREOL"\n"VT_CLREOL - VT_GOTOXY("1","4") - STYLE_STATTEXT "Active connections:" - " \t" - STYLE_STATVALUES "%d" - "\t" - VT_CLREOL - VT_GOTOXY("40","4") - STYLE_STATTEXT "Errors:" - STYLE_STATVALUES " \t" - STYLE_STATVALUES "%d" - VT_CLREOL"\n" - STYLE_STATRESET - , - /* */ - (char*)int2bytes(&strc,SInfo.stat_bytes), - (int)lien_n,(int)SInfo.lien_tot,(int)nbk, - (char*)st, - (int)SInfo.stat_written, - (char*)int2bytessec(&strc2,SInfo.irate),(char*)int2bytessec(&strc3,SInfo.rate), - (int)SInfo.stat_updated, - (int)SInfo.stat_nsocket, - (int)SInfo.stat_errors - /* */ + printf(VT_GOTOXY("1", "1") + VT_CLREOL STYLE_STATTEXT "Bytes saved:" STYLE_STATVALUES " \t%s" "\t" + VT_CLREOL VT_GOTOXY("40", "1") + STYLE_STATTEXT "Links scanned:" STYLE_STATVALUES " \t%d/%d (+%d)" + VT_CLREOL "\n" VT_CLREOL VT_GOTOXY("1", "2") + STYLE_STATTEXT "Time:" " \t" STYLE_STATVALUES "%s" "\t" VT_CLREOL + VT_GOTOXY("40", "2") + STYLE_STATTEXT "Files written:" " \t" STYLE_STATVALUES "%d" VT_CLREOL + "\n" VT_CLREOL VT_GOTOXY("1", "3") + STYLE_STATTEXT "Transfer rate:" " \t" STYLE_STATVALUES "%s (%s)" "\t" + VT_CLREOL VT_GOTOXY("40", "3") + STYLE_STATTEXT "Files updated:" " \t" STYLE_STATVALUES "%d" VT_CLREOL + "\n" VT_CLREOL VT_GOTOXY("1", "4") + STYLE_STATTEXT "Active connections:" " \t" STYLE_STATVALUES "%d" "\t" + VT_CLREOL VT_GOTOXY("40", "4") + STYLE_STATTEXT "Errors:" STYLE_STATVALUES " \t" STYLE_STATVALUES "%d" + VT_CLREOL "\n" STYLE_STATRESET, + /* */ + (char *) int2bytes(&strc, SInfo.stat_bytes), (int) lien_n, + (int) SInfo.lien_tot, (int) nbk, (char *) st, + (int) SInfo.stat_written, (char *) int2bytessec(&strc2, SInfo.irate), + (char *) int2bytessec(&strc3, SInfo.rate), (int) SInfo.stat_updated, + (int) SInfo.stat_nsocket, (int) SInfo.stat_errors + /* */ ); - // parcourir registre des liens - if (back_index>=0) { // seulement si index passé - int j,k; - int index=0; - int ok=0; // idem - int l; // idem + if (back_index >= 0) { // seulement si index passé + int j, k; + int index = 0; + int ok = 0; // idem + int l; // idem + // t_StatsBuffer StatsBuffer[NStatsBuffer]; - + { int i; - for(i=0;i<NStatsBuffer;i++) { - strcpybuff(StatsBuffer[i].state,""); - strcpybuff(StatsBuffer[i].name,""); - strcpybuff(StatsBuffer[i].file,""); - strcpybuff(StatsBuffer[i].url_sav,""); - StatsBuffer[i].back=0; - StatsBuffer[i].size=0; - StatsBuffer[i].sizetot=0; + + for(i = 0; i < NStatsBuffer; i++) { + strcpybuff(StatsBuffer[i].state, ""); + strcpybuff(StatsBuffer[i].name, ""); + strcpybuff(StatsBuffer[i].file, ""); + strcpybuff(StatsBuffer[i].url_sav, ""); + StatsBuffer[i].back = 0; + StatsBuffer[i].size = 0; + StatsBuffer[i].sizetot = 0; } } - for(k=0;k<2;k++) { // 0: lien en cours 1: autres liens - for(j=0;(j<3) && (index<NStatsBuffer);j++) { // passe de priorité + for(k = 0; k < 2; k++) { // 0: lien en cours 1: autres liens + for(j = 0; (j < 3) && (index < NStatsBuffer); j++) { // passe de priorité int _i; - for(_i=0+k;(_i< max(back_max*k,1) ) && (index<NStatsBuffer);_i++) { // no lien - int i=(back_index+_i)%back_max; // commencer par le "premier" (l'actuel) - if (back[i].status>=0) { // signifie "lien actif" + + for(_i = 0 + k; (_i < max(back_max * k, 1)) && (index < NStatsBuffer); _i++) { // no lien + int i = (back_index + _i) % back_max; // commencer par le "premier" (l'actuel) + + if (back[i].status >= 0) { // signifie "lien actif" // int ok=0; // OPTI - ok=0; - switch(j) { - case 0: // prioritaire - if ((back[i].status>0) && (back[i].status<99)) { - strcpybuff(StatsBuffer[index].state,"receive"); ok=1; + ok = 0; + switch (j) { + case 0: // prioritaire + if ((back[i].status > 0) && (back[i].status < 99)) { + strcpybuff(StatsBuffer[index].state, "receive"); + ok = 1; } break; case 1: - if (back[i].status==STATUS_WAIT_HEADERS) { - strcpybuff(StatsBuffer[index].state,"request"); ok=1; - } - else if (back[i].status==STATUS_CONNECTING) { - strcpybuff(StatsBuffer[index].state,"connect"); ok=1; - } - else if (back[i].status==STATUS_WAIT_DNS) { - strcpybuff(StatsBuffer[index].state,"search"); ok=1; - } - else if (back[i].status==STATUS_FTP_TRANSFER) { // ohh le beau ftp - sprintf(StatsBuffer[index].state,"ftp: %s",back[i].info); ok=1; + if (back[i].status == STATUS_WAIT_HEADERS) { + strcpybuff(StatsBuffer[index].state, "request"); + ok = 1; + } else if (back[i].status == STATUS_CONNECTING) { + strcpybuff(StatsBuffer[index].state, "connect"); + ok = 1; + } else if (back[i].status == STATUS_WAIT_DNS) { + strcpybuff(StatsBuffer[index].state, "search"); + ok = 1; + } else if (back[i].status == STATUS_FTP_TRANSFER) { // ohh le beau ftp + sprintf(StatsBuffer[index].state, "ftp: %s", back[i].info); + ok = 1; } break; default: - if (back[i].status==STATUS_READY) { // prêt - if ((back[i].r.statuscode==200)) { - strcpybuff(StatsBuffer[index].state,"ready"); ok=1; - } - else if ((back[i].r.statuscode>=100) && (back[i].r.statuscode<=599)) { - char tempo[256]; tempo[0]='\0'; - infostatuscode(tempo,back[i].r.statuscode); - strcpybuff(StatsBuffer[index].state,tempo); ok=1; - } - else { - strcpybuff(StatsBuffer[index].state,"error"); ok=1; + if (back[i].status == STATUS_READY) { // prêt + if ((back[i].r.statuscode == 200)) { + strcpybuff(StatsBuffer[index].state, "ready"); + ok = 1; + } else if ((back[i].r.statuscode >= 100) + && (back[i].r.statuscode <= 599)) { + char tempo[256]; + + tempo[0] = '\0'; + infostatuscode(tempo, back[i].r.statuscode); + strcpybuff(StatsBuffer[index].state, tempo); + ok = 1; + } else { + strcpybuff(StatsBuffer[index].state, "error"); + ok = 1; } } break; } - + if (ok) { - char BIGSTK s[HTS_URLMAXSIZE*2]; + char BIGSTK s[HTS_URLMAXSIZE * 2]; + // - StatsBuffer[index].back=i; // index pour + d'infos + StatsBuffer[index].back = i; // index pour + d'infos // - s[0]='\0'; - strcpybuff(StatsBuffer[index].url_sav,back[i].url_sav); // pour cancel - if (strcmp(back[i].url_adr,"file://")) - strcatbuff(s,back[i].url_adr); + s[0] = '\0'; + strcpybuff(StatsBuffer[index].url_sav, back[i].url_sav); // pour cancel + if (strcmp(back[i].url_adr, "file://")) + strcatbuff(s, back[i].url_adr); else - strcatbuff(s,"localhost"); - if (back[i].url_fil[0]!='/') - strcatbuff(s,"/"); - strcatbuff(s,back[i].url_fil); - - StatsBuffer[index].file[0]='\0'; + strcatbuff(s, "localhost"); + if (back[i].url_fil[0] != '/') + strcatbuff(s, "/"); + strcatbuff(s, back[i].url_fil); + + StatsBuffer[index].file[0] = '\0'; { - char* a=strrchr(s,'/'); + char *a = strrchr(s, '/'); + if (a) { - strncatbuff(StatsBuffer[index].file,a,200); - *a='\0'; + strncatbuff(StatsBuffer[index].file, a, 200); + *a = '\0'; } } - - if ((l = (int) strlen(s))<MAX_LEN_INPROGRESS) - strcpybuff(StatsBuffer[index].name,s); + + if ((l = (int) strlen(s)) < MAX_LEN_INPROGRESS) + strcpybuff(StatsBuffer[index].name, s); else { // couper - StatsBuffer[index].name[0]='\0'; - strncatbuff(StatsBuffer[index].name,s,MAX_LEN_INPROGRESS/2-2); - strcatbuff(StatsBuffer[index].name,"..."); - strcatbuff(StatsBuffer[index].name,s+l-MAX_LEN_INPROGRESS/2+2); + StatsBuffer[index].name[0] = '\0'; + strncatbuff(StatsBuffer[index].name, s, + MAX_LEN_INPROGRESS / 2 - 2); + strcatbuff(StatsBuffer[index].name, "..."); + strcatbuff(StatsBuffer[index].name, + s + l - MAX_LEN_INPROGRESS / 2 + 2); } - - if (back[i].r.totalsize>=0) { // taille prédéfinie - StatsBuffer[index].sizetot=back[i].r.totalsize; - StatsBuffer[index].size=back[i].r.size; - } else { // pas de taille prédéfinie - if (back[i].status==STATUS_READY) { // prêt - StatsBuffer[index].sizetot=back[i].r.size; - StatsBuffer[index].size=back[i].r.size; + + if (back[i].r.totalsize >= 0) { // taille prédéfinie + StatsBuffer[index].sizetot = back[i].r.totalsize; + StatsBuffer[index].size = back[i].r.size; + } else { // pas de taille prédéfinie + if (back[i].status == STATUS_READY) { // prêt + StatsBuffer[index].sizetot = back[i].r.size; + StatsBuffer[index].size = back[i].r.size; } else { - StatsBuffer[index].sizetot=8192; - StatsBuffer[index].size=(back[i].r.size % 8192); + StatsBuffer[index].sizetot = 8192; + StatsBuffer[index].size = (back[i].r.size % 8192); } } index++; @@ -506,21 +547,22 @@ static int __cdecl htsshow_loop(t_hts_callbackarg *carg, httrackp *opt, lien_bac } /* LF */ - printf("%s\n",VT_CLREOL); + printf("%s\n", VT_CLREOL); /* Display current job */ { - int parsing=0; + int parsing = 0; + printf("Current job: "); - if (!(parsing=hts_is_parsing(opt, -1))) + if (!(parsing = hts_is_parsing(opt, -1))) printf("receiving files"); else { - switch(hts_is_testing(opt)) { + switch (hts_is_testing(opt)) { case 0: - printf("parsing HTML file (%d%%)",parsing); + printf("parsing HTML file (%d%%)", parsing); break; case 1: - printf("parsing HTML file: testing links (%d%%)",parsing); + printf("parsing HTML file: testing links (%d%%)", parsing); break; case 2: printf("purging files"); @@ -536,65 +578,66 @@ static int __cdecl htsshow_loop(t_hts_callbackarg *carg, httrackp *opt, lien_bac break; } } - printf("%s\n",VT_CLREOL); + printf("%s\n", VT_CLREOL); } - + /* Display background jobs */ { int i; - for(i=0;i<NStatsBuffer;i++) { + + for(i = 0; i < NStatsBuffer; i++) { if (strnotempty(StatsBuffer[i].state)) { - printf(VT_CLREOL" %s - \t%s%s \t%s / \t%s", - StatsBuffer[i].state, - StatsBuffer[i].name, - StatsBuffer[i].file, - int2bytes(&strc,StatsBuffer[i].size), - int2bytes(&strc2,StatsBuffer[i].sizetot) + printf(VT_CLREOL " %s - \t%s%s \t%s / \t%s", StatsBuffer[i].state, + StatsBuffer[i].name, StatsBuffer[i].file, int2bytes(&strc, + StatsBuffer + [i]. + size), + int2bytes(&strc2, StatsBuffer[i].sizetot) ); } - printf("%s\n",VT_CLREOL); + printf("%s\n", VT_CLREOL); } } - } } - - return 1; } -static const char* __cdecl htsshow_query(t_hts_callbackarg *carg, httrackp *opt, const char* question) { - static char s[12]=""; /* ok */ +static const char *__cdecl htsshow_query(t_hts_callbackarg * carg, + httrackp * opt, const char *question) { + static char s[12] = ""; /* ok */ + printf("%s\nPress <Y><Enter> to confirm, <N><Enter> to abort\n", question); io_flush; - linput(stdin,s,4); + linput(stdin, s, 4); return s; } -static const char* __cdecl htsshow_query2(t_hts_callbackarg *carg, httrackp *opt, const char* question) { - static char s[12]=""; /* ok */ +static const char *__cdecl htsshow_query2(t_hts_callbackarg * carg, + httrackp * opt, + const char *question) { + static char s[12] = ""; /* ok */ + printf("%s\nPress <Y><Enter> to confirm, <N><Enter> to abort\n", question); io_flush; - linput(stdin,s,4); + linput(stdin, s, 4); return s; } -static const char* __cdecl htsshow_query3(t_hts_callbackarg *carg, httrackp *opt, const char* question) { - static char line[256]; /* ok */ - printf( - "\n" - "A link, %s, is located beyond this mirror scope.\n" - "What should I do? (type in the choice + enter)\n\n" - "* Ignore all further links and do not ask any more questions\n" - "0 Ignore this link (default if empty entry)\n" - "1 Ignore directory and lower structures\n" - "2 Ignore all domain\n" - "\n" - "4 Get only this page/link, but not links inside this page\n" - "5 Mirror this link (useful)\n" - "6 Mirror all links located on the same domain as this link\n" - "\n", - question); +static const char *__cdecl htsshow_query3(t_hts_callbackarg * carg, + httrackp * opt, + const char *question) { + static char line[256]; /* ok */ + + printf("\n" "A link, %s, is located beyond this mirror scope.\n" + "What should I do? (type in the choice + enter)\n\n" + "* Ignore all further links and do not ask any more questions\n" + "0 Ignore this link (default if empty entry)\n" + "1 Ignore directory and lower structures\n" "2 Ignore all domain\n" + "\n" "4 Get only this page/link, but not links inside this page\n" + "5 Mirror this link (useful)\n" + "6 Mirror all links located on the same domain as this link\n" "\n", + question); do { printf(">> "); io_flush; @@ -603,45 +646,70 @@ static const char* __cdecl htsshow_query3(t_hts_callbackarg *carg, httrackp *opt printf("ok..\n"); return line; } -static int __cdecl htsshow_check(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,int status) { +static int __cdecl htsshow_check(t_hts_callbackarg * carg, httrackp * opt, + const char *adr, const char *fil, int status) { return -1; } -static int __cdecl htsshow_check_mime(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,const char* mime,int status) { +static int __cdecl htsshow_check_mime(t_hts_callbackarg * carg, httrackp * opt, + const char *adr, const char *fil, + const char *mime, int status) { return -1; } -static void __cdecl htsshow_pause(t_hts_callbackarg *carg, httrackp *opt, const char* lockfile) { - while (fexist(lockfile)) { +static void __cdecl htsshow_pause(t_hts_callbackarg * carg, httrackp * opt, + const char *lockfile) { + while(fexist(lockfile)) { Sleep(1000); } } -static void __cdecl htsshow_filesave(t_hts_callbackarg *carg, httrackp *opt, const char* file) { +static void __cdecl htsshow_filesave(t_hts_callbackarg * carg, httrackp * opt, + const char *file) { } -static void __cdecl htsshow_filesave2(t_hts_callbackarg *carg, httrackp *opt, const char* adr, const char* fil, const char* save, int is_new, int is_modified,int not_updated) { +static void __cdecl htsshow_filesave2(t_hts_callbackarg * carg, httrackp * opt, + const char *adr, const char *fil, + const char *save, int is_new, + int is_modified, int not_updated) { } -static int __cdecl htsshow_linkdetected(t_hts_callbackarg *carg, httrackp *opt, char* link) { +static int __cdecl htsshow_linkdetected(t_hts_callbackarg * carg, + httrackp * opt, char *link) { return 1; } -static int __cdecl htsshow_linkdetected2(t_hts_callbackarg *carg, httrackp *opt, char* link, const char* start_tag) { +static int __cdecl htsshow_linkdetected2(t_hts_callbackarg * carg, + httrackp * opt, char *link, + const char *start_tag) { return 1; } -static int __cdecl htsshow_xfrstatus(t_hts_callbackarg *carg, httrackp *opt, lien_back* back) { +static int __cdecl htsshow_xfrstatus(t_hts_callbackarg * carg, httrackp * opt, + lien_back * back) { return 1; } -static int __cdecl htsshow_savename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete,const char* fil_complete,const char* referer_adr,const char* referer_fil,char* save) { +static int __cdecl htsshow_savename(t_hts_callbackarg * carg, httrackp * opt, + const char *adr_complete, + const char *fil_complete, + const char *referer_adr, + const char *referer_fil, char *save) { return 1; } -static int __cdecl htsshow_sendheader(t_hts_callbackarg *carg, httrackp *opt, char* buff, const char* adr, const char* fil, const char* referer_adr, const char* referer_fil, htsblk* outgoing) { +static int __cdecl htsshow_sendheader(t_hts_callbackarg * carg, httrackp * opt, + char *buff, const char *adr, + const char *fil, const char *referer_adr, + const char *referer_fil, + htsblk * outgoing) { return 1; } -static int __cdecl htsshow_receiveheader(t_hts_callbackarg *carg, httrackp *opt, char* buff, const char* adr, const char* fil, const char* referer_adr, const char* referer_fil, htsblk* incoming) { +static int __cdecl htsshow_receiveheader(t_hts_callbackarg * carg, + httrackp * opt, char *buff, + const char *adr, const char *fil, + const char *referer_adr, + const char *referer_fil, + htsblk * incoming) { return 1; } /* *** Various functions *** */ - -static int fexist(const char* s) { +static int fexist(const char *s) { struct stat st; + memset(&st, 0, sizeof(st)); if (stat(s, &st) == 0) { if (S_ISREG(st.st_mode)) { @@ -649,68 +717,78 @@ static int fexist(const char* s) { } } return 0; -} +} -static int linput(FILE* fp,char* s,int max) { +static int linput(FILE * fp, char *s, int max) { int c; - int j=0; + int j = 0; + do { - c=fgetc(fp); - if (c!=EOF) { - 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; + c = fgetc(fp); + if (c != EOF) { + 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; } } - } while((c!=-1) && (c!=EOF) && (j<(max-1))); - s[j]='\0'; + } while((c != -1) && (c != EOF) && (j < (max - 1))); + s[j] = '\0'; return j; } - // routines de détournement de SIGHUP & co (Unix) // -static void sig_ignore( int code ) { // ignorer signal +static void sig_ignore(int code) { // ignorer signal } -static void sig_term( int code ) { // quitter brutalement - fprintf(stderr,"\nProgram terminated (signal %d)\n",code); +static void sig_term(int code) { // quitter brutalement + fprintf(stderr, "\nProgram terminated (signal %d)\n", code); exit(0); } -static void sig_finish( int code ) { // finir et quitter - signal(code,sig_term); // quitter si encore - if (global_opt != NULL) { - global_opt->state.exit_xh=1; - } - fprintf(stderr,"\nExit requested to engine (signal %d)\n",code); +static void sig_finish(int code) { // finir et quitter + signal(code, sig_term); // quitter si encore + if (global_opt != NULL) { + global_opt->state.exit_xh = 1; + } + fprintf(stderr, "\nExit requested to engine (signal %d)\n", code); } #ifdef _WIN32 #if 0 -static void sig_ask( int code ) { // demander +static void sig_ask(int code) { // demander char s[256]; - signal(code,sig_term); // quitter si encore + + signal(code, sig_term); // quitter si encore printf("\nQuit program/Interrupt/Cancel? (Q/I/C) "); fflush(stdout); - scanf("%s",s); - if ( (s[0]=='y') || (s[0]=='Y') || (s[0]=='o') || (s[0]=='O') || (s[0]=='q') || (s[0]=='Q')) - exit(0); // quitter - else if ( (s[0]=='i') || (s[0]=='I') ) { + scanf("%s", s); + if ((s[0] == 'y') || (s[0] == 'Y') || (s[0] == 'o') || (s[0] == 'O') + || (s[0] == 'q') || (s[0] == 'Q')) + exit(0); // quitter + else if ((s[0] == 'i') || (s[0] == 'I')) { if (global_opt != NULL) { // ask for stop - global_opt->state.stop=1; + global_opt->state.stop = 1; } } - signal(code,sig_ask); // remettre signal + signal(code, sig_ask); // remettre signal } #endif #else static void sig_doback(int blind); -static void sig_back( int code ) { // ignorer et mettre en backing +static void sig_back(int code) { // ignorer et mettre en backing if (global_opt != NULL && !global_opt->background_on_suspend) { - signal( SIGTSTP , SIG_DFL); // ^Z - printf("\nInterrupting the program.\n"); fflush(stdout); + signal(SIGTSTP, SIG_DFL); // ^Z + printf("\nInterrupting the program.\n"); + fflush(stdout); kill(getpid(), SIGTSTP); } else { // Background the process. @@ -718,76 +796,81 @@ static void sig_back( int code ) { // ignorer et mettre en backing sig_doback(0); } } + #if 0 -static void sig_ask( int code ) { // demander +static void sig_ask(int code) { // demander char s[256]; - signal(code,sig_term); // quitter si encore - printf("\nQuit program/Interrupt/Background/bLind background/Cancel? (Q/I/B/L/C) "); + + signal(code, sig_term); // quitter si encore + printf + ("\nQuit program/Interrupt/Background/bLind background/Cancel? (Q/I/B/L/C) "); fflush(stdout); - scanf("%s",s); - if ( (s[0]=='y') || (s[0]=='Y') || (s[0]=='o') || (s[0]=='O') || (s[0]=='q') || (s[0]=='Q')) - exit(0); // quitter - else if ( (s[0]=='b') || (s[0]=='B') || (s[0]=='a') || (s[0]=='A') ) - sig_doback(0); // arrière plan - else if ( (s[0]=='l') || (s[0]=='L') ) - sig_doback(1); // arrière plan - else if ( (s[0]=='i') || (s[0]=='I') ) { + scanf("%s", s); + if ((s[0] == 'y') || (s[0] == 'Y') || (s[0] == 'o') || (s[0] == 'O') + || (s[0] == 'q') || (s[0] == 'Q')) + exit(0); // quitter + else if ((s[0] == 'b') || (s[0] == 'B') || (s[0] == 'a') || (s[0] == 'A')) + sig_doback(0); // arrière plan + else if ((s[0] == 'l') || (s[0] == 'L')) + sig_doback(1); // arrière plan + else if ((s[0] == 'i') || (s[0] == 'I')) { if (global_opt != NULL) { // ask for stop printf("finishing pending transfers.. please wait\n"); - global_opt->state.stop=1; + global_opt->state.stop = 1; } - signal(code,sig_ask); // remettre signal - } - else { + signal(code, sig_ask); // remettre signal + } else { printf("cancel..\n"); - signal(code,sig_ask); // remettre signal + signal(code, sig_ask); // remettre signal } } #endif -static void sig_brpipe( int code ) { // treat if necessary +static void sig_brpipe(int code) { // treat if necessary signal(code, sig_brpipe); } -static void sig_doback(int blind) { // mettre en backing - int out=-1; +static void sig_doback(int blind) { // mettre en backing + int out = -1; + // - printf("\nMoving into background to complete the mirror...\n"); fflush(stdout); + printf("\nMoving into background to complete the mirror...\n"); + fflush(stdout); - if (global_opt != NULL) { - // suppress logging and asking lousy questions - global_opt->quiet=1; - global_opt->verbosedisplay=0; + if (global_opt != NULL) { + // suppress logging and asking lousy questions + global_opt->quiet = 1; + global_opt->verbosedisplay = 0; } if (!blind) - out = open("hts-nohup.out",O_CREAT|O_WRONLY,S_IRUSR|S_IWUSR); + out = open("hts-nohup.out", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); if (out == -1) - out = open("/dev/null",O_WRONLY,S_IRUSR|S_IWUSR); + out = open("/dev/null", O_WRONLY, S_IRUSR | S_IWUSR); dup2(out, 0); dup2(out, 1); dup2(out, 2); // switch (fork()) { - case 0: + case 0: break; case -1: - fprintf(stderr,"Error: can not fork process\n"); + fprintf(stderr, "Error: can not fork process\n"); break; - default: // pere + default: // pere _exit(0); - break; - } + break; + } } #endif -static void sig_leave( int code ) { +static void sig_leave(int code) { if (global_opt != NULL && global_opt->state._hts_in_mirror) { - signal(code, sig_term); // quitter si encore + signal(code, sig_term); // quitter si encore printf("\n** Finishing pending transfers.. press again ^C to quit.\n"); if (global_opt != NULL) { // ask for stop hts_log_print(global_opt, LOG_ERROR, "Exit requested by shell or user"); - global_opt->state.stop=1; + global_opt->state.stop = 1; } } else { sig_term(code); @@ -797,26 +880,26 @@ static void sig_leave( int code ) { static void signal_handlers(void) { #ifdef _WIN32 #ifndef _WIN32_WCE -#if 0 /* BUG366763 */ - signal( SIGINT , sig_ask ); // ^C +#if 0 /* BUG366763 */ + signal(SIGINT, sig_ask); // ^C #else - signal( SIGINT , sig_leave ); // ^C + signal(SIGINT, sig_leave); // ^C #endif - signal( SIGTERM , sig_finish ); // kill <process> + signal(SIGTERM, sig_finish); // kill <process> #endif #else -#if 0 /* BUG366763 */ - signal( SIGHUP , sig_back ); // close window +#if 0 /* BUG366763 */ + signal(SIGHUP, sig_back); // close window #endif - signal( SIGTSTP , sig_back ); // ^Z - signal( SIGTERM , sig_finish ); // kill <process> -#if 0 /* BUG366763 */ - signal( SIGINT , sig_ask ); // ^C + signal(SIGTSTP, sig_back); // ^Z + signal(SIGTERM, sig_finish); // kill <process> +#if 0 /* BUG366763 */ + signal(SIGINT, sig_ask); // ^C #else - signal( SIGINT , sig_leave ); // ^C + signal(SIGINT, sig_leave); // ^C #endif - signal( SIGPIPE , sig_brpipe ); // broken pipe (write into non-opened socket) - signal( SIGCHLD , sig_ignore ); // child change status + signal(SIGPIPE, sig_brpipe); // broken pipe (write into non-opened socket) + signal(SIGCHLD, sig_ignore); // child change status #endif } |