read_simplemail() when SERVER_ADMIN_MSG is defined
Some warnings were mentioned Add a prototype ahead of the function Use a non-const copy of SERVER_ADMIN_MSG quick-tested by: - uncommenting the following in include/unixconf.h /* #define SERVER_ADMIN_MSG "adminmsg" */ - building NetHack - creating a test message: echo "server_admin: system is going down at 2 pm" >~/nh/install/games/lib/nethackdir/adminmsg - playtested and received the desired message
This commit is contained in:
+1
-1
@@ -940,7 +940,7 @@ extern void strbuf_append(strbuf_t *, const char *);
|
|||||||
extern void strbuf_reserve(strbuf_t *, int);
|
extern void strbuf_reserve(strbuf_t *, int);
|
||||||
extern void strbuf_empty(strbuf_t *);
|
extern void strbuf_empty(strbuf_t *);
|
||||||
extern void strbuf_nl_to_crlf(strbuf_t *);
|
extern void strbuf_nl_to_crlf(strbuf_t *);
|
||||||
extern char *nonconst(const char *, char *);
|
extern char *nonconst(const char *, char *, size_t);
|
||||||
extern int swapbits(int, int, int);
|
extern int swapbits(int, int, int);
|
||||||
extern void shuffle_int_array(int *, int);
|
extern void shuffle_int_array(int *, int);
|
||||||
/* note: the snprintf CPP wrapper includes the "fmt" argument in "..."
|
/* note: the snprintf CPP wrapper includes the "fmt" argument in "..."
|
||||||
|
|||||||
+2
-2
@@ -1221,12 +1221,12 @@ strbuf_nl_to_crlf(strbuf_t *strbuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nonconst(const char *str, char *buf)
|
nonconst(const char *str, char *buf, size_t bufsz)
|
||||||
{
|
{
|
||||||
char *retval = emptystr;
|
char *retval = emptystr;
|
||||||
|
|
||||||
if (str && buf)
|
if (str && buf)
|
||||||
if ((int) strlen(str) < BUFSZ - 1) {
|
if (strlen(str) < (bufsz - 1)) {
|
||||||
Strcpy(buf, str);
|
Strcpy(buf, str);
|
||||||
retval = buf;
|
retval = buf;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -44,6 +44,9 @@ static boolean md_start(coord *);
|
|||||||
static boolean md_stop(coord *, coord *);
|
static boolean md_stop(coord *, coord *);
|
||||||
static boolean md_rush(struct monst *, int, int);
|
static boolean md_rush(struct monst *, int, int);
|
||||||
static void newmail(struct mail_info *);
|
static void newmail(struct mail_info *);
|
||||||
|
#if defined(SIMPLE_MAIL) || defined(SERVER_ADMIN_MSG)
|
||||||
|
static void read_simplemail(char *mbox, boolean adminmsg);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(UNIX) && !defined(VMS)
|
#if !defined(UNIX) && !defined(VMS)
|
||||||
int mustgetmail = -1;
|
int mustgetmail = -1;
|
||||||
@@ -659,13 +662,15 @@ ck_server_admin_msg(void)
|
|||||||
#ifdef SERVER_ADMIN_MSG
|
#ifdef SERVER_ADMIN_MSG
|
||||||
static struct stat ost,nst;
|
static struct stat ost,nst;
|
||||||
static long lastchk = 0;
|
static long lastchk = 0;
|
||||||
|
char adminbuf[BUFSZ];
|
||||||
|
|
||||||
if (g.moves < lastchk + SERVER_ADMIN_MSG_CKFREQ) return;
|
if (g.moves < lastchk + SERVER_ADMIN_MSG_CKFREQ) return;
|
||||||
lastchk = g.moves;
|
lastchk = g.moves;
|
||||||
|
|
||||||
if (!stat(SERVER_ADMIN_MSG, &nst)) {
|
if (!stat(SERVER_ADMIN_MSG, &nst)) {
|
||||||
if (nst.st_mtime > ost.st_mtime)
|
if (nst.st_mtime > ost.st_mtime)
|
||||||
read_simplemail(SERVER_ADMIN_MSG, TRUE);
|
read_simplemail(nonconst(SERVER_ADMIN_MSG, adminbuf,
|
||||||
|
sizeof adminbuf), TRUE);
|
||||||
ost.st_mtime = nst.st_mtime;
|
ost.st_mtime = nst.st_mtime;
|
||||||
}
|
}
|
||||||
#endif /* SERVER_ADMIN_MSG */
|
#endif /* SERVER_ADMIN_MSG */
|
||||||
|
|||||||
Reference in New Issue
Block a user