c01d142121d9307462595e3146800f826dfc2a31
[platform/core/appfw/debug-launchpad.git] / include / common.h
1 /*
2  * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __COMMON_H__
18 #define __COMMON_H__
19
20 #define _GNU_SOURCE
21 #include <unistd.h>
22 #include <ctype.h>
23 #include <dlog.h>
24 #include <bundle.h>
25 #include <sys/socket.h>
26 #include <sys/un.h>
27
28 #ifdef LOG_TAG
29 #undef LOG_TAG
30 #define LOG_TAG "DEBUG_LAUNCHPAD"
31 #endif
32
33 #define _E(fmt, arg...) LOGE(fmt, ##arg)
34 #define _D(fmt, arg...) LOGD(fmt, ##arg)
35 #define _W(fmt, arg...) LOGW(fmt, ##arg)
36
37 #define SOCKET_PATH "/run/aul"
38 #define MAX_LOCAL_BUFSZ 128
39 #define AUL_SOCK_MAXBUFF 131071
40
41 #define PAD_CMD_LAUNCH 0
42
43 typedef struct _app_pkt_t {
44         int cmd;
45         int len;
46         int opt;
47         unsigned char data[1];
48 } app_pkt_t;
49
50 typedef struct {
51         char *appid;
52         char *app_path;
53         char *original_app_path;
54         char *debug_appid;
55         char *pkg_type;
56         char *hwacc;
57         char *taskmanage;
58         char *comp_type;
59 } appinfo_t;
60
61 struct ucred;
62
63 int _create_server_sock(void);
64 app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr);
65 appinfo_t *_appinfo_create(bundle *kb);
66 void _appinfo_free(appinfo_t *appinfo);
67 void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *appinfo, int cmd);
68 void _set_env(appinfo_t *app_info, bundle *kb);
69 char **_create_argc_argv(bundle *kb, int *margc, const char *app_path);
70 int _proc_check_cmdline_bypid(int pid);
71 void _prepare_listen_sock(void);
72
73 #endif /* __COMMON_H__ */
74