]> git.pond.sub.org Git - empserver/commitdiff
(wrmakesrc,wripglob,wrgamesdef,info,apro,mobupdate,rea,turn
authorRon Koenderink <rkoenderink@yahoo.ca>
Wed, 2 Mar 2005 12:47:15 +0000 (12:47 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Wed, 2 Mar 2005 12:47:15 +0000 (12:47 +0000)
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.

17 files changed:
src/doconfig/doconfig.c
src/lib/commands/info.c
src/lib/commands/mobu.c
src/lib/commands/rea.c
src/lib/commands/turn.c
src/lib/commands/upda.c
src/lib/common/file.c
src/lib/common/log.c
src/lib/gen/emp_config.c
src/lib/player/empdis.c
src/lib/player/player.c
src/lib/subs/wu.c
src/lib/update/anno.c
src/server/main.c
src/server/timestamp.c
src/util/fairland.c
src/util/files.c

index 1ed989144208a1181c3e2b910f8d6fba9f8a2cda..1779e69787d0ef4b88a214ee58216bb7af7014ab 100644 (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);
     }
index cfc0866e091ea413026ee153335f859c124bb576..7038add9496d614a34a1d1c0d8368aa787ccf32a 100644 (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) {
index a368c1964f8d9d68022f459ff4d6f56f4e4783fe..636f907c2219cba229f06649249a1db53112d875 100644 (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);
index b70f6fd558cc0f516dfb0fd83102956f5c4eb1f3..fe0dc6fa15e7c893608633f3d873b425c7706dd8 100644 (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");
            }
        }
     }
index 84deb67800c433adab40e9f74941f34bae7e4139..d0567cbdda8a81f93358c3388b93309ae7459c3e 100644 (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);
index 94adc79ae7321c843fd83cbd14fe16a4d9c05fa0..34cedc3e2993aedee4c65b504be48f98459f4c34 100644 (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);
index e94b52c50b18596b4890701076cea32bfb118b6e..e35c775ce32f572ca3f7b48de6ef03ec138e56c5 100644 (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];
index 8419df7a5c10bf51f0c765e3f497ff2ab5394a49..36e2b0d5401317a212c6656765ce9dc321e81050 100644 (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);
index e13736f7e23dd786a1841812d3409b93ef34e89e..4def08f38181c6a99d29139d21294ba401e041cb 100644 (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;
index 57654067082947a7be2b36bd8969b4cbef88d94b..19e4f99183cf8e2168a6604a5e73d449af03e917 100644 (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)");
index a08b2e6e61b77e10e6a37fc756a660cc26e1f857..92272fa2cf1cec6747aaf92383e31f621d966422 100644 (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;
     }
index 036d94e4380d3964dc9f06bf2dfffc70d0b51cf0..292717ad0c295fe6b871c4cadcd5220ab4834483 100644 (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;
     }
index b5b118230f1d981a4fac743e44accfdb03ee4a41..f72683642cdc359bed2bb8d647f4bf234c15480e 100644 (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)
index f6b0b2c1efa396d5e321a86954d64fcf6aef4b82..51b1c5772bcdfda7f6d2bbef90316c494af62174 100644 (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)
index c85c80f88716f7d45ba9bad9815bdd1e8e8f0472..c8d0f5fbef61b1d4d65ce6e143bcdc7e1fc9771f 100644 (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 {
index 9d97ac2b7bb543ebc036d77809d50156f8a9717d..72faccbac7a8101c61e443548760a9c1242a41af 100644 (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;
index f0ad84feb68122b81d081cae6dad265c1a66f1f9..6acee2fba9eacfcf6d89c04d4001b1e3d79cf4a9 100644 (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':