Index: ossp-pkg/lmtp2nntp/fixme.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v rcsdiff -q -kk '-r1.21' '-r1.22' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v' 2>/dev/null --- fixme.h 2002/03/13 13:58:39 1.21 +++ fixme.h 2002/03/13 14:41:13 1.22 @@ -128,4 +128,5 @@ #include "l2.h" extern l2_handler_t l2_handler_var; +extern void logbook(l2_channel_t *, l2_level_t, const char *, ...); #endif /* __FIXME_H__ */ Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.66' '-r1.67' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/03/13 13:58:39 1.66 +++ lmtp2nntp_config.c 2002/03/13 14:41:13 1.67 @@ -182,7 +182,7 @@ /* from this point on logging is up and running and fprintf(stderr, ...) * should not be used in the remainder of the program flow. */ - log1(ctx, NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu); + logbook(ctx->l2, L2_LEVEL_NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu); /* --version FLAG */ try { @@ -192,7 +192,7 @@ || (ov->ndata == 1 && ov->data.f > 1) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--version = %d", ov->data.f); + logbook(ctx->l2, L2_LEVEL_TRACE, "--version = %d", ov->data.f); if (ov->data.f == 1) { fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu); @@ -209,11 +209,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--childsmax = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--childsmax = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_childsmax = atoi(ov->data.s)) <= 0) { - log1(ctx, ERROR, "option --childsmax, number (%d) out of range", ctx->option_childsmax); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --childsmax, number (%d) out of range", ctx->option_childsmax); throw(0,0,0); } } @@ -229,7 +229,7 @@ || (ov->ndata == 1 && ov->data.f > 1) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--daemonize = %d", ov->data.f); + logbook(ctx->l2, L2_LEVEL_TRACE, "--daemonize = %d", ov->data.f); ctx->option_daemon = ov->data.f == 1 ? TRUE : FALSE; } @@ -244,7 +244,7 @@ || (ov->ndata == 1 && ov->data.f > 1) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--kill = %d", ov->data.f); + logbook(ctx->l2, L2_LEVEL_TRACE, "--kill = %d", ov->data.f); ctx->option_killflag = ov->data.f == 1 ? TRUE : FALSE; } @@ -258,7 +258,7 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--pidfile = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--pidfile = \"%s\"", ov->data.s); if (ov->ndata == 1) ctx->option_pidfile = ov->data.s; @@ -276,9 +276,9 @@ || (ov->ndata < 0) || (ov->ndata >= 1 && ov->data.m == NULL) ) throw(0,0,0); - log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ov->ndata = %d", ov->ndata); for (i = 0; i < ov->ndata; i++) - log2(ctx, TRACE, "--acl[%d] = \"%s\"", i, (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_TRACE, "--acl[%d] = \"%s\"", i, (ov->data.m)[i]); /* check if only blocking ACLs exist */ somepass = FALSE; @@ -298,7 +298,7 @@ if (ov->ndata >= 1) { for (i = 0; i < ov->ndata; i++) { cp = (ov->data.m)[i]; - log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); + logbook(ctx->l2, L2_LEVEL_DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); if (cp[0] == '!') { ctx->pacl[i].acl = strdup(cp + 1); ctx->pacl[i].not = TRUE; @@ -307,20 +307,20 @@ ctx->pacl[i].acl = strdup(cp); ctx->pacl[i].not = FALSE; } - log2(ctx, DEBUG, "ctx->pacl[%d].not = %s", i, ctx->pacl[i].not == TRUE ? "TRUE" : "FALSE"); - log2(ctx, DEBUG, "ctx->pacl[%d].acl = %s", i, ctx->pacl[i].acl); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->pacl[%d].not = %s", i, ctx->pacl[i].not == TRUE ? "TRUE" : "FALSE"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->pacl[%d].acl = %s", i, ctx->pacl[i].acl); if ((cp = strrchr(ctx->pacl[i].acl, '/')) != NULL) *cp++ = NUL; else cp = "-1"; ctx->pacl[i].prefixlen = atoi(cp); - log2(ctx, DEBUG, "ctx->pacl[%d].prefixlen = %d", i, ctx->pacl[i].prefixlen); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->pacl[%d].prefixlen = %d", i, ctx->pacl[i].prefixlen); if ((rc = sa_addr_create(&(ctx->pacl[i].saa))) != SA_OK) { - log1(ctx, ERROR, "option --acl, create address (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } if ((rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) { - log2(ctx, ERROR, "option --acl, parsing address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc)); throw(0,0,0); } } @@ -334,11 +334,11 @@ ctx->pacl[i].not = FALSE; ctx->pacl[i].prefixlen = 0; if ((rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) { - log1(ctx, ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } if ((rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) { - log2(ctx, ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc)); throw(0,0,0); } i++; @@ -352,11 +352,11 @@ ctx->pacl[i].not = FALSE; ctx->pacl[i].prefixlen = 0; if ((rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) { - log1(ctx, ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } if ((rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) { - log2(ctx, ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc)); throw(0,0,0); } i++; @@ -373,17 +373,17 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--bind = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--bind = \"%s\"", ov->data.s); if (ov->ndata == 1) { /* dash means stdio */ if (strcmp(ov->data.s, "-") != 0) { if ((rc = sa_create(&ctx->saServerbind)) != SA_OK) { - log1(ctx, ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } if ((rc = sa_addr_create(&ctx->saaServerbind)) != SA_OK) { - log1(ctx, ERROR, "option --bind, create address (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, create address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } /* slash means UNIX socket */ @@ -413,27 +413,27 @@ nPerm = ((nPerm << 3) | n); } if (nPerm == -1 || cpPerm[i] != '\0') { - log1(ctx, ERROR, "option --bind, invalid permissions \"%s\"", cpPerm); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, invalid permissions \"%s\"", cpPerm); throw(0,0,0); } } if ((rc = sa_addr_u2a(ctx->saaServerbind, "unix:%s", cpPath)) != SA_OK) { - log2(ctx, ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\"", cpPath, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\"", cpPath, sa_error(rc)); throw(0,0,0); } if ((rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) { - log2(ctx, ERROR, "option --bind, bind (%s) failed with \"%s\"", cpPath, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", cpPath, sa_error(rc)); throw(0,0,0); } if (nPerm != -1) { if (chmod(cpPath, nPerm) == -1) { - log3(ctx, ERROR, "option --bind, chmod (%s, 0%o) failed with \"%s\"", cpPath, nPerm, strerror(errno)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, chmod (%s, 0%o) failed with \"%s\"", cpPath, nPerm, strerror(errno)); throw(0,0,0); } } if (getuid() == 0 && getuid() != ctx->option_uid) { if (chown(cpPath, ctx->option_uid, -1) == -1) { - log3(ctx, ERROR, "option --bind, chown (%s, %d) failed with \"%s\"", cpPath, ctx->option_uid, strerror(errno)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, chown (%s, %d) failed with \"%s\"", cpPath, ctx->option_uid, strerror(errno)); throw(0,0,0); } } @@ -442,17 +442,17 @@ /* otherwise assume INET socket */ else { if ((rc = sa_addr_u2a(ctx->saaServerbind, "inet://%s", ov->data.s)) != SA_OK) { - log2(ctx, ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); throw(0,0,0); } if ((rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) { - log2(ctx, ERROR, "option --bind, bind (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); throw(0,0,0); } } /* for either sockets */ if ((rc = sa_listen(ctx->saServerbind, -1)) != SA_OK) { - log2(ctx, ERROR, "option --bind, listen (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, listen (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); throw(0,0,0); } } @@ -468,17 +468,17 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--client = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--client = \"%s\"", ov->data.s); if (ov->ndata == 1) { if ((rc = sa_addr_create(&ctx->saaClientbind)) != SA_OK) { - log1(ctx, ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } if ((rc = sa_addr_u2a(ctx->saaClientbind, (strchr(ov->data.s, ':') == NULL) ? "inet://%s:0" : "inet://%s", ov->data.s)) != SA_OK) { - log2(ctx, ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); throw(0,0,0); } } @@ -495,29 +495,29 @@ || (ov->ndata < 0) || (ov->ndata >= 1 && ov->data.m == NULL) ) throw(0,0,0); - log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ov->ndata = %d", ov->ndata); for (i = 0; i < ov->ndata; i++) - log2(ctx, TRACE, "--destination[%d] = \"%s\"", i, (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_TRACE, "--destination[%d] = \"%s\"", i, (ov->data.m)[i]); if (ov->ndata >= 1) { if ((ctx->pns = (struct ns *)malloc(ov->ndata * sizeof(struct ns))) == NULL) throw(0,0,0); for (i = 0; i < ov->ndata;) { cp = (ov->data.m)[i]; - log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); + logbook(ctx->l2, L2_LEVEL_DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); if (strrchr(cp, ':') == NULL) cp = str_concat(cp, ":nntp", NULL); //FIXME is this a config var/val? else cp = str_concat(cp, NULL); /* prepare for free() */ if ((rc = sa_addr_create(&ctx->pns[i].saa)) != SA_OK) { - log1(ctx, ERROR, "option --destination, create address (internal) failed with \"%s\"", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, create address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } if ((rc = sa_addr_u2a(ctx->pns[i].saa, "inet://%s", cp)) != SA_OK) { - log2(ctx, ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", cp /*FIXME again, option vs. config */, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", cp /*FIXME again, option vs. config */, sa_error(rc)); throw(0,0,0); } if ((rc = sa_create(&ctx->pns[i].sa)) != SA_OK) { - log2(ctx, ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", cp /*FIXME again, option vs. config */, sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", cp /*FIXME again, option vs. config */, sa_error(rc)); throw(0,0,0); } ctx->pns[i].nntp = NULL; @@ -538,7 +538,7 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--groupmode = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--groupmode = \"%s\"", ov->data.s); if (ov->ndata == 1) { if (strcasecmp(ov->data.s, "arg") == 0) @@ -548,7 +548,7 @@ else if (strcasecmp(ov->data.s, "header") == 0) ctx->option_groupmode = GROUPMODE_HEADER; else { - log1(ctx, ERROR, "option --groupmode, invalid mode (%s)", ov->data.s); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --groupmode, invalid mode (%s)", ov->data.s); throw(0,0,0); } } @@ -572,14 +572,14 @@ || (ov->ndata < 0) || (ov->ndata >= 1 && ov->data.m == NULL) ) throw(0,0,0); - log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ov->ndata = %d", ov->ndata); for (i = 0; i < ov->ndata; i++) - log2(ctx, TRACE, "--headerule[%d] = \"%s\"", i, (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_TRACE, "--headerule[%d] = \"%s\"", i, (ov->data.m)[i]); if (ov->ndata >= 1) { for (i = 0; i < ov->ndata; i++) { cp = (ov->data.m)[i]; - log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); + logbook(ctx->l2, L2_LEVEL_DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); hrNew = (headerrule_t *)mallocex(sizeof(headerrule_t)); hrNew->next = NULL; @@ -593,7 +593,7 @@ /* priority */ cpP = cp; if ((cp = strchr(cp, ':')) == NULL) { - log1(ctx, ERROR, "option --headerrule, priority (%s) terminating colon missing", (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, priority (%s) terminating colon missing", (ov->data.m)[i]); throw(0,0,0); } cp++; @@ -603,7 +603,7 @@ /* regex */ cpP = cp; if ((cp = strchr(cp, ':')) == NULL) { - log1(ctx, ERROR, "option --headerrule, regex (%s) terminating colon missing", (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, regex (%s) terminating colon missing", (ov->data.m)[i]); throw(0,0,0); } cp++; @@ -613,13 +613,13 @@ /* header */ cpP = cp; if ((cp = strchr(cp, ':')) == NULL) { - log1(ctx, ERROR, "option --headerrule, header (%s) terminating colon missing", (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, header (%s) terminating colon missing", (ov->data.m)[i]); throw(0,0,0); } cp++; n = cp - cpP; if (n == 0) { - log1(ctx, ERROR, "option --headerrule, header (%s) missing", (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, header (%s) missing", (ov->data.m)[i]); throw(0,0,0); } hrNew->header = str_dupex(cpP, n); @@ -632,12 +632,12 @@ if (hrNew->regex != NULL) { /* compile regular expression into finite state machine and optimize */ if ((hrNew->pcreRegex = pcre_compile(hrNew->regex, PCRE_CASELESS, &cpError, &iError, NULL)) == NULL) { - log3(ctx, ERROR, "option --headerrule, regex (%s) failed at pos %d with %s", hrNew->regex, iError, cpError); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, regex (%s) failed at pos %d with %s", hrNew->regex, iError, cpError); throw(0,0,0); } hrNew->pcreExtra = pcre_study(hrNew->pcreRegex, 0, &cpError); if (cpError != NULL) { - log1(ctx, ERROR, "option --headerrule, regex optimization failed with %s", cpError); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, regex optimization failed with %s", cpError); throw(0,0,0); } } @@ -662,11 +662,11 @@ var_rc_t rc; if ((rc = var_create(&ctx->config_varregex)) != VAR_OK) { - log2(ctx, ERROR, "option --headerrule, create regex context failed with %s (%d)", var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, create regex context failed with %s (%d)", var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); throw(0,0,0); } if ((rc = var_config(ctx->config_varregex, VAR_CONFIG_SYNTAX, &syntax_regex)) != VAR_OK) { - log2(ctx, ERROR, "option --headerrule, config regex context failed with %s (%d)", var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --headerrule, config regex context failed with %s (%d)", var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); throw(0,0,0); } } @@ -700,7 +700,7 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--mailfrom = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--mailfrom = \"%s\"", ov->data.s); if (ov->ndata == 1) { ctx->option_mailfrom = strdup(ov->data.s); @@ -714,7 +714,7 @@ ctx->option_mailfrom = cp; } if (str_parse("<>", ctx->option_mailfrom) == -1) { - log1(ctx, ERROR, "option --mailfrom, illegal regex (%s)", ctx->option_mailfrom); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --mailfrom, illegal regex (%s)", ctx->option_mailfrom); throw(0,0,0); } } @@ -729,11 +729,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--nodename = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--nodename = \"%s\"", ov->data.s); if (ov->ndata == 1) { if (strlen(ov->data.s) > sizeof(ctx->uname.nodename)-1) { - log1(ctx, ERROR, "option --nodename, name (%s) too long", ov->data.s); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --nodename, name (%s) too long", ov->data.s); throw(0,0,0); } strcpy(ctx->uname.nodename, ov->data.s); @@ -751,7 +751,7 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--operationmode = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--operationmode = \"%s\"", ov->data.s); if (ov->ndata == 1) { cp = strdup(ov->data.s); @@ -762,11 +762,11 @@ else { ctx->option_operationmode = OPERATIONMODE_FAKE; if (strlen(cp) != 9) { - log1(ctx, ERROR, "option --operationmode, invalid length (%s)", cp); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --operationmode, invalid length (%s)", cp); throw(0,0,0); } if (cp[3] != '/') { - log1(ctx, ERROR, "option --operationmode, missing slash (%s)", cp); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --operationmode, missing slash (%s)", cp); throw(0,0,0); } cp[3] = NUL; @@ -777,7 +777,7 @@ || !isdigit((int)ctx->option_operationmodefakestatus[1]) || !isdigit((int)ctx->option_operationmodefakestatus[2]) ) { - log1(ctx, ERROR, "option --operationmode, invalid status code (%s)", cp); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --operationmode, invalid status code (%s)", cp); throw(0,0,0); } if ( (strlen(ctx->option_operationmodefakedsn) != 5) @@ -788,13 +788,13 @@ || !isdigit((int)ctx->option_operationmodefakedsn[4]) || (ctx->option_operationmodefakedsn[0] != ctx->option_operationmodefakestatus[0]) ) { - log1(ctx, ERROR, "option --operationmode, invalid dsn code (%s)", cp); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --operationmode, invalid dsn code (%s)", cp); throw(0,0,0); } } } else { - log0(ctx, ERROR, "option --operationmode, is mandatory but neither given nor preset (internal)"); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --operationmode, is mandatory but neither given nor preset (internal)"); throw(0,0,0); } } @@ -810,7 +810,7 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--restrictheader = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--restrictheader = \"%s\"", ov->data.s); if (ov->ndata == 1) { ctx->option_restrictheader = strdup(ov->data.s); @@ -824,7 +824,7 @@ ctx->option_restrictheader = cp; } if (str_parse("<>", ctx->option_restrictheader) == -1) { - log1(ctx, ERROR, "option --restrictheader, illegal regex (%s)", ctx->option_restrictheader); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --restrictheader, illegal regex (%s)", ctx->option_restrictheader); throw(0,0,0); } } @@ -839,11 +839,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--size = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--size = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_maxmessagesize = atoi(ov->data.s)) <= 0) { - log1(ctx, ERROR, "option --size, number (%d) out of range", ctx->option_maxmessagesize); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --size, number (%d) out of range", ctx->option_maxmessagesize); throw(0,0,0); } } @@ -859,11 +859,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutlmtp= \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutlmtp= \"%s\"", ov->data.s); if (ov->ndata == 1) { if ((i = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutlmtp, number (%d) out of range", i); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutlmtp, number (%d) out of range", i); throw(0,0,0); } ctx->option_timeout_lmtp_accept = i; @@ -881,11 +881,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutlmtpaccept = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutlmtpaccept = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_timeout_lmtp_accept = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutlmtpaccept, number (%d) out of range", ctx->option_timeout_lmtp_accept); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutlmtpaccept, number (%d) out of range", ctx->option_timeout_lmtp_accept); throw(0,0,0); } } @@ -899,11 +899,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutlmtpread = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutlmtpread = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_timeout_lmtp_read = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutlmtpread, number (%d) out of range", ctx->option_timeout_lmtp_read); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutlmtpread, number (%d) out of range", ctx->option_timeout_lmtp_read); throw(0,0,0); } } @@ -917,11 +917,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutlmtpwrite = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutlmtpwrite = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_timeout_lmtp_write = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutlmtpwrite, number (%d) out of range", ctx->option_timeout_lmtp_write); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutlmtpwrite, number (%d) out of range", ctx->option_timeout_lmtp_write); throw(0,0,0); } } @@ -937,11 +937,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutnntp= \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutnntp= \"%s\"", ov->data.s); if (ov->ndata == 1) { if ((i = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutnntp, number (%d) out of range", i); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutnntp, number (%d) out of range", i); throw(0,0,0); } ctx->option_timeout_nntp_connect = i; @@ -959,11 +959,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutnntpconnect = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutnntpconnect = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_timeout_nntp_connect = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutnntpconnect, number (%d) out of range", ctx->option_timeout_nntp_connect); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutnntpconnect, number (%d) out of range", ctx->option_timeout_nntp_connect); throw(0,0,0); } } @@ -977,11 +977,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutnntpread = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutnntpread = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_timeout_nntp_read = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutnntpread, number (%d) out of range", ctx->option_timeout_nntp_read); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutnntpread, number (%d) out of range", ctx->option_timeout_nntp_read); throw(0,0,0); } } @@ -995,11 +995,11 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--timeoutnntpwrite = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--timeoutnntpwrite = \"%s\"", ov->data.s); if (ov->ndata == 1) if ((ctx->option_timeout_nntp_write = atoi(ov->data.s)) < 0) { - log1(ctx, ERROR, "option --timeoutnntpwrite, number (%d) out of range", ctx->option_timeout_nntp_write); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --timeoutnntpwrite, number (%d) out of range", ctx->option_timeout_nntp_write); throw(0,0,0); } } @@ -1015,18 +1015,18 @@ || (ov->ndata == 1 && ov->data.s == NULL) || (ov->ndata > 1) ) throw(0,0,0); - log1(ctx, TRACE, "--user = \"%s\"", ov->data.s); + logbook(ctx->l2, L2_LEVEL_TRACE, "--user = \"%s\"", ov->data.s); if (ov->ndata == 1) { if (isdigit((int)ov->data.s[0])) { if ((sPasswd = getpwuid((uid_t)atoi(ov->data.s))) == NULL) { - log1(ctx, ERROR, "option --user, uid (%s) not found", ov->data.s); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --user, uid (%s) not found", ov->data.s); throw(0,0,0); } } else { if ((sPasswd = getpwnam(ov->data.s)) == NULL) { - log1(ctx, ERROR, "option --user, name (%s) not found", ov->data.s); + logbook(ctx->l2, L2_LEVEL_ERROR, "option --user, name (%s) not found", ov->data.s); throw(0,0,0); } } @@ -1045,14 +1045,14 @@ || (ov->ndata < 0) || (ov->ndata >= 1 && ov->data.m == NULL) ) throw(0,0,0); - log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ov->ndata = %d", ov->ndata); for (i = 0; i < ov->ndata; i++) - log2(ctx, TRACE, "--newsgroup[%d] = \"%s\"", i, (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_TRACE, "--newsgroup[%d] = \"%s\"", i, (ov->data.m)[i]); if (ov->ndata >= 1) { for (i = 0; i < ov->ndata; i++) { cp = (ov->data.m)[i]; - log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); + logbook(ctx->l2, L2_LEVEL_DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); argz_add(&ctx->azGroupargs, &ctx->asGroupargs, cp); } } @@ -1070,14 +1070,14 @@ || (ov->ndata < 0) || (ov->ndata >= 1 && ov->data.m == NULL) ) throw(0,0,0); - log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ov->ndata = %d", ov->ndata); for (i = 0; i < ov->ndata; i++) - log2(ctx, TRACE, "--testfile[%d] = \"%s\"", i, (ov->data.m)[i]); + logbook(ctx->l2, L2_LEVEL_TRACE, "--testfile[%d] = \"%s\"", i, (ov->data.m)[i]); if (ov->ndata >= 1) { for (i = 0; i < ov->ndata; i++) { cp = (ov->data.m)[i]; - log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); + logbook(ctx->l2, L2_LEVEL_DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); { const char *filename = cp; struct stat sb; @@ -1109,17 +1109,17 @@ msg->l2 = ctx->l2; msg->cpMsg = cpBuf; if ((rc = msg_split((msg_t *)msg)) != MSG_OK) { - log1(ctx, ERROR, "Error splitting message: %s", msg_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "Error splitting message: %s", msg_error(rc)); throw(0, 0, "msg_split"); } {//FIXME char *cp; cp = NULL; - log0(msg, DEBUG, "FIXME trace #20"); + logbook(msg->l2, L2_LEVEL_DEBUG, "FIXME trace #20"); while ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) != NULL) { - log1(msg, DEBUG, "header=\"%s\"", cp); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=\"%s\"", cp); } - log0(msg, DEBUG, "FIXME trace #21"); + logbook(msg->l2, L2_LEVEL_DEBUG, "FIXME trace #21"); } msg_headermatrixbuildup((msg_t *)msg); ctx->msg = (msg_t *)msg; @@ -1128,15 +1128,15 @@ {//FIXME char *cp; cp = NULL; - log0(msg, DEBUG, "FIXME trace #30"); + logbook(msg->l2, L2_LEVEL_DEBUG, "FIXME trace #30"); while ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) != NULL) { - log1(msg, DEBUG, "header=\"%s\"", cp); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=\"%s\"", cp); } - log0(msg, DEBUG, "FIXME trace #31"); + logbook(msg->l2, L2_LEVEL_DEBUG, "FIXME trace #31"); } argz_add(&((msg_t *)msg)->azNewsgroups, &((msg_t *)msg)->asNewsgroups, "invalid.tst"); //FIXME if ((rc = msg_join((msg_t *)msg)) != MSG_OK) { - log1(ctx, ERROR, "Error joining message: %s", msg_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "Error joining message: %s", msg_error(rc)); throw(0, 0, "msg_split"); } printf("%s", msg->cpMsg); //FIXME @@ -1246,7 +1246,7 @@ char *cp; int i; - log2(ctx, DEBUG, "rgx_lookup variable \"%s\" (%d)", var_ptr, var_len); + logbook(ctx->l2, L2_LEVEL_DEBUG, "rgx_lookup variable \"%s\" (%d)", var_ptr, var_len); rc = VAR_ERR_UNDEFINED_VARIABLE; i = atoi(var_ptr); /* works with both '}' and '\0' termination */ if (i < ctx->nMatch) { @@ -1256,9 +1256,9 @@ rc = VAR_OK; } if (rc == VAR_OK) - log4(ctx, DEBUG, "rgx_lookup variable \"%s\" (%d) ok: result is \"%s\" (%d)", var_ptr, var_len, *val_ptr, *val_len); + logbook(ctx->l2, L2_LEVEL_DEBUG, "rgx_lookup variable \"%s\" (%d) ok: result is \"%s\" (%d)", var_ptr, var_len, *val_ptr, *val_len); else - log4(ctx, DEBUG, "rgx_lookup variable \"%s\" (%d) failed: %s (%d)", var_ptr, var_len, var_strerror(var, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_DEBUG, "rgx_lookup variable \"%s\" (%d) failed: %s (%d)", var_ptr, var_len, var_strerror(var, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); return rc; } @@ -1294,14 +1294,14 @@ } cp = argz_next(msg->azHeaders, msg->asHeaders, cp); if (hdI->ndata == 0) { - log1(msg, DEBUG, "header=%s, currently empty", hdI->name); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=%s, currently empty", hdI->name); hdI->data.s = strdupex(cp); hdI->ndata = 1; } else if(hdI->ndata == 1) { char *cpOld; cpOld = hdI->data.s; - log1(msg, DEBUG, "header=%s, currently single valued", hdI->name); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=%s, currently single valued", hdI->name); hdI->data.m = (char **)mallocex(3 * sizeof(char *)); hdI->data.m[0] = strdupex(cpOld); //FIXME hdI->data.m[1] = strdupex(cp); @@ -1309,7 +1309,7 @@ hdI->ndata = 2; } else { - log2(msg, DEBUG, "header=%s, currently multi valued %d", hdI->name, hdI->ndata); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=%s, currently multi valued %d", hdI->name, hdI->ndata); hdI->data.m = (char **)reallocex(hdI->data.m, (hdI->ndata + 2) * sizeof(char *)); hdI->data.m[hdI->ndata++] = strdupex(cp); hdI->data.m[hdI->ndata] = NULL; @@ -1337,21 +1337,21 @@ msg->asHeaders = 0; for (hdI = msg->hdFirst; hdI != NULL; hdI = hdI->next) { /* for each matrix header */ - log2(msg, DEBUG, "FIXME trace loop hdI=%.8lx, hI->name=\"%s\"", hdI, hdI->name); + logbook(msg->l2, L2_LEVEL_DEBUG, "FIXME trace loop hdI=%.8lx, hI->name=\"%s\"", hdI, hdI->name); if (hdI->name == NULL || strlen(hdI->name) == 0 || hdI->ndata == 0) continue; if (hdI->ndata == 0) { - log1(msg, DEBUG, "header=%s, no data", hdI->name); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=%s, no data", hdI->name); } else if(hdI->ndata == 1) { /* header data is single valued */ - log2(msg, DEBUG, "header=%s, data=%s", hdI->name, hdI->data.s); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=%s, data=%s", hdI->name, hdI->data.s); argz_add(&msg->azHeaders, &msg->asHeaders, hdI->name); argz_add(&msg->azHeaders, &msg->asHeaders, hdI->data.s); } else { /* header data is multi valued */ int i; for (i = 0; i < hdI->ndata; i++) { - log3(msg, DEBUG, "header=%s[%d], data=%s", hdI->name, i, hdI->data.m[i]); + logbook(msg->l2, L2_LEVEL_DEBUG, "header=%s[%d], data=%s", hdI->name, i, hdI->data.m[i]); argz_add(&msg->azHeaders, &msg->asHeaders, hdI->name); argz_add(&msg->azHeaders, &msg->asHeaders, hdI->data.m[i]); } @@ -1381,17 +1381,17 @@ headerrule_t *hrD; headerdata_t *hdD; - log0(ctx, DEBUG, "FIXME trace ---------- headerrewrite() ----------"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "FIXME trace ---------- headerrewrite() ----------"); for (hrD = ctx->option_firstheaderrule; hrD != NULL; hrD = hrD->next) - log1(ctx, DEBUG, "hrD->header=%s", hrD->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hrD->header=%s", hrD->header); for (hdD = ctx->msg->hdFirst; hdD != NULL; hdD = hdD->next) { if (hdD->ndata == 0) - log1(ctx, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(ctx, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } @@ -1401,7 +1401,7 @@ regex_ctx->l2_env = ctx->l2_env; regex_ctx->l2 = ctx->l2; if ((rc = var_config(ctx->config_varregex, VAR_CONFIG_CB_VALUE, regex_lookup, regex_ctx)) != VAR_OK) { - log2(ctx, ERROR, "configure regex callback failed with %s (%d)", var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "configure regex callback failed with %s (%d)", var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); throw(0,0,0); } for (hrI = ctx->option_firstheaderrule; hrI != NULL; hrI = hrI->next) { /* for each rule */ @@ -1410,22 +1410,22 @@ headerrule_t *hrD; headerdata_t *hdD; - log0(ctx, DEBUG, "FIXME trace ---------- headerrewrite() ---------- MIDDLE"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "FIXME trace ---------- headerrewrite() ---------- MIDDLE"); for (hrD = ctx->option_firstheaderrule; hrD != NULL; hrD = hrD->next) - log1(ctx, DEBUG, "hrD->header=%s", hrD->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hrD->header=%s", hrD->header); for (hdD = ctx->msg->hdFirst; hdD != NULL; hdD = hdD->next) { - //log3(ctx, DEBUG, "hdD=%.8lx, hdD->name=%.8lx, hdD->data.s=%.8lx", (long)hdD, (long)&hdD->name, (long)&hdD->data.s); + //logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD=%.8lx, hdD->name=%.8lx, hdD->data.s=%.8lx", (long)hdD, (long)&hdD->name, (long)&hdD->data.s); if (hdD->ndata == 0) - log1(ctx, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(ctx, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } if (hrI->regex != NULL) { - log1(ctx, DEBUG, "rule has regex %s", hrI->regex); + logbook(ctx->l2, L2_LEVEL_DEBUG, "rule has regex %s", hrI->regex); for (hdI = ctx->msg->hdFirst; hdI != NULL; hdI = hdI->next) { /* for each header */ if (hdI->name == NULL || strlen(hdI->name) == 0 || hdI->ndata == 0) continue; @@ -1433,23 +1433,23 @@ if (regex_ctx->nMatch >= 1) { int i; char *cp; - log1(ctx, DEBUG, "regex matches, %d references", regex_ctx->nMatch); + logbook(ctx->l2, L2_LEVEL_DEBUG, "regex matches, %d references", regex_ctx->nMatch); pcre_get_substring_list(hdI->name, ovec, regex_ctx->nMatch, ®ex_ctx->acpMatch); if (regex_ctx->acpMatch != NULL) for (i = 0; i < regex_ctx->nMatch; i++) - log2(ctx, DEBUG, "regex reference[%d]=\'%s\'", i, regex_ctx->acpMatch[i] == NULL ? "(UNDEFINED)" : regex_ctx->acpMatch[i]); + logbook(ctx->l2, L2_LEVEL_DEBUG, "regex reference[%d]=\'%s\'", i, regex_ctx->acpMatch[i] == NULL ? "(UNDEFINED)" : regex_ctx->acpMatch[i]); hdNew = headercreate(); /* expanding regex references into header name */ { var_rc_t var_rc; char *res_ptr; - log1(ctx, DEBUG, "expanding regex references in headername '%s'", hrI->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expanding regex references in headername '%s'", hrI->header); if ((var_rc = var_expand(ctx->config_varregex, hrI->header, strlen(hrI->header), &res_ptr, NULL, FALSE)) != VAR_OK) { - log3(ctx, ERROR, "expansion of '%s' failed: %s", hrI->header, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "expansion of '%s' failed: %s", hrI->header, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); } - log1(ctx, DEBUG, "expansion result '%s'", res_ptr); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expansion result '%s'", res_ptr); if (strlen(res_ptr) == 0) { - log0(ctx, DEBUG, "marking deleted - emtpy headername"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - emtpy headername"); hdNew->name = NULL; //FIXME rename ->header to ->name /*FIXME clean up data.s and data.m */ hdNew->ndata = 0; @@ -1459,7 +1459,7 @@ } } if (hrI->val == NULL) { - log0(ctx, DEBUG, "marking deleted - empty headervalue before expansion"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - empty headervalue before expansion"); /*FIXME clean up data.s and data.m */ hdNew->ndata = 0; } @@ -1468,24 +1468,24 @@ { var_rc_t var_rc; char *res_ptr; - log1(ctx, DEBUG, "expanding regex references in header value '%s'", hrI->val); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expanding regex references in header value '%s'", hrI->val); if ((var_rc = var_expand(ctx->config_varregex, hrI->val, strlen(hrI->val), &res_ptr, NULL, FALSE)) != VAR_OK) { - log3(ctx, ERROR, "expansion of '%s' failed: %s", hrI->val, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "expansion of '%s' failed: %s", hrI->val, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); } - log1(ctx, DEBUG, "expansion result '%s'", res_ptr); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expansion result '%s'", res_ptr); cp = res_ptr; } /* expanding header and other variables into header value */ if (hrI->val != NULL) { var_rc_t var_rc; char *res_ptr; - log1(ctx, DEBUG, "expanding variables in header value '%s'", hrI->val); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expanding variables in header value '%s'", hrI->val); if ((var_rc = var_expand(ctx->config_varctx, cp, strlen(cp), &res_ptr, NULL, FALSE)) != VAR_OK) { - log3(ctx, ERROR, "expansion of '%s' failed: %s", cp, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "expansion of '%s' failed: %s", cp, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); } - log1(ctx, DEBUG, "expansion result '%s'", res_ptr); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expansion result '%s'", res_ptr); if (strlen(res_ptr) == 0) { - log0(ctx, DEBUG, "marking deleted - empty headervalue after expansion"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - empty headervalue after expansion"); /*FIXME clean up data.s and data.m */ hdNew->ndata = 0; } @@ -1504,11 +1504,11 @@ } } else { - log1(ctx, DEBUG, "rule has no regex but static header %s", hrI->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "rule has no regex but static header %s", hrI->header); hdNew = headercreate(); hdNew->name = strdupex(hrI->header); //FIXME rename ->header to ->name if (hrI->val == NULL) { - log0(ctx, DEBUG, "marking deleted"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted"); /*FIXME clean up data.s and data.m */ hdNew->ndata = 0; } @@ -1517,13 +1517,13 @@ /* expanding header and other variables into header value */ var_rc_t var_rc; char *res_ptr; - log1(ctx, DEBUG, "expanding variables in header value '%s'", hrI->val); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expanding variables in header value '%s'", hrI->val); if ((var_rc = var_expand(ctx->config_varctx, hrI->val, strlen(hrI->val), &res_ptr, NULL, FALSE)) != VAR_OK) { - log3(ctx, ERROR, "expansion of '%s' failed: %s", hrI->val, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_ERROR, "expansion of '%s' failed: %s", hrI->val, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); } - log1(ctx, DEBUG, "expansion result '%s'", res_ptr); + logbook(ctx->l2, L2_LEVEL_DEBUG, "expansion result '%s'", res_ptr); if (strlen(res_ptr) == 0) { - log0(ctx, DEBUG, "marking deleted - empty headervalue after expansion"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - empty headervalue after expansion"); /*FIXME clean up data.s and data.m */ hdNew->ndata = 0; } @@ -1535,20 +1535,20 @@ for (hdI = ctx->msg->hdFirst; hdI != NULL; hdI = hdI->next) { /* for each header */ if (hdI->name == NULL || strlen(hdI->name) == 0) continue; - log2(ctx, DEBUG, "hrI->header=%s, hdI->name=%s", hrI->header, hdI->name); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hrI->header=%s, hdI->name=%s", hrI->header, hdI->name); if (strcasecmp(hrI->header, hdI->name) == 0) break; } if (hdI != NULL) { - log1(ctx, DEBUG, "replacing header %s", hrI->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "replacing header %s", hrI->header); headerreplace(hdI, hdNew); if (hdNew->prev == NULL) { - log0(ctx, DEBUG, "FIXME trace #1"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "FIXME trace #1"); ctx->msg->hdFirst = hdNew; } } else { - log1(ctx, DEBUG, "appending header %s", hrI->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "appending header %s", hrI->header); for (hdI = ctx->msg->hdFirst; hdI->next != NULL; hdI = hdI->next); hdI->next = hdNew; hdNew->prev = hdI; @@ -1561,17 +1561,17 @@ headerrule_t *hrD; headerdata_t *hdD; - log0(ctx, DEBUG, "FIXME trace ---------- headerrewrite() ---------- FINISH"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "FIXME trace ---------- headerrewrite() ---------- FINISH"); for (hrD = ctx->option_firstheaderrule; hrD != NULL; hrD = hrD->next) - log1(ctx, DEBUG, "hrD->header=%s", hrD->header); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hrD->header=%s", hrD->header); for (hdD = ctx->msg->hdFirst; hdD != NULL; hdD = hdD->next) { if (hdD->ndata == 0) - log1(ctx, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(ctx, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } } Index: ossp-pkg/lmtp2nntp/lmtp2nntp_main.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v rcsdiff -q -kk '-r1.49' '-r1.50' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v' 2>/dev/null --- lmtp2nntp_main.c 2002/03/13 13:58:39 1.49 +++ lmtp2nntp_main.c 2002/03/13 14:41:13 1.50 @@ -116,6 +116,23 @@ static void resetsession(struct session *session); int groupmatch(char *, size_t, char *); +void logbook(l2_channel_t *ch, l2_level_t level, const char *fmt, ...) +{ + va_list ap; + l2_channel_t *ch2 = NULL; + + if (strchr(fmt, '$') == NULL) { + if (l2_channel_downstream(ch, &ch2) == L2_OK) + ch = ch2; + else + return; + } + va_start(ap, fmt); + l2_channel_vlog(ch, level, fmt, ap); + va_end(ap); + return; +} + static var_syntax_t syntax_ctx = { '\\', /* escape */ '$', /* varinit */ @@ -127,12 +144,6 @@ "a-zA-Z0-9.-" /* namechars */ }; -#if 0 -typedef struct { - l2_channel_t *l2; -} logctx_t; -#endif - static var_rc_t ctx_lookup( var_t *var, void *_ctx, @@ -143,18 +154,8 @@ var_rc_t rc; char *cp; optionval_t *ov; -#if 0 - logctx_t *logctx = NULL; - if ((logctx = (logctx_t *)malloc(sizeof(logctx_t))) != NULL) { - if (l2_channel_upstream(ctx->l2, &logctx->l2) != L2_OK) { - if (l2_channel_downstream(ctx->l2, &logctx->l2) != L2_OK) { - logctx->l2 = NULL; - } - } - } - if (logctx != NULL && logctx->l2 != NULL) log2(logctx, DEBUG, "ctx_lookup variable \"%s\" (%d)", var_ptr, var_len); -#endif + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx_lookup variable \"%s\" (%d)", var_ptr, var_len); rc = VAR_ERR_UNDEFINED_VARIABLE; if (strncasecmp(var_ptr, "option.", strlen("option.")) == 0) { @@ -213,18 +214,13 @@ free(cp); } -#if 0 if (rc == VAR_OK) { - if (logctx != NULL && logctx->l2 != NULL) log4(ctx, DEBUG, "ctx_lookup variable \"%s\" (%d) ok: result is \"%s\" (%d)", var_ptr, var_len, *val_ptr, *val_len); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx_lookup variable \"%s\" (%d) ok: result is \"%s\" (%d)", var_ptr, var_len, *val_ptr, *val_len); } else { - if (logctx != NULL && logctx->l2 != NULL) log4(ctx, DEBUG, "ctx_lookup variable \"%s\" (%d) failed: %s (%d)", var_ptr, var_len, var_strerror(var, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx_lookup variable \"%s\" (%d) failed: %s (%d)", var_ptr, var_len, var_strerror(var, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); } - if (logctx != NULL) - free(logctx); -#endif - return rc; } @@ -249,10 +245,10 @@ else rc = read(ctx->fdIOi, buf, nbytes); if (rc == -1) - log0(ctx, TRACE, "LMTP read error: %m"); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP read error: %m"); else - log3(ctx, TRACE, "LMTP %5d << \"%{text}D\"", rc, buf, rc); - log1(ctx, DEBUG, "hook_lmtp_read() return, rc=%d", rc); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP %5d << \"%{text}D\"", rc, buf, rc); + logbook(ctx->l2, L2_LEVEL_DEBUG, "hook_lmtp_read() return, rc=%d", rc); return rc; } @@ -263,7 +259,7 @@ size_t n; sa_rc_t rv; - log3(ctx, TRACE, "LMTP %5d >> \"%{text}D\"", nbytes, buf, nbytes); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP %5d >> \"%{text}D\"", nbytes, buf, nbytes); if (ctx->saIO != NULL) { if ((rv = sa_write(ctx->saIO, buf, nbytes, &n)) != SA_OK) rc = -1; @@ -273,7 +269,7 @@ else rc = write(ctx->fdIOo, buf, nbytes); if (rc == -1) - log0(ctx, TRACE, "LMTP write error: %m"); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP write error: %m"); return rc; } @@ -289,9 +285,9 @@ else rc = (ssize_t)n; if (rc == -1) - log0(ctx, TRACE, "NNTP read error: %m"); + logbook(ctx->l2, L2_LEVEL_TRACE, "NNTP read error: %m"); else - log3(ctx, TRACE, "NNTP %5d << \"%{text}D\"", rc, buf, rc); + logbook(ctx->l2, L2_LEVEL_TRACE, "NNTP %5d << \"%{text}D\"", rc, buf, rc); return rc; } @@ -302,13 +298,13 @@ size_t n; sa_rc_t rv; - log3(ctx, TRACE, "NNTP %5d >> \"%{text}D\"", nbytes, buf, nbytes); + logbook(ctx->l2, L2_LEVEL_TRACE, "NNTP %5d >> \"%{text}D\"", nbytes, buf, nbytes); if ((rv = sa_write(ctx->sa, buf, nbytes, &n)) != SA_OK) rc = -1; else rc = (ssize_t)n; if (rc == -1) - log0(ctx, TRACE, "NNTP write error: %m"); + logbook(ctx->l2, L2_LEVEL_TRACE, "NNTP write error: %m"); return rc; } @@ -322,29 +318,29 @@ va_start(ap, sig); if ((ctx = va_arg(ap, lmtp2nntp_t *)) == NULL) exit(ERR_EXECUTION); - log0(ctx, TRACE, "catching and logging signals now"); + logbook(ctx->l2, L2_LEVEL_TRACE, "catching and logging signals now"); va_end(ap); return; } if (ctx != NULL) { switch (sig) { case SIGCHLD: - log1(ctx, NOTICE, "caught signal %d - wait for child", sig); + logbook(ctx->l2, L2_LEVEL_NOTICE, "caught signal %d - wait for child", sig); pid = wait(NULL); ctx->active_childs--; - log2(ctx, NOTICE, "caught signal %d - child [%ld] terminated", sig, (long)pid); + logbook(ctx->l2, L2_LEVEL_NOTICE, "caught signal %d - child [%ld] terminated", sig, (long)pid); return; case SIGUSR1: - log1(ctx, NOTICE, "caught signal %d - flush logging stream", sig); + logbook(ctx->l2, L2_LEVEL_NOTICE, "caught signal %d - flush logging stream", sig); l2_channel_flush(ctx->l2); return; case SIGHUP: case SIGINT: case SIGQUIT: - log1(ctx, NOTICE, "caught signal %d - exit - no more logging", sig); + logbook(ctx->l2, L2_LEVEL_NOTICE, "caught signal %d - exit - no more logging", sig); break; default: - log1(ctx, PANIC, "CAUGHT SIGNAL %d - EXIT - NO MORE LOGGING", sig); + logbook(ctx->l2, L2_LEVEL_PANIC, "CAUGHT SIGNAL %d - EXIT - NO MORE LOGGING", sig); } l2_channel_destroy(ctx->l2); l2_env_destroy(ctx->l2_env); @@ -480,19 +476,19 @@ if ((ctx->option_pidfile != NULL) && ctx->option_killflag) { if ((fd = fopen(ctx->option_pidfile, "r")) == NULL) - log1(ctx, ERROR, "cannot open pidfile \"%s\" for reading %m", ctx->option_pidfile); + logbook(ctx->l2, L2_LEVEL_ERROR, "cannot open pidfile \"%s\" for reading %m", ctx->option_pidfile); else { if (fscanf(fd, "%d\n", &pid) != 1) { fclose(fd); - log1(ctx, ERROR, "cannot extract pid from pidfile \"%s\"", ctx->option_pidfile); + logbook(ctx->l2, L2_LEVEL_ERROR, "cannot extract pid from pidfile \"%s\"", ctx->option_pidfile); } else { fclose(fd); - log1(ctx, TRACE, "going to kill pid[%d]", pid); + logbook(ctx->l2, L2_LEVEL_TRACE, "going to kill pid[%d]", pid); if (kill(pid, SIGHUP) == -1) - log1(ctx, ERROR, "killing pid[%d] failed %m", pid); + logbook(ctx->l2, L2_LEVEL_ERROR, "killing pid[%d] failed %m", pid); if (unlink(ctx->option_pidfile) == -1) - log1(ctx, ERROR, "unlinking pidfile \"%s\" failed %m", ctx->option_pidfile); + logbook(ctx->l2, L2_LEVEL_ERROR, "unlinking pidfile \"%s\" failed %m", ctx->option_pidfile); } } CU(0); @@ -520,7 +516,7 @@ lmtp_io.read = hook_lmtp_read; lmtp_io.write = hook_lmtp_write; if ((lmtp = lmtp_create(&lmtp_io)) == NULL) { - log0(ctx, ERROR, "Unable to initialize LMTP library\n"); + logbook(ctx->l2, L2_LEVEL_ERROR, "Unable to initialize LMTP library\n"); CU(ERR_EXECUTION); } /* RFC0821, 4.5.1. MINIMUM IMPLEMENTATION @@ -553,11 +549,11 @@ pid = getpid(); if (ctx->option_daemon) { daemonize(); - log1(ctx, NOTICE, "daemonized, previous pid[%d]", pid); + logbook(ctx->l2, L2_LEVEL_NOTICE, "daemonized, previous pid[%d]", pid); } if (ctx->option_pidfile != NULL) { if ((fd = fopen(ctx->option_pidfile, "w+")) == NULL) - log1(ctx, ERROR, "cannot open pidfile \"%s\" for writing %m", ctx->option_pidfile); + logbook(ctx->l2, L2_LEVEL_ERROR, "cannot open pidfile \"%s\" for writing %m", ctx->option_pidfile); else { fprintf(fd, "%d\n", getpid()); fclose(fd); @@ -570,15 +566,15 @@ sa_timeout(ctx->saServerbind, SA_TIMEOUT_WRITE, ctx->option_timeout_lmtp_write, 0); while (1) { while (ctx->active_childs >= ctx->option_childsmax) { - log1(ctx, ERROR, "maximum number of childs (%d) reached - waiting (1s)", ctx->option_childsmax); + logbook(ctx->l2, L2_LEVEL_ERROR, "maximum number of childs (%d) reached - waiting (1s)", ctx->option_childsmax); sleep(1); } if ((rc = sa_accept(ctx->saServerbind, &ctx->saaIO, &ctx->saIO)) != SA_OK) { if (rc == SA_ERR_SYS) - log3(ctx, ERROR, "accept failed: %s: (%d) %s", sa_error(rc), errno, strerror(errno)); + logbook(ctx->l2, L2_LEVEL_ERROR, "accept failed: %s: (%d) %s", sa_error(rc), errno, strerror(errno)); else - log1(ctx, ERROR, "accept failed: %s", sa_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "accept failed: %s", sa_error(rc)); sleep(10); continue; } @@ -594,12 +590,12 @@ sa_addr_a2u(ctx->pacl[i].saa, &cpA1); sa_addr_a2u(ctx->saaIO, &cpA2); if (sa_addr_match(ctx->saaIO, ctx->pacl[i].saa, ctx->pacl[i].prefixlen) == SA_OK) { - log4(ctx, TRACE, "positive/inclusive ACL \"%s\" (%s/%d) matches %s: YES (stop comparison)", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); + logbook(ctx->l2, L2_LEVEL_TRACE, "positive/inclusive ACL \"%s\" (%s/%d) matches %s: YES (stop comparison)", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); bOk = TRUE; break; } else - log4(ctx, TRACE, "positive/inclusive ACL \"%s\" (%s/%d) matches %s: NO", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); + logbook(ctx->l2, L2_LEVEL_TRACE, "positive/inclusive ACL \"%s\" (%s/%d) matches %s: NO", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); free(cpA1); free(cpA2); } @@ -612,24 +608,24 @@ sa_addr_a2u(ctx->pacl[i].saa, &cpA1); sa_addr_a2u(ctx->saaIO, &cpA2); if (sa_addr_match(ctx->saaIO, ctx->pacl[i].saa, ctx->pacl[i].prefixlen) == SA_OK) { - log4(ctx, TRACE, "negative/exclusive ACL \"%s\" (not %s/%d) matches %s: YES (stop comparison)", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); + logbook(ctx->l2, L2_LEVEL_TRACE, "negative/exclusive ACL \"%s\" (not %s/%d) matches %s: YES (stop comparison)", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); bOk = FALSE; break; } else { - log4(ctx, TRACE, "negative/exclusive ACL \"%s\" (not %s/%d) matches %s: NO", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); + logbook(ctx->l2, L2_LEVEL_TRACE, "negative/exclusive ACL \"%s\" (not %s/%d) matches %s: NO", ctx->pacl[i].acl, cpA1, ctx->pacl[i].prefixlen, cpA2); } } if (bOk) { char *cpA; sa_addr_a2u(ctx->saaIO, &cpA); - log1(ctx, TRACE, "connection from %s accepted due to ACL", cpA); + logbook(ctx->l2, L2_LEVEL_TRACE, "connection from %s accepted due to ACL", cpA); free(cpA); } else { char *cpA; sa_addr_a2u(ctx->saaIO, &cpA); - log1(ctx, ERROR, "connection from %s refused due to ACL", cpA); + logbook(ctx->l2, L2_LEVEL_ERROR, "connection from %s refused due to ACL", cpA); free(cpA); sa_destroy(ctx->saIO); sa_addr_destroy(ctx->saaIO); @@ -641,17 +637,17 @@ l2_channel_flush(ctx->l2); pid = fork(); if (pid == -1) { - log0(ctx, ERROR, "daemon cannot spawn child %m"); + logbook(ctx->l2, L2_LEVEL_ERROR, "daemon cannot spawn child %m"); continue; } if (pid != 0) { - log1(ctx, INFO, "daemon forked process, new child pid[%d]", pid); + logbook(ctx->l2, L2_LEVEL_INFO, "daemon forked process, new child pid[%d]", pid); ctx->active_childs++; sa_destroy(ctx->saIO); sa_addr_destroy(ctx->saaIO); continue; } - log1(ctx, NOTICE, "startup new child process, parent pid[%d]", getppid()); + logbook(ctx->l2, L2_LEVEL_NOTICE, "startup new child process, parent pid[%d]", getppid()); /* child must close listening socket */ sa_destroy(ctx->saServerbind); @@ -662,7 +658,7 @@ lmtp_io.read = hook_lmtp_read; lmtp_io.write = hook_lmtp_write; if ((lmtp = lmtp_create(&lmtp_io)) == NULL) { - log0(ctx, ERROR, "Unable to initialize LMTP library\n"); + logbook(ctx->l2, L2_LEVEL_ERROR, "Unable to initialize LMTP library\n"); CU(ERR_EXECUTION); } /* RFC0821, 4.5.1. MINIMUM IMPLEMENTATION @@ -698,7 +694,7 @@ /* graceful shutdown */ CUS: - log0(ctx, NOTICE, "graceful shutdown shortly before exit - no more logging"); + logbook(ctx->l2, L2_LEVEL_NOTICE, "graceful shutdown shortly before exit - no more logging"); //l2_channel_destroy(ctx->l2); l2_env_destroy(ctx->l2_env); if (ctx->saServerbind) @@ -772,13 +768,13 @@ int i; nntp_io_t nntp_io; - log1(ctx, INFO, "LMTP service executing LHLO command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing LHLO command < %s", req->msg); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 503 Bad sequence of commands * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.0.0 Other undefined Status */ - log0(ctx, TRACE, "checking for duplicate LHLO"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for duplicate LHLO"); if (ctx->session.lhlo_seen) { res.statuscode = "503"; res.dsncode = "5.0.0"; @@ -790,7 +786,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.0.0 Other undefined Status */ - log0(ctx, TRACE, "checking domain to match either RFC0821 or RFC1035 syntax"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking domain to match either RFC0821 or RFC1035 syntax"); if (! ( helo_rfc0821domain(req->msg, &ctx->session.lhlo_domain) > 0 || helo_rfc1035domain(req->msg, &ctx->session.lhlo_domain) > 0)) { res.statuscode = "501"; @@ -804,7 +800,7 @@ * RFC1893 3.5 Network and Routing Status X.3.5 System incorrectly configured */ if (ctx->option_operationmode != OPERATIONMODE_FAKE) { - log0(ctx, TRACE, "check if at least one NNTP service was successfully configured"); + logbook(ctx->l2, L2_LEVEL_TRACE, "check if at least one NNTP service was successfully configured"); if (ctx->nns == 0) { res.statuscode = "451"; res.dsncode = "4.3.5"; @@ -813,22 +809,22 @@ } } - log0(ctx, TRACE, "try to establish a session to any configured NNTP services"); + logbook(ctx->l2, L2_LEVEL_TRACE, "try to establish a session to any configured NNTP services"); if (ctx->option_operationmode == OPERATIONMODE_FAKE) - log0(ctx, NOTICE, "NNTP running in fake mode, network connections will be executed but result is ignored"); + logbook(ctx->l2, L2_LEVEL_NOTICE, "NNTP running in fake mode, network connections will be executed but result is ignored"); i = 0; do { - log1(ctx, DEBUG, "trying ns[%d]", i); + logbook(ctx->l2, L2_LEVEL_DEBUG, "trying ns[%d]", i); bOk = TRUE; - log1(ctx, TRACE, "try ${option.destination}[%d]", i); //FIXME + logbook(ctx->l2, L2_LEVEL_TRACE, "try ${option.destination}[%d]", i); //FIXME ctx->pns[i].l2 = ctx->l2; if (bOk && (ctx->saaClientbind != NULL)) { - log0(ctx, DEBUG, "bind local socket to ${option.clientbind}"); //FIXME + logbook(ctx->l2, L2_LEVEL_DEBUG, "bind local socket to ${option.clientbind}"); //FIXME if (sa_bind(ctx->pns[i].sa, ctx->saaClientbind) != SA_OK) { bOk = FALSE; - log0(ctx, ERROR, "binding NNTP client to local address ${option.clientbind} failed, %m"); //FIXME + logbook(ctx->l2, L2_LEVEL_ERROR, "binding NNTP client to local address ${option.clientbind} failed, %m"); //FIXME } } @@ -838,39 +834,39 @@ sa_timeout(ctx->pns[i].sa, SA_TIMEOUT_WRITE, ctx->option_timeout_nntp_read, 0); if (bOk) { - log0(ctx, DEBUG, "connect"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "connect"); if (sa_connect(ctx->pns[i].sa, ctx->pns[i].saa) != SA_OK) { bOk = FALSE; - log1(ctx, WARNING, "connect to ${option.destination}[%d] failed, %m", i); //FIXME + logbook(ctx->l2, L2_LEVEL_WARNING, "connect to ${option.destination}[%d] failed, %m", i); //FIXME } } if (bOk) { - log0(ctx, DEBUG, "nntp_create"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "nntp_create"); nntp_io.ctx = &ctx->pns[i]; nntp_io.read = hook_nntp_read; nntp_io.write = hook_nntp_write; if ((ctx->pns[i].nntp = nntp_create(&nntp_io)) == NULL) { bOk = FALSE; - log0(ctx, ERROR, "creation of NNTP context failed"); + logbook(ctx->l2, L2_LEVEL_ERROR, "creation of NNTP context failed"); } } if (bOk) { - log0(ctx, DEBUG, "nntp_init"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "nntp_init"); if ((rc = nntp_init(ctx->pns[i].nntp)) != NNTP_OK) { bOk = FALSE; - log2(ctx, ERROR, "initialization of NNTP context failed, (%d) %s", rc, nntp_error(rc)); + logbook(ctx->l2, L2_LEVEL_ERROR, "initialization of NNTP context failed, (%d) %s", rc, nntp_error(rc)); } } if (bOk) { - log1(ctx, INFO, "NNTP session to ${option.destination}[%d] successfully established", i); //FIXME + logbook(ctx->l2, L2_LEVEL_INFO, "NNTP session to ${option.destination}[%d] successfully established", i); //FIXME i++; } else { - log1(ctx, WARNING, "NNTP session establishment to ${option.destination}[%d] failed", i); //FIXME - log1(ctx, DEBUG, "FIXME-CURRENTLY-NOT removing ns[%d] from list", i); + logbook(ctx->l2, L2_LEVEL_WARNING, "NNTP session establishment to ${option.destination}[%d] failed", i); //FIXME + logbook(ctx->l2, L2_LEVEL_DEBUG, "FIXME-CURRENTLY-NOT removing ns[%d] from list", i); lmtp_gfs_ns(&ctx->pns[i]); /*FIXME #1 this code is a leftover from the static ns array with nsc counter FIXME #2 this code removes the newsservice forever!? What is the scope, what should the scope be - gateway, child process, session, posting lifetime? What is the intention of the user? @@ -883,16 +879,16 @@ } while (i < ctx->nns); if (ctx->option_operationmode == OPERATIONMODE_FAKE) - log1(ctx, NOTICE, "NNTP running in fake mode, network connections successfully established=%d but ignored", ctx->nns); + logbook(ctx->l2, L2_LEVEL_NOTICE, "NNTP running in fake mode, network connections successfully established=%d but ignored", ctx->nns); else { /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 421 Service not available * RFC1893 2. Status Codes 4.X.X Persistent Transient Failure * RFC1893 3.5 Network and Routing Status X.4.1 No answer from host */ - log0(ctx, DEBUG, "check if at least one NNTP session successfully established"); + logbook(ctx->l2, L2_LEVEL_DEBUG, "check if at least one NNTP session successfully established"); if (ctx->nns == 0) { - log0(ctx, ERROR, "no NNTP session established"); + logbook(ctx->l2, L2_LEVEL_ERROR, "no NNTP session established"); res.statuscode = "421"; res.dsncode = "4.4.1"; res.statusmsg = "No NNTP session established."; @@ -942,7 +938,7 @@ { int i; - log0(ctx, TRACE, "LMTP service LHLO command - graceful shutdown"); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP service LHLO command - graceful shutdown"); for (i = 0; i < ctx->nns; i++) lmtp_gfs_ns(&ctx->pns[i]); @@ -1079,13 +1075,13 @@ lmtp_rc_t rc; lmtp_res_t res; - log1(ctx, INFO, "LMTP service executing MAIL command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing MAIL command < %s", req->msg); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 553 Requested action not taken: mailbox name not allowed * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.1.8 Bad sender's system address */ - log0(ctx, TRACE, "checking for previous LHLO"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for previous LHLO"); if (!ctx->session.lhlo_seen) { res.statuscode = "553"; res.dsncode = "5.1.8"; @@ -1097,7 +1093,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.5.0 Other or undefined protocol status */ - log0(ctx, TRACE, "checking for previous MAIL"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for previous MAIL"); if (ctx->msg != NULL) { res.statuscode = "503"; res.dsncode = "5.5.0"; @@ -1109,7 +1105,7 @@ * RFC1893 2. Status Codes 4.X.X Persistent Transient Failure * RFC1893 3.5 Network and Routing Status X.3.1 Mail system full */ - log0(ctx, TRACE, "msg_create"); + logbook(ctx->l2, L2_LEVEL_TRACE, "msg_create"); if ((ctx->msg = msg_create()) == NULL) { res.statuscode = "452"; res.dsncode = "4.3.1"; @@ -1135,7 +1131,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.1.7 Bad sender's mailbox address syntax */ - log0(ctx, TRACE, "checking if sender address is a domain name"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking if sender address is a domain name"); if (str_parse(req->msg, "m/^MAIL From:\\s*<(?:.+@.+)>/i") <= 0) { res.statuscode = "553"; res.dsncode = "5.1.7"; @@ -1146,7 +1142,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.5.4 Invalid command arguments */ - log0(ctx, TRACE, "checking BODY keyword"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking BODY keyword"); if (str_parse(req->msg, "m/^MAIL From:\\s*<(.+@.+)>" "(?:\\s+BODY=(?:7BIT|8BITMIME)\\s*)?$/i", &ctx->msg->mail_from) <= 0) { @@ -1160,9 +1156,9 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.7.1 Delivery not authorized, message refused */ - log0(ctx, TRACE, "checking if sender is allowed"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking if sender is allowed"); if (ctx->option_mailfrom != NULL) { - log2(ctx, TRACE, "\"%s\" matching against \"%s\"", ctx->msg->mail_from, ctx->option_mailfrom); + logbook(ctx->l2, L2_LEVEL_TRACE, "\"%s\" matching against \"%s\"", ctx->msg->mail_from, ctx->option_mailfrom); if (str_parse(ctx->msg->mail_from, ctx->option_mailfrom) <= 0) { res.statuscode = "550"; res.dsncode = "5.7.1"; @@ -1198,13 +1194,13 @@ char *cp; char *group; - log1(ctx, INFO, "LMTP service executing RCPT command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing RCPT command < %s", req->msg); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 503 Bad sequence of commands * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.5.0 Other or undefined protocol status */ - log0(ctx, TRACE, "checking for previous MAIL"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for previous MAIL"); if ((ctx->msg == NULL) || (ctx->msg->mail_from == NULL)) { res.statuscode = "503"; res.dsncode = "5.5.0"; @@ -1216,7 +1212,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.5.2 Syntax error */ - log0(ctx, TRACE, "checking parameter syntax"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking parameter syntax"); if (str_parse(req->msg, "m/^RCPT To:\\s*(.+)$/i", &cp) <= 0) { res.statuscode = "501"; res.dsncode = "5.5.2"; @@ -1228,7 +1224,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.1.1 Bad destination mailbox address */ - log0(ctx, TRACE, "checking for empty parameter"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for empty parameter"); if ((cp == NULL) || (strlen(cp) == 0)) { res.statuscode = "550"; res.dsncode = "5.1.1"; @@ -1246,26 +1242,26 @@ * RFC1893 3.5 Network and Routing Status X.1.1 Bad destination mailbox address * X.7.2 Mailing list expansion prohibited */ - log1(ctx, DEBUG, "ctx->option_groupmode=%d", ctx->option_groupmode); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->option_groupmode=%d", ctx->option_groupmode); if (ctx->option_groupmode == GROUPMODE_ENVELOPE) { - log0(ctx, TRACE, "groupmode=envelope; transform recipient into group"); + logbook(ctx->l2, L2_LEVEL_TRACE, "groupmode=envelope; transform recipient into group"); if (str_parse(cp, "m/^<(.+)?@[^@]+>$/i", &group) <= 0) { res.statuscode = "550"; res.dsncode = "5.1.1"; res.statusmsg = "Recipient did not transform into group."; CU(LMTP_OK); } - log1(ctx, TRACE, "groupmode=envelope; match group %s", group); + logbook(ctx->l2, L2_LEVEL_TRACE, "groupmode=envelope; match group %s", group); if (!groupmatch(ctx->azGroupargs, ctx->asGroupargs, group)) { res.statuscode = "550"; res.dsncode = "5.7.2"; res.statusmsg = "unmatched Group."; CU(LMTP_OK); } - log1(ctx, TRACE, "memorize group %s", group); + logbook(ctx->l2, L2_LEVEL_TRACE, "memorize group %s", group); argz_add(&ctx->msg->azEnvgroups, &ctx->msg->asEnvgroups, group); } - log1(ctx, TRACE, "memorize recipient %s", cp); + logbook(ctx->l2, L2_LEVEL_TRACE, "memorize recipient %s", cp); argz_add(&ctx->msg->azRcpt, &ctx->msg->asRcpt, cp); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 250 Requested mail action okay, completed @@ -1312,13 +1308,13 @@ char *cpRestrictheader; char *cpRestrictvalue; - log1(ctx, INFO, "LMTP service executing DATA command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing DATA command < %s", req->msg); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 503 Bad sequence of commands * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.5.0 Other or undefined protocol status */ - log0(ctx, TRACE, "checking for previous RCPT"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for previous RCPT"); if ((ctx->msg == NULL) || (argz_count(ctx->msg->azRcpt, ctx->msg->asRcpt) == 0)) { res.statuscode = "503"; res.dsncode = "5.5.0"; @@ -1329,20 +1325,20 @@ /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 354 Start mail input; end with . */ - log0(ctx, TRACE, "tell remote to send message now"); + logbook(ctx->l2, L2_LEVEL_TRACE, "tell remote to send message now"); res.statuscode = "354"; res.dsncode = NULL; /* DSN not used for data */ res.statusmsg = "Enter mail, end with \".\" on a line by itself"; lmtp_response(lmtp, &res); - log1(ctx, TRACE, "read message with maximum size to accept = %d", ctx->option_maxmessagesize); + logbook(ctx->l2, L2_LEVEL_TRACE, "read message with maximum size to accept = %d", ctx->option_maxmessagesize); rc = lmtp_readmsg(lmtp, &ctx->msg->cpMsg, ctx->option_maxmessagesize); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 552 Requested mail action aborted: exceeded storage allocation * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.2.3 Message length exceeds administrative limit. */ - log0(ctx, TRACE, "checking for excessive message size"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for excessive message size"); if (rc == LMTP_ERR_OVERFLOW) { str_format(errorstring, sizeof(errorstring), "Message length exceeds administrative limit. %s", lmtp_error(rc)); res.statuscode = "552"; @@ -1359,7 +1355,7 @@ * RFC1893 2. Status Codes 4.X.X Persistent Transient Failure * RFC1893 3.5 Network and Routing Status X.3.2 System not accepting network messages */ - log0(ctx, TRACE, "checking for system error"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for system error"); if (rc == LMTP_ERR_SYSTEM) { str_format(errorstring, sizeof(errorstring), "System error reading message: %s", strerror(errno)); res.statuscode = "451"; @@ -1376,7 +1372,7 @@ * RFC1893 2. Status Codes 4.X.X Persistent Transient Failure * RFC1893 3.5 Network and Routing Status X.3.2 System not accepting network messages */ - log0(ctx, TRACE, "checking for other error"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking for other error"); if(rc != LMTP_OK) { str_format(errorstring, sizeof(errorstring), "Unknown error reading message: %s", lmtp_error(rc)); res.statuscode = "451"; @@ -1393,7 +1389,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.6.5 Conversion Failed */ - log0(ctx, TRACE, "split message"); + logbook(ctx->l2, L2_LEVEL_TRACE, "split message"); if ((rc = msg_split(ctx->msg)) != MSG_OK) { str_format(errorstring, sizeof(errorstring), "Error splitting message: %s", msg_error(rc)); res.statuscode = "554"; @@ -1474,7 +1470,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.7.1 Delivery not authorized, message refused */ - log0(ctx, TRACE, "checking if restricted header causes reject"); + logbook(ctx->l2, L2_LEVEL_TRACE, "checking if restricted header causes reject"); if (ctx->option_restrictheader != NULL) { bOk = FALSE; cp = NULL; @@ -1485,16 +1481,16 @@ cpRestrictvalue = cp; str_format(errorstring, sizeof(errorstring), "%s %s", cpRestrictheader, cpRestrictvalue); if (str_parse(errorstring, ctx->option_restrictheader) <= 0) { - log2(ctx, TRACE, "\"%s\" matching against \"%s\" NO", errorstring, ctx->option_restrictheader); + logbook(ctx->l2, L2_LEVEL_TRACE, "\"%s\" matching against \"%s\" NO", errorstring, ctx->option_restrictheader); } else { - log2(ctx, TRACE, "\"%s\" matching against \"%s\": YES", errorstring, ctx->option_restrictheader); + logbook(ctx->l2, L2_LEVEL_TRACE, "\"%s\" matching against \"%s\": YES", errorstring, ctx->option_restrictheader); bOk = TRUE; break; } } if (bOk) { - log0(ctx, TRACE, "restricted header found"); + logbook(ctx->l2, L2_LEVEL_TRACE, "restricted header found"); rcpt = NULL; while ((rcpt = argz_next(ctx->msg->azRcpt, ctx->msg->asRcpt, rcpt)) != NULL) { res.statuscode = "550"; @@ -1507,7 +1503,7 @@ } /* rewrite headers */ - log0(ctx, TRACE, "appying header rewrite rules"); + logbook(ctx->l2, L2_LEVEL_TRACE, "appying header rewrite rules"); msg_headermatrixbuildup(ctx->msg); headerrewrite(ctx); msg_headermatrixteardwn(ctx->msg); @@ -1516,7 +1512,7 @@ * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.6.5 Conversion Failed */ - log0(ctx, TRACE, "join message"); + logbook(ctx->l2, L2_LEVEL_TRACE, "join message"); if ((rc = msg_join(ctx->msg)) != MSG_OK) { str_format(errorstring, sizeof(errorstring), "Error joining message: %s", msg_error(rc)); res.statuscode = "554"; @@ -1529,7 +1525,7 @@ return LMTP_OK; } - log0(ctx, TRACE, "deliver message"); + logbook(ctx->l2, L2_LEVEL_TRACE, "deliver message"); bSuccess = NNTP_ERR_DELIVERY; /* assume a hard error for the worst case */ for (i = 0; i < ctx->nns; i++) { switch (ctx->option_operationmode) { @@ -1564,15 +1560,15 @@ switch (ctx->option_operationmodefakestatus[0]) { case '5': bSuccess = NNTP_ERR_UNKNOWN; - log2(ctx, NOTICE, "%s %s", errorstring, "failed"); + logbook(ctx->l2, L2_LEVEL_NOTICE, "%s %s", errorstring, "failed"); break; case '4': bSuccess = NNTP_DEFER; - log2(ctx, NOTICE, "%s %s", errorstring, "deferred"); + logbook(ctx->l2, L2_LEVEL_NOTICE, "%s %s", errorstring, "deferred"); break; default: bSuccess = NNTP_OK; - log2(ctx, NOTICE, "%s %s", errorstring, "succeeded"); + logbook(ctx->l2, L2_LEVEL_NOTICE, "%s %s", errorstring, "succeeded"); break; } } else { @@ -1582,11 +1578,11 @@ ctx->msg->cpMsgid, strlen(ctx->msg->cpMsg)); if (bSuccess == NNTP_OK) - log2(ctx, NOTICE, "%s %s", errorstring, "succeeded"); + logbook(ctx->l2, L2_LEVEL_NOTICE, "%s %s", errorstring, "succeeded"); else if(bSuccess == NNTP_DEFER) - log2(ctx, WARNING, "%s %s", errorstring, "deferred"); + logbook(ctx->l2, L2_LEVEL_WARNING, "%s %s", errorstring, "deferred"); else - log2(ctx, ERROR, "%s %s", errorstring, "failed"); + logbook(ctx->l2, L2_LEVEL_ERROR, "%s %s", errorstring, "failed"); } @@ -1601,7 +1597,7 @@ */ rcpt = NULL; while ((rcpt = argz_next(ctx->msg->azRcpt, ctx->msg->asRcpt, rcpt)) != NULL) { - log1(ctx, DEBUG, "ctx->option_operationmode=%d", ctx->option_operationmode); + logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->option_operationmode=%d", ctx->option_operationmode); if (ctx->option_operationmode == OPERATIONMODE_FAKE) { res.statuscode = ctx->option_operationmodefakestatus; res.dsncode = ctx->option_operationmodefakedsn; @@ -1668,7 +1664,7 @@ lmtp_res_t res; lmtp_rc_t rc = LMTP_OK; - log1(ctx, INFO, "LMTP service executing NOOP command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing NOOP command < %s", req->msg); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 250 Requested mail action okay, completed * RFC1893 2. Status Codes 2.X.X Success @@ -1687,7 +1683,7 @@ lmtp_res_t res; lmtp_rc_t rc = LMTP_OK; - log1(ctx, INFO, "LMTP service executing RSET command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing RSET command < %s", req->msg); lmtp_gfs_rset(ctx); @@ -1704,7 +1700,7 @@ static void lmtp_gfs_rset(lmtp2nntp_t *ctx) { - log0(ctx, TRACE, "LMTP service RSET command - graceful shutdown"); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP service RSET command - graceful shutdown"); if (ctx->msg != NULL) { msg_destroy(ctx->msg); @@ -1718,7 +1714,7 @@ lmtp_res_t res; lmtp_rc_t rc = LMTP_EOF; - log1(ctx, INFO, "LMTP service executing QUIT command < %s", req->msg); + logbook(ctx->l2, L2_LEVEL_INFO, "LMTP service executing QUIT command < %s", req->msg); lmtp_gfs_quit(ctx); @@ -1735,7 +1731,7 @@ static void lmtp_gfs_quit(lmtp2nntp_t *ctx) { - log0(ctx, TRACE, "LMTP service QUIT command - graceful shutdown"); + logbook(ctx->l2, L2_LEVEL_TRACE, "LMTP service QUIT command - graceful shutdown"); lmtp_gfs_rset(ctx); resetsession(&ctx->session); Index: ossp-pkg/lmtp2nntp/lmtp2nntp_msg.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_msg.c,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_msg.c,v' 2>/dev/null --- lmtp2nntp_msg.c 2002/02/26 15:56:08 1.3 +++ lmtp2nntp_msg.c 2002/03/13 14:41:13 1.4 @@ -29,6 +29,7 @@ #include "lmtp2nntp_msg.h" #include "lmtp2nntp_argz.h" +#include "fixme.h" //FIMXE logbook only #include "str.h" @@ -136,14 +137,14 @@ * header information. */ - log0(msg, DEBUG, "split message into header and body"); + logbook(msg->l2, L2_LEVEL_DEBUG, "split message into header and body"); if (str_parse(msg->cpMsg, "m/((?:.*?)\\n)\\n(.*)$/s", &cpHeaders, &msg->cpBody) <= 0) return MSG_ERR_SPLITHEADBODY; free(msg->cpMsg); msg->cpMsg = NULL; - log0(msg, DEBUG, "replace envelope From w/o colon by X-F: pseudotag"); + logbook(msg->l2, L2_LEVEL_DEBUG, "replace envelope From w/o colon by X-F: pseudotag"); /* This eliminates the special case of having one header, which is really * an embedded envelope, not ending with a colon while all others do. * After splitting headers into name and value pairs this envelope ist @@ -152,14 +153,14 @@ if (strncasecmp(cpHeaders, "From", 4) == 0) memcpy(cpHeaders, "X-F:", 4); - log0(msg, DEBUG, "unwrap header lines"); + logbook(msg->l2, L2_LEVEL_DEBUG, "unwrap header lines"); /* poor man's s///g simulator as current str library doesn't support global substitution */ while (str_parse(cpHeaders, "s/(.*?)\\n[ \\t]+(.*)/$1 $2/s", &cpRem) > 0) { free(cpHeaders); cpHeaders = cpRem; } - log0(msg, DEBUG, "split header lines into names and values"); + logbook(msg->l2, L2_LEVEL_DEBUG, "split header lines into names and values"); while (str_parse(cpHeaders, "m/^[> \\t]*([\\x21-\\x7e]+?:)[ \\t]*([^\\n]*?)[ \\t]*\\n(.*)/s", &cpName, &cpValue, &cpRem) > 0) { free(cpHeaders); cpHeaders = cpRem; @@ -169,13 +170,13 @@ free(cpValue); } - log0(msg, DEBUG, "check for headers we care about and do whatever neccessary"); + logbook(msg->l2, L2_LEVEL_DEBUG, "check for headers we care about and do whatever neccessary"); msg->cpMsgid = NULL; msg->azNewsgroups = NULL; msg->asNewsgroups = 0; cp = msg->azHeaders; while (cp != NULL) { - log1(msg, DEBUG, "processing header \"%s\"", cp); + logbook(msg->l2, L2_LEVEL_DEBUG, "processing header \"%s\"", cp); if (strcasecmp("X-F:", cp) == 0) { argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */ argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */ @@ -190,7 +191,7 @@ argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */ if ((msg->cpFid == NULL) && (str_parse(cp, "m/\\sid\\s+cpFid) > 0)) - log1(msg, DEBUG, "found foreign-ID \"%s\" for logging", msg->cpFid); + logbook(msg->l2, L2_LEVEL_DEBUG, "found foreign-ID \"%s\" for logging", msg->cpFid); argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */ continue; } @@ -228,22 +229,22 @@ break; } - log0(msg, DEBUG, "checking Message-ID"); + logbook(msg->l2, L2_LEVEL_DEBUG, "checking Message-ID"); if (msg->cpMsgid == NULL) return MSG_ERR_SPLITIDNONE; - log0(msg, DEBUG, "checking Newsgroups"); + logbook(msg->l2, L2_LEVEL_DEBUG, "checking Newsgroups"); if (msg->azNewsgroups != NULL) { argz_stringify(msg->azNewsgroups, msg->asNewsgroups, ','); if (argz_create_sep(msg->azNewsgroups, ',', &msg->azNewsgroups, &msg->asNewsgroups) != 0) return MSG_ERR_MEM; } - log0(msg, DEBUG, "adding mandatory Path: header"); + logbook(msg->l2, L2_LEVEL_DEBUG, "adding mandatory Path: header"); argz_add(&msg->azHeaders, &msg->asHeaders, "Path:"); argz_add(&msg->azHeaders, &msg->asHeaders, "lmtp2nntp!not-for-mail"); - log0(msg, DEBUG, "split complete"); + logbook(msg->l2, L2_LEVEL_DEBUG, "split complete"); return MSG_OK; } @@ -263,7 +264,7 @@ char *azNewheaders; size_t asNewheaders; - log0(msg, DEBUG, "verify Newsgroups"); + logbook(msg->l2, L2_LEVEL_DEBUG, "verify Newsgroups"); if (msg->azNewsgroups == NULL) return MSG_ERR_JOINGROUPNONE; argz_stringify(msg->azNewsgroups, msg->asNewsgroups, ','); @@ -272,7 +273,7 @@ argz_add(&msg->azHeaders, &msg->asHeaders, "Newsgroups:"); argz_add(&msg->azHeaders, &msg->asHeaders, msg->azNewsgroups); - log0(msg, DEBUG, "verify Message-ID"); + logbook(msg->l2, L2_LEVEL_DEBUG, "verify Message-ID"); if (msg->cpMsgid == NULL) return MSG_ERR_JOINIDNONE; if (strlen(msg->cpMsgid) == 0) @@ -280,7 +281,7 @@ argz_add(&msg->azHeaders, &msg->asHeaders, "Message-ID:"); argz_add(&msg->azHeaders, &msg->asHeaders, msg->cpMsgid); - log0(msg, DEBUG, "merge name/value pairs into single string"); + logbook(msg->l2, L2_LEVEL_DEBUG, "merge name/value pairs into single string"); argz_add(&msg->azHeaders, &msg->asHeaders, ""); /* append empty string */ if ((aHeaders = (char **)malloc((argz_count(msg->azHeaders, msg->asHeaders) + 1) * sizeof(char *))) == NULL) return MSG_ERR_MEM; @@ -298,7 +299,7 @@ } free(aHeaders); - log0(msg, DEBUG, "fold headers"); + logbook(msg->l2, L2_LEVEL_DEBUG, "fold headers"); /* A logical line is split into one or more physical '\n'-terminated * lines. The physical line is never longer than WRAPAT characters. This * includes the folded data and the header name + colon + space for the @@ -348,19 +349,19 @@ strcat(cpWrap, cpRem); } argz_add(&azNewheaders, &asNewheaders, cpWrap); - log2(msg, DEBUG, "a folded header \"%{text}D\"", cpWrap, strlen(cpWrap)); + logbook(msg->l2, L2_LEVEL_DEBUG, "a folded header \"%{text}D\"", cpWrap, strlen(cpWrap)); free(cpWrap); } else { argz_add(&azNewheaders, &asNewheaders, cp); - log2(msg, DEBUG, "verbatim header \"%{text}D\"", cp, strlen(cp)); + logbook(msg->l2, L2_LEVEL_DEBUG, "verbatim header \"%{text}D\"", cp, strlen(cp)); } } free(msg->azHeaders); msg->azHeaders = azNewheaders; msg->asHeaders = asNewheaders; - log0(msg, DEBUG, "strigify headers"); + logbook(msg->l2, L2_LEVEL_DEBUG, "strigify headers"); argz_stringify(msg->azHeaders, msg->asHeaders, '\n'); cpHeaders = msg->azHeaders; @@ -368,7 +369,7 @@ * header + CRLF + body + '.' + CRLF + NUL, replacing NL with CRLF * ********************************************************************/ - log0(msg, DEBUG, "assemble header and body"); + logbook(msg->l2, L2_LEVEL_DEBUG, "assemble header and body"); n = 0; /* count size of headers, reserve space for NL to CRLF conversion */ for (i = 0; ((c = cpHeaders[i]) != NUL); i++) { @@ -436,7 +437,7 @@ msg->cpMsg[n++] = '\n'; msg->cpMsg[n] = NUL; - log0(msg, DEBUG, "join complete"); + logbook(msg->l2, L2_LEVEL_DEBUG, "join complete"); return MSG_OK; }