BOOL CNewProj::OnKillActive( ) { CString st; char tempo[HTS_URLMAXSIZE*2]; GetDlgItemText(IDC_projpath,st); if (st.GetLength() > MAX_PATH) { return FALSE; } strcpybuff(tempo,st); if ((tempo[strlen(tempo)-1]=='/') || (tempo[strlen(tempo)-1]=='\\')) { tempo[strlen(tempo)-1]='\0'; SetDlgItemTextCP(this, IDC_projpath,tempo); } UpdateData(TRUE); // DoDataExchange // créer structure { char dest[HTS_URLMAXSIZE*2]; int i=0; strcpybuff(dest,GetPath()+"hts-cache\\"); { char* a; while(a=strchr(dest,'\\')) *a='/'; structcheck(dest); } } CShellApp_app->end_path=dialog0->GetBasePath(); CShellApp_app->end_path_complete=dialog0->GetPath(); Build_TopIndex(FALSE); // structure visible TStamp t_start = mtime_local(); // FIXME: VERY SLOW!! this_DirTreeView->EnsureVisible(GetPath()+"hts-cache"); TStamp t_end = mtime_local(); //TStamp l_dir = t_end - t_start; //CString a; //a.Format("t=%dms", (int)l_dir); //(void) AfxMessageBox(a, MB_OK); // charger préfs dialog1->OnChangepathlog(); return 1; }
BOOL CNewProj::OnSetActive( ) { //this_CWizTab->SetWizardButtons(PSWIZB_BACK); WHTT_LOCATION("NewProj"); //if (!can_click_next) { // structure visible CString st; GetDlgItemText(IDC_projpath,st); TStamp t_start = mtime_local(); // FIXME: VERY SLOW!! this_DirTreeView->EnsureVisible(st+"\\index.html"); TStamp t_end = mtime_local(); //TStamp l_dir = t_end - t_start; //CString a; //a.Format("t=%dms", (int)l_dir); //(void) AfxMessageBox(a, MB_OK); SetDlgItemTextCP(this_CWizTab, IDCANCEL,LANG_CANCEL); //} else //this_CWizTab->PressButton(PSBTN_NEXT); 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 */ // TStamp mytime; 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; 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; } if (!use_show) return 1; mytime = mtime_local(); if ((stat_time > 0) && (stat_bytes_recv > 0)) rate = (int) (stat_bytes_recv / stat_time); else 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); 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 /* */ ); // 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 // 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 (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" // 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; } 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; } 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; } } break; } if (ok) { char BIGSTK s[HTS_URLMAXSIZE * 2]; // 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); else 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, '/'); if (a) { strncatbuff(StatsBuffer[index].file,a,200); *a = '\0'; } } 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); } 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); } } index++; } } } } } /* LF */ printf("%s\n", VT_CLREOL); /* Display current job */ { int parsing = 0; printf("Current job: "); if (!(parsing = hts_is_parsing(opt, -1))) printf("receiving files"); else { switch (hts_is_testing(opt)) { case 0: printf("parsing HTML file (%d%%)", parsing); break; case 1: printf("parsing HTML file: testing links (%d%%)", parsing); break; case 2: printf("purging files"); break; case 3: printf("loading cache"); break; case 4: printf("waiting (scheduler)"); break; case 5: printf("waiting (throttle)"); break; } } printf("%s\n", VT_CLREOL); } /* Display background jobs */ { int 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("%s\n", VT_CLREOL); } } } } return 1; }
void CNewProj::OnChangeprojpath() { CWaitCursor wait; CString st; CString old_name; char tempo[HTS_URLMAXSIZE*2]; GetDlgItemText(IDC_projname,old_name); GetDlgItemText(IDC_projpath,st); if (st.GetLength() > MAX_PATH) { SetDlgItemText(IDC_projpath, ""); return; } tempo[0] = '\0'; strcatbuff(tempo, st); if ((tempo[strlen(tempo)-1]=='/') || (tempo[strlen(tempo)-1]=='\\')) { tempo[strlen(tempo)-1]='\0'; //SetDlgItemTextCP(this, IDC_projpath,tempo); } strcatbuff(tempo,"\\"); TStamp t_start = mtime_local(); // chargement de la liste m_ctl_projname.ResetContent(); m_ctl_projcateg.ResetContent(); WIN32_FIND_DATA find; char pth[MAX_PATH + 32]; strcpybuff(pth,tempo); strcatbuff(pth,"*.*"); HANDLE h = FindFirstFile(pth,&find); if (h != INVALID_HANDLE_VALUE) { do { if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) if (!(find.dwFileAttributes & (FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN) )) if (strcmp(find.cFileName,"..")) if (strcmp(find.cFileName,".")) { CString st; st=tempo; st=st+find.cFileName; st=st+"\\hts-cache"; WIN32_FIND_DATA find2; HANDLE h2 = FindFirstFile(st,&find2); if (h2 != INVALID_HANDLE_VALUE) { FindClose(h2); m_ctl_projname.AddString(find.cFileName); // Read category st += "\\winprofile.ini"; CString strSection = "OptionsValues"; CString categ = MyGetProfileString(st, strSection, "Category"); if (categ.GetLength() > 0 && m_ctl_projcateg.FindStringExact(0, categ) < 0) { m_ctl_projcateg.AddString(categ); } } } } while(FindNextFile(h,&find)); FindClose(h); } // nouveau nom! SetDlgItemTextCP(this, IDC_projname,old_name); TStamp t_proj = mtime_local(); OnChangeprojname(); TStamp t_end = mtime_local(); TStamp l_dir = t_proj - t_start; TStamp l_proj = t_end - t_proj; //CString a; //a.Format("%s: build=%dms proj=%dms", __FUNCTION__, (int)l_dir, (int)l_proj); //(void) AfxMessageBox(a, MB_OK); }
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; // 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; // char st[256]; /* Exit now */ if (commandEndRequested == 2) return 0; /* Lock */ webhttrack_lock(); 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; } mytime=mtime_local(); if ((stat_time>0) && (stat_bytes_recv>0)) rate=(int)(stat_bytes_recv/stat_time); else 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; st[0]='\0'; qsec2str(st,stat_time); /* Set keys */ smallserver_setkeyint("info.stat_bytes", SInfo.stat_bytes); smallserver_setkeyint("info.stat_time", SInfo.stat_time); smallserver_setkeyint("info.lien_tot", SInfo.lien_tot); smallserver_setkeyint("info.lien_n", SInfo.lien_n); smallserver_setkeyint("info.stat_nsocket", SInfo.stat_nsocket); smallserver_setkeyint("info.rate", SInfo.rate); smallserver_setkeyint("info.irate", SInfo.irate); smallserver_setkeyint("info.stat_back", SInfo.stat_back); smallserver_setkeyint("info.stat_written", SInfo.stat_written); smallserver_setkeyint("info.stat_updated", SInfo.stat_updated); smallserver_setkeyint("info.stat_errors", SInfo.stat_errors); smallserver_setkeyint("info.stat_warnings", SInfo.stat_warnings); smallserver_setkeyint("info.stat_infos", SInfo.stat_infos); /* */ smallserver_setkey("info.stat_time_str", st); if ( ((mytime - prev_mytime)>100) || ((mytime - prev_mytime)<0) ) { prev_mytime=mytime; // parcourir registre des liens if (back_index>=0 && back_max > 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(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" // 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; } 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 char proto[] = "ftp"; if (back[i].url_adr[0]) { char* ep = strchr(back[i].url_adr, ':'); char* eps = strchr(back[i].url_adr, '/'); int count; if (ep != NULL && ep < eps && (count = (int) (ep - back[i].url_adr) ) < 4) { proto[0] = '\0'; strncat(proto, back[i].url_adr, count); } } sprintf(StatsBuffer[index].state,"%s: %s",proto,back[i].info); ok=1; } break; default: if (back[i].status==STATUS_READY) { // prêt if ((back[i].r.statuscode==HTTP_OK)) { 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 s[HTS_URLMAXSIZE*2]; // 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); else 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,'/'); if (a) { strncatbuff(StatsBuffer[index].file,a,200); *a='\0'; } } 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); } 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); } } index++; } } } } } /* Display current job */ { int parsing=0; if (commandEndRequested) smallserver_setkey("info.currentjob", "finishing pending transfers - Select [Cancel] to stop now!"); else if (!(parsing=hts_is_parsing(opt, -1))) smallserver_setkey("info.currentjob", "receiving files"); else { char tmp[1024]; tmp[0] = '\0'; switch(hts_is_testing(opt)) { case 0: sprintf(tmp, "parsing HTML file (%d%%)",parsing); break; case 1: sprintf(tmp, "parsing HTML file: testing links (%d%%)",parsing); break; case 2: sprintf(tmp, "purging files"); break; case 3: sprintf(tmp, "loading cache"); break; case 4: sprintf(tmp, "waiting (scheduler)"); break; case 5: sprintf(tmp, "waiting (throttle)"); break; } smallserver_setkey("info.currentjob", tmp); } } /* Display background jobs */ { int i; for(i=0;i<NStatsBuffer;i++) { if (strnotempty(StatsBuffer[i].state)) { strc_int2bytes2 strc; smallserver_setkeyarr("info.state[", i, "]", StatsBuffer[i].state); smallserver_setkeyarr("info.name[", i, "]", StatsBuffer[i].name); smallserver_setkeyarr("info.file[", i, "]", StatsBuffer[i].file); smallserver_setkeyarr("info.size[", i, "]", int2bytes(&strc,StatsBuffer[i].size)); smallserver_setkeyarr("info.sizetot[", i, "]", int2bytes(&strc,StatsBuffer[i].sizetot)); smallserver_setkeyarr("info.url_adr[", i, "]", StatsBuffer[i].url_adr); smallserver_setkeyarr("info.url_fil[", i, "]", StatsBuffer[i].url_fil); smallserver_setkeyarr("info.url_sav[", i, "]", StatsBuffer[i].url_sav); } } } } } /* UnLock */ webhttrack_release(); return 1; }