Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

db_api.h File Reference

Database Access API. More...

#include <libpackman/types.h>
#include <libpackman/db.h>

Go to the source code of this file.

Database Setup Functions

PmDatabasepmOpenDatabase (const char *type, PmAccessMode mode)
 Opens a database of the specified type.

PmDatabasepmCreateDatabase (const char *type)
 Creates a new database of the specified type.

void pmCloseDatabase (PmDatabase *db)
 Closes the specified database.

PmStatus pmRebuildDatabase (const char *type)
 Rebuilds the database of the specified type.


PmMatches (De)allocation Functions

unsigned long pmDbGetPackageCount (PmDatabase *db)
 Returns the number of packages in the database.


PmMatches (De)allocation Functions

PmMatchespmNewMatches (PmDatabase *db)
 Creates a new PmMatches structure.

void pmDestroyMatches (PmMatches *matches)
 Destroys a PmMatches structure.


Database Manipulation Functions

PmStatus pmInstallPackage (PmDatabase *db, PmPackage *package, char checkDeps, PmTransactionError **error)
 Installs a package and adds it to the database.

PmStatus pmUninstallPackage (PmDatabase *db, PmPackage *package, char checkDeps, PmTransactionError **error)
 Uninstalls a package and removes it from the database.

PmStatus pmInstallBatch (PmDatabase *db, PmBatch *batch, char checkDeps, PmTransactionError **error)
 Installs a batch of packages and adds them to the database.

PmStatus pmUninstallBatch (PmDatabase *db, PmBatch *batch, char checkDeps, PmTransactionError **error)
 Uninstalls a batch of packages and removes them the database.

PmStatus pmDbAddPackage (PmDatabase *db, PmPackage *package, char checkDeps, PmTransactionError **error)
 Adds the information on a package to the database.

PmStatus pmDbRemovePackage (PmDatabase *db, PmPackage *package, char checkDeps, PmTransactionError **error)
 Removes the information on a package from the database.

PmStatus pmDbAddBatch (PmDatabase *db, PmBatch *batch, char checkDeps, PmTransactionError **error)
 Adds a batch of packages to the database.

PmStatus pmDbRemoveBatch (PmDatabase *db, PmBatch *batch, char checkDeps, PmTransactionError **error)
 Removes a batch of packages from the database.


Search Functions

PmStatus pmFindByName (PmDatabase *db, const char *name, PmMatches **matches)
 Searches for a package by name.

PmStatus pmFindByGroup (PmDatabase *db, const char *group, PmMatches **matches)
 Searches for a package by group.

PmStatus pmFindByFile (PmDatabase *db, const char *file, PmMatches **matches)
 Searches for a package by file.

PmStatus pmFindByProvides (PmDatabase *db, const char *provides, PmMatches **matches)
 Searches for a package by the specified provided dependency.

PmStatus pmFindByRequires (PmDatabase *db, const char *requires, PmMatches **matches)
 Searches for a package by the specified required dependency.

PmStatus pmFindByConflicts (PmDatabase *db, const char *conflicts, PmMatches **matches)
 Searches for a package by the specified conflicting dependency.

PmStatus pmGetAllPackages (PmDatabase *db, PmMatches **matches)
 Returns all packages in the database.


Match Iteration Functions

PmPackagepmFirstMatch (PmMatches *matches)
 Returns the first matched package.

PmPackagepmNextMatch (PmMatches *matches)
 Returns the next matched package.


Detailed Description

Database Access API.

Id:
db_api.h,v 1.29 2002/04/20 07:38:08 chipx86 Exp
Copyright:
(C) 1999-2002 The GNUpdate Project.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library 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 Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Function Documentation

void pmCloseDatabase PmDatabase   db
 

Closes the specified database.

This will free up all memory associated with the database, except for any existing PmPackage structures still in memory.

All PmPackage structures returned from a call to the database should be destroyed before pmCloseDatabase() is called.

Parameters:
db  The database to close.

PmDatabase* pmCreateDatabase const char *    type
 

Creates a new database of the specified type.

The type parameter must match one of the installed package modules. These are located in /usr/lib/packman/database, /usr/local/lib/packman/database, and/or $HOME/.gnupdate/packman/database.

If successful, the PmDatabase structure returned will be a handle to the newly created and opened database. The database will be opened in read/write mode.

Parameters:
type  The type of database.
Returns:
A PmDatabase structure representing the created database, or NULL if unsuccessful.

PmStatus pmDbAddBatch PmDatabase   db,
PmBatch   batch,
char    checkDeps,
PmTransactionError **    error
 

Adds a batch of packages to the database.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to add to.
batch  The batch to add.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmDbRemoveBatch()

PmStatus pmDbAddPackage PmDatabase   db,
PmPackage   package,
char    checkDeps,
PmTransactionError **    error
 

Adds the information on a package to the database.

This is different from pmInstallPackage(), which adds the information and then proceeds to extract and install the package's files.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to add the package to.
package  The package to add to the database.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmDbRemovePackage()

unsigned long pmDbGetPackageCount PmDatabase   db
 

Returns the number of packages in the database.

Parameters:
db  The database.
Returns:
The number of packages in the database.

PmStatus pmDbRemoveBatch PmDatabase   db,
PmBatch   batch,
char    checkDeps,
PmTransactionError **    error
 

Removes a batch of packages from the database.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to remove the batch from.
batch  The batch to remove.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmDbAddBatch()

PmStatus pmDbRemovePackage PmDatabase   db,
PmPackage   package,
char    checkDeps,
PmTransactionError **    error
 

Removes the information on a package from the database.

This is different from pmUninstallPackage(), which removes the information and then proceeds to uninstall the package's files.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to remove the package from.
package  The package to remove from the database.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmDbAddPackage()

void pmDestroyMatches PmMatches   matches
 

Destroys a PmMatches structure.

Parameters:
matches  The structure to destroy.

PmStatus pmFindByConflicts PmDatabase   db,
const char *    conflicts,
PmMatches **    matches
 

Searches for a package by the specified conflicting dependency.

Parameters:
db  The database to search.
conflicts  The conflicting dependency to search with.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmStatus pmFindByFile PmDatabase   db,
const char *    file,
PmMatches **    matches
 

Searches for a package by file.

Parameters:
db  The database to search.
file  The file to search for.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmStatus pmFindByGroup PmDatabase   db,
const char *    group,
PmMatches **    matches
 

Searches for a package by group.

Parameters:
db  The database to search.
group  The group to search for.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmStatus pmFindByName PmDatabase   db,
const char *    name,
PmMatches **    matches
 

Searches for a package by name.

Parameters:
db  The database to search.
name  The name of the package to search for.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmStatus pmFindByProvides PmDatabase   db,
const char *    provides,
PmMatches **    matches
 

Searches for a package by the specified provided dependency.

Parameters:
db  The database to search.
provides  The provided dependency to search with.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmStatus pmFindByRequires PmDatabase   db,
const char *    requires,
PmMatches **    matches
 

Searches for a package by the specified required dependency.

Parameters:
db  The database to search.
requires  The required dependency to search with.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmPackage* pmFirstMatch PmMatches   matches
 

Returns the first matched package.

The returned package must be freed.

Parameters:
matches  The matches.
Returns:
The first matched package.
See also:
pmNextMatch()

PmStatus pmGetAllPackages PmDatabase   db,
PmMatches **    matches
 

Returns all packages in the database.

Parameters:
db  The database.
matches  The returned PmMatches structure.
Returns:
The status of the search.

PmStatus pmInstallBatch PmDatabase   db,
PmBatch   batch,
char    checkDeps,
PmTransactionError **    error
 

Installs a batch of packages and adds them to the database.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to add to.
batch  The batch to install.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmUninstallBatch()

PmStatus pmInstallPackage PmDatabase   db,
PmPackage   package,
char    checkDeps,
PmTransactionError **    error
 

Installs a package and adds it to the database.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to add the package to.
package  The package to install.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmUninstallPackage()

PmMatches* pmNewMatches PmDatabase   db
 

Creates a new PmMatches structure.

Parameters:
db  The database associated with these matches.
Returns:
A new PmMatches structure.

PmPackage* pmNextMatch PmMatches   matches
 

Returns the next matched package.

The returned package must be freed.

Parameters:
matches  The matches.
Returns:
The next matched package.
See also:
pmFirstMatch()

PmDatabase* pmOpenDatabase const char *    type,
PmAccessMode    mode
 

Opens a database of the specified type.

The type parameter must match one of the installed package modules. These are located in /usr/lib/packman/database, /usr/local/lib/packman/database, and/or $HOME/.gnupdate/packman/database.

Parameters:
type  The type of database.
mode  The access mode.
Returns:
A PmDatabase structure representing the opened database, or NULL if unsuccessful.

PmStatus pmRebuildDatabase const char *    type
 

Rebuilds the database of the specified type.

The type parameter must match one of the installed package modules. These are located in /usr/lib/packman/database, /usr/local/lib/packman/database, and/or $HOME/.gnupdate/packman/database.

Note:
The database should be closed before you attempt to rebuild it.
Parameters:
type  The type of database.
Returns:
The status of the operation.

PmStatus pmUninstallBatch PmDatabase   db,
PmBatch   batch,
char    checkDeps,
PmTransactionError **    error
 

Uninstalls a batch of packages and removes them the database.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to remove from.
batch  The batch to uninstall.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmInstallBatch()

PmStatus pmUninstallPackage PmDatabase   db,
PmPackage   package,
char    checkDeps,
PmTransactionError **    error
 

Uninstalls a package and removes it from the database.

Under almost all circumstances, you should specify 1 for checkDeps.

Parameters:
db  The database to add the package to.
package  The package to uninstall.
checkDeps  1 if dependency checking should be enabled. 0 otherwise.
error  Returned errors, if any. The result of this can be NULL if successful, or if the error does not lie in anything package-related (i.e., missing database function).
Returns:
The status of this operation.
See also:
pmInstallPackage()


Generated on Tue Jul 2 03:15:23 2002 for libpackman by doxygen1.2.15-20020430