else
minites = atol(player->argp[1]) * 60;
time(&now);
-#if !defined(_WIN32)
if ((fp = fopen(timestampfil, "r+")) == NULL) {
-#else
- if ((fp = fopen(timestampfil, "r+b")) == NULL) {
-#endif
logerror("Unable to edit timestamp file.");
} else {
rewind(fp);
clear_telegram_is_new(player->cnum);
}
-#if !defined(_WIN32)
if ((telfp = fopen(mbox, "r+")) == 0) {
-#else
- if ((telfp = fopen(mbox, "r+b")) == 0) {
-#endif
logerror("telegram file %s", mbox);
return RET_FAIL;
}
/* Here, we just re-open the file for "w" only,
and that will wipe the file clean automatically */
(void)fclose(telfp);
-#if !defined(_WIN32)
telfp = fopen((char *)mbox, "w");
-#else
- telfp = fopen((char *)mbox, "wb");
-#endif
}
}
}
pr("Writing empty no-login message.\n");
}
-#if !defined(_WIN32)
fd = open(msgfilepath, O_RDWR | O_CREAT | O_TRUNC, 0660);
-#else
- fd = open(msgfilepath, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0660);
-#endif
if (fd == -1) {
pr("Something went wrong opening the message file.\n");
logerror("Could not open message file (%s).\n", msgfilepath);
struct mob_acc_globals timestamps;
if (opt_MOB_ACCESS) {
-#if !defined(_WIN32)
- if ((fp = fopen(timestampfil, "r")) == NULL) {
-#else
- if ((fp = fopen(timestampfil, "rb")) == NULL) {
-#endif
+ if ((fp = fopen(timestampfil, "r")) == NULL)
logerror("Unable to open timestamp file.");
- } else {
+ else {
rewind(fp);
fread(×tamps, sizeof(timestamps), 1, fp);
fclose(fp);
static int block;
int size;
-#if defined(_WIN32)
- mode |= _O_BINARY;
-#endif
if (ef_check(type) < 0)
return 0;
ep = &empfile[type];
{
s_char buf[1024];
-#if !defined(_WIN32)
sprintf(buf, "%s/%s.log", datadir, program);
-#else
- sprintf(buf, "%s\\%s.log", datadir, program);
-#endif
logfile = malloc(strlen(buf) + 1);
strcpy(logfile, buf);
}
if ((p = strchr(cbuf, '\n')) != 0)
*p = 0;
(void)sprintf(buf1, "%s %s\n", cbuf, buf);
+#if defined(_WIN32)
+ if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND | O_TEXT, 0666)) < 0)
+#else
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)
+#endif
return;
(void)write(logf, buf1, strlen(buf1));
(void)close(logf);
fixup_files();
return 0;
}
- if ((fp = fopen(file, "r")) == NULL) {
+ if ((fp = fopen(file, "rt")) == NULL) {
fprintf(stderr, "Can't open %s for reading (%s)\n",
file, strerror(errno));
return -1;
{&annfil, "ann"},
{×tampfil, "timestamp"},
{&teldir, "tel"},
-#if !defined(_WIN32)
{&telfil, "tel/tel"},
-#else
- {&telfil, "tel\\tel"},
-#endif
{NULL, NULL}
};
s_char buf[1024];
for (ep = empfile; ep < &empfile[EF_MAX]; ep++) {
-#if !defined(_WIN32)
sprintf(buf, "%s/%s", datadir, ep->name);
-#else
- sprintf(buf, "%s\\%s", datadir, ep->name);
-#endif
ep->file = strdup(buf);
}
for (op = ofiles; op->files; op++) {
-#if !defined(_WIN32)
sprintf(buf, "%s/%s", datadir, op->name);
-#else
- sprintf(buf, "%s\\%s", datadir, op->name);
-#endif
*op->files = strdup(buf);
}
}
if (player->god)
return 0;
-#if !defined(_WIN32)
if ((downf = open(downfil, O_RDONLY, 0)) < 0)
-#else
- if ((downf = open(downfil, O_RDONLY | O_BINARY, 0)) < 0)
-#endif
return 0;
if (read(downf, (s_char *)&tgm, sizeof(tgm)) != sizeof(tgm)) {
logerror("bad header on login message (downfil)");
struct telstr tgm;
char buf[MAXTELSIZE];
-#if !defined(_WIN32)
if ((motdf = open(motdfil, O_RDONLY, 0)) < 0)
-#else
- if ((motdf = open(motdfil, O_RDONLY | O_BINARY, 0)) < 0)
-#endif
{
if (errno == ENOENT)
return RET_OK;
char host[256];
char user[256];
- if ((fp = fopen(file, "r")) == NULL) {
+ if ((fp = fopen(file, "rt")) == NULL) {
/*logerror("Cannot find file %s", file); */
return 0;
}
(np->nat_stat & STAT_SANCT) == 0)) {
return -1;
}
-#if !defined(_WIN32)
if ((fd = open(box, O_WRONLY | O_APPEND, 0)) < 0) {
-#else
- if ((fd = open(box, O_WRONLY | O_APPEND | O_BINARY, 0)) < 0) {
-#endif
logerror("telegram 'open' of %s (#%d) failed", box, to);
return -1;
}
old = now - days(anno_keep_days);
logerror("Deleting annos older than %s", ctime(&old));
- if ((annfp = fopen(annfil, "rb")) == NULL) {
+ if ((annfp = fopen(annfil, "r")) == NULL) {
logerror("can't open telegram file %s for reading", annfil);
return;
}
sprintf(tmp_filename, "%s.tmp", annfil);
- if ((tmpfp = fopen(tmp_filename, "wb")) == NULL) {
+ if ((tmpfp = fopen(tmp_filename, "w")) == NULL) {
logerror("can't open telegram file %s for writing",
tmp_filename);
if (fclose(annfp) != 0)
char *config_file = NULL;
s_char tbuf[256];
+#if defined(_WIN32)
+ _fmode = _O_BINARY;
+#endif
+
loginit("server");
mainpid = getpid();
while (1) {
time(&now);
/* logerror("Updating timestamp file at %s", ctime(&now));*/
-#if !defined(_WIN32)
if ((fp = fopen(timestampfil, "r+")) == NULL) {
-#else
- if ((fp = fopen(timestampfil, "r+b")) == NULL) {
-#endif
logerror("Unable to edit timestamp file.");
continue;
}
mobility */
time(&now);
-#if !defined(_WIN32)
if ((fp = fopen(timestampfil, "r+")) == NULL) {
-#else
- if ((fp = fopen(timestampfil, "r+b")) == NULL) {
-#endif
logerror("Unable to edit timestamp file.");
/* FIXME safe to continue? */
} else {