Index: ossp-pkg/lmtp2nntp/Makefile.in
RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Makefile.in,v
rcsdiff -q -kk '-r1.46' '-r1.47' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Makefile.in,v' 2>/dev/null
--- Makefile.in 2002/02/14 10:51:50 1.46
+++ Makefile.in 2002/03/13 13:58:39 1.47
@@ -45,8 +45,8 @@
PROG = lmtp2nntp
HDRS = lmtp2nntp_global.h lmtp2nntp_daemon.h lmtp2nntp_lmtp.h lmtp2nntp_nntp.h lmtp2nntp_argz.h lmtp2nntp_shpat.h lmtp2nntp_msg.h lmtp2nntp_option.h lmtp2nntp_config.h lmtp2nntp_exwrap.h
-SRCS = lmtp2nntp_main.c lmtp2nntp_daemon.c lmtp2nntp_lmtp.c lmtp2nntp_nntp.c lmtp2nntp_argz.c lmtp2nntp_shpat.c lmtp2nntp_msg.c lmtp2nntp_option.c lmtp2nntp_config.c lmtp2nntp_exwrap.c lmtp2nntp_version.c
-OBJS = lmtp2nntp_main.o lmtp2nntp_daemon.o lmtp2nntp_lmtp.o lmtp2nntp_nntp.o lmtp2nntp_argz.o lmtp2nntp_shpat.o lmtp2nntp_msg.o lmtp2nntp_option.o lmtp2nntp_config.o lmtp2nntp_exwrap.o lmtp2nntp_version.o
+SRCS = lmtp2nntp_main.c lmtp2nntp_daemon.c lmtp2nntp_lmtp.c lmtp2nntp_nntp.c lmtp2nntp_argz.c lmtp2nntp_shpat.c lmtp2nntp_msg.c lmtp2nntp_option.c lmtp2nntp_config.c lmtp2nntp_exwrap.c lmtp2nntp_version.c lmtp2nntp_l2.c
+OBJS = lmtp2nntp_main.o lmtp2nntp_daemon.o lmtp2nntp_lmtp.o lmtp2nntp_nntp.o lmtp2nntp_argz.o lmtp2nntp_shpat.o lmtp2nntp_msg.o lmtp2nntp_option.o lmtp2nntp_config.o lmtp2nntp_exwrap.o lmtp2nntp_version.o lmtp2nntp_l2.o
SUBDIRS = @SUBDIR_EX@ @SUBDIR_STR@ @SUBDIR_L2@ @SUBDIR_SA@ @SUBDIR_VAR@ @SUBDIR_VAL@ @SUBDIR_POPT@ @SUBDIR_PCRE@
Index: ossp-pkg/lmtp2nntp/fixme.h
RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v
rcsdiff -q -kk '-r1.20' '-r1.21' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v' 2>/dev/null
--- fixme.h 2002/03/04 15:54:28 1.20
+++ fixme.h 2002/03/13 13:58:39 1.21
@@ -126,4 +126,6 @@
void msg_headermatrixteardwn(msg_t *msg);
void headerrewrite(lmtp2nntp_t *ctx);
+#include "l2.h"
+extern l2_handler_t l2_handler_var;
#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.65' '-r1.66' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null
--- lmtp2nntp_config.c 2002/03/06 14:26:33 1.65
+++ lmtp2nntp_config.c 2002/03/13 13:58:39 1.66
@@ -119,7 +119,6 @@
{
ex_t ex;
optionval_t *ov;
- //char *cp;
int rc;
/* create L2 environment */
@@ -148,11 +147,29 @@
CU(ERR_EXECUTION);
}
if (ov->data.s != NULL) {
+ l2_channel_t *ch;
+
+ if (l2_env_handler(ctx->l2_env, &l2_handler_var) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to register \"%s\" handler \n", ctx->progname, l2_handler_var.name);
+ CU(ERR_EXECUTION);
+ }
+ if ((rc = l2_channel_create(&ctx->l2, ctx->l2_env, l2_handler_var.name)) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to create \"%s\" channel\n", ctx->progname, l2_handler_var.name);
+ CU(ERR_EXECUTION);
+ }
+ if ((rc = l2_channel_configure(ctx->l2, "", ctx->config_varctx)) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to configure \"%s\" channel\n", ctx->progname, l2_handler_var.name);
+ CU(ERR_EXECUTION);
+ }
//FIXME this is cut off on command line!? fprintf(stderr, "DEBUG: ov->data.s = \"%s\"\n", ov->data.s);
- if ((rc = l2_spec(&ctx->l2, ctx->l2_env, ov->data.s)) != L2_OK) {
+ if ((rc = l2_spec(&ch, ctx->l2_env, ov->data.s)) != L2_OK) {
fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
CU(ERR_EXECUTION);
}
+ if (l2_channel_link(ctx->l2, L2_LINK_CHILD, ch, NULL) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to link child channel\n", ctx->progname);
+ CU(ERR_EXECUTION);
+ }
if (l2_channel_levels(ctx->l2, L2_LEVEL_ALL, L2_LEVEL_NONE) != L2_OK) { /* FIXME should this globalmask and flushmask be user-configurable? */
fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
CU(ERR_EXECUTION);
Index: ossp-pkg/lmtp2nntp/lmtp2nntp_l2.c
RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_l2.c,v
co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_l2.c,v' | diff -u /dev/null - -L'ossp-pkg/lmtp2nntp/lmtp2nntp_l2.c' 2>/dev/null
--- ossp-pkg/lmtp2nntp/lmtp2nntp_l2.c
+++ - 2024-04-20 03:04:47.544437636 +0200
@@ -0,0 +1,128 @@
+
+/*
+** Copyright (c) 2001-2002 The OSSP Project
+** Copyright (c) 2001-2002 Cable & Wireless Deutschland
+**
+** This file is part of OSSP lmtp2nntp, an LMTP speaking local
+** mailer which forwards mails as Usenet news articles via NNTP.
+** It can be found at http://www.ossp.org/pkg/lmtp2nntp/.
+**
+** 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.0 of the License, or (at your option) 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 file; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+** USA, or contact the OSSP project .
+**
+** lmtp2nntp_l2.c: var logging channel for l2
+*/
+
+#include
+#include
+#include "fixme.h"
+
+/* declare private channel configuration */
+typedef struct {
+ var_t *var;
+} l2_ch_var_t;
+
+/* create channel */
+static l2_result_t hook_create(l2_context_t *ctx, l2_channel_t *ch)
+{
+ l2_ch_var_t *cfg;
+
+ /* allocate private channel configuration */
+ if ((cfg = (l2_ch_var_t *)malloc(sizeof(l2_ch_var_t))) == NULL)
+ return L2_ERR_MEM;
+
+ /* initialize configuration with reasonable defaults */
+ cfg->var = NULL;
+
+ /* link private channel configuration into channel context */
+ ctx->vp = cfg;
+
+ return L2_OK;
+}
+
+/* configure channel */
+static l2_result_t hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
+{
+ l2_ch_var_t *cfg;
+
+ /* parameter checks */
+ if ((cfg = (l2_ch_var_t *)ctx->vp) == NULL)
+ return L2_ERR_ARG;
+
+ /* special parameter parsing */
+ if ((cfg->var = (var_t *)va_arg(ap, void *)) == NULL)
+ return L2_ERR_ARG;
+
+ return L2_OK;
+}
+
+/* write to channel */
+static l2_result_t hook_write(l2_context_t *ctx, l2_channel_t *ch,
+ l2_level_t level, const char *buf, size_t buf_size)
+{
+ l2_ch_var_t *cfg;
+ l2_channel_t *downstream;
+ l2_result_t rv;
+ var_rc_t var_rc;
+ char *buf2 = NULL;
+ size_t buf2_size;
+
+ /* parameter checks */
+ if ((cfg = (l2_ch_var_t *)ctx->vp) == NULL)
+ return L2_ERR_ARG;
+ if (cfg->var == NULL)
+ return L2_ERR_ARG;
+
+ /* expand variables */
+ if ((var_rc = var_expand(cfg->var, buf, buf_size, &buf2, &buf2_size, FALSE)) != VAR_OK) {
+ return L2_ERR_USE;
+ }
+
+ /* push data downstream */
+ downstream = NULL;
+ while ((rv = l2_channel_downstream(ch, &downstream)) == L2_OK)
+ if ((rv = l2_channel_write(downstream, level, buf2, buf2_size)) != L2_OK)
+ break;
+
+ if (buf2 != NULL)
+ free(buf2);
+
+ return rv;
+}
+
+/* destroy channel */
+static l2_result_t hook_destroy(l2_context_t *ctx, l2_channel_t *ch)
+{
+ l2_ch_var_t *cfg = (l2_ch_var_t *)ctx->vp;
+
+ /* destroy channel configuration */
+ free(cfg);
+
+ return L2_OK;
+}
+
+/* exported channel handler structure */
+l2_handler_t l2_handler_var = {
+ "lmtp2nntp-l2var",
+ L2_CHANNEL_FILTER,
+ hook_create,
+ hook_configure,
+ NULL,
+ hook_write,
+ NULL,
+ NULL,
+ hook_destroy
+};
+
Index: ossp-pkg/lmtp2nntp/lmtp2nntp_main.c
RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v
rcsdiff -q -kk '-r1.48' '-r1.49' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v' 2>/dev/null
--- lmtp2nntp_main.c 2002/03/06 14:25:39 1.48
+++ lmtp2nntp_main.c 2002/03/13 13:58:39 1.49
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
/* third party (included) */
#include "lmtp2nntp_argz.h"
@@ -126,6 +127,12 @@
"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,
@@ -136,8 +143,19 @@
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
- log2(ctx, DEBUG, "ctx_lookup variable \"%s\" (%d)", var_ptr, var_len);
rc = VAR_ERR_UNDEFINED_VARIABLE;
if (strncasecmp(var_ptr, "option.", strlen("option.")) == 0) {
cp = str_dupex(var_ptr, var_len);
@@ -194,10 +212,19 @@
}
free(cp);
}
- if (rc == VAR_OK)
- log4(ctx, DEBUG, "ctx_lookup variable \"%s\" (%d) ok: result is \"%s\" (%d)", var_ptr, var_len, *val_ptr, *val_len);
- else
- 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);
+
+#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);
+ }
+ 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);
+ }
+
+ if (logctx != NULL)
+ free(logctx);
+#endif
+
return rc;
}
@@ -325,7 +352,6 @@
exit(ERR_EXECUTION);
}
-
int main(int argc, char **argv)
{
int rc;