These new method signatures return and take handle objects to operate on
so we can move away from the idea of one global handle in the API. There
is also another important change and that deals with the setting of root
and dbpaths. These are now done at initialization time instead of using
setter methods. This allows the library to operate more safely knowing
that paths won't change underneath it.
- return 0;
+ /* TODO temporary until global var removed */
+ handle = myhandle;
+ return myhandle;
+
+cleanup:
+ _alpm_handle_free(myhandle);
+ if(err && myerr) {
+ *err = myerr;
+ }
+ return NULL;
}
/** Release the library. This should be the last alpm call you make.
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ * After this returns, handle should be considered invalid and cannot be reused
+ * in any way.
+ * @param handle the context handle
+ * @return 0 on success, -1 on error
*/
-int SYMEXPORT alpm_release(void)
+int SYMEXPORT alpm_release(pmhandle_t *myhandle)
{
pmdb_t *db;
@@ -165,15 +157,14 @@ alpm_cb_totaldl alpm_option_get_totaldlcb(void);
/** Sets the callback used to report total download size. */
int alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
-/** Returns the root of the destination filesystem. */
+/** Returns the root of the destination filesystem. Read-only. */
const char *alpm_option_get_root(void);
-/** Sets the root of the destination filesystem. */
-int alpm_option_set_root(const char *root);
-/** Returns the path to the database directory. */
+/** Returns the path to the database directory. Read-only. */
const char *alpm_option_get_dbpath(void);
-/** Sets the path to the database directory. */
-int alpm_option_set_dbpath(const char *dbpath);
+
+/** Get the name of the database lock file. Read-only. */
+const char *alpm_option_get_lockfile(void);
/** @name Accessors to the list of package cache directories.
* @{
@@ -189,15 +180,6 @@ const char *alpm_option_get_logfile(void);
/** Sets the logfile name. */
int alpm_option_set_logfile(const char *logfile);
-/** Get the name of the database lock file.
- *
- * This properly is read-only, and determined from
- * the database path.
- *
- * @sa alpm_option_set_dbpath(const char*)
- */
-const char *alpm_option_get_lockfile(void);
-
/** Returns the signature directory path. */
const char *alpm_option_get_signaturedir(void);
/** Sets the signature directory path. */
@@ -302,9 +284,10 @@ pmdb_t *alpm_db_register_sync(const char *treename);
int alpm_db_unregister(pmdb_t *db);
/** Unregister all package databases.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_db_unregister_all(void);
+int alpm_db_unregister_all(pmhandle_t *handle);
/** Get the name of a package database.
* @param db pointer to the package database
@@ -1054,6 +1037,11 @@ const char *alpm_strerrorlast(void);
/* End of alpm_api_errors */
/** @} */