message-address.c revision 5ce2084ada06ade9f44fc2914c34658e9a842dc1
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "str.h"
#include "message-tokenize.h"
#include "message-address.h"
static struct message_address *
{
struct message_address *addr;
return addr;
}
struct message_address *
unsigned int max_addresses)
{
static const enum message_token stop_tokens_init[] =
static const enum message_token stop_tokens_group[] =
static const enum message_token stop_tokens_domain[] =
static const enum message_token stop_tokens_domain_group[] =
static const enum message_token stop_tokens_post_addr[] =
{ ',', TOKEN_LAST };
static const enum message_token stop_tokens_post_addr_group[] =
static const enum message_token stop_tokens_addr_route[] =
static const enum message_token stop_tokens_addr_mailbox[] =
static const enum message_token stop_tokens_addr_domain[] =
{ '>', TOKEN_LAST };
struct message_tokenizer *tok;
const enum message_token *stop_tokens;
enum message_token token;
if (size == 0)
return NULL;
first_addr = NULL;
next_addr = &first_addr;
/* 1) name <@route:mailbox@domain>, ...
2) mailbox@domain (name), ...
3) group: name <box@domain>, box2@domain2 (name2), ... ;, ...
ENVELOPE wants groups to be stored like (NIL, NIL, group, NIL),
..., (NIL, NIL, NIL, NIL)
*/
t_push();
if (max_addresses == 0)
max_addresses = (unsigned int)-1;
while (!stop && max_addresses > 0) {
/* continuing previously started name,
separate it from us with space */
} else {
len = 0;
}
/* nothing appeneded, remove the space */
}
switch (token) {
case TOKEN_LAST:
case ',':
case ';':
/* end of address */
}
/* end of group - add end of group marker */
}
if (token == TOKEN_LAST) {
break;
}
str_truncate(mailbox, 0);
str_truncate(domain, 0);
str_truncate(route, 0);
str_truncate(name, 0);
str_truncate(comment, 0);
break;
case '@':
/* domain part comes next */
break;
case '<':
/* route-addr */
been the real name */
str_truncate(mailbox, 0);
str_truncate(domain, 0);
}
/* mailbox */
/* route is given */
/* mailbox comes next */
}
}
/* domain */
}
next_phrase = name;
break;
case ':':
/* beginning of group */
str_truncate(mailbox, 0);
str_truncate(comment, 0);
break;
default:
i_unreached();
break;
}
}
if (ingroup)
t_pop();
return first_addr;
}
{
/* a) mailbox@domain
b) name <@route:mailbox@domain>
c) group: .. ; */
if (first)
else
if (!in_group) {
} else {
/* cut out the ", " */
}
} else {
}
}
}
}
}