forked from enlightenment/efl
Merge branch 'devs/cedric/emile'
Here come a major code refactoring. There is still work to be done, especially on Ecore_Con_SSl and also image compression, but it is already an improvement over current situation. Further development should happen in master. Emile does provide a library to put together serialization, compression and ciphering. It is a low level library and can be use by anything above Eina.
This commit is contained in:
commit
0cf042baee
1
COPYING
1
COPYING
|
@ -14,6 +14,7 @@ use them and is not more restrictive).
|
|||
evil: licenses/COPYING.BSD
|
||||
escape: licenses/COPYING.GPL (used in PlayStation native)
|
||||
eina: licenses/COPYING.LGPL
|
||||
emile: licenses/COPYING.LGPL
|
||||
eet: licenses/COPYING.BSD
|
||||
eo: licenses/COPYING.BSD
|
||||
evas: licenses/COPYING.BSD
|
||||
|
|
|
@ -128,6 +128,7 @@ pc/eo.pc \
|
|||
pc/eolian.pc \
|
||||
pc/efl.pc \
|
||||
pc/efl-cxx.pc \
|
||||
pc/emile.pc \
|
||||
pc/eet.pc \
|
||||
pc/evas.pc \
|
||||
pc/ecore.pc \
|
||||
|
|
401
configure.ac
401
configure.ac
|
@ -343,7 +343,6 @@ AM_CONDITIONAL([EFL_ENABLE_TESTS], [test "${want_tests}" = "yes"])
|
|||
# check for crypto/tls library to use
|
||||
case "$build_crypto" in
|
||||
gnutls)
|
||||
CFOPT_WARNING="xyes"
|
||||
EFL_DEPEND_PKG([crypto], [GNUTLS], [gnutls >= 2.12.16])
|
||||
|
||||
AM_PATH_LIBGCRYPT([], [:],
|
||||
|
@ -611,18 +610,6 @@ AC_DEFINE_IF([HAVE_ATFILE_SOURCE],
|
|||
|
||||
|
||||
###################### EFL ######################
|
||||
build_gui="yes"
|
||||
AC_ARG_ENABLE([gui],
|
||||
[AS_HELP_STRING([--disable-gui],[disable GUI libraries @<:@default=enable@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes"; then
|
||||
build_gui="yes"
|
||||
CFOPT_WARNING="yes"
|
||||
else
|
||||
build_gui="no"
|
||||
fi
|
||||
])
|
||||
AM_CONDITIONAL([BUILD_GUI], [test "x${build_gui}" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE([systemd],
|
||||
[AS_HELP_STRING([--enable-systemd],[Enable systemd support. @<:@default=disabled@:>@])],
|
||||
|
@ -973,7 +960,6 @@ EFL_ADD_FEATURE([EINA], [systemd-journal], [${want_systemd}])
|
|||
EFL_LIB_END([Eina])
|
||||
#### End of Eina
|
||||
|
||||
|
||||
#### Eina CXX
|
||||
EFL_LIB_START([Eina_Cxx])
|
||||
|
||||
|
@ -997,64 +983,6 @@ EFL_EVAL_PKGS([EINA_CXX])
|
|||
EFL_LIB_END([Eina_Cxx])
|
||||
#### End of Eina CXX
|
||||
|
||||
#### Eet
|
||||
|
||||
EFL_LIB_START([Eet])
|
||||
|
||||
### Default values
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
### Checks for programs
|
||||
|
||||
### Checks for libraries
|
||||
|
||||
## Compatibility layers
|
||||
EFL_PLATFORM_DEPEND([EET], [evil])
|
||||
|
||||
EFL_ADD_LIBS([EET], [-lm])
|
||||
|
||||
# Cryptography support
|
||||
if test "$build_crypto" != "none" ; then
|
||||
AC_DEFINE([HAVE_CIPHER], [1], [Have cipher support built in eet])
|
||||
AC_DEFINE([HAVE_SIGNATURE], [1], [Have signature support for eet file])
|
||||
EFL_CRYPTO_DEPEND([EET])
|
||||
fi
|
||||
|
||||
EFL_CHECK_LIBS([EET], [libjpeg zlib])
|
||||
|
||||
EFL_INTERNAL_DEPEND_PKG([EET], [eina])
|
||||
|
||||
EFL_EVAL_PKGS([EET])
|
||||
|
||||
### Checks for header files
|
||||
|
||||
### Checks for types
|
||||
|
||||
### Checks for structures
|
||||
|
||||
### Checks for compiler characteristics
|
||||
|
||||
### Checks for linker characteristics
|
||||
|
||||
### Checks for library functions
|
||||
|
||||
### Check availability
|
||||
|
||||
EFL_LIB_END([Eet])
|
||||
#### End of Eet
|
||||
|
||||
#### Eet CXX
|
||||
EFL_LIB_START([Eet_Cxx])
|
||||
|
||||
EFL_INTERNAL_DEPEND_PKG([EET_CXX], [Eina_Cxx])
|
||||
EFL_INTERNAL_DEPEND_PKG([EET_CXX], [Eet])
|
||||
|
||||
EFL_EVAL_PKGS([EET_CXX])
|
||||
|
||||
EFL_LIB_END([Eet_Cxx])
|
||||
#### End of Eet CXX
|
||||
|
||||
#### Eo
|
||||
|
||||
EFL_LIB_START([Eo])
|
||||
|
@ -1088,13 +1016,124 @@ AM_CONDITIONAL([EO_BUILD_EXAMPLE_EVAS], [test "x${have_elm}" = "xyes"])
|
|||
### Checks for linker characteristics
|
||||
|
||||
### Checks for library functions
|
||||
EFL_CHECK_FUNCS([EO], [dladdr])
|
||||
|
||||
### Check availability
|
||||
|
||||
EFL_LIB_END([Eo])
|
||||
#### End of Eo
|
||||
|
||||
#### Eet CXX
|
||||
EFL_LIB_START([Eet_Cxx])
|
||||
|
||||
EFL_INTERNAL_DEPEND_PKG([EET_CXX], [Eina_Cxx])
|
||||
EFL_INTERNAL_DEPEND_PKG([EET_CXX], [Eet])
|
||||
|
||||
EFL_EVAL_PKGS([EET_CXX])
|
||||
|
||||
EFL_LIB_END([Eet_Cxx])
|
||||
#### End of Eet CXX
|
||||
|
||||
#### Emile
|
||||
|
||||
EFL_LIB_START([Emile])
|
||||
|
||||
### Default values
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
### Checks for programs
|
||||
|
||||
### Checks for libraries
|
||||
|
||||
EFL_CHECK_LIBS([EMILE], [libjpeg])
|
||||
|
||||
## Compatibility layers
|
||||
EFL_PLATFORM_DEPEND([EMILE], [evil])
|
||||
|
||||
EFL_ADD_LIBS([EMILE], [-lm])
|
||||
|
||||
# Cryptography support
|
||||
if test "$build_crypto" != "none" ; then
|
||||
AC_DEFINE([HAVE_CIPHER], [1], [Have cipher support built in emile])
|
||||
AC_DEFINE([HAVE_SIGNATURE], [1], [Have signature support in emile])
|
||||
EFL_CRYPTO_DEPEND([EMILE])
|
||||
fi
|
||||
|
||||
EFL_CHECK_LIBS([EMILE], [zlib])
|
||||
|
||||
EFL_INTERNAL_DEPEND_PKG([EMILE], [eina])
|
||||
|
||||
EFL_EVAL_PKGS([EMILE])
|
||||
|
||||
### Checks for header files
|
||||
|
||||
### Checks for types
|
||||
|
||||
### Checks for structures
|
||||
|
||||
### Checks for compiler characteristics
|
||||
|
||||
### Checks for linker characteristics
|
||||
|
||||
### Checks for library functions
|
||||
|
||||
### Check availability
|
||||
|
||||
EFL_ADD_FEATURE([EMILE], [crypto], [${build_crypto}])
|
||||
|
||||
EFL_LIB_END([Emile])
|
||||
#### End of Emile
|
||||
|
||||
|
||||
#### Eet
|
||||
|
||||
EFL_LIB_START([Eet])
|
||||
|
||||
### Default values
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
### Checks for programs
|
||||
|
||||
### Checks for libraries
|
||||
|
||||
EFL_CHECK_LIBS([EET], [libjpeg])
|
||||
|
||||
## Compatibility layers
|
||||
EFL_PLATFORM_DEPEND([EET], [evil])
|
||||
|
||||
EFL_ADD_LIBS([EET], [-lm])
|
||||
|
||||
# Cryptography support
|
||||
if test "$build_crypto" != "none" ; then
|
||||
AC_DEFINE([HAVE_CIPHER], [1], [Have cipher support built in eet])
|
||||
AC_DEFINE([HAVE_SIGNATURE], [1], [Have signature support for eet file])
|
||||
EFL_CRYPTO_DEPEND([EET])
|
||||
fi
|
||||
|
||||
EFL_INTERNAL_DEPEND_PKG([EET], [eina])
|
||||
EFL_INTERNAL_DEPEND_PKG([EET], [emile])
|
||||
|
||||
EFL_EVAL_PKGS([EET])
|
||||
|
||||
### Checks for header files
|
||||
|
||||
### Checks for types
|
||||
|
||||
### Checks for structures
|
||||
|
||||
### Checks for compiler characteristics
|
||||
|
||||
### Checks for linker characteristics
|
||||
|
||||
### Checks for library functions
|
||||
EFL_CHECK_FUNCS([EO], [dladdr])
|
||||
|
||||
### Check availability
|
||||
|
||||
EFL_LIB_END([Eet])
|
||||
#### End of Eet
|
||||
|
||||
#### Eo CXX
|
||||
EFL_LIB_START([Eo_Cxx])
|
||||
|
||||
|
@ -1177,7 +1216,8 @@ EFL_LIB_END([Efl])
|
|||
#### End of Efl
|
||||
|
||||
#### Evas
|
||||
EFL_LIB_START_OPTIONAL([Evas], [test "x${build_gui}" = "xyes"])
|
||||
|
||||
EFL_LIB_START([Evas])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -1635,6 +1675,7 @@ EFL_INTERNAL_DEPEND_PKG([EVAS], [eo])
|
|||
EFL_INTERNAL_DEPEND_PKG([EVAS], [eet])
|
||||
EFL_INTERNAL_DEPEND_PKG([EVAS], [eina])
|
||||
EFL_INTERNAL_DEPEND_PKG([EVAS], [efl])
|
||||
EFL_INTERNAL_DEPEND_PKG([EVAS], [emile])
|
||||
|
||||
EFL_ADD_LIBS([EVAS], [-lm])
|
||||
|
||||
|
@ -2050,81 +2091,7 @@ EFL_ADD_FEATURE([EVAS], [cserve], [${want_evas_cserve2}])
|
|||
EFL_ADD_FEATURE([EVAS], [tile-rotate])
|
||||
EFL_ADD_FEATURE([EVAS], [dither-mask], [${build_evas_dither_mask}])
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Evas])
|
||||
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
AM_CONDITIONAL([BUILD_ENGINE_BUFFER], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_BUFFER], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_FB], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_FB], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_PSL1GHT], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_PSL1GHT], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_GL_COCOA], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GL_COCOA], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_GL_SDL], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GL_SDL], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_SOFTWARE_GDI], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_SOFTWARE_GDI], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_SOFTWARE_DDRAW], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_SOFTWARE_DDRAW], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_WAYLAND_EGL], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_WAYLAND_EGL], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_WAYLAND_SHM], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_WAYLAND_SHM], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_DRM], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_DRM], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_SOFTWARE_XCB], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_SOFTWARE_XCB], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_SOFTWARE_XLIB], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_SOFTWARE_XLIB], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_SOFTWARE_X11], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_SOFTWARE_X11], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_SOFTWARE_GENERIC], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_GL_XCB], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GL_XCB], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_GL_XLIB], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GL_XLIB], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_GL_X11], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GL_X11], [false])
|
||||
AM_CONDITIONAL([BUILD_ENGINE_GL_COMMON], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GL_COMMON], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_BMP], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_BMP], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_EET], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_EET], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_GENERIC], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GENERIC], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_GIF], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_GIF], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_ICO], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_ICO], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_JPEG], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_JPEG], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_JP2K], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_JP2K], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_PMAPS], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_PMAPS], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_PNG], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_PNG], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_PSD], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_PSD], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_TGA], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_TGA], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_TIFF], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_TIFF], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_WBMP], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_WBMP], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_WEBP], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_WEBP], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_XPM], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_XPM], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_TGV], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_TGV], [false])
|
||||
AM_CONDITIONAL([BUILD_LOADER_DDS], [false])
|
||||
AM_CONDITIONAL([EVAS_STATIC_BUILD_DDS], [false])
|
||||
AM_CONDITIONAL([EVAS_CSERVE2], [false])
|
||||
fi
|
||||
|
||||
EFL_LIB_END([Evas])
|
||||
#### End of Evas
|
||||
|
||||
#### Edje CXX
|
||||
|
@ -2235,9 +2202,6 @@ AC_ARG_ENABLE([gstreamer1],
|
|||
fi
|
||||
],
|
||||
[want_gstreamer1="yes"])
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
want_gstreamer1="no"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([tizen],
|
||||
[AS_HELP_STRING([--enable-tizen],[enable tizen support. @<:@default=disabled@:>@])],
|
||||
|
@ -2515,6 +2479,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eo])
|
|||
EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eet])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eina])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [ecore])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [emile])
|
||||
|
||||
EFL_ADD_LIBS([ECORE_CON], [-lm])
|
||||
|
||||
|
@ -2654,7 +2619,7 @@ EFL_LIB_END([Ecore_File])
|
|||
|
||||
|
||||
#### Ecore_Input
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Input], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ecore_Input])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -2682,12 +2647,12 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_INPUT], [eina])
|
|||
|
||||
### Checks for library functions
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ecore_Input])
|
||||
EFL_LIB_END([Ecore_Input])
|
||||
#### End of Ecore_Input
|
||||
|
||||
|
||||
#### Ecore_Input_Evas
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Input_Evas], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ecore_Input_Evas])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -2718,7 +2683,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_INPUT_EVAS], [eina])
|
|||
|
||||
### Checks for library functions
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ecore_Input_Evas])
|
||||
EFL_LIB_END([Ecore_Input_Evas])
|
||||
#### End of Ecore_Input_Evas
|
||||
|
||||
|
||||
|
@ -3152,10 +3117,6 @@ AC_ARG_ENABLE([audio],
|
|||
],
|
||||
[want_audio="yes"])
|
||||
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
want_audio="no"
|
||||
fi
|
||||
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Audio], [test "${want_audio}" = "yes"])
|
||||
|
||||
### Additional options to configure
|
||||
|
@ -3609,7 +3570,7 @@ AM_CONDITIONAL([HAVE_ECORE_X_XCB], [test "${want_x11_xcb}" = "yes"])
|
|||
|
||||
|
||||
#### Ecore_Imf
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Imf], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ecore_Imf])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -3725,18 +3686,12 @@ EFL_ADD_FEATURE([ECORE_IMF], [wayland], [${want_ecore_imf_wayland}])
|
|||
|
||||
### Checks for library functions
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ecore_Imf])
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
AM_CONDITIONAL([BUILD_ECORE_IMF_IBUS], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_IMF_SCIM], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_IMF_XIM], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_IMF_WAYLAND], [false])
|
||||
fi
|
||||
EFL_LIB_END([Ecore_Imf])
|
||||
#### End of Ecore_Imf
|
||||
|
||||
|
||||
#### Ecore_Imf_Evas
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Imf_Evas], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ecore_Imf_Evas])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -3768,12 +3723,12 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_IMF_EVAS], [eina])
|
|||
|
||||
### Checks for library functions
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ecore_Imf_Evas])
|
||||
EFL_LIB_END([Ecore_Imf_Evas])
|
||||
#### End of Ecore_Imf_Evas
|
||||
|
||||
|
||||
#### Ecore_Evas
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Evas], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ecore_Evas])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -3935,28 +3890,7 @@ EFL_EVAL_PKGS([ECORE_EVAS])
|
|||
|
||||
### Checks for library functions
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ecore_Evas])
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_EXTN], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_EWS], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_FB], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_DRM], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_PSL1GHT], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_OPENGL_COCOA], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_SOFTWARE_SDL], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_OPENGL_SDL], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_SDL], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_WAYLAND_SHM], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_WAYLAND_EGL], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_WAYLAND], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_SOFTWARE_GDI], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_SOFTWARE_DDRAW], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_WIN32], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_SOFTWARE_X11], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_OPENGL_X11], [false])
|
||||
AM_CONDITIONAL([BUILD_ECORE_EVAS_X11], [false])
|
||||
fi
|
||||
|
||||
EFL_LIB_END([Ecore_Evas])
|
||||
#### End of Ecore_Evas
|
||||
|
||||
#### Eio
|
||||
|
@ -4067,10 +4001,6 @@ AC_ARG_ENABLE([physics],
|
|||
],
|
||||
[want_physics="yes"])
|
||||
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
want_physics="no"
|
||||
fi
|
||||
|
||||
EFL_LIB_START_OPTIONAL([EPhysics], [test "${want_physics}" = "yes"])
|
||||
|
||||
### Additional options to configure
|
||||
|
@ -4109,7 +4039,7 @@ EFL_LIB_END_OPTIONAL([EPhysics])
|
|||
|
||||
|
||||
#### Edje
|
||||
EFL_LIB_START_OPTIONAL([Edje], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Edje])
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
|
@ -4127,10 +4057,6 @@ AC_ARG_ENABLE([multisense],
|
|||
],
|
||||
[want_multisense="${want_pulseaudio}"])
|
||||
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
want_multisense="no"
|
||||
fi
|
||||
|
||||
# TODO: should we keep or remove these?
|
||||
want_edje_program_cache="no"
|
||||
want_edje_calc_cache="yes"
|
||||
|
@ -4181,8 +4107,7 @@ AC_DEFINE_IF([BUILD_EDJE_FP], [test "${want_fixed_point}" = "yes"],
|
|||
|
||||
AM_CONDITIONAL([ENABLE_MULTISENSE], [test "${want_multisense}" = "yes"])
|
||||
AC_DEFINE_IF([ENABLE_MULTISENSE], [test "${want_multisense}" = "yes"],
|
||||
[1], [Use Multisense])
|
||||
|
||||
[1], [Use Multisense])
|
||||
AC_SUBST([want_multisense])
|
||||
AC_SUBST([want_physics])
|
||||
|
||||
|
@ -4202,15 +4127,9 @@ sys/wait.h \
|
|||
|
||||
### Checks for library functions
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Edje])
|
||||
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
AC_DEFINE([ENABLE_MULTISENSE], [0], [Use Multisense])
|
||||
AM_CONDITIONAL([ENABLE_MULTISENSE], [false])
|
||||
fi
|
||||
EFL_LIB_END([Edje])
|
||||
#### End of Edje
|
||||
|
||||
|
||||
#### Edje CXX
|
||||
EFL_LIB_START([Edje_Cxx])
|
||||
|
||||
|
@ -4220,7 +4139,7 @@ EFL_LIB_END([Edje_Cxx])
|
|||
#### End of Edje CXX
|
||||
|
||||
#### Emotion
|
||||
EFL_LIB_START_OPTIONAL([Emotion], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Emotion])
|
||||
|
||||
## Compatibility layers
|
||||
EFL_PLATFORM_DEPEND([Emotion], [evil])
|
||||
|
@ -4306,23 +4225,12 @@ fi
|
|||
|
||||
### Check availability
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Emotion])
|
||||
|
||||
if test "x${build_gui}" = "xno"; then
|
||||
AM_CONDITIONAL([EMOTION_BUILD_XINE], [false])
|
||||
AM_CONDITIONAL([EMOTION_STATIC_BUILD_XINE], [false])
|
||||
AM_CONDITIONAL([EMOTION_BUILD_GSTREAMER], [false])
|
||||
AM_CONDITIONAL([EMOTION_STATIC_BUILD_GSTREAMER], [false])
|
||||
AM_CONDITIONAL([EMOTION_BUILD_GSTREAMER1], [false])
|
||||
AM_CONDITIONAL([EMOTION_STATIC_BUILD_GSTREAMER1], [false])
|
||||
AM_CONDITIONAL([EMOTION_BUILD_GENERIC], [false])
|
||||
AM_CONDITIONAL([EMOTION_STATIC_BUILD_GENERIC], [false])
|
||||
fi
|
||||
EFL_LIB_END([Emotion])
|
||||
#### End of Emotion
|
||||
|
||||
|
||||
#### Ethumb
|
||||
EFL_LIB_START_OPTIONAL([Ethumb], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ethumb])
|
||||
|
||||
### Default values
|
||||
|
||||
|
@ -4365,11 +4273,12 @@ EFL_EVAL_PKGS([ETHUMB])
|
|||
|
||||
### Check availability
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ethumb])
|
||||
EFL_LIB_END([Ethumb])
|
||||
#### End of Ethumb
|
||||
|
||||
#### Ethumb_Client
|
||||
EFL_LIB_START_OPTIONAL([Ethumb_Client], [test "x${build_gui}" = "xyes"])
|
||||
EFL_LIB_START([Ethumb_Client])
|
||||
|
||||
### Default values
|
||||
|
||||
### Additional options to configure
|
||||
|
@ -4407,7 +4316,7 @@ EFL_EVAL_PKGS([ETHUMB_CLIENT])
|
|||
|
||||
### Check availability
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Ethumb_Client])
|
||||
EFL_LIB_END([Ethumb_Client])
|
||||
#### End of Ethumb_Client
|
||||
|
||||
#### Elua
|
||||
|
@ -4558,6 +4467,7 @@ pc/evil.pc
|
|||
pc/escape.pc
|
||||
pc/eina.pc
|
||||
pc/eina-cxx.pc
|
||||
pc/emile.pc
|
||||
pc/eet.pc
|
||||
pc/eet-cxx.pc
|
||||
pc/eo.pc
|
||||
|
@ -4736,20 +4646,21 @@ echo " Cryptography..: ${build_crypto}"
|
|||
echo " X11...........: ${with_x11}"
|
||||
echo " OpenGL........: ${with_opengl}"
|
||||
echo " C++11.........: ${have_cxx11}"
|
||||
echo " GUI libs......: ${build_gui}"
|
||||
echo "Evas............: ${efl_lib_optional_evas} (${features_evas})"
|
||||
echo "Eina............: yes (${features_eina})"
|
||||
echo "Eo..............: yes (${features_eo})"
|
||||
echo "Eolian..........: yes (${features_eolian})"
|
||||
echo "Emile...........: yes (${features_emile})"
|
||||
echo "Eet.............: yes"
|
||||
echo "Evas............: yes (${features_evas})"
|
||||
echo " Engines.......: ${features_evas_engine}"
|
||||
echo " Image Loaders.: ${features_evas_loader}"
|
||||
if test "x${have_pixman}" = "xyes" ; then
|
||||
echo " Pixman........: ${features_evas_pixman}"
|
||||
fi
|
||||
echo "Eo..............: yes (${features_eo})"
|
||||
echo "Eolian..........: yes (${features_eolian})"
|
||||
echo "Eina............: yes (${features_eina})"
|
||||
echo "Ecore...........: yes (${features_ecore})"
|
||||
echo "Ecore_Con.......: yes (${features_ecore_con})"
|
||||
echo "Ecore_File......: yes"
|
||||
echo "Ecore_IMF.......: ${efl_lib_optional_ecore_imf} (${features_ecore_imf})"
|
||||
echo "Ecore_IMF.......: yes (${features_ecore_imf})"
|
||||
echo "Ecore_X.........: ${with_x11} (${features_ecore_x})"
|
||||
echo "Ecore_SDL.......: $want_sdl"
|
||||
echo "Ecore_Wayland...: $want_wayland"
|
||||
|
@ -4765,13 +4676,13 @@ echo "Ecore_Win32.....: $have_win32"
|
|||
fi
|
||||
echo "Ecore_Audio.....: ${efl_lib_optional_ecore_audio} (${features_ecore_audio})"
|
||||
echo "Ecore_Avahi.....: yes (${features_ecore_avahi})"
|
||||
echo "Ecore_Evas......: ${efl_lib_optional_ecore_evas} (${features_ecore_evas})"
|
||||
echo "Ecore_Evas......: yes (${features_ecore_evas})"
|
||||
echo "Eeze............: ${efl_lib_optional_eeze} (${features_eeze})"
|
||||
echo "EPhysics........: ${efl_lib_optional_ephysics}"
|
||||
echo "Edje............: ${efl_lib_optional_edje} (${features_edje})"
|
||||
echo "Emotion.........: ${efl_lib_optional_emotion} (${features_emotion})"
|
||||
echo "Ethumb..........: ${efl_lib_optional_ethumb}"
|
||||
echo "Ethumb_Client...: ${efl_lib_optional_ethumb_client}"
|
||||
echo "Edje............: yes (${features_edje})"
|
||||
echo "Emotion.........: yes (${features_emotion})"
|
||||
echo "Ethumb..........: yes"
|
||||
echo "Ethumb_Client...: yes"
|
||||
echo "Elua............: $have_elua"
|
||||
if test "${build_tests}" = "none"; then
|
||||
echo "Tests...........: no"
|
||||
|
@ -4834,7 +4745,6 @@ if test "x${have_systemd_pkg}" = "xyes" -a "x${want_systemd}" = "xno"; then
|
|||
echo " || ||"
|
||||
fi
|
||||
|
||||
|
||||
if test -n "$CFOPT_WARNING"; then
|
||||
echo "_____________________________________________________________________"
|
||||
echo ""
|
||||
|
@ -4862,17 +4772,6 @@ if test -n "$CFOPT_WARNING"; then
|
|||
echo "configure."
|
||||
echo "_____________________________________________________________________"
|
||||
fi
|
||||
if test "x${build_crypto}" = "xgnutls"; then
|
||||
echo "_____________________________________________________________________"
|
||||
echo "You have chosen gnutls as the crypto back-end. This will have some"
|
||||
echo "side-effects that can break set-uid root binaries that happen to"
|
||||
echo "link to and/or use EFL. These do actually exist. Gnutls will drop"
|
||||
echo "root privs if it detects being setuid, thus breaking these tools"
|
||||
echo "and their functionality. Only enable gnutls if you REALLY know"
|
||||
echo "what you are doing and are willing to live with broken "
|
||||
echo "functionality."
|
||||
echo "_____________________________________________________________________"
|
||||
fi
|
||||
if test "x${want_physics}" = "xno"; then
|
||||
echo "_____________________________________________________________________"
|
||||
echo "You have chosen to disable physics support. This disables lots of"
|
||||
|
|
|
@ -63,8 +63,6 @@ CLEANFILES += libeo.so.@VMAJ@.@VMIN@.@VMIC@-gdb.py
|
|||
|
||||
EXTRA_DIST += $(eogdb_SCRIPTS) eo/libeo-gdb.py.in
|
||||
|
||||
if BUILD_GUI
|
||||
|
||||
########################################################################
|
||||
# Edje
|
||||
edjefilesdir = $(datadir)/edje/include
|
||||
|
@ -111,7 +109,6 @@ ethumb/frames/border-0.jpg
|
|||
ethumb_clientfilesdir = $(datadir)/ethumb_client
|
||||
ethumb_clientfiles_DATA = ethumb_client/checkme
|
||||
EXTRA_DIST += $(ethumb_clientfiles_DATA)
|
||||
endif
|
||||
|
||||
########################################################################
|
||||
# Elua
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
if BUILD_GUI
|
||||
if EFL_BUILD_DOC
|
||||
|
||||
.PHONY: doc
|
||||
|
@ -24,7 +23,7 @@ AM_CPPFLAGS = \
|
|||
-I$(top_builddir)/src/lib/ecore_evas \
|
||||
-DEFL_BETA_API_SUPPORT=1 \
|
||||
-DEFL_EO_API_SUPPORT=1 \
|
||||
@ECORE_EVAS_LDFLAGS@
|
||||
@ECORE_EVAS_CFLAGS@
|
||||
|
||||
LDADD = \
|
||||
$(top_builddir)/src/lib/eina/libeina.la \
|
||||
|
@ -64,10 +63,10 @@ doc: Makefile previews-data
|
|||
endif
|
||||
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = preview_text_filter.c
|
||||
|
||||
clean-local:
|
||||
rm -rf $(DATADIR)
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ case "m4_defn([DOWNOTHER])" in
|
|||
;;
|
||||
esac
|
||||
requirements_pc_[]m4_defn([DOWNEFL])="${depname} >= ${PACKAGE_VERSION} ${requirements_pc_[][]m4_defn([DOWNEFL])}"
|
||||
requirements_cflags_[]m4_defn([DOWNEFL])="-I\$(top_srcdir)/src/lib/${libdirname} -I\$(top_builddir)/src/lib/${libdirname} ${requirements_cflags_[][]m4_defn([DOWNEFL])}"
|
||||
requirements_cflags_[]m4_defn([DOWNEFL])="-I\$(top_srcdir)/src/lib/${libdirname} -I\$(top_builddir)/src/lib/${libdirname} ${requirements_cflags_[][]m4_defn([DOWNOTHER])} ${requirements_cflags_[][]m4_defn([DOWNEFL])}"
|
||||
requirements_internal_libs_[]m4_defn([DOWNEFL])="lib/${libdirname}/lib${libname}.la ${requirements_internal_libs_[][]m4_defn([DOWNEFL])}"
|
||||
requirements_internal_deps_libs_[]m4_defn([DOWNEFL])="${requirements_public_libs_[]m4_defn([DOWNOTHER])} ${requirements_internal_deps_libs_[][]m4_defn([DOWNEFL])}"
|
||||
m4_popdef([DOWNOTHER])dnl
|
||||
|
|
|
@ -61,3 +61,4 @@
|
|||
/efl.pc
|
||||
/efl-cxx.pc
|
||||
/elua.pc
|
||||
/emile.pc
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: emile
|
||||
Description: Library for simplified serialization, compression and ciphering.
|
||||
Version: @VERSION@
|
||||
Requires.private: @requirements_pc_emile@
|
||||
Libs: -L${libdir} -lemile
|
||||
Libs.private: @requirements_libs_emile@
|
||||
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/emile-@VMAJ@
|
|
@ -31,21 +31,14 @@ include Makefile_Escape.am
|
|||
include Makefile_Eina.am
|
||||
include Makefile_Eo.am
|
||||
include Makefile_Efl.am
|
||||
include Makefile_Emile.am
|
||||
include Makefile_Eet.am
|
||||
include Makefile_Eolian.am
|
||||
include Makefile_Evas.am
|
||||
include Makefile_Ecore.am
|
||||
include Makefile_Ecore_Con.am
|
||||
include Makefile_Ecore_Ipc.am
|
||||
include Makefile_Ecore_File.am
|
||||
include Makefile_Ecore_Avahi.am
|
||||
include Makefile_Embryo.am
|
||||
include Makefile_Eio.am
|
||||
include Makefile_Eldbus.am
|
||||
include Makefile_Efreet.am
|
||||
include Makefile_Eeze.am
|
||||
|
||||
if BUILD_GUI
|
||||
include Makefile_Evas.am
|
||||
include Makefile_Ecore_Input.am
|
||||
include Makefile_Ecore_Input_Evas.am
|
||||
include Makefile_Ecore_Cocoa.am
|
||||
|
@ -56,21 +49,23 @@ include Makefile_Ecore_SDL.am
|
|||
include Makefile_Ecore_Wayland.am
|
||||
include Makefile_Ecore_Win32.am
|
||||
include Makefile_Ecore_X.am
|
||||
include Makefile_Ecore_Audio.am
|
||||
include Makefile_Ecore_IMF.am
|
||||
include Makefile_Ecore_IMF_Evas.am
|
||||
include Makefile_Ecore_Evas.am
|
||||
include Makefile_Ecore_Audio.am
|
||||
include Makefile_Ecore_Audio_Cxx.am
|
||||
include Makefile_Ecore_Avahi.am
|
||||
include Makefile_Embryo.am
|
||||
include Makefile_Eio.am
|
||||
include Makefile_Eldbus.am
|
||||
include Makefile_Efreet.am
|
||||
include Makefile_Eeze.am
|
||||
include Makefile_EPhysics.am
|
||||
include Makefile_Edje.am
|
||||
include Makefile_Emotion.am
|
||||
include Makefile_Ethumb.am
|
||||
include Makefile_Ethumb_Client.am
|
||||
|
||||
include Makefile_Ecore_Audio_Cxx.am
|
||||
include Makefile_Edje_Cxx.am
|
||||
include Makefile_Evas_Cxx.am
|
||||
endif
|
||||
|
||||
include Makefile_Eina_Cxx.am
|
||||
include Makefile_Ecore_Cxx.am
|
||||
include Makefile_Eldbus_Cxx.am
|
||||
|
@ -78,6 +73,9 @@ include Makefile_Eolian_Cxx.am
|
|||
include Makefile_Eet_Cxx.am
|
||||
include Makefile_Eo_Cxx.am
|
||||
include Makefile_Efl_Cxx.am
|
||||
include Makefile_Edje_Cxx.am
|
||||
include Makefile_Evas_Cxx.am
|
||||
|
||||
include Makefile_Elua.am
|
||||
include Makefile_Elocation.am
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
### Library
|
||||
lib_LTLIBRARIES += lib/emile/libemile.la
|
||||
|
||||
installed_emilemainheadersdir = $(includedir)/emile-@VMAJ@
|
||||
dist_installed_emilemainheaders_DATA = \
|
||||
lib/emile/Emile.h \
|
||||
lib/emile/emile_cipher.h \
|
||||
lib/emile/emile_compress.h \
|
||||
lib/emile/emile_image.h
|
||||
|
||||
lib_emile_libemile_la_SOURCES = \
|
||||
lib/emile/emile_private.h \
|
||||
lib/emile/emile_main.c \
|
||||
lib/emile/emile_compress.c \
|
||||
lib/emile/emile_image.c \
|
||||
static_libs/rg_etc/rg_etc1.c \
|
||||
static_libs/rg_etc/rg_etc2.c \
|
||||
static_libs/rg_etc/rg_etc1.h \
|
||||
static_libs/rg_etc/etc2_encoder.c
|
||||
|
||||
if ! ENABLE_LIBLZ4
|
||||
lib_emile_libemile_la_SOURCES += \
|
||||
static_libs/lz4/lz4.c \
|
||||
static_libs/lz4/lz4.h \
|
||||
static_libs/lz4/lz4hc.c \
|
||||
static_libs/lz4/lz4hc.h
|
||||
endif
|
||||
|
||||
if HAVE_CRYPTO_GNUTLS
|
||||
lib_emile_libemile_la_SOURCES += lib/emile/emile_cipher_gnutls.c
|
||||
else
|
||||
if HAVE_CRYPTO_OPENSSL
|
||||
lib_emile_libemile_la_SOURCES += lib/emile/emile_cipher_openssl.c
|
||||
else
|
||||
lib_emile_libemile_la_SOURCES += lib/emile/emile_cipher.c
|
||||
endif
|
||||
endif
|
||||
|
||||
lib_emile_libemile_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/static_libs/rg_etc \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/emile\" \
|
||||
@EMILE_CFLAGS@
|
||||
|
||||
if ! ENABLE_LIBLZ4
|
||||
lib_emile_libemile_la_CPPFLAGS += \
|
||||
-I$(top_srcdir)/src/static_libs/lz4
|
||||
endif
|
||||
|
||||
lib_emile_libemile_la_LIBADD = @EMILE_LIBS@
|
||||
lib_emile_libemile_la_DEPENDENCIES = @EMILE_INTERNAL_LIBS@
|
||||
lib_emile_libemile_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||
|
||||
if ! ENABLE_LIBLZ4
|
||||
lib_emile_libemile_la_LIBADD += @LIBLZ4_LIBS@
|
||||
endif
|
||||
|
||||
EXTRA_DIST += static_libs/lz4/README \
|
||||
static_libs/lz4/lz4.c \
|
||||
static_libs/lz4/lz4.h \
|
||||
static_libs/lz4/lz4hc.c \
|
||||
static_libs/lz4/lz4hc.h \
|
||||
static_libs/rg_etc/README
|
||||
|
||||
### Binary
|
||||
|
||||
# None yet, maybe a tool to manually use cypher/compression ?
|
||||
|
||||
### Unit tests
|
||||
|
||||
if EFL_ENABLE_TESTS
|
||||
|
||||
check_PROGRAMS += tests/emile/emile_suite
|
||||
TESTS += tests/emile/emile_suite
|
||||
|
||||
tests_emile_emile_suite_SOURCES = \
|
||||
tests/emile/emile_suite.c
|
||||
|
||||
tests_emile_emile_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-DTESTS_WD=\"`pwd`\" \
|
||||
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/emile\" \
|
||||
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/emile\" \
|
||||
@CHECK_CFLAGS@ \
|
||||
@EMILE_CFLAGS@
|
||||
|
||||
tests_emile_emile_suite_LDADD = @CHECK_LIBS@ @USE_EMILE_LIBS@
|
||||
tests_emile_emile_suite_DEPENDENCIES = @USE_EMILE_INTERNAL_LIBS@
|
||||
|
||||
endif
|
|
@ -1343,7 +1343,7 @@ bin/evas/evas_cserve2_client.c
|
|||
bin_evas_evas_cserve2_client_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/lib/evas \
|
||||
-I$(top_srcdir)/src/lib/evas/cserve2 \
|
||||
@EINA_CFLAGS@
|
||||
@EVAS_CFLAGS@
|
||||
bin_evas_evas_cserve2_client_LDADD = @USE_EINA_LIBS@
|
||||
bin_evas_evas_cserve2_client_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
|
||||
|
||||
|
@ -1352,7 +1352,7 @@ bin/evas/evas_cserve2_usage.c
|
|||
bin_evas_evas_cserve2_usage_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/lib/evas \
|
||||
-I$(top_srcdir)/src/lib/evas/cserve2 \
|
||||
@EINA_CFLAGS@
|
||||
@EVAS_CFLAGS@
|
||||
bin_evas_evas_cserve2_usage_LDADD = @USE_EINA_LIBS@
|
||||
bin_evas_evas_cserve2_usage_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ bin/evas/evas_cserve2_debug.c
|
|||
bin_evas_evas_cserve2_debug_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/lib/evas \
|
||||
-I$(top_srcdir)/src/lib/evas/cserve2 \
|
||||
@EINA_CFLAGS@
|
||||
@EVAS_CFLAGS@
|
||||
bin_evas_evas_cserve2_debug_LDADD = @USE_EINA_LIBS@
|
||||
bin_evas_evas_cserve2_debug_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ bin/evas/evas_cserve2_shm_debug.c
|
|||
bin_evas_evas_cserve2_shm_debug_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/lib/evas \
|
||||
-I$(top_srcdir)/src/lib/evas/cserve2 \
|
||||
@EINA_CFLAGS@
|
||||
@EVAS_CFLAGS@
|
||||
bin_evas_evas_cserve2_shm_debug_LDADD = @USE_EINA_LIBS@
|
||||
bin_evas_evas_cserve2_shm_debug_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
|
|||
AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/lib/eina \
|
||||
-I$(top_srcdir)/src/lib/emile \
|
||||
-I$(top_srcdir)/src/lib/eo \
|
||||
-I$(top_srcdir)/src/lib/evas \
|
||||
-I$(top_srcdir)/src/lib/ecore \
|
||||
|
@ -15,6 +16,7 @@ AM_CPPFLAGS = \
|
|||
-I$(top_srcdir)/src/lib/ecore_evas \
|
||||
-I$(top_srcdir)/src/lib/ecore_audio \
|
||||
-I$(top_builddir)/src/lib/eina \
|
||||
-I$(top_builddir)/src/lib/emile \
|
||||
-I$(top_builddir)/src/lib/eo \
|
||||
-I$(top_builddir)/src/lib/evas \
|
||||
-I$(top_builddir)/src/lib/ecore \
|
||||
|
@ -71,6 +73,7 @@ ECORE_COMMON_LDADD = \
|
|||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(top_builddir)/src/lib/eo/libeo.la \
|
||||
$(top_builddir)/src/lib/eina/libeina.la \
|
||||
$(top_builddir)/src/lib/emile/libemile.la \
|
||||
@ECORE_LDFLAGS@
|
||||
|
||||
if HAVE_ECORE_AUDIO
|
||||
|
|
|
@ -126,6 +126,7 @@ eina_tiler_01_CPPFLAGS = \
|
|||
-I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_builddir)/src/lib/efl/interfaces \
|
||||
-I$(top_builddir)/src/lib/eina \
|
||||
-I$(top_builddir)/src/lib/emile \
|
||||
-I$(top_builddir)/src/lib/eo \
|
||||
-I$(top_builddir)/src/lib/evas \
|
||||
-I$(top_builddir)/src/lib/ecore \
|
||||
|
@ -135,6 +136,7 @@ eina_tiler_01_CPPFLAGS = \
|
|||
|
||||
eina_tiler_01_LDADD = \
|
||||
$(top_builddir)/src/lib/eina/libeina.la \
|
||||
$(top_builddir)/src/lib/emile/libemile.la \
|
||||
$(top_builddir)/src/lib/eo/libeo.la \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(top_builddir)/src/lib/ecore_input/libecore_input.la \
|
||||
|
|
|
@ -3,11 +3,13 @@ MAINTAINERCLEANFILES = Makefile.in
|
|||
AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/lib/eina \
|
||||
-I$(top_srcdir)/src/lib/emile \
|
||||
-I$(top_srcdir)/src/lib/eo \
|
||||
-I$(top_srcdir)/src/lib/eet \
|
||||
-I$(top_srcdir)/src/lib/ecore \
|
||||
-I$(top_srcdir)/src/lib/eio \
|
||||
-I$(top_builddir)/src/lib/eina \
|
||||
-I$(top_builddir)/src/lib/emile \
|
||||
-I$(top_builddir)/src/lib/eo \
|
||||
-I$(top_builddir)/src/lib/eet \
|
||||
-I$(top_builddir)/src/lib/ecore \
|
||||
|
@ -23,6 +25,7 @@ $(top_builddir)/src/lib/eio/libeio.la \
|
|||
$(top_builddir)/src/lib/eo/libeo.la \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(top_builddir)/src/lib/eet/libeet.la \
|
||||
$(top_builddir)/src/lib/emile/libemile.la \
|
||||
$(top_builddir)/src/lib/eina/libeina.la \
|
||||
@EIO_LDFLAGS@
|
||||
|
||||
|
@ -32,6 +35,7 @@ $(top_builddir)/src/lib/eio/libeio.la \
|
|||
$(top_builddir)/src/lib/eo/libeo.la \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(top_builddir)/src/lib/eet/libeet.la \
|
||||
$(top_builddir)/src/lib/emile/libemile.la \
|
||||
$(top_builddir)/src/lib/eina/libeina.la \
|
||||
@EIO_LDFLAGS@
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ AM_CXXFLAGS = \
|
|||
-I$(top_builddir)/src/lib/efl/interfaces \
|
||||
-I$(top_srcdir)/src/lib/eina \
|
||||
-I$(top_builddir)/src/lib/eina \
|
||||
-I$(top_srcdir)/src/lib/emile \
|
||||
-I$(top_builddir)/src/lib/emile \
|
||||
-I$(top_srcdir)/src/lib/eo \
|
||||
-I$(top_builddir)/src/lib/eo \
|
||||
-I$(top_srcdir)/src/bindings/eo_cxx \
|
||||
|
@ -45,6 +47,7 @@ AM_CFLAGS = $(AM_CXXFLAGS)
|
|||
AM_LDFLAGS = \
|
||||
-L$(top_builddir)/src/lib/efl \
|
||||
-L$(top_builddir)/src/lib/eina \
|
||||
-L$(top_builddir)/src/lib/emile \
|
||||
-L$(top_builddir)/src/lib/eo \
|
||||
-L$(top_builddir)/src/lib/evas \
|
||||
-L$(top_builddir)/src/lib/ecore \
|
||||
|
@ -55,6 +58,7 @@ LDADD = \
|
|||
$(top_builddir)/src/lib/efl/libefl.la \
|
||||
$(top_builddir)/src/lib/eo/libeo.la \
|
||||
$(top_builddir)/src/lib/eina/libeina.la \
|
||||
$(top_builddir)/src/lib/emile/libemile.la \
|
||||
$(top_builddir)/src/lib/evas/libevas.la \
|
||||
$(top_builddir)/src/lib/ecore_evas/libecore_evas.la
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ _ecore_con_socks_svr_init_v4(Ecore_Con_Server *obj, Ecore_Con_Socks_v4 *v4)
|
|||
sbuf[8] = 0;
|
||||
if (addrlen) memcpy(sbuf + 8 + ulen, svr->name, addrlen);
|
||||
|
||||
svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
|
||||
svr->ecs_buf = eina_binbuf_manage_new(sbuf, buflen, EINA_FALSE);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *obj, Ecore_Con_Socks_v5 *v5)
|
|||
sbuf[2] = ECORE_CON_SOCKS_V5_METHOD_NONE;
|
||||
}
|
||||
|
||||
svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
|
||||
svr->ecs_buf = eina_binbuf_manage_new(sbuf, buflen, EINA_FALSE);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ _ecore_con_socks_auth_v5(Ecore_Con_Server *obj, Ecore_Con_Socks_v5 *v5)
|
|||
memcpy(&data[2 + v5->ulen], v5->password, v5->plen);
|
||||
else
|
||||
data[2 + v5->ulen] = 0;
|
||||
svr->ecs_buf = eina_binbuf_manage_new_length(data, size);
|
||||
svr->ecs_buf = eina_binbuf_manage_new(data, size, EINA_FALSE);
|
||||
return EINA_TRUE;
|
||||
|
||||
default:
|
||||
|
@ -412,7 +412,7 @@ _ecore_con_socks_read_v5(Ecore_Con_Server *obj, Ecore_Con_Socks_v5 *v5, const un
|
|||
sbuf[addrlen + 4] = svr->port >> 8;
|
||||
sbuf[addrlen + 5] = svr->port & 0xff;
|
||||
|
||||
svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
|
||||
svr->ecs_buf = eina_binbuf_manage_new(sbuf, buflen, EINA_FALSE);
|
||||
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <Emile.h>
|
||||
|
||||
#include "Ecore.h"
|
||||
#include "ecore_con_private.h"
|
||||
|
||||
|
@ -35,8 +38,6 @@ EAPI int ECORE_CON_EVENT_SERVER_UPGRADE = 0;
|
|||
static int _init_con_ssl_init_count = 0;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
GCRY_THREAD_OPTION_PTHREAD_IMPL;
|
||||
|
||||
static int _client_connected = 0;
|
||||
|
||||
# define SSL_SUFFIX(ssl_func) ssl_func ## _gnutls
|
||||
|
@ -425,11 +426,6 @@ _openssl_print_session(SSL *ssl)
|
|||
} \
|
||||
while (0)
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
SSL_SUFFIX(_ecore_con_ssl_init) (void);
|
||||
static Ecore_Con_Ssl_Error
|
||||
SSL_SUFFIX(_ecore_con_ssl_shutdown) (void);
|
||||
|
||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server *svr, const char *ca_file);
|
||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server *svr, const char *crl_file);
|
||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server *svr, const char *cert);
|
||||
|
@ -457,7 +453,16 @@ ecore_con_ssl_init(void)
|
|||
{
|
||||
if (!_init_con_ssl_init_count++)
|
||||
{
|
||||
SSL_SUFFIX(_ecore_con_ssl_init) ();
|
||||
#if defined ISCOMFITOR && defined HAVE_GNUTLS
|
||||
if (eina_log_domain_level_check(_ecore_con_log_dom,
|
||||
EINA_LOG_LEVEL_DBG))
|
||||
{
|
||||
gnutls_global_set_log_level(9);
|
||||
gnutls_global_set_log_function(_gnutls_log_func);
|
||||
}
|
||||
#endif
|
||||
emile_init();
|
||||
|
||||
#if _ECORE_CON_SSL_AVAILABLE != 0
|
||||
ECORE_CON_EVENT_CLIENT_UPGRADE = ecore_event_type_new();
|
||||
ECORE_CON_EVENT_SERVER_UPGRADE = ecore_event_type_new();
|
||||
|
@ -478,7 +483,7 @@ ecore_con_ssl_shutdown(void)
|
|||
}
|
||||
|
||||
if (!--_init_con_ssl_init_count)
|
||||
SSL_SUFFIX(_ecore_con_ssl_shutdown) ();
|
||||
emile_shutdown();
|
||||
|
||||
return _init_con_ssl_init_count;
|
||||
}
|
||||
|
@ -489,6 +494,9 @@ ecore_con_ssl_server_prepare(Ecore_Con_Server *svr,
|
|||
{
|
||||
if (!ssl_type)
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
if (!emile_cipher_init())
|
||||
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
||||
|
||||
return SSL_SUFFIX(_ecore_con_ssl_server_prepare) (svr, ssl_type);
|
||||
}
|
||||
|
||||
|
@ -739,32 +747,6 @@ ecore_con_ssl_client_upgrade(Ecore_Con_Client *obj, Ecore_Con_Type ssl_type)
|
|||
* GnuTLS
|
||||
*/
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_init_gnutls(void)
|
||||
{
|
||||
if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
|
||||
WRN("YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
|
||||
if (gnutls_global_init())
|
||||
return ECORE_CON_SSL_ERROR_INIT_FAILED;
|
||||
|
||||
#ifdef ISCOMFITOR
|
||||
if (eina_log_domain_level_check(_ecore_con_log_dom, EINA_LOG_LEVEL_DBG))
|
||||
{
|
||||
gnutls_global_set_log_level(9);
|
||||
gnutls_global_set_log_function(_gnutls_log_func);
|
||||
}
|
||||
#endif
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
}
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_shutdown_gnutls(void)
|
||||
{
|
||||
gnutls_global_deinit();
|
||||
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
}
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *obj,
|
||||
int ssl_type)
|
||||
|
@ -1389,24 +1371,6 @@ _ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *obj,
|
|||
* OpenSSL
|
||||
*/
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_init_openssl(void)
|
||||
{
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
}
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_shutdown_openssl(void)
|
||||
{
|
||||
ERR_free_strings();
|
||||
EVP_cleanup();
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
}
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *obj,
|
||||
int ssl_type)
|
||||
|
@ -1911,19 +1875,6 @@ _ecore_con_ssl_client_write_openssl(Ecore_Con_Client *obj,
|
|||
/*
|
||||
* No Ssl
|
||||
*/
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_init_none(void)
|
||||
{
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
}
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_shutdown_none(void)
|
||||
{
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
}
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||
int ssl_type EINA_UNUSED)
|
||||
|
|
|
@ -1506,7 +1506,7 @@ edje_edit_sound_samplebuffer_get(Evas_Object *obj, const char *sample_name)
|
|||
return NULL;
|
||||
}
|
||||
eet_close(ef);
|
||||
return eina_binbuf_manage_read_only_new_length(data, len);
|
||||
return eina_binbuf_manage_new(data, len, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -96,8 +96,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <Eina.h>
|
||||
#include <Efl_Config.h>
|
||||
#include <Eina.h>
|
||||
#include <Emile.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
|
@ -481,25 +482,24 @@ typedef enum _Eet_File_Mode
|
|||
* Specify lossy encoding for image
|
||||
* @since 1.10
|
||||
*/
|
||||
typedef enum _Eet_Image_Encoding
|
||||
{
|
||||
EET_IMAGE_LOSSLESS = 0,
|
||||
EET_IMAGE_JPEG = 1,
|
||||
EET_IMAGE_ETC1 = 2,
|
||||
EET_IMAGE_ETC2_RGB = 3,
|
||||
EET_IMAGE_ETC2_RGBA = 4,
|
||||
EET_IMAGE_ETC1_ALPHA = 5,
|
||||
} Eet_Image_Encoding;
|
||||
typedef Emile_Image_Encoding Eet_Image_Encoding;
|
||||
|
||||
typedef enum _Eet_Colorspace
|
||||
{
|
||||
EET_COLORSPACE_ARGB8888 = 0,
|
||||
/* The number between are reserved to preserve compatibility with evas */
|
||||
EET_COLORSPACE_ETC1 = 9,
|
||||
EET_COLORSPACE_RGB8_ETC2 = 10,
|
||||
EET_COLORSPACE_RGBA8_ETC2_EAC = 11,
|
||||
EET_COLORSPACE_ETC1_ALPHA = 12
|
||||
} Eet_Colorspace;
|
||||
#define EET_IMAGE_LOSSLESS EMILE_IMAGE_LOSSLESS
|
||||
#define EET_IMAGE_JPEG EMILE_IMAGE_JPEG
|
||||
#define EET_IMAGE_ETC1 EMILE_IMAGE_ETC1
|
||||
#define EET_IMAGE_ETC2_RGB EMILE_IMAGE_ETC2_RGB
|
||||
#define EET_IMAGE_ETC2_RGBA EMILE_IMAGE_ETC2_RGBA
|
||||
#define EET_IMAGE_ETC1_ALPHA EMILE_IMAGE_ETC1_ALPHA
|
||||
|
||||
typedef Emile_Colorspace Eet_Colorspace;
|
||||
|
||||
#define EET_COLORSPACE_ARGB8888 EMILE_COLORSPACE_ARGB8888
|
||||
#define EET_COLORSPACE_GRY8 EMILE_COLORSPACE_GRY8
|
||||
#define EET_COLORSPACE_AGRY88 EMILE_COLORSPACE_AGRY88
|
||||
#define EET_COLORSPACE_ETC1 EMILE_COLORSPACE_ETC1
|
||||
#define EET_COLORSPACE_RGB8_ETC2 EMILE_COLORSPACE_RGB8_ETC2
|
||||
#define EET_COLORSPACE_RGBA8_ETC2_EAC EMILE_COLORSPACE_RGBA8_ETC2_EAC
|
||||
#define EET_COLORSPACE_ETC1_ALPHA EMILE_COLORSPACE_ETC1_ALPHA
|
||||
|
||||
/**
|
||||
* @typedef Eet_File
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _EET_PRIVATE_H
|
||||
|
||||
#include <Eina.h>
|
||||
#include <Emile.h>
|
||||
|
||||
typedef enum _Eet_Convert_Type Eet_Convert_Type;
|
||||
|
||||
|
@ -298,6 +299,16 @@ Eet_Node *
|
|||
void
|
||||
eet_node_free(Eet_Node *node);
|
||||
|
||||
static inline Emile_Compressor_Type
|
||||
eet_2_emile_compressor(int comp)
|
||||
{
|
||||
switch (comp)
|
||||
{
|
||||
case EET_COMPRESSION_VERYFAST: return EMILE_LZ4HC;
|
||||
case EET_COMPRESSION_SUPERFAST: return EMILE_LZ4HC;
|
||||
default: return EMILE_ZLIB;
|
||||
}
|
||||
}
|
||||
|
||||
#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
|
||||
TYPE *Type##_malloc(unsigned int); \
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
# endif /* ifdef HAVE_GNUTLS */
|
||||
#endif /* ifdef HAVE_CIPHER */
|
||||
|
||||
#include <Emile.h>
|
||||
|
||||
#include "Eet.h"
|
||||
#include "Eet_private.h"
|
||||
|
||||
|
@ -59,25 +61,6 @@
|
|||
# define MAX_IV_LEN EVP_MAX_IV_LENGTH
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
|
||||
#ifdef HAVE_CIPHER
|
||||
# ifdef HAVE_GNUTLS
|
||||
static Eet_Error
|
||||
eet_hmac_sha1(const void *key,
|
||||
size_t key_len,
|
||||
const void *data,
|
||||
size_t data_len,
|
||||
unsigned char *res);
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
static Eet_Error
|
||||
eet_pbkdf2_sha1(const char *key,
|
||||
int key_len,
|
||||
const unsigned char *salt,
|
||||
unsigned int salt_len,
|
||||
int iter,
|
||||
unsigned char *res,
|
||||
int res_len);
|
||||
#endif /* ifdef HAVE_CIPHER */
|
||||
|
||||
struct _Eet_Key
|
||||
{
|
||||
int references;
|
||||
|
@ -107,6 +90,8 @@ eet_identity_open(const char *certificate_file,
|
|||
gnutls_datum_t load_file = { NULL, 0 };
|
||||
char pass[1024];
|
||||
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Init */
|
||||
if (!(key = malloc(sizeof(Eet_Key))))
|
||||
goto on_error;
|
||||
|
@ -206,6 +191,8 @@ on_error:
|
|||
EVP_PKEY *pkey = NULL;
|
||||
X509 *cert = NULL;
|
||||
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Load the X509 certificate in memory. */
|
||||
fp = fopen(certificate_file, "r");
|
||||
if (!fp)
|
||||
|
@ -261,6 +248,8 @@ on_error:
|
|||
EAPI void
|
||||
eet_identity_close(Eet_Key *key)
|
||||
{
|
||||
if (!emile_cipher_init()) return ;
|
||||
|
||||
#ifdef HAVE_SIGNATURE
|
||||
if (!key || (key->references > 0))
|
||||
return;
|
||||
|
@ -303,6 +292,8 @@ eet_identity_print(Eet_Key *key,
|
|||
if (!key)
|
||||
return;
|
||||
|
||||
if (!emile_cipher_init()) return ;
|
||||
|
||||
if (key->private_key)
|
||||
{
|
||||
if (gnutls_x509_privkey_export_rsa_raw(key->private_key,
|
||||
|
@ -371,6 +362,8 @@ on_error:
|
|||
if (!key)
|
||||
return;
|
||||
|
||||
if (!emile_cipher_init()) return ;
|
||||
|
||||
rsa = EVP_PKEY_get1_RSA(key->private_key);
|
||||
if (rsa)
|
||||
{
|
||||
|
@ -490,6 +483,8 @@ eet_identity_sign(FILE *fp,
|
|||
if (!fp || !key || !key->certificate || !key->private_key)
|
||||
return EET_ERROR_BAD_OBJECT;
|
||||
|
||||
if (!emile_cipher_init()) return EET_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
/* Get the file size. */
|
||||
fd = fileno(fp);
|
||||
if (fd < 0)
|
||||
|
@ -656,6 +651,8 @@ eet_identity_check(const void *data_base,
|
|||
if (signature_length < sizeof(int) * 3)
|
||||
return NULL;
|
||||
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Get the header */
|
||||
memcpy(&magic, header, sizeof(int));
|
||||
memcpy(&sign_len, header+1, sizeof(int));
|
||||
|
@ -818,6 +815,8 @@ eet_identity_certificate_print(const unsigned char *certificate,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!emile_cipher_init()) return ;
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
gnutls_datum_t datum;
|
||||
gnutls_x509_crt_t cert;
|
||||
|
@ -880,177 +879,17 @@ eet_cipher(const void *data,
|
|||
void **result,
|
||||
unsigned int *result_length)
|
||||
{
|
||||
#ifdef HAVE_CIPHER
|
||||
/* Cipher declarations */
|
||||
unsigned int *ret = NULL;
|
||||
unsigned char iv[MAX_IV_LEN];
|
||||
unsigned char ik[MAX_KEY_LEN];
|
||||
unsigned char key_material[MAX_IV_LEN + MAX_KEY_LEN];
|
||||
unsigned int salt;
|
||||
unsigned int tmp = 0;
|
||||
int crypted_length;
|
||||
int opened = 0;
|
||||
# ifdef HAVE_GNUTLS
|
||||
/* Gcrypt declarations */
|
||||
gcry_error_t err = 0;
|
||||
gcry_cipher_hd_t cipher;
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
/* Openssl declarations*/
|
||||
EVP_CIPHER_CTX ctx;
|
||||
unsigned int *buffer = NULL;
|
||||
int tmp_len;
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
Eina_Binbuf *out;
|
||||
Eina_Binbuf *in;
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
/* Gcrypt salt generation */
|
||||
gcry_create_nonce((unsigned char *)&salt, sizeof(salt));
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
/* Openssl salt generation */
|
||||
if (!RAND_bytes((unsigned char *)&salt, sizeof (unsigned int)))
|
||||
return EET_ERROR_PRNG_NOT_SEEDED;
|
||||
in = eina_binbuf_manage_new(data, size, EINA_TRUE);
|
||||
out = emile_binbuf_cipher(EMILE_AES256_CBC, in, key, length);
|
||||
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
if (result_length) *result_length = out ? eina_binbuf_length_get(out) : 0;
|
||||
if (result) *result = out ? eina_binbuf_string_steal(out) : NULL;
|
||||
|
||||
eet_pbkdf2_sha1(key,
|
||||
length,
|
||||
(unsigned char *)&salt,
|
||||
sizeof(unsigned int),
|
||||
2048,
|
||||
key_material,
|
||||
MAX_KEY_LEN + MAX_IV_LEN);
|
||||
|
||||
memcpy(iv, key_material, MAX_IV_LEN);
|
||||
memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
|
||||
|
||||
memset(key_material, 0, sizeof (key_material));
|
||||
|
||||
crypted_length = ((((size + sizeof (unsigned int)) >> 5) + 1) << 5);
|
||||
ret = malloc(crypted_length + sizeof(unsigned int));
|
||||
if (!ret)
|
||||
{
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
memset(&salt, 0, sizeof (salt));
|
||||
return EET_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*ret = salt;
|
||||
memset(&salt, 0, sizeof (salt));
|
||||
tmp = htonl(size);
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
*(ret + 1) = tmp;
|
||||
memcpy(ret + 2, data, size);
|
||||
|
||||
/* Gcrypt create the corresponding cipher
|
||||
AES with a 256 bit key, Cipher Block Chaining mode */
|
||||
err = gcry_cipher_open(&cipher, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
opened = 1;
|
||||
err = gcry_cipher_setiv(cipher, iv, MAX_IV_LEN);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
err = gcry_cipher_setkey(cipher, ik, MAX_KEY_LEN);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
/* Gcrypt encrypt */
|
||||
err = gcry_cipher_encrypt(cipher,
|
||||
(unsigned char *)(ret + 1),
|
||||
crypted_length,
|
||||
NULL,
|
||||
0);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
/* Gcrypt close the cipher */
|
||||
gcry_cipher_close(cipher);
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
buffer = malloc(crypted_length);
|
||||
if (!buffer) goto on_error;
|
||||
*buffer = tmp;
|
||||
|
||||
memcpy(buffer + 1, data, size);
|
||||
|
||||
/* Openssl create the corresponding cipher
|
||||
AES with a 256 bit key, Cipher Block Chaining mode */
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
if (!EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, ik, iv))
|
||||
goto on_error;
|
||||
|
||||
opened = 1;
|
||||
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
/* Openssl encrypt */
|
||||
if (!EVP_EncryptUpdate(&ctx, (unsigned char *)(ret + 1), &tmp_len,
|
||||
(unsigned char *)buffer,
|
||||
size + sizeof(unsigned int)))
|
||||
goto on_error;
|
||||
|
||||
/* Openssl close the cipher */
|
||||
if (!EVP_EncryptFinal_ex(&ctx, ((unsigned char *)(ret + 1)) + tmp_len,
|
||||
&tmp_len))
|
||||
goto on_error;
|
||||
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
free(buffer);
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
|
||||
/* Set return values */
|
||||
if (result_length)
|
||||
*result_length = crypted_length + sizeof(unsigned int);
|
||||
|
||||
if (result)
|
||||
*result = ret;
|
||||
else
|
||||
free(ret);
|
||||
|
||||
return EET_ERROR_NONE;
|
||||
|
||||
on_error:
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
/* Gcrypt error */
|
||||
if (opened)
|
||||
gcry_cipher_close(cipher);
|
||||
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
/* Openssl error */
|
||||
if (opened)
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
free(buffer);
|
||||
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
/* General error */
|
||||
free(ret);
|
||||
if (result)
|
||||
*result = NULL;
|
||||
|
||||
if (result_length)
|
||||
*result_length = 0;
|
||||
|
||||
return EET_ERROR_ENCRYPT_FAILED;
|
||||
#else /* ifdef HAVE_CIPHER */
|
||||
/* Cipher not supported */
|
||||
(void)data;
|
||||
(void)size;
|
||||
(void)key;
|
||||
(void)length;
|
||||
(void)result;
|
||||
(void)result_length;
|
||||
return EET_ERROR_NOT_IMPLEMENTED;
|
||||
#endif /* ifdef HAVE_CIPHER */
|
||||
eina_binbuf_free(out);
|
||||
return out ? EET_ERROR_NONE : EET_ERROR_ENCRYPT_FAILED;
|
||||
}
|
||||
|
||||
Eet_Error
|
||||
|
@ -1061,261 +900,15 @@ eet_decipher(const void *data,
|
|||
void **result,
|
||||
unsigned int *result_length)
|
||||
{
|
||||
#ifdef HAVE_CIPHER
|
||||
const unsigned int *over = data;
|
||||
unsigned int *ret = NULL;
|
||||
unsigned char ik[MAX_KEY_LEN];
|
||||
unsigned char iv[MAX_IV_LEN];
|
||||
unsigned char key_material[MAX_KEY_LEN + MAX_IV_LEN];
|
||||
unsigned int salt;
|
||||
int tmp_len;
|
||||
int tmp = 0;
|
||||
int opened = 0;
|
||||
Eina_Binbuf *out;
|
||||
Eina_Binbuf *in;
|
||||
|
||||
/* At least the salt and an AES block */
|
||||
if (size < sizeof(unsigned int) + 16)
|
||||
return EET_ERROR_BAD_OBJECT;
|
||||
in = eina_binbuf_manage_new(data, size, EINA_TRUE);
|
||||
out = emile_binbuf_decipher(EMILE_AES256_CBC, in, key, length);
|
||||
|
||||
/* Get the salt */
|
||||
salt = *over;
|
||||
if (result_length) *result_length = out ? eina_binbuf_length_get(out) : 0;
|
||||
if (result) *result = out ? eina_binbuf_string_steal(out) : NULL;
|
||||
|
||||
/* Generate the iv and the key with the salt */
|
||||
eet_pbkdf2_sha1(key, length, (unsigned char *)&salt,
|
||||
sizeof(unsigned int), 2048, key_material,
|
||||
MAX_KEY_LEN + MAX_IV_LEN);
|
||||
|
||||
memcpy(iv, key_material, MAX_IV_LEN);
|
||||
memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
|
||||
|
||||
memset(key_material, 0, sizeof (key_material));
|
||||
memset(&salt, 0, sizeof (salt));
|
||||
|
||||
/* Align to AES block size if size is not align */
|
||||
tmp_len = size - sizeof (unsigned int);
|
||||
if ((tmp_len & 0x1F) != 0)
|
||||
goto on_error;
|
||||
|
||||
ret = malloc(tmp_len);
|
||||
if (!ret)
|
||||
goto on_error;
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
gcry_error_t err = 0;
|
||||
gcry_cipher_hd_t cipher;
|
||||
|
||||
/* Gcrypt create the corresponding cipher */
|
||||
err = gcry_cipher_open(&cipher, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err)
|
||||
return EET_ERROR_DECRYPT_FAILED;
|
||||
|
||||
err = gcry_cipher_setiv(cipher, iv, MAX_IV_LEN);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
err = gcry_cipher_setkey(cipher, ik, MAX_KEY_LEN);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
/* Gcrypt decrypt */
|
||||
err = gcry_cipher_decrypt(cipher, ret, tmp_len,
|
||||
((unsigned int *)data) + 1, tmp_len);
|
||||
if (err)
|
||||
goto on_error;
|
||||
|
||||
/* Gcrypt close the cipher */
|
||||
gcry_cipher_close(cipher);
|
||||
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
EVP_CIPHER_CTX ctx;
|
||||
|
||||
/* Openssl create the corresponding cipher */
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
opened = 1;
|
||||
|
||||
if (!EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, ik, iv))
|
||||
goto on_error;
|
||||
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
/* Openssl decrypt */
|
||||
if (!EVP_DecryptUpdate(&ctx, (unsigned char *)ret, &tmp,
|
||||
(unsigned char *)(over + 1), tmp_len))
|
||||
goto on_error;
|
||||
|
||||
/* Openssl close the cipher*/
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
/* Get the decrypted data size */
|
||||
tmp = *ret;
|
||||
tmp = ntohl(tmp);
|
||||
if (tmp > tmp_len || tmp <= 0)
|
||||
goto on_error;
|
||||
|
||||
/* Update the return values */
|
||||
if (result_length)
|
||||
*result_length = tmp;
|
||||
|
||||
if (result)
|
||||
{
|
||||
*result = NULL;
|
||||
*result = malloc(tmp);
|
||||
if (!*result)
|
||||
goto on_error;
|
||||
|
||||
memcpy(*result, ret + 1, tmp);
|
||||
}
|
||||
|
||||
free(ret);
|
||||
|
||||
return EET_ERROR_NONE;
|
||||
|
||||
on_error:
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
(void)opened;
|
||||
# else
|
||||
if (opened)
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
if (result)
|
||||
*result = NULL;
|
||||
|
||||
if (result_length)
|
||||
*result_length = 0;
|
||||
|
||||
if (ret)
|
||||
free(ret);
|
||||
|
||||
return EET_ERROR_DECRYPT_FAILED;
|
||||
#else /* ifdef HAVE_CIPHER */
|
||||
(void)data;
|
||||
(void)size;
|
||||
(void)key;
|
||||
(void)length;
|
||||
(void)result;
|
||||
(void)result_length;
|
||||
return EET_ERROR_NOT_IMPLEMENTED;
|
||||
#endif /* ifdef HAVE_CIPHER */
|
||||
eina_binbuf_free(out);
|
||||
return out ? EET_ERROR_NONE : EET_ERROR_DECRYPT_FAILED;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CIPHER
|
||||
# ifdef HAVE_GNUTLS
|
||||
static Eet_Error
|
||||
eet_hmac_sha1(const void *key,
|
||||
size_t key_len,
|
||||
const void *data,
|
||||
size_t data_len,
|
||||
unsigned char *res)
|
||||
{
|
||||
size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
|
||||
gcry_md_hd_t mdh;
|
||||
unsigned char *hash;
|
||||
gpg_error_t err;
|
||||
|
||||
err = gcry_md_open(&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
|
||||
if (err != GPG_ERR_NO_ERROR)
|
||||
return 1;
|
||||
|
||||
err = gcry_md_setkey(mdh, key, key_len);
|
||||
if (err != GPG_ERR_NO_ERROR)
|
||||
{
|
||||
gcry_md_close(mdh);
|
||||
return 1;
|
||||
}
|
||||
|
||||
gcry_md_write(mdh, data, data_len);
|
||||
|
||||
hash = gcry_md_read(mdh, GCRY_MD_SHA1);
|
||||
if (!hash)
|
||||
{
|
||||
gcry_md_close(mdh);
|
||||
return 1;
|
||||
}
|
||||
|
||||
memcpy(res, hash, hlen);
|
||||
|
||||
gcry_md_close(mdh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
|
||||
static Eet_Error
|
||||
eet_pbkdf2_sha1(const char *key,
|
||||
int key_len,
|
||||
const unsigned char *salt,
|
||||
unsigned int salt_len,
|
||||
int iter,
|
||||
unsigned char *res,
|
||||
int res_len)
|
||||
{
|
||||
unsigned char digest[20];
|
||||
unsigned char tab[4];
|
||||
unsigned char *p = res;
|
||||
unsigned char *buf;
|
||||
unsigned long i;
|
||||
int digest_len = 20;
|
||||
int len = res_len;
|
||||
int tmp_len;
|
||||
int j, k;
|
||||
# ifdef HAVE_GNUTLS
|
||||
# else
|
||||
HMAC_CTX hctx;
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
|
||||
buf = alloca(salt_len + 4);
|
||||
if (!buf)
|
||||
return 1;
|
||||
|
||||
for (i = 1; len; len -= tmp_len, p += tmp_len, i++)
|
||||
{
|
||||
if (len > digest_len)
|
||||
tmp_len = digest_len;
|
||||
else
|
||||
tmp_len = len;
|
||||
|
||||
tab[0] = (unsigned char)(i & 0xff000000) >> 24;
|
||||
tab[1] = (unsigned char)(i & 0x00ff0000) >> 16;
|
||||
tab[2] = (unsigned char)(i & 0x0000ff00) >> 8;
|
||||
tab[3] = (unsigned char)(i & 0x000000ff) >> 0;
|
||||
|
||||
# ifdef HAVE_GNUTLS
|
||||
memcpy(buf, salt, salt_len);
|
||||
memcpy(buf + salt_len, tab, 4);
|
||||
eet_hmac_sha1(key, key_len, buf, salt_len + 4, digest);
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
HMAC_Init(&hctx, key, key_len, EVP_sha1());
|
||||
HMAC_Update(&hctx, salt, salt_len);
|
||||
HMAC_Update(&hctx, tab, 4);
|
||||
HMAC_Final(&hctx, digest, NULL);
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
memcpy(p, digest, tmp_len);
|
||||
|
||||
for (j = 1; j < iter; j++)
|
||||
{
|
||||
# ifdef HAVE_GNUTLS
|
||||
eet_hmac_sha1(key, key_len, digest, 20, digest);
|
||||
# else /* ifdef HAVE_GNUTLS */
|
||||
HMAC(EVP_sha1(), key, key_len, digest, 20, digest, NULL);
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
for (k = 0; k < tmp_len; k++)
|
||||
p[k] ^= digest[k];
|
||||
}
|
||||
# ifdef HAVE_GNUTLS
|
||||
# else
|
||||
HMAC_cleanup(&hctx);
|
||||
# endif /* ifdef HAVE_GNUTLS */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* ifdef HAVE_CIPHER */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,6 @@
|
|||
#include <unistd.h>
|
||||
#include <fnmatch.h>
|
||||
#include <fcntl.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
|
@ -26,32 +25,11 @@
|
|||
#endif /* ifdef HAVE_EVIL */
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
# include <gnutls/gnutls.h>
|
||||
# include <gcrypt.h>
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/evp.h>
|
||||
#endif /* ifdef HAVE_OPENSSL */
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
GCRY_THREAD_OPTION_PTHREAD_IMPL;
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
#include <Emile.h>
|
||||
|
||||
#include "Eet.h"
|
||||
#include "Eet_private.h"
|
||||
|
||||
#ifdef ENABLE_LIBLZ4
|
||||
# include <lz4.h>
|
||||
# include <lz4hc.h>
|
||||
#else
|
||||
# include "lz4.h"
|
||||
# include "lz4hc.h"
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
@ -106,11 +84,9 @@ static Eet_Error
|
|||
static Eet_File_Node *
|
||||
find_node_by_name(Eet_File *ef,
|
||||
const char *name);
|
||||
static int
|
||||
read_data_from_disk(Eet_File *ef,
|
||||
Eet_File_Node *efn,
|
||||
void *buf,
|
||||
int len);
|
||||
static Eina_Binbuf *
|
||||
read_binbuf_from_disk(Eet_File *ef,
|
||||
Eet_File_Node *efn);
|
||||
|
||||
static Eet_Error
|
||||
eet_internal_close(Eet_File *ef,
|
||||
|
@ -562,49 +538,20 @@ eet_init(void)
|
|||
goto shutdown_mempool;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* Before the library can be used, it must initialize itself if needed. */
|
||||
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
|
||||
if (!emile_init())
|
||||
{
|
||||
gcry_check_version(NULL);
|
||||
/* Disable warning messages about problems with the secure memory subsystem.
|
||||
This command should be run right after gcry_check_version. */
|
||||
if (gcry_control(GCRYCTL_DISABLE_SECMEM_WARN))
|
||||
goto shutdown_eet; /* This command is used to allocate a pool of secure memory and thus
|
||||
enabling the use of secure memory. It also drops all extra privileges the
|
||||
process has (i.e. if it is run as setuid (root)). If the argument nbytes
|
||||
is 0, secure memory will be disabled. The minimum amount of secure memory
|
||||
allocated is currently 16384 bytes; you may thus use a value of 1 to
|
||||
request that default size. */
|
||||
|
||||
if (gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0))
|
||||
WRN(
|
||||
"BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !");
|
||||
EINA_LOG_ERR("Emile: failed to initialize");
|
||||
goto shutdown_emile;
|
||||
}
|
||||
|
||||
if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
|
||||
WRN(
|
||||
"YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
|
||||
|
||||
if (gnutls_global_init())
|
||||
goto shutdown_eet;
|
||||
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
#ifdef HAVE_OPENSSL
|
||||
ERR_load_crypto_strings();
|
||||
OpenSSL_add_all_algorithms();
|
||||
#endif /* ifdef HAVE_OPENSSL */
|
||||
|
||||
eina_log_timing(_eet_log_dom_global,
|
||||
EINA_LOG_STATE_STOP,
|
||||
EINA_LOG_STATE_INIT);
|
||||
EINA_LOG_STATE_STOP,
|
||||
EINA_LOG_STATE_INIT);
|
||||
|
||||
return eet_init_count;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
shutdown_eet:
|
||||
shutdown_emile:
|
||||
eet_node_shutdown();
|
||||
#endif
|
||||
shutdown_mempool:
|
||||
eet_mempool_shutdown();
|
||||
unregister_log_domain:
|
||||
|
@ -627,8 +574,8 @@ eet_shutdown(void)
|
|||
return eet_init_count;
|
||||
|
||||
eina_log_timing(_eet_log_dom_global,
|
||||
EINA_LOG_STATE_START,
|
||||
EINA_LOG_STATE_SHUTDOWN);
|
||||
EINA_LOG_STATE_START,
|
||||
EINA_LOG_STATE_SHUTDOWN);
|
||||
|
||||
eet_clearcache();
|
||||
|
||||
|
@ -663,26 +610,8 @@ eet_shutdown(void)
|
|||
|
||||
eina_lock_free(&eet_cache_lock);
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* Note that gnutls has a leak where it doesnt free stuff it alloced
|
||||
* on init. valgrind trace here:
|
||||
* 21 bytes in 1 blocks are definitely lost in loss record 24 of 194
|
||||
* at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
|
||||
* by 0x68AC801: strdup (strdup.c:43)
|
||||
* by 0xD215B6A: p11_kit_registered_module_to_name (in /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0)
|
||||
* by 0x9571574: gnutls_pkcs11_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
|
||||
* by 0x955B031: gnutls_global_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
|
||||
* by 0x6DFD6D0: eet_init (eet_lib.c:608)
|
||||
*
|
||||
* yes - i've tried calling gnutls_pkcs11_deinit() by hand but no luck.
|
||||
* the leak is in there.
|
||||
*/
|
||||
gnutls_global_deinit();
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
#ifdef HAVE_OPENSSL
|
||||
EVP_cleanup();
|
||||
ERR_free_strings();
|
||||
#endif /* ifdef HAVE_OPENSSL */
|
||||
emile_shutdown();
|
||||
|
||||
eina_log_domain_unregister(_eet_log_dom_global);
|
||||
_eet_log_dom_global = -1;
|
||||
eina_shutdown();
|
||||
|
@ -1907,8 +1836,8 @@ eet_read_cipher(Eet_File *ef,
|
|||
const char *cipher_key)
|
||||
{
|
||||
Eet_File_Node *efn;
|
||||
char *data = NULL;
|
||||
unsigned long int size = 0;
|
||||
Eina_Binbuf *in = NULL;
|
||||
unsigned char *data = NULL;
|
||||
|
||||
if (size_ret)
|
||||
*size_ret = 0;
|
||||
|
@ -1935,148 +1864,59 @@ eet_read_cipher(Eet_File *ef,
|
|||
if (!efn)
|
||||
goto on_error;
|
||||
|
||||
/* get size (uncompressed, if compressed at all) */
|
||||
size = efn->data_size;
|
||||
/* Get a binbuf attached to this efn */
|
||||
in = read_binbuf_from_disk(ef, efn);
|
||||
if (!in) goto on_error;
|
||||
|
||||
/* allocate data */
|
||||
data = malloc(size);
|
||||
if (!data)
|
||||
goto on_error;
|
||||
|
||||
/* uncompressed data */
|
||||
if (efn->compression == 0)
|
||||
/* First uncipher data */
|
||||
if (efn->ciphered && cipher_key)
|
||||
{
|
||||
void *data_deciphered = NULL;
|
||||
unsigned int data_deciphered_sz = 0;
|
||||
/* if we already have the data in ram... copy that */
|
||||
Eina_Binbuf *out;
|
||||
|
||||
if (efn->ciphered && efn->size > size)
|
||||
{
|
||||
size = efn->size;
|
||||
data = realloc(data, efn->size);
|
||||
}
|
||||
out = emile_binbuf_decipher(EMILE_AES256_CBC, in,
|
||||
cipher_key, strlen(cipher_key));
|
||||
|
||||
if (efn->data)
|
||||
memcpy(data, efn->data, size);
|
||||
else
|
||||
if (!read_data_from_disk(ef, efn, data, size))
|
||||
goto on_error;
|
||||
eina_binbuf_free(in);
|
||||
if (!out) goto on_error;
|
||||
|
||||
if (efn->ciphered && cipher_key)
|
||||
{
|
||||
if (eet_decipher(data, efn->size, cipher_key, strlen(cipher_key),
|
||||
&data_deciphered, &data_deciphered_sz))
|
||||
{
|
||||
if (data_deciphered)
|
||||
free(data_deciphered);
|
||||
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
free(data);
|
||||
data = data_deciphered;
|
||||
size = data_deciphered_sz;
|
||||
}
|
||||
in = out;
|
||||
}
|
||||
/* compressed data */
|
||||
else
|
||||
|
||||
if (efn->compression)
|
||||
{
|
||||
void *tmp_data = NULL;
|
||||
void *data_deciphered = NULL;
|
||||
unsigned int data_deciphered_sz = 0;
|
||||
int free_tmp = 0, ret;
|
||||
int compr_size = efn->size;
|
||||
uLongf dlen;
|
||||
Eina_Binbuf *out;
|
||||
|
||||
/* if we already have the data in ram... copy that */
|
||||
if (efn->data)
|
||||
tmp_data = efn->data;
|
||||
else
|
||||
{
|
||||
tmp_data = malloc(compr_size);
|
||||
if (!tmp_data)
|
||||
goto on_error;
|
||||
out = emile_decompress(in,
|
||||
eet_2_emile_compressor(efn->compression_type),
|
||||
efn->data_size);
|
||||
|
||||
free_tmp = 1;
|
||||
eina_binbuf_free(in);
|
||||
if (!out) goto on_error;
|
||||
|
||||
if (!read_data_from_disk(ef, efn, tmp_data, compr_size))
|
||||
{
|
||||
free(tmp_data);
|
||||
goto on_error;
|
||||
}
|
||||
}
|
||||
|
||||
if (efn->ciphered && cipher_key)
|
||||
{
|
||||
if (eet_decipher(tmp_data, compr_size, cipher_key,
|
||||
strlen(cipher_key), &data_deciphered,
|
||||
&data_deciphered_sz))
|
||||
{
|
||||
if (free_tmp)
|
||||
free(tmp_data);
|
||||
|
||||
if (data_deciphered)
|
||||
free(data_deciphered);
|
||||
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
if (free_tmp)
|
||||
free(tmp_data);
|
||||
free_tmp = 1;
|
||||
tmp_data = data_deciphered;
|
||||
compr_size = data_deciphered_sz;
|
||||
}
|
||||
|
||||
/* decompress it */
|
||||
dlen = size;
|
||||
switch (efn->compression_type)
|
||||
{
|
||||
case EET_COMPRESSION_VERYFAST:
|
||||
case EET_COMPRESSION_SUPERFAST:
|
||||
ret = LZ4_decompress_fast(tmp_data, data, dlen);
|
||||
if (ret != compr_size)
|
||||
{
|
||||
if (free_tmp)
|
||||
free(tmp_data);
|
||||
goto on_error;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (uncompress((Bytef *)data, &dlen,
|
||||
tmp_data, (uLongf)compr_size) != Z_OK)
|
||||
{
|
||||
if (free_tmp)
|
||||
free(tmp_data);
|
||||
goto on_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (free_tmp)
|
||||
free(tmp_data);
|
||||
in = out;
|
||||
}
|
||||
|
||||
UNLOCK_FILE(ef);
|
||||
|
||||
if (size_ret)
|
||||
*size_ret = eina_binbuf_length_get(in);
|
||||
data = eina_binbuf_string_steal(in);
|
||||
eina_binbuf_free(in);
|
||||
|
||||
/* handle alias */
|
||||
if (efn->alias)
|
||||
{
|
||||
void *tmp;
|
||||
|
||||
if (data[size - 1] != '\0')
|
||||
if (data[efn->data_size - 1] != '\0')
|
||||
goto on_error;
|
||||
|
||||
tmp = eet_read_cipher(ef, data, size_ret, cipher_key);
|
||||
tmp = eet_read_cipher(ef, (char*) data, size_ret, cipher_key);
|
||||
|
||||
free(data);
|
||||
|
||||
data = tmp;
|
||||
}
|
||||
else
|
||||
/* fill in return values */
|
||||
if (size_ret)
|
||||
*size_ret = size;
|
||||
|
||||
return data;
|
||||
|
||||
|
@ -2101,7 +1941,7 @@ eet_read_direct(Eet_File *ef,
|
|||
{
|
||||
Eet_File_Node *efn;
|
||||
const char *data = NULL;
|
||||
int size = 0, ret;
|
||||
int size = 0;
|
||||
|
||||
if (size_ret)
|
||||
*size_ret = 0;
|
||||
|
@ -2125,8 +1965,7 @@ eet_read_direct(Eet_File *ef,
|
|||
|
||||
/* hunt hash bucket */
|
||||
efn = find_node_by_name(ef, name);
|
||||
if (!efn)
|
||||
goto on_error;
|
||||
if (!efn) goto on_error;
|
||||
|
||||
/* trick to detect data in memory instead of mmaped from disk */
|
||||
if (efn->offset > ef->data_size && !efn->data)
|
||||
|
@ -2135,57 +1974,42 @@ eet_read_direct(Eet_File *ef,
|
|||
/* get size (uncompressed, if compressed at all) */
|
||||
size = efn->data_size;
|
||||
|
||||
/* handle alias case */
|
||||
if (efn->alias)
|
||||
{
|
||||
data = efn->data ? efn->data : ef->data + efn->offset;
|
||||
|
||||
/* handle alias case */
|
||||
if (efn->compression)
|
||||
{
|
||||
const void *retptr;
|
||||
char *tmp;
|
||||
int compr_size = efn->size;
|
||||
uLongf dlen;
|
||||
|
||||
tmp = malloc(compr_size);
|
||||
if (!tmp) goto on_error;
|
||||
switch (efn->compression_type)
|
||||
Eina_Binbuf *in;
|
||||
Eina_Binbuf *out;
|
||||
const unsigned char *tmp;
|
||||
const char *retptr;
|
||||
|
||||
in = read_binbuf_from_disk(ef, efn);
|
||||
if (!in) goto on_error;
|
||||
|
||||
out = emile_decompress(in,
|
||||
eet_2_emile_compressor(efn->compression_type),
|
||||
efn->data_size);
|
||||
eina_binbuf_free(in);
|
||||
if (!out) goto on_error;
|
||||
|
||||
tmp = eina_binbuf_string_get(out);
|
||||
if (tmp[eina_binbuf_length_get(out) - 1] != '\0')
|
||||
{
|
||||
case EET_COMPRESSION_VERYFAST:
|
||||
case EET_COMPRESSION_SUPERFAST:
|
||||
ret = LZ4_decompress_fast(data, tmp, size);
|
||||
if (ret != compr_size)
|
||||
{
|
||||
free(tmp);
|
||||
goto on_error;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dlen = size;
|
||||
|
||||
if (uncompress((Bytef *)tmp, &dlen, (Bytef *)data,
|
||||
(uLongf)compr_size))
|
||||
{
|
||||
free(tmp);
|
||||
goto on_error;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp[compr_size - 1] != '\0')
|
||||
{
|
||||
free(tmp);
|
||||
eina_binbuf_free(out);
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
|
||||
UNLOCK_FILE(ef);
|
||||
|
||||
retptr = eet_read_direct(ef, tmp, size_ret);
|
||||
free(tmp);
|
||||
|
||||
retptr = eet_read_direct(ef, (const char *) tmp, size_ret);
|
||||
|
||||
eina_binbuf_free(out);
|
||||
return retptr;
|
||||
}
|
||||
|
||||
if (!data)
|
||||
goto on_error;
|
||||
data = efn->data ? efn->data : ef->data + efn->offset;
|
||||
if (!data) goto on_error;
|
||||
|
||||
if (data[size - 1] != '\0')
|
||||
goto on_error;
|
||||
|
@ -2220,7 +2044,7 @@ eet_alias_get(Eet_File *ef,
|
|||
{
|
||||
Eet_File_Node *efn;
|
||||
const char *data = NULL;
|
||||
int size = 0, ret;
|
||||
int size = 0;
|
||||
|
||||
/* check to see its' an eet file pointer */
|
||||
if (eet_check_pointer(ef))
|
||||
|
@ -2257,45 +2081,32 @@ eet_alias_get(Eet_File *ef,
|
|||
/* handle alias case */
|
||||
if (efn->compression)
|
||||
{
|
||||
Eina_Binbuf *in;
|
||||
Eina_Binbuf *out;
|
||||
const unsigned char *tmp;
|
||||
const char *retptr;
|
||||
char *tmp;
|
||||
int compr_size = efn->size;
|
||||
uLongf dlen;
|
||||
|
||||
tmp = malloc(compr_size);
|
||||
if (!tmp) goto on_error;
|
||||
switch (efn->compression_type)
|
||||
|
||||
in = read_binbuf_from_disk(ef, efn);
|
||||
if (!in) goto on_error;
|
||||
|
||||
out = emile_decompress(in,
|
||||
eet_2_emile_compressor(efn->compression_type),
|
||||
efn->data_size);
|
||||
eina_binbuf_free(in);
|
||||
if (!out) goto on_error;
|
||||
|
||||
tmp = eina_binbuf_string_get(out);
|
||||
if (tmp[eina_binbuf_length_get(out) - 1] != '\0')
|
||||
{
|
||||
case EET_COMPRESSION_VERYFAST:
|
||||
case EET_COMPRESSION_SUPERFAST:
|
||||
ret = LZ4_decompress_fast(data, tmp, size);
|
||||
if (ret != compr_size)
|
||||
{
|
||||
free(tmp);
|
||||
goto on_error;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dlen = size;
|
||||
|
||||
if (uncompress((Bytef *)tmp, &dlen, (Bytef *)data,
|
||||
(uLongf)compr_size))
|
||||
{
|
||||
free(tmp);
|
||||
goto on_error;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp[compr_size - 1] != '\0')
|
||||
{
|
||||
free(tmp);
|
||||
eina_binbuf_free(out);
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
UNLOCK_FILE(ef);
|
||||
|
||||
retptr = eina_stringshare_add(tmp);
|
||||
free(tmp);
|
||||
retptr = eina_stringshare_add((const char *) tmp);
|
||||
|
||||
eina_binbuf_free(out);
|
||||
return retptr;
|
||||
}
|
||||
|
||||
|
@ -2314,6 +2125,21 @@ on_error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
eet_define_data(Eet_File *ef, Eet_File_Node *efn, Eina_Binbuf *data, int original_size, int comp, Eina_Bool ciphered)
|
||||
{
|
||||
free(efn->data);
|
||||
efn->alias = 0;
|
||||
efn->ciphered = ciphered;
|
||||
efn->compression = !!comp;
|
||||
efn->compression_type = comp;
|
||||
efn->size = eina_binbuf_length_get(data);
|
||||
efn->data_size = original_size;
|
||||
efn->data = efn->size ? eina_binbuf_string_steal(data) : NULL;
|
||||
/* Put the offset above the limit to avoid direct access */
|
||||
efn->offset = ef->data_size + 1;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eet_alias(Eet_File *ef,
|
||||
const char *name,
|
||||
|
@ -2321,9 +2147,10 @@ eet_alias(Eet_File *ef,
|
|||
int comp)
|
||||
{
|
||||
Eet_File_Node *efn;
|
||||
void *data2;
|
||||
Eina_Binbuf *in;
|
||||
Eina_Bool exists_already = EINA_FALSE;
|
||||
int data_size, ret, hash, slen;
|
||||
int hash;
|
||||
Eina_Bool success = EINA_FALSE;
|
||||
|
||||
/* check to see its' an eet file pointer */
|
||||
if (eet_check_pointer(ef))
|
||||
|
@ -2372,78 +2199,22 @@ eet_alias(Eet_File *ef,
|
|||
/* figure hash bucket */
|
||||
hash = _eet_hash_gen(name, ef->header->directory->size);
|
||||
|
||||
slen = strlen(destination) + 1;
|
||||
data_size = comp ?
|
||||
12 + ((slen * 101) / 100)
|
||||
: slen;
|
||||
if (comp)
|
||||
{
|
||||
ret = LZ4_compressBound(slen);
|
||||
if ((ret > 0) && (ret > data_size)) data_size = ret;
|
||||
}
|
||||
|
||||
data2 = malloc(data_size);
|
||||
if (!data2) goto on_error;
|
||||
in = eina_binbuf_manage_new((unsigned char*) destination, strlen(destination) + 1, EINA_TRUE);
|
||||
if (!in) goto on_error;
|
||||
|
||||
/* if we want to compress */
|
||||
if (comp)
|
||||
{
|
||||
switch (comp)
|
||||
{
|
||||
case EET_COMPRESSION_VERYFAST:
|
||||
ret = LZ4_compressHC((const char *)destination, (char *)data2,
|
||||
slen);
|
||||
if (ret <= 0)
|
||||
{
|
||||
free(data2);
|
||||
goto on_error;
|
||||
}
|
||||
data_size = ret;
|
||||
break;
|
||||
case EET_COMPRESSION_SUPERFAST:
|
||||
ret = LZ4_compress((const char *)destination, (char *)data2,
|
||||
slen);
|
||||
if (ret <= 0)
|
||||
{
|
||||
free(data2);
|
||||
goto on_error;
|
||||
}
|
||||
data_size = ret;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
uLongf buflen;
|
||||
|
||||
/* compress the data with max compression */
|
||||
buflen = (uLongf)data_size;
|
||||
if (compress2((Bytef *)data2, &buflen,
|
||||
(const Bytef *)destination,
|
||||
(uLong)slen, Z_BEST_COMPRESSION) != Z_OK)
|
||||
{
|
||||
free(data2);
|
||||
goto on_error;
|
||||
}
|
||||
/* record compressed chunk size */
|
||||
data_size = (int)buflen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((data_size < 0) ||
|
||||
(data_size >= (int)(strlen(destination) + 1)))
|
||||
{
|
||||
comp = 0;
|
||||
data_size = strlen(destination) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
void *data3;
|
||||
Eina_Binbuf *out;
|
||||
|
||||
data3 = realloc(data2, data_size);
|
||||
if (data3) data2 = data3;
|
||||
}
|
||||
out = emile_compress(in,
|
||||
eet_2_emile_compressor(comp),
|
||||
EMILE_COMPRESSOR_BEST);
|
||||
eina_binbuf_free(in);
|
||||
if (!out) goto on_error;
|
||||
|
||||
in = out;
|
||||
}
|
||||
|
||||
if (!comp) memcpy(data2, destination, data_size);
|
||||
|
||||
/* Does this node already exist? */
|
||||
for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
|
||||
|
@ -2451,16 +2222,7 @@ eet_alias(Eet_File *ef,
|
|||
/* if it matches */
|
||||
if ((efn->name) && (eet_string_match(efn->name, name)))
|
||||
{
|
||||
free(efn->data);
|
||||
efn->alias = 1;
|
||||
efn->ciphered = 0;
|
||||
efn->compression = !!comp;
|
||||
efn->compression_type = comp;
|
||||
efn->size = data_size;
|
||||
efn->data_size = strlen(destination) + 1;
|
||||
efn->data = data2;
|
||||
/* Put the offset above the limit to avoid direct access */
|
||||
efn->offset = ef->data_size + 1;
|
||||
eet_define_data(ef, efn, in, strlen(destination) + 1, comp, 0);
|
||||
exists_already = EINA_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -2470,36 +2232,32 @@ eet_alias(Eet_File *ef,
|
|||
efn = eet_file_node_malloc(1);
|
||||
if (!efn)
|
||||
{
|
||||
free(data2);
|
||||
eina_binbuf_free(in);
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
efn->name = strdup(name);
|
||||
efn->name_size = strlen(efn->name) + 1;
|
||||
efn->free_name = 1;
|
||||
efn->data = NULL;
|
||||
|
||||
efn->next = ef->header->directory->nodes[hash];
|
||||
ef->header->directory->nodes[hash] = efn;
|
||||
/* Put the offset above the limit to avoid direct access */
|
||||
efn->offset = ef->data_size + 1;
|
||||
efn->alias = 1;
|
||||
efn->ciphered = 0;
|
||||
efn->compression = !!comp;
|
||||
efn->compression_type = comp;
|
||||
efn->size = data_size;
|
||||
efn->data_size = strlen(destination) + 1;
|
||||
efn->data = data2;
|
||||
|
||||
eet_define_data(ef, efn, in, strlen(destination) + 1, comp, 0);
|
||||
}
|
||||
|
||||
efn->alias = 1;
|
||||
eina_binbuf_free(in);
|
||||
|
||||
/* flags that writes are pending */
|
||||
ef->writes_pending = 1;
|
||||
|
||||
UNLOCK_FILE(ef);
|
||||
return EINA_TRUE;
|
||||
|
||||
success = EINA_TRUE;
|
||||
on_error:
|
||||
|
||||
UNLOCK_FILE(ef);
|
||||
return EINA_FALSE;
|
||||
return success;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
|
@ -2510,9 +2268,10 @@ eet_write_cipher(Eet_File *ef,
|
|||
int comp,
|
||||
const char *cipher_key)
|
||||
{
|
||||
Eina_Binbuf *in;
|
||||
Eet_File_Node *efn;
|
||||
void *data2 = NULL;
|
||||
int exists_already = 0, data_size, hash, ret;
|
||||
int exists_already = 0;
|
||||
int hash;
|
||||
|
||||
/* check to see its' an eet file pointer */
|
||||
if (eet_check_pointer(ef))
|
||||
|
@ -2562,157 +2321,87 @@ eet_write_cipher(Eet_File *ef,
|
|||
hash = _eet_hash_gen(name, ef->header->directory->size);
|
||||
|
||||
UNLOCK_FILE(ef);
|
||||
|
||||
data_size = comp ? 12 + ((size * 101) / 100) : size;
|
||||
|
||||
in = eina_binbuf_manage_new(data, size, EINA_TRUE);
|
||||
if (comp)
|
||||
{
|
||||
ret = LZ4_compressBound(size);
|
||||
if ((ret > 0) && (ret > data_size)) data_size = ret;
|
||||
}
|
||||
|
||||
if (comp || !cipher_key)
|
||||
{
|
||||
data2 = malloc(data_size);
|
||||
if (!data2)
|
||||
goto on_error;
|
||||
}
|
||||
Eina_Binbuf *out;
|
||||
|
||||
/* if we want to compress */
|
||||
if (comp)
|
||||
{
|
||||
switch (comp)
|
||||
out = emile_compress(in, eet_2_emile_compressor(comp), EMILE_COMPRESSOR_BEST);
|
||||
if (out)
|
||||
{
|
||||
case EET_COMPRESSION_VERYFAST:
|
||||
ret = LZ4_compressHC((const char *)data, (char *)data2, size);
|
||||
if (ret <= 0)
|
||||
if (eina_binbuf_length_get(out) < eina_binbuf_length_get(in))
|
||||
{
|
||||
free(data2);
|
||||
LOCK_FILE(ef);
|
||||
goto on_error;
|
||||
eina_binbuf_free(in);
|
||||
in = out;
|
||||
}
|
||||
data_size = ret;
|
||||
break;
|
||||
case EET_COMPRESSION_SUPERFAST:
|
||||
ret = LZ4_compress((const char *)data, (char *)data2, size);
|
||||
if (ret <= 0)
|
||||
else
|
||||
{
|
||||
free(data2);
|
||||
LOCK_FILE(ef);
|
||||
goto on_error;
|
||||
eina_binbuf_free(out);
|
||||
comp = 0;
|
||||
}
|
||||
data_size = ret;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
uLongf buflen;
|
||||
|
||||
/* compress the data with max compression */
|
||||
buflen = (uLongf)data_size;
|
||||
if (compress2((Bytef *)data2, &buflen, (Bytef *)data,
|
||||
(uLong)size, Z_BEST_COMPRESSION) != Z_OK)
|
||||
{
|
||||
free(data2);
|
||||
LOCK_FILE(ef);
|
||||
goto on_error;
|
||||
}
|
||||
/* record compressed chunk size */
|
||||
data_size = (int)buflen;
|
||||
}
|
||||
}
|
||||
if ((data_size < 0) || (data_size >= size))
|
||||
{
|
||||
comp = 0;
|
||||
data_size = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
void *data3;
|
||||
|
||||
data3 = realloc(data2, data_size);
|
||||
if (data3)
|
||||
data2 = data3;
|
||||
// There is a change of behavior here, in case of memory pressure,
|
||||
// we will try to keep the uncompressed buffer.
|
||||
comp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (cipher_key)
|
||||
{
|
||||
void *data_ciphered = NULL;
|
||||
unsigned int data_ciphered_sz = 0;
|
||||
const void *tmp;
|
||||
Eina_Binbuf *out;
|
||||
|
||||
tmp = comp ? data2 : data;
|
||||
if (!eet_cipher(tmp, data_size, cipher_key, strlen(cipher_key),
|
||||
&data_ciphered, &data_ciphered_sz))
|
||||
out = emile_binbuf_cipher(EMILE_AES256_CBC, in,
|
||||
cipher_key, strlen(cipher_key));
|
||||
// Old behaviour was to not fail if the cipher where not built in
|
||||
if (out)
|
||||
{
|
||||
if (data2)
|
||||
free(data2);
|
||||
|
||||
data2 = data_ciphered;
|
||||
data_size = data_ciphered_sz;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data_ciphered)
|
||||
free(data_ciphered);
|
||||
|
||||
cipher_key = NULL;
|
||||
eina_binbuf_free(in);
|
||||
in = out;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!comp)
|
||||
memcpy(data2, data, size);
|
||||
|
||||
LOCK_FILE(ef);
|
||||
/* Does this node already exist? */
|
||||
for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
|
||||
{
|
||||
/* if it matches */
|
||||
if ((efn->name) && (eet_string_match(efn->name, name)))
|
||||
{
|
||||
free(efn->data);
|
||||
efn->alias = 0;
|
||||
efn->ciphered = cipher_key ? 1 : 0;
|
||||
efn->compression = !!comp;
|
||||
efn->compression_type = comp;
|
||||
efn->size = data_size;
|
||||
efn->data_size = size;
|
||||
efn->data = data2;
|
||||
/* Put the offset above the limit to avoid direct access */
|
||||
efn->offset = ef->data_size + 1;
|
||||
exists_already = 1;
|
||||
break;
|
||||
}
|
||||
if ((efn->name) && (eet_string_match(efn->name, name)))
|
||||
{
|
||||
eet_define_data(ef, efn, in, size, comp, !!cipher_key);
|
||||
exists_already = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exists_already)
|
||||
{
|
||||
efn = eet_file_node_malloc(1);
|
||||
if (!efn)
|
||||
{
|
||||
free(data2);
|
||||
eina_binbuf_free(in);
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
efn->name = strdup(name);
|
||||
efn->name_size = strlen(efn->name) + 1;
|
||||
efn->free_name = 1;
|
||||
efn->data = NULL;
|
||||
|
||||
efn->next = ef->header->directory->nodes[hash];
|
||||
ef->header->directory->nodes[hash] = efn;
|
||||
/* Put the offset above the limit to avoid direct access */
|
||||
efn->offset = ef->data_size + 1;
|
||||
efn->alias = 0;
|
||||
efn->ciphered = cipher_key ? 1 : 0;
|
||||
efn->compression = !!comp;
|
||||
efn->compression_type = comp;
|
||||
efn->size = data_size;
|
||||
efn->data_size = size;
|
||||
efn->data = data2;
|
||||
|
||||
eet_define_data(ef, efn, in, size, comp, !!cipher_key);
|
||||
}
|
||||
|
||||
/* flags that writes are pending */
|
||||
ef->writes_pending = 1;
|
||||
UNLOCK_FILE(ef);
|
||||
return data_size;
|
||||
|
||||
eina_binbuf_free(in);
|
||||
|
||||
return efn->size;
|
||||
|
||||
on_error:
|
||||
UNLOCK_FILE(ef);
|
||||
|
@ -3046,23 +2735,21 @@ find_node_by_name(Eet_File *ef,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
read_data_from_disk(Eet_File *ef,
|
||||
Eet_File_Node *efn,
|
||||
void *buf,
|
||||
int len)
|
||||
static Eina_Binbuf *
|
||||
read_binbuf_from_disk(Eet_File *ef,
|
||||
Eet_File_Node *efn)
|
||||
{
|
||||
if (efn->data)
|
||||
return eina_binbuf_manage_new(efn->data, efn->size, EINA_TRUE);
|
||||
|
||||
if (efn->offset > ef->data_size)
|
||||
return 0;
|
||||
|
||||
if (!ef->data)
|
||||
return 0;
|
||||
|
||||
if ((efn->offset + len) > ef->data_size)
|
||||
if ((efn->offset + efn->size) > ef->data_size)
|
||||
return 0;
|
||||
|
||||
memcpy(buf, ef->data + efn->offset, len);
|
||||
|
||||
return len;
|
||||
return eina_binbuf_manage_new(ef->data + efn->offset, efn->size, EINA_TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,19 @@ static const char __BINBUF_MAGIC_STR[] = "Eina Binbuf";
|
|||
|
||||
#include "eina_binbuf_template_c.x"
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
eina_binbuf_manage_new(const unsigned char *str, size_t length, Eina_Bool ro)
|
||||
{
|
||||
Eina_Binbuf *buf;
|
||||
|
||||
if (ro)
|
||||
buf = eina_strbuf_common_manage_ro_new(_STRBUF_CSIZE, (void *) str, length);
|
||||
else
|
||||
buf = eina_strbuf_common_manage_new(_STRBUF_CSIZE, (void *) str, length);
|
||||
EINA_MAGIC_SET(buf, _STRBUF_MAGIC);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
|
|
@ -62,7 +62,32 @@ EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
|||
* @see eina_binbuf_manage_new()
|
||||
* @since 1.2.0
|
||||
*/
|
||||
EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Create a new string buffer using the passed string. The passed
|
||||
* string is used directly as the buffer, it's somehow the opposite function of
|
||||
* @ref eina_binbuf_string_steal .
|
||||
*
|
||||
* @param str the string to start from
|
||||
* @param length the length of the string.
|
||||
* @param ro the passed string will not be touched if set to EINA_TRUE.
|
||||
* @return Newly allocated string buffer instance.
|
||||
*
|
||||
* This function creates a new string buffer. On error, @c NULL is
|
||||
* returned. To free the resources, use eina_binbuf_free(). It will
|
||||
* not touch the buffer if ro is set to @c EINA_TRUE, but it will also not
|
||||
* copy it. If ro is set to @c EINA_TRUE any change operation will
|
||||
* create a fresh new memory, copy old data there and starting modifying
|
||||
* that one.
|
||||
*
|
||||
* @see eina_binbuf_manage_new()
|
||||
* @see eina_binbuf_manage_new_length()
|
||||
* @see eina_binbuf_manage_read_only_new_length()
|
||||
*
|
||||
* @since 1.14.0
|
||||
*/
|
||||
EAPI Eina_Binbuf *eina_binbuf_manage_new(const unsigned char *str, size_t length, Eina_Bool ro) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* @brief Create a new string buffer using the passed string. The passed
|
||||
|
@ -82,7 +107,7 @@ EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t lengt
|
|||
* @see eina_binbuf_manage_new()
|
||||
* @since 1.9.0
|
||||
*/
|
||||
EAPI Eina_Binbuf *eina_binbuf_manage_read_only_new_length(const unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Binbuf *eina_binbuf_manage_read_only_new_length(const unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Free a string buffer.
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/* EMILE - EFL serialization, compression and crypto library.
|
||||
* Copyright (C) 2013 Enlightenment Developers:
|
||||
* Cedric Bail <cedric.bail@samsung.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef EMILE_H_
|
||||
#define EMILE_H_
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_EMILE_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Emile serialization, compression and ciphering public API calls.
|
||||
*
|
||||
* These routines are used for Emile Library interaction
|
||||
*
|
||||
* @date 2013 (created)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Emile.h
|
||||
* @brief The file that provide the Emile function
|
||||
*
|
||||
* This header provides the Emile management functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Emile_Group Top level functions
|
||||
* @ingroup Emile
|
||||
* Function that affect Emile as a whole.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the Emile library
|
||||
*
|
||||
* The first time this function is called, it will perform all the internal
|
||||
* initialization required for the library to function properly and
|
||||
* increment the initialization counter. Any subsequent call only
|
||||
* increment this counter and return its new value, so it's safe to call
|
||||
* this function more than once.
|
||||
*
|
||||
* @return The new init count. Will be 0 if initialization failed.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI int emile_init(void);
|
||||
|
||||
/**
|
||||
* Shut down the Emile library
|
||||
*
|
||||
* If emile_init() was called more than once for the running application,
|
||||
* emile_shutdown() will decrement the initialization counter and return its
|
||||
* new value, without doing anything else. When the counter reaches 0, all
|
||||
* of the internal elements will be shutdown and any memory used freed.
|
||||
*
|
||||
* @return The new init count.
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI int emile_shutdown(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "emile_cipher.h"
|
||||
#include "emile_compress.h"
|
||||
#include "emile_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,151 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif /* ifdef HAVE_CONFIG_H */
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#include "Emile.h"
|
||||
|
||||
#include "emile_private.h"
|
||||
|
||||
Eina_Bool _emile_cipher_init(void)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_binbuf_sha1(const char *key EINA_UNUSED,
|
||||
unsigned int key_len EINA_UNUSED,
|
||||
const Eina_Binbuf *data EINA_UNUSED,
|
||||
unsigned char digest[20] EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_cipher(Emile_Cipher_Algorithm algo EINA_UNUSED,
|
||||
const Eina_Binbuf *data EINA_UNUSED,
|
||||
const char *key EINA_UNUSED,
|
||||
unsigned int length EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_decipher(Emile_Cipher_Algorithm algo EINA_UNUSED,
|
||||
const Eina_Binbuf *data EINA_UNUSED,
|
||||
const char *key EINA_UNUSED,
|
||||
unsigned int length EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Emile_SSL *
|
||||
emile_cipher_server_listen(Emile_Cipher_Type t EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Emile_SSL *
|
||||
emile_cipher_client_connect(Emile_SSL *server EINA_UNUSED, int fd EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Emile_SSL *
|
||||
emile_cipher_server_connect(Emile_Cipher_Type t EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_free(Emile_SSL *emile EINA_UNUSED)
|
||||
{
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_cafile_add(Emile_SSL *emile EINA_UNUSED,
|
||||
const char *file EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_cert_add(Emile_SSL *emile EINA_UNUSED,
|
||||
const char *file EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_privkey_add(Emile_SSL *emile EINA_UNUSED,
|
||||
const char *file EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_crl_add(Emile_SSL *emile EINA_UNUSED,
|
||||
const char *file EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
emile_cipher_read(Emile_SSL *emile EINA_UNUSED,
|
||||
Eina_Binbuf *buffer EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
emile_cipher_write(Emile_SSL *emile EINA_UNUSED,
|
||||
const Eina_Binbuf *buffer EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
||||
EAPI const char *
|
||||
emile_cipher_error_get(const Emile_SSL *emile EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_verify_name_set(Emile_SSL *emile EINA_UNUSED,
|
||||
const char *name EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
emile_cipher_verify_name_get(const Emile_SSL *emile EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
emile_cipher_verify_set(Emile_SSL *emile EINA_UNUSED,
|
||||
Eina_Bool verify EINA_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
EAPI void
|
||||
emile_cipher_verify_basic_set(Emile_SSL *emile EINA_UNUSED,
|
||||
Eina_Bool verify_basic EINA_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_verify_get(const Emile_SSL *emile EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_verify_basic_get(const Emile_SSL *emile EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
#ifndef EMILE_CIPHER_H_
|
||||
#define EMILE_CIPHER_H_
|
||||
|
||||
/**
|
||||
* @defgroup Emile_Cipher_Group Top level functions
|
||||
* @ingroup Emile
|
||||
* Function that allow ciphering content.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Emile_Cipher_Backend
|
||||
*
|
||||
* Flags describing the implemented backend.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Cipher_Backend
|
||||
{
|
||||
EMILE_NONE,
|
||||
EMILE_OPENSSL,
|
||||
EMILE_GNUTLS
|
||||
} Emile_Cipher_Backend;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Cipher_Algorithm
|
||||
*
|
||||
* Flags describing known cipher algorithm.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Cipher_Algorithm
|
||||
{
|
||||
EMILE_AES256_CBC
|
||||
} Emile_Cipher_Algorithm;
|
||||
|
||||
/**
|
||||
* Force the initialization of the underlying cipher library.
|
||||
*
|
||||
* This call force the initialisation of GNUTLS or OpenSSL, so
|
||||
* that you get the same setup for everyone.
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
* @see emile_cipher_module_get
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Eina_Bool emile_cipher_init(void);
|
||||
/**
|
||||
* Get the name of the current used backend.
|
||||
*
|
||||
* @return the name of the current cipher backend.
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Emile_Cipher_Backend emile_cipher_module_get(void);
|
||||
|
||||
/**
|
||||
* Cipher a buffer with a defined algorithm and key.
|
||||
*
|
||||
* @param algo The algorithm to use to cipher the buffer.
|
||||
* @param in The buffer to cipher.
|
||||
* @param key The symetric key to use for ciphering.
|
||||
* @param length The length of the symetric key to be used.
|
||||
* @return the ciphered buffer or NULL on error.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Eina_Binbuf *emile_binbuf_cipher(Emile_Cipher_Algorithm algo, const Eina_Binbuf * in, const char *key, unsigned int length);
|
||||
|
||||
/**
|
||||
* Decipher a buffer with a defined algorithm and key.
|
||||
*
|
||||
* @param algo The algorithm to use to decipher the buffer.
|
||||
* @param in The ciphered buffer to decipher.
|
||||
* @param key The symetric key used to cipher the buffer.
|
||||
* @param length The length of the symetric key used to cipher the buffer.
|
||||
* @return the clear buffer or NULL on error.
|
||||
*
|
||||
* @note This won't detect if the given key is the correct one or not. You
|
||||
* have to check that the returned data make sense. You should also not treat
|
||||
* them as safe.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Eina_Binbuf *emile_binbuf_decipher(Emile_Cipher_Algorithm algo, const Eina_Binbuf * in, const char *key, unsigned int length);
|
||||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
typedef struct _Emile_SSL Emile_SSL;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EMILE_SSLv23,
|
||||
EMILE_SSLv3,
|
||||
EMILE_TLSv1
|
||||
} Emile_Cipher_Type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EMILE_WANT_NOTHING = 0,
|
||||
EMILE_WANT_READ = 1,
|
||||
EMILE_WANT_WRITE = 3
|
||||
} Emile_Want_Type;
|
||||
|
||||
EAPI Eina_Bool emile_binbuf_sha1(const char *key, unsigned int key_len, const Eina_Binbuf * data, unsigned char digest[20]);
|
||||
|
||||
|
||||
EAPI Emile_SSL *emile_cipher_server_listen(Emile_Cipher_Type t);
|
||||
EAPI Emile_SSL *emile_cipher_client_connect(Emile_SSL * server, int fd);
|
||||
EAPI Emile_SSL *emile_cipher_server_connect(Emile_Cipher_Type t);
|
||||
EAPI Eina_Bool emile_cipher_free(Emile_SSL * emile);
|
||||
|
||||
EAPI Eina_Bool emile_cipher_cafile_add(Emile_SSL * emile, const char *file);
|
||||
EAPI Eina_Bool emile_cipher_cert_add(Emile_SSL * emile, const char *file);
|
||||
EAPI Eina_Bool emile_cipher_privkey_add(Emile_SSL * emile, const char *file);
|
||||
EAPI Eina_Bool emile_cipher_crl_add(Emile_SSL * emile, const char *file);
|
||||
EAPI int emile_cipher_read(Emile_SSL * emile, Eina_Binbuf * buffer);
|
||||
EAPI int emile_cipher_write(Emile_SSL * emile, const Eina_Binbuf * buffer);
|
||||
EAPI const char *emile_cipher_error_get(const Emile_SSL * emile);
|
||||
EAPI Eina_Bool emile_cipher_verify_name_set(Emile_SSL * emile, const char *name);
|
||||
EAPI const char *emile_cipher_verify_name_get(const Emile_SSL * emile);
|
||||
EAPI void emile_cipher_verify_set(Emile_SSL * emile, Eina_Bool verify);
|
||||
EAPI void emile_cipher_verify_basic_set(Emile_SSL * emile, Eina_Bool verify_basic);
|
||||
EAPI Eina_Bool emile_cipher_verify_get(const Emile_SSL * emile);
|
||||
EAPI Eina_Bool emile_cipher_verify_basic_get(const Emile_SSL * emile);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -0,0 +1,575 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <gnutls/abstract.h>
|
||||
#include <gnutls/x509.h>
|
||||
#include <gcrypt.h>
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#include "Emile.h"
|
||||
|
||||
#include "emile_private.h"
|
||||
|
||||
#define MAX_KEY_LEN 32
|
||||
#define MAX_IV_LEN 16
|
||||
|
||||
struct _Emile_SSL
|
||||
{
|
||||
const char *last_error;
|
||||
const char *cert_file;
|
||||
const char *name;
|
||||
|
||||
gnutls_certificate_credentials_t cert;
|
||||
gnutls_session_t session;
|
||||
|
||||
union {
|
||||
struct {
|
||||
gnutls_datum_t session_ticket;
|
||||
} client;
|
||||
struct {
|
||||
gnutls_anon_client_credentials_t anoncred_c;
|
||||
gnutls_anon_server_credentials_t anoncred_s;
|
||||
gnutls_psk_client_credentials_t pskcred_c;
|
||||
gnutls_psk_server_credentials_t pskcred_s;
|
||||
char *cert_file;
|
||||
gnutls_dh_params_t dh_params;
|
||||
} server;
|
||||
} u;
|
||||
|
||||
Emile_Cipher_Type t;
|
||||
Emile_SSL_State ssl_state;
|
||||
|
||||
Eina_Bool server : 1;
|
||||
Eina_Bool verify : 1;
|
||||
Eina_Bool verify_basic : 1;
|
||||
};
|
||||
|
||||
GCRY_THREAD_OPTION_PTHREAD_IMPL;
|
||||
|
||||
Eina_Bool
|
||||
_emile_cipher_init(void)
|
||||
{
|
||||
if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
|
||||
WRN("YOU ARE USING PTHREADS, "
|
||||
"BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
|
||||
|
||||
/* Before the library can be used, it must initialize itself if needed. */
|
||||
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
|
||||
{
|
||||
gcry_check_version(NULL);
|
||||
/* Disable warning messages about problems with the secure memory subsystem.
|
||||
This command should be run right after gcry_check_version. */
|
||||
if (gcry_control(GCRYCTL_DISABLE_SECMEM_WARN))
|
||||
return EINA_FALSE;
|
||||
|
||||
/* This command is used to allocate a pool of secure memory and thus
|
||||
enabling the use of secure memory. It also drops all extra privileges the
|
||||
process has (i.e. if it is run as setuid (root)). If the argument nbytes
|
||||
is 0, secure memory will be disabled. The minimum amount of secure memory
|
||||
allocated is currently 16384 bytes; you may thus use a value of 1 to
|
||||
request that default size. */
|
||||
if (gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0))
|
||||
WRN("BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, "
|
||||
"Cryptographic operation are at risk !");
|
||||
}
|
||||
|
||||
if (gnutls_global_init())
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
emile_hmac_sha1(const void *key,
|
||||
size_t key_len,
|
||||
const void *data,
|
||||
size_t data_len,
|
||||
unsigned char *res)
|
||||
{
|
||||
size_t hlen = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
|
||||
gcry_md_hd_t mdh;
|
||||
unsigned char *hash;
|
||||
gpg_error_t err;
|
||||
|
||||
err = gcry_md_open(&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
|
||||
if (err != GPG_ERR_NO_ERROR)
|
||||
return EINA_FALSE;
|
||||
|
||||
err = gcry_md_setkey(mdh, key, key_len);
|
||||
if (err != GPG_ERR_NO_ERROR)
|
||||
{
|
||||
gcry_md_close(mdh);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
gcry_md_write(mdh, data, data_len);
|
||||
|
||||
hash = gcry_md_read(mdh, GCRY_MD_SHA1);
|
||||
if (!hash)
|
||||
{
|
||||
gcry_md_close(mdh);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memcpy(res, hash, hlen);
|
||||
|
||||
gcry_md_close(mdh);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_binbuf_sha1(const char *key,
|
||||
unsigned int key_len,
|
||||
const Eina_Binbuf *data,
|
||||
unsigned char digest[20])
|
||||
{
|
||||
return emile_hmac_sha1(key, key_len,
|
||||
eina_binbuf_string_get(data), eina_binbuf_length_get(data),
|
||||
digest);
|
||||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *data,
|
||||
const char *key,
|
||||
unsigned int length)
|
||||
{
|
||||
/* Cipher declarations */
|
||||
Eina_Binbuf *result;
|
||||
unsigned char *pointer;
|
||||
unsigned char iv[MAX_IV_LEN];
|
||||
unsigned char ik[MAX_KEY_LEN];
|
||||
unsigned char key_material[MAX_IV_LEN + MAX_KEY_LEN];
|
||||
unsigned int salt;
|
||||
unsigned int tmp = 0;
|
||||
unsigned int crypted_length;
|
||||
int opened = 0;
|
||||
/* Gcrypt declarations */
|
||||
gcry_error_t err = 0;
|
||||
gcry_cipher_hd_t cipher;
|
||||
|
||||
if (algo != EMILE_AES256_CBC) return NULL;
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Gcrypt salt generation */
|
||||
gcry_create_nonce((unsigned char *)&salt, sizeof(salt));
|
||||
|
||||
result = eina_binbuf_new();
|
||||
if (!result) return NULL;
|
||||
|
||||
emile_pbkdf2_sha1(key,
|
||||
length,
|
||||
(unsigned char *)&salt,
|
||||
sizeof(unsigned int),
|
||||
2048,
|
||||
key_material,
|
||||
MAX_KEY_LEN + MAX_IV_LEN);
|
||||
|
||||
memcpy(iv, key_material, MAX_IV_LEN);
|
||||
memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
|
||||
|
||||
memset(key_material, 0, sizeof (key_material));
|
||||
|
||||
crypted_length = ((((eina_binbuf_length_get(data) + sizeof (unsigned int)) >> 5) + 1) << 5)
|
||||
+ sizeof (unsigned int);
|
||||
|
||||
eina_binbuf_append_length(result, (unsigned char*) &salt, sizeof (salt));
|
||||
memset(&salt, 0, sizeof (salt));
|
||||
|
||||
tmp = htonl(eina_binbuf_length_get(data));
|
||||
eina_binbuf_append_length(result, (unsigned char*) &tmp, sizeof (tmp));
|
||||
eina_binbuf_append_buffer(result, data);
|
||||
|
||||
while (eina_binbuf_length_get(result) < crypted_length)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = rand();
|
||||
eina_binbuf_append_length(result, (unsigned char*) &r, sizeof (r));
|
||||
}
|
||||
eina_binbuf_remove(result, crypted_length, eina_binbuf_length_get(result));
|
||||
|
||||
/* Gcrypt create the corresponding cipher
|
||||
AES with a 256 bit key, Cipher Block Chaining mode */
|
||||
err = gcry_cipher_open(&cipher, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err) goto on_error;
|
||||
|
||||
opened = 1;
|
||||
err = gcry_cipher_setiv(cipher, iv, MAX_IV_LEN);
|
||||
if (err) goto on_error;
|
||||
|
||||
err = gcry_cipher_setkey(cipher, ik, MAX_KEY_LEN);
|
||||
if (err) goto on_error;
|
||||
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
pointer = (unsigned char*) eina_binbuf_string_get(result);
|
||||
|
||||
/* Gcrypt encrypt */
|
||||
err = gcry_cipher_encrypt(cipher, pointer + sizeof (int),
|
||||
eina_binbuf_length_get(result) - sizeof (int),
|
||||
NULL, 0);
|
||||
if (err) goto on_error;
|
||||
|
||||
/* Gcrypt close the cipher */
|
||||
gcry_cipher_close(cipher);
|
||||
|
||||
return result;
|
||||
|
||||
on_error:
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
/* Gcrypt error */
|
||||
if (opened)
|
||||
gcry_cipher_close(cipher);
|
||||
|
||||
/* General error */
|
||||
eina_binbuf_free(result);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *data,
|
||||
const char *key,
|
||||
unsigned int length)
|
||||
{
|
||||
Eina_Binbuf *result = NULL;
|
||||
unsigned int *over;
|
||||
gcry_error_t err = 0;
|
||||
gcry_cipher_hd_t cipher;
|
||||
unsigned char ik[MAX_KEY_LEN];
|
||||
unsigned char iv[MAX_IV_LEN];
|
||||
unsigned char key_material[MAX_KEY_LEN + MAX_IV_LEN];
|
||||
unsigned int salt;
|
||||
unsigned int size;
|
||||
int tmp_len;
|
||||
int tmp = 0;
|
||||
|
||||
if (algo != EMILE_AES256_CBC) return NULL;
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
over = (unsigned int*) eina_binbuf_string_get(data);
|
||||
size = eina_binbuf_length_get(data);
|
||||
|
||||
/* At least the salt and an AES block */
|
||||
if (size < sizeof(unsigned int) + 16)
|
||||
return NULL;
|
||||
|
||||
/* Get the salt */
|
||||
salt = *over;
|
||||
|
||||
/* Generate the iv and the key with the salt */
|
||||
emile_pbkdf2_sha1(key, length, (unsigned char *)&salt,
|
||||
sizeof(unsigned int), 2048, key_material,
|
||||
MAX_KEY_LEN + MAX_IV_LEN);
|
||||
|
||||
memcpy(iv, key_material, MAX_IV_LEN);
|
||||
memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
|
||||
|
||||
memset(key_material, 0, sizeof (key_material));
|
||||
memset(&salt, 0, sizeof (salt));
|
||||
|
||||
/* Align to AES block size if size is not align */
|
||||
tmp_len = size - sizeof (unsigned int);
|
||||
if ((tmp_len & 0x1F) != 0) goto on_error;
|
||||
|
||||
result = eina_binbuf_new();
|
||||
if (!result) goto on_error;
|
||||
|
||||
eina_binbuf_append_length(result, (unsigned char*) (over + 1), tmp_len);
|
||||
|
||||
/* Gcrypt create the corresponding cipher */
|
||||
err = gcry_cipher_open(&cipher, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err) goto on_error;
|
||||
|
||||
err = gcry_cipher_setiv(cipher, iv, MAX_IV_LEN);
|
||||
if (err) goto on_error;
|
||||
|
||||
err = gcry_cipher_setkey(cipher, ik, MAX_KEY_LEN);
|
||||
if (err) goto on_error;
|
||||
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
/* Gcrypt decrypt */
|
||||
err = gcry_cipher_decrypt(cipher,
|
||||
(void*) eina_binbuf_string_get(result), tmp_len,
|
||||
(void*) (over + 1), tmp_len);
|
||||
if (err) goto on_error;
|
||||
|
||||
/* Gcrypt close the cipher */
|
||||
gcry_cipher_close(cipher);
|
||||
|
||||
/* Get the decrypted data size */
|
||||
tmp = *(unsigned int*)(eina_binbuf_string_get(result));
|
||||
tmp = ntohl(tmp);
|
||||
if (tmp > tmp_len || tmp <= 0)
|
||||
goto on_error;
|
||||
|
||||
/* Remove header and padding */
|
||||
eina_binbuf_remove(result, 0, sizeof (unsigned int));
|
||||
eina_binbuf_remove(result, tmp, eina_binbuf_length_get(result));
|
||||
|
||||
return result;
|
||||
|
||||
on_error:
|
||||
memset(iv, 0, sizeof (iv));
|
||||
memset(ik, 0, sizeof (ik));
|
||||
|
||||
eina_binbuf_free(result);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FIXME: handshaking and fun
|
||||
|
||||
|
||||
EAPI Emile_SSL *
|
||||
emile_cipher_server_listen(Emile_Cipher_Type t)
|
||||
{
|
||||
Emile_SSL *r;
|
||||
int ret;
|
||||
|
||||
if (t != EMILE_SSLv23 &&
|
||||
t != EMILE_SSLv3 &&
|
||||
t != EMILE_TLSv1)
|
||||
return NULL;
|
||||
|
||||
r = calloc(1, sizeof (Emile_SSL));
|
||||
if (!r) return NULL;
|
||||
|
||||
ret = gnutls_certificate_allocate_credentials(&r->cert);
|
||||
if (ret) goto on_error;
|
||||
|
||||
r->t = t;
|
||||
r->server = EINA_TRUE;
|
||||
|
||||
return r;
|
||||
|
||||
on_error:
|
||||
ERR("GNUTLS error: %s - %s.",
|
||||
gnutls_strerror_name(ret),
|
||||
gnutls_strerror(ret));
|
||||
emile_cipher_free(r);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Emile_SSL *
|
||||
emile_cipher_client_connect(Emile_SSL *server EINA_UNUSED, int fd EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Emile_SSL *
|
||||
emile_cipher_server_connect(Emile_Cipher_Type t)
|
||||
{
|
||||
const char *priority = "NORMAL:%VERIFY_ALLOW_X509_V1_CA_CRT";
|
||||
Emile_SSL *r;
|
||||
int ret;
|
||||
|
||||
switch (t)
|
||||
{
|
||||
case EMILE_SSLv23:
|
||||
break;
|
||||
case EMILE_SSLv3:
|
||||
priority = "NORMAL:%VERIFY_ALLOW_X509_V1_CA_CRT:!VERS-TLS1.0:!VERS-TLS1.1:!VERS-TLS1.2";
|
||||
break;
|
||||
case EMILE_TLSv1:
|
||||
priority = "NORMAL:%VERIFY_ALLOW_X509_V1_CA_CRT:!VERS-SSL3.0";
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r = calloc(1, sizeof (Emile_SSL));
|
||||
if (!r) return NULL;
|
||||
|
||||
r->server = EINA_FALSE;
|
||||
|
||||
ret = gnutls_certificate_allocate_credentials(&r->cert);
|
||||
if (ret) goto on_error;
|
||||
|
||||
ret = gnutls_init(&r->session, GNUTLS_CLIENT);
|
||||
if (ret) goto on_error;
|
||||
|
||||
ret = gnutls_session_ticket_enable_client(r->session);
|
||||
if (ret) goto on_error;
|
||||
|
||||
// FIXME: Delay that until later access
|
||||
|
||||
ret = gnutls_server_name_set(r->session, GNUTLS_NAME_DNS,
|
||||
r->name, strlen(r->name));
|
||||
if (ret) goto on_error;
|
||||
|
||||
ret = gnutls_priority_set_direct(r->session, priority, NULL);
|
||||
if (ret) goto on_error;
|
||||
|
||||
gnutls_handshake_set_private_extensions(r->session, 1);
|
||||
ret = gnutls_credentials_set(r->session, GNUTLS_CRD_CERTIFICATE, r->cert);
|
||||
|
||||
return r;
|
||||
|
||||
on_error:
|
||||
// FIXEM: cleanly destroy session
|
||||
free(r);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_free(Emile_SSL *emile EINA_UNUSED)
|
||||
{
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_cafile_add(Emile_SSL *emile, const char *file)
|
||||
{
|
||||
Eina_File_Direct_Info *info;
|
||||
Eina_Iterator *it;
|
||||
struct stat st;
|
||||
int count = 0;
|
||||
int ret;
|
||||
|
||||
if (stat(file, &st)) return EINA_FALSE;
|
||||
if (S_ISDIR(st.st_mode))
|
||||
{
|
||||
it = eina_file_direct_ls(file);
|
||||
EINA_ITERATOR_FOREACH(it, info)
|
||||
{
|
||||
if (!(info->type == EINA_FILE_UNKNOWN ||
|
||||
info->type == EINA_FILE_REG ||
|
||||
info->type == EINA_FILE_LNK))
|
||||
continue ;
|
||||
|
||||
ret = gnutls_certificate_set_x509_trust_file(emile->cert,
|
||||
file,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
if (ret > 0) count += ret;
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = gnutls_certificate_set_x509_trust_file(emile->cert,
|
||||
file,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
if (ret > 0) count += ret;
|
||||
}
|
||||
|
||||
if (!count) ERR("Could not load CA file from '%s'.", file);
|
||||
return !count ? EINA_FALSE : EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_cert_add(Emile_SSL *emile, const char *file)
|
||||
{
|
||||
return eina_stringshare_replace(&emile->cert_file, file);
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_privkey_add(Emile_SSL *emile, const char *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = gnutls_certificate_set_x509_key_file(emile->cert,
|
||||
emile->cert_file,
|
||||
file,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
if (ret)
|
||||
ERR("Could not load certificate/key file ('%s'/'%s').",
|
||||
emile->cert_file, file);
|
||||
return ret ? EINA_FALSE : EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_crl_add(Emile_SSL *emile, const char *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = gnutls_certificate_set_x509_crl_file(emile->cert, file,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
if (ret)
|
||||
ERR("Could not load CRL file from '%s'.", file);
|
||||
return ret ? EINA_FALSE : EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
emile_cipher_read(Emile_SSL *emile, Eina_Binbuf *buffer)
|
||||
{
|
||||
int num;
|
||||
|
||||
if (!buffer || eina_binbuf_length_get(buffer) <= 0) return 0;
|
||||
if (emile->ssl_state == EMILE_SSL_STATE_HANDSHAKING)
|
||||
{
|
||||
DBG("Ongoing GNUTLS handshaking.");
|
||||
//_emile_cipher_handshaking(emile);
|
||||
if (emile->ssl_state == EMILE_SSL_STATE_ERROR)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
num = gnutls_record_recv(emile->session,
|
||||
(void*) eina_binbuf_string_get(buffer),
|
||||
eina_binbuf_length_get(buffer));
|
||||
return num;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
emile_cipher_write(Emile_SSL *emile EINA_UNUSED, const Eina_Binbuf *buffer EINA_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
emile_cipher_error_get(const Emile_SSL *emile)
|
||||
{
|
||||
return emile->last_error;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_verify_name_set(Emile_SSL *emile, const char *name)
|
||||
{
|
||||
return eina_stringshare_replace(&emile->name, name);
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
emile_cipher_verify_name_get(const Emile_SSL *emile)
|
||||
{
|
||||
return emile->name;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
emile_cipher_verify_set(Emile_SSL *emile, Eina_Bool verify)
|
||||
{
|
||||
emile->verify = verify;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
emile_cipher_verify_basic_set(Emile_SSL *emile, Eina_Bool verify_basic)
|
||||
{
|
||||
emile->verify_basic = verify_basic;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_verify_get(const Emile_SSL *emile)
|
||||
{
|
||||
return emile->verify;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_verify_basic_get(const Emile_SSL *emile)
|
||||
{
|
||||
return emile->verify_basic;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,156 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef ENABLE_LIBLZ4
|
||||
#include <lz4.h>
|
||||
#include <lz4hc.h>
|
||||
#else
|
||||
#include "lz4.h"
|
||||
#include "lz4hc.h"
|
||||
#endif
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#include "Emile.h"
|
||||
|
||||
static int
|
||||
_emile_compress_buffer_size(const Eina_Binbuf *data, Emile_Compressor_Type t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case EMILE_ZLIB:
|
||||
return 12 + ((eina_binbuf_length_get(data) * 101) / 100);
|
||||
|
||||
case EMILE_LZ4:
|
||||
case EMILE_LZ4HC:
|
||||
return LZ4_compressBound(eina_binbuf_length_get(data));
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_compress(const Eina_Binbuf *data,
|
||||
Emile_Compressor_Type t,
|
||||
Emile_Compressor_Level l)
|
||||
{
|
||||
void *compact;
|
||||
int length;
|
||||
int level = l;
|
||||
Eina_Bool ok = EINA_FALSE;
|
||||
|
||||
length = _emile_compress_buffer_size(data, t);
|
||||
|
||||
compact = malloc(length);
|
||||
if (!compact)
|
||||
return NULL;
|
||||
|
||||
switch (t)
|
||||
{
|
||||
case EMILE_LZ4:
|
||||
length = LZ4_compress((const char *)eina_binbuf_string_get(data),
|
||||
compact,
|
||||
eina_binbuf_length_get(data));
|
||||
if (length > 0)
|
||||
ok = EINA_TRUE;
|
||||
/* It is going to be smaller and should never fail, if it does you are in deep poo. */
|
||||
compact = realloc(compact, length);
|
||||
break;
|
||||
|
||||
case EMILE_LZ4HC:
|
||||
length = LZ4_compressHC((const char *)eina_binbuf_string_get(data),
|
||||
compact,
|
||||
eina_binbuf_length_get(data));
|
||||
if (length > 0)
|
||||
ok = EINA_TRUE;
|
||||
compact = realloc(compact, length);
|
||||
break;
|
||||
|
||||
case EMILE_ZLIB:
|
||||
{
|
||||
uLongf buflen = (uLongf)length;
|
||||
|
||||
if (compress2((Bytef *)compact, &buflen, (Bytef *)eina_binbuf_string_get(data), (uLong)eina_binbuf_length_get(data), level) == Z_OK)
|
||||
ok = EINA_TRUE;
|
||||
length = (int)buflen;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
free(compact);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return eina_binbuf_manage_new(compact, length, EINA_FALSE);
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_expand(const Eina_Binbuf *in, Eina_Binbuf *out, Emile_Compressor_Type t)
|
||||
{
|
||||
if (!in || !out)
|
||||
return EINA_FALSE;
|
||||
|
||||
switch (t)
|
||||
{
|
||||
case EMILE_LZ4:
|
||||
case EMILE_LZ4HC:
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = LZ4_decompress_fast((const char *)eina_binbuf_string_get(in),
|
||||
(char *)eina_binbuf_string_get(out),
|
||||
eina_binbuf_length_get(out));
|
||||
if ((unsigned int)ret != eina_binbuf_length_get(in))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
case EMILE_ZLIB:
|
||||
{
|
||||
uLongf dlen = eina_binbuf_length_get(out);
|
||||
|
||||
if (uncompress((Bytef *)eina_binbuf_string_get(out), &dlen, eina_binbuf_string_get(in), (uLongf)eina_binbuf_length_get(in)) != Z_OK)
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_decompress(const Eina_Binbuf *data,
|
||||
Emile_Compressor_Type t,
|
||||
unsigned int dest_length)
|
||||
{
|
||||
Eina_Binbuf *out;
|
||||
void *expanded;
|
||||
|
||||
expanded = malloc(dest_length);
|
||||
if (!expanded)
|
||||
return NULL;
|
||||
|
||||
out = eina_binbuf_manage_new(expanded, dest_length, EINA_FALSE);
|
||||
if (!out)
|
||||
goto on_error;
|
||||
|
||||
if (!emile_expand(data, out, t))
|
||||
goto on_error;
|
||||
|
||||
return out;
|
||||
|
||||
on_error:
|
||||
if (!out)
|
||||
free(expanded);
|
||||
if (out)
|
||||
eina_binbuf_free(out);
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
#ifndef EMILE_COMPRESSION_H_
|
||||
#define EMILE_COMPRESSION_H_
|
||||
|
||||
/**
|
||||
* @defgroup Emile_Group_Compression Non destructive general purpose compression functions.
|
||||
* @ingroup Emile
|
||||
* Function that allow the compression and expansion of Eina_Binbuf with
|
||||
* non destructive algorithm.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Supported type of compression algorithm.
|
||||
* @since 1.14
|
||||
*
|
||||
* @see emile_binbuf_compress()
|
||||
* @see emile_binbuf_uncompress()
|
||||
* @see emile_binbuf_expand()
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EMILE_ZLIB,
|
||||
EMILE_LZ4,
|
||||
EMILE_LZ4HC
|
||||
} Emile_Compressor_Type;
|
||||
|
||||
/**
|
||||
* Compression level to apply.
|
||||
* @since 1.14
|
||||
*
|
||||
* @see emile_binbuf_compress();
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EMILE_COMPRESSOR_DEFAULT = -1,
|
||||
EMILE_COMPRESSOR_NONE = 0,
|
||||
EMILE_COMPRESSOR_FAST = 1,
|
||||
EMILE_COMPRESSOR_BEST = 9
|
||||
} Emile_Compressor_Level;
|
||||
|
||||
/**
|
||||
* @brief Compress an Eina_Binbuf into a new Eina_Binbuf
|
||||
*
|
||||
* @param in Buffer to compress.
|
||||
* @param t Type of compression logic to use.
|
||||
* @param level Level of compression to apply.
|
||||
*
|
||||
* @return On success it will return a buffer that contains
|
||||
* the compressed data, @c NULL otherwise.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Eina_Binbuf *emile_compress(const Eina_Binbuf * in, Emile_Compressor_Type t, Emile_Compressor_Level level);
|
||||
/**
|
||||
* @brief Uncompress a buffer into a newly allocated buffer.
|
||||
*
|
||||
* @param in Buffer to uncompress.
|
||||
* @param t Type of compression logic to use.
|
||||
* @param dest_length Expected length of the decompressed data.
|
||||
*
|
||||
* @return a newly allocated buffer with the uncompressed data,
|
||||
* @c NULL if it failed.
|
||||
*
|
||||
* @since 1.14
|
||||
*
|
||||
* @note That if dest_length doesn't match the expanded data, it will
|
||||
* just fail and return @c NULL.
|
||||
*/
|
||||
EAPI Eina_Binbuf *emile_decompress(const Eina_Binbuf * in, Emile_Compressor_Type t, unsigned int dest_length);
|
||||
|
||||
/**
|
||||
* @brief Uncompress a buffer into an existing buffer.
|
||||
*
|
||||
* @param in Buffer to uncompress.
|
||||
* @param out Buffer to expand data into.
|
||||
* @param t Type of compression logic to use.
|
||||
*
|
||||
* @return EINA_TRUE if it succeed, EINA_FALSE if it failed.
|
||||
* @since 1.14
|
||||
*
|
||||
* @note The out buffer should have the necessary size to hold the
|
||||
* expanded data or it will fail. In case of failure, random garbage
|
||||
* could fill the out buffer.
|
||||
*/
|
||||
EAPI Eina_Bool emile_expand(const Eina_Binbuf * in, Eina_Binbuf * out, Emile_Compressor_Type t);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,322 @@
|
|||
#ifndef EMILE_IMAGE_H
|
||||
#define EMILE_IMAGE_H
|
||||
|
||||
/**
|
||||
* @defgroup Emile_Image_Group Top level functions
|
||||
* @ingroup Emile
|
||||
* Function that allow reading/saving image.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Emile_Colorspace
|
||||
*
|
||||
* Flags that describe all colorspace known by EFL. Some routine may not know all of them.
|
||||
* All the value from below enum should be the same as in Evas_Loader.h
|
||||
*
|
||||
* @see Evas_Colorspace
|
||||
* @see Eet_Colorspace
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Colorspace
|
||||
{
|
||||
EMILE_COLORSPACE_ARGB8888,/**< ARGB 32 bits per pixel, high-byte is Alpha, accessed 1 32bit word at a time */
|
||||
EMILE_COLORSPACE_YCBCR422P601_PL, /**< YCbCr 4:2:2 Planar, ITU.BT-601 specifications. The data pointed to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EMILE_COLORSPACE_YCBCR422P709_PL, /**< YCbCr 4:2:2 Planar, ITU.BT-709 specifications. The data pointed to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EMILE_COLORSPACE_RGB565_A5P, /**< 16bit rgb565 + Alpha plane at end - 5 bits of the 8 being used per alpha byte */
|
||||
EMILE_COLORSPACE_GRY8 = 4,
|
||||
EMILE_COLORSPACE_YCBCR422601_PL, /**< YCbCr 4:2:2, ITU.BT-601 specifications. The data pointed to is just an array of row pointer, pointing to line of Y,Cb,Y,Cr bytes */
|
||||
EMILE_COLORSPACE_YCBCR420NV12601_PL, /**< YCbCr 4:2:0, ITU.BT-601 specification. The data pointed to is just an array of row pointer, pointing to the Y rows, then the Cb,Cr rows. */
|
||||
EMILE_COLORSPACE_YCBCR420TM12601_PL, /**< YCbCr 4:2:0, ITU.BT-601 specification. The data pointed to is just an array of tiled row pointer, pointing to the Y rows, then the Cb,Cr rows. */
|
||||
EMILE_COLORSPACE_AGRY88 = 8, /**< AY 8bits Alpha and 8bits Grey, accessed 1 16bits at a time */
|
||||
EMILE_COLORSPACE_ETC1 = 9, /**< OpenGL ETC1 encoding of RGB texture (4 bit per pixel) @since 1.10 */
|
||||
EMILE_COLORSPACE_RGB8_ETC2 = 10, /**< OpenGL GL_COMPRESSED_RGB8_ETC2 texture compression format (4 bit per pixel) @since 1.10 */
|
||||
EMILE_COLORSPACE_RGBA8_ETC2_EAC = 11, /**< OpenGL GL_COMPRESSED_RGBA8_ETC2_EAC texture compression format, supports alpha (8 bit per pixel) @since 1.10 */
|
||||
EMILE_COLORSPACE_ETC1_ALPHA = 12, /**< ETC1 with alpha support using two planes: ETC1 RGB and ETC1 grey for alpha @since 1.11 */
|
||||
EMILE_COLORSPACE_RGB_S3TC_DXT1 = 13, /**< OpenGL COMPRESSED_RGB_S3TC_DXT1_EXT format with RGB only. @since 1.11 */
|
||||
EMILE_COLORSPACE_RGBA_S3TC_DXT1 = 14, /**< OpenGL COMPRESSED_RGBA_S3TC_DXT1_EXT format with RGBA punchthrough. @since 1.11 */
|
||||
EMILE_COLORSPACE_RGBA_S3TC_DXT2 = 15, /**< DirectDraw DXT2 format with premultiplied RGBA. Not supported by OpenGL itself. @since 1.11 */
|
||||
EMILE_COLORSPACE_RGBA_S3TC_DXT3 = 16, /**< OpenGL COMPRESSED_RGBA_S3TC_DXT3_EXT format with RGBA. @since 1.11 */
|
||||
EMILE_COLORSPACE_RGBA_S3TC_DXT4 = 17, /**< DirectDraw DXT4 format with premultiplied RGBA. Not supported by OpenGL itself. @since 1.11 */
|
||||
EMILE_COLORSPACE_RGBA_S3TC_DXT5 = 18 /**< OpenGL COMPRESSED_RGBA_S3TC_DXT5_EXT format with RGBA. @since 1.11 */
|
||||
} Emile_Colorspace;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Encoding
|
||||
*
|
||||
* Flags that describe the supported encoding. Some routine may not know all of them.
|
||||
* The value are the same as the one provided before in Eet.h
|
||||
*
|
||||
* @see Eet_Image_Encoding
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Image_Encoding
|
||||
{
|
||||
EMILE_IMAGE_LOSSLESS = 0,
|
||||
EMILE_IMAGE_JPEG = 1,
|
||||
EMILE_IMAGE_ETC1 = 2,
|
||||
EMILE_IMAGE_ETC2_RGB = 3,
|
||||
EMILE_IMAGE_ETC2_RGBA = 4,
|
||||
EMILE_IMAGE_ETC1_ALPHA = 5
|
||||
} Emile_Image_Encoding;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Scale_Hint
|
||||
*
|
||||
* Flags that describe the scale hint used by the loader infrastructure.
|
||||
*
|
||||
* @see Evas_Image_Scale_Hint
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Image_Scale_Hint
|
||||
{
|
||||
EMILE_IMAGE_SCALE_HINT_NONE = 0, /**< No scale hint at all */
|
||||
EMILE_IMAGE_SCALE_HINT_DYNAMIC = 1, /**< Image is being re-scaled over time, thus turning scaling cache @b off for its data */
|
||||
EMILE_IMAGE_SCALE_HINT_STATIC = 2 /**< Image is not being re-scaled over time, thus turning scaling cache @b on for its data */
|
||||
} Emile_Image_Scale_Hint;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Animated_Loop_Hint
|
||||
*
|
||||
* Flags describing the behavior of animation from a loaded image.
|
||||
*
|
||||
* @see Evas_Image_Animated_Loop_Hint
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Image_Animated_Loop_Hint
|
||||
{
|
||||
EMILE_IMAGE_ANIMATED_HINT_NONE = 0,
|
||||
EMILE_IMAGE_ANIMATED_HINT_LOOP = 1,
|
||||
EMILE_IMAGE_ANIMATED_HINT_PINGPONG = 2
|
||||
} Emile_Image_Animated_Loop_Hint;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Load_Error
|
||||
*
|
||||
* Flags describing error state as discovered by an image loader.
|
||||
*
|
||||
* @see Evas_Load_Error
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef enum _Emile_Image_Load_Error
|
||||
{
|
||||
EMILE_IMAGE_LOAD_ERROR_NONE = 0, /**< No error on load */
|
||||
EMILE_IMAGE_LOAD_ERROR_GENERIC = 1, /**< A non-specific error occurred */
|
||||
EMILE_IMAGE_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< File (or file path) does not exist */
|
||||
EMILE_IMAGE_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission denied to an existing file (or path) */
|
||||
EMILE_IMAGE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Allocation of resources failure prevented load */
|
||||
EMILE_IMAGE_LOAD_ERROR_CORRUPT_FILE = 5, /**< File corrupt (but was detected as a known format) */
|
||||
EMILE_IMAGE_LOAD_ERROR_UNKNOWN_FORMAT = 6 /**< File is not a known format */
|
||||
} Emile_Image_Load_Error; /**< Emile image load error codes one can get - see emile_load_error_str() too. */
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image
|
||||
*
|
||||
* Internal type representing an opened image.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef struct _Emile_Image Emile_Image;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Load_Opts
|
||||
*
|
||||
* Description of the possible load option.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef struct _Emile_Image_Load_Opts Emile_Image_Load_Opts;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Animated
|
||||
*
|
||||
* Description animation.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef struct _Emile_Image_Animated Emile_Image_Animated;
|
||||
|
||||
/**
|
||||
* @typedef Emile_Image_Property
|
||||
*
|
||||
* Description of a loaded image property.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
typedef struct _Emile_Image_Property Emile_Image_Property;
|
||||
|
||||
struct _Emile_Image_Property
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned char l, r, t, b;
|
||||
} borders;
|
||||
|
||||
const Emile_Colorspace *cspaces;
|
||||
Emile_Colorspace cspace;
|
||||
|
||||
Emile_Image_Encoding encoding;
|
||||
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
unsigned int row_stride;
|
||||
|
||||
unsigned char scale;
|
||||
|
||||
Eina_Bool rotated;
|
||||
Eina_Bool alpha;
|
||||
Eina_Bool premul;
|
||||
Eina_Bool alpha_sparse;
|
||||
|
||||
Eina_Bool flipped;
|
||||
Eina_Bool comp;
|
||||
};
|
||||
|
||||
struct _Emile_Image_Animated
|
||||
{
|
||||
Eina_List *frames;
|
||||
|
||||
Emile_Image_Animated_Loop_Hint loop_hint;
|
||||
|
||||
int frame_count;
|
||||
int loop_count;
|
||||
int cur_frame;
|
||||
|
||||
Eina_Bool animated;
|
||||
};
|
||||
|
||||
struct _Emile_Image_Load_Opts
|
||||
{
|
||||
Eina_Rectangle region;
|
||||
struct
|
||||
{
|
||||
int src_x, src_y, src_w, src_h;
|
||||
int dst_w, dst_h;
|
||||
int smooth;
|
||||
|
||||
/* This should have never been part of this structure, but we keep it
|
||||
for ABI/API compability with Evas_Loader */
|
||||
Emile_Image_Scale_Hint scale_hint;
|
||||
} scale_load;
|
||||
double dpi;
|
||||
unsigned int w, h;
|
||||
unsigned int degree;
|
||||
int scale_down_by;
|
||||
|
||||
Eina_Bool orientation;
|
||||
};
|
||||
|
||||
// FIXME: should we set region at load time, instead of head time
|
||||
// FIXME: should we regive the animated structure for head and data ?
|
||||
|
||||
/**
|
||||
* Open a TGV image from memory.
|
||||
*
|
||||
* @param source The Eina_Binbuf with TGV image in it.
|
||||
* @param opts Load option for the image to open (it can be @c NULL).
|
||||
* @param animated Description of the image animation property, set during head reading and updated for each frame read by data (can be @c NULL)
|
||||
* @param error Contain a valid error code if the function return @c NULL.
|
||||
* @return a handler of the image if successfully opened, otherwise @c NULL.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Emile_Image *emile_image_tgv_memory_open(Eina_Binbuf * source, Emile_Image_Load_Opts * opts, Emile_Image_Animated * animated, Emile_Image_Load_Error * error);
|
||||
|
||||
/**
|
||||
* Open a TGV image from a file.
|
||||
*
|
||||
* @param source The Eina_File with TGV image in it.
|
||||
* @param opts Load option for the image to open (it can be @c NULL).
|
||||
* @param animated Description of the image animation property, set during head reading and updated for each frame read by data (can be @c NULL)
|
||||
* @param error Contain a valid error code if the function return @c NULL.
|
||||
* @return a handler of the image if successfully opened, otherwise @c NULL.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Emile_Image *emile_image_tgv_file_open(Eina_File * source, Emile_Image_Load_Opts * opts, Emile_Image_Animated * animated, Emile_Image_Load_Error * error);
|
||||
|
||||
|
||||
/**
|
||||
* Open a JPEG image from memory.
|
||||
*
|
||||
* @param source The Eina_Binbuf with JPEG image in it.
|
||||
* @param opts Load option for the image to open (it can be @c NULL).
|
||||
* @param animated Description of the image animation property, set during head reading and updated for each frame read by data (can be @c NULL)
|
||||
* @param error Contain a valid error code if the function return @c NULL.
|
||||
* @return a handler of the image if successfully opened, otherwise @c NULL.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Emile_Image *emile_image_jpeg_memory_open(Eina_Binbuf * source, Emile_Image_Load_Opts * opts, Emile_Image_Animated * animated, Emile_Image_Load_Error * error);
|
||||
|
||||
/**
|
||||
* Open a JPEG image from file.
|
||||
*
|
||||
* @param source The Eina_File with JPEG image in it.
|
||||
* @param opts Load option for the image to open (it can be @c NULL).
|
||||
* @param animated Description of the image animation property, set during head reading and updated for each frame read by data (can be @c NULL)
|
||||
* @param error Contain a valid error code if the function return @c NULL.
|
||||
* @return a handler of the image if successfully opened, otherwise @c NULL.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Emile_Image *emile_image_jpeg_file_open(Eina_File * source, Emile_Image_Load_Opts * opts, Emile_Image_Animated * animated, Emile_Image_Load_Error * error);
|
||||
|
||||
/**
|
||||
* Read the header of an image to fill Emile_Image_Property.
|
||||
*
|
||||
* @param image The Emile_Image handler.
|
||||
* @param prop The Emile_Image_Property to be filled.
|
||||
* @param property_size The size of the Emile_Image_Property as known during compilation.
|
||||
* @param error Contain a valid error code if the function return @c NULL.
|
||||
* @return @c EINA_TRUE if the header was successfully readed and prop properly filled.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Eina_Bool emile_image_head(Emile_Image * image, Emile_Image_Property * prop, unsigned int property_size, Emile_Image_Load_Error * error);
|
||||
|
||||
/**
|
||||
* Read the pixels from an image file.
|
||||
*
|
||||
* @param image The Emile_Image handler.
|
||||
* @param prop The property to respect while reading this pixels.
|
||||
* @param property_size The size of the Emile_Image_Property as known during compilation.
|
||||
* @param pixels The actual pointer to the already allocated pixels buffer to fill.
|
||||
* @param error Contain a valid error code if the function return @c NULL.
|
||||
* @return @c EINA_TRUE if the data was successfully read and the pixels correctly filled.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI Eina_Bool emile_image_data(Emile_Image * image, Emile_Image_Property * prop, unsigned int property_size, void *pixels, Emile_Image_Load_Error * error);
|
||||
|
||||
/**
|
||||
* Close an opened image handler.
|
||||
*
|
||||
* @param source The handler to close.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI void emile_image_close(Emile_Image * source);
|
||||
|
||||
/**
|
||||
* Convert an error code related to an image handler into a meaningful string.
|
||||
*
|
||||
* @param source The handler related to the error (can be @c NULL).
|
||||
* @param error The error code to get a message from.
|
||||
* @return a string that will be owned by Emile, either by the handler if it is not @c NULL or by the library directly if it is.
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
EAPI const char *emile_load_error_str(Emile_Image * source, Emile_Image_Load_Error error);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -0,0 +1,176 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /* ifdef HAVE_CONFIG_H */
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#include <gnutls/x509.h>
|
||||
#include <gcrypt.h>
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#endif /* ifdef HAVE_OPENSSL */
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#include "Emile.h"
|
||||
#include "emile_private.h"
|
||||
|
||||
static Eina_Bool _emile_cipher_inited = EINA_FALSE;
|
||||
static unsigned int _emile_init_count = 0;
|
||||
int _emile_log_dom_global = -1;
|
||||
|
||||
EAPI Eina_Bool
|
||||
emile_cipher_init(void)
|
||||
{
|
||||
if (_emile_cipher_inited)
|
||||
return EINA_TRUE;
|
||||
|
||||
if (!_emile_cipher_init())
|
||||
return EINA_FALSE;
|
||||
|
||||
_emile_cipher_inited = EINA_TRUE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Emile_Cipher_Backend
|
||||
emile_cipher_module_get(void)
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
return EMILE_GNUTLS;
|
||||
#else
|
||||
#ifdef HAVE_OPENSSL
|
||||
return EMILE_OPENSSL;
|
||||
#else
|
||||
return EMILE_NONE;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI int
|
||||
emile_init(void)
|
||||
{
|
||||
if (++_emile_init_count != 1)
|
||||
return _emile_init_count;
|
||||
|
||||
if (!eina_init())
|
||||
return --_emile_init_count;
|
||||
|
||||
_emile_log_dom_global = eina_log_domain_register("emile", EINA_COLOR_CYAN);
|
||||
if (_emile_log_dom_global < 0)
|
||||
{
|
||||
EINA_LOG_ERR("Emile can not create a general log domain.");
|
||||
goto shutdown_eina;
|
||||
}
|
||||
|
||||
eina_log_timing(_emile_log_dom_global, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
|
||||
|
||||
return _emile_init_count;
|
||||
|
||||
shutdown_eina:
|
||||
eina_shutdown();
|
||||
|
||||
return --_emile_init_count;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
emile_shutdown(void)
|
||||
{
|
||||
if (--_emile_init_count != 0)
|
||||
return _emile_init_count;
|
||||
|
||||
eina_log_timing(_emile_log_dom_global, EINA_LOG_STATE_START, EINA_LOG_STATE_SHUTDOWN);
|
||||
|
||||
if (_emile_cipher_inited)
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* Note that gnutls has a leak where it doesnt free stuff it alloced
|
||||
* on init. valgrind trace here:
|
||||
* 21 bytes in 1 blocks are definitely lost in loss record 24 of 194
|
||||
* at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
|
||||
* by 0x68AC801: strdup (strdup.c:43)
|
||||
* by 0xD215B6A: p11_kit_registered_module_to_name (in /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0)
|
||||
* by 0x9571574: gnutls_pkcs11_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
|
||||
* by 0x955B031: gnutls_global_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
|
||||
* by 0x6DFD6D0: eet_init (eet_lib.c:608)
|
||||
*
|
||||
* yes - i've tried calling gnutls_pkcs11_deinit() by hand but no luck.
|
||||
* the leak is in there.
|
||||
*/
|
||||
gnutls_global_deinit();
|
||||
#endif /* ifdef HAVE_GNUTLS */
|
||||
#ifdef HAVE_OPENSSL
|
||||
EVP_cleanup();
|
||||
ERR_free_strings();
|
||||
#endif /* ifdef HAVE_OPENSSL */
|
||||
}
|
||||
|
||||
eina_log_domain_unregister(_emile_log_dom_global);
|
||||
_emile_log_dom_global = -1;
|
||||
|
||||
eina_shutdown();
|
||||
|
||||
return _emile_init_count;
|
||||
}
|
||||
|
||||
/* For the moment, we have just one function shared accross both cipher
|
||||
* backend, so here it is. */
|
||||
Eina_Bool
|
||||
emile_pbkdf2_sha1(const char *key, unsigned int key_len, const unsigned char *salt, unsigned int salt_len, unsigned int iter, unsigned char *res, unsigned int res_len)
|
||||
{
|
||||
Eina_Binbuf *step1, *step2;
|
||||
unsigned char *buf;
|
||||
unsigned char *p = res;
|
||||
unsigned char digest[20];
|
||||
unsigned char tab[4];
|
||||
unsigned int len = res_len;
|
||||
unsigned int tmp_len;
|
||||
unsigned int i, j, k;
|
||||
|
||||
buf = alloca(salt_len + 4);
|
||||
if (!buf)
|
||||
return EINA_FALSE;
|
||||
|
||||
step1 = eina_binbuf_manage_new(buf, salt_len + 4, EINA_TRUE);
|
||||
if (!step1)
|
||||
return EINA_FALSE;
|
||||
step2 = eina_binbuf_manage_new(digest, 20, EINA_TRUE);
|
||||
if (!step2)
|
||||
return EINA_FALSE;
|
||||
|
||||
for (i = 1; len; len -= tmp_len, p += tmp_len, i++)
|
||||
{
|
||||
tmp_len = (len > 20) ? 20 : len;
|
||||
|
||||
tab[0] = (unsigned char)(i & 0xff000000) >> 24;
|
||||
tab[1] = (unsigned char)(i & 0x00ff0000) >> 16;
|
||||
tab[2] = (unsigned char)(i & 0x0000ff00) >> 8;
|
||||
tab[3] = (unsigned char)(i & 0x000000ff) >> 0;
|
||||
|
||||
memcpy(buf, salt, salt_len);
|
||||
memcpy(buf + salt_len, tab, 4);
|
||||
|
||||
if (!emile_binbuf_sha1(key, key_len, step1, digest))
|
||||
return EINA_FALSE;
|
||||
|
||||
memcpy(p, digest, tmp_len);
|
||||
|
||||
for (j = 1; j < iter; j++)
|
||||
{
|
||||
if (!emile_binbuf_sha1(key, key_len, step2, digest))
|
||||
return EINA_FALSE;
|
||||
for (k = 0; k < tmp_len; k++)
|
||||
p[k] ^= digest[k];
|
||||
}
|
||||
}
|
||||
|
||||
eina_binbuf_free(step1);
|
||||
eina_binbuf_free(step2);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef EMILE_PRIVATE_H_
|
||||
# define EMILE_PRIVATE_H_
|
||||
|
||||
extern int _emile_log_dom_global;
|
||||
|
||||
#ifdef ERR
|
||||
# undef ERR
|
||||
#endif
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_emile_log_dom_global, __VA_ARGS__)
|
||||
#ifdef DBG
|
||||
# undef DBG
|
||||
#endif
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(_emile_log_dom_global, __VA_ARGS__)
|
||||
#ifdef INF
|
||||
# undef INF
|
||||
#endif
|
||||
#define INF(...) EINA_LOG_DOM_INFO(_emile_log_dom_global, __VA_ARGS__)
|
||||
#ifdef WRN
|
||||
# undef WRN
|
||||
#endif
|
||||
#define WRN(...) EINA_LOG_DOM_WARN(_emile_log_dom_global, __VA_ARGS__)
|
||||
#ifdef CRI
|
||||
# undef CRI
|
||||
#endif
|
||||
#define CRI(...) EINA_LOG_DOM_CRIT(_emile_log_dom_global, __VA_ARGS__)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EMILE_SSL_STATE_INIT = 0,
|
||||
EMILE_SSL_STATE_HANDSHAKING,
|
||||
EMILE_SSL_STATE_DONE,
|
||||
EMILE_SSL_STATE_ERROR
|
||||
} Emile_SSL_State;
|
||||
|
||||
Eina_Bool _emile_cipher_init(void);
|
||||
|
||||
Eina_Bool
|
||||
emile_pbkdf2_sha1(const char *key,
|
||||
unsigned int key_len,
|
||||
const unsigned char *salt,
|
||||
unsigned int salt_len,
|
||||
unsigned int iter,
|
||||
unsigned char *res,
|
||||
unsigned int res_len);
|
||||
|
||||
#endif
|
|
@ -37,6 +37,7 @@
|
|||
#define _EVAS_LOADER_H
|
||||
|
||||
#include "Eina.h"
|
||||
#include "Emile.h"
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
|
@ -116,119 +117,61 @@ struct _Evas_Module
|
|||
unsigned char loaded : 1;
|
||||
};
|
||||
|
||||
typedef struct _Evas_Image_Load_Opts Evas_Image_Load_Opts;
|
||||
typedef struct _Evas_Image_Animated Evas_Image_Animated;
|
||||
typedef struct _Evas_Image_Property Evas_Image_Property;
|
||||
typedef Emile_Image_Load_Opts Evas_Image_Load_Opts;
|
||||
typedef Emile_Image_Animated Evas_Image_Animated;
|
||||
typedef Emile_Image_Property Evas_Image_Property;
|
||||
|
||||
typedef struct _Evas_Image_Load_Func Evas_Image_Load_Func;
|
||||
|
||||
typedef enum _Evas_Load_Error
|
||||
{
|
||||
EVAS_LOAD_ERROR_NONE = 0, /**< No error on load */
|
||||
EVAS_LOAD_ERROR_GENERIC = 1, /**< A non-specific error occurred */
|
||||
EVAS_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< File (or file path) does not exist */
|
||||
EVAS_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission denied to an existing file (or path) */
|
||||
EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Allocation of resources failure prevented load */
|
||||
EVAS_LOAD_ERROR_CORRUPT_FILE = 5, /**< File corrupt (but was detected as a known format) */
|
||||
EVAS_LOAD_ERROR_UNKNOWN_FORMAT = 6 /**< File is not a known format */
|
||||
} Evas_Load_Error; /**< Evas image load error codes one can get - see evas_load_error_str() too. */
|
||||
typedef Emile_Image_Load_Error Evas_Load_Error;
|
||||
|
||||
typedef enum _Evas_Image_Animated_Loop_Hint
|
||||
{
|
||||
EVAS_IMAGE_ANIMATED_HINT_NONE = 0,
|
||||
EVAS_IMAGE_ANIMATED_HINT_LOOP = 1, /**< Image's animation mode is loop like 1->2->3->1->2->3 */
|
||||
EVAS_IMAGE_ANIMATED_HINT_PINGPONG = 2 /**< Image's animation mode is pingpong like 1->2->3->2->1-> ... */
|
||||
} Evas_Image_Animated_Loop_Hint;
|
||||
#define EVAS_LOAD_ERROR_NONE EMILE_IMAGE_LOAD_ERROR_NONE
|
||||
#define EVAS_LOAD_ERROR_GENERIC EMILE_IMAGE_LOAD_ERROR_GENERIC
|
||||
#define EVAS_LOAD_ERROR_DOES_NOT_EXIST EMILE_IMAGE_LOAD_ERROR_DOES_NOT_EXIST
|
||||
#define EVAS_LOAD_ERROR_PERMISSION_DENIED EMILE_IMAGE_LOAD_ERROR_PERMISSION_DENIED
|
||||
#define EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED EMILE_IMAGE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED
|
||||
#define EVAS_LOAD_ERROR_CORRUPT_FILE EMILE_IMAGE_LOAD_ERROR_CORRUPT_FILE
|
||||
#define EVAS_LOAD_ERROR_UNKNOWN_FORMAT EMILE_IMAGE_LOAD_ERROR_UNKNOWN_FORMAT
|
||||
|
||||
typedef enum _Evas_Image_Scale_Hint
|
||||
{
|
||||
EVAS_IMAGE_SCALE_HINT_NONE = 0, /**< No scale hint at all */
|
||||
EVAS_IMAGE_SCALE_HINT_DYNAMIC = 1, /**< Image is being re-scaled over time, thus turning scaling cache @b off for its data */
|
||||
EVAS_IMAGE_SCALE_HINT_STATIC = 2 /**< Image is not being re-scaled over time, thus turning scaling cache @b on for its data */
|
||||
} Evas_Image_Scale_Hint; /**< How an image's data is to be treated by Evas, with regard to scaling cache */
|
||||
typedef Emile_Image_Animated_Loop_Hint Evas_Image_Animated_Loop_Hint;
|
||||
|
||||
#define EVAS_IMAGE_ANIMATED_HINT_NONE EMILE_IMAGE_ANIMATED_HINT_NONE
|
||||
#define EVAS_IMAGE_ANIMATED_HINT_LOOP EMILE_IMAGE_ANIMATED_HINT_LOOP
|
||||
#define EVAS_IMAGE_ANIMATED_HINT_PINGPONG EMILE_IMAGE_ANIMATED_HINT_PINGPONG
|
||||
|
||||
typedef Emile_Image_Scale_Hint Evas_Image_Scale_Hint; /**< How an image's data is to be treated by Evas, with regard to scaling cache */
|
||||
|
||||
#define EVAS_IMAGE_SCALE_HINT_NONE EMILE_IMAGE_SCALE_HINT_NONE
|
||||
#define EVAS_IMAGE_SCALE_HINT_DYNAMIC EMILE_IMAGE_SCALE_HINT_DYNAMIC
|
||||
#define EVAS_IMAGE_SCALE_HINT_STATIC EMILE_IMAGE_SCALE_HINT_STATIC
|
||||
|
||||
/**
|
||||
* Colorspaces for pixel data supported by Evas
|
||||
* @ingroup Evas_Object_Image
|
||||
*/
|
||||
typedef enum _Evas_Colorspace
|
||||
{
|
||||
EVAS_COLORSPACE_ARGB8888, /**< ARGB 32 bits per pixel, high-byte is Alpha, accessed 1 32bit word at a time */
|
||||
/* these are not currently supported - but planned for the future */
|
||||
EVAS_COLORSPACE_YCBCR422P601_PL, /**< YCbCr 4:2:2 Planar, ITU.BT-601 specifications. The data pointed to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EVAS_COLORSPACE_YCBCR422P709_PL, /**< YCbCr 4:2:2 Planar, ITU.BT-709 specifications. The data pointed to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EVAS_COLORSPACE_RGB565_A5P, /**< 16bit rgb565 + Alpha plane at end - 5 bits of the 8 being used per alpha byte */
|
||||
EVAS_COLORSPACE_GRY8, /**< 8bit grayscale */
|
||||
EVAS_COLORSPACE_YCBCR422601_PL, /**< YCbCr 4:2:2, ITU.BT-601 specifications. The data pointed to is just an array of row pointer, pointing to line of Y,Cb,Y,Cr bytes */
|
||||
EVAS_COLORSPACE_YCBCR420NV12601_PL, /**< YCbCr 4:2:0, ITU.BT-601 specification. The data pointed to is just an array of row pointer, pointing to the Y rows, then the Cb,Cr rows. */
|
||||
EVAS_COLORSPACE_YCBCR420TM12601_PL, /**< YCbCr 4:2:0, ITU.BT-601 specification. The data pointed to is just an array of tiled row pointer, pointing to the Y rows, then the Cb,Cr rows. */
|
||||
EVAS_COLORSPACE_AGRY88, /**< AY 8bits Alpha and 8bits Grey, accessed 1 16bits at a time */
|
||||
typedef Emile_Colorspace Evas_Colorspace; /**< Colorspaces for pixel data supported by Evas */
|
||||
|
||||
#define EVAS_COLORSPACE_ARGB8888 EMILE_COLORSPACE_ARGB8888
|
||||
#define EVAS_COLORSPACE_YCBCR422P601_PL EMILE_COLORSPACE_YCBCR422P601_PL
|
||||
#define EVAS_COLORSPACE_YCBCR422P709_PL EMILE_COLORSPACE_YCBCR422P709_PL
|
||||
#define EVAS_COLORSPACE_RGB565_A5P EMILE_COLORSPACE_RGB565_A5P
|
||||
#define EVAS_COLORSPACE_GRY8 EMILE_COLORSPACE_GRY8
|
||||
#define EVAS_COLORSPACE_YCBCR422601_PL EMILE_COLORSPACE_YCBCR422601_PL
|
||||
#define EVAS_COLORSPACE_YCBCR420NV12601_PL EMILE_COLORSPACE_YCBCR420NV12601_PL
|
||||
#define EVAS_COLORSPACE_YCBCR420TM12601_PL EMILE_COLORSPACE_YCBCR420TM12601_PL
|
||||
#define EVAS_COLORSPACE_AGRY88 EMILE_COLORSPACE_AGRY88
|
||||
// ETC1/2 support
|
||||
EVAS_COLORSPACE_ETC1, /**< OpenGL ETC1 encoding of RGB texture (4 bit per pixel) @since 1.10 */
|
||||
EVAS_COLORSPACE_RGB8_ETC2, /**< OpenGL GL_COMPRESSED_RGB8_ETC2 texture compression format (4 bit per pixel) @since 1.10 */
|
||||
EVAS_COLORSPACE_RGBA8_ETC2_EAC, /**< OpenGL GL_COMPRESSED_RGBA8_ETC2_EAC texture compression format, supports alpha (8 bit per pixel) @since 1.10 */
|
||||
EVAS_COLORSPACE_ETC1_ALPHA, /**< ETC1 with alpha support using two planes: ETC1 RGB and ETC1 grey for alpha @since 1.11 */
|
||||
#define EVAS_COLORSPACE_ETC1 EMILE_COLORSPACE_ETC1
|
||||
#define EVAS_COLORSPACE_RGB8_ETC2 EMILE_COLORSPACE_RGB8_ETC2
|
||||
#define EVAS_COLORSPACE_RGBA8_ETC2_EAC EMILE_COLORSPACE_RGBA8_ETC2_EAC
|
||||
#define EVAS_COLORSPACE_ETC1_ALPHA EMILE_COLORSPACE_ETC1_ALPHA
|
||||
// S3TC support
|
||||
EVAS_COLORSPACE_RGB_S3TC_DXT1, /**< OpenGL COMPRESSED_RGB_S3TC_DXT1_EXT format with RGB only. @since 1.11 */
|
||||
EVAS_COLORSPACE_RGBA_S3TC_DXT1, /**< OpenGL COMPRESSED_RGBA_S3TC_DXT1_EXT format with RGBA punchthrough. @since 1.11 */
|
||||
EVAS_COLORSPACE_RGBA_S3TC_DXT2, /**< DirectDraw DXT2 format with premultiplied RGBA. Not supported by OpenGL itself. @since 1.11 */
|
||||
EVAS_COLORSPACE_RGBA_S3TC_DXT3, /**< OpenGL COMPRESSED_RGBA_S3TC_DXT3_EXT format with RGBA. @since 1.11 */
|
||||
EVAS_COLORSPACE_RGBA_S3TC_DXT4, /**< DirectDraw DXT4 format with premultiplied RGBA. Not supported by OpenGL itself. @since 1.11 */
|
||||
EVAS_COLORSPACE_RGBA_S3TC_DXT5, /**< OpenGL COMPRESSED_RGBA_S3TC_DXT5_EXT format with RGBA. @since 1.11 */
|
||||
} Evas_Colorspace; /**< Colorspaces for pixel data supported by Evas */
|
||||
|
||||
struct _Evas_Image_Property
|
||||
{
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
|
||||
unsigned char scale;
|
||||
|
||||
Eina_Bool rotated;
|
||||
Eina_Bool alpha;
|
||||
Eina_Bool premul;
|
||||
Eina_Bool alpha_sparse;
|
||||
|
||||
const Evas_Colorspace *cspaces; /**< Specify the color space handled by the loader @since 1.10 */
|
||||
Evas_Colorspace cspace; /**< Specify the color space handle by the engine @since 1.10 */
|
||||
|
||||
struct {
|
||||
unsigned char l, r, t, b; /**< Specify the dimensions of duplicated pixels borders for OpenGL compressed textures, set by the loader. @since 1.11 */
|
||||
} borders;
|
||||
|
||||
Eina_Bool flipped;
|
||||
};
|
||||
|
||||
struct _Evas_Image_Animated
|
||||
{
|
||||
Eina_List *frames;
|
||||
|
||||
Evas_Image_Animated_Loop_Hint loop_hint;
|
||||
|
||||
int frame_count;
|
||||
int loop_count;
|
||||
int cur_frame;
|
||||
|
||||
Eina_Bool animated;
|
||||
};
|
||||
|
||||
struct _Evas_Image_Load_Opts
|
||||
{
|
||||
struct {
|
||||
unsigned int x, y, w, h;
|
||||
} region;
|
||||
struct {
|
||||
int src_x, src_y, src_w, src_h;
|
||||
int dst_w, dst_h;
|
||||
int smooth;
|
||||
Evas_Image_Scale_Hint scale_hint;
|
||||
} scale_load;
|
||||
double dpi; // if > 0.0 use this
|
||||
unsigned int w, h; // if > 0 use this
|
||||
unsigned int degree;//if>0 there is some info related with rotation
|
||||
int scale_down_by; // if > 1 then use this
|
||||
|
||||
Eina_Bool orientation; // if EINA_TRUE => should honor orientation information provided by file (like jpeg exif info)
|
||||
};
|
||||
#define EVAS_COLORSPACE_RGB_S3TC_DXT1 EMILE_COLORSPACE_RGB_S3TC_DXT1
|
||||
#define EVAS_COLORSPACE_RGBA_S3TC_DXT1 EMILE_COLORSPACE_RGBA_S3TC_DXT1
|
||||
#define EVAS_COLORSPACE_RGBA_S3TC_DXT2 EMILE_COLORSPACE_RGBA_S3TC_DXT2
|
||||
#define EVAS_COLORSPACE_RGBA_S3TC_DXT3 EMILE_COLORSPACE_RGBA_S3TC_DXT3
|
||||
#define EVAS_COLORSPACE_RGBA_S3TC_DXT4 EMILE_COLORSPACE_RGBA_S3TC_DXT4
|
||||
#define EVAS_COLORSPACE_RGBA_S3TC_DXT5 EMILE_COLORSPACE_RGBA_S3TC_DXT5
|
||||
|
||||
struct _Evas_Image_Load_Func
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,114 +2,16 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#include <Emile.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <winsock2.h>
|
||||
#endif /* ifdef _WIN32 */
|
||||
|
||||
#ifdef ENABLE_LIBLZ4
|
||||
# include <lz4.h>
|
||||
#else
|
||||
# include "lz4.h"
|
||||
#endif
|
||||
|
||||
#include "rg_etc1.h"
|
||||
#include "Evas_Loader.h"
|
||||
|
||||
#ifdef BUILD_NEON
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
/* x86 */
|
||||
#define A_VAL(p) (((uint8_t *)(p))[3])
|
||||
#define R_VAL(p) (((uint8_t *)(p))[2])
|
||||
#define G_VAL(p) (((uint8_t *)(p))[1])
|
||||
#define B_VAL(p) (((uint8_t *)(p))[0])
|
||||
#else
|
||||
/* ppc */
|
||||
#define A_VAL(p) (((uint8_t *)(p))[0])
|
||||
#define R_VAL(p) (((uint8_t *)(p))[1])
|
||||
#define G_VAL(p) (((uint8_t *)(p))[2])
|
||||
#define B_VAL(p) (((uint8_t *)(p))[3])
|
||||
#endif
|
||||
|
||||
/**************************************************************
|
||||
* The TGV file format is oriented around compression mecanism
|
||||
* that hardware are good at decompressing. We do still provide
|
||||
* a fully software implementation in case your hardware doesn't
|
||||
* handle it. As OpenGL is pretty bad at handling border of
|
||||
* texture, we do duplicate the first pixels of every border.
|
||||
*
|
||||
* This file format is designed to compress/decompress things
|
||||
* in block area. Giving opportunity to store really huge file
|
||||
* and only decompress/compress them as we need. Note that region
|
||||
* only work with software decompression as we don't have a sane
|
||||
* way to duplicate border to avoid artifact when scaling texture.
|
||||
*
|
||||
* The file format is as follow :
|
||||
* - char magic[4]: "TGV1"
|
||||
* - uint8_t block_size (real block size = (4 << bits[0-3], 4 << bits[4-7])
|
||||
* - uint8_t algorithm (0 -> ETC1, 1 -> ETC2 RGB, 2 -> ETC2 RGBA, 3 -> ETC1+Alpha)
|
||||
* - uint8_t options[2] (bitmask: 1 -> lz4, 2 for block-less, 4 -> unpremultiplied)
|
||||
* - uint32_t width
|
||||
* - uint32_t height
|
||||
* - blocks[]
|
||||
* - 0 length encoded compress size (if length == 64 * block_size => no compression)
|
||||
* - lzma encoded etc1 block
|
||||
*
|
||||
* If the format is ETC1+Alpha (algo = 3), then a second image is encoded
|
||||
* in ETC1 right after the first one, and it contains grey-scale alpha
|
||||
* values.
|
||||
**************************************************************/
|
||||
|
||||
// FIXME: wondering if we should support mipmap
|
||||
// TODO: support ETC1+ETC2 images (RGB only)
|
||||
|
||||
typedef struct _Evas_Loader_Internal Evas_Loader_Internal;
|
||||
struct _Evas_Loader_Internal
|
||||
{
|
||||
Eina_File *f;
|
||||
Emile_Image *image;
|
||||
|
||||
Eina_Rectangle region;
|
||||
|
||||
struct {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
} block;
|
||||
struct {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
} size;
|
||||
|
||||
Evas_Colorspace cspace;
|
||||
|
||||
Eina_Bool compress : 1;
|
||||
Eina_Bool blockless : 1; // Special mode used when copying data directly
|
||||
Eina_Bool unpremul : 1;
|
||||
};
|
||||
|
||||
static const Evas_Colorspace cspaces_etc1[2] = {
|
||||
EVAS_COLORSPACE_ETC1,
|
||||
EVAS_COLORSPACE_ARGB8888
|
||||
};
|
||||
|
||||
static const Evas_Colorspace cspaces_rgb8_etc2[2] = {
|
||||
EVAS_COLORSPACE_RGB8_ETC2,
|
||||
EVAS_COLORSPACE_ARGB8888
|
||||
};
|
||||
|
||||
static const Evas_Colorspace cspaces_rgba8_etc2_eac[2] = {
|
||||
EVAS_COLORSPACE_RGBA8_ETC2_EAC,
|
||||
EVAS_COLORSPACE_ARGB8888
|
||||
};
|
||||
|
||||
static const Evas_Colorspace cspaces_etc1_alpha[2] = {
|
||||
EVAS_COLORSPACE_ETC1_ALPHA,
|
||||
EVAS_COLORSPACE_ARGB8888
|
||||
};
|
||||
|
||||
static void *
|
||||
|
@ -119,10 +21,13 @@ evas_image_load_file_open_tgv(Eina_File *f, Eina_Stringshare *key EINA_UNUSED,
|
|||
int *error)
|
||||
{
|
||||
Evas_Loader_Internal *loader;
|
||||
Emile_Image *image;
|
||||
Emile_Image_Load_Error image_error;
|
||||
|
||||
if (eina_file_size_get(f) <= 16)
|
||||
image = emile_image_tgv_file_open(f, opts, NULL, &image_error);
|
||||
if (!image)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
*error = image_error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -133,14 +38,7 @@ evas_image_load_file_open_tgv(Eina_File *f, Eina_Stringshare *key EINA_UNUSED,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
loader->f = eina_file_dup(f);
|
||||
if (!loader->f)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||
free(loader);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
loader->image = image;
|
||||
if (opts && (opts->region.w > 0) && (opts->region.h > 0))
|
||||
{
|
||||
EINA_RECTANGLE_SET(&loader->region,
|
||||
|
@ -165,149 +63,27 @@ evas_image_load_file_close_tgv(void *loader_data)
|
|||
{
|
||||
Evas_Loader_Internal *loader = loader_data;
|
||||
|
||||
eina_file_close(loader->f);
|
||||
emile_image_close(loader->image);
|
||||
free(loader);
|
||||
}
|
||||
|
||||
static int
|
||||
roundup(int val, int rup)
|
||||
{
|
||||
if (val >= 0 && rup > 0)
|
||||
return (val + rup - 1) - ((val + rup - 1) % rup);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OFFSET_BLOCK_SIZE 4
|
||||
#define OFFSET_ALGORITHM 5
|
||||
#define OFFSET_OPTIONS 6
|
||||
#define OFFSET_WIDTH 8
|
||||
#define OFFSET_HEIGHT 12
|
||||
#define OFFSET_BLOCKS 16
|
||||
|
||||
static Eina_Bool
|
||||
evas_image_load_file_head_tgv(void *loader_data,
|
||||
Evas_Image_Property *prop,
|
||||
int *error)
|
||||
{
|
||||
Evas_Loader_Internal *loader = loader_data;
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
char *m;
|
||||
Emile_Image_Load_Error image_error;
|
||||
Eina_Bool ret;
|
||||
|
||||
m = eina_file_map_all(loader->f, EINA_FILE_SEQUENTIAL);
|
||||
if (!m)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
ret = emile_image_head(loader->image,
|
||||
prop, sizeof (Emile_Image_Property),
|
||||
&image_error);
|
||||
*error = image_error;
|
||||
|
||||
if (strncmp(m, "TGV1", 4) != 0)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
switch (m[OFFSET_ALGORITHM] & 0xFF)
|
||||
{
|
||||
case 0:
|
||||
prop->cspaces = cspaces_etc1;
|
||||
loader->cspace = EVAS_COLORSPACE_ETC1;
|
||||
prop->alpha = EINA_FALSE;
|
||||
break;
|
||||
case 1:
|
||||
prop->cspaces = cspaces_rgb8_etc2;
|
||||
loader->cspace = EVAS_COLORSPACE_RGB8_ETC2;
|
||||
prop->alpha = EINA_FALSE;
|
||||
break;
|
||||
case 2:
|
||||
prop->cspaces = cspaces_rgba8_etc2_eac;
|
||||
loader->cspace = EVAS_COLORSPACE_RGBA8_ETC2_EAC;
|
||||
prop->alpha = EINA_TRUE;
|
||||
break;
|
||||
case 3:
|
||||
prop->cspaces = cspaces_etc1_alpha;
|
||||
loader->cspace = EVAS_COLORSPACE_ETC1_ALPHA;
|
||||
loader->unpremul = !!(m[OFFSET_OPTIONS] & 0x4);
|
||||
prop->alpha = EINA_TRUE;
|
||||
prop->premul = loader->unpremul;
|
||||
break;
|
||||
default:
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
loader->compress = m[OFFSET_OPTIONS] & 0x1;
|
||||
loader->blockless = (m[OFFSET_OPTIONS] & 0x2) != 0;
|
||||
|
||||
loader->size.width = ntohl(*((unsigned int*) &(m[OFFSET_WIDTH])));
|
||||
loader->size.height = ntohl(*((unsigned int*) &(m[OFFSET_HEIGHT])));
|
||||
|
||||
if (loader->blockless)
|
||||
{
|
||||
loader->block.width = roundup(loader->size.width + 2, 4);
|
||||
loader->block.height = roundup(loader->size.height + 2, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
loader->block.width = 4 << (m[OFFSET_BLOCK_SIZE] & 0x0f);
|
||||
loader->block.height = 4 << ((m[OFFSET_BLOCK_SIZE] & 0xf0) >> 4);
|
||||
}
|
||||
|
||||
if (loader->region.w == -1 && loader->region.h == -1)
|
||||
{
|
||||
loader->region.w = loader->size.width;
|
||||
loader->region.h = loader->size.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Eina_Rectangle r;
|
||||
|
||||
// ETC1 colorspace doesn't work with region
|
||||
prop->cspaces = NULL;
|
||||
|
||||
EINA_RECTANGLE_SET(&r, 0, 0, loader->size.width, loader->size.height);
|
||||
if (!eina_rectangle_intersection(&loader->region, &r))
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||
goto on_error;
|
||||
}
|
||||
}
|
||||
|
||||
prop->w = loader->size.width;
|
||||
prop->h = loader->size.height;
|
||||
prop->borders.l = 1;
|
||||
prop->borders.t = 1;
|
||||
prop->borders.r = roundup(prop->w + 2, 4) - prop->w - 1;
|
||||
prop->borders.b = roundup(prop->h + 2, 4) - prop->h - 1;
|
||||
|
||||
ret = EINA_TRUE;
|
||||
|
||||
on_error:
|
||||
eina_file_map_free(loader->f, m);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
_tgv_length_get(const char *m, unsigned int length, unsigned int *offset)
|
||||
{
|
||||
unsigned int r = 0;
|
||||
unsigned int shift = 0;
|
||||
|
||||
while (*offset < length && ((*m) & 0x80))
|
||||
{
|
||||
r = r | (((*m) & 0x7F) << shift);
|
||||
shift += 7;
|
||||
m++;
|
||||
(*offset)++;
|
||||
}
|
||||
if (*offset < length)
|
||||
{
|
||||
r = r | (((*m) & 0x7F) << shift);
|
||||
(*offset)++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
evas_image_load_file_data_tgv(void *loader_data,
|
||||
Evas_Image_Property *prop,
|
||||
|
@ -315,234 +91,15 @@ evas_image_load_file_data_tgv(void *loader_data,
|
|||
int *error)
|
||||
{
|
||||
Evas_Loader_Internal *loader = loader_data;
|
||||
const char *m;
|
||||
unsigned int *p = pixels;
|
||||
unsigned char *p_etc = pixels;
|
||||
char *buffer = NULL;
|
||||
Eina_Rectangle master;
|
||||
unsigned int block_length;
|
||||
unsigned int length, offset;
|
||||
unsigned int x, y;
|
||||
unsigned int block_count;
|
||||
unsigned int etc_width = 0;
|
||||
unsigned int etc_block_size;
|
||||
Eina_Bool r = EINA_FALSE;
|
||||
int num_planes = 1, plane, alpha_offset = 0;
|
||||
Emile_Image_Load_Error image_error;
|
||||
Eina_Bool ret;
|
||||
|
||||
length = eina_file_size_get(loader->f);
|
||||
offset = OFFSET_BLOCKS;
|
||||
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
|
||||
m = eina_file_map_all(loader->f, EINA_FILE_WILLNEED);
|
||||
if (!m) return EINA_FALSE;
|
||||
|
||||
// By definition, prop{.w, .h} == region{.w, .h}
|
||||
EINA_RECTANGLE_SET(&master,
|
||||
loader->region.x, loader->region.y,
|
||||
prop->w, prop->h);
|
||||
|
||||
switch (loader->cspace)
|
||||
{
|
||||
case EVAS_COLORSPACE_ETC1:
|
||||
case EVAS_COLORSPACE_RGB8_ETC2:
|
||||
etc_block_size = 8;
|
||||
break;
|
||||
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
||||
etc_block_size = 16;
|
||||
break;
|
||||
case EVAS_COLORSPACE_ETC1_ALPHA:
|
||||
etc_block_size = 8;
|
||||
num_planes = 2;
|
||||
alpha_offset = ((prop->w + 2 + 3) / 4) * ((prop->h + 2 + 3) / 4) * 8 / sizeof(*p_etc);
|
||||
break;
|
||||
default: abort();
|
||||
}
|
||||
etc_width = ((prop->w + 2 + 3) / 4) * etc_block_size;
|
||||
|
||||
switch (prop->cspace)
|
||||
{
|
||||
case EVAS_COLORSPACE_ETC1:
|
||||
case EVAS_COLORSPACE_RGB8_ETC2:
|
||||
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
||||
case EVAS_COLORSPACE_ETC1_ALPHA:
|
||||
if (master.x % 4 || master.y % 4)
|
||||
abort();
|
||||
break;
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
// Offset to take duplicated pixels into account
|
||||
master.x += 1;
|
||||
master.y += 1;
|
||||
break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
if (prop->cspace != EVAS_COLORSPACE_ARGB8888 && prop->cspace != loader->cspace)
|
||||
{
|
||||
if (!((prop->cspace == EVAS_COLORSPACE_RGB8_ETC2) &&
|
||||
(loader->cspace == EVAS_COLORSPACE_ETC1)))
|
||||
goto on_error;
|
||||
// else: ETC2 is compatible with ETC1 and is preferred
|
||||
}
|
||||
|
||||
// Allocate space for each ETC block (8 or 16 bytes per 4 * 4 pixels group)
|
||||
block_count = loader->block.width * loader->block.height / (4 * 4);
|
||||
if (loader->compress)
|
||||
buffer = alloca(etc_block_size * block_count);
|
||||
|
||||
for (plane = 0; plane < num_planes; plane++)
|
||||
for (y = 0; y < loader->size.height + 2; y += loader->block.height)
|
||||
for (x = 0; x < loader->size.width + 2; x += loader->block.width)
|
||||
{
|
||||
Eina_Rectangle current;
|
||||
const char *data_start;
|
||||
const char *it;
|
||||
unsigned int expand_length;
|
||||
unsigned int i, j;
|
||||
|
||||
block_length = _tgv_length_get(m + offset, length, &offset);
|
||||
|
||||
if (block_length == 0) goto on_error;
|
||||
|
||||
data_start = m + offset;
|
||||
offset += block_length;
|
||||
|
||||
EINA_RECTANGLE_SET(¤t, x, y,
|
||||
loader->block.width, loader->block.height);
|
||||
|
||||
if (!eina_rectangle_intersection(¤t, &master))
|
||||
continue;
|
||||
|
||||
if (loader->compress)
|
||||
{
|
||||
expand_length = LZ4_decompress_fast(data_start, buffer,
|
||||
block_count * etc_block_size);
|
||||
// That's an overhead for now, need to be fixed
|
||||
if (expand_length != block_length)
|
||||
goto on_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = (void*) data_start;
|
||||
if (block_count * etc_block_size != block_length)
|
||||
goto on_error;
|
||||
}
|
||||
it = buffer;
|
||||
|
||||
for (i = 0; i < loader->block.height; i += 4)
|
||||
for (j = 0; j < loader->block.width; j += 4, it += etc_block_size)
|
||||
{
|
||||
Eina_Rectangle current_etc;
|
||||
unsigned int temporary[4 * 4];
|
||||
unsigned int offset_x, offset_y;
|
||||
int k, l;
|
||||
|
||||
EINA_RECTANGLE_SET(¤t_etc, x + j, y + i, 4, 4);
|
||||
|
||||
if (!eina_rectangle_intersection(¤t_etc, ¤t))
|
||||
continue;
|
||||
|
||||
switch (prop->cspace)
|
||||
{
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
switch (loader->cspace)
|
||||
{
|
||||
case EVAS_COLORSPACE_ETC1:
|
||||
case EVAS_COLORSPACE_ETC1_ALPHA:
|
||||
if (!rg_etc1_unpack_block(it, temporary, 0))
|
||||
{
|
||||
// TODO: Should we decode as RGB8_ETC2?
|
||||
fprintf(stderr, "ETC1: Block starting at {%i, %i} is corrupted!\n", x + j, y + i);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case EVAS_COLORSPACE_RGB8_ETC2:
|
||||
rg_etc2_rgb8_decode_block((uint8_t *) it, temporary);
|
||||
break;
|
||||
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
||||
rg_etc2_rgba8_decode_block((uint8_t *) it, temporary);
|
||||
break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
offset_x = current_etc.x - x - j;
|
||||
offset_y = current_etc.y - y - i;
|
||||
|
||||
if (!plane)
|
||||
{
|
||||
#ifdef BUILD_NEON
|
||||
if (eina_cpu_features_get() & EINA_CPU_NEON)
|
||||
{
|
||||
uint32_t *dst = &p[current_etc.x - 1 + (current_etc.y - 1) * master.w];
|
||||
uint32_t *src = &temporary[offset_x + offset_y * 4];
|
||||
for (k = 0; k < current_etc.h; k++)
|
||||
{
|
||||
if (current_etc.w == 4)
|
||||
vst1q_u32(dst, vld1q_u32(src));
|
||||
else if (current_etc.w == 3)
|
||||
{
|
||||
vst1_u32(dst, vld1_u32(src));
|
||||
*(dst + 2) = *(src + 2);
|
||||
}
|
||||
else if (current_etc.w == 2)
|
||||
vst1_u32(dst, vld1_u32(src));
|
||||
else
|
||||
*dst = *src;
|
||||
dst += master.w;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
for (k = 0; k < current_etc.h; k++)
|
||||
{
|
||||
memcpy(&p[current_etc.x - 1 + (current_etc.y - 1 + k) * master.w],
|
||||
&temporary[offset_x + (offset_y + k) * 4],
|
||||
current_etc.w * sizeof (unsigned int));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (k = 0; k < current_etc.h; k++)
|
||||
for (l = 0; l < current_etc.w; l++)
|
||||
{
|
||||
unsigned int *rgbdata =
|
||||
&p[current_etc.x - 1 + (current_etc.y - 1 + k) * master.w + l];
|
||||
unsigned int *adata =
|
||||
&temporary[offset_x + (offset_y + k) * 4 + l];
|
||||
A_VAL(rgbdata) = G_VAL(adata);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EVAS_COLORSPACE_ETC1:
|
||||
case EVAS_COLORSPACE_RGB8_ETC2:
|
||||
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
||||
memcpy(&p_etc[(current_etc.x / 4) * etc_block_size +
|
||||
(current_etc.y / 4) * etc_width],
|
||||
it, etc_block_size);
|
||||
break;
|
||||
case EVAS_COLORSPACE_ETC1_ALPHA:
|
||||
memcpy(&p_etc[(current_etc.x / 4) * etc_block_size +
|
||||
(current_etc.y / 4) * etc_width +
|
||||
plane * alpha_offset],
|
||||
it, etc_block_size);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
} // bx,by inside blocks
|
||||
} // x,y macroblocks
|
||||
|
||||
// TODO: Add support for more unpremultiplied modes (ETC2)
|
||||
if (prop->cspace == EVAS_COLORSPACE_ARGB8888)
|
||||
prop->premul = loader->unpremul; // call premul if unpremul data
|
||||
|
||||
r = EINA_TRUE;
|
||||
*error = EVAS_LOAD_ERROR_NONE;
|
||||
|
||||
on_error:
|
||||
eina_file_map_free(loader->f, (void*) m);
|
||||
return r;
|
||||
ret = emile_image_data(loader->image,
|
||||
prop, sizeof (Emile_Image_Property),
|
||||
pixels,
|
||||
&image_error);
|
||||
*error = image_error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Evas_Image_Load_Func evas_image_load_tgv_func =
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /* ifdef HAVE_CONFIG_H */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include <Eina.h>
|
||||
#include <Emile.h>
|
||||
|
||||
START_TEST(emile_test_init)
|
||||
{
|
||||
fail_if(emile_init() <= 0);
|
||||
fail_if(emile_shutdown() != 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
emile_base_test(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, emile_test_init);
|
||||
}
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
void (*build)(TCase *tc);
|
||||
} tests[] = {
|
||||
{
|
||||
"Emile_Base", emile_base_test
|
||||
}
|
||||
};
|
||||
|
||||
static void
|
||||
_list_tests(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
fputs("Available tests cases :\n", stderr);
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
|
||||
fprintf(stderr, "\t%s\n", tests[i].name);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_use_test(const char *name, int argc, char *argv[])
|
||||
{
|
||||
argc--;
|
||||
argv--;
|
||||
|
||||
if (argc < 1)
|
||||
return EINA_TRUE;
|
||||
|
||||
for (; argc > 1; argc--, argv++)
|
||||
if (strcmp(name, *argv) == 0)
|
||||
return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SRunner *sr;
|
||||
Suite *s;
|
||||
unsigned int i;
|
||||
int failed_count;
|
||||
int j;
|
||||
|
||||
for (j = 1; j < argc; j++)
|
||||
if ((strcmp(argv[j], "-h") == 0) || (strcmp(argv[j], "--help") == 0))
|
||||
{
|
||||
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]);
|
||||
_list_tests();
|
||||
return 0;
|
||||
}
|
||||
else if ((strcmp(argv[j], "-l") == 0) || (strcmp(argv[j], "--list") == 0))
|
||||
{
|
||||
_list_tests();
|
||||
return 0;
|
||||
}
|
||||
|
||||
s = suite_create("Emile");
|
||||
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
|
||||
{
|
||||
TCase *tc;
|
||||
|
||||
if (!_use_test(tests[i].name, argc, argv))
|
||||
continue;
|
||||
|
||||
tc = tcase_create(tests[i].name);
|
||||
tests[i].build(tc);
|
||||
suite_add_tcase(s, tc);
|
||||
tcase_set_timeout(tc, 0);
|
||||
}
|
||||
|
||||
sr = srunner_create(s);
|
||||
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
||||
srunner_run_all(sr, CK_ENV);
|
||||
failed_count = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
|
||||
return (failed_count == 0) ? 0 : 255;
|
||||
}
|
Loading…
Reference in New Issue