Просмотр исходного кода

libdpkg: Add new package status setters

Guillem Jover лет назад: 14
Родитель
Сommit
c09a3a9797
3 измененных файлов с 59 добавлено и 2 удалено
  1. 5 0
      lib/dpkg/libdpkg.map
  2. 46 1
      lib/dpkg/pkg.c
  3. 8 1
      lib/dpkg/pkg.h

+ 5 - 0
lib/dpkg/libdpkg.map

@@ -200,6 +200,11 @@ LIBDPKG_PRIVATE {
 	pkg_blank;
 	pkgbin_blank;
 	pkg_name_is_illegal;
+	pkg_set_status;
+	pkg_set_eflags;
+	pkg_clear_eflags;
+	pkg_reset_eflags;
+	pkg_set_want;
 	pkg_is_informative;
 	copy_dependency_links;
 	pkg_sorter_by_name;

+ 46 - 1
lib/dpkg/pkg.c

@@ -3,7 +3,7 @@
  * pkg.c - primitives for pkg handling
  *
  * Copyright © 1995, 1996 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2009-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2009-2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,51 @@
 #include <dpkg/dpkg-db.h>
 #include <dpkg/pkg.h>
 
+/**
+ * Set the package installation status.
+ */
+void
+pkg_set_status(struct pkginfo *pkg, enum pkgstatus status)
+{
+	pkg->status = status;
+}
+
+/**
+ * Set the specified flags to 1 in the package error flags.
+ */
+void
+pkg_set_eflags(struct pkginfo *pkg, enum pkgeflag eflag)
+{
+	pkg->eflag |= eflag;
+}
+
+/**
+ * Clear the specified flags to 0 in the package error flags.
+ */
+void
+pkg_clear_eflags(struct pkginfo *pkg, enum pkgeflag eflag)
+{
+	pkg->eflag &= ~eflag;
+}
+
+/**
+ * Reset the package error flags to 0.
+ */
+void
+pkg_reset_eflags(struct pkginfo *pkg)
+{
+	pkg->eflag = eflag_ok;
+}
+
+/**
+ * Set the package selection status.
+ */
+void
+pkg_set_want(struct pkginfo *pkg, enum pkgwant want)
+{
+	pkg->want = want;
+}
+
 void
 pkgbin_blank(struct pkgbin *pkgbin)
 {

+ 8 - 1
lib/dpkg/pkg.h

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * pkg.h - primitives for pkg handling
  *
- * Copyright © 2009 Guillem Jover <guillem@debian.org>
+ * Copyright © 2009,2011-2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 #define LIBDPKG_PKG_H
 
 #include <dpkg/macros.h>
+#include <dpkg/dpkg-db.h>
 
 DPKG_BEGIN_DECLS
 
@@ -29,6 +30,12 @@ typedef int pkg_sorter_func(const void *a, const void *b);
 
 int pkg_sorter_by_name(const void *a, const void *b);
 
+void pkg_set_status(struct pkginfo *pkg, enum pkgstatus status);
+void pkg_set_eflags(struct pkginfo *pkg, enum pkgeflag eflag);
+void pkg_clear_eflags(struct pkginfo *pkg, enum pkgeflag eflag);
+void pkg_reset_eflags(struct pkginfo *pkg);
+void pkg_set_want(struct pkginfo *pkg, enum pkgwant want);
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_PKG_H */