alpm.c

Go to the documentation of this file.
00001 /*
00002  *  alpm.c
00003  *
00004  *  Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
00005  *  Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
00006  *  Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
00007  *  Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
00008  *
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021  */
00022 
00023 #include "config.h"
00024 
00025 /* libalpm */
00026 #include "alpm.h"
00027 #include "alpm_list.h"
00028 #include "error.h"
00029 #include "handle.h"
00030 #include "util.h"
00031 
00032 /* Globals */
00033 enum _pmerrno_t pm_errno SYMEXPORT;
00034 
00035 /** \addtogroup alpm_interface Interface Functions
00036  * @brief Functions to initialize and release libalpm
00037  * @{
00038  */
00039 
00040 /** Initializes the library.  This must be called before any other
00041  * functions are called.
00042  * @return 0 on success, -1 on error (pm_errno is set accordingly)
00043  */
00044 int SYMEXPORT alpm_initialize(void)
00045 {
00046     ASSERT(handle == NULL, RET_ERR(PM_ERR_HANDLE_NOT_NULL, -1));
00047 
00048     handle = _alpm_handle_new();
00049     if(handle == NULL) {
00050         RET_ERR(PM_ERR_MEMORY, -1);
00051     }
00052 
00053 #ifdef ENABLE_NLS
00054     bindtextdomain("libalpm", LOCALEDIR);
00055 #endif
00056 
00057     return(0);
00058 }
00059 
00060 /** Release the library.  This should be the last alpm call you make.
00061  * @return 0 on success, -1 on error (pm_errno is set accordingly)
00062  */
00063 int SYMEXPORT alpm_release(void)
00064 {
00065     ALPM_LOG_FUNC;
00066 
00067     ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
00068 
00069     if(alpm_db_unregister_all() == -1) {
00070         return(-1);
00071     }
00072 
00073     _alpm_handle_free(handle);
00074 
00075     return(0);
00076 }
00077 
00078 /** @} */
00079 
00080 /** @defgroup alpm_misc Miscellaneous Functions
00081  * @brief Various libalpm functions
00082  */
00083 
00084 /* vim: set ts=2 sw=2 noet: */

Generated on Mon Jan 14 23:53:39 2008 for libalpm by  doxygen 1.5.4