2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
31 int util_check_extension(const char *filename, const char *check_ptr)
35 name_len = strlen(filename);
36 while (--name_len >= 0 && *check_ptr) {
37 if (filename[name_len] != *check_ptr)
46 double util_timestamp(void)
50 gettimeofday(&tv, NULL);
52 return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
55 const char *util_basename(const char *name)
58 length = name ? strlen(name) : 0;
62 while (--length > 0 && name[length] != '/');
64 return length <= 0 ? name : name + length + (name[length] == '/');
67 static inline int check_native_livebox(const char *pkgname)
72 len = strlen(pkgname) * 2;
73 len += strlen("/opt/usr/live/%s/libexec/liblive-%s.so");
75 path = malloc(len + 1);
77 ErrPrint("Heap: %s\n", strerror(errno));
81 snprintf(path, len, "/opt/usr/live/%s/libexec/liblive-%s.so", pkgname, pkgname);
82 if (access(path, F_OK | R_OK) != 0) {
83 ErrPrint("%s is not a valid package\n", pkgname);
92 static inline int check_web_livebox(const char *pkgname)
97 len = strlen(pkgname) * 2;
98 len += strlen("/opt/usr/apps/%s/res/wgt/livebox/index.html");
100 path = malloc(len + 1);
102 ErrPrint("Heap: %s\n", strerror(errno));
106 snprintf(path, len, "/opt/usr/apps/%s/res/wgt/livebox/index.html", pkgname);
107 if (access(path, F_OK | R_OK) != 0) {
108 ErrPrint("%s is not a valid package\n", pkgname);
117 int util_validate_livebox_package(const char *pkgname)
120 ErrPrint("Invalid argument\n");
124 if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname))
130 const char *util_uri_to_path(const char *uri)
134 len = strlen(SCHEMA_FILE);
135 if (strncasecmp(uri, SCHEMA_FILE, len))