svnno****@sourc*****
svnno****@sourc*****
2009年 3月 12日 (木) 01:36:36 JST
Revision: 122 http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=122 Author: yoya Date: 2009-03-12 01:36:36 +0900 (Thu, 12 Mar 2009) Log Message: ----------- - libpng や giblib のない環境では各々の処理のみ無効として動くように改造 - config-lib.m4 で --without-...= 系の処理を追加 - config.h を読み込ませて HAVE_... で依存する処理をくくった Modified Paths: -------------- trunk/src/config-lib.m4 trunk/src/swf_define.h trunk/src/swf_gif.c trunk/src/swf_object.c trunk/src/swf_png.c trunk/src/swf_tag.c trunk/src/swf_tag_lossless.c trunk/src/swfed.c -------------- next part -------------- Modified: trunk/src/config-lib.m4 =================================================================== --- trunk/src/config-lib.m4 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/config-lib.m4 2009-03-11 16:36:36 UTC (rev 122) @@ -60,9 +60,11 @@ # if test "$PHP_PNG_DIR" != "no" && test "$PHP_PNG_DIR" != "yes"; then if test -f "$PHP_PNG_DIR/include/libpng/png.h"; then + AC_DEFINE(HAVE_PNG,1,[ ]) PHP_PNG_DIR="$PHP_PNG_DIR" PHP_PNG_INCDIR="$PHP_PNG_DIR/include/libpng" elif test -f "$PHP_PNG_DIR/include/png.h"; then + AC_DEFINE(HAVE_PNG,1,[ ]) PHP_PNG_DIR="$PHP_PNG_DIR" PHP_PNG_INCDIR="$PHP_PNG_DIR/include" else @@ -71,9 +73,11 @@ else for i in /usr/local /usr; do if test -f "$i/include/libpng/png.h"; then + AC_DEFINE(HAVE_PNG,1,[ ]) PHP_PNG_DIR="$i" PHP_PNG_INCDIR="$i/include/libpng" elif test -f "$i/include/png.h"; then + AC_DEFINE(HAVE_PNG,1,[ ]) PHP_PNG_DIR="$i" PHP_PNG_INCDIR="$i/include" fi @@ -83,7 +87,7 @@ dnl # libpng AC_MSG_CHECKING([for the location of libpng]) if test "$PHP_PNG_DIR" = "no"; then - AC_MSG_ERROR([swfed support requires PNG. Use --with-png-dir=<DIR> to specify prefix where PNG include and library are located]) + AC_MSG_RESULT([png.h not found.]) else AC_MSG_RESULT([$PHP_PNG_DIR]) if test "z$PHP_LIBDIR" != "z"; then @@ -101,9 +105,11 @@ # if test "$PHP_GIF_DIR" != "no" && test "$PHP_GIF_DIR" != "yes"; then if test -f "$PHP_GIF_DIR/include/giflib/gif_lib.h"; then + AC_DEFINE(HAVE_GIF,1,[ ]) PHP_GIF_DIR="$PHP_GIF_DIR" PHP_GIF_INCDIR="$PHP_GIF_DIR/include/giflib" elif test -f "$PHP_GIF_DIR/include/gif_lib.h"; then + AC_DEFINE(HAVE_GIF,1,[ ]) PHP_GIF_DIR="$PHP_GIF_DIR" PHP_GIF_INCDIR="$PHP_GIF_DIR/include" else @@ -112,9 +118,11 @@ else for i in /usr/local /usr; do if test -f "$i/include/giflib/gif_lib.h"; then + AC_DEFINE(HAVE_GIF,1,[ ]) PHP_GIF_DIR="$i" PHP_GIF_INCDIR="$i/include/giflib" elif test -f "$i/include/gif_lib.h"; then + AC_DEFINE(HAVE_GIF,1,[ ]) PHP_GIF_DIR="$i" PHP_GIF_INCDIR="$i/include" fi @@ -124,7 +132,7 @@ dnl # giflib AC_MSG_CHECKING([for the location of giflib]) if test "$PHP_GIF_DIR" = "no"; then - AC_MSG_ERROR([swfed support requires GIF. Use --with-gif-dir=<DIR> to specify prefix where GIF include and library are located]) + AC_MSG_RESULT([gif_lib.h not found.]) else AC_MSG_RESULT([$PHP_GIF_DIR]) if test "z$PHP_LIBDIR" != "z"; then Modified: trunk/src/swf_define.h =================================================================== --- trunk/src/swf_define.h 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swf_define.h 2009-03-11 16:36:36 UTC (rev 122) @@ -3,6 +3,10 @@ #include <stdlib.h> +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #define SWF_TWIPS 20 #define SWF_MAGIC_SIZE 4 #define SWF_FILE_LENGTH_SIZE 4 Modified: trunk/src/swf_gif.c =================================================================== --- trunk/src/swf_gif.c 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swf_gif.c 2009-03-11 16:36:36 UTC (rev 122) @@ -6,8 +6,12 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include "swf_define.h" + +#ifdef HAVE_GIF + #include <gif_lib.h> -#include <string.h> #include "bitstream.h" #include "swf_rgb.h" // Lossless format=3 #include "swf_rgba.h" // Lossless2 format=3 @@ -284,3 +288,5 @@ *length = gif_buff.data_offset; return gif_buff.data; } + +#endif /* HAVE_GIF */ Modified: trunk/src/swf_object.c =================================================================== --- trunk/src/swf_object.c 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swf_object.c 2009-03-11 16:36:36 UTC (rev 122) @@ -257,6 +257,7 @@ return result; } +#ifdef HAVE_PNG unsigned char * swf_object_get_pngdata(swf_object_t *swf, unsigned long *length, int image_id) { @@ -300,6 +301,11 @@ return result; } + +#endif /* HAVE_PNG */ + +#ifdef HAVE_GIF + int swf_object_replace_gifdata(swf_object_t *swf, int image_id, unsigned char *gif_data, @@ -320,6 +326,8 @@ return result; } +#endif /* HAVE_GIF */ + unsigned char * swf_object_get_sounddata(swf_object_t *swf, unsigned long *length, int sound_id) { swf_tag_t *tag; Modified: trunk/src/swf_png.c =================================================================== --- trunk/src/swf_png.c 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swf_png.c 2009-03-11 16:36:36 UTC (rev 122) @@ -6,6 +6,10 @@ #include <stdio.h> #include <stdlib.h> +#include "swf_define.h" + +#ifdef HAVE_PNG + #include <png.h> #include "bitstream.h" #include "swf_rgb.h" // Lossless format=3 @@ -398,3 +402,5 @@ *length = png_buff.data_offset; return png_buff.data; } + +#endif /* HAVE_PNG */ Modified: trunk/src/swf_tag.c =================================================================== --- trunk/src/swf_tag.c 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swf_tag.c 2009-03-11 16:36:36 UTC (rev 122) @@ -366,6 +366,9 @@ return result; } + +#ifdef HAVE_PNG + unsigned char * swf_tag_get_png_data(swf_tag_t *tag, unsigned long *length, int image_id) { swf_tag_info_t *tag_info; @@ -436,6 +439,10 @@ return result; } +#endif /* HAVE_PNG */ + +#ifdef HAVE_GIF + int swf_tag_replace_gif_data(swf_tag_t *tag, int image_id, unsigned char *gif_data, @@ -484,6 +491,8 @@ return result; } +#endif /* HAVE_GIF */ + /* * DefineSound */ Modified: trunk/src/swf_tag_lossless.c =================================================================== --- trunk/src/swf_tag_lossless.c 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swf_tag_lossless.c 2009-03-11 16:36:36 UTC (rev 122) @@ -348,7 +348,9 @@ } return ; } - + +#ifdef HAVE_PNG + unsigned char *swf_tag_lossless_get_png_data(void *detail, unsigned long *length, int image_id, @@ -474,6 +476,10 @@ return 0; } +#endif /* HAVE_PNG */ + +#ifdef HAVE_GIF + int swf_tag_lossless_replace_gif_data(void *detail, int image_id, unsigned char *gif_data, @@ -529,3 +535,5 @@ } return 0; } + +#endif /* HAVE_GIF */ Modified: trunk/src/swfed.c =================================================================== --- trunk/src/swfed.c 2009-03-09 16:12:20 UTC (rev 121) +++ trunk/src/swfed.c 2009-03-11 16:36:36 UTC (rev 122) @@ -536,6 +536,10 @@ } PHP_METHOD(swfed, getPNGData) { +#ifndef HAVE_PNG + fprintf(stderr, "replacePNGData: no png library\n"); + RETURN_FALSE; +#else /* HAVE_PNG */ unsigned long image_id = 0; unsigned long len = 0; unsigned char *data; @@ -559,9 +563,14 @@ memcpy(new_buff, data, len); free(data); RETURN_STRINGL(new_buff, (int) len, 0); +#endif /* HAVE_PNG */ } PHP_METHOD(swfed, replacePNGData) { +#ifndef HAVE_PNG + fprintf(stderr, "replacePNGData: no png library\n"); + RETURN_FALSE; +#else /* HAVE_PNG */ char *data = NULL; int data_len = 0; int image_id; @@ -585,9 +594,14 @@ RETURN_FALSE; } RETURN_TRUE; +#endif /* HAVE_PNG */ } PHP_METHOD(swfed, replaceGIFData) { +#ifndef HAVE_GIF + fprintf(stderr, "replaceGIFData: no gif library\n"); + RETURN_FALSE; +#else /* HAVE_GIF */ char *data = NULL; int data_len = 0; int image_id; @@ -611,6 +625,7 @@ RETURN_FALSE; } RETURN_TRUE; +#endif /* HAVE_GIF */ } PHP_METHOD(swfed, getSoundData) {