-/* GLIB - Library of useful routines for C programming
+/*
+ * libmedia-service
*
- * gconvert.c: Convert between character sets using iconv
- * Copyright Red Hat Inc., 2000
- * Authors: Havoc Pennington <hp@redhat.com>, Owen Taylor <otaylor@redhat.com
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
- * 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 of the License, or (at your option) any later version.
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
*
- * 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.
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* The array below is taken from gconvert.c, which is licensed by GNU Lesser General Public License
- * Code to escape string is also taken partially from gconvert.c
- * File name is changed to media-svc-hash.c
*/
#include "md5.h"
static const char ACCEPTABLE_URI_CHARS[96] = {
- /* ! " # $ % & ' ( ) * + , - . / */
+ /* ! " # $ % & ' ( ) * + , - . / */
0x00, 0x3F, 0x20, 0x20, 0x28, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x2A,
- 0x28, 0x3F, 0x3F, 0x1C,
+ 0x28, 0x3F, 0x3F, 0x1C,
/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20,
- 0x20, 0x2C, 0x20, 0x20,
+ 0x20, 0x2C, 0x20, 0x20,
/* @ A B C D E F G H I J K L M N O */
0x38, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x3F, 0x3F, 0x3F, 0x3F,
/* P Q R S T U V W X Y Z [ \ ] ^ _ */
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
- 0x20, 0x20, 0x20, 0x3F,
+ 0x20, 0x20, 0x20, 0x3F,
/* ` a b c d e f g h i j k l m n o */
0x20, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x3F, 0x3F, 0x3F, 0x3F,
/* p q r s t u v w x y z { | } ~ DEL */
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
- 0x20, 0x20, 0x3F, 0x20
+ 0x20, 0x20, 0x3F, 0x20
};
char *_mb_svc_generate_hash_name(const char *file)
const unsigned char *c;
int length;
- if (!file) {
+ if (!file)
return NULL;
- }
length = 3 * strlen(file) + 9;
memset(md5out, 0, sizeof(md5out));
#define _check_uri_char(c) \
-((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
+ ((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
uri = alloca(length);
- if (uri == NULL) {
+ if (uri == NULL)
return NULL;
- }
strncpy(uri, "file://", length);
uri[length - 1] = '\0';
*t = '\0';
#undef _check_uri_char
- MD5Init(&ctx);
- MD5Update(&ctx, (unsigned char const *)uri, (unsigned)strlen(uri));
- MD5Final(hash, &ctx);
+ media_svc_MD5Init(&ctx);
+ media_svc_MD5Update(&ctx, (unsigned char const *)uri, (unsigned)strlen(uri));
+ media_svc_MD5Final(hash, &ctx);
for (n = 0; n < MD5_HASHBYTES; n++) {
md5out[2 * n] = hex[hash[n] >> 4];
{
char *hash = NULL;
- if (max_length < ((2 * MD5_HASHBYTES) + 1)) {
+ if (max_length < ((2 * MD5_HASHBYTES) + 1))
return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
hash = _mb_svc_generate_hash_name(origin_path);
- if (hash == NULL) {
+ if (hash == NULL)
return MS_MEDIA_ERR_INTERNAL;
- }
strncpy(hash_code, hash, max_length);
- hash_code[strlen(hash_code)] ='\0';
+ hash_code[strlen(hash_code)] = '\0';
return MS_MEDIA_ERR_NONE;
}