4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
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>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #ifndef __PKGMGR_PARSER_H__
24 #define __PKGMGR_PARSER_H__
27 * @file pkgmgr_parser.h
28 * @author Sewook Park <sewook7.park@samsung.com>
29 * @author Shobhit Srivastava <shobhit.s@samsung.com>
31 * @brief This file declares API of pkgmgr_parser
32 * @addtogroup APPLICATION_FRAMEWORK
35 * @defgroup PackageManagerParser
36 * @section Header Header file to include:
38 * #include <pkgmgr_parser.h>
44 #include <libxml/xmlreader.h>
46 /* For multi-user support */
47 #include <tzplatform_config.h>
48 #include "pkgmgrinfo_basic.h"
55 #define DEPRECATED __attribute__ ((__deprecated__))
58 #define DEFAULT_LOCALE "No Locale"
60 #define PKG_PARSERLIB "parserlib:"
61 #define PKG_PARSER_CONF_PATH SYSCONFDIR "/package-manager/parser_path.conf"
63 #define PKG_STRING_LEN_MAX 1024
65 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
68 * @brief Structure which is used by metadata plugin
77 * @brief Structure which is used by category plugin
93 * @brief API return values
96 PM_PARSER_R_EINVAL = -2, /**< Invalid argument */
97 PM_PARSER_R_ERROR = -1, /**< General error */
98 PM_PARSER_R_OK = 0 /**< General success */
102 * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
103 * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
104 * @brief This API parses the manifest file of the package after installation and stores the data in DB.
106 * @par This API is for package-manager installer backends.
107 * @par Sync (or) Async : Synchronous API
109 * @param[in] manifest pointer to package manifest file
110 * @param[in] uid the addressee user id of the instruction
111 * @param[in] tagv array of xml tags or NULL
112 * @return 0 if success, error code(<0) if fail
113 * @retval PMINFO_R_OK success
114 * @retval PMINFO_R_EINVAL invalid argument
115 * @retval PMINFO_R_ERROR internal error
119 static int parse_manifest_file_for_installation(const char *manifest)
122 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
129 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]) DEPRECATED;
130 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
131 int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest);
132 int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid);
135 * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
136 * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
137 * @brief This API parses the manifest file of the package after upgrade and stores the data in DB.
139 * @par This API is for package-manager installer backends.
140 * @par Sync (or) Async : Synchronous API
142 * @param[in] manifest pointer to package manifest file
143 * @param[in] uid the addressee user id of the instruction
144 * @param[in] tagv array of xml tags or NULL
145 * @return 0 if success, error code(<0) if fail
146 * @retval PMINFO_R_OK success
147 * @retval PMINFO_R_EINVAL invalid argument
148 * @retval PMINFO_R_ERROR internal error
152 static int parse_manifest_file_for_upgrade(const char *manifest)
155 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
162 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]) DEPRECATED;
163 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
164 int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest);
165 int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid);
168 * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
169 * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
170 * @brief This API parses the manifest file of the package after uninstallation and deletes the data from DB.
172 * @par This API is for package-manager installer backends.
173 * @par Sync (or) Async : Synchronous API
175 * @param[in] manifest pointer to package manifest file
176 * @param[in] uid the addressee user id of the instruction
177 * @param[in] tagv array of xml tags or NULL
178 * @return 0 if success, error code(<0) if fail
179 * @retval PMINFO_R_OK success
180 * @retval PMINFO_R_EINVAL invalid argument
181 * @retval PMINFO_R_ERROR internal error
185 static int parse_manifest_file_for_uninstallation(const char *manifest)
188 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
195 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]) DEPRECATED;
196 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
197 int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest);
198 int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid);
201 * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
202 * @brief This API validates the manifest file against the manifest schema.
204 * @par This API is for package-manager installer backends.
205 * @par Sync (or) Async : Synchronous API
207 * @param[in] manifest pointer to package manifest file
208 * @return 0 if success, error code(<0) if fail
209 * @retval PMINFO_R_OK success
210 * @retval PMINFO_R_EINVAL invalid argument
211 * @retval PMINFO_R_ERROR internal error
215 static int validate_manifest_file(const char *manifest)
218 ret = pkgmgr_parser_check_manifest_validation(manifest);
225 int pkgmgr_parser_check_manifest_validation(const char *manifest);
228 * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
229 * @brief This API will free the manifest pointer by recursively freeing all sub elements.
231 * @par This API is for package-manager installer backends.
232 * @par Sync (or) Async : Synchronous API
234 * @param[in] mfx pointer to parsed manifest data
235 * @pre pkgmgr_parser_process_manifest_xml()
238 static int parse_manifest_file(const char *manifest)
240 manifest_x *mfx = NULL
241 mfx = pkgmgr_parser_process_manifest_xml(manifest);
244 printf("Parsing Manifest Success\n");
245 pkgmgr_parser_free_manifest_xml(mfx);
250 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
253 * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
254 * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
255 * @brief This API parses the manifest file and stores all the data in the manifest structure.
257 * @par This API is for package-manager installer backends.
258 * @par Sync (or) Async : Synchronous API
260 * @param[in] manifest pointer to package manifest file
261 * @param[in] uid the addressee user id of the instruction
262 * @return manifest pointer on success, NULL on failure
264 * @post pkgmgr_parser_free_manifest_xml()
266 static int parse_manifest_file(const char *manifest)
268 manifest_x *mfx = NULL
269 mfx = pkgmgr_parser_process_manifest_xml(manifest);
272 printf("Parsing Manifest Success\n");
273 pkgmgr_parser_free_manifest_xml(mfx);
278 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) DEPRECATED;
279 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid) DEPRECATED;
285 #endif /* __PKGMGR_PARSER_H__ */