Fix Prevent and remove compile warning messages
[platform/core/appfw/ail.git] / tool / src / ail_list.c
1 /*
2  * ail_list.c is based on ail_filter.c
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdio.h>
21 #include <getopt.h>
22 #include <unistd.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "ail.h"
26 #include "ail_private.h"
27
28 ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo, void *user_data, uid_t uid)
29 {
30         char *package_str_name = NULL;
31         char *package_str_appid = NULL;
32         char *package_str_x_slp_exe = NULL;
33
34         ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_APPID_STR, &package_str_appid);
35         ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &package_str_name);
36         ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_EXE_PATH, &package_str_x_slp_exe);
37
38         printf("'%s' '%s' '%s'\n", package_str_appid, package_str_name, package_str_x_slp_exe);
39
40         free(package_str_appid);
41         free(package_str_name);
42         free(package_str_x_slp_exe);
43
44         return AIL_CB_RET_CONTINUE;
45 }
46
47 int main(int argc, char *argv[])
48 {
49         if (getuid() == 0) {
50                 printf("Please use it as non root user\n");
51                 return -1;
52         }
53
54         printf("Application List for user %lu\n", (long)getuid());
55         printf("User's Application \n");
56         printf("APPID    NAME   EXEPATH \n");
57
58         ail_filter_list_usr_appinfo_foreach(NULL, appinfo_list_appid_namefunc, NULL, getuid());
59
60         printf("Global's / Common Applications \n");
61         printf("APPID    NAME   EXEPATH \n");
62
63         ail_filter_list_appinfo_foreach(NULL, appinfo_list_appid_namefunc, NULL);
64
65         printf("=================================================\n");
66
67         return 0;
68 }