+static void
+modify_headers(struct hlist* headers, struct variable** hash)
+{
+ struct hlist* p;
+ struct hlist* last = NULL;
+ struct variable* pv;
+ int i;
+
+ for(p = headers; p; p = p->next){
+ pv = find_var(p->name,NULL,hash);
+ if (pv->modified){
+ pv->modified = 0;
+ free(pv->value);
+ pv->value = xstrdup(p->value); //FIXME: fold it
+ }
+ last = p;
+ }
+
+ /* find new headers */
+ for (i = 0; i < HASHSIZE; i++){
+ for(pv = hash[i]; pv; pv = pv->next){
+ if (isupper(pv->name[0]) && pv->modified){
+ pv->modified = 0;
+ p = xmalloc(sizeof(struct hlist));
+
+ last->next = p; //FIXME
+ p->next = NULL;
+ p->name = xstrdup(pv->name);
+ p->value = xstrdup(pv->value);
+ }
+ }
+ }
+}
+
+static struct hlist*
+copy_headers(struct hlist* orig)
+{
+ struct hlist* new = NULL;
+ struct hlist* po, * pn = NULL;
+
+ for (po = orig; po; po = po->next){
+ if (!pn)
+ pn = xmalloc(sizeof(struct hlist));
+ pn->next = xmalloc(sizeof(struct hlist));
+ pn = pn->next;
+ pn->next = NULL;
+ pn->name = xstrdup(po->name);
+ pn->value = xstrdup(po->value);
+ if (!new)
+ new = pn;
+ }
+
+ return new;
+}
+
+static void
+new_action(char* l, char* r, char* s, struct variable** hash)