Add SIMPLE_MAIL compile-time option for public servers
This commit is contained in:
@@ -191,7 +191,16 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* If SIMPLE_MAIL is defined, the mail spool file format is
|
||||||
|
"sender:message", one mail per line, and mails are
|
||||||
|
read within game, from demon-delivered mail scrolls */
|
||||||
|
/* #define SIMPLE_MAIL */
|
||||||
|
|
||||||
|
#ifndef MAILCKFREQ
|
||||||
|
/* How often mail spool file is checked for new messages, in turns */
|
||||||
#define MAILCKFREQ 50
|
#define MAILCKFREQ 50
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* MAIL */
|
#endif /* MAIL */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+68
-1
@@ -5,6 +5,10 @@
|
|||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
|
|
||||||
#ifdef MAIL
|
#ifdef MAIL
|
||||||
|
#ifdef SIMPLE_MAIL
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <errno.h>
|
||||||
|
#endif /* SIMPLE_MAIL */
|
||||||
#include "mail.h"
|
#include "mail.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -498,6 +502,64 @@ ckmailstatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SIMPLE_MAIL
|
||||||
|
void
|
||||||
|
read_simplemail()
|
||||||
|
{
|
||||||
|
FILE* mb = fopen(mailbox, "r");
|
||||||
|
char curline[102], *msg;
|
||||||
|
boolean seen_one_already = FALSE;
|
||||||
|
struct flock fl = { 0 };
|
||||||
|
|
||||||
|
fl.l_type = F_RDLCK;
|
||||||
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
|
fl.l_len = 0;
|
||||||
|
|
||||||
|
if (!mb)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
/* Allow this call to block. */
|
||||||
|
if (fcntl (fileno (mb), F_SETLKW, &fl) == -1)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
while (fgets(curline, 102, mb) != NULL) {
|
||||||
|
fl.l_type = F_UNLCK;
|
||||||
|
fcntl (fileno(mb), F_UNLCK, &fl);
|
||||||
|
|
||||||
|
pline("There is a%s message on this scroll.",
|
||||||
|
seen_one_already ? "nother" : "");
|
||||||
|
|
||||||
|
msg = strchr(curline, ':');
|
||||||
|
|
||||||
|
if (!msg)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
*msg = '\0';
|
||||||
|
msg++;
|
||||||
|
|
||||||
|
pline("This message is from '%s'.", curline);
|
||||||
|
|
||||||
|
msg[strlen(msg) - 1] = '\0'; /* kill newline */
|
||||||
|
pline ("It reads: \"%s\".", msg);
|
||||||
|
|
||||||
|
seen_one_already = TRUE;
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
|
fl.l_type = F_RDLCK;
|
||||||
|
fcntl(fileno(mb), F_SETLKW, &fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
fl.l_type = F_UNLCK;
|
||||||
|
fcntl(fileno(mb), F_UNLCK, &fl);
|
||||||
|
fclose(mb);
|
||||||
|
unlink(mailbox);
|
||||||
|
bail:
|
||||||
|
pline("It appears to be all gibberish."); /* bail out _professionally_ */
|
||||||
|
}
|
||||||
|
#endif /* SIMPLE_MAIL */
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
void
|
void
|
||||||
readmail(otmp)
|
readmail(otmp)
|
||||||
@@ -505,7 +567,12 @@ struct obj *otmp UNUSED;
|
|||||||
{
|
{
|
||||||
#ifdef DEF_MAILREADER /* This implies that UNIX is defined */
|
#ifdef DEF_MAILREADER /* This implies that UNIX is defined */
|
||||||
register const char *mr = 0;
|
register const char *mr = 0;
|
||||||
|
#endif /* DEF_MAILREADER */
|
||||||
|
#ifdef SIMPLE_MAIL
|
||||||
|
read_simplemail();
|
||||||
|
return;
|
||||||
|
#endif /* SIMPLE_MAIL */
|
||||||
|
#ifdef DEF_MAILREADER /* This implies that UNIX is defined */
|
||||||
display_nhwindow(WIN_MESSAGE, FALSE);
|
display_nhwindow(WIN_MESSAGE, FALSE);
|
||||||
if (!(mr = nh_getenv("MAILREADER")))
|
if (!(mr = nh_getenv("MAILREADER")))
|
||||||
mr = DEF_MAILREADER;
|
mr = DEF_MAILREADER;
|
||||||
|
|||||||
Reference in New Issue
Block a user