diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-01-15 16:47:58 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-01-15 16:47:58 +0000 |
commit | 381ed5f6ff9e6fdf318371a48201ef502a98d36c (patch) | |
tree | 7442a36fbe34efe355b5c5f745f4b32b2af8a9cc /rfc822.c | |
parent | e7016da9d722c75c864c8f50b136c8d18ee4b12b (diff) | |
download | fetchmail-381ed5f6ff9e6fdf318371a48201ef502a98d36c.tar.gz fetchmail-381ed5f6ff9e6fdf318371a48201ef502a98d36c.tar.bz2 fetchmail-381ed5f6ff9e6fdf318371a48201ef502a98d36c.zip |
This should be correct.
svn path=/trunk/; revision=767
Diffstat (limited to 'rfc822.c')
-rw-r--r-- | rfc822.c | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -40,6 +40,13 @@ const char *host; /* server hostname */ printf("state %d: %s", state, mycopy); printf("%*s^\n", from - mycopy + 10, " "); #endif /* TESTMAIN */ + +#define INSERT_HOSTNAME \ + strcpy(buf, "@"); \ + strcat(buf, host); \ + buf += strlen(buf); \ + state = 7; + switch (state) { case 0: /* before header colon */ @@ -71,6 +78,7 @@ const char *host; /* server hostname */ --from; continue; } + break; case 3: /* we're in a quoted human name, copy and ignore */ if (*from == '"') @@ -91,30 +99,26 @@ const char *host; /* server hostname */ state = 7; else if (*from == '>') { - strcpy(buf, "@"); - strcat(buf, host); - buf += strlen(buf); - state = 7; + INSERT_HOSTNAME } - break; case 6: /* not string or comment, could be a bare address */ if (*from == '@') state = 7; + else if (*from == '<') + state = 5; + /* on proper termination with no @, insert hostname */ else if (*from == ',') { - strcpy(buf, "@"); - strcat(buf, host); - buf += strlen(buf); + INSERT_HOSTNAME tokencount = 0; - state = 1; } /* If the address token is not properly terminated, ignore it. */ - else if (*from == ' ' || *from == '\t') + else if (isspace(*from)) { const char *cp; @@ -127,10 +131,7 @@ const char *host; /* server hostname */ continue; if (*cp == '(') { - strcpy(buf, "@"); - strcat(buf, host); - buf += strlen(buf); - state = 1; + INSERT_HOSTNAME } } @@ -140,8 +141,8 @@ const char *host; /* server hostname */ case 7: /* we're done with this address, skip to end */ if (*from == ',') { - tokencount == 0; state = 1; + tokencount == 0; } break; } @@ -149,6 +150,7 @@ const char *host; /* server hostname */ /* all characters from the old buffer get copied to the new one */ *buf++ = *from; } +#undef INSERT_HOSTNAME /* back up and nuke the appended comma sentinel */ *--buf = '\0'; |