From: Christophe CURIS <[email protected]>

An enum is always a better idea as it allows the compiler to do
some checks, and as this info is internal only to the WRLib it
will not change the API.
---
 wrlib/imgformat.h |   18 ++++++++++--------
 wrlib/load.c      |    4 ++--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/wrlib/imgformat.h b/wrlib/imgformat.h
index 1b655ee..eee0f81 100644
--- a/wrlib/imgformat.h
+++ b/wrlib/imgformat.h
@@ -30,14 +30,16 @@
 #define IMGFORMAT_INTERNAL_H
 
 
-#define IM_ERROR   -1
-#define IM_UNKNOWN  0
-#define IM_XPM      1
-#define IM_TIFF     2
-#define IM_PNG      3
-#define IM_PPM      4
-#define IM_JPEG     5
-#define IM_GIF      6
+typedef enum {
+       IM_ERROR   = -1,
+       IM_UNKNOWN =  0,
+       IM_XPM     =  1,
+       IM_TIFF    =  2,
+       IM_PNG     =  3,
+       IM_PPM     =  4,
+       IM_JPEG    =  5,
+       IM_GIF     =  6
+} WRImgFormat;
 
 /* How many image types we have. */
 /* Increase this when adding new image types! */
diff --git a/wrlib/load.c b/wrlib/load.c
index dc30873..dc17c26 100644
--- a/wrlib/load.c
+++ b/wrlib/load.c
@@ -68,7 +68,7 @@ static int RImageCacheMaxImage = -1;  /* 0 = any size */
 static RCachedImage *RImageCache;
 
 
-static int identFile(char *path);
+static WRImgFormat identFile(char *path);
 
 
 char **RSupportedFileFormats(void)
@@ -272,7 +272,7 @@ char *RGetImageFileFormat(char *file)
        }
 }
 
-static int identFile(char *path)
+static WRImgFormat identFile(char *path)
 {
        FILE *file;
        unsigned char buffer[32];
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to