diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2012-03-19 12:55:42 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2012-03-19 12:55:42 +0000 |
commit | 844ecc37072d515513177c65a8c9dc35c9cdfc1a (patch) | |
tree | 733b1fe039c0c37095a594b66d5076f3f5a0153d /libtest/callbacks-example-filenameiisbug.c | |
parent | 25adbdabb47499fe641c7bd9595024ff82667058 (diff) |
httrack 3.33.16
Diffstat (limited to 'libtest/callbacks-example-filenameiisbug.c')
-rwxr-xr-x | libtest/callbacks-example-filenameiisbug.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libtest/callbacks-example-filenameiisbug.c b/libtest/callbacks-example-filenameiisbug.c new file mode 100755 index 0000000..eb162d9 --- /dev/null +++ b/libtest/callbacks-example-filenameiisbug.c @@ -0,0 +1,54 @@ +/*
+ HTTrack external callbacks example : changing folder names ending with ".com"
+ with ".c0m" as a workaround of IIS bug (see KB 275601)
+
+ How to use:
+ - compile this file as a module (callback.so or callback.dll)
+ example:
+ (with gcc)
+ gcc -O -g3 -Wall -D_REENTRANT -DINET6 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -shared -o callback.so callbacks-example-filename.c
+ or (with visual c++)
+ cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"callback.dll" callbacks-example-filename.c
+ - use the --wrapper option in httrack:
+ httrack --wrapper save-name=callback:mysavename
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* "External" */
+#ifdef _WIN32
+#define EXTERNAL_FUNCTION __declspec(dllexport)
+#else
+#define EXTERNAL_FUNCTION
+#endif
+
+/* Function definitions */
+EXTERNAL_FUNCTION int mysavename(char* adr_complete, char* fil_complete, char* referer_adr, char* referer_fil, char* save);
+
+/*
+ Replaces all "offending" IIS extensions (exe, dll..) with "nice" ones
+*/
+/*
+"check-html" callback
+from htsdefines.h:
+typedef int (* t_hts_htmlcheck_savename)(char* adr_complete,char* fil_complete,char* referer_adr,char* referer_fil,char* save);
+*/
+EXTERNAL_FUNCTION int mysavename(char* adr_complete, char* fil_complete, char* referer_adr, char* referer_fil, char* save) {
+ static const char* iisBogus[] = { ".com", ".exe", ".dll", ".sh", NULL };
+ static const char* iisBogusReplace[] = { ".c0m", ".ex3", ".dl1", ".5h", NULL }; /* MUST be the same sizes */
+ char* a;
+ for(a = save ; *a != '\0' ; a++) {
+ int i;
+ for(i = 0 ; iisBogus[i] != NULL ; i++) {
+ int j;
+ for(j = 0 ; iisBogus[i][j] == a[j] && iisBogus[i][j] != '\0' ; j++);
+ if (iisBogus[i][j] == '\0' && ( a[j] == '\0' || a[j] == '/' || a[j] == '\\' ) ) {
+ strncpy(a, iisBogusReplace[i], strlen(iisBogusReplace[i]));
+ break;
+ }
+ }
+ }
+ return 1; /* success */
+}
|