Bug fix. insecure strncmp
[platform/core/multimedia/libmm-utility.git] / common / include / mm_util_private.h
old mode 100755 (executable)
new mode 100644 (file)
index 601d42d..5a5f87a
@@ -3,8 +3,6 @@
  *
  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: YoungHun Kim <yh8004.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 #ifndef __MM_UTIL_PRIVATE_H__
 #define __MM_UTIL_PRIVATE_H__
 
-#include <glib.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include "mm_util_debug.h"
 #include "mm_util_type.h"
+#include "mm_util_debug.h"
+#include "mm_util_image.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* for memory management */
-#define MMUTIL_SAFE_FREE(x)                            { if (x) { free(x); x = NULL; } }
-#define MMUTIL_SAFE_G_FREE(x)                  { if (x) { g_free(x); x = NULL; } }
-#define MMUTIL_SAFE_STRCPY(dst, src, n)        g_strlcpy(dst, src, n)
-#define MMUTIL_STRING_VALID(str)       ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
 
-#define SAFE_STRLCPY(dst, src, n)      g_strlcpy(dst, src, n);
+#define MMUTIL_STRING_VALID(str)         (str != NULL && strlen(str) > 0)
 
 /* for alignment */
 #define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1)
@@ -48,12 +40,44 @@ extern "C" {
 #define MM_UTIL_ROUND_DOWN_4(num) ((num)&(~3))
 #define MM_UTIL_ROUND_DOWN_16(num) ((num)&(~15))
 
-#define IS_VALID_COLOR(color)  mm_util_is_valid_color_format(color)
+#define IS_VALID_COLOR(color)  ((color >= MM_UTIL_COLOR_YUV420) && (color < MM_UTIL_COLOR_NUM))
+#define IS_VALID_IMAGE(image)  mm_image_is_valid_image(image)
+
+typedef int (*ANIM_ENC_CREATE)(void *);
+typedef int (*ANIM_ENC_SET_BG_COLOR)(void *, unsigned char, unsigned char, unsigned char, unsigned char);
+typedef int (*ANIM_ENC_SET_LOOP_COUNT)(void *, unsigned int);
+typedef int (*ANIM_ENC_SET_LOSSLESS)(void *, bool);
+typedef int (*ANIM_ENC_ADD_IMAGE)(void *, mm_util_image_h);
+typedef int (*ANIM_ENC_SAVE_TO_FILE)(void *, const char *);
+typedef int (*ANIM_ENC_SAVE_TO_BUFFER)(void *, void **, size_t *);
+typedef void (*ANIM_ENC_DESTROY)(void *);
 
-gboolean mm_util_is_valid_color_format(mm_util_color_format_e color);
+typedef struct {
+       ANIM_ENC_CREATE                 create;
+       ANIM_ENC_SET_BG_COLOR   set_bgcolor;
+       ANIM_ENC_SET_LOOP_COUNT set_loop_count;
+       ANIM_ENC_SET_LOSSLESS   set_lossless;
+       ANIM_ENC_ADD_IMAGE              add_image;
+       ANIM_ENC_SAVE_TO_FILE   save_to_file;
+       ANIM_ENC_SAVE_TO_BUFFER save_to_buffer;
+       ANIM_ENC_DESTROY                destroy;
+} anim_enc_module_t;
 
+typedef struct {
+       mm_util_img_codec_type codec;
+       unsigned int compression;
+       bool lossless;
+} mm_util_enc_opt_t;
+
+// for using fp like jpeg
 int mm_util_safe_fopen(const char *path, const char *mode, FILE **fp);
-void mm_util_safe_fclose(FILE *fp);
+
+// for others
+int mm_util_file_read(const char *path, void **data, size_t *size);
+int mm_util_file_write(const char *path, void *data, size_t size);
+
+// for reading ini
+int mm_util_ini_get_int(const char *category, const char *item, int default_value);
 
 #ifdef __cplusplus
 }