diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-08-21 20:46:58 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-08-21 20:46:58 +0100 |
commit | 70939d5b136968839f2d7815a8416d23ce24b2e4 (patch) | |
tree | bfcd9f2bc9c9bd488bd4e8be1576ff50313f8c06 | |
parent | 1071a2368e1a5d194995178dfc6461d60673b745 (diff) | |
download | imv-70939d5b136968839f2d7815a8416d23ce24b2e4.tar.gz |
Reduce backend boilerplate
-rw-r--r-- | src/backend_freeimage.c | 8 | ||||
-rw-r--r-- | src/backend_freeimage.h | 9 | ||||
-rw-r--r-- | src/backend_libjpeg.c | 8 | ||||
-rw-r--r-- | src/backend_libjpeg.h | 9 | ||||
-rw-r--r-- | src/backend_libpng.c | 7 | ||||
-rw-r--r-- | src/backend_libpng.h | 9 | ||||
-rw-r--r-- | src/backend_librsvg.c | 7 | ||||
-rw-r--r-- | src/backend_librsvg.h | 9 | ||||
-rw-r--r-- | src/backend_libtiff.c | 8 | ||||
-rw-r--r-- | src/backend_libtiff.h | 9 | ||||
-rw-r--r-- | src/main.c | 24 |
11 files changed, 17 insertions, 90 deletions
diff --git a/src/backend_freeimage.c b/src/backend_freeimage.c index 40a204b..bdddff2 100644 --- a/src/backend_freeimage.c +++ b/src/backend_freeimage.c @@ -1,4 +1,3 @@ -#include "backend_freeimage.h" #include "backend.h" #include "source.h" #include "log.h" @@ -363,7 +362,7 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source return BACKEND_SUCCESS; } -const struct imv_backend freeimage_backend = { +const struct imv_backend imv_backend_freeimage = { .name = "FreeImage", .description = "Open source image library supporting a large number of formats", .website = "http://freeimage.sourceforge.net/", @@ -371,8 +370,3 @@ const struct imv_backend freeimage_backend = { .open_path = &open_path, .open_memory = &open_memory, }; - -const struct imv_backend *imv_backend_freeimage(void) -{ - return &freeimage_backend; -} diff --git a/src/backend_freeimage.h b/src/backend_freeimage.h deleted file mode 100644 index ee8fb6d..0000000 --- a/src/backend_freeimage.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef IMV_BACKEND_FREEIMAGE_H -#define IMV_BACKEND_FREEIMAGE_H - -struct imv_backend; - -/* Get an instance of the freeimage backend */ -const struct imv_backend *imv_backend_freeimage(void); - -#endif diff --git a/src/backend_libjpeg.c b/src/backend_libjpeg.c index 3c7ead7..34dfb43 100644 --- a/src/backend_libjpeg.c +++ b/src/backend_libjpeg.c @@ -1,4 +1,3 @@ -#include "backend_libjpeg.h" #include "backend.h" #include "source.h" @@ -205,7 +204,7 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source return BACKEND_SUCCESS; } -const struct imv_backend libjpeg_backend = { +const struct imv_backend imv_backend_libjpeg = { .name = "libjpeg-turbo", .description = "Fast JPEG codec based on libjpeg. " "This software is based in part on the work " @@ -215,8 +214,3 @@ const struct imv_backend libjpeg_backend = { .open_path = &open_path, .open_memory = &open_memory, }; - -const struct imv_backend *imv_backend_libjpeg(void) -{ - return &libjpeg_backend; -} diff --git a/src/backend_libjpeg.h b/src/backend_libjpeg.h deleted file mode 100644 index cc9664a..0000000 --- a/src/backend_libjpeg.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef IMV_BACKEND_LIBJPEG_H -#define IMV_BACKEND_LIBJPEG_H - -struct imv_backend; - -/* Get an instance of the libjpeg backend */ -const struct imv_backend *imv_backend_libjpeg(void); - -#endif diff --git a/src/backend_libpng.c b/src/backend_libpng.c index ecbe088..88a163e 100644 --- a/src/backend_libpng.c +++ b/src/backend_libpng.c @@ -1,4 +1,3 @@ -#include "backend_libpng.h" #include "backend.h" #include "source.h" #include "log.h" @@ -196,7 +195,7 @@ static enum backend_result open_path(const char *path, struct imv_source **src) return BACKEND_SUCCESS; } -const struct imv_backend libpng_backend = { +const struct imv_backend imv_backend_libpng = { .name = "libpng", .description = "The official PNG reference implementation", .website = "http://www.libpng.org/pub/png/libpng.html", @@ -204,7 +203,3 @@ const struct imv_backend libpng_backend = { .open_path = &open_path, }; -const struct imv_backend *imv_backend_libpng(void) -{ - return &libpng_backend; -} diff --git a/src/backend_libpng.h b/src/backend_libpng.h deleted file mode 100644 index d93284a..0000000 --- a/src/backend_libpng.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef IMV_BACKEND_LIBPNG_H -#define IMV_BACKEND_LIBPNG_H - -struct imv_backend; - -/* Get an instance of the libpng backend */ -const struct imv_backend *imv_backend_libpng(void); - -#endif diff --git a/src/backend_librsvg.c b/src/backend_librsvg.c index d8c4557..ff27477 100644 --- a/src/backend_librsvg.c +++ b/src/backend_librsvg.c @@ -1,4 +1,3 @@ -#include "backend_librsvg.h" #include "backend.h" #include "source.h" @@ -171,7 +170,7 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source return BACKEND_SUCCESS; } -const struct imv_backend librsvg_backend = { +const struct imv_backend imv_backend_librsvg = { .name = "libRSVG", .description = "SVG library developed by GNOME", .website = "https://wiki.gnome.org/Projects/LibRsvg", @@ -180,7 +179,3 @@ const struct imv_backend librsvg_backend = { .open_memory = &open_memory, }; -const struct imv_backend *imv_backend_librsvg(void) -{ - return &librsvg_backend; -} diff --git a/src/backend_librsvg.h b/src/backend_librsvg.h deleted file mode 100644 index b62aa85..0000000 --- a/src/backend_librsvg.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef IMV_BACKEND_RSVG_H -#define IMV_BACKEND_RSVG_H - -struct imv_backend; - -/* Create an instance of the rsvg backend */ -const struct imv_backend *imv_backend_librsvg(void); - -#endif diff --git a/src/backend_libtiff.c b/src/backend_libtiff.c index a3cbb7c..de7fc70 100644 --- a/src/backend_libtiff.c +++ b/src/backend_libtiff.c @@ -1,4 +1,3 @@ -#include "backend_libtiff.h" #include "backend.h" #include "source.h" @@ -218,7 +217,7 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source return BACKEND_SUCCESS; } -const struct imv_backend libtiff_backend = { +const struct imv_backend imv_backend_libtiff = { .name = "libtiff", .description = "The de-facto tiff library", .website = "http://www.libtiff.org/", @@ -226,8 +225,3 @@ const struct imv_backend libtiff_backend = { .open_path = &open_path, .open_memory = &open_memory, }; - -const struct imv_backend *imv_backend_libtiff(void) -{ - return &libtiff_backend; -} diff --git a/src/backend_libtiff.h b/src/backend_libtiff.h deleted file mode 100644 index ce2ab18..0000000 --- a/src/backend_libtiff.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef IMV_BACKEND_LIBTIFF_H -#define IMV_BACKEND_LIBTIFF_H - -struct imv_backend; - -/* Get an instance of the libtiff backend */ -const struct imv_backend *imv_backend_libtiff(void); - -#endif @@ -1,14 +1,14 @@ #include "imv.h" -#include "backend.h" +struct imv_backend; -#include "backend_freeimage.h" -#include "backend_libtiff.h" -#include "backend_libpng.h" -#include "backend_libjpeg.h" -#include "backend_librsvg.h" +extern const struct imv_backend imv_backend_freeimage; +extern const struct imv_backend imv_backend_libpng; +extern const struct imv_backend imv_backend_librsvg; +extern const struct imv_backend imv_backend_libtiff; +extern const struct imv_backend imv_backend_libjpeg; -int main(int argc, char** argv) +int main(int argc, char **argv) { struct imv *imv = imv_create(); @@ -17,23 +17,23 @@ int main(int argc, char** argv) } #ifdef IMV_BACKEND_LIBTIFF - imv_install_backend(imv, imv_backend_libtiff()); + imv_install_backend(imv, &imv_backend_libtiff); #endif #ifdef IMV_BACKEND_LIBPNG - imv_install_backend(imv, imv_backend_libpng()); + imv_install_backend(imv, &imv_backend_libpng); #endif #ifdef IMV_BACKEND_LIBJPEG - imv_install_backend(imv, imv_backend_libjpeg()); + imv_install_backend(imv, &imv_backend_libjpeg); #endif #ifdef IMV_BACKEND_LIBRSVG - imv_install_backend(imv, imv_backend_librsvg()); + imv_install_backend(imv, &imv_backend_librsvg); #endif #ifdef IMV_BACKEND_FREEIMAGE - imv_install_backend(imv, imv_backend_freeimage()); + imv_install_backend(imv, &imv_backend_freeimage); #endif if (!imv_load_config(imv)) { |