2005-03-14 20:51:43 -05:00
|
|
|
/*
|
|
|
|
* alpm.c
|
|
|
|
*
|
2007-06-05 17:32:53 -04:00
|
|
|
* Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
|
2006-10-15 15:31:03 -04:00
|
|
|
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
|
|
|
|
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
|
|
|
|
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
|
2005-03-14 20:51:43 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
* USA.
|
|
|
|
*/
|
|
|
|
|
2007-03-05 17:13:33 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
/* libalpm */
|
|
|
|
#include "alpm.h"
|
|
|
|
#include "alpm_list.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "error.h"
|
|
|
|
#include "handle.h"
|
2007-06-03 23:57:38 -04:00
|
|
|
#include "util.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2005-03-16 17:06:31 -05:00
|
|
|
/* Globals */
|
2005-03-14 20:51:43 -05:00
|
|
|
pmhandle_t *handle = NULL;
|
2007-01-30 02:47:19 -05:00
|
|
|
enum _pmerrno_t pm_errno SYMEXPORT;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/** \addtogroup alpm_interface Interface Functions
|
2007-01-11 12:32:49 -05:00
|
|
|
* @brief Functions to initialize and release libalpm
|
2005-10-09 03:42:06 -04:00
|
|
|
* @{
|
2005-03-14 20:51:43 -05:00
|
|
|
*/
|
|
|
|
|
2005-10-09 03:42:06 -04:00
|
|
|
/** Initializes the library. This must be called before any other
|
|
|
|
* functions are called.
|
|
|
|
* @return 0 on success, -1 on error (pm_errno is set accordingly)
|
|
|
|
*/
|
2007-07-06 12:11:55 -04:00
|
|
|
int SYMEXPORT alpm_initialize(void)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2005-03-16 17:10:05 -05:00
|
|
|
ASSERT(handle == NULL, RET_ERR(PM_ERR_HANDLE_NOT_NULL, -1));
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
handle = _alpm_handle_new();
|
2005-04-24 14:58:34 -04:00
|
|
|
if(handle == NULL) {
|
2005-04-24 16:11:10 -04:00
|
|
|
RET_ERR(PM_ERR_MEMORY, -1);
|
2005-04-24 14:58:34 -04:00
|
|
|
}
|
2007-10-23 00:52:55 -04:00
|
|
|
|
|
|
|
#ifdef ENABLE_NLS
|
2007-07-06 17:59:08 -04:00
|
|
|
bindtextdomain("libalpm", LOCALEDIR);
|
2007-10-23 00:52:55 -04:00
|
|
|
#endif
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2005-10-09 03:42:06 -04:00
|
|
|
/** Release the library. This should be the last alpm call you make.
|
|
|
|
* @return 0 on success, -1 on error (pm_errno is set accordingly)
|
|
|
|
*/
|
2007-07-06 12:11:55 -04:00
|
|
|
int SYMEXPORT alpm_release(void)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-16 17:10:05 -05:00
|
|
|
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-07-09 11:02:29 -04:00
|
|
|
if(alpm_db_unregister_all() == -1) {
|
|
|
|
return(-1);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-04-26 20:29:12 -04:00
|
|
|
_alpm_handle_free(handle);
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2007-01-11 12:32:49 -05:00
|
|
|
/** @} */
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-06-03 23:57:38 -04:00
|
|
|
/** @defgroup alpm_misc Miscellaneous Functions
|
2006-02-01 12:58:02 -05:00
|
|
|
* @brief Various libalpm functions
|
2006-10-15 15:31:03 -04:00
|
|
|
*/
|
2007-02-04 03:26:52 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* vim: set ts=2 sw=2 noet: */
|