int checkrobots_set(robots_wizard* robots,char* adr,char* data) { if (((int) strlen(adr)) >= sizeof(robots->adr) - 2) return 0; if (((int) strlen(data)) >= sizeof(robots->token) - 2) return 0; while(robots) { if (strfield2(robots->adr,adr)) { // entrée existe strcpybuff(robots->token,data); #if DEBUG_ROBOTS printf("robots.txt: set %s to %s\n",adr,data); #endif return -1; } else if (!robots->next) { robots->next=(robots_wizard*) calloct(1,sizeof(robots_wizard)); if (robots->next) { robots->next->next=NULL; strcpybuff(robots->next->adr,adr); strcpybuff(robots->next->token,data); #if DEBUG_ROBOTS printf("robots.txt: new set %s to %s\n",adr,data); #endif } #if DEBUG_ROBOTS else printf("malloc error!!\n"); #endif } robots=robots->next; } return 0; }
void CWinHTTrackApp::OnWizRequest2() { wizard2 diawiz2; diawiz2.m_question=WIZ_question; if (diawiz2.DoModal()==IDOK) strcpybuff(WIZ_reponse,"YES"); else strcpybuff(WIZ_reponse,"NO"); }
void CWinHTTrackApp::OnWizRequest3() { WizLinks diawiz3; diawiz3.m_url=WIZ_question; if (diawiz3.DoModal()==IDskipall) strcpybuff(WIZ_reponse,"*"); else switch(diawiz3.m_lnk) { case 0: strcpybuff(WIZ_reponse,"0"); break; case 1: strcpybuff(WIZ_reponse,"1"); break; case 2: strcpybuff(WIZ_reponse,"2"); break; case 3: strcpybuff(WIZ_reponse,"4"); break; case 4: strcpybuff(WIZ_reponse,"5"); break; case 5: strcpybuff(WIZ_reponse,"6"); break; default: strcpybuff(WIZ_reponse,""); break; } }
// destruction chaine dans s position pos void cookie_delete(char *s, int pos) { char *buff; if (strnotempty(s + pos) == 0) { // rien à faire, effacer s[0] = '\0'; } else { buff = (char *) malloct(strlen(s + pos) + 2); if (buff) { strcpybuff(buff, s + pos); // copie temporaire strcpybuff(s, buff); // copier freet(buff); } } }
// insertion chaine ins avant s void cookie_insert(char *s, char *ins) { char *buff; if (strnotempty(s) == 0) { // rien à faire, juste concat strcatbuff(s, ins); } else { buff = (char *) malloct(strlen(s) + 2); if (buff) { strcpybuff(buff, s); // copie temporaire strcpybuff(s, ins); // insérer strcatbuff(s, buff); // copier freet(buff); } } }
void CSplitterFrame::IconChange(CString st) { if (iconifie) { strcpybuff(icnd.szTip,""); strncatbuff(icnd.szTip,st,60); Shell_NotifyIcon(NIM_MODIFY,&icnd); } }
// Message from CEasyDropTarget LRESULT CNewProj::DragDropText(WPARAM wParam,LPARAM lParam) { if (lParam) { CString st=*((CString*) lParam); CLIPFORMAT cfFormat = (CLIPFORMAT) wParam; if (cfFormat==CF_HDROP) { if (st.Right(5).CompareNoCase(".whtt")==0) st=st.Left(st.GetLength()-5); if(st.GetLength()<256) { char s[256]; strcpybuff(s,st); if (!fexist(s)) { if (st.Find('\n')<0) { int pos=st.ReverseFind('\\'); SetDlgItemTextCP(this, IDC_projpath,st.Mid(0,pos)); SetDlgItemTextCP(this, IDC_projname,st.Mid(pos+1)); // OnChangeprojpath(); OnChangeprojname(); } else AfxMessageBox(LANG(LANG_DIAL3),MB_SYSTEMMODAL); } else AfxMessageBox(LANG(LANG_DIAL4),MB_SYSTEMMODAL); } } else AfxMessageBox(LANG(LANG_DIAL5),MB_SYSTEMMODAL); } return 0; }
BOOL Ctrans::OnInitDialog() { CPropertyPage::OnInitDialog(); ((CButton*)GetDlgItem(IDC_select_start))->SetCheck(1); strcpybuff(RasString,""); SetIcon(httrack_icon,false); SetIcon(httrack_icon,true); EnableToolTips(true); // TOOL TIPS // Patcher l'interface pour les Français ;-) if (LANG_T(-1)) { // Patcher en français //SetDlgItemTextCP(this, ,""); SetWindowTextCP(this, LANG(LANG_J9) /*"Démarrer.."*/); SetDlgItemTextCP(this, IDC_select_start,LANG(LANG_J10) /*"Vous pouvez démarrer le miroir en pressant la touche DEMARRER,\nou définir avant les options de connexion"*/); SetDlgItemTextCP(this, IDC_select_save,LANG(LANG_J10b)); SetDlgItemTextCP(this, IDC_STATIC_delay,LANG(LANG_J11) /*"Retarder"*/); SetDlgItemTextCP(this, IDC_wait,LANG(LANG_J12) /*"Attendre avant de commencer jusqu'à: (hh/mm/ss)"*/); //SetDlgItemTextCP(this, IDC_avant,LANG(LANG_BACK) /*"<- AVANT"*/); SetDlgItemTextCP(this, IDCANCEL,LANG(LANG_QUIT) /*"Quitter"*/); SetDlgItemTextCP(this, IDOK,LANG(LANG_J13) /*"DEMARRER!"*/); SetDlgItemTextCP(this, IDC_STATIC_ras,LANG(LANG_J14) /*"Connexion provider"*/); SetDlgItemTextCP(this, IDC_cnx,LANG(LANG_J15) /*"Connecter à ce provider"*/); SetDlgItemTextCP(this, IDC_rasdisc,LANG_J16); } // liste vide pour commencer isfilled=FALSE; FillProviderList(0); m_ctlrasid.SetCurSel(0); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void Ctrans::OnChangehh() { CString st=""; char tempo[256]; // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CPropertyPage::OnInitDialog() // function to send the EM_SETEVENTMASK message to the control // with the ENM_CHANGE flag ORed into the lParam mask. // TODO: Add your control notification handler code here GetDlgItemText(IDC_hh,st); strcpybuff(tempo,st); if ((strlen(tempo)>0)!=hms) { hms=!hms; if (strlen(tempo)>0) { m_ctl_wait.ModifyStyle(WS_DISABLED,0); } else { m_ctl_wait.ModifyStyle(0,WS_DISABLED); } m_ctl_wait.RedrawWindow(); } // m_wait=TRUE; }
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; }
/* download cancelled */ static int stop_mms(lien_back* back) { if (back->stop_ftp) { strcpybuff(back->r.msg, "Cancelled by User"); back->r.statuscode = STATUSCODE_INVALID; return 1; } return 0; }
/* Convert ~/foo into /home/smith/foo */ void expand_home(String * str) { if (StringSub(*str, 1) == '~') { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; strcpybuff(tempo, hts_gethome()); strcatbuff(tempo, StringBuff(*str) + 1); StringCopy(*str, tempo); } }
BOOL CDialogHtmlHelp::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(httrack_icon,false); SetIcon(httrack_icon,true); EnableToolTips(true); // TOOL TIPS SetForegroundWindow(); // yop en premier plan! strcpybuff(home,"file://"); { char* a=home+strlen(home); ::GetModuleFileName(NULL, a, sizeof(home)/sizeof(TCHAR) - 1 - strlen(home)); // strcatbuff(home,AfxGetApp()->m_pszHelpFilePath); a = home + strlen(home) -1; while( (*a!='\\') && ( a > home ) ) a--; if (*a=='\\') { *(a+1)='\0'; } strcatbuff(home,"html\\"); strcpybuff(home_dir,home); strcatbuff(home,"index.html"); } // créer if (m_page.CreateFromStatic(IDC_HTMLVIEW, this)) { m_page.SetToolBar(false); m_page.SetMenuBar(false); m_page.SetStatusBar(false); m_page.SetRegisterAsBrowser(false); m_page.SetFullScreen(false); if (page.GetLength()==0) OnHome(); else Go(page); UpdateWindow(); } else { EndDialog(IDCANCEL); if (!ShellExecute(NULL,"open",home+strlen("file://"),"","",SW_RESTORE)) AfxMessageBox(LANG(LANG_DIAL1)); } return TRUE; }
void CDialogHtmlHelp::Go(CString st) { if (st.Left(7)!="http://") { char tempo[1024]; strcpybuff(tempo,home_dir); strcatbuff(tempo,st); m_page.Navigate2(tempo); } else m_page.Navigate2(st); m_page.ShowWindow(SW_SHOW); this->GetDlgItem(IDC_HTMLVIEW)->SetFocus(); }
/* // Example: find_handle h = hts_findfirst("/tmp"); if (h) { do { if (hts_findisfile(h)) printf("File: %s (%d octets)\n",hts_findgetname(h),hts_findgetsize(h)); else if (hts_findisdir(h)) printf("Dir: %s\n",hts_findgetname(h)); } while(hts_findnext(h)); hts_findclose(h); } */ HTSEXT_API find_handle hts_findfirst(char* path) { if (path) { if (strnotempty(path)) { find_handle_struct* find = (find_handle_struct*) calloc(1,sizeof(find_handle_struct)); if (find) { memset(find, 0, sizeof(find_handle_struct)); #ifdef _WIN32 { char BIGSTK rpath[1024*2]; strcpybuff(rpath,path); if (rpath[0]) { if (rpath[strlen(rpath)-1]!='\\') strcatbuff(rpath,"\\"); } strcatbuff(rpath,"*.*"); find->handle = FindFirstFileA(rpath,&find->hdata); if (find->handle != INVALID_HANDLE_VALUE) return find; } #else strcpybuff(find->path,path); { if (find->path[0]) { if (find->path[strlen(find->path)-1]!='/') strcatbuff(find->path,"/"); } } find->hdir=opendir(path); if (find->hdir != NULL) { if (hts_findnext(find) == 1) return find; } #endif free((void*)find); } } } return NULL; }
void COptionTab10::OnChangeprox() { CString st=""; char tempo[8192]; CString port=""; GetDlgItemText(IDC_prox,st); int pos=st.Find(':'); if (pos>=0) { port=st.Mid(pos+1); st=st.Mid(0,pos); SetDlgItemTextCP(this, IDC_prox,st); } strcpybuff(tempo,st); int ex=0; do { if (strlen(tempo)>0) { switch (tempo[strlen(tempo)-1]) { case 10: case 13: case 32: tempo[strlen(tempo)-1]='\0'; break; default: ex=1; break; } } else ex=1; } while(!ex); if ((strlen(tempo)>0)!=prox_status) { prox_status=!prox_status; if (strlen(tempo)>0) { CString st=""; GetDlgItemText(IDC_portprox,st); if (strlen(st)==0) { SetDlgItemTextCP(this, IDC_portprox,"8080"); m_ctl_portprox.RedrawWindow(); } m_ctl_proxtitle.ModifyStyle(WS_DISABLED,0); } else { SetDlgItemTextCP(this, IDC_portprox,""); m_ctl_portprox.RedrawWindow(); m_ctl_proxtitle.ModifyStyle(0,WS_DISABLED); } m_ctl_proxtitle.RedrawWindow(); } if (port.GetLength()) SetDlgItemTextCP(this, IDC_portprox,port); }
/* déclarer un répertoire comme possédant une authentification propre */ int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth) { char buffer[HTS_URLMAXSIZE * 2]; if (cookie) { if (!bauth_check(cookie, adr, fil)) { // n'existe pas déja bauth_chain *chain = &cookie->auth; char *prefix = bauth_prefix(buffer, adr, fil); /* fin de la chaine */ while(chain->next) chain = chain->next; chain->next = (bauth_chain *) calloc(sizeof(bauth_chain), 1); if (chain->next) { chain = chain->next; chain->next = NULL; strcpybuff(chain->auth, auth); strcpybuff(chain->prefix, prefix); return 1; } } } return 0; }
void Cinprogress::Oniplog(int mode) { char catbuff[CATBUFF_SIZE]; if (!BackAffLog) { // pas encore lancé strcpybuff(pathlog,dialog0->GetPath()); if (strlen(pathlog)>0) if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\')) strcatbuff(pathlog,"/"); // fichier log existe ou on est télécommandé par un ! if ( (fexist(fconcat(catbuff,sizeof(catbuff),pathlog,"hts-err.txt"))) || (fexist(fconcat(catbuff,sizeof(catbuff),pathlog,"hts-log.txt"))) || (ShellOptions != NULL && ShellOptions->choixdeb[0]=='!') ) { if (mode) form.type_log=0; else form.type_log=1; strcpybuff(form.pathlog,pathlog); BackAffLog = AfxBeginThread(AffLog,this); } else { char s[1024]; sprintf(s,LANG(LANG_H2 /*"No log files in %s!","Aucun fichier d'audit dans %s!"*/),pathlog); AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION); } } }
char *bauth_prefix(char *prefix, char *adr, char *fil) { char *a; strcpybuff(prefix, jump_identification(adr)); strcatbuff(prefix, fil); a = strchr(prefix, '?'); if (a) *a = '\0'; if (strchr(prefix, '/')) { a = prefix + strlen(prefix) - 1; while(*a != '/') a--; *(a + 1) = '\0'; } return prefix; }
// Iconify void CSplitterFrame::Onhide() { if (!iconifie) { //icnd.hWnd=this->GetMainWnd()->m_hWnd; //icnd.hWnd=AfxGetMainWnd()->m_hWnd; icnd.hWnd=this_CSplitterFrame->m_hWnd; strcpybuff(icnd.szTip,"WinHTTrack Website Copier"); /* */ AfxGetMainWnd()->ShowWindow(SW_HIDE); //ShowWindow(SW_SHOWMINNOACTIVE); Shell_NotifyIcon(NIM_ADD,&icnd); iconifie=true; } else { CheckRestore(); } }
void inthash_add_value(inthash hashtable, const char *name, inthash_value value) { int pos = (inthash_key(name) % hashtable->hash_size); inthash_chain **h = &hashtable->hash[pos]; while(*h) h = &((*h)->next); *h = (inthash_chain *) calloct(1, sizeof(inthash_chain) + strlen(name) + 2); if (*h) { (*h)->name = ((char *) (*h)) + sizeof(inthash_chain); (*h)->next = NULL; strcpybuff((*h)->name, name); (*h)->value = value; hashtable->nitems++; } }
void CNewProj::Onbr() { CString st,spth; char pth[MAX_PATH + 32]; GetDlgItemText(IDC_projpath,spth); if (spth.GetLength() > MAX_PATH) { return ; } strcpybuff(pth,spth); st=XSHBrowseForFolder(this->m_hWnd,"Select a path name for mirror",pth); if (st.GetLength()>0) { if (st.Right(1)=='\\') st=st.Left(st.GetLength()-1); SetDlgItemTextCP(this, IDC_projpath,st); } }
void *inthash_addblk(inthash hashtable, const char *name, int blksize) { int pos = (inthash_key(name) % hashtable->hash_size); inthash_chain **h = &hashtable->hash[pos]; while(*h) h = &((*h)->next); *h = (inthash_chain *) calloct(1, sizeof(inthash_chain) + strlen(name) + 2 + blksize); if (*h) { (*h)->name = ((char *) (*h)) + sizeof(inthash_chain); (*h)->next = NULL; strcpybuff((*h)->name, name); (*h)->value.ptr = (void *) (((char *) (*h)) + sizeof(inthash_chain) + strlen(name) + 2); hashtable->nitems++; return (*h)->value.ptr; } return NULL; }
void CNewProj::Changeprojname(CString stl) { char catbuff[CATBUFF_SIZE]; CWaitCursor wait; CString st; // if (stl.GetLength()==0 || stl.GetLength() > HTS_URLMAXSIZE) { //m_ctl_idok.ModifyStyle(0,WS_DISABLED); SetDlgItemTextCP(this, IDC_STATIC_comments,LANG(LANG_S30)); SetDlgItemTextCP(this, IDC_STATIC_projname,LANG(LANG_S11c)); this_CWizTab->SetWizardButtons(PSWIZB_BACK); can_click_next=FALSE; } else { char tempo[HTS_URLMAXSIZE*2]; GetDlgItemText(IDC_projpath,st); if (st.GetLength() + stl.GetLength() + 32 > sizeof(tempo)) { can_click_next=FALSE; } else { strcpybuff(tempo,st); strcatbuff(tempo,"/"); strcatbuff(tempo,stl); strcatbuff(tempo,"/"); if (fexist(fconcat(catbuff,tempo,"hts-cache/winprofile.ini")) // un cache est présent && fsize(fconcat(catbuff,tempo,"hts-cache/winprofile.ini"))>0) { // taille log contrôle>0 CString strSection = "OptionsValues"; CString st = MyGetProfileString(fconcat(catbuff,tempo,"hts-cache/winprofile.ini"),strSection,"CurrentUrl"); CString st2 = MyGetProfileString(fconcat(catbuff,tempo,"hts-cache/winprofile.ini"),strSection,"Category"); // SetDlgItemTextCP(this, IDC_STATIC_comments, st); SetDlgItemTextCP(this, IDC_projcateg, st2); // Static SetDlgItemTextCP(this, IDC_STATIC_projname,LANG(LANG_S11b)); } else { SetDlgItemTextCP(this, IDC_STATIC_comments,LANG(LANG_S31)); SetDlgItemTextCP(this, IDC_STATIC_projname,LANG(LANG_S11)); } //m_ctl_idok.ModifyStyle(WS_DISABLED,0); //if (!can_click_next) this_CWizTab->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT); can_click_next=TRUE; } } //m_ctl_idok.RedrawWindow(); }
void Ctrans::FillProviderList(int fill) { // remplssage su champ des noms de connexion RAS #if USE_RAS if (LibRasUse && fill) { DWORD size; RASENTRYNAME* adr; int count=256; size = sizeof(RASENTRYNAME)*(count+2); adr = (RASENTRYNAME*) (char*) calloc(size,1); if (adr) { DWORD ent; int i; for(i=0;i<count;i++) { adr[i].dwSize=sizeof(RASENTRYNAME); strcpybuff(adr[i].szEntryName,""); } if (LibRas->RasEnumEntries(NULL,NULL,(RASENTRYNAME*) adr,&size,&ent) == 0) { int i; GetDlgItem(IDC_STATIC_ras)->ModifyStyle(WS_DISABLED,0); GetDlgItem(IDC_STATIC_ras)->RedrawWindow(); m_ctlrasid.ResetContent(); m_ctlrasid.InsertString(-1,LANG(LANG_J2 /*"do not connect to a provider (already connected)","pas de connexion à un provider (déja connecté)"*/)); for(i=0;i<(int) ent;i++) { m_ctlrasid.InsertString(-1,adr[i].szEntryName); } } free(adr); } } else #endif { if (LibRasUse) { GetDlgItem(IDC_STATIC_ras)->ModifyStyle(WS_DISABLED,0); } else { GetDlgItem(IDC_STATIC_ras)->ModifyStyle(0,WS_DISABLED); } GetDlgItem(IDC_STATIC_ras)->RedrawWindow(); m_ctlrasid.ResetContent(); m_ctlrasid.InsertString(-1,LANG_J2b); } }
void COptionTab7::OnAdd2() { char s[1024]; s[0]='\0'; NewFilter(1,s); if (strlen(s)>0) { char tempo[HTS_URLMAXSIZE*16]; { CString st; GetDlgItemText(IDC_URL2,st); if (st.GetLength() < sizeof(tempo) - 2) strcpybuff(tempo,st); else tempo[0] = '\0'; } if (strlen(tempo)>0) { if ((tempo[strlen(tempo)-1]!=' ') && (tempo[strlen(tempo)-1]!='\n') && (tempo[strlen(tempo)-1]!=13)) strcatbuff(tempo,"\x0d\x0a"); } strcatbuff(tempo,s); // m_url2=tempo; SetDlgItemTextCP(this, IDC_URL2,tempo); } }
void COptionTab10::Onproxyconfigure() { CProxyId proxy; char adr[256]; CString s; GetDlgItemText(IDC_portprox,s); proxy.m_proxport=s; GetDlgItemText(IDC_prox,s); strcpybuff(adr,s); proxy.m_proxadr=jump_identification(adr); if (jump_identification(adr)!=adr) { char user_pass[256]; user_pass[0]='\0'; char* a; size_t nsize = (size_t) ( ( jump_identification(adr) - adr ) - 1 ); strncatbuff(user_pass,adr,nsize); a=strchr(user_pass,':'); if (a) *a='\0'; else a=user_pass+strlen(user_pass); proxy.m_proxlogin=user_pass; proxy.m_proxpass=a+1; } if (proxy.DoModal() == IDOK) { if (proxy.m_proxlogin.GetLength()==0) { SetDlgItemTextCP(this, IDC_prox,proxy.m_proxadr); m_ctl_pwdhide.SetCheck(0); OnPwdhide(); } else { SetDlgItemTextCP(this, IDC_prox,proxy.m_proxlogin+":"+proxy.m_proxpass+"@"+proxy.m_proxadr); m_ctl_pwdhide.SetCheck(1); OnPwdhide(); } SetDlgItemTextCP(this, IDC_portprox,proxy.m_proxport); } }
void CWinHTTrackApp::OnFileDelete() { static char szFilter[256]; strcpybuff(szFilter,"WinHTTrack Website Copier Project (*.whtt)|*.whtt||"); CFileDialog* dial = new CFileDialog(true,"whtt",NULL,OFN_HIDEREADONLY,szFilter); if (dial->DoModal() == IDOK) { CString st=dial->GetPathName(); if (fexist((char*) LPCTSTR(st))) { int pos=st.ReverseFind('.'); CString dir=st.Left(pos)+"\\"; char msg[1000]; sprintf(msg,"%s\r\n%s",LANG_DELETECONF,dir); if (AfxMessageBox(msg,MB_OKCANCEL)==IDOK) { if (remove(st)) { AfxMessageBox("Error deleting "+st); } else { RmDir(dir); } } } else AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/)); } delete dial; }
void help_wizard(httrackp * opt) { help_wizard_buffers *buffers = malloct(sizeof(help_wizard_buffers)); #undef urls #undef mainpath #undef projname #undef stropt #undef stropt2 #undef strwild #undef cmd #undef str #undef argv #define urls (buffers->urls) #define mainpath (buffers->mainpath) #define projname (buffers->projname) #define stropt (buffers->stropt) #define stropt2 (buffers->stropt2) #define strwild (buffers->strwild) #define cmd (buffers->cmd) #define str (buffers->str) #define argv (buffers->argv) //char *urls = (char *) malloct(HTS_URLMAXSIZE * 2); //char *mainpath = (char *) malloct(256); //char *projname = (char *) malloct(256); //char *stropt = (char *) malloct(2048); // options //char *stropt2 = (char *) malloct(2048); // options longues //char *strwild = (char *) malloct(2048); // wildcards //char *cmd = (char *) malloct(4096); //char *str = (char *) malloct(256); //char **argv = (char **) malloct(256 * sizeof(char *)); // char *a; // if (urls == NULL || mainpath == NULL || projname == NULL || stropt == NULL || stropt2 == NULL || strwild == NULL || cmd == NULL || str == NULL || argv == NULL) { fprintf(stderr, "* memory exhausted in %s, line %d\n", __FILE__, __LINE__); return; } urls[0] = mainpath[0] = projname[0] = stropt[0] = stropt2[0] = strwild[0] = cmd[0] = str[0] = '\0'; // strcpybuff(stropt, "-"); mainpath[0] = projname[0] = stropt2[0] = strwild[0] = '\0'; // printf("\n"); printf("Welcome to HTTrack Website Copier (Offline Browser) " HTTRACK_VERSION "%s\n", hts_get_version_info(opt)); printf("Copyright (C) 1998-2016 Xavier Roche and other contributors\n"); #ifdef _WIN32 printf("Note: You are running the commandline version,\n"); printf("run 'WinHTTrack.exe' to get the GUI version.\n"); #endif #ifdef HTTRACK_AFF_WARNING printf("NOTE: " HTTRACK_AFF_WARNING "\n"); #endif #ifdef HTS_PLATFORM_NAME #if USE_BEGINTHREAD printf("[compiled: " HTS_PLATFORM_NAME " - MT]\n"); #else printf("[compiled: " HTS_PLATFORM_NAME "]\n"); #endif #endif printf("To see the option list, enter a blank line or try httrack --help\n"); // // Project name while(strnotempty(projname) == 0) { printf("\n"); printf("Enter project name :"); fflush(stdout); linput(stdin, projname, 250); if (strnotempty(projname) == 0) help("httrack", 1); } // // Path if (strnotempty(hts_gethome())) printf("\nBase path (return=%s/websites/) :", hts_gethome()); else printf("\nBase path (return=current directory) :"); linput(stdin, str, 250); if (!strnotempty(str)) { strcatbuff(str, hts_gethome()); strcatbuff(str, "/websites/"); } if (strnotempty(str)) if ((str[strlen(str) - 1] != '/') && (str[strlen(str) - 1] != '\\')) strcatbuff(str, "/"); strcatbuff(stropt2, "-O \""); strcatbuff(stropt2, str); strcatbuff(stropt2, projname); strcatbuff(stropt2, "\" "); // Créer si ce n'est fait un index.html 1er niveau make_empty_index(str); // printf("\n"); printf("Enter URLs (separated by commas or blank spaces) :"); fflush(stdout); linput(stdin, urls, 250); if (strnotempty(urls)) { while((a = strchr(urls, ','))) *a = ' '; while((a = strchr(urls, '\t'))) *a = ' '; // Action printf("\nAction:\n"); switch (help_query ("Mirror Web Site(s)|Mirror Web Site(s) with Wizard|Just Get Files Indicated|Mirror ALL links in URLs (Multiple Mirror)|Test Links In URLs (Bookmark Test)|Update/Continue a Mirror", 1)) { case 1: break; case 2: strcatbuff(stropt, "W"); break; case 3: strcatbuff(stropt2, "--get "); break; case 4: strcatbuff(stropt2, "--mirrorlinks "); break; case 5: strcatbuff(stropt2, "--testlinks "); break; case 6: strcatbuff(stropt2, "--update "); break; case 0: return; break; } // Proxy printf("\nProxy (return=none) :"); linput(stdin, str, 250); if (strnotempty(str)) { while((a = strchr(str, ' '))) *a = ':'; // port if (!strchr(jump_identification_const(str), ':')) { char str2[256]; printf("\nProxy port (return=8080) :"); linput(stdin, str2, 250); strcatbuff(str, ":"); if (strnotempty(str2) == 0) strcatbuff(str, "8080"); else strcatbuff(str, str2); } strcatbuff(stropt2, "-P "); strcatbuff(stropt2, str); strcatbuff(stropt2, " "); } // Display strcatbuff(stropt2, " -%v "); // Wildcards printf ("\nYou can define wildcards, like: -*.gif +www.*.com/*.zip -*img_*.zip\n"); printf("Wildcards (return=none) :"); linput(stdin, strwild, 250); // Options do { printf ("\nYou can define additional options, such as recurse level (-r<number>), separated by blank spaces\n"); printf("To see the option list, type help\n"); printf("Additional options (return=none) :"); linput(stdin, str, 250); if (strfield2(str, "help")) { help("httrack", 2); } else if (strnotempty(str)) { strcatbuff(stropt2, str); strcatbuff(stropt2, " "); } } while(strfield2(str, "help")); { int argc = 1; int g = 0; int i = 0; // printf("\n"); if (strlen(stropt) == 1) stropt[0] = '\0'; // aucune sprintf(cmd, "%s %s %s %s", urls, stropt, stropt2, strwild); printf("---> Wizard command line: httrack %s\n\n", cmd); printf("Ready to launch the mirror? (Y/n) :"); fflush(stdout); linput(stdin, str, 250); if (strnotempty(str)) { if (!((str[0] == 'y') || (str[0] == 'Y'))) return; } printf("\n"); // couper en morceaux argv[0] = strdup("winhttrack"); argv[1] = cmd; argc++; while(cmd[i]) { if (cmd[i] == '\"') g = !g; if (cmd[i] == ' ') { if (!g) { cmd[i] = '\0'; argv[argc++] = cmd + i + 1; } } i++; } hts_main(argc, argv); } //} else { // help("httrack",1); } /* Free buffers */ free(buffers); #undef urls #undef mainpath #undef projname #undef stropt #undef stropt2 #undef strwild #undef cmd #undef str #undef argv }
HTSEXT_API int hts_buildtopindex(httrackp* opt,const char* path,const char* binpath) { FILE* fpo; int retval=0; char BIGSTK rpath[1024*2]; char *toptemplate_header=NULL,*toptemplate_body=NULL,*toptemplate_footer=NULL,*toptemplate_bodycat=NULL; char catbuff[CATBUFF_SIZE]; // et templates html toptemplate_header=readfile_or(fconcat(catbuff, binpath,"templates/topindex-header.html"),HTS_INDEX_HEADER); toptemplate_body=readfile_or(fconcat(catbuff, binpath,"templates/topindex-body.html"),HTS_INDEX_BODY); toptemplate_bodycat=readfile_or(fconcat(catbuff, binpath,"templates/topindex-bodycat.html"),HTS_INDEX_BODYCAT); toptemplate_footer=readfile_or(fconcat(catbuff, binpath,"templates/topindex-footer.html"),HTS_INDEX_FOOTER); if (toptemplate_header && toptemplate_body && toptemplate_footer && toptemplate_bodycat) { strcpybuff(rpath,path); if (rpath[0]) { if (rpath[strlen(rpath)-1]=='/') rpath[strlen(rpath)-1]='\0'; } fpo=fopen(fconcat(catbuff, rpath,"/index.html"),"wb"); if (fpo) { find_handle h; verif_backblue(opt,concat(catbuff, rpath,"/")); // générer gif // Header fprintf(fpo,toptemplate_header, "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->" ); /* Find valid project names */ h = hts_findfirst(rpath); if (h) { struct topindex_chain * chain=NULL; struct topindex_chain * startchain=NULL; String iname = STRING_EMPTY; int chainSize = 0; do { if (hts_findisdir(h)) { StringCopy(iname,rpath); StringCat(iname,"/"); StringCat(iname,hts_findgetname(h)); StringCat(iname,"/index.html"); if (fexist(StringBuff(iname))) { int level = 0; char* category = NULL; struct topindex_chain * oldchain=chain; /* Check for an existing category */ StringCopy(iname,rpath); StringCat(iname,"/"); StringCat(iname,hts_findgetname(h)); StringCat(iname,"/hts-cache/winprofile.ini"); if (fexist(StringBuff(iname))) { category = hts_getcategory(StringBuff(iname)); if (category != NULL) { if (*category == '\0') { freet(category); category = NULL; } } } if (category == NULL) { category = strdupt("No categories"); level = 1; } chain=calloc(sizeof(struct topindex_chain), 1); chainSize++; if (!startchain) { startchain=chain; } if (chain) { if (oldchain) { oldchain->next=chain; } chain->next=NULL; strcpybuff(chain->name, hts_findgetname(h)); chain->category = category; chain->level = level; } } } } while(hts_findnext(h)); hts_findclose(h); StringFree(iname); /* Sort chain */ { struct topindex_chain** sortedElts = (struct topindex_chain**) calloct(sizeof(topindex_chain*), chainSize); assertf(sortedElts != NULL); if (sortedElts != NULL) { int i; char* category = ""; /* Build array */ struct topindex_chain * chain = startchain; for(i = 0 ; i < chainSize ; i++) { assertf(chain != NULL); sortedElts[i] = chain; chain = chain->next; } qsort(sortedElts, chainSize, sizeof(topindex_chain*), sortTopIndexFnc); /* Build sorted index */ for(i = 0 ; i < chainSize ; i++) { char BIGSTK hname[HTS_URLMAXSIZE*2]; strcpybuff(hname,sortedElts[i]->name); escape_check_url(hname); /* Changed category */ if (strcmp(category, sortedElts[i]->category) != 0) { category = sortedElts[i]->category; fprintf(fpo,toptemplate_bodycat, category); } fprintf(fpo,toptemplate_body, hname, sortedElts[i]->name ); } /* Wipe elements */ for(i = 0 ; i < chainSize ; i++) { freet(sortedElts[i]->category); freet(sortedElts[i]); sortedElts[i] = NULL; } freet(sortedElts); /* Return value */ retval=1; } } } // Footer fprintf(fpo,toptemplate_footer, "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->" ); fclose(fpo); } } if (toptemplate_header) freet(toptemplate_header); if (toptemplate_body) freet(toptemplate_body); if (toptemplate_footer) freet(toptemplate_footer); if (toptemplate_body) freet(toptemplate_body); return retval; }