};
#define HDR_LEN 128
+#define TAB 0x09
/*
* Like strncpy() but with terminated result.
int inheader = 1;
int readnewline = 0;
int newmail = 0;
+ int lookahead;
char from_[HDR_LEN] = "";
char from[HDR_LEN] = "";
buf[strlen(buf)-1] = '\0';
if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\r')
buf[strlen(buf)-1] = '\0';
+
+ if (inheader && !feof(f)) {
+ lookahead = fgetc(f);
+ if (lookahead == TAB) {
+ if ((cp = fgets(tmp, sizeof(tmp), f)) != NULL) {
+ strncat(buf, tmp, sizeof(buf)-strlen(buf)-1);
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\r')
+ buf[strlen(buf)-1] = '\0';
+
+ if (strlen(tmp) > 0 && buf[strlen(tmp)-1] == '\n') {
+ /* Read the remainder */
+ while (!feof(f) && fgets(tmp, sizeof(tmp), f) != NULL) {
+ if (strlen(tmp) > 0 && tmp[strlen(tmp)-1] == '\n')
+ break;
+ }
+ }
+ }
+ } else
+ /* Rewind by one character for next read */
+ if (lookahead != EOF)
+ fseek(f, -1, SEEK_CUR);
+ }
} else {
+ /* Read the remainder */
while (!feof(f) && fgets(tmp, sizeof(tmp), f) != NULL) {
if (strlen(tmp) > 0 && tmp[strlen(tmp)-1] == '\n')
break;