Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-09 20:16:00 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-01-09 20:16:00 +0000
commitfd6ce1f4cb8011756f7c07d28c5e06ce0be1acb7 (patch)
tree1e735f251fdfb3413085862bf77f851ec0ce3eb0 /lib/libalpm/package.c
parent45a7e57f6c4c375d6b8716e2dfc15da592ec147b (diff)
- merged pkg_new and pkg_dummy functions
- renamed _alpm_log_action to _alpm_logaction
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index aa331bb4..784b9b07 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -35,14 +35,22 @@
#include "package.h"
#include "alpm.h"
-pmpkg_t *pkg_new()
+pmpkg_t *pkg_new(const char *name, const char *version)
{
pmpkg_t* pkg = NULL;
MALLOC(pkg, sizeof(pmpkg_t));
- pkg->name[0] = '\0';
- pkg->version[0] = '\0';
+ if(name && name[0] != 0) {
+ STRNCPY(pkg->name, name, PKG_NAME_LEN);
+ } else {
+ pkg->name[0] = '\0';
+ }
+ if(version && version[0] != 0) {
+ STRNCPY(pkg->version, version, PKG_VERSION_LEN);
+ } else {
+ pkg->version[0] = '\0';
+ }
pkg->desc[0] = '\0';
pkg->url[0] = '\0';
pkg->license = NULL;
@@ -133,27 +141,6 @@ void pkg_free(pmpkg_t *pkg)
return;
}
-/* Create a dummy package struct that only contains the package
- * name and version. This is useful when we're only passing
- * name/version data, but it needs to be wrapped in a pmpkg_t
- */
-pmpkg_t* pkg_dummy(const char *name, const char *version)
-{
- pmpkg_t *pkg = pkg_new();
- if(pkg == NULL) {
- return(NULL);
- }
-
- if(name) {
- STRNCPY(pkg->name, name, PKG_NAME_LEN);
- }
- if(version) {
- STRNCPY(pkg->version, version, PKG_VERSION_LEN);
- }
-
- return(pkg);
-}
-
/* Parses the package description file for the current package
*
* Returns: 0 on success, 1 on error
@@ -262,7 +249,7 @@ pmpkg_t *pkg_load(char *pkgfile)
RET_ERR(PM_ERR_NOT_A_FILE, NULL);
}
- info = pkg_new();
+ info = pkg_new(NULL, NULL);
if(info == NULL) {
tar_close(tar);
RET_ERR(PM_ERR_MEMORY, NULL);