diff options
Diffstat (limited to 'libtest/callbacks-example-log.c')
-rwxr-xr-x | libtest/callbacks-example-log.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/libtest/callbacks-example-log.c b/libtest/callbacks-example-log.c index 21881b7..d7d1465 100755 --- a/libtest/callbacks-example-log.c +++ b/libtest/callbacks-example-log.c @@ -24,23 +24,24 @@ #include "htsdefines.h" /* external functions */ -EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv); -EXTERNAL_FUNCTION int hts_unplug(httrackp *opt); +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*/ +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; (void) ourDummyArg; /* 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 */ - } + if (!CALLBACKARG_PREV_FUN(carg, check_html) + (CALLBACKARG_PREV_CARG(carg), opt, html, len, url_address, url_file)) { + return 0; /* abort */ + } } /* log */ @@ -50,11 +51,11 @@ static int process_file(t_hts_callbackarg *carg, httrackp *opt, hts_log(opt, "log-wrapper-info", fmt); free(fmt); - return 1; /* success */ + return 1; /* success */ } -static int start_of_mirror(t_hts_callbackarg *carg, httrackp *opt) { - const char *arginfo = (char*) CALLBACKARG_USERDEF(carg); +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"); @@ -62,15 +63,15 @@ static int start_of_mirror(t_hts_callbackarg *carg, httrackp *opt) { /* 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 CALLBACKARG_PREV_FUN(carg, start) (CALLBACKARG_PREV_CARG(carg), opt); } - return 1; /* success */ + 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); +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"); @@ -78,19 +79,20 @@ static int end_of_mirror(t_hts_callbackarg *carg, httrackp *opt) { /* 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 CALLBACKARG_PREV_FUN(carg, end) (CALLBACKARG_PREV_CARG(carg), opt); } - return 1; /* success */ + 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) { +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++; @@ -98,19 +100,19 @@ EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) { 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); + 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 */ + return 1; /* success */ } /* module exit point the function name and prototype MUST match this prototype */ -EXTERNAL_FUNCTION int hts_unplug(httrackp *opt) { +EXTERNAL_FUNCTION int hts_unplug(httrackp * opt) { hts_log(opt, "log-wrapper-info", "* module successfully unplugged"); return 1; } |