upload tizen1.0 source
[pkgs/n/native-installer.git] / inc / native_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
24
25
26
27 #ifndef NATIVEINSTALLERUTIL_H_
28 #define NATIVEINSTALLERUTIL_H_
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif                          /* __cplusplus */
33
34 #include <string.h>
35 #include <stdarg.h>
36 #include <sys/wait.h>
37 #include <sys/types.h>
38 #include <unistd.h>
39 #include <libgen.h>
40 #include <wait.h>
41 #include <stdio.h>
42
43 #define NATIVE_BACKEND_EXEC     "native-backend"
44
45 #define PKGTYPE "deb"
46 #define NATIVE_INSTALLER_VERSION                        "1.2.10"
47
48 #define NATIVEINSTALLER_SUCCESS                                 0
49 #define NATIVEINSTALLER_ERR_WRONG_PARAM                         3
50 #define NATIVEINSTALLER_ERR_DBUS_PROBLEM                        4
51 #define NATIVEINSTALLER_ERR_NOT_ENOUGH_MEMORY                   5
52 #define NATIVEINSTALLER_ERR_NO_MANIFEST                         6
53 #define NATIVEINSTALLER_ERR_PACKAGE_EXIST                       7
54 #define NATIVEINSTALLER_ERR_PACKAGE_NOT_INSTALLED               8
55 #define NATIVEINSTALLER_ERR_RESOURCE_BUSY                       9
56 #define NATIVEINSTALLER_ERR_UNKNOWN                             10
57 #define NATIVEINSTALLER_ERR_PKG_NOT_FOUND                       11
58 #define NATIVEINSTALLER_ERR_NOT_SUPPOTED_VERSION                12
59 #define NATIVEINSTALLER_ERR_NO_DEB_FILE                         13
60 #define NATIVEINSTALLER_ERR_DB_ACCESS_FAILED                    14
61 #define NATIVEINSTALLER_ERR_DPKG_OPERATION_FAILED               15
62 #define NATIVEINSTALLER_PACKAGE_NOT_UPGRADED                    16
63 #define NATIVEINSTALLER_ERR_NEED_USER_CONFIRMATION              17
64 #define NATIVEINSTALLER_ERR_CLEAR_DATA_FAILED           18
65
66 #define NATIVEINSTALLER_SUCCESS_STR                     "success"
67 #define NATIVEINSTALLER_ERR_WRONG_PARAM_STR             "Wrong Input Param"
68 #define NATIVEINSTALLER_ERR_DBUS_PROBLEM_STR                    "dbus error"
69 #define NATIVEINSTALLER_ERR_NOT_ENOUGH_MEMORY_STR       "Not Enough Memory"
70 #define NATIVEINSTALLER_ERR_NO_MANIFEST_STR                     "No Manifest"
71 #define NATIVEINSTALLER_ERR_PACKAGE_EXIST_STR   "Package Already Installed"
72 #define NATIVEINSTALLER_ERR_PACKAGE_NOT_INSTALLED_STR   "Package Not Installed"
73 #define NATIVEINSTALLER_ERR_RESOURCE_BUSY_STR                   "Resource Busy"
74 #define NATIVEINSTALLER_ERR_UNKNOWN_STR                 "Unknown Error"
75 #define NATIVEINSTALLER_ERR_PKG_NOT_FOUND_STR   "Package file not found"
76 #define NATIVEINSTALLER_ERR_NOT_SUPPOTED_VERSION_STR    "Version Not supported"
77 #define NATIVEINSTALLER_ERR_NO_DEB_FILE_STR     "No Debian Package"
78 #define NATIVEINSTALLER_ERR_DB_ACCESS_FAILED_STR        "DB Access Failed"
79 #define NATIVEINSTALLER_ERR_DPKG_OPERATION_FAILED_STR   "dpkg operation failed"
80 #define NATIVEINSTALLER_PACKAGE_NOT_UPGRADED_STR        "Package Not Upgraded"
81 #define NATIVEINSTALLER_ERR_CLEAR_DATA_FAILED_STR       "Clear Data Failed"
82
83 #define DEBUG_ERR       0x0001
84 #define DEBUG_INFO      0x0002
85 #define DEBUG_RESULT    0x0004
86
87 #define FRONTEND_LOG    1
88 #define BACKEND_LOG     2
89
90 extern int logging;
91
92 void _print_msg(int type, int exetype, char *format, ...);
93 #define d_msg_frontend(type, fmtstr, args...) { \
94 _print_msg(type, FRONTEND_LOG, "%s():%d: " fmtstr, \
95 __func__, __LINE__, ##args); \
96 }
97
98 #define d_msg_backend(type, fmtstr, args...) { \
99 _print_msg(type, BACKEND_LOG, "%s():%d: " fmtstr, \
100 __func__, __LINE__, ##args); \
101 }
102
103 void _d_msg_init(char *program);
104 void _d_msg_deinit();
105 int _xsystem(const char *argv[]);
106 char *_substring(const char *str, size_t begin, size_t len);
107 int _tok_split_string(char tok, char *input, char **list,
108                    unsigned long ListMax);
109 void _error_no_to_string(int errnumber, char **errstr);
110 int _string_to_error_no(char *errstr);
111
112 #ifdef __cplusplus
113 }
114 #endif                          /* __cplusplus */
115 #endif                          /* NATIVEINSTALLERUTIL_H_ */
116