mirror of
https://github.com/bobbimanners/emailler.git
synced 2026-04-26 11:25:45 +00:00
Initial work on EMAIL.SYSTEM, the user agent
This commit is contained in:
+4
-2
@@ -45,7 +45,7 @@ TCP =\
|
||||
tweet65 \
|
||||
pop65-slow
|
||||
|
||||
bin: wget65.bin pop65.bin
|
||||
bin: wget65.bin pop65.bin email.bin
|
||||
|
||||
wget65.bin: w5100.c w5100_http.c linenoise.c
|
||||
wget65.bin: IP65LIB = ../ip65/ip65.lib
|
||||
@@ -138,10 +138,12 @@ ip65.dsk: bin
|
||||
# java -jar $(AC) -as $@ tweet65 < tweet65.bin
|
||||
# java -jar $(AC) -p $@ tweet65.system sys < $(CC65)/apple2enh/util/loader.system
|
||||
java -jar $(AC) -as $@ pop65 < pop65.bin
|
||||
java -jar $(AC) -p $@ pop65.system sys < $(CC65)/apple2enh/util/loader.system
|
||||
java -jar $(AC) -p $@ pop65.system sys < $(CC65)/apple2enh/util/loader.system
|
||||
java -jar $(AC) -as $@ wget65 < wget65.bin
|
||||
java -jar $(AC) -p $@ wget65.system sys < $(CC65)/apple2enh/util/loader.system
|
||||
java -jar $(AC) -as $@ telnet65 < telnet65.bin
|
||||
java -jar $(AC) -as $@ email < email.bin
|
||||
java -jar $(AC) -p $@ email.system sys < $(CC65)/apple2enh/util/loader.system
|
||||
java -jar $(AC) -p $@ tzone.txt txt < tzone.txt
|
||||
java -jar $(AC) -p $@ pop65.cfg txt < pop65.cfg
|
||||
|
||||
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// Simple Email User Agent
|
||||
// Bobbi June 2020
|
||||
// Handles INBOX in the format created by POP65
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <conio.h>
|
||||
|
||||
char filename[80];
|
||||
FILE *fp;
|
||||
struct emailhdrs *headers;
|
||||
|
||||
// Configuration params from POP65.CFG
|
||||
char cfg_server[80]; // IP of POP3 server
|
||||
char cfg_user[80]; // Username
|
||||
char cfg_pass[80]; // Password
|
||||
char cfg_spooldir[80]; // ProDOS directory to spool email to
|
||||
char cfg_inboxdir[80]; // ProDOS directory for email inbox
|
||||
|
||||
// Represents the email headers for one message
|
||||
struct emailhdrs {
|
||||
char date[80];
|
||||
char from[80];
|
||||
char to[80];
|
||||
char cc[80];
|
||||
char subject[80];
|
||||
struct emailhdrs *next;
|
||||
};
|
||||
|
||||
/*
|
||||
* Keypress before quit
|
||||
*/
|
||||
void confirm_exit(void)
|
||||
{
|
||||
printf("\nPress any key ");
|
||||
cgetc();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called for all non IP65 errors
|
||||
*/
|
||||
void error_exit()
|
||||
{
|
||||
confirm_exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* Read parms from POP65.CFG
|
||||
*/
|
||||
void readconfigfile(void) {
|
||||
fp = fopen("POP65.CFG", "r");
|
||||
if (!fp) {
|
||||
puts("Can't open config file POP65.CFG");
|
||||
error_exit();
|
||||
}
|
||||
fscanf(fp, "%s", cfg_server);
|
||||
fscanf(fp, "%s", cfg_user);
|
||||
fscanf(fp, "%s", cfg_pass);
|
||||
fscanf(fp, "%s", cfg_spooldir);
|
||||
fscanf(fp, "%s", cfg_inboxdir);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read EMAIL.DB
|
||||
*/
|
||||
void read_email_db(void) {
|
||||
struct emailhdrs *curr = NULL, *prev = NULL;
|
||||
uint16_t l;
|
||||
headers = NULL;
|
||||
sprintf(filename, "%s/EMAIL.DB", cfg_inboxdir);
|
||||
fp = fopen(filename, "rb");
|
||||
if (!fp) {
|
||||
printf("Can't open %s\n", filename);
|
||||
error_exit();
|
||||
}
|
||||
while (1) {
|
||||
curr = (struct emailhdrs*)malloc(sizeof(struct emailhdrs));
|
||||
curr->next = NULL;
|
||||
l = fread(curr, 1, sizeof(struct emailhdrs) - 2, fp);
|
||||
if (l != sizeof(struct emailhdrs) - 2) {
|
||||
free(curr);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
if (!prev)
|
||||
headers = curr;
|
||||
else
|
||||
prev->next = curr;
|
||||
prev = curr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show email summary
|
||||
*/
|
||||
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);
|
||||
h = h->next;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
videomode(VIDEOMODE_80COL);
|
||||
readconfigfile();
|
||||
read_email_db();
|
||||
email_summary();
|
||||
confirm_exit();
|
||||
}
|
||||
|
||||
+2
-1
@@ -431,6 +431,8 @@ void main(void) {
|
||||
uint16_t msg, nummsgs;
|
||||
uint32_t bytes;
|
||||
|
||||
padding[0] = 0; // To shut up warning
|
||||
|
||||
videomode(VIDEOMODE_80COL);
|
||||
printf("\nReading POP65.CFG -");
|
||||
readconfigfile();
|
||||
@@ -519,7 +521,6 @@ void main(void) {
|
||||
printf("Disconnecting\n");
|
||||
w5100_disconnect();
|
||||
|
||||
inbox:
|
||||
printf("Updating INBOX ...\n");
|
||||
update_inbox(nummsgs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user