Implement list all command. Print full version string.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 9 Dec 2009 06:37:09 +0000 (06:37 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 9 Dec 2009 06:37:09 +0000 (06:37 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@478 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

tests/libopkg_test.c

index 073a9a7ca392483701244f8665ee854cf142ba30..2b42a2d1e825ae6fc4f4716a34991c6565dacdab 100644 (file)
@@ -25,10 +25,24 @@ char *errors[10] = {
 void
 progress_callback (const opkg_progress_data_t *progress, void *data)
 {
-  printf ("\r%s %3d%%", (char*) data, progress->percentage);
+  printf ("\r%s %3d%%\n", (char*) data, progress->percentage);
   fflush (stdout);
 }
 
+static void list_pkg(pkg_t *pkg)
+{
+  char *v = pkg_version_str_alloc(pkg);
+  printf ("%s - %s\n", pkg->name, v);
+  free(v);
+}
+
+void
+package_list_installed_callback (pkg_t *pkg, void *data)
+{
+  if (pkg->state_status == SS_INSTALLED)
+    list_pkg(pkg);
+}
+
 void
 package_list_callback (pkg_t *pkg, void *data)
 {
@@ -53,7 +67,7 @@ package_list_callback (pkg_t *pkg, void *data)
 void
 package_list_upgradable_callback (pkg_t *pkg, void *data)
 {
-  printf ("%s - %s\n", pkg->name, pkg->version);
+  list_pkg(pkg);
 }
 
 void
@@ -213,6 +227,7 @@ main (int argc, char **argv)
             break;
           case 'i':
             printf ("Listing installed packages...\n");
+            opkg_list_packages (package_list_installed_callback, NULL);
             break;
           default:
             printf ("Unknown list option \"%s\"", argv[2]);