diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-09-25 12:18:49 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-09-25 12:18:49 +0000 |
commit | 97516fc3a60aae3d9cd30c3f61192e5ddd7d3170 (patch) | |
tree | 0c4f651f4840ba7e21c6c706c2e170d9ad9fb3ff | |
parent | 6c4dadefb611d8fa3336fba9f4dfadceb7beea88 (diff) | |
download | busybox-w32-97516fc3a60aae3d9cd30c3f61192e5ddd7d3170.tar.gz busybox-w32-97516fc3a60aae3d9cd30c3f61192e5ddd7d3170.tar.bz2 busybox-w32-97516fc3a60aae3d9cd30c3f61192e5ddd7d3170.zip |
- add dpkg -l <packagepattern> (Peter Korsgaard)
-rw-r--r-- | archival/dpkg.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index f31a7f017..1bc8d27ce 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "libbb.h" | 27 | #include "libbb.h" |
28 | #include <fnmatch.h> | ||
28 | #include "unarchive.h" | 29 | #include "unarchive.h" |
29 | 30 | ||
30 | /* note: if you vary hash_prime sizes be aware, | 31 | /* note: if you vary hash_prime sizes be aware, |
@@ -1293,7 +1294,7 @@ static void free_array(char **array) | |||
1293 | * the status_hashtable to retrieve the info. This results in smaller code than | 1294 | * the status_hashtable to retrieve the info. This results in smaller code than |
1294 | * scanning the status file. The resulting list, however, is unsorted. | 1295 | * scanning the status file. The resulting list, however, is unsorted. |
1295 | */ | 1296 | */ |
1296 | static void list_packages(void) | 1297 | static void list_packages(const char *pattern) |
1297 | { | 1298 | { |
1298 | int i; | 1299 | int i; |
1299 | 1300 | ||
@@ -1314,6 +1315,9 @@ static void list_packages(void) | |||
1314 | name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name]; | 1315 | name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name]; |
1315 | vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version]; | 1316 | vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version]; |
1316 | 1317 | ||
1318 | if (pattern && fnmatch(pattern, name_str, 0)) | ||
1319 | continue; | ||
1320 | |||
1317 | /* get abbreviation for status field 1 */ | 1321 | /* get abbreviation for status field 1 */ |
1318 | s1 = stat_str[0] == 'i' ? 'i' : 'r'; | 1322 | s1 = stat_str[0] == 'i' ? 'i' : 'r'; |
1319 | 1323 | ||
@@ -1626,7 +1630,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv) | |||
1626 | 1630 | ||
1627 | /* if the list action was given print the installed packages and exit */ | 1631 | /* if the list action was given print the installed packages and exit */ |
1628 | if (opt & OPT_list_installed) { | 1632 | if (opt & OPT_list_installed) { |
1629 | list_packages(); | 1633 | list_packages(argv[0]); |
1630 | return EXIT_SUCCESS; | 1634 | return EXIT_SUCCESS; |
1631 | } | 1635 | } |
1632 | 1636 | ||