--- lmtp2nntp_main.c 2002/04/18 15:38:21 1.54
+++ lmtp2nntp_main.c 2002/05/27 15:09:50 1.55
@@ -376,6 +376,7 @@
if ((ctx = (lmtp2nntp_t *)malloc(sizeof(lmtp2nntp_t))) == NULL)
CU(ERR_EXECUTION);
ctx->ctx.vp = ctx;
+ ctx->prival = NULL;
ctx->val = NULL;
ctx->progname = NULL;
ctx->option_groupmode = GROUPMODE_UNDEF;
@@ -390,6 +391,7 @@
ctx->option_timeout_nntp_connect = 0;
ctx->option_timeout_nntp_read = 0;
ctx->option_timeout_nntp_write = 0;
+ ctx->option_nodename = NULL;
ctx->option_mailfrom = NULL;
ctx->option_restrictheader = NULL;
ctx->option_pidfile = NULL;
@@ -416,17 +418,29 @@
ctx->asGroupargs = 0;
initsession(&ctx->session);
ctx->msg = NULL;
- memset(&ctx->uname, 0, sizeof(struct utsname));
ctx->config_varregex = NULL;
ctx->config_varctx = NULL;
+ ctx->msgcount = 0;
- /* fill in application context */
+ /* private application context */
+ if (val_create(&ctx->prival) != VAL_OK)
+ CU(ERR_EXECUTION);
+
+ /* create printable variables context and mount it into the private application context */
if (val_create(&ctx->val) != VAL_OK)
CU(ERR_EXECUTION);
- if (uname(&ctx->uname) == -1) {
- fprintf(stderr, "%s:Error: uname failed \"%s\"\n", ctx->progname, strerror(errno));
+ if (val_reg(ctx->prival, "printable", VAL_TYPE_VAL, "printable variables", NULL) != VAL_OK)
CU(ERR_EXECUTION);
- }
+ if (val_set(ctx->prival, "printable", ctx->val) != VAL_OK)
+ CU(ERR_EXECUTION);
+
+ /* feed lib_val */
+ if (val_reg(ctx->prival, "msgcount", VAL_TYPE_INT, "number of messages processed so far", (void *)&ctx->msgcount) != VAL_OK)
+ CU(ERR_EXECUTION);
+ if (val_reg(ctx->prival, "nodename", VAL_TYPE_PTR, "nodename configured or uname(3)", (void *)&ctx->option_nodename) != VAL_OK)
+ CU(ERR_EXECUTION);
+
+ /* set progname */
ctx->progname = strdup(argv[0]);
/* establish variable expansion context */
@@ -448,6 +462,7 @@
}
}
+
/* read in the arguments */
{
lmtp2nntp_option_rc_t rv;
@@ -700,6 +715,8 @@
//FIXME if (ctx->azHeaderValuePairs != NULL) free(ctx->azHeaderValuePairs); what about headerrules
if (ctx->option_pidfile != NULL)
free(ctx->option_pidfile);
+ if (ctx->option_nodename != NULL)
+ free(ctx->option_nodename);
if (ctx->progname != NULL)
free(ctx->progname);
if (ctx->azGroupargs != NULL)
@@ -713,6 +730,7 @@
str_parse(NULL, NULL);
if (o != NULL)
(void)option_destroy(o);
+ //FIXME check if anything initialized in the lmtp2nntp_t structure is destroyed here (val, prival ...)
return rc;
}
@@ -900,7 +918,7 @@
"DSN\n" /* RFC1894 */
"PIPELINING\n" /* RFC1854 */
"8BITMIME", /* RFC1652 */
- ctx->uname.nodename,
+ ctx->option_nodename,
ctx->session.lhlo_domain);
res.statuscode = "250";
res.dsncode = NULL; /* DSN not used for greeting */
@@ -1100,7 +1118,8 @@
* RFC1893 3.5 Network and Routing Status X.3.1 Mail system full
*/
logbook(ctx->l2, L2_LEVEL_TRACE, "msg_create");
- if ((ctx->msg = msg_create()) == NULL) {
+ ctx->msgcount++;
+ if ((ctx->msg = msg_create(ctx->prival)) == NULL) {
res.statuscode = "452";
res.dsncode = "4.3.1";
res.statusmsg = "Internal error - memory.";
@@ -1402,7 +1421,8 @@
* RFC1893 2. Status Codes 4.X.X Persistent Transient Failure
* RFC1893 3.5 Network and Routing Status X.3.1 Mail system full
*/
- if ((ctx->msg = msg_create()) == NULL) {
+ ctx->msgcount++;
+ if ((ctx->msg = msg_create(ctx->prival)) == NULL) {
res.statuscode = "452";
res.dsncode = "4.3.1";
res.statusmsg = "Internal error - memory.";
@@ -1419,7 +1439,8 @@
* RFC1893 2. Status Codes 4.X.X Persistent Transient Failure
* RFC1893 3.5 Network and Routing Status X.3.1 Mail system full
*/
- if ((ctx->msg = msg_create()) == NULL) {
+ ctx->msgcount++;
+ if ((ctx->msg = msg_create(ctx->prival)) == NULL) {
res.statuscode = "452";
res.dsncode = "4.3.1";
res.statusmsg = "Internal error - memory.";
|