Hello

I'm using mailutil libs in a small mailrobot.

while developing the mailbox is a simple mailfile.
in productive the mailbox is pop3.

I have written a function to search with a regular expression through
the mailbody and return everything after a separator.

when I use the mailfile I can call the function twice, but when i use
a pop3-account the second call of the function doesn't enter the
while-loop.

so there must be a difference between a memory-based stream and a
file-based...
is this a bug or am I doing something wrong?

<code>
char *mc_get_field_value(data_t *data, regex_t *regexp, char *sep) {
       
  char *value = NULL;
  body_t body;
  stream_t stream;
  char *p;
  char buf[128];
  off_t off = 0;
  size_t rd;

  int regex_ret;
  regmatch_t regmatch[RE_SIZE];

  /* ||| */

  message_get_body(*(data->msg), &body);
  body_get_stream(body, &stream);

  while(value == NULL
        && stream_readline(stream, buf, sizeof(buf), off, &rd) == 0
        && rd != 0) {
    off += rd;

    if ((regex_ret = regexec(regexp, buf, RE_SIZE, regmatch, 0)) == 0) {
      if((p = strstr(buf,sep)) != NULL) {
        value = strdup(p+strlen(sep));
        if((p = strchr(value,'\n')) != NULL)
          *p = '\0';
        break;
      }
    }
  }

  return value;
}
</code>

-- 
Mit freundlichen Grüßen

Simon Walter
NETHINKS GmbH, Technik
Bahnhofstraße 16
36037 Fulda
Tel: +49 661 25000-0
Fax: +49 661 25000-49
eMail: [EMAIL PROTECTED]


_______________________________________________
Bug-mailutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-mailutils

Reply via email to