}
}
-static inline int __ctsvc_vcard_get_image_type(char *val)
+static inline int __ctsvc_vcard_get_image_type(const char *val)
{
- char *temp, *result;
+ char *temp, *image_path, *result;
RETV_IF(NULL == val, CTSVC_VCARD_IMG_NONE);
- temp = val;
+ image_path = strdup(val);
+ temp = image_path;
while (*temp) {
*temp = tolower(*temp);
temp++;
}
- result = strstr(val, "jpeg");
- if (result) return CTSVC_VCARD_IMG_JPEG;
+ result = strstr(image_path, "jpeg");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_JPEG;
+ }
- result = strstr(val, "jpg");
- if (result) return CTSVC_VCARD_IMG_JPEG;
+ result = strstr(image_path, "jpg");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_JPEG;
+ }
- result = strstr(val, "png");
- if (result) return CTSVC_VCARD_IMG_PNG;
+ result = strstr(image_path, "png");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_PNG;
+ }
- result = strstr(val, "gif");
- if (result) return CTSVC_VCARD_IMG_GIF;
+ result = strstr(image_path, "gif");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_GIF;
+ }
- result = strstr(val, "tiff");
- if (result) return CTSVC_VCARD_IMG_TIFF;
+ result = strstr(image_path, "tiff");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_TIFF;
+ }
- result = strstr(val, "cgm");
- if (result) return CTSVC_VCARD_IMG_CGM;
+ result = strstr(image_path, "cgm");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_CGM;
+ }
- result = strstr(val, "wmf");
- if (result) return CTSVC_VCARD_IMG_WMF;
+ result = strstr(image_path, "wmf");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_WMF;
+ }
- result = strstr(val, "bmp");
- if (result) return CTSVC_VCARD_IMG_BMP;
+ result = strstr(image_path, "bmp");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_BMP;
+ }
- result = strstr(val, "met");
- if (result) return CTSVC_VCARD_IMG_MET;
+ result = strstr(image_path, "met");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_MET;
+ }
- result = strstr(val, "pmb");
- if (result) return CTSVC_VCARD_IMG_PMB;
+ result = strstr(image_path, "pmb");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_PMB;
+ }
- result = strstr(val, "dib");
- if (result) return CTSVC_VCARD_IMG_DIB;
+ result = strstr(image_path, "dib");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_DIB;
+ }
- result = strstr(val, "pict");
- if (result) return CTSVC_VCARD_IMG_PICT;
+ result = strstr(image_path, "pict");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_PICT;
+ }
- result = strstr(val, "pdf");
- if (result) return CTSVC_VCARD_IMG_PDF;
+ result = strstr(image_path, "pdf");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_PDF;
+ }
- result = strstr(val, "ps");
- if (result) return CTSVC_VCARD_IMG_PS;
+ result = strstr(image_path, "ps");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_PS;
+ }
- result = strstr(val, "qtime");
- if (result) return CTSVC_VCARD_IMG_QTIME;
+ result = strstr(image_path, "qtime");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_QTIME;
+ }
- result = strstr(val, "mpeg");
- if (result) return CTSVC_VCARD_IMG_MPEG;
+ result = strstr(image_path, "mpeg");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_MPEG;
+ }
- result = strstr(val, "mpeg2");
- if (result) return CTSVC_VCARD_IMG_MPEG2;
+ result = strstr(image_path, "mpeg2");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_MPEG2;
+ }
- result = strstr(val, "avi");
- if (result) return CTSVC_VCARD_IMG_AVI;
+ result = strstr(image_path, "avi");
+ if (result) {
+ free(image_path);
+ return CTSVC_VCARD_IMG_AVI;
+ }
+ free(image_path);
return CTSVC_VCARD_IMG_NONE;
}
guchar image[CTSVC_VCARD_PHOTO_MAX_SIZE] = {0};
suffix = strrchr(path, '.');
- type = __ctsvc_vcard_get_image_type(suffix);
+ type = __ctsvc_vcard_get_image_type((const char *)suffix);
fd = open(path, O_RDONLY);
RETVM_IF(fd < 0, CONTACTS_ERROR_SYSTEM, "System : Open Fail(%d)", errno);
}
suffix = strrchr(data->path, '.');
- type = __ctsvc_vcard_get_image_type(suffix);
+ type = __ctsvc_vcard_get_image_type((const char *)suffix);
buf_image = g_base64_encode(image, read_len);
free(image);
*temp = '\0';
- type = __ctsvc_vcard_get_image_type(prefix);
+ type = __ctsvc_vcard_get_image_type((const char *)prefix);
buf = g_base64_decode(temp+1, &size);
if ((0 == size) || (NULL == buf)) {
RETVM_IF(NULL == temp, CONTACTS_ERROR_INVALID_PARAMETER, "val is invalid");
*temp = '\0';
- type = __ctsvc_vcard_get_image_type(prefix);
+ type = __ctsvc_vcard_get_image_type((const char *)prefix);
buf = g_base64_decode(temp+1, &size);
if ((0 == size) || (NULL == buf)) {
cursor = new_start;
if (prefix)
free(prefix);
+ if (val)
+ free(val);
continue;
}
if (CONTACTS_ERROR_NONE != ret) {
free(stream);
fclose(file);
- ERR("_ctsvc_safe_add() Fail(%u + %d)", len, written_len);
+ ERR("_ctsvc_safe_add() Fail(len:%d, written_len:%d)", len, written_len);
return ret;
}