(wrmakesrc,wripglob,wrgamesdef,info,apro,mobupdate,rea,turn

upda,ef_open,logerror,emp_config,match_user,show_motd,gamedown,
typed_wu,delete_old_announcements,mobility_check,mobility_init,
allocate_memory,write_newcap_script,main,files,fairland,doconfig,)
[_WIN32]: Switchback to default mode of text.
"t" (text) is not included the ISO/ANSI C standard but "b" (binary)
is included.
This commit is contained in:
Ron Koenderink 2005-03-02 12:47:15 +00:00
parent d4af51c9e2
commit 55e6aca9e0
17 changed files with 28 additions and 41 deletions

View file

@ -88,10 +88,6 @@ main(void)
char *cp;
char *pathname;
#if defined(_WIN32)
_fmode = _O_BINARY;
#endif
if ((pathname = safe_getcwd()) == NULL) {
printf("Can't get current path!\n");
exit(-1);
@ -141,7 +137,7 @@ wrmakesrc(char *pathname)
char buf[256];
sprintf(buf, "%s/src/make.src", pathname);
if ((fp = fopen(buf, "w")) == NULL) {
if ((fp = fopen(buf, "wb")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", buf);
exit(-1);
}
@ -158,7 +154,7 @@ wripglob(char *filename)
FILE *fp;
printf("Writing %s\n", filename);
if ((fp = fopen(filename, "w")) == NULL) {
if ((fp = fopen(filename, "wb")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", filename);
exit(-1);
}
@ -175,7 +171,7 @@ wrauth(char *filename)
FILE *fp;
printf("Writing %s\n", filename);
if ((fp = fopen(filename, "wt")) == NULL) {
if ((fp = fopen(filename, "w")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", filename);
exit(-1);
}
@ -232,7 +228,7 @@ wrgamesdef(char *filename)
}
printf("Writing %s\n", filename);
if ((fp = fopen(filename, "w")) == NULL) {
if ((fp = fopen(filename, "wb")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", filename);
exit(-1);
}

View file

@ -305,7 +305,7 @@ info(void)
name = "TOP";
_snprintf(filename, sizeof(filename) - 1, "%s\\%s", infodir, name);
fp = fopen(filename, "r");
fp = fopen(filename, "rb");
if (fp == NULL) {
/* may be a "partial" request. */
HANDLE hDir;
@ -365,7 +365,7 @@ info(void)
}
_snprintf(filename, sizeof(filename), "%s/%s",
infodir, last);
fp = fopen(filename, "r");
fp = fopen(filename, "rb");
if (fp == NULL) {
pr("Error reading info file for %s\n", name);
logerror("Cannot open for \"%s\" info file (%s)",
@ -455,7 +455,7 @@ apro(void)
(fData.dwFileAttributes == FILE_ATTRIBUTE_READONLY))) {
_snprintf(filename, sizeof(filename), "%s\\%s", infodir,
fData.cFileName);
fp = fopen(filename, "r");
fp = fopen(filename, "rb");
alreadyhit = 0;
nll = nlhl = 0;
if (fp != NULL) {

View file

@ -61,7 +61,7 @@ mobupdate(void)
else
minites = atol(player->argp[1]) * 60;
time(&now);
if ((fp = fopen(timestampfil, "r+")) == NULL) {
if ((fp = fopen(timestampfil, "rb+")) == NULL) {
logerror("Unable to edit timestamp file.");
} else {
rewind(fp);

View file

@ -100,7 +100,7 @@ rea(void)
clear_telegram_is_new(player->cnum);
}
if ((telfp = fopen(mbox, "r+")) == 0) {
if ((telfp = fopen(mbox, "rb+")) == 0) {
logerror("telegram file %s", mbox);
return RET_FAIL;
}
@ -201,7 +201,7 @@ rea(void)
/* 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, "w");
telfp = fopen((char *)mbox, "wb");
}
}
}

View file

@ -95,7 +95,7 @@ turn(void)
pr("Writing empty no-login message.\n");
}
fptr = fopen(msgfilepath, "w");
fptr = fopen(msgfilepath, "wb");
if (fptr == NULL) {
pr("Something went wrong opening the message file.\n");
logerror("Could not open message file (%s).\n", msgfilepath);

View file

@ -51,7 +51,7 @@ upda(void)
struct mob_acc_globals timestamps;
if (opt_MOB_ACCESS) {
if ((fp = fopen(timestampfil, "r")) == NULL)
if ((fp = fopen(timestampfil, "rb")) == NULL)
logerror("Unable to open timestamp file.");
else {
rewind(fp);

View file

@ -60,6 +60,9 @@ ef_open(int type, int mode, int how)
static int block;
int size;
#if defined(_WIN32)
mode |= O_BINARY;
#endif
if (ef_check(type) < 0)
return 0;
ep = &empfile[type];

View file

@ -82,11 +82,7 @@ logerror(s_char *format, ...)
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);

View file

@ -92,7 +92,7 @@ emp_config(char *file)
fixup_files();
return 0;
}
if ((fp = fopen(file, "rt")) == NULL) {
if ((fp = fopen(file, "r")) == NULL) {
fprintf(stderr, "Can't open %s for reading (%s)\n",
file, strerror(errno));
return -1;

View file

@ -158,7 +158,7 @@ gamedown(void)
if (player->god)
return 0;
if ((down_fp = fopen(downfil, "r")) == NULL)
if ((down_fp = fopen(downfil, "rb")) == NULL)
return 0;
if (fread((void *)&tgm, sizeof(tgm), 1, down_fp) != 1) {
logerror("bad header on login message (downfil)");

View file

@ -347,7 +347,7 @@ show_motd(void)
struct telstr tgm;
char buf[MAXTELSIZE];
if ((motd_fp = fopen(motdfil, "r")) == NULL)
if ((motd_fp = fopen(motdfil, "rb")) == NULL)
{
if (errno == ENOENT)
return RET_OK;
@ -387,7 +387,7 @@ match_user(char *file, struct player *p)
char host[256];
char user[256];
if ((fp = fopen(file, "rt")) == NULL) {
if ((fp = fopen(file, "r")) == NULL) {
/*logerror("Cannot find file %s", file); */
return 0;
}

View file

@ -125,7 +125,11 @@ typed_wu(natid from, natid to, s_char *message, int type)
(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;
}

View file

@ -65,12 +65,12 @@ delete_old_announcements(void)
old = now - days(anno_keep_days);
logerror("Deleting annos older than %s", ctime(&old));
if ((annfp = fopen(annfil, "r")) == NULL) {
if ((annfp = fopen(annfil, "rb")) == NULL) {
logerror("can't open telegram file %s for reading", annfil);
return;
}
sprintf(tmp_filename, "%s.tmp", annfil);
if ((tmpfp = fopen(tmp_filename, "w")) == NULL) {
if ((tmpfp = fopen(tmp_filename, "wb")) == NULL) {
logerror("can't open telegram file %s for writing",
tmp_filename);
if (fclose(annfp) != 0)

View file

@ -113,10 +113,6 @@ main(int argc, char **argv)
int op;
s_char tbuf[256];
#if defined(_WIN32)
_fmode = _O_BINARY;
#endif
mainpid = getpid();
#if defined(_WIN32)

View file

@ -52,7 +52,7 @@ mobility_check(void *unused)
while (1) {
time(&now);
/* logerror("Updating timestamp file at %s", ctime(&now));*/
if ((fp = fopen(timestampfil, "r+")) == NULL) {
if ((fp = fopen(timestampfil, "rb+")) == NULL) {
logerror("Unable to edit timestamp file.");
continue;
}
@ -97,7 +97,7 @@ mobility_init(void)
mobility */
time(&now);
if ((fp = fopen(timestampfil, "r+")) == NULL) {
if ((fp = fopen(timestampfil, "rb+")) == NULL) {
logerror("Unable to edit timestamp file.");
/* FIXME safe to continue? */
} else {

View file

@ -194,10 +194,6 @@ main(int argc, char *argv[])
char tbuf[512];
int i = 0;
#if defined(_WIN32)
_fmode = _O_BINARY;
#endif
rnd_seed = time(NULL);
while ((opt = getopt(argc, argv, "ae:ioqs:R:")) != EOF) {
@ -411,7 +407,7 @@ allocate_memory(void)
{
int i;
sect_fptr = fopen(empfile[EF_SECTOR].file, "w");
sect_fptr = fopen(empfile[EF_SECTOR].file, "wb");
if (sect_fptr == NULL) {
perror(empfile[EF_SECTOR].file);
return -1;

View file

@ -88,10 +88,6 @@ main(int argc, char *argv[])
char *config_file = NULL;
int force = 0;
#if defined(_WIN32)
_fmode = _O_BINARY;
#endif
while ((opt = getopt(argc, argv, "e:f")) != EOF) {
switch (opt) {
case 'e':