diff --git a/Client/CMakeLists.txt b/Client/CMakeLists.txt index e5b5155..fc096e0 100644 --- a/Client/CMakeLists.txt +++ b/Client/CMakeLists.txt @@ -11,7 +11,7 @@ if(WIN32) Graphics/Font.cpp Graphics/Startup.cpp Graphics/Viewport.cpp - resources/Resource.rc + Resources/Resource.rc Scene/LoginScreen/LoginScreen.cpp System/System.cpp Window/Window.cpp diff --git a/Client/resources/Resource.h b/Client/Resources/Resource.h similarity index 100% rename from Client/resources/Resource.h rename to Client/Resources/Resource.h diff --git a/Client/resources/Resource.rc b/Client/Resources/Resource.rc similarity index 100% rename from Client/resources/Resource.rc rename to Client/Resources/Resource.rc diff --git a/Client/resources/TSO.ico b/Client/Resources/TSO.ico similarity index 100% rename from Client/resources/TSO.ico rename to Client/Resources/TSO.ico diff --git a/Libraries/FileHandler/far/far.c b/Libraries/FileHandler/far/far.c index b52bd00..0acdd46 100644 --- a/Libraries/FileHandler/far/far.c +++ b/Libraries/FileHandler/far/far.c @@ -1,6 +1,6 @@ /* FileHandler - General-purpose file handling library for Niotso - libfar.c - Copyright (c) 2011 Niotso Project + far.c - Copyright (c) 2011-2012 Niotso Project Author(s): Fatbag Permission to use, copy, modify, and/or distribute this software for any @@ -72,21 +72,18 @@ int far_identify(const uint8_t * Buffer, unsigned FileSize) return FAR_TYPE_INVALID; #ifdef FAR_SUPPORT_FAR - if(FileSize >= MINSIZE_FAR) - if(!memcmp(Buffer, Header_FAR, 8)) - return FAR_TYPE_FAR; + if(FileSize >= MINSIZE_FAR && !memcmp(Buffer, Header_FAR, 8)) + return FAR_TYPE_FAR; #endif #ifdef FAR_SUPPORT_DBPF - if(FileSize >= MINSIZE_DBPF) - if(!memcmp(Buffer, Header_DBPF, 4)) - return FAR_TYPE_DBPF; + if(FileSize >= MINSIZE_DBPF && !memcmp(Buffer, Header_DBPF, 4)) + return FAR_TYPE_DBPF; #endif #ifdef FAR_SUPPORT_PERSIST - if(FileSize >= MINSIZE_PERSIST) - if(Buffer[0] == 0x01) - return FAR_TYPE_PERSIST; + if(FileSize >= MINSIZE_PERSIST && Buffer[0] == 0x01) + return FAR_TYPE_PERSIST; #endif return FAR_TYPE_INVALID; diff --git a/Libraries/FileHandler/far/far.h b/Libraries/FileHandler/far/far.h index 7b59b35..689be8cb 100644 --- a/Libraries/FileHandler/far/far.h +++ b/Libraries/FileHandler/far/far.h @@ -1,6 +1,6 @@ /* FileHandler - General-purpose file handling library for Niotso - libfar.h - Copyright (c) 2011 Niotso Project + far.h - Copyright (c) 2011 Niotso Project Author(s): Fatbag Permission to use, copy, modify, and/or distribute this software for any diff --git a/Libraries/FileHandler/far/farextract.c b/Libraries/FileHandler/far/farextract.c index d4a29cf..237b76e 100644 --- a/Libraries/FileHandler/far/farextract.c +++ b/Libraries/FileHandler/far/farextract.c @@ -21,7 +21,6 @@ #include #include #include -#include "config.h" #include "far.h" enum { diff --git a/Libraries/FileHandler/far/refpack_dec.c b/Libraries/FileHandler/far/refpack_dec.c index 3f48b2c..5ddd6ac 100644 --- a/Libraries/FileHandler/far/refpack_dec.c +++ b/Libraries/FileHandler/far/refpack_dec.c @@ -159,5 +159,5 @@ int RefPackDecompress(const uint8_t *__restrict CompressedData, size_t Compresse } } - return (!stopflag || CompressedSize || DecompressedSize) ? 0 : 1; + return (stopflag && !CompressedSize && !DecompressedSize); } \ No newline at end of file diff --git a/Libraries/FileHandler/iff/iff.c b/Libraries/FileHandler/iff/iff.c index 04e53c3..441e11f 100644 --- a/Libraries/FileHandler/iff/iff.c +++ b/Libraries/FileHandler/iff/iff.c @@ -102,18 +102,16 @@ void (* const iff_free_function[])(void*) = { ** API public functions */ -IFFFile * iff_create() +int iff_create(IFFFile * IFFFileInfo) { - IFFFile *ptr = calloc(1, sizeof(IFFFile)); - if(ptr == NULL) return NULL; + memset(IFFFileInfo, 0, sizeof(IFFFile)); - ptr->Chunks = calloc(1, sizeof(IFFChunk)); - if(ptr->Chunks == NULL){ - free(ptr); - return NULL; - } - ptr->SizeAllocated = sizeof(IFFChunk); - return ptr; + IFFFileInfo->Chunks = calloc(1, sizeof(IFFChunk)); + if(IFFFileInfo->Chunks == NULL) + return 0; + IFFFileInfo->SizeAllocated = sizeof(IFFChunk); + + return 1; } int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned FileSize) @@ -250,7 +248,4 @@ void iff_delete(IFFFile * IFFFileInfo){ free(IFFFileInfo->ResourceMap->FormattedData); free(IFFFileInfo->ResourceMap); } - - free(IFFFileInfo); - IFFFileInfo = NULL; } \ No newline at end of file diff --git a/Libraries/FileHandler/iff/iff.h b/Libraries/FileHandler/iff/iff.h index 645159d..d231a68 100644 --- a/Libraries/FileHandler/iff/iff.h +++ b/Libraries/FileHandler/iff/iff.h @@ -345,7 +345,7 @@ extern "C" { ** IFF file functions */ -IFFFile * iff_create(); +int iff_create(IFFFile * IFFFileInfo); int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned FileSize); IFFChunk * iff_add_chunk(IFFFile * IFFFileInfo); diff --git a/Libraries/FileHandler/iff/iffexport.c b/Libraries/FileHandler/iff/iffexport.c index 3e79066..98e6d6c 100644 --- a/Libraries/FileHandler/iff/iffexport.c +++ b/Libraries/FileHandler/iff/iffexport.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]){ clock_t BeginningTime; unsigned chunkcount, chunk; unsigned exported = 0; - IFFFile * IFFFileInfo; + IFFFile IFFFileInfo; IFFChunk * ChunkData; if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){ @@ -95,12 +95,11 @@ int main(int argc, char *argv[]){ ** Load header information */ - IFFFileInfo = iff_create(); - if(IFFFileInfo == NULL){ + if(!iff_create(&IFFFileInfo)){ printf("%sMemory for this file could not be allocated.", "iffexport: error: "); return -1; } - if(!iff_read_header(IFFFileInfo, IFFData, FileSize)){ + if(!iff_read_header(&IFFFileInfo, IFFData, FileSize)){ printf("%sNot a valid IFF file.", "iffexport: error: "); return -1; } @@ -109,19 +108,19 @@ int main(int argc, char *argv[]){ ** Load entry information */ - if(!iff_enumerate_chunks(IFFFileInfo, IFFData+64, FileSize-64)){ + if(!iff_enumerate_chunks(&IFFFileInfo, IFFData+64, FileSize-64)){ printf("%sChunk data is corrupt.", "iffexport: error: "); return -1; } - chunkcount = IFFFileInfo->ChunkCount; + chunkcount = IFFFileInfo.ChunkCount; printf("This IFF file contains %u chunks.\n\nExporting\n", chunkcount); BeginningTime = clock(); /**** ** Extract each entry */ - for(chunk = 1, ChunkData = IFFFileInfo->Chunks; chunk <= chunkcount; chunk++, ChunkData++){ + for(chunk = 1, ChunkData = IFFFileInfo.Chunks; chunk <= chunkcount; chunk++, ChunkData++){ char name[256], destination[256]; char filter[] = "\\/:*?\"<>|"; int i; diff --git a/Server/CMakeLists.txt b/Server/CMakeLists.txt index e69de29..46c3647 100644 --- a/Server/CMakeLists.txt +++ b/Server/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 2.6) +project(NiotsoServer) + +if(WIN32) +else() + set(NIOTSOSERVER_SOURCES + Server.cpp + ) + add_executable(niotsod-vanilla ${NIOTSOSERVER_SOURCES}) + target_link_libraries(niotsod-vanilla) +endif() diff --git a/Server/Server.cpp b/Server/Server.cpp index 028bfe5..7542b0c 100644 --- a/Server/Server.cpp +++ b/Server/Server.cpp @@ -16,4 +16,161 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -*/ \ No newline at end of file +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Server.hpp" + +#define SHUTDOWN(X) do { syslog(LOG_INFO, " Could not recover from errors. Shutting down."); \ + exitval = EXIT_FAILURE; goto X; } while(0) +#define SHUTDOWN_M(X, Y) do { syslog(LOG_ERR, " %s (%s)", X, strerror(errno)); \ + SHUTDOWN(Y); } while(0) + +//IPV6_V6ONLY + +static void term(int) +{ +} + +int main(int, char **) +{ + const pid_t pid = fork(); + if(pid < 0){ + const char *msg1 = " Failed to create child process (%s).", *msg2 = strerror(errno); + openlog(SERVER_NAME, 0, LOG_DAEMON); + syslog(LOG_ERR, msg1, msg2); + closelog(); + fprintf(stderr, msg1, msg2); + fprintf(stderr, "\n"); + return EXIT_FAILURE; + }else if(pid > 0) + return EXIT_SUCCESS; + + int exitval = EXIT_SUCCESS, sockfd, epollfd; + { //New scope required for error handling + int ret; + FILE * fd; + + umask(0); + + openlog(SERVER_NAME, LOG_PID, LOG_DAEMON); + + if(setsid() < 0) + SHUTDOWN_M("Failed to create session", close_msg); + + if(chdir(CONFIG_DIR) < 0) + SHUTDOWN_M("Failed to change into \""CONFIG_DIR"\"", close_msg); + + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + + struct sigaction sigact; + sigact.sa_handler = term; + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigaction(SIGTERM, &sigact, NULL); + sigaction(SIGINT, &sigact, NULL); + + syslog(LOG_INFO, " "SERVER_NAME" (version "VERSIONSTR") is starting..."); + + fd = fopen("network.conf", "r"); + if(!fd) + SHUTDOWN_M("Failed to open \""CONFIG_DIR"/network.conf\"", close_msg); + unsigned int port = 0; + ret = fscanf(fd, "%u", &port); + fclose(fd); + if(ret < 0) + SHUTDOWN_M("Failed to read \""CONFIG_DIR"/network.conf\"", close_msg); + if(port > 65535){ + syslog(LOG_ERR, " Invalid port '%u' specified in \""CONFIG_DIR"/network.conf\".", port); + SHUTDOWN(close_msg); + } + + sockfd = socket(AF_INET6, SOCK_DGRAM, 0); + if(sockfd < 0) + SHUTDOWN_M("Failed to open socket", close_msg); + + int flags = fcntl(sockfd, F_GETFL, 0); + if(flags < 0) + SHUTDOWN_M("Failed to read socket flags", close_socket); + if(fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) < 0) + SHUTDOWN_M("Failed to set socket flags", close_socket); + + sockaddr_in6 server_addr, client_addr; + memset(&server_addr, 0, sizeof(sockaddr_in6)); + memset(&client_addr, 0, sizeof(sockaddr_in6)); + server_addr.sin6_family = AF_INET6; + server_addr.sin6_port = htons((uint16_t) port); + server_addr.sin6_addr = in6addr_any; + client_addr.sin6_family = AF_INET6; + client_addr.sin6_addr = in6addr_any; + + if(bind(sockfd, (const sockaddr*) &server_addr, sizeof(sockaddr_in6)) < 0) + SHUTDOWN_M("Failed to bind to socket", close_socket); + + epollfd = epoll_create(1); + if(epollfd < 0) + SHUTDOWN_M("Failed to create an epoll handle", close_socket); + + epoll_event epev[1]; + epev[0].events = EPOLLIN | EPOLLPRI; + epev[0].data.fd = sockfd; + if(epoll_ctl(epollfd, EPOLL_CTL_ADD, sockfd, epev) < 0) + SHUTDOWN_M("Failed to register the socket to the epoll handle", close_epoll); + + //Now that we're running, stop being terminate-on-failure-happy + syslog(LOG_INFO, " Running."); + + /**** + ** Listen loop + */ + + int eventcount; + while((eventcount = epoll_wait(epollfd, epev, 1, -1)) >= 0){ + if(eventcount == 0) + continue; + else if(epev[0].events & EPOLLERR) + SHUTDOWN_M("Socket closed unexpectedly with EPOLLERR", close_epoll); + else if(epev[0].events & EPOLLHUP) + SHUTDOWN_M("Socket closed unexpectedly with EPOLLHUP", close_epoll); + else if(!(epev[0].events & EPOLLIN) && !(epev[0].events & EPOLLPRI)) + continue; + + uint8_t packetdata[1500]; + socklen_t addrlen = sizeof(sockaddr_in6); + ssize_t packetsize = recvfrom(epev[0].data.fd, packetdata, 1500, 0, (sockaddr*) &client_addr, &addrlen); + if(packetsize < 0){ + if(errno == EINTR || errno == ECONNRESET || errno == ENOTCONN || errno == ETIMEDOUT) + continue; + + SHUTDOWN_M("Socket closed unexpectedly on call to recvfrom", close_epoll); + } + + //Pass the packet down (even zero-length packets might be meaningful in the protocol) + //... + } + + /**** + ** Shutdown + */ + + } + close_epoll: close(epollfd); + close_socket: close(sockfd); + close_msg: syslog(LOG_INFO, " Shut down gracefully."); + closelog(); + + return exitval; +} diff --git a/Server/Server.hpp b/Server/Server.hpp new file mode 100644 index 0000000..77e83f9 --- /dev/null +++ b/Server/Server.hpp @@ -0,0 +1,24 @@ +/* + Niotso Server - Niotso daemon based on PostgreSQL + Server.hpp + Copyright (c) 2012 Niotso Project + Author(s): Fatbag + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#define SERVER_NAME "niotsod-vanilla" +#define CONFIG_DIR "/etc/"SERVER_NAME + +#define VERSIONSTR "0.0.0" diff --git a/Tools/iff2html/iff2html.c b/Tools/iff2html/iff2html.c index 5661c6d..2080866 100644 --- a/Tools/iff2html/iff2html.c +++ b/Tools/iff2html/iff2html.c @@ -60,7 +60,7 @@ int main(int argc, char *argv[]){ struct MD5Context md5c; unsigned char digest[16]; uint8_t * IFFData; - IFFFile * IFFFileInfo; + IFFFile IFFFileInfo; IFFChunk * ChunkData; if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){ @@ -139,12 +139,11 @@ int main(int argc, char *argv[]){ ** Load header information */ - IFFFileInfo = iff_create(); - if(IFFFileInfo == NULL){ + if(!iff_create(&IFFFileInfo)){ printf("%sMemory for this file could not be allocated.", "iff2html: error: "); return -1; } - if(!iff_read_header(IFFFileInfo, IFFData, FileSize)){ + if(!iff_read_header(&IFFFileInfo, IFFData, FileSize)){ printf("%sNot a valid IFF file.", "iff2html: error: "); return -1; } @@ -153,7 +152,7 @@ int main(int argc, char *argv[]){ ** Load entry information */ - if(!iff_enumerate_chunks(IFFFileInfo, IFFData+64, FileSize-64)){ + if(!iff_enumerate_chunks(&IFFFileInfo, IFFData+64, FileSize-64)){ printf("%sChunk data is corrupt.", "iff2html: error: "); return -1; } @@ -164,7 +163,7 @@ int main(int argc, char *argv[]){ MD5Final(digest, &md5c); free(IFFData); - for(c = 0, ChunkData = IFFFileInfo->Chunks; c < IFFFileInfo->ChunkCount; c++, ChunkData++) + for(c = 0, ChunkData = IFFFileInfo.Chunks; c < IFFFileInfo.ChunkCount; c++, ChunkData++) iff_parse_chunk(ChunkData, ChunkData->Data); /**** @@ -292,9 +291,9 @@ int main(int argc, char *argv[]){ fprintf(hFile, "\n"); fprintf(hFile, "
Dumped by iff2html.
\n"); fprintf(hFile, "\n"); - fprintf(hFile, "
Contents – %u chunks
\n", IFFFileInfo->ChunkCount); + fprintf(hFile, "
Contents – %u chunks
\n", IFFFileInfo.ChunkCount); fprintf(hFile, "
    \n"); - for(c=1, ChunkData = IFFFileInfo->Chunks; c <= IFFFileInfo->ChunkCount; c++, ChunkData++) + for(c=1, ChunkData = IFFFileInfo.Chunks; c <= IFFFileInfo.ChunkCount; c++, ChunkData++) fprintf(hFile, "
  • %u [%s] (%.4X)%s%s
  • \n", c, ChunkData->ChunkID, c, ChunkData->Type, ChunkData->ChunkID, (ChunkData->Label[0] != 0x00) ? " – " : "", ChunkData->Label); @@ -302,7 +301,7 @@ int main(int argc, char *argv[]){ fprintf(hFile, "
\n"); fprintf(hFile, "\n"); - for(c=0, ChunkData = IFFFileInfo->Chunks; c < IFFFileInfo->ChunkCount; c++, ChunkData++){ + for(c=0, ChunkData = IFFFileInfo.Chunks; c < IFFFileInfo.ChunkCount; c++, ChunkData++){ fprintf(hFile, "

%u [%s] (%.4X)%s%s (Jump)

\n", c+1, ChunkData->ChunkID, c+1, ChunkData->Type, ChunkData->ChunkID, (ChunkData->Label[0] != 0x00) ? " – " : "", ChunkData->Label, @@ -555,9 +554,9 @@ int main(int argc, char *argv[]){ fprintf(hFile, "\n"); if(SpriteList->PaletteID < 0xFFFF){ - Palette = iff_find_chunk(IFFFileInfo, "PALT", SpriteList->PaletteID); - if(!Palette || !Palette->FormattedData) Palette = iff_find_chunk(IFFFileInfo, "PALT", ChunkData->ChunkID); - if(!Palette || !Palette->FormattedData) Palette = iff_find_chunk(IFFFileInfo, "PALT", -1); + Palette = iff_find_chunk(&IFFFileInfo, "PALT", SpriteList->PaletteID); + if(!Palette || !Palette->FormattedData) Palette = iff_find_chunk(&IFFFileInfo, "PALT", ChunkData->ChunkID); + if(!Palette || !Palette->FormattedData) Palette = iff_find_chunk(&IFFFileInfo, "PALT", -1); } if(!Palette || !Palette->FormattedData){ memset(&BlankPalette, 0, sizeof(IFFPalette)); @@ -697,7 +696,7 @@ int main(int argc, char *argv[]){ fprintf(hFile, "
\n\n"); } - iff_delete(IFFFileInfo); + iff_delete(&IFFFileInfo); fprintf(hFile, "
This page was generated by the use of iff2html.\n"); diff --git a/Tools/tsoscan/stats.c b/Tools/tsoscan/stats.c index 76792c0..fa35f0b 100644 --- a/Tools/tsoscan/stats.c +++ b/Tools/tsoscan/stats.c @@ -21,11 +21,9 @@ #include #include "tsoscan.h" -IFFStats* stats_create(){ - IFFStats *stats = calloc(1, sizeof(IFFStats)); - if (stats == NULL) return NULL; +int stats_create(IFFStats *stats){ stats->AverageChunkCount = -1; - return stats; + return 0; } int stats_version_increment(IFFStats *stats, char *type, unsigned version){ @@ -107,5 +105,4 @@ void stats_delete(IFFStats *stats){ free(stats->ChunkTypes[i].Versions); free(stats->ChunkTypes); } - free(stats); } \ No newline at end of file diff --git a/Tools/tsoscan/tsoscan.c b/Tools/tsoscan/tsoscan.c index 26c6e1e..cc3f6a4 100644 --- a/Tools/tsoscan/tsoscan.c +++ b/Tools/tsoscan/tsoscan.c @@ -39,10 +39,10 @@ int main(int argc, char *argv[]){ CommandLineArgs *CmdArgs; unsigned i, version, FileCount = 0; char **Files = NULL; - IFFStats *Stats = stats_create(); + IFFStats Stats; FILE *OutFile; - if(Stats == NULL){ + if(!stats_create(&Stats)){ printf("%sUnable to allocate enough memory.\n", TSOSCAN_ERROR); return -1; } @@ -114,13 +114,11 @@ int main(int argc, char *argv[]){ ** Load and parse IFF files */ - Stats->AverageChunkCount = -1; - for(i=0; iFileCount++; - if(Stats->AverageChunkCount == -1){ - Stats->AverageChunkCount = iff->ChunkCount; + Stats.FileCount++; + if(Stats.AverageChunkCount == -1){ + Stats.AverageChunkCount = iff.ChunkCount; }else{ - Stats->AverageChunkCount += iff->ChunkCount; - Stats->AverageChunkCount /= 2; + Stats.AverageChunkCount += iff.ChunkCount; + Stats.AverageChunkCount /= 2; } - for(ChunkIndex = 0, ChunkData = iff->Chunks; ChunkIndex < iff->ChunkCount; ChunkIndex++, ChunkData++){ + for(ChunkIndex = 0, ChunkData = iff.Chunks; ChunkIndex < iff.ChunkCount; ChunkIndex++, ChunkData++){ unsigned version = stats_get_version(ChunkData->Type, ChunkData->Data); - if(!stats_version_increment(Stats, ChunkData->Type, version)){ + if(!stats_version_increment(&Stats, ChunkData->Type, version)){ printf("%sUnable to allocate enough memory.\n", TSOSCAN_ERROR); return -1; } } - iff_delete(iff); + iff_delete(&iff); } /**** @@ -274,23 +271,23 @@ int main(int argc, char *argv[]){ fprintf(OutFile, "

IFF Chunk Statistics (tsostats)

\n"); fprintf(OutFile, "
\n"); fprintf(OutFile, "\n"); - fprintf(OutFile, "\n", Stats->FileCount); - fprintf(OutFile, "\n", Stats->AverageChunkCount); + fprintf(OutFile, "\n", Stats.FileCount); + fprintf(OutFile, "\n", Stats.AverageChunkCount); fprintf(OutFile, "
Number of IFF files:%u
Average chunk count:%.1f
Number of IFF files:%u
Average chunk count:%.1f
\n"); fprintf(OutFile, "
\n"); - fprintf(OutFile, "
Contents – %u chunk types
\n", Stats->ChunkTypeCount); + fprintf(OutFile, "
Contents – %u chunk types
\n", Stats.ChunkTypeCount); fprintf(OutFile, "
    \n"); - for(i=0; iChunkTypeCount; i++) - fprintf(OutFile, "
  • %u %s
  • \n", i, i+1, Stats->ChunkTypes[i].Type); + for(i=0; i%u %s\n", i, i+1, Stats.ChunkTypes[i].Type); fprintf(OutFile, "
\n"); fprintf(OutFile, "
\n"); fprintf(OutFile, "\n"); - for(i=0; iChunkTypeCount; i++){ - ChunkStats *chunk = Stats->ChunkTypes+i; + for(i=0; i%u %s (Jump)\n", i, i+1, Stats->ChunkTypes[i].Type, i); + fprintf(OutFile, "

%u %s (Jump)

\n", i, i+1, Stats.ChunkTypes[i].Type, i); fprintf(OutFile, "
\n"); fprintf(OutFile, "\n"); @@ -324,8 +321,8 @@ int main(int argc, char *argv[]){ fprintf(OutFile, ""); fclose(OutFile); - printf("Generated statistics based on %u IFF files.\n", Stats->FileCount); + printf("Generated statistics based on %u IFF files.\n", Stats.FileCount); cmd_delete(CmdArgs); - stats_delete(Stats); + stats_delete(&Stats); return 0; } \ No newline at end of file diff --git a/Tools/tsoscan/tsoscan.h b/Tools/tsoscan/tsoscan.h index 5f63eac..4351496 100644 --- a/Tools/tsoscan/tsoscan.h +++ b/Tools/tsoscan/tsoscan.h @@ -59,7 +59,7 @@ typedef struct IFFStats_s CommandLineArgs* cmd_parse_args(int argc, char *argv[]); void cmd_delete(CommandLineArgs *args); -IFFStats* stats_create(); +int stats_create(IFFStats *stats); int stats_version_increment(IFFStats *stats, char *type, unsigned version); unsigned stats_get_version(char *type, uint8_t *data); void stats_delete(IFFStats *stats); \ No newline at end of file diff --git a/update-libraries.mk b/update-libraries.mk index 7a2fad3..3172ecb 100644 --- a/update-libraries.mk +++ b/update-libraries.mk @@ -1,8 +1,9 @@ LIBS = freetype libjpeg-turbo libmpg123 libpng libpq zlib -all: .PHONY ../_deps/$(LIBS) +all: .PHONY $(addprefix ../_deps/, $(LIBS)) .PHONY: $(LIBS) - wget -N http://niotso.org/pub/environment/windows/lib/$<.tar.xz -../_deps/%: %.tar.xz +$(LIBS): + wget -N http://niotso.org/pub/environment/windows/lib/$@.tar.xz +../_deps/%: ../_deps/%.tar.xz ifdef CMD del /F /S /Q "$@" else