--- lmtp2nntp_main.c 2002/02/28 12:57:55 1.42
+++ lmtp2nntp_main.c 2002/02/28 14:02:26 1.43
@@ -222,11 +222,39 @@
}
free(cp);
}
- else if (strncasecmp(var_ptr, "xyz", var_len) == 0) {
- *val_ptr = "Hello, World!";
- *val_len = strlen("Hello, World!");
- *val_size = 0;
- rc = VAR_OK;
+ else if ( (strncasecmp(var_ptr, "msg.header.", strlen("msg.header.")) == 0)
+ && (ctx->msg != NULL)
+ ) {
+ headerdata_t *hdI;
+ int n;
+ cp = str_dupex(var_ptr + strlen("msg.header."), var_len - strlen("msg.header.") + 1);
+ n = strlen(cp);
+ cp[n]= ':';
+ cp[n + 1] = NUL;
+ log2(ctx, DEBUG, "FIXME var_idx=%d, cp=%s", var_idx, cp);
+ for (hdI = ctx->msg->hdFirst; hdI != NULL; hdI = hdI->next) { /* for each header */
+ log1(ctx, DEBUG, "FIXME hdI->name=%s", hdI->name);
+ if (hdI->name == NULL || strlen(hdI->name) == 0)
+ continue; //FIXME header w/o name cannot happen normally
+ if (strcmp(cp, hdI->name) == 0)
+ break;
+ }
+ if (hdI != NULL) {
+ log1(ctx, DEBUG, "FIXME hdI->ndata=%d", hdI->ndata);
+ if ((var_idx == 0) && (hdI->ndata == 1)) { /* request first/only single value */
+ *val_ptr = hdI->data.s;
+ *val_len = strlen(hdI->data.s);
+ *val_size = 0;
+ rc = VAR_OK;
+ }
+ else if (var_idx < hdI->ndata) { /* request from multi value */
+ *val_ptr = hdI->data.m[var_idx];
+ *val_len = strlen(hdI->data.m[var_idx]);
+ *val_size = 0;
+ rc = VAR_OK;
+ }
+ }
+ 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);
|