]> mj.ucw.cz Git - umpf.git/blobdiff - int.c
rename to umpf, guess default mailbox
[umpf.git] / int.c
diff --git a/int.c b/int.c
index a9481808cb3b0b09cd888bdf76e0cc8511005cc6..f7fe023b592f5c5538c33d003251a2494e02d86a 100644 (file)
--- a/int.c
+++ b/int.c
@@ -4,7 +4,7 @@
 #include <ctype.h>
 
 #include "cond.tab.h"
-#include "brum.h"
+#include "umpf.h"
 
 #define OVECCOUNT 3
 #define HASHSIZE 103
@@ -42,40 +42,26 @@ get_bucket_number(char* name)
 static struct variable*
 find_var(char* name, char* value, struct list* hash)
 {
-       int n, found = 0;
+       int n;
        struct variable *p;
 
        n = get_bucket_number(name);
-
-       if (isupper(*name)){
-               LIST_FOREACH(p, hash + n)
-                       if (!strcasecmp(p->name,name)){
-                               found = 1;
-                               break;
-                       }
-       } else {
-               LIST_FOREACH(p, hash + n)
-                       if (!strcmp(p->name, name)){
-                               found = 1;
-                               break;
+       int nocase = isupper(*name);
+       LIST_FOREACH(p, hash + n)
+               if (!(nocase ? strcasecmp : strcmp)(p->name,name)){
+                       if (value){
+                               free(p->value);
+                               p->value = value;
+                               p->modified = 1;
                        }
-       }
-
-       if (found && value){
-               free(p->value);
-               p->value = value;
-               p->modified = 1;
-       } else if (found && !value)
-               return p;
-       else {
-               p = xmalloc(sizeof(struct variable));
-               p->name = name; 
-               p->value = (value? value:xstrdup(""));
-               p->modified = 1;
-
-               list_add_last(hash+n, &p->car);
-       }
+                       return p;
+               }
 
+       p = xmalloc(sizeof(struct variable));
+       p->name = xstrdup(name); 
+       p->value = (value? value:xstrdup(""));
+       p->modified = 1;
+       list_add_last(hash+n, &p->car);
        return p;
 }
 
@@ -220,6 +206,8 @@ interp_cond(struct tree* t, struct list* hash)
                                return regex_cmp(left,right);
                        case CC('!','~'):
                                return !regex_cmp(left,right);
+                       default:
+                               die("Brrrchlemst!");
                } //TODO: add numbers
 
        } else {
@@ -238,6 +226,8 @@ interp_cond(struct tree* t, struct list* hash)
                                return (left || right) && !(left && right);
                        case '!':
                                return !left;
+                       default:
+                               die("Brrrchlemst!");
                }
        }
 }
@@ -302,6 +292,9 @@ new_action(char* l, char* r, char* s, struct list* hash)
 
        modify_headers(current_headers, hash);
        a->e.headers = copy_headers(current_headers);
+       a->e.body_len = current_body->body_len; 
+       a->e.body = xmalloc(a->e.body_len);
+       memcpy(a->e.body, current_body->body, a->e.body_len);
        a->l = l;
        a->r = r;
        a->s = s;
@@ -395,3 +388,9 @@ save_current_headers(struct list* hash)
        }
 
 }
+
+void
+get_default_mailbox(char* mb)
+{
+       default_mailbox = mb;
+}