3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 * @brief Utilities header for Power manager
24 #ifndef __DEF_UTIL_H__
25 #define __DEF_UTIL_H__
28 * @addtogroup POWER_MANAGER
33 * @brief write the pid
35 * get a pid and write it to pidpath
37 * @param[in] pidpath pid file path
40 extern int writepid(char *pidpath);
45 * get a pid and write it to pidpath
47 * @param[in] pidpath pid file path
48 * @return pid : success, -1 : failed
50 extern int readpid(char *pidpath);
53 * @brief daemonize function
55 * fork the process, kill the parent process
56 * and replace all the standard fds to /dev/null.
58 * @return 0 : success, -1 : fork() error
60 extern int daemonize(void);
63 * @brief function to run a process
65 * fork the process, and run the other process if it is child.
67 * @return new process pid on success, -1 on error
69 extern int exec_process(char *name);
72 * @brief function to get the pkg name for AUL (Application Util Library)
74 * remove the path of exepath and make the "com.samsung.<exe_file_name>" string.
76 * @return new process pid on success, -1 on error
78 extern char *get_pkgname(char *exepath);
81 * @brief logging function
85 * @param[in] priority log pritority
86 * @param[in] fmt format string
88 extern void pm_log(int priority, char *fmt, ...);
90 #if defined(ENABLE_DLOG_OUT)
93 * @brief LOG_INFO wrapper
95 # define LOGINFO(fmt, arg...) pm_log(DLOG_INFO, fmt, ## arg)
98 * @brief LOG_ERR wrapper
100 # define LOGERR(fmt, arg...) pm_log(DLOG_ERROR, fmt, ## arg)
103 # define LOGINFO(fmt, arg...) pm_log(LOG_INFO, fmt, ## arg)
104 # define LOGERR(fmt, arg...) pm_log(LOG_ERR, fmt, ## arg)