From: Christophe CURIS <christophe.cu...@free.fr>

The functions are declared in different files but they were called
in another file which re-declared the prototypes. This is dangerous
as it can lead to misaligned prototypes when functions changes.

They are now grouped in the library internal header 'imgformat.h'
---
 wrlib/Makefile.am |    1 +
 wrlib/gif.c       |    1 +
 wrlib/imgformat.h |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 wrlib/jpeg.c      |    1 +
 wrlib/load.c      |   28 +--------------------
 wrlib/nxpm.c      |    1 +
 wrlib/png.c       |    1 +
 wrlib/ppm.c       |    1 +
 wrlib/tiff.c      |    1 +
 wrlib/xpm.c       |    1 +
 10 files changed, 79 insertions(+), 27 deletions(-)
 create mode 100644 wrlib/imgformat.h

diff --git a/wrlib/Makefile.am b/wrlib/Makefile.am
index 0aa8db2..c98a60f 100644
--- a/wrlib/Makefile.am
+++ b/wrlib/Makefile.am
@@ -19,6 +19,7 @@ bin_SCRIPTS = get-wraster-flags
 include_HEADERS = wraster.h
 
 libwraster_la_SOURCES =        \
+       imgformat.h     \
        raster.c        \
        alpha_combine.c \
        draw.c          \
diff --git a/wrlib/gif.c b/wrlib/gif.c
index 081f1ee..1ad638a 100644
--- a/wrlib/gif.c
+++ b/wrlib/gif.c
@@ -31,6 +31,7 @@
 #include <gif_lib.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 static int InterlacedOffset[] = { 0, 4, 2, 1 };
 static int InterlacedJumps[] = { 8, 8, 4, 2 };
diff --git a/wrlib/imgformat.h b/wrlib/imgformat.h
new file mode 100644
index 0000000..f6e5b88
--- /dev/null
+++ b/wrlib/imgformat.h
@@ -0,0 +1,70 @@
+/*
+ * Raster graphics library
+ *
+ * Copyright (c) 1997-2003 Alfredo K. Kojima
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ *  MA 02110-1301, USA.
+ */
+
+/*
+ * Functions to load and save RImage from/to file in a specific file format
+ *
+ * These functions are for WRaster library's internal use only, please use
+ * the RLoadImage function defined in 'wraster.h'
+ */
+
+#ifndef IMGFORMAT_INTERNAL_H
+#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
+
+/* How many image types we have. */
+/* Increase this when adding new image types! */
+#define IM_TYPES    6
+
+/*
+ * Function for Loading in a specific format
+ */
+RImage *RLoadPPM(char *file_name);
+
+RImage *RLoadXPM(RContext *context, char *file);
+
+#ifdef USE_TIFF
+RImage *RLoadTIFF(char *file, int index);
+#endif
+
+#ifdef USE_PNG
+RImage *RLoadPNG(RContext *context, char *file);
+#endif
+
+#ifdef USE_JPEG
+RImage *RLoadJPEG(RContext *context, char *file);
+#endif
+
+#ifdef USE_GIF
+RImage *RLoadGIF(char *file, int index);
+#endif
+
+
+#endif
diff --git a/wrlib/jpeg.c b/wrlib/jpeg.c
index 68f4e02..2864277 100644
--- a/wrlib/jpeg.c
+++ b/wrlib/jpeg.c
@@ -34,6 +34,7 @@
 #include <jpeglib.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 /*
  * <setjmp.h> is used for the optional error recovery mechanism shown in
diff --git a/wrlib/load.c b/wrlib/load.c
index d3ae8ad..dc30873 100644
--- a/wrlib/load.c
+++ b/wrlib/load.c
@@ -38,6 +38,7 @@
 #endif
 
 #include "wraster.h"
+#include "imgformat.h"
 
 #define        RETRY( x )      do {                            \
                                x;                      \
@@ -66,36 +67,9 @@ static int RImageCacheMaxImage = -1; /* 0 = any size */
 
 static RCachedImage *RImageCache;
 
-#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
-/* How many image types do we have. */
-/* Increase this when adding new image types! */
-#define IM_TYPES        6
 
 static int identFile(char *path);
 
-extern RImage *RLoadPPM(char *file_name);
-
-extern RImage *RLoadXPM(RContext * context, char *file);
-
-#ifdef USE_TIFF
-extern RImage *RLoadTIFF(char *file, int index);
-#endif
-#ifdef USE_PNG
-extern RImage *RLoadPNG(RContext * context, char *file);
-#endif
-#ifdef USE_JPEG
-extern RImage *RLoadJPEG(RContext * context, char *file_name);
-#endif
-#ifdef USE_GIF
-extern RImage *RLoadGIF(char *file_name, int index);
-#endif
 
 char **RSupportedFileFormats(void)
 {
diff --git a/wrlib/nxpm.c b/wrlib/nxpm.c
index 45ace0d..5d9d270 100644
--- a/wrlib/nxpm.c
+++ b/wrlib/nxpm.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 /*
  * Restricted support for XPM images.
diff --git a/wrlib/png.c b/wrlib/png.c
index e28d730..41736a9 100644
--- a/wrlib/png.c
+++ b/wrlib/png.c
@@ -31,6 +31,7 @@
 #include <png.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 RImage *RLoadPNG(RContext * context, char *file)
 {
diff --git a/wrlib/ppm.c b/wrlib/ppm.c
index e4bd758..c386363 100644
--- a/wrlib/ppm.c
+++ b/wrlib/ppm.c
@@ -28,6 +28,7 @@
 #include <string.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 static RImage *load_graymap(FILE * file, int w, int h, int max, int raw)
 {
diff --git a/wrlib/tiff.c b/wrlib/tiff.c
index accdfbe..979cb5f 100644
--- a/wrlib/tiff.c
+++ b/wrlib/tiff.c
@@ -32,6 +32,7 @@
 #include <tiffio.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 RImage *RLoadTIFF(char *file, int index)
 {
diff --git a/wrlib/xpm.c b/wrlib/xpm.c
index 5ce1ea1..04307e3 100644
--- a/wrlib/xpm.c
+++ b/wrlib/xpm.c
@@ -31,6 +31,7 @@
 #include <X11/xpm.h>
 
 #include "wraster.h"
+#include "imgformat.h"
 
 RImage *RGetImageFromXPMData(RContext * context, char **xpmData)
 {
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to