mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-10-03 19:55:02 +00:00
Further improvements to pop65.c and email.c user interface
This commit is contained in:
parent
3183a67ce1
commit
9cee699f99
20
apps/email.c
20
apps/email.c
@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <conio.h>
|
||||
#include <string.h>
|
||||
|
||||
char filename[80];
|
||||
FILE *fp;
|
||||
@ -95,6 +96,17 @@ void read_email_db(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a header field from char postion start to end,
|
||||
* padding with spaces as needed
|
||||
*/
|
||||
void printfield(char *s, uint8_t start, uint8_t end) {
|
||||
uint8_t i;
|
||||
uint8_t l = strlen(s);
|
||||
for (i = start; i < end; i++)
|
||||
putchar(i < l ? s[i] : ' ');
|
||||
}
|
||||
|
||||
/*
|
||||
* Show email summary
|
||||
*/
|
||||
@ -102,7 +114,13 @@ void email_summary(void) {
|
||||
uint16_t i = 1;
|
||||
struct emailhdrs *h = headers;
|
||||
while (h) {
|
||||
printf("**%d %s %s %s", i++, h->date, h->from, h->subject);
|
||||
printf("%02d|", i++);
|
||||
printfield(h->date, 0, 16);
|
||||
putchar('|');
|
||||
printfield(h->from, 0, 20);
|
||||
putchar('|');
|
||||
printfield(h->subject, 0, 39);
|
||||
//putchar('\r');
|
||||
h = h->next;
|
||||
}
|
||||
}
|
||||
|
23
apps/pop65.c
23
apps/pop65.c
@ -365,6 +365,19 @@ void update_email_db(struct emailhdrs *h) {
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy one header from source->dest, removing '\r' from end
|
||||
*/
|
||||
void copyheader(char *dest, char *source, uint16_t len) {
|
||||
uint16_t i;
|
||||
memset(dest, ' ', len);
|
||||
for (i = 0; i < len; ++i) {
|
||||
if ((*source == '\0') || (*source == '\r'))
|
||||
return;
|
||||
*dest++ = *source++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Update INBOX
|
||||
* Copy messages from spool dir to inbox and find headers of interest
|
||||
@ -395,23 +408,23 @@ void update_inbox(uint16_t nummsgs) {
|
||||
while (get_line(fp)) {
|
||||
if (headers) {
|
||||
if (!strncmp(linebuf, "Date: ", 6)) {
|
||||
strncpy(hdrs.date, linebuf + 6, 79);
|
||||
copyheader(hdrs.date, linebuf + 6, 79);
|
||||
hdrs.date[79] = '\0';
|
||||
}
|
||||
if (!strncmp(linebuf, "From: ", 6)) {
|
||||
strncpy(hdrs.from, linebuf + 6, 79);
|
||||
copyheader(hdrs.from, linebuf + 6, 79);
|
||||
hdrs.from[79] = '\0';
|
||||
}
|
||||
if (!strncmp(linebuf, "To: ", 4)) {
|
||||
strncpy(hdrs.to, linebuf + 4, 79);
|
||||
copyheader(hdrs.to, linebuf + 4, 79);
|
||||
hdrs.to[79] = '\0';
|
||||
}
|
||||
if (!strncmp(linebuf, "Cc: ", 4)) {
|
||||
strncpy(hdrs.cc, linebuf + 4, 79);
|
||||
copyheader(hdrs.cc, linebuf + 4, 79);
|
||||
hdrs.cc[79] = '\0';
|
||||
}
|
||||
if (!strncmp(linebuf, "Subject: ", 9)) {
|
||||
strncpy(hdrs.subject, linebuf + 9, 79);
|
||||
copyheader(hdrs.subject, linebuf + 9, 79);
|
||||
hdrs.subject[79] = '\0';
|
||||
}
|
||||
if (linebuf[0] == '\r')
|
||||
|
Loading…
Reference in New Issue
Block a user