/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* rea.c: Read telegrams
- *
+ *
* Known contributors to this file:
* Dave Pare
* Doug Hay, 1998
#include <config.h>
-#include "misc.h"
-#include "player.h"
-#include "nat.h"
-#include "file.h"
-#include "tel.h"
+#include <ctype.h>
+#include <stdio.h>
#include "commands.h"
-#include "optlist.h"
#include "match.h"
-
-#include <stdio.h>
-#include <fcntl.h>
-#if !defined(_WIN32)
-#include <sys/file.h>
-#endif
+#include "misc.h"
+#include "optlist.h"
+#include "tel.h"
int
rea(void)
{
- static s_char *telnames[] = {
+ static char *telnames[] = {
/* must follow TEL_ defines in tel.h */
"Telegram", "Announcement", "BULLETIN", "Production Report"
};
- register s_char *p;
- register s_char *mbox;
- s_char mbox_buf[256]; /* Maximum path length */
+ char *p;
+ char *mbox;
+ char mbox_buf[256]; /* Maximum path length */
struct telstr tgm;
FILE *telfp;
int teles;
int size;
- unsigned int nbytes;
+ unsigned nbytes;
char buf[1024];
char msgbuf[4096]; /* UTF-8 */
int lasttype;
time_t lastdate;
int header;
int filelen;
- s_char kind[80];
+ char *kind;
int n;
int num = player->cnum;
struct natstr *np = getnatp(player->cnum);
int readit;
int may_delete = 1; /* may messages be deleted? */
- memset(kind, 0, sizeof(kind));
now = time(NULL);
if (*player->argp[0] == 'w') {
- strcpy(kind, "announcement");
+ kind = "announcement";
if (player->argp[1] && isdigit(*player->argp[1])) {
delta = days(atoi(player->argp[1]));
then = now - delta;
then = np->nat_annotim;
mbox = annfil;
} else {
- strcpy(kind, "telegram");
+ kind = "telegram";
if (player->god && player->argp[1] &&
(mineq(player->argp[1], "yes") == ME_MISMATCH) &&
(mineq(player->argp[1], "no") == ME_MISMATCH)) {
nbytes = tgm.tel_length;
if (nbytes > sizeof(msgbuf) - 1)
nbytes = sizeof(msgbuf) - 1;
- (void)fread(msgbuf, sizeof(s_char), nbytes, telfp);
+ fread(msgbuf, 1, nbytes, telfp);
msgbuf[nbytes] = 0;
if (readit)
uprnf(msgbuf);
tgm.tel_length -= nbytes;
}
}
- p = NULL;
if (teles > 0 && player->cnum == num && may_delete) {
pr("\n");
if (teles == 1) {
/* Here, we just re-open the file for "w" only,
and that will wipe the file clean automatically */
(void)fclose(telfp);
- telfp = fopen((char *)mbox, "wb");
+ telfp = fopen(mbox, "wb");
}
}
}