X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=pak.c;h=35e605ca59c5aae11b553ecf91e6900ee4ae9ddf;hp=2ab417dfbbe61704f9f251bffb6dc83b5557068d;hb=9a6316221c88250d247b744322d6c690ccf5eec5;hpb=160e7cf7eebd7fa173fb739aca00143097a3518b diff --git a/pak.c b/pak.c index 2ab417d..35e605c 100644 --- a/pak.c +++ b/pak.c @@ -20,13 +20,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include +#include + #include "gmqcc.h" /* * The PAK format uses a FOURCC concept for storing the magic ident within * the header as a uint32_t. */ -#define PAK_FOURCC ((uint32_t)(('P' | ('A' << 8) | ('C' << 16) | ('K' << 24)))) +#define PAK_FOURCC ((uint32_t)(((uint8_t)'P'|((uint8_t)'A'<<8)|((uint8_t)'C'<<16)|((uint8_t)'K'<<24)))) typedef struct { uint32_t magic; /* "PACK" */ @@ -95,14 +98,14 @@ static void pak_tree_build(const char *entry) { memset(pathsplit, 0, 56); - strncpy(directory, entry, 56); + util_strncpy(directory, entry, 56); for (itr = 0; (token = pak_tree_sep(&directory, "/")) != NULL; itr++) { elements[itr] = token; } for (jtr = 0; jtr < itr - 1; jtr++) { - strcat(pathsplit, elements[jtr]); - strcat(pathsplit, "/"); + util_strcat(pathsplit, elements[jtr]); + util_strcat(pathsplit, "/"); if (fs_dir_make(pathsplit)) { mem_d(pathsplit); @@ -222,7 +225,7 @@ static pak_file_t *pak_open_write(const char *file) { return pak; } -pak_file_t *pak_open(const char *file, const char *mode) { +static pak_file_t *pak_open(const char *file, const char *mode) { if (!file || !mode) return NULL; @@ -234,7 +237,7 @@ pak_file_t *pak_open(const char *file, const char *mode) { return NULL; } -bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) { +static bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) { size_t itr; if (!pak || !file) @@ -259,7 +262,7 @@ bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) { /* * Extraction abilities. These work as you expect them to. */ -bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) { +static bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) { pak_directory_t *dir = NULL; unsigned char *dat = NULL; char *local = NULL; @@ -310,7 +313,7 @@ bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) { return true; } -bool pak_extract_all(pak_file_t *pak, const char *dir) { +static bool pak_extract_all(pak_file_t *pak, const char *dir) { size_t itr; if (!fs_dir_make(dir)) @@ -328,7 +331,7 @@ bool pak_extract_all(pak_file_t *pak, const char *dir) { * Insertion functions (the opposite of extraction). Yes for generating * PAKs. */ -bool pak_insert_one(pak_file_t *pak, const char *file) { +static bool pak_insert_one(pak_file_t *pak, const char *file) { pak_directory_t dir; unsigned char *dat; FILE *fp; @@ -364,7 +367,7 @@ bool pak_insert_one(pak_file_t *pak, const char *file) { return false; } - strncpy(dir.name, file, strlen(file)); + util_strncpy(dir.name, file, strlen(file)); /* * Allocate some memory for loading in the data that will be @@ -413,7 +416,7 @@ bool pak_insert_all(pak_file_t *pak, const char *dir) { return true; } -bool pak_close(pak_file_t *pak) { +static bool pak_close(pak_file_t *pak) { size_t itr; if (!pak) @@ -552,7 +555,8 @@ int main(int argc, char **argv) { /* not possible */ pak_close(pak); vec_free(files); - util_meminfo(); + stat_info(); + return EXIT_SUCCESS; } @@ -575,7 +579,6 @@ int main(int argc, char **argv) { pak_close(pak); vec_free(files); - - util_meminfo(); + stat_info(); return EXIT_SUCCESS; }