return;
}
pkgmgr_installer_set_session_id(pi, info->req_id);
- switch(info->req_type) {
+ switch (info->req_type) {
case PKGMGR_REQUEST_TYPE_INSTALL:
case PKGMGR_REQUEST_TYPE_MOUNT_INSTALL:
case PKGMGR_REQUEST_TYPE_REINSTALL:
static int __check_backend_status_for_exit(void)
{
int i = 0;
- for(i = 0; i < num_of_backends; i++)
- {
- if (!__is_backend_busy(i))
- continue;
- else
+ for (i = 0; i < num_of_backends; i++) {
+ if (__is_backend_busy(i))
return 0;
}
return 1;
int i = 0;
int c = 0;
int slot = -1;
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (ptr->queue_slot <= slot) {
ptr++;
- continue;
- }
- else {
+ } else {
head[c] = ptr->head;
slot = ptr->queue_slot;
c++;
ptr++;
}
}
- for(i = 0; i < num_of_backends; i++)
- {
- if (!head[i])
- continue;
- else
+ for (i = 0; i < num_of_backends; i++) {
+ if (head[i])
return 0;
}
return 1;
int pgid;
dp = opendir("/proc");
- if (dp == NULL) {
+ if (dp == NULL)
return -1;
- }
for (ret = readdir_r(dp, &dentry, &result);
ret == 0 && result != NULL;
struct passwd pwd;
struct passwd *pwd_result;
- if(req_key == NULL)
+ if (req_key == NULL)
return;
ret = getpwuid_r(uid, &pwd, buf, sizeof(buf), &pwd_result);
}
ret = __pkgcmd_proc_iter_kill_cmdline(exec, 1);
- if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_OK)
DBG("failed to kill app[%s], exec[%s]", appid, exec);
- }
pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
return ret;
if (strcmp(pdata->cmd, "kill") == 0)
pid = __pkgcmd_proc_iter_kill_cmdline(exec, 1);
- else if(strcmp(pdata->cmd, "check") == 0)
+ else if (strcmp(pdata->cmd, "check") == 0)
pid = __pkgcmd_proc_iter_kill_cmdline(exec, 0);
__make_pid_info_file(pkgid, pid, pdata->uid);
if (!ctx)
return;
env = ctx->env;
- //env variable ends by NULL element
+ /* env variable ends by NULL element */
while (env[i]) {
free(env[i]);
i++;
return -1;
}
env = ctx->env;
- //env variable ends by NULL element
+ /* env variable ends by NULL element */
while (env[i]) {
if (putenv(env[i]) != 0)
res = -1;
ret = -1;
break;
}
- // Build environment context
+ /* Build environment context */
len = snprintf(NULL, 0, "HOME=%s", pwd.pw_dir);
env[0] = (char *)malloc((len + 1) * sizeof(char));
- if(env[0] == NULL) {
+ if (env[0] == NULL) {
ret = -1;
break;
}
snprintf(env[0], len + 1, "HOME=%s", pwd.pw_dir);
len = snprintf(NULL, 0, "USER=%s", pwd.pw_name);
env[1] = (char *)malloc((len + 1) * sizeof(char));
- if(env[1] == NULL) {
+ if (env[1] == NULL) {
ret = -1;
break;
}
free(context_res);
context_res = NULL;
i = 0;
- //env variable ends by NULL element
+ /* env variable ends by NULL element */
while (env && env[i]) {
free(env[i]);
i++;
char buffer[1024] = { 0 };
char *command = NULL;
int size = 0;
+
fp = fopen(PKG_CONF_PATH, "r");
- if (fp == NULL) {
+ if (fp == NULL)
return NULL;
- }
char *path = NULL;
while (fgets(buffer, 1024, fp) != NULL) {
return -1;
}
-#if !GLIB_CHECK_VERSION(2,35,0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
mainloop = g_main_loop_new(NULL, FALSE);
queue_info_map *ptr = NULL;
ptr = start;
int i = 0;
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
return 1;
- else {
+ else
ptr++;
- continue;
- }
}
return 0;
}
queue_info_map *ptr = NULL;
ptr = start;
int i = 0;
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (!strncmp(ptr->backend, backend, MAX_PKG_NAME_LEN))
return ptr->queue_slot;
- else {
+ else
ptr++;
- continue;
- }
}
return -1;
}
ptr = start;
int slot = -1;
int i = 0;
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (!strncmp(ptr->pkgtype, data->msg->pkg_type, MAX_PKG_TYPE_LEN)) {
ptr->head = data;
slot = ptr->queue_slot;
- }
- else {
+ } else {
ptr++;
- continue;
}
}
/*update head for each duplicate entry*/
ptr = start;
- for(i = 0; i < entries; i++)
- {
- if(ptr->queue_slot == slot && !ptr->head) {
+ for (i = 0; i < entries; i++) {
+ if (ptr->queue_slot == slot && !ptr->head)
ptr->head = data;
- }
+
ptr++;
}
return;
queue_info_map *ptr = NULL;
ptr = start;
int i = 0;
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (!strncmp(ptr->pkgtype, pkg_type, MAX_PKG_TYPE_LEN))
return ptr->head;
- else {
+ else
ptr++;
- continue;
- }
}
return NULL;
return -1;
}
i = n;
- /*Find number of backends (symlinks + executables)
- The backend dir should not conatin any other file except the backends.*/
- while(n--)
- {
- if(!strcmp(namelist[n]->d_name, ".") ||
- !strcmp(namelist[n]->d_name, ".."))
+ /* Find number of backends (symlinks + executables)
+ The backend dir should not conatin any other file except the backends. */
+ while (n--) {
+ if (!strcmp(namelist[n]->d_name, ".") ||
+ !strcmp(namelist[n]->d_name, ".."))
continue;
snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s",
- BACKEND_DIR, namelist[n]->d_name);
+ BACKEND_DIR, namelist[n]->d_name);
if (lstat(abs_filename, &fileinfo)) {
perror("lstat");
continue;
c++;
memset(abs_filename, 0x00, MAX_PKG_NAME_LEN);
}
- /*Add entries to info map.*/
+ /* Add entries to info map. */
ptr = (queue_info_map*)calloc(c , sizeof(queue_info_map));
memset(ptr, '\0', c * sizeof(queue_info_map));
start = ptr;
- for(n = 0; n < c ; n++)
- {
+ for (n = 0; n < c ; n++) {
ptr->backend[0] = '\0';
ptr->head = NULL;
- ptr->queue_slot = -2;/*-1 can be error return*/
+ ptr->queue_slot = -2; /* -1 can be error return */
ptr->pkgtype[0] = '\0';
ptr++;
}
n = i;
ptr = start;
- while(n--)
- {
- if(!strcmp(namelist[n]->d_name, ".") ||
- !strcmp(namelist[n]->d_name, ".."))
+ while (n--) {
+ if (!strcmp(namelist[n]->d_name, ".") ||
+ !strcmp(namelist[n]->d_name, ".."))
continue;
snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s",
BACKEND_DIR, namelist[n]->d_name);
return -1;
}
buf[ret] = '\0';
- }
- /*executable*/
- else {
+ } else {
+ /*executable*/
snprintf(buf, sizeof(buf), "%s", abs_filename);
}
ret = __entry_exist(buf);
entries++;
slot++;
ptr++;
- }
- else {
+ } else {
snprintf(ptr->backend, sizeof(ptr->backend), "%s", buf);
snprintf(ptr->pkgtype, sizeof(ptr->pkgtype), "%s", namelist[n]->d_name);
ptr->queue_slot = ret;
DBG("Number of Entries is %d", entries);
DBG("Backend\tType\tSlot\tHead");
ptr = start;
- for(n = 0; n < entries; n++)
- {
+ for (n = 0; n < entries; n++) {
DBG("%s\t%s\t%d\t%p", ptr->backend, ptr->pkgtype, ptr->queue_slot, ptr->head);
ptr++;
}
/* first push */
cur = data;
__update_head_from_pkgtype(data);
- }
- else {
+ } else {
while (tmp->next)
tmp = tmp->next;
}
memset(ret, 0x00, sizeof(pm_dbus_msg));
ptr = start;
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (ptr->queue_slot == position) {
cur = ptr->head;
break;
cur->next = NULL;
free(cur->msg);
free(cur);
- /*update head for each duplicate queue entry*/
+ /* update head for each duplicate queue entry */
ptr = start;
- for(i = 0; i < entries; i++)
- {
- if(ptr->queue_slot == position) {
+ for (i = 0; i < entries; i++) {
+ if (ptr->queue_slot == position)
ptr->head = saveptr;
- }
+
ptr++;
}
return ret;
}
-/*populate an array of all queue heads and delete them one by one*/
+/* populate an array of all queue heads and delete them one by one */
void _pm_queue_final()
{
int c = 0;
queue_info_map *ptr = NULL;
ptr = start;
- for(i = 0; i < num_of_backends; i++)
- {
+ for (i = 0; i < num_of_backends; i++)
head[i] = NULL;
- }
- for(i = 0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (ptr->queue_slot <= slot) {
ptr++;
- continue;
- }
- else {
+ } else {
head[c] = ptr->head;
slot = ptr->queue_slot;
c++;
}
c = 0;
- while(c < num_of_backends) {
+ while (c < num_of_backends) {
if (!head[c]) { /* in case of head is NULL */
c = c + 1;
continue;
pm_queue_data *cur = NULL;
queue_info_map *ptr = start;
int i = 0;
- for(i =0; i < entries; i++)
- {
+ for (i = 0; i < entries; i++) {
if (ptr->queue_slot == position) {
cur = ptr->head;
break;
ptr++;
}
int index = 1;
- if (!cur) {
+ if (!cur)
return;
- }
while (cur) {
index++;
if (target_uid == (uid_t)-1 || pkgtype == NULL) {
g_dbus_method_invocation_return_value(invocation,
- g_variant_new("(is)",
- PKGMGR_R_ECOMM, ""));
+ g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
ret = -1;
goto catch;
}
if (pkgpath == NULL) {
g_dbus_method_invocation_return_value(invocation,
- g_variant_new("(is)",
- PKGMGR_R_ECOMM, ""));
+ g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
ret = -1;
goto catch;
}
}
if (_pm_queue_push(target_uid, reqkey, PKGMGR_REQUEST_TYPE_MOUNT_INSTALL,
- pkgtype, pkgpath, args)) {
- g_dbus_method_invocation_return_value(invocation,
- g_variant_new("(is)",
- PKGMGR_R_ESYSTEM, ""));
+ pkgtype, pkgpath, args)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
ret = -1;
goto catch;
}
g_dbus_method_invocation_return_value(invocation,
- g_variant_new("(is)",
- PKGMGR_R_OK,
- reqkey));
+ g_variant_new("(is)", PKGMGR_R_OK, reqkey));
ret = 0;
- catch:
+catch:
if (reqkey)
free(reqkey);
ret = 0;
catch:
- if(reqkey)
+ if (reqkey)
free(reqkey);
return ret;
return 0;
}
-static const GDBusInterfaceVTable interface_vtable =
-{
+static const GDBusInterfaceVTable interface_vtable = {
__handle_method_call,
NULL,
NULL,