From 84d0fe25287ae0aaa9a1b9ff19b2ce61afbb173e Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Fri, 26 Nov 2010 08:19:20 +0100
Source: deets
Version: 0.0.7-1
Status: applied
Debbug: 620834
Subject: [PATCH 4/5] Switch to new libdpkg 1.16.0 API

---
 luau.c |   23 +++++------------------
 1 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/luau.c b/luau.c
index b086004..b384026 100644
--- a/luau.c
+++ b/luau.c
@@ -18,7 +18,6 @@
 
 #include <stdio.h>
 
-#include <setjmp.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -69,7 +68,7 @@ dpkg_status (lua_State * L)
 	  lua_error (L);
 	}
 
-      p = findpackage (lua_tostring (L, i));
+      p = pkg_db_find (lua_tostring (L, i));
       switch (p->status)
 	{
 	case stat_notinstalled:
@@ -113,7 +112,7 @@ dpkg_pkglist (lua_State * L)
 
   lua_newtable (L);
 
-  for (iter = iterpkgstart (); (pkg = iterpkgnext (iter));)
+  for (iter = pkg_db_iter_new (); (pkg = pkg_db_iter_next (iter));)
     {
       lua_pushnumber (L, ++i);
       lua_pushstring (L, pkg->name);
@@ -137,7 +136,7 @@ dpkg_conffilelist (lua_State * L)
       lua_error (L);
     }
 
-  p = findpackage (lua_tostring (L, 1));
+  p = pkg_db_find (lua_tostring (L, 1));
   if (!(c = p->installed.conffiles))
     {
       lua_pushnil (L);
@@ -359,8 +358,6 @@ main (int argc, char **argv)
   int c;
   int digit_optind = 0;
 
-  jmp_buf ejbuf;
-
   int status;
 
   char *tempdir;
@@ -372,19 +369,9 @@ main (int argc, char **argv)
   fprintf (stderr, "This is free software, and you are welcome to redistribute it\n");
   fprintf (stderr, "under certain conditions.\n");
 
-  do
-    {
-      if (setjmp (ejbuf))
-	{
-	  error_unwind (ehflag_bombout);
-	  exit (2);
-	}
-      push_error_handler (&ejbuf, print_error_fatal, NULL);
-    }
-  while (0);
-
+  push_error_context ();
 
-  modstatdb_init ("/var/lib/dpkg", msdbrw_readonly | msdbrw_noavail);
+  modstatdb_open (msdbrw_readonly); /* Use default dpkg db directory. */
 
   while (1)
     {
-- 
1.7.4.1

