[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Router memory management...



Hi,
as some may remember, I did a small mod to router to be able to 
dynamically (i.e. script controlled) add a header, to support on the fly 
marking of content (in a spam controlling scheme).

As my big mouth said, that was not a big mod. Router has all the hooks 
in place for doing that. But doing it has not been pain free.

Turns out, the router uses a layered memory allocation control scheme 
that I don't fully understand yet, but yields my allocated memory 
unavailable at the time I want to use it :-(

So I ended up doing a static allocation for the test, but even though it 
has been working for my test setup, the real one has proven being different.

If someone with some time knows how to do it, would he please chime in ?

Here's my current try at the beast (in rfc822.c):

< struct header tagheader;
< char tagline[256];
< token822 tagtoken;
< extern struct headerinfo nullhdr;
<
< /*
<  * append a freeform header line.
<  */
<
< int run_tag(argc, argv)
<       int argc;
<       const char *argv[];
< {
<       char *line;
<       struct header   *h, *nh, *ph;
<       int i, j, n;
<
<       if (argc != 2)
<       {
<               fprintf(stderr, "Usage: %s header\n", argv[0]);
<               return PERR_USAGE;
<       }
<
<       /* file = argv[optind]; */
<       line = (char*)argv[1];
<
<       n = strlen(line);
<       for (i = -1, j = 0; j < n; j++)
<       {
<               if (line[j] == ':')
<               {
<                       i = j;
<                       break;
<               }
<       }
<       if (i < 0)
<       {
<               fprintf(stderr, "Usage: %s header\n", argv[0]);
<               return PERR_USAGE;
<       }
<
<       if (qate == NULL || qate->e_headers == NULL)
<       {
<               fprintf(stderr, "%s: no headers!\n", argv[0]);
<               return PERR_USAGE;
<       }
<
<       for (ph = NULL, h = qate->e_headers; h != NULL; h = nh) {
<               nh = h->h_next;
<               ph = h;
<       }
<
<       /* h = makeHeader(spt_headers,line,i); */
<       h = &tagheader;
<       memset(h, 0, sizeof(*h));
<       h->h_pname = tagline;
<       strncpy(tagline, line, 256);
<       tagline[i] = 0;
<
<       h->h_contents.a = NULL;
<       h->h_descriptor = &nullhdr;
<       h->h_stamp = newHeader;
<       h->h_next = NULL;
<
<
<       ph->h_next = h;
<       h->h_next = NULL;
<       /* h->h_lines = makeToken(line+i+1, n-i-1);*/
<       h->h_lines = &tagtoken;
<       h->h_lines->t_pname = tagline+i+1;
<       h->h_lines->t_len = 0;
<       h->h_lines->t_type = Line;
<       h->h_lines->t_next = 0;
< }


-- 
Carlos G Mendioroz  <tron@huapi.ba.ar>  LW7 EQI  Argentina
-
To unsubscribe from this list: send the line "unsubscribe zmailer" in
the body of a message to majordomo@nic.funet.fi