emile: fix coding style with ecrustify.

This commit is contained in:
Cedric BAIL 2015-03-17 08:51:01 +01:00
parent aa3b6615ee
commit f875f759ca
7 changed files with 601 additions and 552 deletions

View File

@ -66,9 +66,7 @@ EAPI Emile_Cipher_Backend emile_cipher_module_get(void);
*
* @since 1.14
*/
EAPI Eina_Binbuf *emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
const Eina_Binbuf *in,
const char *key, unsigned int length);
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.
@ -85,9 +83,7 @@ EAPI Eina_Binbuf *emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
*
* @since 1.14
*/
EAPI Eina_Binbuf *emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
const Eina_Binbuf *in,
const char *key, unsigned int length);
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
@ -107,30 +103,27 @@ typedef enum
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 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_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_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);
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

View File

@ -1,15 +1,15 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif
#include <zlib.h>
#ifdef ENABLE_LIBLZ4
# include <lz4.h>
# include <lz4hc.h>
#include <lz4.h>
#include <lz4hc.h>
#else
# include "lz4.h"
# include "lz4hc.h"
#include "lz4.h"
#include "lz4hc.h"
#endif
#include <Eina.h>
@ -22,12 +22,14 @@ _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);
return 12 + ((eina_binbuf_length_get(data) * 101) / 100);
case EMILE_LZ4:
case EMILE_LZ4HC:
return LZ4_compressBound(eina_binbuf_length_get(data));
return LZ4_compressBound(eina_binbuf_length_get(data));
default:
return -1;
return -1;
}
}
@ -44,29 +46,38 @@ emile_compress(const Eina_Binbuf *data,
length = _emile_compress_buffer_size(data, t);
compact = malloc(length);
if (!compact) return NULL;
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;
compact = realloc(compact, length); /* It is going to be smaller and should never fail, if it does you are in deep poo. */
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;
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;
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;
}
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)
@ -79,62 +90,67 @@ emile_compress(const Eina_Binbuf *data,
}
EAPI Eina_Bool
emile_expand(const Eina_Binbuf *in,
Eina_Binbuf *out,
Emile_Compressor_Type t)
emile_expand(const Eina_Binbuf *in, Eina_Binbuf *out, Emile_Compressor_Type t)
{
if (!in || !out) return EINA_FALSE;
if (!in || !out)
return EINA_FALSE;
switch (t)
{
case EMILE_LZ4:
case EMILE_LZ4HC:
{
int ret;
{
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;
}
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);
{
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;
}
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_FALSE;
}
return EINA_TRUE;
}
EAPI Eina_Binbuf *
emile_decompress(const Eina_Binbuf *data, Emile_Compressor_Type t, unsigned int dest_length)
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;
if (!expanded)
return NULL;
out = eina_binbuf_manage_new(expanded, dest_length, EINA_FALSE);
if (!out) goto on_error;
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);
on_error:
if (!out)
free(expanded);
if (out)
eina_binbuf_free(out);
return NULL;
}

View File

@ -51,9 +51,7 @@ typedef enum
*
* @since 1.14
*/
EAPI Eina_Binbuf *emile_compress(const Eina_Binbuf *in,
Emile_Compressor_Type t,
Emile_Compressor_Level level);
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.
*
@ -69,9 +67,7 @@ EAPI Eina_Binbuf *emile_compress(const Eina_Binbuf *in,
* @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);
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.
@ -87,9 +83,7 @@ EAPI Eina_Binbuf *emile_decompress(const Eina_Binbuf *in,
* 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);
EAPI Eina_Bool emile_expand(const Eina_Binbuf * in, Eina_Binbuf * out, Emile_Compressor_Type t);
/**
* @}
*/

File diff suppressed because it is too large Load Diff

View File

@ -33,14 +33,14 @@ typedef enum _Emile_Colorspace
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_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_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;
/**
@ -106,13 +106,13 @@ typedef enum _Emile_Image_Animated_Loop_Hint
*/
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_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. */
/**
@ -153,61 +153,63 @@ typedef struct _Emile_Image_Property Emile_Image_Property;
struct _Emile_Image_Property
{
struct {
unsigned char l, r, t, b;
} borders;
struct
{
unsigned char l, r, t, b;
} borders;
const Emile_Colorspace *cspaces;
Emile_Colorspace cspace;
const Emile_Colorspace *cspaces;
Emile_Colorspace cspace;
Emile_Image_Encoding encoding;
Emile_Image_Encoding encoding;
unsigned int w;
unsigned int h;
unsigned int row_stride;
unsigned int w;
unsigned int h;
unsigned int row_stride;
unsigned char scale;
unsigned char scale;
Eina_Bool rotated;
Eina_Bool alpha;
Eina_Bool premul;
Eina_Bool alpha_sparse;
Eina_Bool rotated;
Eina_Bool alpha;
Eina_Bool premul;
Eina_Bool alpha_sparse;
Eina_Bool flipped;
Eina_Bool comp;
Eina_Bool flipped;
Eina_Bool comp;
};
struct _Emile_Image_Animated
{
Eina_List *frames;
Eina_List *frames;
Emile_Image_Animated_Loop_Hint loop_hint;
Emile_Image_Animated_Loop_Hint loop_hint;
int frame_count;
int loop_count;
int cur_frame;
int frame_count;
int loop_count;
int cur_frame;
Eina_Bool animated;
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;
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;
/* 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;
Eina_Bool orientation;
};
// FIXME: should we set region at load time, instead of head time
@ -224,11 +226,7 @@ struct _Emile_Image_Load_Opts
*
* @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);
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.
@ -241,11 +239,7 @@ emile_image_tgv_memory_open(Eina_Binbuf *source,
*
* @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);
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);
/**
@ -259,11 +253,7 @@ emile_image_tgv_file_open(Eina_File *source,
*
* @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);
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.
@ -276,11 +266,7 @@ emile_image_jpeg_memory_open(Eina_Binbuf *source,
*
* @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);
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.
@ -293,11 +279,7 @@ emile_image_jpeg_file_open(Eina_File *source,
*
* @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);
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.
@ -311,12 +293,7 @@ emile_image_head(Emile_Image *image,
*
* @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);
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.
@ -325,8 +302,7 @@ emile_image_data(Emile_Image *image,
*
* @since 1.14
*/
EAPI void
emile_image_close(Emile_Image *source);
EAPI void emile_image_close(Emile_Image * source);
/**
* Convert an error code related to an image handler into a meaningful string.
@ -337,9 +313,7 @@ emile_image_close(Emile_Image *source);
*
* @since 1.14
*/
EAPI const char *
emile_load_error_str(Emile_Image *source,
Emile_Image_Load_Error error);
EAPI const char *emile_load_error_str(Emile_Image * source, Emile_Image_Load_Error error);
/**
* @}

View File

@ -1,17 +1,17 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#ifdef HAVE_GNUTLS
# include <gnutls/gnutls.h>
# include <gnutls/x509.h>
# include <gcrypt.h>
#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>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#endif /* ifdef HAVE_OPENSSL */
#include <Eina.h>
@ -26,9 +26,11 @@ int _emile_log_dom_global = -1;
EAPI Eina_Bool
emile_cipher_init(void)
{
if (_emile_cipher_inited) return EINA_TRUE;
if (_emile_cipher_inited)
return EINA_TRUE;
if (!_emile_cipher_init()) return EINA_FALSE;
if (!_emile_cipher_init())
return EINA_FALSE;
_emile_cipher_inited = EINA_TRUE;
@ -65,13 +67,11 @@ emile_init(void)
goto shutdown_eina;
}
eina_log_timing(_emile_log_dom_global,
EINA_LOG_STATE_STOP,
EINA_LOG_STATE_INIT);
eina_log_timing(_emile_log_dom_global, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
return _emile_init_count;
shutdown_eina:
shutdown_eina:
eina_shutdown();
return --_emile_init_count;
@ -83,9 +83,7 @@ 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);
eina_log_timing(_emile_log_dom_global, EINA_LOG_STATE_START, EINA_LOG_STATE_SHUTDOWN);
if (_emile_cipher_inited)
{
@ -122,13 +120,7 @@ emile_shutdown(void)
/* 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)
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;
@ -140,12 +132,15 @@ emile_pbkdf2_sha1(const char *key,
unsigned int i, j, k;
buf = alloca(salt_len + 4);
if (!buf) return EINA_FALSE;
if (!buf)
return EINA_FALSE;
step1 = eina_binbuf_manage_new(buf, salt_len + 4, EINA_TRUE);
if (!step1) return EINA_FALSE;
if (!step1)
return EINA_FALSE;
step2 = eina_binbuf_manage_new(digest, 20, EINA_TRUE);
if (!step2) return EINA_FALSE;
if (!step2)
return EINA_FALSE;
for (i = 1; len; len -= tmp_len, p += tmp_len, i++)
{
@ -178,3 +173,4 @@ emile_pbkdf2_sha1(const char *key,
return EINA_TRUE;
}

View File

@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include <stdlib.h>
@ -23,11 +23,14 @@ emile_base_test(TCase *tc)
tcase_add_test(tc, emile_test_init);
}
static const struct {
static const struct
{
const char *name;
void (*build)(TCase *tc);
void (*build)(TCase *tc);
} tests[] = {
{ "Emile_Base", emile_base_test }
{
"Emile_Base", emile_base_test
}
};
static void
@ -36,16 +39,18 @@ _list_tests(void)
unsigned int i;
fputs("Available tests cases :\n", stderr);
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
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--;
argc--;
argv--;
if (argc < 1) return EINA_TRUE;
if (argc < 1)
return EINA_TRUE;
for (; argc > 1; argc--, argv++)
if (strcmp(name, *argv) == 0)
@ -63,16 +68,13 @@ main(int argc, char *argv[])
int j;
for (j = 1; j < argc; j++)
if ((strcmp(argv[j], "-h") == 0) ||
(strcmp(argv[j], "--help") == 0))
if ((strcmp(argv[j], "-h") == 0) || (strcmp(argv[j], "--help") == 0))
{
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
argv[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))
else if ((strcmp(argv[j], "-l") == 0) || (strcmp(argv[j], "--list") == 0))
{
_list_tests();
return 0;
@ -80,11 +82,12 @@ main(int argc, char *argv[])
s = suite_create("Emile");
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
{
TCase *tc;
if (!_use_test(tests[i].name, argc, argv)) continue ;
if (!_use_test(tests[i].name, argc, argv))
continue;
tc = tcase_create(tests[i].name);
tests[i].build(tc);