physfshttpd: removed deprecated PHYSFS_getLastError() calls.
This commit is contained in:
parent
7222c51ca8
commit
ca4f27346b
|
@ -78,6 +78,11 @@ static char *txt200 =
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"\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)
|
static int writeAll(const int fd, const void *buf, const size_t len)
|
||||||
{
|
{
|
||||||
return (write(fd, buf, len) == len);
|
return (write(fd, buf, len) == len);
|
||||||
|
@ -91,7 +96,7 @@ static void feed_file_http(const char *ipstr, int sock, const char *fname)
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
{
|
{
|
||||||
printf("%s: Can't open [%s]: %s.\n",
|
printf("%s: Can't open [%s]: %s.\n",
|
||||||
ipstr, fname, PHYSFS_getLastError());
|
ipstr, fname, lastError());
|
||||||
if (!writeAll(sock, txt404, strlen(txt404)))
|
if (!writeAll(sock, txt404, strlen(txt404)))
|
||||||
printf("%s: Write error to socket.\n", ipstr);
|
printf("%s: Write error to socket.\n", ipstr);
|
||||||
return;
|
return;
|
||||||
|
@ -105,7 +110,7 @@ static void feed_file_http(const char *ipstr, int sock, const char *fname)
|
||||||
PHYSFS_sint64 br = PHYSFS_readBytes(in, buffer, sizeof (buffer));
|
PHYSFS_sint64 br = PHYSFS_readBytes(in, buffer, sizeof (buffer));
|
||||||
if (br == -1)
|
if (br == -1)
|
||||||
{
|
{
|
||||||
printf("%s: Read error: %s.\n", ipstr, PHYSFS_getLastError());
|
printf("%s: Read error: %s.\n", ipstr, lastError());
|
||||||
break;
|
break;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
@ -237,7 +242,7 @@ void at_exit_cleanup(void)
|
||||||
close(listensocket);
|
close(listensocket);
|
||||||
|
|
||||||
if (!PHYSFS_deinit())
|
if (!PHYSFS_deinit())
|
||||||
printf("PHYSFS_deinit() failed: %s\n", PHYSFS_getLastError());
|
printf("PHYSFS_deinit() failed: %s\n", lastError());
|
||||||
} /* at_exit_cleanup */
|
} /* at_exit_cleanup */
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,7 +272,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if (!PHYSFS_init(argv[0]))
|
if (!PHYSFS_init(argv[0]))
|
||||||
{
|
{
|
||||||
printf("PHYSFS_init() failed: %s\n", PHYSFS_getLastError());
|
printf("PHYSFS_init() failed: %s\n", lastError());
|
||||||
return 42;
|
return 42;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue