From ce1cfe7ce2042f7ff959e0a71760f926e1b47aeb Mon Sep 17 00:00:00 2001 From: "graham.gower" Date: Wed, 9 Dec 2009 06:37:09 +0000 Subject: [PATCH] Implement list all command. Print full version string. git-svn-id: http://opkg.googlecode.com/svn/trunk@478 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- tests/libopkg_test.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/libopkg_test.c b/tests/libopkg_test.c index 073a9a7..2b42a2d 100644 --- a/tests/libopkg_test.c +++ b/tests/libopkg_test.c @@ -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]); -- 2.25.1