mirror of
https://github.com/simtactics/niotso.git
synced 2025-07-04 13:47:05 -04:00
Fixed the update-libraries script (thanks to Anderson Souza) and added a basic Linux daemon for the server
This commit is contained in:
parent
bb904c4698
commit
5444c9aea6
19 changed files with 260 additions and 84 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
FileHandler - General-purpose file handling library for Niotso
|
||||
libfar.c - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||
far.c - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
FileHandler - General-purpose file handling library for Niotso
|
||||
libfar.h - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||
far.h - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include "config.h"
|
||||
#include "far.h"
|
||||
|
||||
enum {
|
||||
|
|
|
@ -159,5 +159,5 @@ int RefPackDecompress(const uint8_t *__restrict CompressedData, size_t Compresse
|
|||
}
|
||||
}
|
||||
|
||||
return (!stopflag || CompressedSize || DecompressedSize) ? 0 : 1;
|
||||
return (stopflag && !CompressedSize && !DecompressedSize);
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue