Skip to content

Commit

Permalink
Rename Mail to Email
Browse files Browse the repository at this point in the history
  • Loading branch information
docelic committed Jun 28, 2020
1 parent 3b2d6fb commit b9231eb
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 53 deletions.
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ACLOCAL_AMFLAGS = -I m4

LIB = @URWEB_LIB@/ur/mail
LIB = @URWEB_LIB@/ur/email

lib_LTLIBRARIES = liburweb_mail.la
lib_LTLIBRARIES = liburweb_email.la

liburweb_mail_la_SOURCES = mail.c
liburweb_email_la_SOURCES = email.c

AM_CPPFLAGS = -I@URWEB_INC@
AM_CFLAGS = -Wimplicit -Wall -Werror
Expand Down
40 changes: 20 additions & 20 deletions mail.c → email.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct headers {
uw_Basis_string from, to, cc, bcc, subject, user_agent;
};

typedef struct headers *uw_Mail_headers;
typedef struct headers *uw_Email_headers;

static uw_Basis_string copy_string(uw_Basis_string s) {
if (s == NULL)
Expand All @@ -24,8 +24,8 @@ static void free_string(uw_Basis_string s) {
free(s);
}

static uw_Mail_headers copy_headers(uw_Mail_headers h) {
uw_Mail_headers h2 = malloc(sizeof(struct headers));
static uw_Email_headers copy_headers(uw_Email_headers h) {
uw_Email_headers h2 = malloc(sizeof(struct headers));
h2->from = copy_string(h->from);
h2->to = copy_string(h->to);
h2->cc = copy_string(h->cc);
Expand All @@ -35,7 +35,7 @@ static uw_Mail_headers copy_headers(uw_Mail_headers h) {
return h2;
}

static void free_headers(uw_Mail_headers h) {
static void free_headers(uw_Email_headers h) {
free_string(h->from);
free_string(h->to);
free_string(h->cc);
Expand All @@ -45,7 +45,7 @@ static void free_headers(uw_Mail_headers h) {
free(h);
}

uw_Mail_headers uw_Mail_empty = NULL;
uw_Email_headers uw_Email_empty = NULL;

static void header(uw_context ctx, uw_Basis_string s) {
if (strlen(s) > 100)
Expand All @@ -63,8 +63,8 @@ static void address(uw_context ctx, uw_Basis_string s) {
uw_error(ctx, FATAL, "E-mail address contains comma");
}

uw_Mail_headers uw_Mail_from(uw_context ctx, uw_Basis_string s, uw_Mail_headers h) {
uw_Mail_headers h2 = uw_malloc(ctx, sizeof(struct headers));
uw_Email_headers uw_Email_from(uw_context ctx, uw_Basis_string s, uw_Email_headers h) {
uw_Email_headers h2 = uw_malloc(ctx, sizeof(struct headers));

if (h)
*h2 = *h;
Expand All @@ -80,8 +80,8 @@ uw_Mail_headers uw_Mail_from(uw_context ctx, uw_Basis_string s, uw_Mail_headers
return h2;
}

uw_Mail_headers uw_Mail_to(uw_context ctx, uw_Basis_string s, uw_Mail_headers h) {
uw_Mail_headers h2 = uw_malloc(ctx, sizeof(struct headers));
uw_Email_headers uw_Email_to(uw_context ctx, uw_Basis_string s, uw_Email_headers h) {
uw_Email_headers h2 = uw_malloc(ctx, sizeof(struct headers));
if (h)
*h2 = *h;
else
Expand All @@ -98,8 +98,8 @@ uw_Mail_headers uw_Mail_to(uw_context ctx, uw_Basis_string s, uw_Mail_headers h)
return h2;
}

uw_Mail_headers uw_Mail_cc(uw_context ctx, uw_Basis_string s, uw_Mail_headers h) {
uw_Mail_headers h2 = uw_malloc(ctx, sizeof(struct headers));
uw_Email_headers uw_Email_cc(uw_context ctx, uw_Basis_string s, uw_Email_headers h) {
uw_Email_headers h2 = uw_malloc(ctx, sizeof(struct headers));
if (h)
*h2 = *h;
else
Expand All @@ -116,8 +116,8 @@ uw_Mail_headers uw_Mail_cc(uw_context ctx, uw_Basis_string s, uw_Mail_headers h)
return h2;
}

uw_Mail_headers uw_Mail_bcc(uw_context ctx, uw_Basis_string s, uw_Mail_headers h) {
uw_Mail_headers h2 = uw_malloc(ctx, sizeof(struct headers));
uw_Email_headers uw_Email_bcc(uw_context ctx, uw_Basis_string s, uw_Email_headers h) {
uw_Email_headers h2 = uw_malloc(ctx, sizeof(struct headers));
if (h)
*h2 = *h;
else
Expand All @@ -134,8 +134,8 @@ uw_Mail_headers uw_Mail_bcc(uw_context ctx, uw_Basis_string s, uw_Mail_headers h
return h2;
}

uw_Mail_headers uw_Mail_subject(uw_context ctx, uw_Basis_string s, uw_Mail_headers h) {
uw_Mail_headers h2 = uw_malloc(ctx, sizeof(struct headers));
uw_Email_headers uw_Email_subject(uw_context ctx, uw_Basis_string s, uw_Email_headers h) {
uw_Email_headers h2 = uw_malloc(ctx, sizeof(struct headers));

if (h)
*h2 = *h;
Expand All @@ -151,8 +151,8 @@ uw_Mail_headers uw_Mail_subject(uw_context ctx, uw_Basis_string s, uw_Mail_heade
return h2;
}

uw_Mail_headers uw_Mail_user_agent(uw_context ctx, uw_Basis_string s, uw_Mail_headers h) {
uw_Mail_headers h2 = uw_malloc(ctx, sizeof(struct headers));
uw_Email_headers uw_Email_user_agent(uw_context ctx, uw_Basis_string s, uw_Email_headers h) {
uw_Email_headers h2 = uw_malloc(ctx, sizeof(struct headers));

if (h)
*h2 = *h;
Expand All @@ -170,7 +170,7 @@ uw_Mail_headers uw_Mail_user_agent(uw_context ctx, uw_Basis_string s, uw_Mail_he

typedef struct {
uw_context ctx;
uw_Mail_headers h;
uw_Email_headers h;
uw_Basis_string server, ca, user, password, body, xbody;
uw_Basis_bool ssl;
} job;
Expand Down Expand Up @@ -408,10 +408,10 @@ static void free_job(void *p, int will_retry) {
free(j);
}

uw_unit uw_Mail_send(uw_context ctx, uw_Basis_string server,
uw_unit uw_Email_send(uw_context ctx, uw_Basis_string server,
uw_Basis_bool ssl, uw_Basis_string ca,
uw_Basis_string user, uw_Basis_string password,
uw_Mail_headers h, uw_Basis_string body, uw_Basis_string xbody) {
uw_Email_headers h, uw_Basis_string body, uw_Basis_string xbody) {
job *j;

if (!h || !h->from)
Expand Down
16 changes: 16 additions & 0 deletions email.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <urweb.h>

typedef struct headers *uw_Email_headers;

extern uw_Email_headers uw_Email_empty;

uw_Email_headers uw_Email_from(uw_context, uw_Basis_string, uw_Email_headers);
uw_Email_headers uw_Email_to(uw_context, uw_Basis_string, uw_Email_headers);
uw_Email_headers uw_Email_cc(uw_context, uw_Basis_string, uw_Email_headers);
uw_Email_headers uw_Email_bcc(uw_context, uw_Basis_string, uw_Email_headers);
uw_Email_headers uw_Email_subject(uw_context, uw_Basis_string, uw_Email_headers);

uw_unit uw_Email_send(uw_context, uw_Basis_string server,
uw_Basis_bool ssl, uw_Basis_string ca,
uw_Basis_string user, uw_Basis_string password,
uw_Email_headers, uw_Basis_string body, uw_Basis_string xbody);
File renamed without changes.
12 changes: 6 additions & 6 deletions examples/multiple.ur
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
val server = "smtp://you.com:465"
val user = "you"
val password = "pass"
val send = Mail.send server True None user password
val send = Email.send server True None user password

fun solicitText (user : string) : transaction string
= key <- rand;
Expand Down Expand Up @@ -31,18 +31,18 @@ fun solicitText (user : string) : transaction string
"Your System.\n"
)

val sendOneMail (from : string) (to : string) (subject : string) (text : string) : transaction unit
= send (Mail.subject subject (Mail.to to (Mail.from from Mail.empty))) text None
val sendOneEmail (from : string) (to : string) (subject : string) (text : string) : transaction unit
= send (Email.subject subject (Email.to to (Email.from from Email.empty))) text None

val sendMails : transaction unit
val sendEmails : transaction unit
= users <- return ("[email protected]" :: "[email protected]" :: "[email protected]" :: []);
List.app
(fn user =>
text <- solicitText user;
sendOneMail "[email protected]" user "soliciting your data" text
sendOneEmail "[email protected]" user "soliciting your data" text
)
users

fun main () : transaction page
= sendMails;
= sendEmails;
return <xml>Sent</xml>
2 changes: 1 addition & 1 deletion examples/multiple.urs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
val sendMails : transaction unit
val sendEmails : transaction unit
val main : unit -> transaction page
6 changes: 3 additions & 3 deletions examples/test.ur
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
val server = "smtp://you.com:465"
val user = "you"
val password = "pass"
val send = Mail.send server True None user password
val send = Email.send server True None user password

fun sendPlain r =
send (Mail.from r.From (Mail.to r.To (Mail.subject r.Subject Mail.empty)))
send (Email.from r.From (Email.to r.To (Email.subject r.Subject Email.empty)))
r.Body None;
return <xml>Sent</xml>

fun sendHtml r =
send (Mail.from r.From (Mail.to r.To (Mail.subject r.Subject Mail.empty)))
send (Email.from r.From (Email.to r.To (Email.subject r.Subject Email.empty)))
r.Body (Some <xml><a href={url (main ())}>Spread the love!</a></xml>);
return <xml>Sent</xml>

Expand Down
8 changes: 4 additions & 4 deletions lib.urp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ffi mail
include mail.h
link -lurweb_mail -lcurl
effectful Mail.send
ffi email
include email.h
link -lurweb_email -lcurl
effectful Email.send
16 changes: 0 additions & 16 deletions mail.h

This file was deleted.

0 comments on commit b9231eb

Please sign in to comment.