remove activator, add da_command script
[platform/core/system/swap-manager.git] / daemon / utils.h
1 /*
2 *  DA manager
3 *
4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5 *
6 * Contact: 
7 *
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
11
12  * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 * Contributors:
25 * - S-Core Co., Ltd
26 *
27 */ 
28
29 #ifndef _UTILS_
30 #define _UTILS_
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #include <stdio.h>
37 #include <unistd.h>
38 #include <string.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #include <sys/stat.h>
42 #include <sys/types.h>
43 #include <linux/limits.h>
44
45 #define LAUNCH_APP_PATH                 "/usr/bin/launch_app"
46 #define KILL_APP_PATH                   "/usr/bin/pkill"
47 #define LAUNCH_APP_NAME                 "launch_app"
48 #define DA_PRELOAD_EXEC                 "__AUL_SDK_DYNAMIC_ANALYSIS"
49 #define DA_PRELOAD(AppType)             AppType ? DA_PRELOAD_OSP : DA_PRELOAD_TIZEN
50 #define DA_PRELOAD_TIZEN                "LD_PRELOAD=/usr/lib/da_probe_tizen.so"
51 #define DA_PRELOAD_OSP                  "LD_PRELOAD=/usr/lib/da_probe_osp.so"
52 #define BATT_LOG_FILE                   "/home/developer/sdk_tools/da/battery/"
53 #define SHELL_CMD                               "/bin/sh"
54
55 enum ApplicationType
56 {
57         APP_TYPE_TIZEN = 0,
58         APP_TYPE_OSP = 1
59 };
60
61 char* get_app_name(char* binary_path);
62
63 int exec_app(const char* exec_path, int app_type);
64
65 void kill_app(const char* binary_path);
66
67 pid_t find_pid_from_path(const char* path);
68
69 int create_open_batt_log(const char* app_name);
70
71 int get_batt_fd();
72
73 int write_batt_log(const char* message);
74
75 void close_batt_fd();
76
77 #if DEBUG
78 void write_log();
79 #endif
80
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif