author | ecalot
<ecalot> 2006-07-16 23:26:44 UTC |
committer | ecalot
<ecalot> 2006-07-16 23:26:44 UTC |
parent | 8459b96a73779da6268a296492a997041fbcec66 |
PR/src/include/common.h | +2 | -0 |
PR/src/include/other.h | +6 | -2 |
PR/src/include/plv.h | +1 | -1 |
PR/src/lib/formats/plv.c | +3 | -2 |
PR/src/lib/object/level/level_common.c | +12 | -10 |
diff --git a/PR/src/include/common.h b/PR/src/include/common.h index 77c9e9a..4dec51e 100644 --- a/PR/src/include/common.h +++ b/PR/src/include/common.h @@ -236,6 +236,8 @@ PARSING_OPTRAW\ #define PR_RESULT_WAV_UNSUPPORTED_BITRATE -28 #define PR_RESULT_WAV_UNSUPPORTED_SAMPLERATE -29 #define PR_RESULT_WAV_UNSUPPORTED_STEREO -30 +#define PR_RESULT_PLV_WRONG_FILE_FORMAT -33 +#define PR_RESULT_MID_WRONG_FILE_FORMAT -34 #define PR_RESULT_XML_AND_DAT_FORMAT_DO_NOT_MATCH -25 #endif diff --git a/PR/src/include/other.h b/PR/src/include/other.h index 6f8f12e..ba9d116 100644 --- a/PR/src/include/other.h +++ b/PR/src/include/other.h @@ -46,11 +46,15 @@ int objectOtherBinarySet(void* o,tResource* res); #define objectLevelPop2Create(a,b,c,d,e,f,g) objectLevelCreate(a,b,c,d,e,f,g) #define objectLevelPop1Write(a,b,c,d) objectLevelWrite(a,b,c,d,1) #define objectLevelPop2Write(a,b,c,d) objectLevelWrite(a,b,c,d,2) +#define objectLevelPop1Read(a,b) objectLevelRead(a,b,1); +#define objectLevelPop2Read(a,b) objectLevelRead(a,b,2); +#define objectLevelPop1Set(a,b) objectLevelSet(a,b); +#define objectLevelPop2Set(a,b) objectLevelSet(a,b); void* objectLevelCreate(tBinary content,int number,const char* datfile,const char* name,const char* desc,const char* datAuthor,int *error); int objectLevelWrite(void* o, const char* file, int optionflag, const char* backupExtension,int popVersion); +void* objectLevelRead(const char* file,int *result, int popversion); -void* objectLevelPop1Read(const char* file,int *result); -int objectLevelPop1Set(void* o,tResource* res); +int objectLevelSet(void* o,tResource* res); #endif diff --git a/PR/src/include/plv.h b/PR/src/include/plv.h index 053aa5c..77ee98a 100644 --- a/PR/src/include/plv.h +++ b/PR/src/include/plv.h @@ -67,7 +67,7 @@ int mFormatExportPlv(const unsigned char* data, const char *vFileext,unsigned lo int writePlv(const char* file, tBinary content, int popversion, const char* datfile, int level, const char* filename, const char* desc, const char* title, const char* vDatAuthor, int optionflag,const char* backupExtension); -int readPlv(const char* file, tBinary* content, int *number, char** datfile, char** name, char** desc, char** datAuthor); +int readPlv(const char* file, tBinary* content, int *number, char** datfile, char** name, char** desc, char** datAuthor, int* popversion); /* Weekdays and months */ #define DATE_WEEKDAYS "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat" diff --git a/PR/src/lib/formats/plv.c b/PR/src/lib/formats/plv.c index 720d9c0..76c1847 100644 --- a/PR/src/lib/formats/plv.c +++ b/PR/src/lib/formats/plv.c @@ -172,7 +172,7 @@ int writePlv(const char* file, tBinary content, int popversion, const char* datf extern FILE* outputStream; -int readPlv(const char* file, tBinary* content, int *number, char** datfile, char** name, char** desc, char** datAuthor) { +int readPlv(const char* file, tBinary* content, int *number, char** datfile, char** name, char** desc, char** datAuthor, int* ppopversion) { /* * PLV 1 SPECS: @@ -220,7 +220,7 @@ int readPlv(const char* file, tBinary* content, int *number, char** datfile, cha /* Check data */ if (!ok) { fclose(fd); - return PR_RESULT_ERR_FILE_NOT_READ_ACCESS; /* TODO: use a bad format code */ + return PR_RESULT_PLV_WRONG_FILE_FORMAT; } /* Read data */ @@ -237,6 +237,7 @@ int readPlv(const char* file, tBinary* content, int *number, char** datfile, cha *name=NULL; *desc=NULL; *datAuthor=NULL; + *ppopversion=popVersion; fclose(fd); diff --git a/PR/src/lib/object/level/level_common.c b/PR/src/lib/object/level/level_common.c index 698f398..a477f42 100644 --- a/PR/src/lib/object/level/level_common.c +++ b/PR/src/lib/object/level/level_common.c @@ -54,14 +54,14 @@ typedef struct { char* name; char* desc; char* datAuthor; -}tPop1Level; +}tPopLevel; void* objectLevelCreate(tBinary content,int number,const char* datfile,const char* name,const char* desc,const char* datAuthor,int *error) { - tPop1Level* r; + tPopLevel* r; *error=PR_RESULT_SUCCESS; /*TODO: fix the original file name path (lala///lele/demo.plv--> demo.plv) */ - r=(tPop1Level*)malloc(sizeof(tPop1Level)); + r=(tPopLevel*)malloc(sizeof(tPopLevel)); r->content=content; r->number=number; r->datfile=(char*)datfile; @@ -72,16 +72,18 @@ void* objectLevelCreate(tBinary content,int number,const char* datfile,const cha } int objectLevelWrite(void* o, const char* file, int optionflag, const char* backupExtension,int version) { - tPop1Level* b=o; + tPopLevel* b=o; return writePlv(file,b->content,version,b->datfile,b->number,getFileNameFromPath(file),b->desc,b->name,b->datAuthor,optionflag,backupExtension); } -void* objectLevelPop1Read(const char* file,int *result) { /* TODO: generalize to POP2 */ - tPop1Level* r; +/*void* objectLevelPop1Read(const char* file,int *result,int popversion) { * TODO: generalize to POP2 */ +void* objectLevelRead(const char* file,int *result,int popversion) { + tPopLevel* r; + int version; - r=(tPop1Level*)malloc(sizeof(tPop1Level)); + r=(tPopLevel*)malloc(sizeof(tPopLevel)); - *result=readPlv(file,&r->content,&r->number,&r->datfile,&r->name,&r->desc,&r->datAuthor); + *result=readPlv(file,&r->content,&r->number,&r->datfile,&r->name,&r->desc,&r->datAuthor,&version); if (*result!=PR_RESULT_SUCCESS) { free(r); @@ -91,8 +93,8 @@ void* objectLevelPop1Read(const char* file,int *result) { /* TODO: generalize to return (void*)r; } -int objectLevelPop1Set(void* o,tResource* res) { - tPop1Level* r=o; +int objectLevelSet(void* o,tResource* res) { + tPopLevel* r=o; res->content=r->content; mWriteFileInDatFile(res); return PR_RESULT_SUCCESS;