1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-14 13:25:09 -05:00
pacman/lib/libalpm/alpm.c

91 lines
2.3 KiB
C
Raw Normal View History

2005-03-14 20:51:43 -05:00
/*
* alpm.c
*
* Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* 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, see <http://www.gnu.org/licenses/>.
2005-03-14 20:51:43 -05:00
*/
#include "config.h"
/* libalpm */
#include "alpm.h"
#include "alpm_list.h"
2005-03-14 20:51:43 -05:00
#include "handle.h"
#include "util.h"
2005-03-14 20:51:43 -05:00
2005-03-16 17:06:31 -05:00
/* Globals */
enum _pmerrno_t pm_errno SYMEXPORT;
2005-03-14 20:51:43 -05:00
/** \addtogroup alpm_interface Interface Functions
* @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)
*/
int SYMEXPORT alpm_initialize(void)
2005-03-14 20:51:43 -05:00
{
ASSERT(handle == NULL, RET_ERR(PM_ERR_HANDLE_NOT_NULL, -1));
2005-03-14 20:51:43 -05:00
handle = _alpm_handle_new();
2005-04-24 14:58:34 -04:00
if(handle == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
2005-04-24 14:58:34 -04:00
}
#ifdef ENABLE_NLS
bindtextdomain("libalpm", LOCALEDIR);
#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)
*/
int SYMEXPORT alpm_release(void)
2005-03-14 20:51:43 -05:00
{
ALPM_LOG_FUNC;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
2005-03-14 20:51:43 -05:00
if(alpm_db_unregister_all() == -1) {
return(-1);
2005-03-14 20:51:43 -05:00
}
_alpm_handle_free(handle);
handle = NULL;
2005-03-14 20:51:43 -05:00
return(0);
}
/** @} */
2005-03-14 20:51:43 -05:00
/** @defgroup alpm_misc Miscellaneous Functions
* @brief Various libalpm functions
*/
/* Get the version of library */
const char SYMEXPORT *alpm_version(void) {
return(LIB_VERSION);
}
2005-03-14 20:51:43 -05:00
/* vim: set ts=2 sw=2 noet: */