physfshttpd: removed deprecated PHYSFS_getLastError() calls.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 14 Aug 2017 21:59:56 -0400
changeset 1585 17acf7df0c38
parent 1584 d9349944bb52
child 1586 c044e06eb23d
physfshttpd: removed deprecated PHYSFS_getLastError() calls.
extras/physfshttpd.c
--- a/extras/physfshttpd.c	Mon Aug 14 21:22:30 2017 -0400
+++ b/extras/physfshttpd.c	Mon Aug 14 21:59:56 2017 -0400
@@ -78,6 +78,11 @@
 "Content-Type: text/plain; charset=utf-8\n"
 "\n";
 
+static const char *lastError(void)
+{
+    return PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode());
+} /* lastError */
+
 static int writeAll(const int fd, const void *buf, const size_t len)
 {
     return (write(fd, buf, len) == len);
@@ -91,7 +96,7 @@
     if (in == NULL)
     {
         printf("%s: Can't open [%s]: %s.\n",
-               ipstr, fname, PHYSFS_getLastError());
+               ipstr, fname, lastError());
         if (!writeAll(sock, txt404, strlen(txt404)))
             printf("%s: Write error to socket.\n", ipstr);
         return;
@@ -105,7 +110,7 @@
             PHYSFS_sint64 br = PHYSFS_readBytes(in, buffer, sizeof (buffer));
             if (br == -1)
             {
-                printf("%s: Read error: %s.\n", ipstr, PHYSFS_getLastError());
+                printf("%s: Read error: %s.\n", ipstr, lastError());
                 break;
             } /* if */
 
@@ -237,7 +242,7 @@
         close(listensocket);
 
     if (!PHYSFS_deinit())
-        printf("PHYSFS_deinit() failed: %s\n", PHYSFS_getLastError());
+        printf("PHYSFS_deinit() failed: %s\n", lastError());
 } /* at_exit_cleanup */
 
 
@@ -267,7 +272,7 @@
 
     if (!PHYSFS_init(argv[0]))
     {
-        printf("PHYSFS_init() failed: %s\n", PHYSFS_getLastError());
+        printf("PHYSFS_init() failed: %s\n", lastError());
         return 42;
     } /* if */