merge with master
[platform/core/base/rpm-installer.git] / inc / rpm-installer-util.h
1 /*
2  * rpm-installer
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7  * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __RPM_INSTALLER_UTIL_H_
24 #define __RPM_INSTALLER_UTIL_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif                          /* __cplusplus */
29
30 #include <string.h>
31 #include <stdarg.h>
32 #include <sys/wait.h>
33 #include <sys/types.h>
34 #include <unistd.h>
35 #include <libgen.h>
36 #include <wait.h>
37 #include <stdio.h>
38
39 #define RPM_BACKEND_EXEC        "rpm-backend"
40
41 #define PKGTYPE "rpm"
42
43 #define RPM_INSTALLER_SUCCESS                                           0
44 #define RPM_INSTALLER_ERR_WRONG_PARAM                           101
45 #define RPM_INSTALLER_ERR_DBUS_PROBLEM                          102
46 #define RPM_INSTALLER_ERR_NOT_ENOUGH_MEMORY                     62
47 #define RPM_INSTALLER_ERR_PACKAGE_EXIST                         103
48 #define RPM_INSTALLER_ERR_PACKAGE_NOT_INSTALLED         104
49 #define RPM_INSTALLER_ERR_RESOURCE_BUSY                         105
50 #define RPM_INSTALLER_ERR_UNKNOWN                                       120
51 #define RPM_INSTALLER_ERR_PKG_NOT_FOUND                         1
52 #define RPM_INSTALLER_ERR_NOT_SUPPOTED_VERSION          107
53 #define RPM_INSTALLER_ERR_NO_RPM_FILE                           108
54 #define RPM_INSTALLER_ERR_DB_ACCESS_FAILED                      109
55 #define RPM_INSTALLER_ERR_RPM_OPERATION_FAILED          110
56 #define RPM_INSTALLER_ERR_PACKAGE_NOT_UPGRADED          111
57 #define RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS         112
58 #define RPM_INSTALLER_ERR_NEED_USER_CONFIRMATION        113
59 #define RPM_INSTALLER_ERR_PACKAGE_INSTALLATION_DISABLED         114
60 #define RPM_INSTALLER_ERR_PACKAGE_UNINSTALLATION_DISABLED       115
61 #define RPM_INSTALLER_ERR_CLEAR_DATA_FAILED                     116
62 #define RPM_INSTALLER_ERR_INTERNAL                                      117
63 #define RPM_INSTALLER_ERR_NO_MANIFEST                           11
64 #define RPM_INSTALLER_ERR_INVALID_MANIFEST                      12
65
66 #define RPM_INSTALLER_SUCCESS_STR                       "Success"
67 #define RPM_INSTALLER_ERR_WRONG_PARAM_STR               "Wrong Input Param"
68 #define RPM_INSTALLER_ERR_DBUS_PROBLEM_STR                      "DBUS Error"
69 #define RPM_INSTALLER_ERR_NOT_ENOUGH_MEMORY_STR "Not Enough Memory"
70 #define RPM_INSTALLER_ERR_PACKAGE_EXIST_STR     "Package Already Installed"
71 #define RPM_INSTALLER_ERR_PACKAGE_NOT_INSTALLED_STR     "Package Not Installed"
72 #define RPM_INSTALLER_ERR_RESOURCE_BUSY_STR                     "Resource Busy"
73 #define RPM_INSTALLER_ERR_UNKNOWN_STR                   "Unknown Error"
74 #define RPM_INSTALLER_ERR_PKG_NOT_FOUND_STR             "Package file not found"
75 #define RPM_INSTALLER_ERR_NOT_SUPPOTED_VERSION_STR      "Version Not supported"
76 #define RPM_INSTALLER_ERR_NO_RPM_FILE_STR       "No RPM Package"
77 #define RPM_INSTALLER_ERR_DB_ACCESS_FAILED_STR  "DB Access Failed"
78 #define RPM_INSTALLER_ERR_RPM_OPERATION_FAILED_STR      "RPM operation failed"
79 #define RPM_INSTALLER_ERR_PACKAGE_NOT_UPGRADED_STR      "Package Not Upgraded"
80 #define RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS_STR     "Wrong Args to Script"
81 #define RPM_INSTALLER_ERR_PACKAGE_INSTALLATION_DISABLED_STR     "Installation Disabled"
82 #define RPM_INSTALLER_ERR_PACKAGE_UNINSTALLATION_DISABLED_STR   "Uninstallation Disabled"
83 #define RPM_INSTALLER_ERR_CLEAR_DATA_FAILED_STR         "Clear Data Failed"
84 #define RPM_INSTALLER_ERR_INTERNAL_STR  "Internal Error"
85 #define RPM_INSTALLER_ERR_NO_MANIFEST_STR       "Manifest File Not Found"
86 #define RPM_INSTALLER_ERR_INVALID_MANIFEST_STR  "Manifest Validation Failed"
87
88
89 #define DEBUG_ERR               0x0001
90 #define DEBUG_INFO              0x0002
91 #define DEBUG_RESULT    0x0004
92
93 #define RPM_LOG 1
94
95         void _print_msg(int type, int exetype, char *format, ...);
96 #define _d_msg(type, fmtstr, args...) { \
97 _print_msg(type, RPM_LOG, "%s:%d:%s(): " fmtstr, basename(__FILE__), \
98 __LINE__, __func__, ##args); \
99 }
100
101         void _d_msg_init(char *program);
102         void _d_msg_deinit();
103         int _ri_xsystem(const char *argv[]);
104         char *_ri_substring(const char *str, size_t begin, size_t len);
105         int _ri_tok_split_string(char tok, char *input, char **list,
106                                  unsigned long listmax);
107         void _ri_error_no_to_string(int errnumber, char **errstr);
108         int _ri_string_to_error_no(char *errstr);
109
110 #ifdef __cplusplus
111 }
112 #endif                          /* __cplusplus */
113 #endif                          /* __RPM_INSTALLER_UTIL_H_ */