Browse Source

Rework date header generation

tags/v0.1.0
Damien Goutte-Gattat 9 years ago
parent
commit
231d32d928
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      src/fmail.c

+ 5
- 5
src/fmail.c View File

@@ -114,19 +114,19 @@ qp_encode_stream(FILE *in, FILE *out)
}
}

static void
make_date_header(string_buffer_t *headers)
static char *
rfc2822_date(void)
{
time_t timestamp;
struct tm *timestruct;
char buffer[32];
const char *rfc2822_format = "%a, %d %b %Y %H:%M:%S %z";
static char buffer[32];

timestamp = time(NULL);
timestruct = localtime(&timestamp);
strftime(buffer, sizeof(buffer), rfc2822_format, timestruct);

sb_addf(headers, "Date: %s\r\n", buffer);
return buffer;
}

static void
@@ -191,7 +191,7 @@ main(int argc, char *argv[])
}
}

make_date_header(headers);
sb_addf(headers, "Date: %s\r\n", rfc2822_date());
read_headers(stdin, headers);
fprintf(stdout, "%s\r\n", sb_get(headers));
qp_encode_stream(stdin, stdout);


Loading…
Cancel
Save