Fixed the update-libraries script (thanks to Anderson Souza) and added a basic Linux daemon for the server

This commit is contained in:
Fatbag 2012-11-11 17:10:53 -06:00
parent bb904c4698
commit 5444c9aea6
19 changed files with 260 additions and 84 deletions

View file

@ -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;

View file

@ -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

View file

@ -21,7 +21,6 @@
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include "config.h"
#include "far.h"
enum {

View file

@ -159,5 +159,5 @@ int RefPackDecompress(const uint8_t *__restrict CompressedData, size_t Compresse
}
}
return (!stopflag || CompressedSize || DecompressedSize) ? 0 : 1;
return (stopflag && !CompressedSize && !DecompressedSize);
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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;