(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:
parent
d4af51c9e2
commit
55e6aca9e0
17 changed files with 28 additions and 41 deletions
|
@ -88,10 +88,6 @@ main(void)
|
||||||
char *cp;
|
char *cp;
|
||||||
char *pathname;
|
char *pathname;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
_fmode = _O_BINARY;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((pathname = safe_getcwd()) == NULL) {
|
if ((pathname = safe_getcwd()) == NULL) {
|
||||||
printf("Can't get current path!\n");
|
printf("Can't get current path!\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -141,7 +137,7 @@ wrmakesrc(char *pathname)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
sprintf(buf, "%s/src/make.src", pathname);
|
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);
|
printf("Cannot open %s for writing, exiting.\n", buf);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +154,7 @@ wripglob(char *filename)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
printf("Writing %s\n", 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);
|
printf("Cannot open %s for writing, exiting.\n", filename);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +171,7 @@ wrauth(char *filename)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
printf("Writing %s\n", filename);
|
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);
|
printf("Cannot open %s for writing, exiting.\n", filename);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +228,7 @@ wrgamesdef(char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Writing %s\n", 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);
|
printf("Cannot open %s for writing, exiting.\n", filename);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,7 @@ info(void)
|
||||||
name = "TOP";
|
name = "TOP";
|
||||||
|
|
||||||
_snprintf(filename, sizeof(filename) - 1, "%s\\%s", infodir, name);
|
_snprintf(filename, sizeof(filename) - 1, "%s\\%s", infodir, name);
|
||||||
fp = fopen(filename, "r");
|
fp = fopen(filename, "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
/* may be a "partial" request. */
|
/* may be a "partial" request. */
|
||||||
HANDLE hDir;
|
HANDLE hDir;
|
||||||
|
@ -365,7 +365,7 @@ info(void)
|
||||||
}
|
}
|
||||||
_snprintf(filename, sizeof(filename), "%s/%s",
|
_snprintf(filename, sizeof(filename), "%s/%s",
|
||||||
infodir, last);
|
infodir, last);
|
||||||
fp = fopen(filename, "r");
|
fp = fopen(filename, "rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
pr("Error reading info file for %s\n", name);
|
pr("Error reading info file for %s\n", name);
|
||||||
logerror("Cannot open for \"%s\" info file (%s)",
|
logerror("Cannot open for \"%s\" info file (%s)",
|
||||||
|
@ -455,7 +455,7 @@ apro(void)
|
||||||
(fData.dwFileAttributes == FILE_ATTRIBUTE_READONLY))) {
|
(fData.dwFileAttributes == FILE_ATTRIBUTE_READONLY))) {
|
||||||
_snprintf(filename, sizeof(filename), "%s\\%s", infodir,
|
_snprintf(filename, sizeof(filename), "%s\\%s", infodir,
|
||||||
fData.cFileName);
|
fData.cFileName);
|
||||||
fp = fopen(filename, "r");
|
fp = fopen(filename, "rb");
|
||||||
alreadyhit = 0;
|
alreadyhit = 0;
|
||||||
nll = nlhl = 0;
|
nll = nlhl = 0;
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ mobupdate(void)
|
||||||
else
|
else
|
||||||
minites = atol(player->argp[1]) * 60;
|
minites = atol(player->argp[1]) * 60;
|
||||||
time(&now);
|
time(&now);
|
||||||
if ((fp = fopen(timestampfil, "r+")) == NULL) {
|
if ((fp = fopen(timestampfil, "rb+")) == NULL) {
|
||||||
logerror("Unable to edit timestamp file.");
|
logerror("Unable to edit timestamp file.");
|
||||||
} else {
|
} else {
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
|
|
|
@ -100,7 +100,7 @@ rea(void)
|
||||||
clear_telegram_is_new(player->cnum);
|
clear_telegram_is_new(player->cnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((telfp = fopen(mbox, "r+")) == 0) {
|
if ((telfp = fopen(mbox, "rb+")) == 0) {
|
||||||
logerror("telegram file %s", mbox);
|
logerror("telegram file %s", mbox);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ rea(void)
|
||||||
/* Here, we just re-open the file for "w" only,
|
/* Here, we just re-open the file for "w" only,
|
||||||
and that will wipe the file clean automatically */
|
and that will wipe the file clean automatically */
|
||||||
(void)fclose(telfp);
|
(void)fclose(telfp);
|
||||||
telfp = fopen((char *)mbox, "w");
|
telfp = fopen((char *)mbox, "wb");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ turn(void)
|
||||||
pr("Writing empty no-login message.\n");
|
pr("Writing empty no-login message.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fptr = fopen(msgfilepath, "w");
|
fptr = fopen(msgfilepath, "wb");
|
||||||
if (fptr == NULL) {
|
if (fptr == NULL) {
|
||||||
pr("Something went wrong opening the message file.\n");
|
pr("Something went wrong opening the message file.\n");
|
||||||
logerror("Could not open message file (%s).\n", msgfilepath);
|
logerror("Could not open message file (%s).\n", msgfilepath);
|
||||||
|
|
|
@ -51,7 +51,7 @@ upda(void)
|
||||||
struct mob_acc_globals timestamps;
|
struct mob_acc_globals timestamps;
|
||||||
|
|
||||||
if (opt_MOB_ACCESS) {
|
if (opt_MOB_ACCESS) {
|
||||||
if ((fp = fopen(timestampfil, "r")) == NULL)
|
if ((fp = fopen(timestampfil, "rb")) == NULL)
|
||||||
logerror("Unable to open timestamp file.");
|
logerror("Unable to open timestamp file.");
|
||||||
else {
|
else {
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
|
|
|
@ -60,6 +60,9 @@ ef_open(int type, int mode, int how)
|
||||||
static int block;
|
static int block;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
mode |= O_BINARY;
|
||||||
|
#endif
|
||||||
if (ef_check(type) < 0)
|
if (ef_check(type) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
ep = &empfile[type];
|
ep = &empfile[type];
|
||||||
|
|
|
@ -82,11 +82,7 @@ logerror(s_char *format, ...)
|
||||||
if ((p = strchr(cbuf, '\n')) != 0)
|
if ((p = strchr(cbuf, '\n')) != 0)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
(void)sprintf(buf1, "%s %s\n", cbuf, buf);
|
(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)
|
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
(void)write(logf, buf1, strlen(buf1));
|
(void)write(logf, buf1, strlen(buf1));
|
||||||
(void)close(logf);
|
(void)close(logf);
|
||||||
|
|
|
@ -92,7 +92,7 @@ emp_config(char *file)
|
||||||
fixup_files();
|
fixup_files();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((fp = fopen(file, "rt")) == NULL) {
|
if ((fp = fopen(file, "r")) == NULL) {
|
||||||
fprintf(stderr, "Can't open %s for reading (%s)\n",
|
fprintf(stderr, "Can't open %s for reading (%s)\n",
|
||||||
file, strerror(errno));
|
file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -158,7 +158,7 @@ gamedown(void)
|
||||||
|
|
||||||
if (player->god)
|
if (player->god)
|
||||||
return 0;
|
return 0;
|
||||||
if ((down_fp = fopen(downfil, "r")) == NULL)
|
if ((down_fp = fopen(downfil, "rb")) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (fread((void *)&tgm, sizeof(tgm), 1, down_fp) != 1) {
|
if (fread((void *)&tgm, sizeof(tgm), 1, down_fp) != 1) {
|
||||||
logerror("bad header on login message (downfil)");
|
logerror("bad header on login message (downfil)");
|
||||||
|
|
|
@ -347,7 +347,7 @@ show_motd(void)
|
||||||
struct telstr tgm;
|
struct telstr tgm;
|
||||||
char buf[MAXTELSIZE];
|
char buf[MAXTELSIZE];
|
||||||
|
|
||||||
if ((motd_fp = fopen(motdfil, "r")) == NULL)
|
if ((motd_fp = fopen(motdfil, "rb")) == NULL)
|
||||||
{
|
{
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -387,7 +387,7 @@ match_user(char *file, struct player *p)
|
||||||
char host[256];
|
char host[256];
|
||||||
char user[256];
|
char user[256];
|
||||||
|
|
||||||
if ((fp = fopen(file, "rt")) == NULL) {
|
if ((fp = fopen(file, "r")) == NULL) {
|
||||||
/*logerror("Cannot find file %s", file); */
|
/*logerror("Cannot find file %s", file); */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,11 @@ typed_wu(natid from, natid to, s_char *message, int type)
|
||||||
(np->nat_stat & STAT_SANCT) == 0)) {
|
(np->nat_stat & STAT_SANCT) == 0)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#if !defined(_WIN32)
|
||||||
if ((fd = open(box, O_WRONLY | O_APPEND, 0)) < 0) {
|
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);
|
logerror("telegram 'open' of %s (#%d) failed", box, to);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,12 +65,12 @@ delete_old_announcements(void)
|
||||||
old = now - days(anno_keep_days);
|
old = now - days(anno_keep_days);
|
||||||
logerror("Deleting annos older than %s", ctime(&old));
|
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);
|
logerror("can't open telegram file %s for reading", annfil);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sprintf(tmp_filename, "%s.tmp", annfil);
|
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",
|
logerror("can't open telegram file %s for writing",
|
||||||
tmp_filename);
|
tmp_filename);
|
||||||
if (fclose(annfp) != 0)
|
if (fclose(annfp) != 0)
|
||||||
|
|
|
@ -113,10 +113,6 @@ main(int argc, char **argv)
|
||||||
int op;
|
int op;
|
||||||
s_char tbuf[256];
|
s_char tbuf[256];
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
_fmode = _O_BINARY;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mainpid = getpid();
|
mainpid = getpid();
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
|
@ -52,7 +52,7 @@ mobility_check(void *unused)
|
||||||
while (1) {
|
while (1) {
|
||||||
time(&now);
|
time(&now);
|
||||||
/* logerror("Updating timestamp file at %s", ctime(&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.");
|
logerror("Unable to edit timestamp file.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ mobility_init(void)
|
||||||
mobility */
|
mobility */
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
if ((fp = fopen(timestampfil, "r+")) == NULL) {
|
if ((fp = fopen(timestampfil, "rb+")) == NULL) {
|
||||||
logerror("Unable to edit timestamp file.");
|
logerror("Unable to edit timestamp file.");
|
||||||
/* FIXME safe to continue? */
|
/* FIXME safe to continue? */
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -194,10 +194,6 @@ main(int argc, char *argv[])
|
||||||
char tbuf[512];
|
char tbuf[512];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
_fmode = _O_BINARY;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rnd_seed = time(NULL);
|
rnd_seed = time(NULL);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ae:ioqs:R:")) != EOF) {
|
while ((opt = getopt(argc, argv, "ae:ioqs:R:")) != EOF) {
|
||||||
|
@ -411,7 +407,7 @@ allocate_memory(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sect_fptr = fopen(empfile[EF_SECTOR].file, "w");
|
sect_fptr = fopen(empfile[EF_SECTOR].file, "wb");
|
||||||
if (sect_fptr == NULL) {
|
if (sect_fptr == NULL) {
|
||||||
perror(empfile[EF_SECTOR].file);
|
perror(empfile[EF_SECTOR].file);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -88,10 +88,6 @@ main(int argc, char *argv[])
|
||||||
char *config_file = NULL;
|
char *config_file = NULL;
|
||||||
int force = 0;
|
int force = 0;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
_fmode = _O_BINARY;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "e:f")) != EOF) {
|
while ((opt = getopt(argc, argv, "e:f")) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'e':
|
case 'e':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue