mirror of
https://github.com/xroche/httrack.git
synced 2026-05-17 08:26:14 +03:00
httrack 3.43.12
This commit is contained in:
@@ -59,6 +59,7 @@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DL_LIBS = @DL_LIBS@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
@@ -83,6 +84,7 @@ MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
@@ -92,6 +94,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SOCKET_LIBS = @SOCKET_LIBS@
|
||||
|
||||
@@ -1,118 +1,118 @@
|
||||
/*
|
||||
HTTrack external callbacks example : enforce a constant base href
|
||||
Can be useful to make copies of site's archives using site's URL base href as root reference
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp* opt, char* html, int len, const char* url_address, const char* url_file);
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp* opt, char* link);
|
||||
static int check_detectedlink_end(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Check args */
|
||||
fprintf(stderr, "Plugged..\n");
|
||||
if (arg == NULL || *arg == '\0' || strlen(arg) >= HTS_URLMAXSIZE / 2) {
|
||||
fprintf(stderr, "** callback error: arguments expected or bad arguments\n");
|
||||
fprintf(stderr, "usage: httrack --wrapper modulename,base\n");
|
||||
fprintf(stderr, "example: httrack --wrapper callback,http://www.example.com/\n");
|
||||
return 0; /* failed */
|
||||
} else {
|
||||
char *callbacks_userdef = strdup(arg); /* userdef */
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, callbacks_userdef);
|
||||
CHAIN_FUNCTION(opt, linkdetected, check_detectedlink, callbacks_userdef);
|
||||
CHAIN_FUNCTION(opt, end, check_detectedlink_end, callbacks_userdef);
|
||||
|
||||
fprintf(stderr, "Using root '%s'\n", callbacks_userdef);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp* opt, char* html, int len, const char* url_address, const char* url_file) {
|
||||
char* prevBase;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable base href, if any */
|
||||
if ( ( prevBase = strstr(html, "<BASE HREF=\"") ) != NULL) {
|
||||
prevBase[1] = 'X';
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp* opt, char* link) {
|
||||
const char *base = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, linkdetected) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, linkdetected)(CALLBACKARG_PREV_CARG(carg), opt, link)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* The incoming (read/write) buffer is at least HTS_URLMAXSIZE bytes long */
|
||||
if (strncmp(link, "http://", 7) == 0 || strncmp(link, "https://", 8) == 0) {
|
||||
char temp[HTS_URLMAXSIZE * 2];
|
||||
strcpy(temp, base);
|
||||
strcat(temp, link);
|
||||
strcpy(link, temp);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_detectedlink_end(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
char *base = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "Unplugged ..\n");
|
||||
if (base != NULL) {
|
||||
free(base);
|
||||
base = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : enforce a constant base href
|
||||
Can be useful to make copies of site's archives using site's URL base href as root reference
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp* opt, char* html, int len, const char* url_address, const char* url_file);
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp* opt, char* link);
|
||||
static int check_detectedlink_end(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Check args */
|
||||
fprintf(stderr, "Plugged..\n");
|
||||
if (arg == NULL || *arg == '\0' || strlen(arg) >= HTS_URLMAXSIZE / 2) {
|
||||
fprintf(stderr, "** callback error: arguments expected or bad arguments\n");
|
||||
fprintf(stderr, "usage: httrack --wrapper modulename,base\n");
|
||||
fprintf(stderr, "example: httrack --wrapper callback,http://www.example.com/\n");
|
||||
return 0; /* failed */
|
||||
} else {
|
||||
char *callbacks_userdef = strdup(arg); /* userdef */
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, callbacks_userdef);
|
||||
CHAIN_FUNCTION(opt, linkdetected, check_detectedlink, callbacks_userdef);
|
||||
CHAIN_FUNCTION(opt, end, check_detectedlink_end, callbacks_userdef);
|
||||
|
||||
fprintf(stderr, "Using root '%s'\n", callbacks_userdef);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp* opt, char* html, int len, const char* url_address, const char* url_file) {
|
||||
char* prevBase;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable base href, if any */
|
||||
if ( ( prevBase = strstr(html, "<BASE HREF=\"") ) != NULL) {
|
||||
prevBase[1] = 'X';
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp* opt, char* link) {
|
||||
const char *base = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, linkdetected) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, linkdetected)(CALLBACKARG_PREV_CARG(carg), opt, link)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* The incoming (read/write) buffer is at least HTS_URLMAXSIZE bytes long */
|
||||
if (strncmp(link, "http://", 7) == 0 || strncmp(link, "https://", 8) == 0) {
|
||||
char temp[HTS_URLMAXSIZE * 2];
|
||||
strcpy(temp, base);
|
||||
strcat(temp, link);
|
||||
strcpy(link, temp);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_detectedlink_end(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
char *base = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "Unplugged ..\n");
|
||||
if (base != NULL) {
|
||||
free(base);
|
||||
base = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
/*
|
||||
HTTrack external callbacks example : display all incoming request headers
|
||||
Example of <wrappername>_init and <wrappername>_exit call (httrack >> 3.31)
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int postprocess(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char** html, int* len,
|
||||
const char* url_address, const char* url_file);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
/*
|
||||
HTTrack external callbacks example : display all incoming request headers
|
||||
Example of <wrappername>_init and <wrappername>_exit call (httrack >> 3.31)
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int postprocess(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char** html, int* len,
|
||||
const char* url_address, const char* url_file);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Plug callback functions */
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, postprocess, postprocess, NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int postprocess(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) {
|
||||
char *old = *html;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, postprocess) != NULL) {
|
||||
if (CALLBACKARG_PREV_FUN(carg, postprocess)(CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) {
|
||||
/* Modified *html */
|
||||
old = *html;
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
*html = strdup(*html);
|
||||
hts_free(old);
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int postprocess(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) {
|
||||
char *old = *html;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, postprocess) != NULL) {
|
||||
if (CALLBACKARG_PREV_FUN(carg, postprocess)(CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) {
|
||||
/* Modified *html */
|
||||
old = *html;
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
*html = strdup(*html);
|
||||
hts_free(old);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,150 +1,150 @@
|
||||
/*
|
||||
HTTrack external callbacks example : crawling html pages depending on content
|
||||
Example of <wrappername>_init and <wrappername>_exit call (httrack >> 3.31)
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback,stringtofind,stringtofind.. ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* address, const char* filename);
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/* TOLOWER */
|
||||
#define TOLOWER_(a) (a >= 'A' && a <= 'Z') ? (a + ('a' - 'A')) : a
|
||||
#define TOLOWER(a) ( TOLOWER_( (a) ) )
|
||||
|
||||
/*
|
||||
This sample just crawls pages that contains certain keywords, and skips the other ones
|
||||
*/
|
||||
|
||||
typedef struct t_my_userdef {
|
||||
char stringfilter[8192];
|
||||
char* stringfilters[128];
|
||||
} t_my_userdef;
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Check args */
|
||||
if (arg == NULL || *arg == '\0') {
|
||||
fprintf(stderr, "** callback error: arguments expected or bad arguments\n");
|
||||
fprintf(stderr, "usage: httrack --wrapper callback,stringtofind,stringtofind..\n");
|
||||
fprintf(stderr, "example: httrack --wrapper callback,apple,orange,lemon\n");
|
||||
return 0;
|
||||
} else {
|
||||
t_my_userdef *userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef)); /* userdef */
|
||||
char * const stringfilter = userdef->stringfilter;
|
||||
char** const stringfilters = userdef->stringfilters;
|
||||
/* */
|
||||
char* a = stringfilter;
|
||||
int i = 0;
|
||||
fprintf(stderr, "** info: wrapper_init(%s) called!\n", arg);
|
||||
fprintf(stderr, "** callback example: crawling pages only if specific keywords are found\n");
|
||||
|
||||
/* stringfilters = split(arg, ','); */
|
||||
strcpy(stringfilter, arg);
|
||||
while(a != NULL) {
|
||||
stringfilters[i] = a;
|
||||
a = strchr(a, ',');
|
||||
if (a != NULL) {
|
||||
*a = '\0';
|
||||
a ++;
|
||||
}
|
||||
fprintf(stderr, "** callback info: will crawl pages with '%s' in them\n", stringfilters[i]);
|
||||
i++;
|
||||
}
|
||||
stringfilters[i++] = NULL;
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process, userdef);
|
||||
CHAIN_FUNCTION(opt, end, end, userdef);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* address, const char* filename) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const stringfilter = userdef->stringfilter;
|
||||
char** const stringfilters = userdef->stringfilters;
|
||||
/* */
|
||||
int i = 0;
|
||||
int getIt = 0;
|
||||
char* pos;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt, html, len, address, filename)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
if (strcmp(address, "primary") == 0 && strcmp(filename, "/primary") == 0) /* primary page (list of links) */
|
||||
return 1;
|
||||
while(stringfilters[i] != NULL && ! getIt) {
|
||||
if ( ( pos = strstr(html, stringfilters[i]) ) != NULL) {
|
||||
int j;
|
||||
getIt = 1;
|
||||
fprintf(stderr, "** callback info: found '%s' keyword in '%s%s', crawling this page!\n", stringfilters[i], address, filename);
|
||||
fprintf(stderr, "** details:\n(..)");
|
||||
for(j = 0; j < 72 && pos[j] ; j++) {
|
||||
if (pos[j] > 32)
|
||||
fprintf(stderr, "%c", pos[j]);
|
||||
else
|
||||
fprintf(stderr, "?");
|
||||
}
|
||||
fprintf(stderr, "(..)\n");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (getIt) {
|
||||
return 1; /* success */
|
||||
} else {
|
||||
fprintf(stderr, "** callback info: won't parse '%s%s' (no specified keywords found)\n", address, filename);
|
||||
return 0; /* this page sucks, don't parse it */
|
||||
}
|
||||
}
|
||||
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
fprintf(stderr, "** info: wrapper_exit() called!\n");
|
||||
if (userdef != NULL) {
|
||||
free(userdef);
|
||||
userdef = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : crawling html pages depending on content
|
||||
Example of <wrappername>_init and <wrappername>_exit call (httrack >> 3.31)
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback,stringtofind,stringtofind.. ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* address, const char* filename);
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/* TOLOWER */
|
||||
#define TOLOWER_(a) (a >= 'A' && a <= 'Z') ? (a + ('a' - 'A')) : a
|
||||
#define TOLOWER(a) ( TOLOWER_( (a) ) )
|
||||
|
||||
/*
|
||||
This sample just crawls pages that contains certain keywords, and skips the other ones
|
||||
*/
|
||||
|
||||
typedef struct t_my_userdef {
|
||||
char stringfilter[8192];
|
||||
char* stringfilters[128];
|
||||
} t_my_userdef;
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Check args */
|
||||
if (arg == NULL || *arg == '\0') {
|
||||
fprintf(stderr, "** callback error: arguments expected or bad arguments\n");
|
||||
fprintf(stderr, "usage: httrack --wrapper callback,stringtofind,stringtofind..\n");
|
||||
fprintf(stderr, "example: httrack --wrapper callback,apple,orange,lemon\n");
|
||||
return 0;
|
||||
} else {
|
||||
t_my_userdef *userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef)); /* userdef */
|
||||
char * const stringfilter = userdef->stringfilter;
|
||||
char** const stringfilters = userdef->stringfilters;
|
||||
/* */
|
||||
char* a = stringfilter;
|
||||
int i = 0;
|
||||
fprintf(stderr, "** info: wrapper_init(%s) called!\n", arg);
|
||||
fprintf(stderr, "** callback example: crawling pages only if specific keywords are found\n");
|
||||
|
||||
/* stringfilters = split(arg, ','); */
|
||||
strcpy(stringfilter, arg);
|
||||
while(a != NULL) {
|
||||
stringfilters[i] = a;
|
||||
a = strchr(a, ',');
|
||||
if (a != NULL) {
|
||||
*a = '\0';
|
||||
a ++;
|
||||
}
|
||||
fprintf(stderr, "** callback info: will crawl pages with '%s' in them\n", stringfilters[i]);
|
||||
i++;
|
||||
}
|
||||
stringfilters[i++] = NULL;
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process, userdef);
|
||||
CHAIN_FUNCTION(opt, end, end, userdef);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* address, const char* filename) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const stringfilter = userdef->stringfilter;
|
||||
char** const stringfilters = userdef->stringfilters;
|
||||
/* */
|
||||
int i = 0;
|
||||
int getIt = 0;
|
||||
char* pos;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt, html, len, address, filename)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
if (strcmp(address, "primary") == 0 && strcmp(filename, "/primary") == 0) /* primary page (list of links) */
|
||||
return 1;
|
||||
while(stringfilters[i] != NULL && ! getIt) {
|
||||
if ( ( pos = strstr(html, stringfilters[i]) ) != NULL) {
|
||||
int j;
|
||||
getIt = 1;
|
||||
fprintf(stderr, "** callback info: found '%s' keyword in '%s%s', crawling this page!\n", stringfilters[i], address, filename);
|
||||
fprintf(stderr, "** details:\n(..)");
|
||||
for(j = 0; j < 72 && pos[j] ; j++) {
|
||||
if (pos[j] > 32)
|
||||
fprintf(stderr, "%c", pos[j]);
|
||||
else
|
||||
fprintf(stderr, "?");
|
||||
}
|
||||
fprintf(stderr, "(..)\n");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (getIt) {
|
||||
return 1; /* success */
|
||||
} else {
|
||||
fprintf(stderr, "** callback info: won't parse '%s%s' (no specified keywords found)\n", address, filename);
|
||||
return 0; /* this page sucks, don't parse it */
|
||||
}
|
||||
}
|
||||
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
fprintf(stderr, "** info: wrapper_exit() called!\n");
|
||||
if (userdef != NULL) {
|
||||
free(userdef);
|
||||
userdef = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
/*
|
||||
HTTrack external callbacks example : display all incoming request headers
|
||||
Example of <wrappername>_init and <wrappername>_exit call (httrack >> 3.31)
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char* buff, const char* adr, const char* fil,
|
||||
const char* referer_adr, const char* referer_fil,
|
||||
htsblk* incoming);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, receivehead, process, NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char* buff, const char* adr, const char* fil,
|
||||
const char* referer_adr, const char* referer_fil,
|
||||
htsblk* incoming) {
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, receivehead) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, receivehead)(CALLBACKARG_PREV_CARG(carg), opt, buff, adr, fil, referer_adr, referer_fil, incoming)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("[ %s%s ]\n%s\n", adr, fil, buff);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : display all incoming request headers
|
||||
Example of <wrappername>_init and <wrappername>_exit call (httrack >> 3.31)
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char* buff, const char* adr, const char* fil,
|
||||
const char* referer_adr, const char* referer_fil,
|
||||
htsblk* incoming);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, receivehead, process, NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char* buff, const char* adr, const char* fil,
|
||||
const char* referer_adr, const char* referer_fil,
|
||||
htsblk* incoming) {
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, receivehead) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, receivehead)(CALLBACKARG_PREV_CARG(carg), opt, buff, adr, fil, referer_adr, referer_fil, incoming)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("[ %s%s ]\n%s\n", adr, fil, buff);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,86 +1,86 @@
|
||||
/*
|
||||
HTTrack external callbacks example : changing the destination filename
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/* Options settings */
|
||||
#include "htsopt.h"
|
||||
|
||||
/* TOLOWER */
|
||||
#define TOLOWER_(a) (a >= 'A' && a <= 'Z') ? (a + ('a' - 'A')) : a
|
||||
#define TOLOWER(a) ( TOLOWER_( (a) ) )
|
||||
|
||||
/*
|
||||
This sample just changes the destination filenames to ROT-13 equivalent ; that is,
|
||||
a -> n
|
||||
b -> o
|
||||
c -> p
|
||||
d -> q
|
||||
..
|
||||
n -> a
|
||||
o -> b
|
||||
..
|
||||
|
||||
<parent> -> <link>
|
||||
This sample can be improved, for example, to make a map of a website.
|
||||
*/
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, savename, mysavename, NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save) {
|
||||
char* a;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, savename) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, savename)(CALLBACKARG_PREV_CARG(carg), opt, adr_complete, fil_complete, referer_adr, referer_fil, save)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
for(a = save ; *a != 0 ; a++) {
|
||||
char c = TOLOWER(*a);
|
||||
if (c >= 'a' && c <= 'z')
|
||||
*a = ( ( ( c - 'a' ) + 13 ) % 26 ) + 'a'; // ROT-13
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : changing the destination filename
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local function definitions */
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/* Options settings */
|
||||
#include "htsopt.h"
|
||||
|
||||
/* TOLOWER */
|
||||
#define TOLOWER_(a) (a >= 'A' && a <= 'Z') ? (a + ('a' - 'A')) : a
|
||||
#define TOLOWER(a) ( TOLOWER_( (a) ) )
|
||||
|
||||
/*
|
||||
This sample just changes the destination filenames to ROT-13 equivalent ; that is,
|
||||
a -> n
|
||||
b -> o
|
||||
c -> p
|
||||
d -> q
|
||||
..
|
||||
n -> a
|
||||
o -> b
|
||||
..
|
||||
|
||||
<parent> -> <link>
|
||||
This sample can be improved, for example, to make a map of a website.
|
||||
*/
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, savename, mysavename, NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save) {
|
||||
char* a;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, savename) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, savename)(CALLBACKARG_PREV_CARG(carg), opt, adr_complete, fil_complete, referer_adr, referer_fil, save)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
for(a = save ; *a != 0 ; a++) {
|
||||
char c = TOLOWER(*a);
|
||||
if (c >= 'a' && c <= 'z')
|
||||
*a = ( ( ( c - 'a' ) + 13 ) % 26 ) + 'a'; // ROT-13
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,130 +1,130 @@
|
||||
/*
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback,string1,string2 ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Function definitions */
|
||||
static int mysavename(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 myend(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/* TOLOWER */
|
||||
#define TOLOWER_(a) (a >= 'A' && a <= 'Z') ? (a + ('a' - 'A')) : a
|
||||
#define TOLOWER(a) ( TOLOWER_( (a) ) )
|
||||
|
||||
/*
|
||||
This sample just replaces all occurences of "string1" into "string2"
|
||||
string1 and string2 are passed in the callback string:
|
||||
httrack --wrapper save-name=callback:mysavename,string1,string2 ..
|
||||
*/
|
||||
|
||||
typedef struct t_my_userdef {
|
||||
char string1[256];
|
||||
char string2[256];
|
||||
} t_my_userdef;
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Check args */
|
||||
if (arg == NULL || *arg == '\0' || strchr(arg, ',') == NULL) {
|
||||
fprintf(stderr, "** callback error: arguments expected or bad arguments\n");
|
||||
fprintf(stderr, "usage: httrack --wrapper save-name=callback:mysavename,string1,string2\n");
|
||||
fprintf(stderr, "example: httrack --wrapper save-name=callback:mysavename,foo,bar\n");
|
||||
return 0; /* failed */
|
||||
} else {
|
||||
char *pos = strchr(arg, ',');
|
||||
t_my_userdef *userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef));
|
||||
char * const string1 = userdef->string1;
|
||||
char * const string2 = userdef->string2;
|
||||
|
||||
/* Split args */
|
||||
fprintf(stderr, "** info: wrapper_init(%s) called!\n", arg);
|
||||
fprintf(stderr, "** callback example: changing destination filename word by another one\n");
|
||||
string1[0] = string1[1] = '\0';
|
||||
strncat(string1, arg, pos - arg);
|
||||
strcpy(string2, pos + 1);
|
||||
fprintf(stderr, "** callback info: will replace %s by %s in filenames!\n", string1, string2);
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, savename, mysavename, userdef);
|
||||
CHAIN_FUNCTION(opt, end, myend, userdef);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int myend(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "** info: wrapper_exit() called!\n");
|
||||
if (userdef != NULL) {
|
||||
free(userdef);
|
||||
userdef = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const string1 = userdef->string1;
|
||||
char * const string2 = userdef->string2;
|
||||
/* */
|
||||
char *buff, *a, *b;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, savename) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, savename)(CALLBACKARG_PREV_CARG(carg), opt, adr_complete, fil_complete, referer_adr, referer_fil, save)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
buff = strdup(save);
|
||||
a = buff;
|
||||
b = save;
|
||||
*b = '\0'; /* the "save" variable points to a buffer with "sufficient" space */
|
||||
while(*a) {
|
||||
if (strncmp(a, string1, (int)strlen(string1)) == 0) {
|
||||
strcat(b, string2);
|
||||
b += strlen(b);
|
||||
a += strlen(string1);
|
||||
} else {
|
||||
*b++ = *a++;
|
||||
*b = '\0';
|
||||
}
|
||||
}
|
||||
free(buff);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback,string1,string2 ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Function definitions */
|
||||
static int mysavename(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 myend(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/* TOLOWER */
|
||||
#define TOLOWER_(a) (a >= 'A' && a <= 'Z') ? (a + ('a' - 'A')) : a
|
||||
#define TOLOWER(a) ( TOLOWER_( (a) ) )
|
||||
|
||||
/*
|
||||
This sample just replaces all occurences of "string1" into "string2"
|
||||
string1 and string2 are passed in the callback string:
|
||||
httrack --wrapper save-name=callback:mysavename,string1,string2 ..
|
||||
*/
|
||||
|
||||
typedef struct t_my_userdef {
|
||||
char string1[256];
|
||||
char string2[256];
|
||||
} t_my_userdef;
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Check args */
|
||||
if (arg == NULL || *arg == '\0' || strchr(arg, ',') == NULL) {
|
||||
fprintf(stderr, "** callback error: arguments expected or bad arguments\n");
|
||||
fprintf(stderr, "usage: httrack --wrapper save-name=callback:mysavename,string1,string2\n");
|
||||
fprintf(stderr, "example: httrack --wrapper save-name=callback:mysavename,foo,bar\n");
|
||||
return 0; /* failed */
|
||||
} else {
|
||||
char *pos = strchr(arg, ',');
|
||||
t_my_userdef *userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef));
|
||||
char * const string1 = userdef->string1;
|
||||
char * const string2 = userdef->string2;
|
||||
|
||||
/* Split args */
|
||||
fprintf(stderr, "** info: wrapper_init(%s) called!\n", arg);
|
||||
fprintf(stderr, "** callback example: changing destination filename word by another one\n");
|
||||
string1[0] = string1[1] = '\0';
|
||||
strncat(string1, arg, pos - arg);
|
||||
strcpy(string2, pos + 1);
|
||||
fprintf(stderr, "** callback info: will replace %s by %s in filenames!\n", string1, string2);
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, savename, mysavename, userdef);
|
||||
CHAIN_FUNCTION(opt, end, myend, userdef);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int myend(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "** info: wrapper_exit() called!\n");
|
||||
if (userdef != NULL) {
|
||||
free(userdef);
|
||||
userdef = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const string1 = userdef->string1;
|
||||
char * const string2 = userdef->string2;
|
||||
/* */
|
||||
char *buff, *a, *b;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, savename) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, savename)(CALLBACKARG_PREV_CARG(carg), opt, adr_complete, fil_complete, referer_adr, referer_fil, save)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
buff = strdup(save);
|
||||
a = buff;
|
||||
b = save;
|
||||
*b = '\0'; /* the "save" variable points to a buffer with "sufficient" space */
|
||||
while(*a) {
|
||||
if (strncmp(a, string1, (int)strlen(string1)) == 0) {
|
||||
strcat(b, string2);
|
||||
b += strlen(b);
|
||||
a += strlen(string1);
|
||||
} else {
|
||||
*b++ = *a++;
|
||||
*b = '\0';
|
||||
}
|
||||
}
|
||||
free(buff);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
/*
|
||||
HTTrack external callbacks example : changing folder names ending with ".com"
|
||||
with ".c0m" as a workaround of IIS bug (see KB 275601)
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Function definitions */
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
CHAIN_FUNCTION(opt, savename, mysavename, NULL);
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
Replaces all "offending" IIS extensions (exe, dll..) with "nice" ones
|
||||
*/
|
||||
static int mysavename(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 const char* iisBogus[] = { ".com", ".exe", ".dll", ".sh", NULL };
|
||||
static const char* iisBogusReplace[] = { ".c0m", ".ex3", ".dl1", ".5h", NULL }; /* MUST be the same sizes */
|
||||
char* a;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, savename) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, savename)(CALLBACKARG_PREV_CARG(carg), opt, adr_complete, fil_complete, referer_adr, referer_fil, save)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
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 */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : changing folder names ending with ".com"
|
||||
with ".c0m" as a workaround of IIS bug (see KB 275601)
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Function definitions */
|
||||
static int mysavename(t_hts_callbackarg *carg, httrackp *opt, const char* adr_complete, const char* fil_complete, const char* referer_adr, const char* referer_fil, char* save);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
CHAIN_FUNCTION(opt, savename, mysavename, NULL);
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
Replaces all "offending" IIS extensions (exe, dll..) with "nice" ones
|
||||
*/
|
||||
static int mysavename(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 const char* iisBogus[] = { ".com", ".exe", ".dll", ".sh", NULL };
|
||||
static const char* iisBogusReplace[] = { ".c0m", ".ex3", ".dl1", ".5h", NULL }; /* MUST be the same sizes */
|
||||
char* a;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, savename) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, savename)(CALLBACKARG_PREV_CARG(carg), opt, adr_complete, fil_complete, referer_adr, referer_fil, save)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
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 */
|
||||
}
|
||||
|
||||
@@ -1,133 +1,133 @@
|
||||
/*
|
||||
HTTrack external callbacks example
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Function definitions */
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* url_address, const char* url_file);
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp *opt, char* link);
|
||||
static int check_loop(t_hts_callbackarg *carg, httrackp *opt, void* back,int back_max,int back_index,int lien_tot,int lien_ntot,int stat_time,void* stats);
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
This sample just lists all links in documents with the parent link:
|
||||
<parent> -> <link>
|
||||
This sample can be improved, for example, to make a map of a website.
|
||||
*/
|
||||
|
||||
typedef struct t_my_userdef {
|
||||
char currentURLBeingParsed[2048];
|
||||
} t_my_userdef;
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
t_my_userdef *userdef;
|
||||
/* */
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Create user-defined structure */
|
||||
userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef)); /* userdef */
|
||||
userdef->currentURLBeingParsed[0] = '\0';
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, userdef);
|
||||
CHAIN_FUNCTION(opt, end, end, userdef);
|
||||
CHAIN_FUNCTION(opt, linkdetected, check_detectedlink, userdef);
|
||||
CHAIN_FUNCTION(opt, loop, check_loop, userdef);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* url_address, const char* url_file) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const currentURLBeingParsed = userdef->currentURLBeingParsed;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("now parsing %s%s..\n", url_address, url_file);
|
||||
strcpy(currentURLBeingParsed, url_address);
|
||||
strcat(currentURLBeingParsed, url_file);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp *opt, char* link) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const currentURLBeingParsed = userdef->currentURLBeingParsed;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, linkdetected) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, linkdetected)(CALLBACKARG_PREV_CARG(carg), opt, link)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("[%s] -> [%s]\n", currentURLBeingParsed, link);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_loop(t_hts_callbackarg *carg, httrackp *opt, void* back,int back_max,int back_index,int lien_tot,int lien_ntot,int stat_time,void* stats) {
|
||||
static int fun_animation=0;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, loop) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, loop)(CALLBACKARG_PREV_CARG(carg), opt, back, back_max, back_index, lien_tot, lien_ntot, stat_time, stats)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("%c\r", "/-\\|"[(fun_animation++)%4]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
fprintf(stderr, "** info: wrapper_exit() called!\n");
|
||||
if (userdef != NULL) {
|
||||
free(userdef);
|
||||
userdef = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example
|
||||
.c file
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Function definitions */
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* url_address, const char* url_file);
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp *opt, char* link);
|
||||
static int check_loop(t_hts_callbackarg *carg, httrackp *opt, void* back,int back_max,int back_index,int lien_tot,int lien_ntot,int stat_time,void* stats);
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt);
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
|
||||
/*
|
||||
This sample just lists all links in documents with the parent link:
|
||||
<parent> -> <link>
|
||||
This sample can be improved, for example, to make a map of a website.
|
||||
*/
|
||||
|
||||
typedef struct t_my_userdef {
|
||||
char currentURLBeingParsed[2048];
|
||||
} t_my_userdef;
|
||||
|
||||
/*
|
||||
module entry point
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
t_my_userdef *userdef;
|
||||
/* */
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* Create user-defined structure */
|
||||
userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef)); /* userdef */
|
||||
userdef->currentURLBeingParsed[0] = '\0';
|
||||
|
||||
/* Plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, userdef);
|
||||
CHAIN_FUNCTION(opt, end, end, userdef);
|
||||
CHAIN_FUNCTION(opt, linkdetected, check_detectedlink, userdef);
|
||||
CHAIN_FUNCTION(opt, loop, check_loop, userdef);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp *opt, char* html, int len, const char* url_address, const char* url_file) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const currentURLBeingParsed = userdef->currentURLBeingParsed;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("now parsing %s%s..\n", url_address, url_file);
|
||||
strcpy(currentURLBeingParsed, url_address);
|
||||
strcat(currentURLBeingParsed, url_file);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_detectedlink(t_hts_callbackarg *carg, httrackp *opt, char* link) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
char * const currentURLBeingParsed = userdef->currentURLBeingParsed;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, linkdetected) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, linkdetected)(CALLBACKARG_PREV_CARG(carg), opt, link)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("[%s] -> [%s]\n", currentURLBeingParsed, link);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int check_loop(t_hts_callbackarg *carg, httrackp *opt, void* back,int back_max,int back_index,int lien_tot,int lien_ntot,int stat_time,void* stats) {
|
||||
static int fun_animation=0;
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, loop) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, loop)(CALLBACKARG_PREV_CARG(carg), opt, back, back_max, back_index, lien_tot, lien_ntot, stat_time, stats)) {
|
||||
return 0; /* Abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
printf("%c\r", "/-\\|"[(fun_animation++)%4]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int end(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
t_my_userdef *userdef = (t_my_userdef*) CALLBACKARG_USERDEF(carg);
|
||||
fprintf(stderr, "** info: wrapper_exit() called!\n");
|
||||
if (userdef != NULL) {
|
||||
free(userdef);
|
||||
userdef = NULL;
|
||||
}
|
||||
|
||||
/* Call parent functions if multiple callbacks are chained. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,114 +1,114 @@
|
||||
/*
|
||||
HTTrack external callbacks example : dumy plugin, aimed to log for debugging purpose
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
/* system includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt);
|
||||
|
||||
/* local function called as "check_html" callback */
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char* html, int len, const char* url_address, const char* url_file) {
|
||||
void *ourDummyArg = (void*) CALLBACKARG_USERDEF(carg); /*optional user-defined arg*/
|
||||
char *fmt;
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt,
|
||||
html, len, url_address, url_file)) {
|
||||
return 0; /* abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* log */
|
||||
fprintf(stderr, "* parsing file %s%s\n", url_address, url_file);
|
||||
fmt = malloc(strlen(url_address) + strlen(url_file) + 128);
|
||||
sprintf(fmt, " parsing file %s%s", url_address, url_file);
|
||||
hts_log(opt, "log-wrapper-info", fmt);
|
||||
free(fmt);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int start_of_mirror(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
const char *arginfo = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "* mirror start\n");
|
||||
hts_log(opt, arginfo, "mirror started");
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
/* status is ok on our side, return other callabck's status */
|
||||
return CALLBACKARG_PREV_FUN(carg, start)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/* local function called as "end" callback */
|
||||
static int end_of_mirror(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
const char *arginfo = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "* mirror end\n");
|
||||
hts_log(opt, arginfo, "mirror ended");
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
/* status is ok on our side, return other callabck's status */
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module entry point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
/* optional argument passed in the commandline we won't be using here */
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* plug callback functions */
|
||||
if (arg == NULL)
|
||||
arg = "log-wrapper-info";
|
||||
hts_log(opt, arg, "* plugging functions");
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, (char*) arg);
|
||||
CHAIN_FUNCTION(opt, start, start_of_mirror, (char*) arg);
|
||||
CHAIN_FUNCTION(opt, end, end_of_mirror, (char*) arg);
|
||||
|
||||
hts_log(opt, arg, "* module successfully plugged");
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module exit point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt) {
|
||||
hts_log(opt, "log-wrapper-info", "* module successfully unplugged");
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : dumy plugin, aimed to log for debugging purpose
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
/* system includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt);
|
||||
|
||||
/* local function called as "check_html" callback */
|
||||
static int process_file(t_hts_callbackarg *carg, httrackp *opt,
|
||||
char* html, int len, const char* url_address, const char* url_file) {
|
||||
void *ourDummyArg = (void*) CALLBACKARG_USERDEF(carg); /*optional user-defined arg*/
|
||||
char *fmt;
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt,
|
||||
html, len, url_address, url_file)) {
|
||||
return 0; /* abort */
|
||||
}
|
||||
}
|
||||
|
||||
/* log */
|
||||
fprintf(stderr, "* parsing file %s%s\n", url_address, url_file);
|
||||
fmt = malloc(strlen(url_address) + strlen(url_file) + 128);
|
||||
sprintf(fmt, " parsing file %s%s", url_address, url_file);
|
||||
hts_log(opt, "log-wrapper-info", fmt);
|
||||
free(fmt);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int start_of_mirror(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
const char *arginfo = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "* mirror start\n");
|
||||
hts_log(opt, arginfo, "mirror started");
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
/* status is ok on our side, return other callabck's status */
|
||||
return CALLBACKARG_PREV_FUN(carg, start)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/* local function called as "end" callback */
|
||||
static int end_of_mirror(t_hts_callbackarg *carg, httrackp *opt) {
|
||||
const char *arginfo = (char*) CALLBACKARG_USERDEF(carg);
|
||||
|
||||
fprintf(stderr, "* mirror end\n");
|
||||
hts_log(opt, arginfo, "mirror ended");
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
/* status is ok on our side, return other callabck's status */
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module entry point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
/* optional argument passed in the commandline we won't be using here */
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* plug callback functions */
|
||||
if (arg == NULL)
|
||||
arg = "log-wrapper-info";
|
||||
hts_log(opt, arg, "* plugging functions");
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, (char*) arg);
|
||||
CHAIN_FUNCTION(opt, start, start_of_mirror, (char*) arg);
|
||||
CHAIN_FUNCTION(opt, end, end_of_mirror, (char*) arg);
|
||||
|
||||
hts_log(opt, arg, "* module successfully plugged");
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module exit point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt) {
|
||||
hts_log(opt, "log-wrapper-info", "* module successfully unplugged");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
/*
|
||||
HTTrack external callbacks example : print all downloaded html documents
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack1.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
/* system includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt);
|
||||
|
||||
/* local function called as "check_html" callback */
|
||||
static int process_file(t_hts_callbackarg /*the carg structure, holding various information*/*carg, /*the option settings*/httrackp *opt,
|
||||
/*other parameters are callback-specific*/
|
||||
char* html, int len, const char* url_address, const char* url_file) {
|
||||
void *ourDummyArg = (void*) CALLBACKARG_USERDEF(carg); /*optional user-defined arg*/
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt,
|
||||
html, len, url_address, url_file)) {
|
||||
return 0; /* abort */
|
||||
}
|
||||
}
|
||||
|
||||
printf("file %s%s content: %s\n", url_address, url_file, html);
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/* local function called as "end" callback */
|
||||
static int end_of_mirror(t_hts_callbackarg /*the carg structure, holding various information*/*carg, /*the option settings*/httrackp *opt) {
|
||||
void *ourDummyArg = (void*) CALLBACKARG_USERDEF(carg); /*optional user-defined arg*/
|
||||
|
||||
/* processing */
|
||||
fprintf(stderr, "That's all, folks!\n");
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
/* status is ok on our side, return other callabck's status */
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module entry point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
/* optional argument passed in the commandline we won't be using here */
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, /*optional user-defined arg*/NULL);
|
||||
CHAIN_FUNCTION(opt, end, end_of_mirror, /*optional user-defined arg*/NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module exit point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt) {
|
||||
fprintf(stderr, "Module unplugged");
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
/*
|
||||
HTTrack external callbacks example : print all downloaded html documents
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -O -g3 -Wall -D_REENTRANT -shared -o mycallback.so callbacks-example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -LD -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.dll" callbacks-example.c libhttrack.lib
|
||||
|
||||
Note: the httrack library linker option is only necessary when using libhttrack's functions inside the callback
|
||||
|
||||
How to use:
|
||||
httrack --wrapper mycallback ..
|
||||
*/
|
||||
|
||||
/* system includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* external functions */
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv);
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt);
|
||||
|
||||
/* local function called as "check_html" callback */
|
||||
static int process_file(t_hts_callbackarg /*the carg structure, holding various information*/*carg, /*the option settings*/httrackp *opt,
|
||||
/*other parameters are callback-specific*/
|
||||
char* html, int len, const char* url_address, const char* url_file) {
|
||||
void *ourDummyArg = (void*) CALLBACKARG_USERDEF(carg); /*optional user-defined arg*/
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, check_html) != NULL) {
|
||||
if (!CALLBACKARG_PREV_FUN(carg, check_html)(CALLBACKARG_PREV_CARG(carg), opt,
|
||||
html, len, url_address, url_file)) {
|
||||
return 0; /* abort */
|
||||
}
|
||||
}
|
||||
|
||||
printf("file %s%s content: %s\n", url_address, url_file, html);
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/* local function called as "end" callback */
|
||||
static int end_of_mirror(t_hts_callbackarg /*the carg structure, holding various information*/*carg, /*the option settings*/httrackp *opt) {
|
||||
void *ourDummyArg = (void*) CALLBACKARG_USERDEF(carg); /*optional user-defined arg*/
|
||||
|
||||
/* processing */
|
||||
fprintf(stderr, "That's all, folks!\n");
|
||||
|
||||
/* call parent functions if multiple callbacks are chained. you can skip this part, if you don't want previous callbacks to be called. */
|
||||
if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {
|
||||
/* status is ok on our side, return other callabck's status */
|
||||
return CALLBACKARG_PREV_FUN(carg, end)(CALLBACKARG_PREV_CARG(carg), opt);
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module entry point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) {
|
||||
/* optional argument passed in the commandline we won't be using here */
|
||||
const char *arg = strchr(argv, ',');
|
||||
if (arg != NULL)
|
||||
arg++;
|
||||
|
||||
/* plug callback functions */
|
||||
CHAIN_FUNCTION(opt, check_html, process_file, /*optional user-defined arg*/NULL);
|
||||
CHAIN_FUNCTION(opt, end, end_of_mirror, /*optional user-defined arg*/NULL);
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
module exit point
|
||||
the function name and prototype MUST match this prototype
|
||||
*/
|
||||
EXTERNAL_FUNCTION int hts_unplug(httrackp *opt) {
|
||||
fprintf(stderr, "Module unplugged");
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
@@ -1,201 +1,201 @@
|
||||
/*
|
||||
HTTrack library example
|
||||
.c file
|
||||
|
||||
Prerequisites:
|
||||
- install winhttrack
|
||||
- set the proper path in the project settings (especially for the httrack lib and dll)
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -I/usr/include/httrack -O -g3 -Wall -D_REENTRANT -o example example.c -lhttrack1
|
||||
With MS-Visual C++:
|
||||
cl -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.exe" callbacks-example.c wsock32.lib libhttrack.lib
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local definitions */
|
||||
#include "example.h"
|
||||
|
||||
/*
|
||||
* Name: main
|
||||
* Description: main() function
|
||||
* Parameters: None
|
||||
* Should return: error status
|
||||
*/
|
||||
int main(void) {
|
||||
/*
|
||||
First, ask for an URL
|
||||
Note: For the test, option r2 (mirror max depth=1) and --testscan (no index, no cache, do not store, no log files)
|
||||
*/
|
||||
char _argv[][256] = {"httrack_test" , "<URL>" , "-r3" , "--testscan" , "" };
|
||||
char* argv[] = {NULL , NULL , NULL , NULL , NULL};
|
||||
int argc = 0;
|
||||
httrackp *opt;
|
||||
int ret;
|
||||
while(strlen(_argv[argc])) {
|
||||
argv[argc]=_argv[argc];
|
||||
argc++;
|
||||
}
|
||||
argv[argc]=NULL;
|
||||
printf("HTTrackLib test program\n");
|
||||
printf("Enter URL (example: www.foobar.com/index.html) :");
|
||||
scanf("%s",argv[1]);
|
||||
printf("Test: 1 depth\n");
|
||||
|
||||
/* Initialize the library */
|
||||
#ifdef _WIN32
|
||||
{
|
||||
WORD wVersionRequested; // requested version WinSock API
|
||||
WSADATA wsadata; // Windows Sockets API data
|
||||
int stat;
|
||||
wVersionRequested = 0x0101;
|
||||
stat = WSAStartup( wVersionRequested, &wsadata );
|
||||
if (stat != 0) {
|
||||
printf("Winsock not found!\n");
|
||||
return;
|
||||
} else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) {
|
||||
printf("WINSOCK.DLL does not support version 1.1\n");
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
hts_init();
|
||||
|
||||
/* Create option settings and set callbacks (wrappers) */
|
||||
opt = hts_create_opt();
|
||||
|
||||
CHAIN_FUNCTION(opt, init, httrack_wrapper_init, NULL);
|
||||
CHAIN_FUNCTION(opt, uninit, httrack_wrapper_uninit, NULL);
|
||||
CHAIN_FUNCTION(opt, start, httrack_wrapper_start, NULL);
|
||||
CHAIN_FUNCTION(opt, end, httrack_wrapper_end, NULL);
|
||||
CHAIN_FUNCTION(opt, chopt, httrack_wrapper_chopt, NULL);
|
||||
CHAIN_FUNCTION(opt, preprocess, httrack_wrapper_preprocesshtml, NULL);
|
||||
CHAIN_FUNCTION(opt, postprocess, httrack_wrapper_postprocesshtml, NULL);
|
||||
CHAIN_FUNCTION(opt, check_html, httrack_wrapper_checkhtml, NULL);
|
||||
CHAIN_FUNCTION(opt, query, httrack_wrapper_query, NULL);
|
||||
CHAIN_FUNCTION(opt, query2, httrack_wrapper_query2, NULL);
|
||||
CHAIN_FUNCTION(opt, query3, httrack_wrapper_query3, NULL);
|
||||
CHAIN_FUNCTION(opt, loop, httrack_wrapper_loop, NULL);
|
||||
CHAIN_FUNCTION(opt, check_link, httrack_wrapper_check, NULL);
|
||||
CHAIN_FUNCTION(opt, check_mime, httrack_wrapper_check_mime, NULL);
|
||||
CHAIN_FUNCTION(opt, pause, httrack_wrapper_pause, NULL);
|
||||
CHAIN_FUNCTION(opt, filesave, httrack_wrapper_filesave, NULL);
|
||||
CHAIN_FUNCTION(opt, filesave2, httrack_wrapper_filesave2, NULL);
|
||||
CHAIN_FUNCTION(opt, linkdetected, httrack_wrapper_linkdetected, NULL);
|
||||
CHAIN_FUNCTION(opt, linkdetected2, httrack_wrapper_linkdetected2, NULL);
|
||||
CHAIN_FUNCTION(opt, xfrstatus, httrack_wrapper_xfrstatus, NULL);
|
||||
CHAIN_FUNCTION(opt, savename, httrack_wrapper_savename, NULL);
|
||||
CHAIN_FUNCTION(opt, sendhead, httrack_wrapper_sendheader, NULL);
|
||||
CHAIN_FUNCTION(opt, receivehead, httrack_wrapper_receiveheader, NULL);
|
||||
|
||||
/* Then, launch the mirror */
|
||||
ret = hts_main2(argc, argv, opt);
|
||||
|
||||
/* Wait for a key */
|
||||
printf("\nPress ENTER key to exit\n");
|
||||
scanf("%s",argv[1]);
|
||||
|
||||
/* Clear option state */
|
||||
hts_free_opt(opt);
|
||||
hts_uninit();
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
|
||||
/* That's all! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* CALLBACK FUNCTIONS */
|
||||
|
||||
/* Initialize the Winsock */
|
||||
static void CDECL httrack_wrapper_init(t_hts_callbackarg *carg) {
|
||||
printf("Engine started\n");
|
||||
}
|
||||
static void CDECL httrack_wrapper_uninit(t_hts_callbackarg *carg) {
|
||||
printf("Engine exited\n");
|
||||
}
|
||||
static int CDECL httrack_wrapper_start(t_hts_callbackarg *carg, httrackp* opt) {
|
||||
printf("Start of mirror\n");
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_chopt(t_hts_callbackarg *carg, httrackp* opt) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_end(t_hts_callbackarg *carg, httrackp* opt) {
|
||||
printf("End of mirror\n");
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_checkhtml(t_hts_callbackarg *carg, httrackp *opt, char* html,int len,const char* url_address,const char* url_file) {
|
||||
printf("Parsing html file: http://%s%s\n",url_address,url_file);
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_loop(t_hts_callbackarg *carg, httrackp *opt, void* _back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats) {
|
||||
/* printf("..httrack_wrapper_loop called\n"); */
|
||||
return 1;
|
||||
}
|
||||
static const char* CDECL httrack_wrapper_query(t_hts_callbackarg *carg, httrackp *opt, const char* question) {
|
||||
/* Answer is No */
|
||||
return "N";
|
||||
}
|
||||
static const char* CDECL httrack_wrapper_query2(t_hts_callbackarg *carg, httrackp *opt, const char* question) {
|
||||
/* Answer is No */
|
||||
return "N";
|
||||
}
|
||||
static const char* CDECL httrack_wrapper_query3(t_hts_callbackarg *carg, httrackp *opt, const char* question) {
|
||||
/* Answer is "" */
|
||||
return "";
|
||||
}
|
||||
static int CDECL httrack_wrapper_check(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,int status) {
|
||||
printf("Link status tested: http://%s%s\n",adr,fil);
|
||||
return -1;
|
||||
}
|
||||
static void CDECL httrack_wrapper_pause(t_hts_callbackarg *carg, httrackp *opt, const char* lockfile) {
|
||||
/* Wait until lockfile is removed.. */
|
||||
}
|
||||
static void CDECL httrack_wrapper_filesave(t_hts_callbackarg *carg, httrackp *opt, const char* file) {
|
||||
}
|
||||
static int CDECL httrack_wrapper_linkdetected(t_hts_callbackarg *carg, httrackp *opt, char* link) {
|
||||
printf("Link detected: %s\n",link);
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_xfrstatus(t_hts_callbackarg *carg, httrackp *opt, void* back) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_preprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_postprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_check_mime(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,const char* mime,int status) {
|
||||
return -1;
|
||||
}
|
||||
static void CDECL httrack_wrapper_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 httrack_wrapper_linkdetected2(t_hts_callbackarg *carg, httrackp *opt, char* link, const char* start_tag) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_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 httrack_wrapper_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 httrack_wrapper_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;
|
||||
}
|
||||
/*
|
||||
HTTrack library example
|
||||
.c file
|
||||
|
||||
Prerequisites:
|
||||
- install winhttrack
|
||||
- set the proper path in the project settings (especially for the httrack lib and dll)
|
||||
|
||||
How to build: (callback.so or callback.dll)
|
||||
With GNU-GCC:
|
||||
gcc -I/usr/include/httrack -O -g3 -Wall -D_REENTRANT -o example example.c -lhttrack2
|
||||
With MS-Visual C++:
|
||||
cl -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.exe" callbacks-example.c wsock32.lib libhttrack.lib
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* Standard httrack module includes */
|
||||
#include "httrack-library.h"
|
||||
#include "htsopt.h"
|
||||
#include "htsdefines.h"
|
||||
|
||||
/* Local definitions */
|
||||
#include "example.h"
|
||||
|
||||
/*
|
||||
* Name: main
|
||||
* Description: main() function
|
||||
* Parameters: None
|
||||
* Should return: error status
|
||||
*/
|
||||
int main(void) {
|
||||
/*
|
||||
First, ask for an URL
|
||||
Note: For the test, option r2 (mirror max depth=1) and --testscan (no index, no cache, do not store, no log files)
|
||||
*/
|
||||
char _argv[][256] = {"httrack_test" , "<URL>" , "-r3" , "--testscan" , "" };
|
||||
char* argv[] = {NULL , NULL , NULL , NULL , NULL};
|
||||
int argc = 0;
|
||||
httrackp *opt;
|
||||
int ret;
|
||||
while(strlen(_argv[argc])) {
|
||||
argv[argc]=_argv[argc];
|
||||
argc++;
|
||||
}
|
||||
argv[argc]=NULL;
|
||||
printf("HTTrackLib test program\n");
|
||||
printf("Enter URL (example: www.foobar.com/index.html) :");
|
||||
scanf("%s",argv[1]);
|
||||
printf("Test: 1 depth\n");
|
||||
|
||||
/* Initialize the library */
|
||||
#ifdef _WIN32
|
||||
{
|
||||
WORD wVersionRequested; // requested version WinSock API
|
||||
WSADATA wsadata; // Windows Sockets API data
|
||||
int stat;
|
||||
wVersionRequested = 0x0101;
|
||||
stat = WSAStartup( wVersionRequested, &wsadata );
|
||||
if (stat != 0) {
|
||||
printf("Winsock not found!\n");
|
||||
return;
|
||||
} else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) {
|
||||
printf("WINSOCK.DLL does not support version 1.1\n");
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
hts_init();
|
||||
|
||||
/* Create option settings and set callbacks (wrappers) */
|
||||
opt = hts_create_opt();
|
||||
|
||||
CHAIN_FUNCTION(opt, init, httrack_wrapper_init, NULL);
|
||||
CHAIN_FUNCTION(opt, uninit, httrack_wrapper_uninit, NULL);
|
||||
CHAIN_FUNCTION(opt, start, httrack_wrapper_start, NULL);
|
||||
CHAIN_FUNCTION(opt, end, httrack_wrapper_end, NULL);
|
||||
CHAIN_FUNCTION(opt, chopt, httrack_wrapper_chopt, NULL);
|
||||
CHAIN_FUNCTION(opt, preprocess, httrack_wrapper_preprocesshtml, NULL);
|
||||
CHAIN_FUNCTION(opt, postprocess, httrack_wrapper_postprocesshtml, NULL);
|
||||
CHAIN_FUNCTION(opt, check_html, httrack_wrapper_checkhtml, NULL);
|
||||
CHAIN_FUNCTION(opt, query, httrack_wrapper_query, NULL);
|
||||
CHAIN_FUNCTION(opt, query2, httrack_wrapper_query2, NULL);
|
||||
CHAIN_FUNCTION(opt, query3, httrack_wrapper_query3, NULL);
|
||||
CHAIN_FUNCTION(opt, loop, httrack_wrapper_loop, NULL);
|
||||
CHAIN_FUNCTION(opt, check_link, httrack_wrapper_check, NULL);
|
||||
CHAIN_FUNCTION(opt, check_mime, httrack_wrapper_check_mime, NULL);
|
||||
CHAIN_FUNCTION(opt, pause, httrack_wrapper_pause, NULL);
|
||||
CHAIN_FUNCTION(opt, filesave, httrack_wrapper_filesave, NULL);
|
||||
CHAIN_FUNCTION(opt, filesave2, httrack_wrapper_filesave2, NULL);
|
||||
CHAIN_FUNCTION(opt, linkdetected, httrack_wrapper_linkdetected, NULL);
|
||||
CHAIN_FUNCTION(opt, linkdetected2, httrack_wrapper_linkdetected2, NULL);
|
||||
CHAIN_FUNCTION(opt, xfrstatus, httrack_wrapper_xfrstatus, NULL);
|
||||
CHAIN_FUNCTION(opt, savename, httrack_wrapper_savename, NULL);
|
||||
CHAIN_FUNCTION(opt, sendhead, httrack_wrapper_sendheader, NULL);
|
||||
CHAIN_FUNCTION(opt, receivehead, httrack_wrapper_receiveheader, NULL);
|
||||
|
||||
/* Then, launch the mirror */
|
||||
ret = hts_main2(argc, argv, opt);
|
||||
|
||||
/* Wait for a key */
|
||||
printf("\nPress ENTER key to exit\n");
|
||||
scanf("%s",argv[1]);
|
||||
|
||||
/* Clear option state */
|
||||
hts_free_opt(opt);
|
||||
hts_uninit();
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
|
||||
/* That's all! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* CALLBACK FUNCTIONS */
|
||||
|
||||
/* Initialize the Winsock */
|
||||
static void CDECL httrack_wrapper_init(t_hts_callbackarg *carg) {
|
||||
printf("Engine started\n");
|
||||
}
|
||||
static void CDECL httrack_wrapper_uninit(t_hts_callbackarg *carg) {
|
||||
printf("Engine exited\n");
|
||||
}
|
||||
static int CDECL httrack_wrapper_start(t_hts_callbackarg *carg, httrackp* opt) {
|
||||
printf("Start of mirror\n");
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_chopt(t_hts_callbackarg *carg, httrackp* opt) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_end(t_hts_callbackarg *carg, httrackp* opt) {
|
||||
printf("End of mirror\n");
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_checkhtml(t_hts_callbackarg *carg, httrackp *opt, char* html,int len,const char* url_address,const char* url_file) {
|
||||
printf("Parsing html file: http://%s%s\n",url_address,url_file);
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_loop(t_hts_callbackarg *carg, httrackp *opt, void* _back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats) {
|
||||
/* printf("..httrack_wrapper_loop called\n"); */
|
||||
return 1;
|
||||
}
|
||||
static const char* CDECL httrack_wrapper_query(t_hts_callbackarg *carg, httrackp *opt, const char* question) {
|
||||
/* Answer is No */
|
||||
return "N";
|
||||
}
|
||||
static const char* CDECL httrack_wrapper_query2(t_hts_callbackarg *carg, httrackp *opt, const char* question) {
|
||||
/* Answer is No */
|
||||
return "N";
|
||||
}
|
||||
static const char* CDECL httrack_wrapper_query3(t_hts_callbackarg *carg, httrackp *opt, const char* question) {
|
||||
/* Answer is "" */
|
||||
return "";
|
||||
}
|
||||
static int CDECL httrack_wrapper_check(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,int status) {
|
||||
printf("Link status tested: http://%s%s\n",adr,fil);
|
||||
return -1;
|
||||
}
|
||||
static void CDECL httrack_wrapper_pause(t_hts_callbackarg *carg, httrackp *opt, const char* lockfile) {
|
||||
/* Wait until lockfile is removed.. */
|
||||
}
|
||||
static void CDECL httrack_wrapper_filesave(t_hts_callbackarg *carg, httrackp *opt, const char* file) {
|
||||
}
|
||||
static int CDECL httrack_wrapper_linkdetected(t_hts_callbackarg *carg, httrackp *opt, char* link) {
|
||||
printf("Link detected: %s\n",link);
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_xfrstatus(t_hts_callbackarg *carg, httrackp *opt, void* back) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_preprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_postprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_check_mime(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,const char* mime,int status) {
|
||||
return -1;
|
||||
}
|
||||
static void CDECL httrack_wrapper_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 httrack_wrapper_linkdetected2(t_hts_callbackarg *carg, httrackp *opt, char* link, const char* start_tag) {
|
||||
return 1;
|
||||
}
|
||||
static int CDECL httrack_wrapper_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 httrack_wrapper_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 httrack_wrapper_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;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
/*
|
||||
HTTrack library example
|
||||
.h file
|
||||
*/
|
||||
|
||||
#ifdef __WIN32
|
||||
#define CDECL __cdecl
|
||||
#else
|
||||
#define CDECL
|
||||
#endif
|
||||
|
||||
static void CDECL httrack_wrapper_init(t_hts_callbackarg *carg);
|
||||
static void CDECL httrack_wrapper_uninit(t_hts_callbackarg *carg);
|
||||
static int CDECL httrack_wrapper_start(t_hts_callbackarg *carg, httrackp* opt);
|
||||
static int CDECL httrack_wrapper_chopt(t_hts_callbackarg *carg, httrackp* opt);
|
||||
static int CDECL httrack_wrapper_end(t_hts_callbackarg *carg, httrackp* opt);
|
||||
static int CDECL httrack_wrapper_checkhtml(t_hts_callbackarg *carg, httrackp *opt, char* html,int len,const char* url_address,const char* url_file);
|
||||
static int CDECL httrack_wrapper_loop(t_hts_callbackarg *carg, httrackp *opt, void* _back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats);
|
||||
static const char* CDECL httrack_wrapper_query(t_hts_callbackarg *carg, httrackp *opt, const char* question);
|
||||
static const char* CDECL httrack_wrapper_query2(t_hts_callbackarg *carg, httrackp *opt, const char* question);
|
||||
static const char* CDECL httrack_wrapper_query3(t_hts_callbackarg *carg, httrackp *opt, const char* question);
|
||||
static int CDECL httrack_wrapper_check(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,int status);
|
||||
static void CDECL httrack_wrapper_pause(t_hts_callbackarg *carg, httrackp *opt, const char* lockfile);
|
||||
static void CDECL httrack_wrapper_filesave(t_hts_callbackarg *carg, httrackp *opt, const char* file);
|
||||
static int CDECL httrack_wrapper_linkdetected(t_hts_callbackarg *carg, httrackp *opt, char* link);
|
||||
static int CDECL httrack_wrapper_xfrstatus(t_hts_callbackarg *carg, httrackp *opt, void* back);
|
||||
static int CDECL httrack_wrapper_preprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file);
|
||||
static int CDECL httrack_wrapper_postprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file);
|
||||
static int CDECL httrack_wrapper_check_mime(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,const char* mime,int status);
|
||||
static void CDECL httrack_wrapper_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 httrack_wrapper_linkdetected2(t_hts_callbackarg *carg, httrackp *opt, char* link, const char* start_tag);
|
||||
static int CDECL httrack_wrapper_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 httrack_wrapper_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 httrack_wrapper_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);
|
||||
/*
|
||||
HTTrack library example
|
||||
.h file
|
||||
*/
|
||||
|
||||
#ifdef __WIN32
|
||||
#define CDECL __cdecl
|
||||
#else
|
||||
#define CDECL
|
||||
#endif
|
||||
|
||||
static void CDECL httrack_wrapper_init(t_hts_callbackarg *carg);
|
||||
static void CDECL httrack_wrapper_uninit(t_hts_callbackarg *carg);
|
||||
static int CDECL httrack_wrapper_start(t_hts_callbackarg *carg, httrackp* opt);
|
||||
static int CDECL httrack_wrapper_chopt(t_hts_callbackarg *carg, httrackp* opt);
|
||||
static int CDECL httrack_wrapper_end(t_hts_callbackarg *carg, httrackp* opt);
|
||||
static int CDECL httrack_wrapper_checkhtml(t_hts_callbackarg *carg, httrackp *opt, char* html,int len,const char* url_address,const char* url_file);
|
||||
static int CDECL httrack_wrapper_loop(t_hts_callbackarg *carg, httrackp *opt, void* _back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats);
|
||||
static const char* CDECL httrack_wrapper_query(t_hts_callbackarg *carg, httrackp *opt, const char* question);
|
||||
static const char* CDECL httrack_wrapper_query2(t_hts_callbackarg *carg, httrackp *opt, const char* question);
|
||||
static const char* CDECL httrack_wrapper_query3(t_hts_callbackarg *carg, httrackp *opt, const char* question);
|
||||
static int CDECL httrack_wrapper_check(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,int status);
|
||||
static void CDECL httrack_wrapper_pause(t_hts_callbackarg *carg, httrackp *opt, const char* lockfile);
|
||||
static void CDECL httrack_wrapper_filesave(t_hts_callbackarg *carg, httrackp *opt, const char* file);
|
||||
static int CDECL httrack_wrapper_linkdetected(t_hts_callbackarg *carg, httrackp *opt, char* link);
|
||||
static int CDECL httrack_wrapper_xfrstatus(t_hts_callbackarg *carg, httrackp *opt, void* back);
|
||||
static int CDECL httrack_wrapper_preprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file);
|
||||
static int CDECL httrack_wrapper_postprocesshtml(t_hts_callbackarg *carg, httrackp *opt, char** html,int* len,const char* url_address,const char* url_file);
|
||||
static int CDECL httrack_wrapper_check_mime(t_hts_callbackarg *carg, httrackp *opt, const char* adr,const char* fil,const char* mime,int status);
|
||||
static void CDECL httrack_wrapper_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 httrack_wrapper_linkdetected2(t_hts_callbackarg *carg, httrackp *opt, char* link, const char* start_tag);
|
||||
static int CDECL httrack_wrapper_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 httrack_wrapper_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 httrack_wrapper_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);
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
HTTrack library example
|
||||
-----------------------
|
||||
|
||||
Here is an example of how to integrate HTTrack Website Copier into a project
|
||||
to use it as a "core library".
|
||||
|
||||
|
||||
Important Notice:
|
||||
----------------
|
||||
|
||||
These sources are covered by the GNU General Public License (see below)
|
||||
(Projects based on these sources must follow the GPL, too)
|
||||
|
||||
|
||||
Copyright notice:
|
||||
----------------
|
||||
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) Xavier Roche and other contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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.
|
||||
|
||||
========================================================================
|
||||
MAKEFILE PROJECT : libtest Project Overview
|
||||
========================================================================
|
||||
|
||||
AppWizard has created this libtest project for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your libtest project.
|
||||
|
||||
|
||||
libtest.vcproj
|
||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the version of Visual C++ that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
This project allows you to build/clean/rebuild from within Visual Studio by calling the commands you have input
|
||||
in the wizard. The build command can be nmake or any other tool you use.
|
||||
|
||||
This project does not contain any files, so there are none displayed in Solution Explorer.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HTTrack library example
|
||||
-----------------------
|
||||
|
||||
Here is an example of how to integrate HTTrack Website Copier into a project
|
||||
to use it as a "core library".
|
||||
|
||||
|
||||
Important Notice:
|
||||
----------------
|
||||
|
||||
These sources are covered by the GNU General Public License (see below)
|
||||
(Projects based on these sources must follow the GPL, too)
|
||||
|
||||
|
||||
Copyright notice:
|
||||
----------------
|
||||
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) Xavier Roche and other contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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.
|
||||
|
||||
========================================================================
|
||||
MAKEFILE PROJECT : libtest Project Overview
|
||||
========================================================================
|
||||
|
||||
AppWizard has created this libtest project for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your libtest project.
|
||||
|
||||
|
||||
libtest.vcproj
|
||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the version of Visual C++ that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
This project allows you to build/clean/rebuild from within Visual Studio by calling the commands you have input
|
||||
in the wizard. The build command can be nmake or any other tool you use.
|
||||
|
||||
This project does not contain any files, so there are none displayed in Solution Explorer.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user