/* Pseudo-key (lien_url structure) hash function */ static coucal_hashkeys key_adrfil_hashes_generic(void *arg, coucal_key_const value, const int former) { hash_struct *const hash = (hash_struct*) arg; const lien_url*const lien = (const lien_url*) value; const char *const adr = !former ? lien->adr : lien->former_adr; const char *const fil = !former ? lien->fil : lien->former_fil; const char *const adr_norm = adr != NULL ? ( hash->normalized ? jump_normalized_const(adr) : jump_identification_const(adr) ) : NULL; // copy address assertf(adr_norm != NULL); strcpy(hash->normfil, adr_norm); // copy link assertf(fil != NULL); if (hash->normalized) { fil_normalized(fil, &hash->normfil[strlen(hash->normfil)]); } else { strcpy(&hash->normfil[strlen(hash->normfil)], fil); } // hash return coucal_hash_string(hash->normfil); }
/* Pseudo-key (lien_url structure) comparison function */ static int key_adrfil_equals_generic(void *arg, coucal_key_const a_, coucal_key_const b_, const int former) { hash_struct *const hash = (hash_struct*) arg; const int normalized = hash->normalized; const lien_url*const a = (const lien_url*) a_; const lien_url*const b = (const lien_url*) b_; const char *const a_adr = !former ? a->adr : a->former_adr; const char *const b_adr = !former ? b->adr : b->former_adr; const char *const a_fil = !former ? a->fil : a->former_fil; const char *const b_fil = !former ? b->fil : b->former_fil; const char *ja; const char *jb; // safety assertf(a_adr != NULL); assertf(b_adr != NULL); assertf(a_fil != NULL); assertf(b_fil != NULL); // skip scheme and authentication to the domain (possibly without www.) ja = normalized ? jump_normalized_const(a_adr) : jump_identification_const(a_adr); jb = normalized ? jump_normalized_const(b_adr) : jump_identification_const(b_adr); assertf(ja != NULL); assertf(jb != NULL); if (strcasecmp(ja, jb) != 0) { return 0; } // now compare pathes if (normalized) { fil_normalized(a_fil, hash->normfil); fil_normalized(b_fil, hash->normfil2); return strcmp(hash->normfil, hash->normfil2) == 0; } else { return strcmp(a_fil, b_fil) == 0; } }
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 }