2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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
8 * http://www.tizenopensource.org/license
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.
21 * @brief Utilities header for Power manager
23 #ifndef __DEF_UTIL_H__
24 #define __DEF_UTIL_H__
27 * @addtogroup POWER_MANAGER
32 * @brief write the pid
34 * get a pid and write it to pidpath
36 * @param[in] pidpath pid file path
39 extern int writepid(char *pidpath);
44 * get a pid and write it to pidpath
46 * @param[in] pidpath pid file path
47 * @return pid : success, -1 : failed
49 extern int readpid(char *pidpath);
52 * @brief daemonize function
54 * fork the process, kill the parent process
55 * and replace all the standard fds to /dev/null.
57 * @return 0 : success, -1 : fork() error
59 extern int daemonize(void);
62 * @brief function to run a process
64 * fork the process, and run the other process if it is child.
66 * @return new process pid on success, -1 on error
68 extern int exec_process(char *name);
71 * @brief function to get the pkg name for AUL (Application Util Library)
73 * remove the path of exepath and make the "com.samsung.<exe_file_name>" string.
75 * @return new process pid on success, -1 on error
77 extern char *get_pkgname(char *exepath);
80 * @brief logging function
84 * @param[in] priority log pritority
85 * @param[in] fmt format string
87 extern void pm_log(int priority, char *fmt, ...);
89 #if defined(ENABLE_DLOG_OUT)
92 * @brief LOG_INFO wrapper
94 # define LOGINFO(fmt, arg...) pm_log(DLOG_INFO, fmt, ## arg)
97 * @brief LOG_ERR wrapper
99 # define LOGERR(fmt, arg...) pm_log(DLOG_ERROR, fmt, ## arg)
102 # define LOGINFO(fmt, arg...) pm_log(LOG_INFO, fmt, ## arg)
103 # define LOGERR(fmt, arg...) pm_log(LOG_ERR, fmt, ## arg)