author | ecalot
<ecalot> 2005-06-08 23:52:20 UTC |
committer | ecalot
<ecalot> 2005-06-08 23:52:20 UTC |
parent | 4bcc62618043782bc7c25715b8c4ea92ee6ae696 |
PR/src/lib/actions/import.c | +0 | -11 |
PR/src/lib/layers/dat.c | +7 | -20 |
diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c index a6ee7ba..126a914 100644 --- a/PR/src/lib/actions/import.c +++ b/PR/src/lib/actions/import.c @@ -78,17 +78,6 @@ int mAddCompiledFileToDatFile(tResource* res,const char* vFile) { return 1; } -/* TODO: code the free resources into reslist.c that includes the pointed char*'s */ -#define freeResources \ -for (id=0;id<MAX_RES_COUNT;id++) {\ - if (r[id]!=NULL) {\ - freeAllocation(r[id]->desc);\ - freeAllocation(r[id]->name);\ - freeAllocation(r[id]->path);\ - free(r[id]);\ - }\ -} - /***************************************************************\ | M A I N F U N C T I O N | \***************************************************************/ diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c index 95521d5..85c3d67 100644 --- a/PR/src/lib/layers/dat.c +++ b/PR/src/lib/layers/dat.c @@ -142,7 +142,7 @@ int dat_cursorMoveId(tIndexCursor* r, tResourceId id) { /* the same index */ do { if (strcmp(r->slaveIndexName,id.index)) return 0; /* in case we are passed */ - if (array2short(r->currentRecord)==id.value) return 1; /* found! */ /* TODO: check for segmentation faults here */ + if (array2short(r->currentRecord)==id.value) return 1; /* found! */ } while (dat_cursorNext(r)); return 0; /* id not found */ } @@ -322,10 +322,7 @@ int mReadBeginDatFile(unsigned short int *numberOfItems,const char* vFiledat){ return 0; } -int mReadFileInDatFileId(tResource* res) { - if (!dat_cursorMoveId(&readIndexCursor,res->id)) return 0; /* 0 means index not found */ - /* TODO: use a function for common parts */ - +void dat_readRes(tResource* res) { /* for each archived file the index is read */ res->id.value= dat_readCursorGetId (readIndexCursor); strncpy(res->id.index,dat_readCursorGetIndexName (readIndexCursor),5); @@ -333,30 +330,20 @@ int mReadFileInDatFileId(tResource* res) { res->size= dat_readCursorGetSize (readIndexCursor); res->flags= dat_readCursorGetFlags (readIndexCursor); - /* if (offset>indexOffset) return -1; * a resourse offset is allways before the index offset TODO: move this check to detect pop version*/ res->size++; /* add the checksum */ res->data=readDatFile+res->offset; +} +int mReadFileInDatFileId(tResource* res) { + if (!dat_cursorMoveId(&readIndexCursor,res->id)) return 0; /* 0 means index not found */ + dat_readRes(res); return 1; - } int mReadFileInDatFile(tResource* res, int k) { - if (!dat_cursorMove(&readIndexCursor,k)) return 0; /* 0 means out of range */ - - /* for each archived file the index is read */ - res->id.value= dat_readCursorGetId (readIndexCursor); - strncpy(res->id.index,dat_readCursorGetIndexName (readIndexCursor),5); - res->offset= dat_readCursorGetOffset (readIndexCursor); - res->size= dat_readCursorGetSize (readIndexCursor); - res->flags= dat_readCursorGetFlags (readIndexCursor); - - /* if (offset>indexOffset) return -1; * a resourse offset is allways before the index offset TODO: move this check to detect pop version*/ - res->size++; /* add the checksum */ - res->data=readDatFile+res->offset; - + dat_readRes(res); return 1; }