OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp_config.c versions 1.57 and 1.58
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.57 -> 1.58

--- lmtp2nntp_config.c   2002/02/27 10:22:38     1.57
+++ lmtp2nntp_config.c   2002/02/27 12:17:34     1.58
@@ -1311,13 +1311,37 @@
     /*FIXME
     const char *name;
     size_t len;
-    char *cp;
     */
     var_rc_t rc;
+    char *cp;
+    optionval_t *ov;
 
     log2(ctx, DEBUG, "ctx_lookup variable \"%s\" (%d)", var_ptr, var_len);
     rc = VAR_ERR_UNDEFINED_VARIABLE;
-    if (strncasecmp(var_ptr, "test", var_len) == 0) {
+    if (strncasecmp(var_ptr, "option.", strlen("option.")) == 0) {
+        cp = str_dupex(var_ptr, var_len);
+        if (val_get(ctx->val, cp, &ov) == VAL_OK) {
+            //log3(ctx, DEBUG, "FIXME var_idx=%d, ov->type=%d, ov->ndata=%d", var_idx, ov->type, ov->ndata);
+            if ((var_idx == 0) && (ov->ndata == 1) && (ov->type == OPT_SINGLE)) { /* request first/only single value */
+                *val_ptr = ov->data.s;
+                *val_len = strlen(ov->data.s);
+                *val_size = 0;
+                rc = VAR_OK;
+            }
+            else if ((var_idx == 0) && (ov->ndata == 1) && (ov->type == OPT_FLAG)) { /* request first/only single value */
+                *val_ptr = ov->data.f == TRUE ? "yes" : "no";
+                *val_len = strlen(ov->data.s);
+                *val_size = 0;
+                rc = VAR_OK;
+            }
+            else if ((var_idx < ov->ndata) && (ov->type == OPT_MULTI)) { /* request second+ from multi value */
+                *val_ptr = ov->data.m[var_idx];
+                *val_len = strlen(ov->data.m[var_idx]);
+                *val_size = 0;
+                rc = VAR_OK;
+            }
+        }
+        free(cp);
     }
     else if (strncasecmp(var_ptr, "xyz", var_len) == 0) {
         *val_ptr = "Hello, World!";
@@ -1349,7 +1373,7 @@
     ']',          /* endindex      */ //FIXME
     '#',          /* current_index */ //FIXME
     '\\',         /* escape        */ 
-    "0-9"         /* namechars     */ 
+    "0-9"         /* namechars     */ //FIXME bug in lib_val
 };
 
 static var_rc_t regex_lookup(
@@ -1618,7 +1642,7 @@
                         char *res_ptr;
                         log1(ctx, DEBUG, "expanding regex references in headername '%s'", hrI->header);
                         if ((var_rc = var_expand(hrI->header, strlen(hrI->header), &res_ptr, NULL,
-                                                 regex_lookup, regex_ctx, &regex_lookup_cfg, TRUE)) != VAR_OK) {
+                                                 regex_lookup, regex_ctx, &regex_lookup_cfg, FALSE)) != VAR_OK) {
                             log2(ctx, ERROR, "expansion of '%s' failed: %s", hrI->header, var_strerror(var_rc));
                         }
                         log1(ctx, DEBUG, "expansion result '%s'", res_ptr);
@@ -1636,7 +1660,7 @@
                             char *res_ptr;
                             log1(ctx, DEBUG, "expanding regex references in header value '%s'", hrI->val);
                             if ((var_rc = var_expand(hrI->val, strlen(hrI->val), &res_ptr, NULL,
-                                                     regex_lookup, regex_ctx, &regex_lookup_cfg, TRUE)) != VAR_OK) {
+                                                     regex_lookup, regex_ctx, &regex_lookup_cfg, FALSE)) != VAR_OK) {
                                 log2(ctx, ERROR, "expansion of '%s' failed: %s", hrI->val, var_strerror(var_rc));
                             }
                             log1(ctx, DEBUG, "expansion result '%s'", res_ptr);
@@ -1648,7 +1672,7 @@
                             char *res_ptr;
                             log1(ctx, DEBUG, "expanding variables in header value '%s'", hrI->val);
                             if ((var_rc = var_expand(cp, strlen(cp), &res_ptr, NULL,
-                                                     ctx_lookup, ctx, &ctx_lookup_cfg, TRUE)) != VAR_OK) {
+                                                     ctx_lookup, ctx, &ctx_lookup_cfg, FALSE)) != VAR_OK) {
                                 log2(ctx, ERROR, "expansion of '%s' failed: %s", cp, var_strerror(var_rc));
                             }
                             log1(ctx, DEBUG, "expansion result '%s'", res_ptr);

CVSTrac 2.0.1