INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs -pie" )
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall -Werror")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
#include <sys/wait.h>
#include "delta.h"
-static GList * __list_directory(const char * dir_name, const char * tpk_path, GList * list);
-static int __compare_files(char * path1, char * path2);
-static void __print_to_file(char* msg);
-static void __free_g_list(GList * list);
+static GList *__list_directory(const char *dir_name, const char *tpk_path, GList *list);
+static int __compare_files(char *path1, char *path2);
+static void __print_to_file(char *msg);
+static void __free_g_list(GList *list);
-static void __free_g_list(GList * list)
+static void __free_g_list(GList *list)
{
- GList * iter = NULL;
- for (iter = list; iter != NULL; iter = iter->next)
- {
+ GList *iter = NULL;
+
+ for (iter = list; iter != NULL; iter = iter->next) {
if (iter->data)
free(iter->data);
}
g_list_free(list);
+
return;
}
-static GList * __list_directory (const char * dir_name, const char * tpk_path, GList * list)
+static GList *__list_directory(const char *dir_name, const char *tpk_path, GList *list)
{
- DIR *dir = NULL;
- struct dirent entry, *result;
- int flag = 0;
- char path[PATH_MAX] = {0, };
- char rel_path_old_tpk_file[PATH_MAX] = {0, };
- char *file_path = NULL;
- char buf[BUF_SIZE] = {0};
-
- dir = opendir(dir_name);
- if (!dir)
- {
- if (strerror_r(errno, buf, sizeof(buf)) == 0) {
- printf ("Cannot open directory '%s': %s\n", dir_name, buf);
- }
- exit (EXIT_FAILURE);
- }
- while (1)
- {
- const char * d_name = NULL;
- int ret = 0;
- ret = readdir_r(dir, &entry, &result); /* "Readdir" gets subsequent entries from "d". */
- if (ret != 0 || result == NULL)/* There are no more entries in this directory, so break out of the while loop. */
- {
- flag++;
- break;
- }
- d_name = entry.d_name;
- if (!(entry.d_type & DT_DIR))
- {
- snprintf(rel_path_old_tpk_file, PATH_MAX, "%s/%s", dir_name, d_name);
- strncpy(path, rel_path_old_tpk_file+strlen(tpk_path), strlen(rel_path_old_tpk_file));
- file_path = strndup(path, sizeof(path));
- list = g_list_append(list, file_path);
- memset(path, 0, PATH_MAX);
- memset(rel_path_old_tpk_file, 0, PATH_MAX);
-
- }
-
- if (entry.d_type & DT_DIR) /* Check that the directory is not "d" or d's parent. */
- {
- if (strcmp(d_name, "..") != 0 && strcmp (d_name, ".") != 0)
- {
- int path_length;
- path_length = snprintf (path, PATH_MAX, "%s/%s", dir_name, d_name);
- if (path_length >= PATH_MAX)
- {
- printf("Path length has got too long.\n");
- exit(EXIT_FAILURE);
- }
- list = __list_directory (path, tpk_path, list);
- memset(path, 0, PATH_MAX);/* Recursively call "list_dir" with the new path. */
- }
- }
- }
- if(flag == 1)
- {
- snprintf (rel_path_old_tpk_file, PATH_MAX, "%s/", dir_name);
- strncpy(path, rel_path_old_tpk_file+strlen(tpk_path), strlen(rel_path_old_tpk_file));
- file_path = strndup(path, sizeof(path));
- list = g_list_prepend(list, file_path);
- memset(path, 0, PATH_MAX);
- memset(rel_path_old_tpk_file, 0, PATH_MAX);
- }
- if (closedir(dir))
- {
- if (strerror_r(errno, buf, sizeof(buf)) == 0) {
- printf("Could not close '%s': %s\n", dir_name, buf);
- }
- exit(EXIT_FAILURE);
- }
- return list;
+ DIR *dir = NULL;
+ struct dirent file_info;
+ struct dirent *result;
+ int flag = 0;
+ char path[PATH_MAX] = {0, };
+ char rel_path_old_tpk_file[PATH_MAX] = {0, };
+ char *file_path = NULL;
+ char buf[BUF_SIZE] = {0};
+ const char *d_name = NULL;
+ int ret = 0;
+ int path_length;
+
+ dir = opendir(dir_name);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ printf("Cannot open directory '%s': %s\n", dir_name, buf);
+ exit(EXIT_FAILURE);
+ }
+
+ while (1) {
+ ret = readdir_r(dir, &file_info, &result);
+ if (ret != 0 || result == NULL) {
+ flag++;
+ break;
+ }
+
+ d_name = file_info.d_name;
+ if (!(file_info.d_type & DT_DIR)) {
+ snprintf(rel_path_old_tpk_file, PATH_MAX, "%s/%s", dir_name, d_name);
+ strncpy(path, rel_path_old_tpk_file + strlen(tpk_path),
+ strlen(rel_path_old_tpk_file));
+ file_path = strndup(path, sizeof(path));
+ list = g_list_append(list, file_path);
+ memset(path, 0, PATH_MAX);
+ memset(rel_path_old_tpk_file, 0, PATH_MAX);
+ }
+
+ if (file_info.d_type & DT_DIR) {
+ if (strcmp(d_name, "..") != 0 && strcmp(d_name, ".") != 0) {
+ path_length = snprintf(path, PATH_MAX, "%s/%s", dir_name, d_name);
+ if (path_length >= PATH_MAX) {
+ printf("Path length has got too long.\n");
+ exit(EXIT_FAILURE);
+ }
+ list = __list_directory(path, tpk_path, list);
+ memset(path, 0, PATH_MAX);
+ }
+ }
+ }
+
+ if (flag == 1) {
+ snprintf(rel_path_old_tpk_file, PATH_MAX, "%s/", dir_name);
+ strncpy(path, rel_path_old_tpk_file+strlen(tpk_path),
+ strlen(rel_path_old_tpk_file));
+ file_path = strndup(path, sizeof(path));
+ list = g_list_prepend(list, file_path);
+ }
+
+ if (closedir(dir)) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ printf("Could not close '%s': %s\n", dir_name, buf);
+ exit(EXIT_FAILURE);
+ }
+
+ return list;
}
-static char * __create_md5Hash(char * file_name)
+static char *__create_md5Hash(char *file_name)
{
- FILE *inFile = fopen (file_name, "rb");
+ FILE *inFile = fopen(file_name, "rb");
unsigned char data[1024] = {0, };
int bytes = 0;
return 0;
}
- while ((bytes = fread(data, 1, 1024, inFile)) != 0) {
+ while ((bytes = fread(data, 1, 1024, inFile)) != 0)
g_checksum_update(checksum, (const guchar *)data, bytes);
- }
checksum_val = (char *)g_checksum_get_string(checksum);
- if (checksum_val) {
+ if (checksum_val)
return_val = strdup(checksum_val);
- }
g_checksum_free(checksum);
fclose(inFile);
return return_val;
}
-static int __compare_files(char * old_file, char * new_file)
+static int __compare_files(char *old_file, char *new_file)
{
char *md5_old_file = NULL;
char *md5_new_file = NULL;
+
md5_old_file = __create_md5Hash(old_file);
- if(md5_old_file == NULL)
- {
- printf("md5checksum failed for %s.\n", old_file );
+ if (md5_old_file == NULL) {
+ printf("md5checksum failed for %s.\n", old_file);
exit(EXIT_FAILURE);
}
+
md5_new_file = __create_md5Hash(new_file);
- if(md5_new_file == NULL)
- {
- printf("md5checksum failed for %s.\n", new_file );
+ if (md5_new_file == NULL) {
+ printf("md5checksum failed for %s.\n", new_file);
exit(EXIT_FAILURE);
}
- if(strcmp(md5_old_file, md5_new_file) == 0)
- {
+
+ if (strcmp(md5_old_file, md5_new_file) == 0) {
free(md5_old_file);
free(md5_new_file);
return 0;
- }
- else
- {
+ } else {
free(md5_old_file);
free(md5_new_file);
return 1;
}
}
-static void __print_to_file(char* msg)
+static void __print_to_file(char *msg)
{
FILE *fp;
+
fp = fopen(DIFF_FILE, "a");
- if (fp == NULL)
- {
+
+ if (fp == NULL) {
printf("Cannot open %s for writing ", DIFF_FILE);
exit(1);
}
+
fprintf(fp, "%s \n", msg);
memset(msg, 0, MAX_MESSAGE_LEN);
fclose(fp);
}
-void __create_diff_file(char * old_tpk_path, char * new_tpk_path)
+void __create_diff_file(char *old_tpk_path, char *new_tpk_path)
{
- char rel_path_old_tpk_file[PATH_MAX] = {0, }, rel_path_new_tpk_file[PATH_MAX] = {0, };
- GList *list_dir_old_tpk = NULL, *list_dir_new_tpk = NULL, *iterator_old_tpk = NULL, *iterator_new_tpk = NULL, *next_iterator_old_tpk = NULL, *next_iterator_new_tpk = NULL;
- int ret = -1;
-
- list_dir_old_tpk = __list_directory (old_tpk_path, old_tpk_path, list_dir_old_tpk);
- list_dir_new_tpk = __list_directory (new_tpk_path, new_tpk_path, list_dir_new_tpk);
- if(list_dir_old_tpk == NULL)
- {
- printf("Could Not read %s\n", old_tpk_path);
- return;
- }
+ char rel_path_old_tpk_file[PATH_MAX] = {0, };
+ char rel_path_new_tpk_file[PATH_MAX] = {0, };
+ GList *list_dir_old_tpk = NULL;
+ GList *list_dir_new_tpk = NULL;
+ GList *iterator_old_tpk = NULL;
+ GList *iterator_new_tpk = NULL;
+ GList *next_iterator_old_tpk = NULL;
+ GList *next_iterator_new_tpk = NULL;
+ int ret = -1;
- if(list_dir_new_tpk == NULL)
- {
- printf("Could Not read %s\n", new_tpk_path);
- return;
- }
+ list_dir_old_tpk = __list_directory(old_tpk_path, old_tpk_path, list_dir_old_tpk);
+ list_dir_new_tpk = __list_directory(new_tpk_path, new_tpk_path, list_dir_new_tpk);
+ if (list_dir_old_tpk == NULL) {
+ printf("Could Not read %s\n", old_tpk_path);
+ return;
+ }
- iterator_old_tpk = list_dir_old_tpk;
- iterator_new_tpk = list_dir_new_tpk;
+ if (list_dir_new_tpk == NULL) {
+ printf("Could Not read %s\n", new_tpk_path);
+ return;
+ }
+
+ iterator_old_tpk = list_dir_old_tpk;
+ iterator_new_tpk = list_dir_new_tpk;
- while(iterator_old_tpk != NULL)
- {
+ while (iterator_old_tpk != NULL) {
next_iterator_old_tpk = iterator_old_tpk->next;
iterator_new_tpk = list_dir_new_tpk;
- while(iterator_new_tpk != NULL)
- {
+ while (iterator_new_tpk != NULL) {
next_iterator_new_tpk = iterator_new_tpk->next;
- if(strcmp((char *)iterator_old_tpk->data, (char *)iterator_new_tpk->data) == 0)
- {
- snprintf(rel_path_old_tpk_file, PATH_MAX,"%s%s", old_tpk_path,(char *)iterator_old_tpk->data);
- snprintf(rel_path_new_tpk_file, PATH_MAX,"%s%s", new_tpk_path,(char *)iterator_new_tpk->data);
- ret = 0;
- if(rel_path_new_tpk_file[strlen(rel_path_new_tpk_file) - 1] != '/')
- {
- ret = __compare_files(rel_path_old_tpk_file, rel_path_new_tpk_file);
- if (ret == 1)
- {
- snprintf(message, MAX_MESSAGE_LEN, "Files %s and %s differ", rel_path_old_tpk_file, rel_path_new_tpk_file);
- __print_to_file(message);
- }
- }
- list_dir_new_tpk = g_list_delete_link(list_dir_new_tpk, iterator_new_tpk);
- list_dir_old_tpk = g_list_delete_link(list_dir_old_tpk, iterator_old_tpk);
- iterator_new_tpk = next_iterator_new_tpk;
- iterator_old_tpk = next_iterator_old_tpk;
- break;
- }
- iterator_new_tpk = next_iterator_new_tpk;
- }
- iterator_old_tpk = next_iterator_old_tpk;
- }
+ if (strcmp((char *)iterator_old_tpk->data,
+ (char *)iterator_new_tpk->data) == 0) {
+ snprintf(rel_path_old_tpk_file, PATH_MAX, "%s%s", old_tpk_path,
+ (char *)iterator_old_tpk->data);
+ snprintf(rel_path_new_tpk_file, PATH_MAX, "%s%s", new_tpk_path,
+ (char *)iterator_new_tpk->data);
+ ret = 0;
+ if (rel_path_new_tpk_file[strlen(rel_path_new_tpk_file) - 1]
+ != '/') {
+ ret = __compare_files(rel_path_old_tpk_file,
+ rel_path_new_tpk_file);
+ if (ret == 1) {
+ snprintf(message, MAX_MESSAGE_LEN,
+ "Files %s and %s differ",
+ rel_path_old_tpk_file,
+ rel_path_new_tpk_file);
+ __print_to_file(message);
+ }
+ }
+ list_dir_new_tpk = g_list_delete_link(list_dir_new_tpk,
+ iterator_new_tpk);
+ list_dir_old_tpk = g_list_delete_link(list_dir_old_tpk,
+ iterator_old_tpk);
+ iterator_new_tpk = next_iterator_new_tpk;
+ iterator_old_tpk = next_iterator_old_tpk;
+ break;
+ }
+ iterator_new_tpk = next_iterator_new_tpk;
+ }
+ iterator_old_tpk = next_iterator_old_tpk;
+ }
- //find if new file or new directory
+ /* find if new file or new directory */
iterator_old_tpk = list_dir_old_tpk;
- while(iterator_old_tpk != NULL)
- {
+ while (iterator_old_tpk != NULL) {
iterator_new_tpk = iterator_old_tpk->next;
- while(iterator_new_tpk != NULL)
- {
+ while (iterator_new_tpk != NULL) {
next_iterator_new_tpk = iterator_new_tpk->next;
if (strstr(iterator_new_tpk->data, iterator_old_tpk->data) != NULL)
- list_dir_new_tpk = g_list_delete_link(list_dir_new_tpk, iterator_new_tpk);
+ list_dir_new_tpk = g_list_delete_link(list_dir_new_tpk,
+ iterator_new_tpk);
iterator_new_tpk = next_iterator_new_tpk;
}
iterator_old_tpk = iterator_old_tpk->next;
}
iterator_old_tpk = list_dir_new_tpk;
- while(iterator_old_tpk != NULL)
- {
+ while (iterator_old_tpk != NULL) {
iterator_new_tpk = iterator_old_tpk->next;
- while(iterator_new_tpk != NULL)
- {
+ while (iterator_new_tpk != NULL) {
next_iterator_new_tpk = iterator_new_tpk->next;
if (strstr(iterator_new_tpk->data, iterator_old_tpk->data) != NULL)
- list_dir_new_tpk = g_list_delete_link(list_dir_new_tpk, iterator_new_tpk);
+ list_dir_new_tpk = g_list_delete_link(list_dir_new_tpk,
+ iterator_new_tpk);
iterator_new_tpk = next_iterator_new_tpk;
}
iterator_old_tpk = iterator_old_tpk->next;
}
iterator_old_tpk = list_dir_old_tpk;
- while(iterator_old_tpk != NULL)
- {
- snprintf(message, MAX_MESSAGE_LEN, "Only in %s%s", old_tpk_path, (char *)iterator_old_tpk->data);
+ while (iterator_old_tpk != NULL) {
+ snprintf(message, MAX_MESSAGE_LEN, "Only in %s%s", old_tpk_path,
+ (char *)iterator_old_tpk->data);
__print_to_file(message);
iterator_old_tpk = iterator_old_tpk->next;
}
+
iterator_new_tpk = list_dir_new_tpk;
- while(iterator_new_tpk != NULL)
- {
- snprintf(message, MAX_MESSAGE_LEN, "Only in %s%s", new_tpk_path, (char *)iterator_new_tpk->data);
+ while (iterator_new_tpk != NULL) {
+ snprintf(message, MAX_MESSAGE_LEN, "Only in %s%s", new_tpk_path,
+ (char *)iterator_new_tpk->data);
__print_to_file(message);
iterator_new_tpk = iterator_new_tpk->next;
}
- /*to free GSList*/
+ /* to free GSList */
__free_g_list(list_dir_old_tpk);
__free_g_list(list_dir_new_tpk);
}
int __xsystem(const char *argv[])
{
- int status = 0;
- pid_t pid;
- pid = fork();
- switch (pid) {
- case -1:
- perror("fork failed");
- return -1;
- case 0:
- /* child */
- if (execvp(argv[0], (char *const *)argv) < 0) {
- char buf[BUF_SIZE] = {0};
- if (strerror_r(errno, buf, sizeof(buf)) == 0) {
- fprintf(stderr, "execvp failed %d....%s\n", errno, buf); /*Don't use d_msg_app2sd */
- }
- }
- _exit(-1);
- default:
- /* parent */
- break;
- }
- if (waitpid(pid, &status, 0) == -1) {
- perror("waitpid failed");
- return -1;
- }
- if (WIFSIGNALED(status)) {
- perror("signal");
- return -1;
- }
- if (!WIFEXITED(status)) {
- /* shouldn't happen */
- perror("should not happen");
- return -1;
- }
- return WEXITSTATUS(status);
+ char buf[BUF_SIZE] = {0};
+ int status = 0;
+ pid_t pid;
+
+ pid = fork();
+
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ if (execvp(argv[0], (char *const *)argv) < 0) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ fprintf(stderr, "execvp failed %d....%s\n", errno, buf);
+ }
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+
+ return WEXITSTATUS(status);
}
+
#ifndef DELTA_H_
#define DELTA_H_
-#define DIFF_FILE "/opt/usr/temp_delta/difffile.txt"
-#define TEMP_DELTA_REPO "/opt/usr/temp_delta/"
-#define UNZIPFILE "_FILES"
-#define MAX_MESSAGE_LEN 1024
-#define BUF_SIZE 1024
+#define DIFF_FILE "/opt/usr/temp_delta/difffile.txt"
+#define TEMP_DELTA_REPO "/opt/usr/temp_delta/"
+#define UNZIPFILE "_FILES"
+#define MAX_MESSAGE_LEN 1024
+#define BUF_SIZE 1024
char message[MAX_MESSAGE_LEN];
-void __create_diff_file(char * old_tpk_path, char * new_tpk_path);
+void __create_diff_file(char *old_tpk_path, char *new_tpk_path);
int __xsystem(const char *argv[]);
#endif /* DELTA_H_ */
return -1;
}
execl(BACKEND_CMD, BACKEND_CMD, "-i", buf, "--preload",
- (char*)NULL);
+ (char *)NULL);
} else if (pid < 0) {
_E("failed to fork and execute %s!", BACKEND_CMD);
closedir(dir);
int ret = 0;
char dirname[PATH_MAX] = {0,};
- if(pkgid == NULL) {
+ if (pkgid == NULL) {
LOGE("pkgid is NULL\n");
return -1;
}
- // cache internal
+ /* cache internal */
snprintf(dirname, sizeof(dirname), "%s/%s%s",
INTERNAL_CACHE_PATH_PREFIX, pkgid, CACHE_PATH_POSTFIX);
if (ret < 0)
LOGE("Failed to clear internal cache dir.");
- // shared/cache internal
+ /* shared/cache internal */
snprintf(dirname, sizeof(dirname), "%s/%s%s",
INTERNAL_CACHE_PATH_PREFIX, pkgid, SHARED_PATH_POSTFIX);
}
res = __clear_cache_dir(pkgid);
- if (res != 0) { // error flag
+ if (res != 0) {
LOGE("Failed to clear cache dir of %s", pkgid);
--(*err_cnt);
return 0;
if (errstr == NULL)
return;
switch (errnumber) {
- case PKGCMD_ERRCODE_UNZIP_ERROR:
+ case PKGCMD_ERRCODE_UNZIP_ERROR:
*errstr = PKGCMD_ERRCODE_UNZIP_ERROR_STR;
break;
case PKGCMD_ERRCODE_SECURITY_ERROR:
data.result = ret_val;
ret_result = strstr((char *)val, delims);
- if (ret_result){
+ if (ret_result)
printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d] error message: %s\n",
req_id, pkg_type, pkgid, key, ret_val, ret_result);
- }
else
printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d]\n",
req_id, pkg_type, pkgid, key, ret_val);
req_id, pkg_type, pkgid, key, val);
if (strncmp(key, "end", strlen("end")) == 0) {
- if ((strncmp(val, "fail", strlen("fail")) == 0) && data.result == 0){
+ if ((strncmp(val, "fail", strlen("fail")) == 0) && data.result == 0)
data.result = PKGCMD_ERRCODE_ERROR;
- }
g_main_loop_quit(main_loop);
}
else
ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
- if(ret < 0) {
+ if (ret < 0) {
printf("package is not in pkgmgr_info DB\n");
return -1;
- } else
+ } else {
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ }
return 0;
}
}
-static int __pkgmgr_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+static int __pkgmgr_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
{
int ret = -1;
char *pkgid = NULL;
return ret;
}
- printf("%s\tpkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\n", for_all_users ? "system apps" : "user apps ", pkg_type, pkgid, pkg_label, pkg_version);
+ printf("%s\tpkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\n",
+ for_all_users ? "system apps" : "user apps ", pkg_type, pkgid, pkg_label, pkg_version);
return ret;
}
pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle;
ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
- if(ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
- }
- if (uid_info->uid != GLOBAL_USER)
- ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, uid_info->uid, NULL, NULL, NULL);
- else
- ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
- if (ret < 0){
+
+ if (uid_info->uid != GLOBAL_USER)
+ ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE,
+ (pkgmgr_client *)user_data, NULL, pkgid, uid_info->uid, NULL, NULL, NULL);
+ else
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE,
+ (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
+ if (ret < 0) {
printf("pkgmgr_client_request_service Failed\n");
return -1;
}
char pkg_new[PATH_MAX] = {0, };
bool blacklist;
-#if !GLIB_CHECK_VERSION(2,35,0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
switch (data.request) {
if (data.tep_path[0] != '\0')
pkgmgr_client_set_tep_path(pc, data.tep_path, data.tep_move);
- if (data.des_path[0] == '\0') {
- ret =
- pkgmgr_client_usr_install(pc, data.pkg_type, NULL,
- data.pkg_path, NULL, PM_QUIET,
- __return_cb, pc, uid);
- } else {
- ret =
- pkgmgr_client_usr_install(pc, data.pkg_type,
- data.des_path, data.pkg_path,
- NULL, PM_QUIET, __return_cb, pc, uid);
+ if (data.des_path[0] == '\0')
+ ret = pkgmgr_client_usr_install(pc, data.pkg_type, NULL,
+ data.pkg_path, NULL, PM_QUIET,
+ __return_cb, pc, uid);
+ else
+ ret = pkgmgr_client_usr_install(pc, data.pkg_type,
+ data.des_path, data.pkg_path,
+ NULL, PM_QUIET, __return_cb, pc, uid);
- }
- if (ret < 0){
+ if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
if (access(data.pkg_path, F_OK) != 0)
data.result = PKGCMD_ERRCODE_PACKAGE_NOT_FOUND;
break;
case CREATE_DELTA:
printf("CREATE_DELTA\n");
- if (data.pkg_old[0] == '\0' || data.pkg_new[0] == '\0' ) {
+ if (data.pkg_old[0] == '\0' || data.pkg_new[0] == '\0') {
printf("tpk pkg missing\n");
break;
}
- if(data.delta_pkg[0] == '\0') {
+ if (data.delta_pkg[0] == '\0') {
snprintf(data.resolved_path_delta_pkg, PATH_MAX, "/tmp/delta_pkg");
printf("output file will be /tmp/delta_pkg.delta\n");
}
- const char *unzip_argv[] = {"sh", "/etc/package-manager/pkgmgr-unzip-tpk.sh", "-a", data.resolved_path_pkg_old, "-b", data.resolved_path_pkg_new, "-p", data.resolved_path_delta_pkg, NULL};
+ const char *unzip_argv[] = {"sh", "/etc/package-manager/pkgmgr-unzip-tpk.sh", "-a",
+ data.resolved_path_pkg_old, "-b", data.resolved_path_pkg_new, "-p",
+ data.resolved_path_delta_pkg, NULL};
ret = __xsystem(unzip_argv);
if (ret != 0) {
printf("unzip is fail .\n");
}
ptr_new_tpk++;
- snprintf(pkg_old, PATH_MAX,"%s%s%s", TEMP_DELTA_REPO, ptr_old_tpk, UNZIPFILE);
- snprintf(pkg_new, PATH_MAX,"%s%s%s", TEMP_DELTA_REPO, ptr_new_tpk, UNZIPFILE);
+ snprintf(pkg_old, PATH_MAX, "%s%s%s", TEMP_DELTA_REPO, ptr_old_tpk, UNZIPFILE);
+ snprintf(pkg_new, PATH_MAX, "%s%s%s", TEMP_DELTA_REPO, ptr_new_tpk, UNZIPFILE);
__create_diff_file(pkg_old, pkg_new);
- const char *delta_argv[] = {"sh", "/etc/package-manager/pkgmgr-create-delta.sh", "-a", data.resolved_path_pkg_old, "-b", data.resolved_path_pkg_new, "-p", data.resolved_path_delta_pkg, NULL};
+ const char *delta_argv[] = {"sh", "/etc/package-manager/pkgmgr-create-delta.sh", "-a",
+ data.resolved_path_pkg_old, "-b", data.resolved_path_pkg_new, "-p",
+ data.resolved_path_delta_pkg, NULL};
ret = __xsystem(delta_argv);
if (ret != 0) {
printf("create delta script fail .\n");
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
-//if global
+
ret = __is_app_installed(data.pkgid, uid);
if (ret == -1) {
printf("package is not installed\n");
break;
}
- ret =
- pkgmgr_client_usr_uninstall(pc, data.pkg_type, data.pkgid,
- PM_QUIET, __return_cb, NULL,uid);
- if (ret < 0){
+ ret = pkgmgr_client_usr_uninstall(pc, data.pkg_type, data.pkgid,
+ PM_QUIET, __return_cb, NULL, uid);
+ if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
if (access(data.pkg_path, F_OK) != 0)
data.result = PKGCMD_ERRCODE_PACKAGE_NOT_FOUND;
}
ret = pkgmgr_client_usr_reinstall(pc, data.pkg_type, data.pkgid, NULL, PM_QUIET, __return_cb, pc, uid);
- if (ret < 0){
+ if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
if (access(data.pkg_path, F_OK) != 0)
data.result = PKGCMD_ERRCODE_PACKAGE_NOT_FOUND;
break;
}
ret = pkgmgr_client_usr_clear_user_data(pc, data.pkg_type,
- data.pkgid, PM_QUIET, uid);
+ data.pkgid, PM_QUIET, uid);
if (ret < 0)
break;
ret = data.result;
break;
}
- if (strcmp(data.pkg_type, "app") == 0 ) {
+ if (strcmp(data.pkg_type, "app") == 0) {
if (data.global)
/* enable global app for this user only */
ret = pkgmgr_client_activate_global_app_for_uid(pc, data.pkgid, __app_return_cb, getuid());
break;
}
- if (strcmp(data.pkg_type, "app") == 0 ) {
+ if (strcmp(data.pkg_type, "app") == 0) {
if (data.global)
/* disable global app for this user only*/
ret = pkgmgr_client_deactivate_global_app_for_uid(pc, data.pkgid, __app_return_cb, getuid());
if (data.request == KILLAPP_REQ) {
ret = pkgmgr_client_usr_request_service(PM_REQUEST_KILL_APP, 0, pc, NULL, data.pkgid, uid, NULL, NULL, &pid);
- if (ret < 0){
+ if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
} else if (data.request == CHECKAPP_REQ) {
ret = pkgmgr_client_usr_request_service(PM_REQUEST_CHECK_APP, 0, pc, NULL, data.pkgid, uid, NULL, NULL, &pid);
- if (ret < 0){
+ if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
case LIST_REQ:
if (data.pkg_type[0] == '\0') {
ret = 0;
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER)
ret = pkgmgrinfo_pkginfo_get_usr_list(__pkgmgr_list_cb, NULL, uid);
- } else {
+ else
ret = pkgmgrinfo_pkginfo_get_list(__pkgmgr_list_cb, NULL);
- }
- if (ret == -1)
- printf("no packages found\n");
- break;
+
+ if (ret == -1)
+ printf("no packages found\n");
+ break;
} else {
pkgmgrinfo_pkginfo_filter_h handle;
+
ret = pkgmgrinfo_pkginfo_filter_create(&handle);
if (ret == -1) {
printf("Failed to get package filter handle\n");
break;
}
+
ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, data.pkg_type);
if (ret == -1) {
printf("Failed to add package type filter\n");
pkgmgrinfo_pkginfo_filter_destroy(handle);
break;
}
- if (uid != GLOBAL_USER) {
+
+ if (uid != GLOBAL_USER)
ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL, uid);
- } else {
+ else
ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL);
- }
- if (ret != PMINFO_R_OK)
- printf("no package filter list\n");
- pkgmgrinfo_pkginfo_filter_destroy(handle);
+
+ if (ret != PMINFO_R_OK)
+ printf("no package filter list\n");
+
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
break;
}
break;
case CSC_REQ:
- ret = pkgmgr_client_usr_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, uid, data.des_path, NULL, (void *)data.pkg_path);
+ ret = pkgmgr_client_usr_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, uid,
+ data.des_path, NULL, (void *)data.pkg_path);
if (ret < 0)
data.result = PKGCMD_ERRCODE_ERROR;
break;
ret = pkgmgrinfo_pkginfo_get_usr_list(__pkg_list_cb, (void *)pc, uid);
break;
}
- ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, uid, NULL, NULL, NULL);
- if (ret < 0){
+ ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, data.type,
+ pc, NULL, data.pkgid, uid, NULL, NULL, NULL);
+ if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
ret = -1;
break;
}
+
pc = pkgmgr_client_new(PC_REQUEST);
if (pc == NULL) {
printf("PkgMgr Client Creation Failed\n");
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
+
ret = pkgmgr_client_usr_add_blacklist(pc, data.pkgid, uid);
if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
ret = -1;
break;
}
+
pc = pkgmgr_client_new(PC_REQUEST);
if (pc == NULL) {
printf("PkgMgr Client Creation Failed\n");
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
+
ret = pkgmgr_client_usr_remove_blacklist(pc, data.pkgid, uid);
if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
ret = -1;
break;
}
+
pc = pkgmgr_client_new(PC_REQUEST);
if (pc == NULL) {
printf("PkgMgr Client Creation Failed\n");
data.result = PKGCMD_ERRCODE_ERROR;
break;
}
+
ret = pkgmgr_client_usr_check_blacklist(pc, data.pkgid, &blacklist, uid);
if (ret < 0) {
data.result = PKGCMD_ERRCODE_ERROR;
printf("%s is blacklisted\n", data.pkgid);
else
printf("%s is not blacklisted\n", data.pkgid);
+
ret = data.result;
break;
struct timeval tv;
bool is_root_cmd = false;
-
if (argc == 1)
__print_usage();
memset(data.tep_path, '\0', PATH_MAX);
memset(data.tep_move, '\0', PKG_NAME_STRING_LEN_MAX);
- data.global = 0; //By default pkg_cmd will manage for the current user
+ data.global = 0; /* By default pkg_cmd will manage for the current user */
data.result = 0;
data.type = -1;
while (1) {
case 'X': /* old_tpk */
data.request = CREATE_DELTA;
is_root_cmd = true;
- if (optarg) {
+ if (optarg)
strncpy(data.pkg_old, optarg, PATH_MAX - 1);
- }
+
if (realpath(data.pkg_old, data.resolved_path_pkg_old) == NULL) {
printf("failed to set realpath\n");
return -1;
break;
case 'Y': /* new_tpk */
- if (optarg) {
+ if (optarg)
strncpy(data.pkg_new, optarg, PATH_MAX - 1);
- }
+
if (realpath(data.pkg_new, data.resolved_path_pkg_new) == NULL) {
printf("failed to set realpath\n");
return -1;
break;
case 'Z': /* delta_tpk */
- if (optarg) {
+ if (optarg)
strncpy(data.delta_pkg, optarg, PATH_MAX - 1);
- }
+
printf("delta_pkg is %s\n", data.delta_pkg);
if (realpath(data.delta_pkg, data.resolved_path_delta_pkg) == NULL) {
printf("failed to set realpath\n");
return -1;
}
- printf("delta_pkg abs path is %s\n",data.resolved_path_delta_pkg);
+ printf("delta_pkg abs path is %s\n", data.resolved_path_delta_pkg);
break;
case 'd': /* descriptor path */
if (optarg)
case 'M': /*tep move*/
if (optarg)
- strncpy(data.tep_move, (atoi(optarg) == 1)?"tep_move":"tep_copy", PKG_NAME_STRING_LEN_MAX - 1);
+ strncpy(data.tep_move, (atoi(optarg) == 1) ? "tep_move" : "tep_copy",
+ PKG_NAME_STRING_LEN_MAX - 1);
break;
case 't': /* package type */
}
}
+
uid_t uid = getuid();
- if(!is_root_cmd && uid == OWNER_ROOT) {
+ if (!is_root_cmd && uid == OWNER_ROOT) {
printf("Current User is Root! : Only regular users are allowed\n");
return -1;
}
- if(data.global == 1) {
+
+ if (data.global == 1)
uid = GLOBAL_USER;
- }
+
ret = __process_request(uid);
if ((ret < 0) && (data.result == 0)) {
- printf("Undefined error(%d)", ret);
+ printf("Undefined error(%d)", ret);
data.result = PKGCMD_ERRCODE_UNDEFINED_ERROR;
- }
+ }
if (ret != 0) {
__error_no_to_string(data.result, &errstr);
#undef LOG_TAG
#ifndef LOG_TAG
#define LOG_TAG "PKGMGR_GETSIZE"
-#endif /* LOG_TAG */
+#endif /* LOG_TAG */
#define MAX_PKG_BUF_LEN 1024
-#define BLOCK_SIZE 4096 /*in bytes*/
-#define MAX_PATH_LENGTH 512
-#define MAX_LONGLONG_LENGTH 32
-#define MAX_SIZE_INFO_SIZE 128
+#define BLOCK_SIZE 4096 /*in bytes*/
+#define MAX_PATH_LENGTH 512
+#define MAX_LONGLONG_LENGTH 32
+#define MAX_SIZE_INFO_SIZE 128
#define OWNER_ROOT 0
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
#define APP_BASE_EXTERNAL_PATH ""
#endif
-typedef enum
-{
+typedef enum {
STORAGE_TYPE_INTERNAL,
STORAGE_TYPE_EXTERNAL,
STORAGE_TYPE_MAX = 255,
long long blksize = s->st_blksize;
long long size = (long long)s->st_blocks * 512;
- if (blksize) {
+ if (blksize)
size = (size + blksize - 1) & (~(blksize - 1));
- }
return size;
}
int ret;
DIR *dir;
struct dirent *dent;
- const char *entry;
+ const char *file_info;
if (include_itself) {
ret = fstat(dfd, &st);
if (ret < 0) {
- ERR("fstat() failed, entry: ., errno: %d (%s)", errno,
+ ERR("fstat() failed, file_info: ., errno: %d (%s)", errno,
strerror(errno));
return -1;
}
}
while ((dent = readdir(dir))) {
- entry = dent->d_name;
- if (entry[0] == '.') {
- if (entry[1] == '\0')
+ file_info = dent->d_name;
+ if (file_info[0] == '.') {
+ if (file_info[1] == '\0')
continue;
- if ((entry[1] == '.') && (entry[2] == '\0'))
+ if ((file_info[1] == '.') && (file_info[2] == '\0'))
continue;
}
if (dent->d_type == DT_DIR) {
- subfd = openat(dfd, entry, O_RDONLY | O_DIRECTORY);
+ subfd = openat(dfd, file_info, O_RDONLY | O_DIRECTORY);
if (subfd < 0) {
- ERR("openat() failed, entry:%s, errno: %d(%s)",
- entry, errno, strerror(errno));
+ ERR("openat() failed, file_info:%s, errno: %d(%s)",
+ file_info, errno, strerror(errno));
goto error;
}
- DBG("traverse entry: %s", entry);
+ DBG("traverse file_info: %s", file_info);
size += __calculate_directory_size(subfd, true);
close(subfd);
} else {
- ret = fstatat(dfd, entry, &st, AT_SYMLINK_NOFOLLOW);
+ ret = fstatat(dfd, file_info, &st, AT_SYMLINK_NOFOLLOW);
if (ret < 0) {
- ERR("fstatat() failed, entry:%s, errno: %d(%s)",
- entry, errno, strerror(errno));
+ ERR("fstatat() failed, file_info:%s, errno: %d(%s)",
+ file_info, errno, strerror(errno));
goto error;
}
size += __stat_size(&st);
app_root_dir, errno, strerror(errno));
goto error;
}
- *app_size += __stat_size(&st); // shared directory
+ *app_size += __stat_size(&st); /* shared directory */
DBG("app_size: %lld", *app_size);
DBG("traverse path: %s/shared/data", app_root_dir);
subfd = openat(fd, "data", O_RDONLY | O_DIRECTORY);
if (subfd >= 0) {
size = __calculate_directory_size(subfd, true);
- if (size < 0)
- {
+ if (size < 0) {
ERR("Calculating shared/data directory failed.");
goto error;
}
DBG("data_size: %lld", *data_size);
close(subfd);
} else if (subfd < 0 && errno != ENOENT) {
- ERR("openat() failed, entry: data, errno: %d (%s)",
+ ERR("openat() failed, file_info: data, errno: %d (%s)",
errno, strerror(errno));
goto error;
}
DBG("data_size: %lld", *data_size);
close(subfd);
} else if (subfd < 0 && errno != ENOENT) {
- DBG("openat() failed, entry: trusted, errno: %d (%s)",
+ DBG("openat() failed, file_info: trusted, errno: %d (%s)",
errno, strerror(errno));
goto error;
}
DBG("app_size: %lld", *app_size);
close(subfd);
} else if (subfd < 0 && errno != ENOENT) {
- ERR("openat() failed, entry: res, errno: %d (%s)",
+ ERR("openat() failed, file_info: res, errno: %d (%s)",
errno, strerror(errno));
goto error;
}
DBG("data_size: %lld", *data_size);
close(subfd);
} else if (subfd < 0 && errno != ENOENT) {
- ERR("openat() failed, entry: data, errno: %d (%s)",
+ ERR("openat() failed, file_info: data, errno: %d (%s)",
errno, strerror(errno));
goto error;
}
snprintf(size_info_str, MAX_SIZE_INFO_SIZE, "%lld",
pkg_size_info->data_size);
- strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str)- 1);
+ strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str) - 1);
snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH,
"%lld", pkg_size_info->cache_size);
- strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str)- 1);
+ strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str) - 1);
snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH,
"%lld", pkg_size_info->app_size);
- strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str)- 1);
+ strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str) - 1);
snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH,
"%lld", pkg_size_info->ext_data_size);
- strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str)- 1);
+ strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str) - 1);
snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH,
"%lld", pkg_size_info->ext_cache_size);
- strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str)- 1);
+ strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str) - 1);
snprintf(size_info_str + strlen(size_info_str), MAX_LONGLONG_LENGTH,
"%lld", pkg_size_info->ext_app_size);
- strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str)- 1);
+ strncat(size_info_str, ":", MAX_SIZE_INFO_SIZE - strlen(size_info_str) - 1);
DBG("size_info_str: %s", size_info_str);
pkgmgr_installer *pi;
pkg_size_info_t info = {0, };
- // argv has bellowed meaning
- // argv[1] = pkgid
- // argv[2] = get type
- // argv[4] = req_key
+ /* argv has bellowed meaning */
+ /* argv[1] = pkgid */
+ /* argv[2] = get type */
+ /* argv[4] = req_key */
if (argv[1] == NULL) {
ERR("pkgid is NULL");
static int __del_certinfo_from_db(char *pkgid);
static int __get_integer_input_data(void);
char *__get_string_input_data(void);
-static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data);
+static int __pkg_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data);
static int __app_category_list_cb(const char *category_name, void *user_data);
static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data);
static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
int installed_time = -1;
ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get pkg type\n");
- }
if (type)
printf("Type: %s\n", type);
ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get version\n");
- }
if (version)
printf("Version: %s\n", version);
ret = pkgmgrinfo_pkginfo_get_install_location(handle, &location);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get install location\n");
- }
printf("Install Location: %d\n", location);
ret = pkgmgrinfo_pkginfo_get_icon(handle, &icon);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get icon\n");
- }
if (icon)
printf("Icon: %s\n", icon);
ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get label\n");
- }
if (label)
printf("Label: %s\n", label);
ret = pkgmgrinfo_pkginfo_get_description(handle, &desc);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get description\n");
- }
if (desc)
printf("Description: %s\n", desc);
ret = pkgmgrinfo_pkginfo_get_author_name(handle, &author_name);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get author name\n");
- }
if (author_name)
printf("Author Name: %s\n", author_name);
ret = pkgmgrinfo_pkginfo_get_author_email(handle, &author_email);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get author email\n");
- }
if (author_email)
printf("Author Email: %s\n", author_email);
ret = pkgmgrinfo_pkginfo_get_author_href(handle, &author_href);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get author href\n");
- }
if (author_href)
printf("Author Href: %s\n", author_href);
ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get root_path\n");
- }
- if (author_href)
+ if (root_path)
printf("root_path : %s\n", root_path);
ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get mainappid\n");
- }
- if (author_href)
+ if (mainappid)
printf("mainappid : %s\n", mainappid);
ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get install time\n");
- }
printf("Install time: %d\n", installed_time);
ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get removable\n");
- }
else
printf("Removable: %d\n", removable);
ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get preload\n");
- }
else
printf("Preload: %d\n", preload);
ret = pkgmgrinfo_pkginfo_is_readonly(handle, &readonly);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get readonly\n");
- }
else
printf("Readonly: %d\n", readonly);
ret = pkgmgrinfo_pkginfo_is_update(handle, &update);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get update\n");
- }
else
printf("update: %d\n", update);
ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get system\n");
- }
else
printf("system: %d\n", system);
}
int ret = -1;
ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get appid\n");
- }
ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get package\n");
- }
printf("apptype [%s]\t appid [%s]\n", apptype, appid);
return 0;
printf("Malloc Failed\n");
return NULL;
}
- if (fgets(data,1024,stdin) == NULL){
+
+ if (fgets(data, 1024, stdin) == NULL) {
printf("Buffer overflow!!! try again\n");
exit(-1);
}
data[strlen(data) - 1] = '\0';
+
return data;
}
static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
{
char *appid = NULL;
+
pkgmgrinfo_appinfo_get_appid(handle, &appid);
printf("appid : %s\n", appid);
+
return 0;
}
char *value = NULL;
ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
- if (ret != PMINFO_R_OK){
+ if (ret != PMINFO_R_OK) {
printf("pkgmgrinfo_appinfo_metadata_filter_create() failed\n");
return ret;
}
printf("filter condition : key=[%s], value=[%s]\n", key, value);
ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, key, value);
- if (ret != PMINFO_R_OK){
+ if (ret != PMINFO_R_OK) {
printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
goto err;
}
ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
- if (ret != PMINFO_R_OK){
+ if (ret != PMINFO_R_OK) {
printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
goto err;
}
int val = -1;
int count = 0;
pkgmgrinfo_appinfo_filter_h handle;
+
ret = pkgmgrinfo_appinfo_filter_create(&handle);
if (ret > 0) {
printf("appinfo filter handle create failed\n");
return -1;
}
- while (choice != 0 && choice != 1)
- {
+
+ while (choice != 0 && choice != 1) {
printf("Enter Choice\n");
printf("0 --> Finalize filter and get count of apps\n");
printf("1 --> Finalize filter and get list of apps\n");
printf("pkginfo filter handle create failed\n");
return -1;
}
- while (choice != 0 && choice !=1)
- {
+
+ while (choice != 0 && choice != 1) {
printf("Enter Choice\n");
printf("0 --> Finalize filter and get count of packages\n");
printf("1 --> Finalize filter and get list of packages\n");
int i = 0;
const char *value = NULL;
pkgmgrinfo_certinfo_h handle = NULL;
+
ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
if (ret < 0) {
printf("pkgmgrinfo_pkginfo_create_certinfo failed\n");
return -1;
}
+
ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle, uid);
if (ret < 0) {
printf("pkgmgrinfo_pkginfo_load_certinfo failed\n");
return -1;
}
- while (choice != 10)
- {
+
+ while (choice != 10) {
printf("Enter the choice to get\n");
printf("0 --> to get all cert values\n");
printf("1 --> author root certificate\n");
choice = __get_integer_input_data();
switch (choice) {
case 0:
- for (i = 0; i < 9; i++)
- {
+ for (i = 0; i < 9; i++) {
pkgmgrinfo_pkginfo_get_cert_value(handle, i, &value);
if (value)
printf("cert type[%d] value = %s\n", i, value);
ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_pkgid, rhs_pkgid, uid, &result);
else
ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
- if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_OK)
return -1;
- }
printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
printf("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
ret = pkgmgrinfo_pkginfo_compare_usr_app_cert_info(lhs_appid, rhs_appid, uid, &result);
else
ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &result);
- if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_OK)
return -1;
- }
printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
printf("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
int choice = -1;
char *value = NULL;
pkgmgr_instcertinfo_h handle = NULL;
+
ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
if (ret < 0) {
printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
return -1;
}
- while (choice != 0)
- {
+
+ while (choice != 0) {
printf("Enter the choice you want to set\n");
printf("0 --> to set data in DB\n");
printf("1 --> author root certificate\n");
int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
{
+ int ret = -1;
char *appid;
char *data = NULL;
- if (user_data) {
- data = (char *)user_data;
- }
- int ret = -1;
char *exec = NULL;
char *icon = NULL;
char *label = NULL;
- pkgmgrinfo_app_component component = 0;
char *apptype = NULL;
+ char *package = NULL;
bool nodisplay = 0;
bool multiple = 0;
bool taskmanage = 0;
- pkgmgrinfo_app_hwacceleration hwacceleration;
- pkgmgrinfo_app_screenreader screenreader;
bool onboot = 0;
bool autorestart = 0;
- char *package = NULL;
+ pkgmgrinfo_app_component component = 0;
+ pkgmgrinfo_app_hwacceleration hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+
+ if (user_data)
+ data = (char *)user_data;
ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get appid\n");
- }
if (appid)
printf("Appid: %s\n", appid);
ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get package\n");
- }
if (package)
printf("Package: %s\n", package);
ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get exec\n");
- }
if (exec)
printf("Exec: %s\n", exec);
ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get icon\n");
- }
if (icon)
printf("Icon: %s\n", icon);
ret = pkgmgrinfo_appinfo_get_label(handle, &label);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get label\n");
- }
if (label)
printf("Label: %s\n", label);
ret = pkgmgrinfo_appinfo_get_component(handle, &component);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get component\n");
- }
ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get apptype\n");
- }
if (apptype)
printf("Apptype: %s\n", apptype);
printf("component: %s\n", component == PMINFO_UI_APP ? "uiapp" :
"widgetapp");
ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get multiple\n");
- } else {
+ else
printf("Multiple: %d\n", multiple);
- }
ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get nodisplay\n");
- } else {
+ else
printf("Nodisplay: %d \n", nodisplay);
- }
ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get taskmanage\n");
- } else {
+ else
printf("Taskmanage: %d\n", taskmanage);
- }
ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get hwacceleration\n");
- } else {
+ else
printf("hw-acceleration: %d\n", hwacceleration);
- }
ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get screenreader\n");
- } else {
+ else
printf("screenreader: %d\n", screenreader);
- }
-
}
+
if (component == PMINFO_SVC_APP) {
printf("component: svcapp\n");
ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get onboot\n");
- } else {
+ else
printf("Onboot: %d\n", onboot);
- }
ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get autorestart\n");
- } else {
+ else
printf("Autorestart: %d \n", autorestart);
- }
}
+
if (data)
printf("user_data : %s\n\n", data);
}
-static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+static int __pkg_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
{
- char *test_data = "test data";
int ret = -1;
+ int installed_time = -1;
+ char *test_data = "test data";
char *pkgid;
char *pkg_type;
char *pkg_version;
bool preload = 0;
- int installed_time = -1;
pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle;
ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
- if(ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
- }
+
ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
- if(ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_pkginfo_get_type() failed\n");
- }
+
ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
- if(ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_pkginfo_get_version() failed\n");
- }
+
ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
- if(ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_pkginfo_is_preload() failed\n");
- }
+
ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
- if(ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_pkginfo_get_installed_time() failed\n");
- }
-
printf("---------------------------------------\n");
printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
if (uid_info->uid != GLOBAL_USER) {
printf("**List of Ui-Apps**\n");
ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid_info->uid);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgr_get_info_app() failed\n");
- }
+
printf("**List of Svc-Apps**\n");
ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid_info->uid);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgr_get_info_app() failed\n");
- }
} else {
printf("**List of Ui-Apps**\n");
ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgr_get_info_app() failed\n");
- }
+
printf("**List of Svc-Apps**\n");
ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgr_get_info_app() failed\n");
- }
}
printf("---------------------------------------\n");
static int __get_pkg_list(uid_t uid)
{
int ret = -1;
+
if (uid != GLOBAL_USER)
ret = pkgmgrinfo_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
else
printf("pkgmgrinfo_pkginfo_get_list() failed\n");
return -1;
}
+
return 0;
}
static int __get_installed_app_list(uid_t uid)
{
int ret = -1;
- if(uid != GLOBAL_USER)
+
+ if (uid != GLOBAL_USER)
ret = pkgmgrinfo_appinfo_get_usr_installed_list(app_func, uid, NULL);
else
ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
return -1;
}
+
return 0;
}
{
int ret = -1;
pkgmgrinfo_appinfo_h handle;
+
ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
if (ret < 0) {
printf("Failed to get handle\n");
return -1;
}
+
ret = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
if (ret < 0) {
printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
pkgmgrinfo_appinfo_destroy_appinfo(handle);
return -1;
}
+
pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
return 0;
}
{
int ret = -1;
pkgmgrinfo_appinfo_h handle;
+
ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
if (ret < 0) {
printf("Failed to get handle\n");
return -1;
}
+
ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
if (ret < 0) {
printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
pkgmgrinfo_appinfo_destroy_appinfo(handle);
return -1;
}
+
pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
return 0;
}
{
int ret = -1;
pkgmgrinfo_appinfo_h handle;
+
ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
if (ret < 0) {
printf("Failed to get handle\n");
return -1;
}
+
ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
if (ret < 0) {
printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
pkgmgrinfo_appinfo_destroy_appinfo(handle);
return -1;
}
+
pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
return 0;
}
static int __set_app_enabled(char *appid, bool enabled)
{
int ret = -1;
+
ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
if (ret < 0) {
printf("Failed to get handle\n");
return -1;
}
+
return 0;
}
static int __get_app_list(char *pkgid, uid_t uid)
{
- pkgmgrinfo_pkginfo_h handle;
int ret = -1;
char *test_data = "test data";
- if(uid != GLOBAL_USER)
+ pkgmgrinfo_pkginfo_h handle;
+
+ if (uid != GLOBAL_USER)
ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
else
ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
printf("Failed to get handle\n");
return -1;
}
+
if (uid != GLOBAL_USER) {
printf("List of Ui-Apps\n\n");
ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_appinfo_get_list() failed\n");
- }
+
printf("List of Svc-Apps\n\n");
ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_appinfo_get_list() failed\n");
- }
} else {
printf("List of Ui-Apps\n\n");
ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_appinfo_get_list() failed\n");
- }
+
printf("List of Svc-Apps\n\n");
ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
- if (ret < 0) {
+ if (ret < 0)
printf("pkgmgrinfo_appinfo_get_list() failed\n");
- }
}
+
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
return 0;
}
static int __get_pkg_info(char *pkgid, uid_t uid)
{
- pkgmgrinfo_pkginfo_h handle;
int ret = -1;
+ pkgmgrinfo_pkginfo_h handle;
printf("Get Pkg Info Called [%s]\n", pkgid);
- if(uid != GLOBAL_USER)
+ if (uid != GLOBAL_USER)
ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
else
ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
__get_pkgmgrinfo_pkginfo(handle, NULL);
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
return 0;
}
static int __get_app_info(char *appid)
{
- printf("Get App Info Called [%s]\n", appid);
+ int ret = -1;
char *exec = NULL;
char *app_id = NULL;
char *apptype = NULL;
char *icon = NULL;
char *label = NULL;
char *package = NULL;
- pkgmgrinfo_app_component component = 0;
bool nodisplay = 0;
bool multiple = 0;
bool taskmanage = 0;
- pkgmgrinfo_app_hwacceleration hwacceleration;
- pkgmgrinfo_app_screenreader screenreader;
bool onboot = 0;
bool autorestart = 0;
bool enabled = 0;
bool preload = 0;
pkgmgrinfo_appinfo_h handle;
- int ret = -1;
+ pkgmgrinfo_app_component component = 0;
+ pkgmgrinfo_app_hwacceleration hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+
+ printf("Get App Info Called [%s]\n", appid);
ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
if (ret < 0) {
}
ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get package\n");
- }
ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get exec\n");
- }
ret = pkgmgrinfo_appinfo_get_label(handle, &label);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get label\n");
- }
+
ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get icon\n");
- }
ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get exec\n");
- }
+
ret = pkgmgrinfo_appinfo_get_component(handle, &component);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get component\n");
- }
+
ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get apptype\n");
- }
+
ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get nodisplay\n");
- }
+
ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get multiple\n");
- }
+
ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get taskmanage\n");
- }
+
ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get hwacceleration\n");
- }
+
ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get screenreader\n");
- }
+
ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get onboot\n");
- }
+
ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get autorestart\n");
- }
+
ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get enabled\n");
- }
+
ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
- if (ret < 0) {
+ if (ret < 0)
printf("Failed to get preload\n");
- }
if (app_id)
printf("Appid: %s\n", app_id);
if (exec)
printf("Exec: %s\n", exec);
+
if (apptype)
printf("Apptype: %s\n", apptype);
printf("Preload: %d\n", preload);
pkgmgrinfo_appinfo_destroy_appinfo(handle);
- return 0;
+ return 0;
}
static int __check_manifest_validation(char *manifest)
{
int ret = 0;
+
if (manifest == NULL) {
printf("Manifest file is NULL\n");
return -1;
}
+
ret = pkgmgr_parser_check_manifest_validation(manifest);
if (ret < 0) {
printf("check manifest validation failed\n");
return -1;
}
+
return 0;
}
ret = -1;
goto end;
}
- }else if (argc == 4) {
+ } else if (argc == 4) {
if (strcmp(argv[1], "--setappenabled") == 0) {
- ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
+ ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0") == 0) ? false : true);
if (ret == -1) {
printf("set app enabled failed\n");
goto end;
}
goto end;
- } else if(strcmp(argv[1], "--setpkgenabled") == 0) {
- ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
+ } else if (strcmp(argv[1], "--setpkgenabled") == 0) {
+ ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0") == 0) ? false : true);
if (ret == -1) {
printf("set pkg enabled failed\n");
goto end;
__print_usage();
end:
-
gettimeofday(&tv, NULL);
endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E][%s,%d] "fmt"\n", \
+ __FUNCTION__, __LINE__, ##arg);
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", \
+ __FUNCTION__, __LINE__, ##arg);
#define PKGINSTALLMANIFEST_CMD "/usr/bin/pkg-install-manifest"
static int _initdb_load_directory(uid_t uid, const char *directory)
{
DIR *dir;
- struct dirent entry, *result;
+ struct dirent file_info, *result;
int ret;
char buf[BUFSZE];
_D("Loading manifest files from %s", directory);
- for (ret = readdir_r(dir, &entry, &result);
+ for (ret = readdir_r(dir, &file_info, &result);
ret == 0 && result != NULL;
- ret = readdir_r(dir, &entry, &result)) {
- if (entry.d_name[0] == '.')
+ ret = readdir_r(dir, &file_info, &result)) {
+ if (file_info.d_name[0] == '.')
continue;
- snprintf(buf, sizeof(buf), "%s/%s", directory, entry.d_name);
+ snprintf(buf, sizeof(buf), "%s/%s", directory, file_info.d_name);
_D("manifest file %s", buf);
pid_t pid = fork();
}
execl(PKGINSTALLMANIFEST_CMD, PKGINSTALLMANIFEST_CMD, "-x", buf,
- (char*)NULL);
+ (char *)NULL);
} else if (pid < 0) {
_E("failed to fork and execute %s!", PKGINSTALLMANIFEST_CMD);
closedir(dir);