--- lmtp2nntp_config.c 2002/03/13 16:22:09 1.69
+++ lmtp2nntp_config.c 2002/04/18 13:31:27 1.70
@@ -1263,6 +1263,48 @@
return rc;
}
+static var_rc_t operate_cb(
+ var_t *var, void *ctx,
+ const char *op_ptr, size_t op_len,
+ const char *arg_ptr, size_t arg_len,
+ const char *val_ptr, size_t val_len,
+ char **out_ptr, size_t *out_len, size_t *out_size)
+{
+ int i;
+
+ if (val_ptr == NULL) {
+ *out_ptr = "";
+ *out_len = 0;
+ *out_size = 0;
+ return VAR_OK;
+ }
+ if (op_len == 6 && strncmp(op_ptr, "return", 6) == 0) {
+ *out_ptr = malloc(arg_len);
+ *out_len = arg_len;
+ *out_size = arg_len;
+ memcpy(*out_ptr, arg_ptr, arg_len);
+ return VAR_OK;
+ }
+ else if (op_len == 5 && strncmp(op_ptr, "upper", 5) == 0) {
+ *out_ptr = malloc(val_len);
+ *out_len = val_len;
+ *out_size = val_len;
+ for (i = 0; i < val_len; i++)
+ (*out_ptr)[i] = (char)toupper((int)(val_ptr[i]));
+ return VAR_OK;
+ }
+ else if (op_len == 5 && strncmp(op_ptr, "lower", 5) == 0) {
+ *out_ptr = malloc(val_len);
+ *out_len = val_len;
+ *out_size = val_len;
+ for (i = 0; i < val_len; i++)
+ (*out_ptr)[i] = (char)tolower((int)(val_ptr[i]));
+ return VAR_OK;
+ }
+ else
+ return VAR_ERR_UNDEFINED_OPERATION;
+}
+
void msg_headermatrixbuildup(msg_t *msg)
{
ex_t ex;
@@ -1405,6 +1447,10 @@
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);
}
+ if ((rc = var_config(ctx->config_varregex, VAR_CONFIG_CB_OPERATION, operate_cb, NULL)) != VAR_OK) {
+ logbook(ctx->l2, L2_LEVEL_ERROR, "configure operate 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 */
{ //FIXME debug code block
int i;
@@ -1476,7 +1522,7 @@
logbook(ctx->l2, L2_LEVEL_DEBUG, "expansion result '%s'", res_ptr);
cp = res_ptr;
}
- /* expanding header and other variables into header value */
+ /* expanding variables into header value */
if (hrI->val != NULL) {
var_rc_t var_rc;
char *res_ptr;
@@ -1515,7 +1561,7 @@
}
else {
/*FIXME clean up data.m */
- /* expanding header and other variables into header value */
+ /* expanding variables into header value */
var_rc_t var_rc;
char *res_ptr;
logbook(ctx->l2, L2_LEVEL_DEBUG, "expanding variables in header value '%s'", hrI->val);
|