4static stralloc 
tokens = {0};
 
    5static stralloc comment = {0};
 
    7static stralloc addr = {0};
 
   10static int docomment(stralloc *
out)
 
   16  for (j = i = 0;j < comment.len;++j) {
 
   18    if (ch == 
' ') 
if (!i || (comment.s[i - 1] == 
' ')) 
continue;
 
   21  while (i && (comment.s[i - 1] == 
' ')) --i;
 
   25    if (!stralloc_0(
out)) 
return 0;
 
   26    if (!stralloc_catb(
out,comment.s,i)) 
return 0;
 
   27    if (!stralloc_append(
out,
"(")) 
return 0;
 
   33static int doit(stralloc *
out)
 
   37  if (!stralloc_0(
out)) 
return 0;
 
   39    if (!stralloc_append(
out,
"@")) 
return 0;
 
   40  if (!stralloc_catb(
out,addr.s,addr.len)) 
return 0;
 
   41  if (!stralloc_append(
out,
"+")) 
return 0;
 
   43  if (!docomment(
out)) 
return 0;
 
   50static int addcomment(
char *tok)
 
   54  if (*tok == 
',') 
return 1;
 
   55  if (*tok == 
':') 
return 1;
 
   56  if (*tok == 
';') 
return 1;
 
   57  if (*tok == 
'<') 
return 1;
 
   58  if (*tok == 
'>') 
return 1;
 
   60  if ((*tok == 
'|') || (*tok == 
'(')) ++tok;
 
   64    if (!stralloc_append(&comment,tok + i)) 
return 0;
 
   69static int addaddr(
char *tok)
 
   73  if ((*tok != 
'|') && (*tok != 
'.') && (*tok != 
'@'))
 
   74    return addcomment(tok);
 
   76  if (!state) state = 1;
 
   77  if (*tok == 
'@') state = 2;
 
   79  if (*tok == 
'|') ++tok;
 
   83    if (!stralloc_append(&addr,tok + i)) 
return 0;
 
   96  if (!stralloc_copys(
out,
"")) 
return 0;
 
  100  for (j = 0; j <= 
tokens.len; j++) {
 
  103      if ((ch == 
' ') || (ch == 
'\t') || (ch == 
'<') || (ch == 
'(') || (ch == 
'['))  
continue;
 
  104        if (!stralloc_catb(
out,&ch,1)) 
return 0;
 
  105    if (ch == 
'=') keyvalue = 1;
 
  107      if ((ch == 
' ') || (ch == 
'\t') || (ch == 
'>') || (ch == 
')') || (ch == 
']') || (ch == 
';'))  
break;
 
  108    if (!stralloc_catb(
out,&ch,1)) 
return 0;
 
  112    if (!stralloc_copys(
out,
"")) 
return 0;
 
 
  129  if (!stralloc_copys(
out,
"")) 
return 0;
 
  130  if (!stralloc_copys(&comment,
"")) 
return 0;
 
  131  if (!stralloc_copys(&addr,
"")) 
return 0;
 
  137    while (j--) 
if (!j || !
tokens.s[j - 1]) 
break;
 
  141      if ((ch != 
',') && (ch != 
';') && (ch != 
':') && (ch != 
'>')) {
 
  142        if (!addcomment(
tokens.s + j)) 
return 0;
 
  145      if (!doit(
out)) 
return 0;
 
  152        if (!addcomment(
" ")) 
return 0;
 
  156        if (!doit(
out)) 
return 0;
 
  157        if (!docomment(
out)) 
return 0;
 
  162        if (!addcomment(
" ")) 
return 0;
 
  163        if (!addcomment(
tokens.s + j)) 
return 0;
 
  164        if (!addcomment(
" ")) 
return 0;
 
  169          if (!doit(
out)) 
return 0;
 
  170        if (!addaddr(
tokens.s + j)) 
return 0;
 
  175        if (!doit(
out)) 
return 0;
 
  177        if (!state) state = 1; 
 
  180          if (!addaddr(
tokens.s + j)) 
return 0;
 
  182          while (j--) 
if (!j || !
tokens.s[j - 1]) 
break;
 
  183          if (
tokens.s[j] == 
':') 
break;
 
  184          if (
tokens.s[j] == 
'<') 
break;
 
  189            if (!addcomment(
tokens.s + j)) 
return 0;
 
  191            while (j--) 
if (!j || !
tokens.s[j - 1]) 
break;
 
  192            if (
tokens.s[j] == 
'<') 
break;
 
  201        if (!addaddr(
tokens.s + j)) 
return 0;
 
  207  if (!doit(
out)) 
return 0;
 
  208  if (!docomment(
out)) 
return 0;
 
 
int mess822_token(stralloc *, char *)
int mess822_addrlist(stralloc *out, char *in)
int mess822_keyvalue(stralloc *out, char *in)