From: Jan P. <pa...@pi...> - 2005-04-03 18:08:02
|
Hi Lutz, > On Wed, 2005-03-30 at 19:23 +0200, Jan Patera wrote: >> should I understand it as you are strictly against completion codes >> returned by exif functions? > > No, not at all. All I wanted to do is to make people aware of the limit= s > of error codes. > > Let's say we define EXIF_RESULT_OK, EXIF_RESULT_SOMEWHAT_OK and > EXIF_RESULT_NOT_OK. What code should libexif return if it encounters an > unknown tag or a wrong format on loading? EXIF_RESULT_UNKNOWN_TAG and EXIF_RESULT_WRONG_TAG_FORMAT, EXIF_RESULT_WRONG_SOMETHING_FORMAT and EXIF_RESULT_WRONG_SOMETHING_ELSE_FORMAT. Depending on the situation. There would be as many values as needed. The values could be like SCODE/HRESULT in COM and similar interfaces: some bits would indicate success/warning/error and some bits what actually happened. There would be macros for simple checks if (fatal) error or warning occured. // Values are 32 bit values layed out as follows: // // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // +---+-+-+-----------------------+-------------------------------+ // |Sev| | Facility | Code | // +---+-+-+-----------------------+-------------------------------+ // // where // Sev - is the severity code // 00 - Success // 01 - Informational // 10 - Warning // 11 - Error // Facility - is the facility code // Code - is the facility's status code #define EXIF_ERROR 0xC0000000 #define EXIF_WARN 0x80000000 Examples: #define EXIF_FAILED(x) (((x) & 0xC0000000) =3D=3D EXIF_ERROR) ? TRUE : F= ALSE) #define EXIF_ALMOST_OK(x) (((x) & 0xC0000000) =3D=3D EXIF_WARN) ? TRUE : = FALSE) #define EXIF_NO_MEMORY(x) (((x) & 0xFFFF) =3D=3D EXIF_CODE_NOMEMORY) ? TR= UE : FALSE) // START of internal values #define EXIF_CODE_NOMEMORY 1 #define EXIF_CODE_CANT_OPEN 2 #define EXIF_CODE_NO_DATA 3 #define EXIF_FAC_IFD 0x10000 // IFD parser #define EXIF_FAC_LOADER 0x20000 // JPEG loader #define EXIF_FAC_MNOTE 0x30000 // END of internal values #define EX_MNOTE_NO_MEMORY (EXIF_FAC_MNOTE | EXIF_EXIF_CODE_NOMEMORY) #define EX_LOADER_NO_MEMORY (EXIF_FAC_LOADER | EXIF_CODE_NOMEMORY) #define EX_LOADER_NO_MEMORY_FATAL (EXIF_FAC_LOADER | EXIF_CODE_NOMEMORY | EXIF_ERROR) #define EX_CANNOT_OPEN_FILE (EXIF_FAC_LOADER | EXIF_CODE_CANT_OPEN | EXIF_ERROR) #define EX_WRONG_TAG_FORMAT (EXIF_WARN | EXIF_FAC_IFD | EXIF_CODE_WRONG_FORMAT) #define EX_WRONG_IFD_FORMAT (EXIF_WARN | EXIF_FAC_LOADER | EXIF_CODE_WRONG_FORMAT) #define EX_WRONG_MNOTE_FORMAT (EXIF_WAR | EXIF_FAC_MNOTE | EXIF_CODE_WRONG_FORMAT) #define EX_NO_EXIF_DATA (EXIF_WARN | EXIF_FAC_LOADER | EXIF_CODE_NO_DATA) Amd of course also this one ;-) #define EX_OK 0 All relevant "returns;"'s would be replaced with appropriate "return EX_CANNOT_OPEN_FILE;" or "return EX_WRONG_MNOTE_FORMAT;" Quite powerfull bit-mask macros with mininum overhead in libEXIF (just changed returns) giving lots of information. I hope you've got the idea ;-) How do you (and also others) like it? --- Jan |