Updates from both Vladimir and Larry
[oweals/busybox.git] / dpkg_deb.c
index 7c5a5de5897a76f753a4751c4dec0c27fd691702..17b5476d0ddefc1f4ab7d1114a788b1af1cc1887 100644 (file)
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <getopt.h>
 #include "busybox.h"
 
 extern int dpkg_deb_main(int argc, char **argv)
 {
        char *argument = NULL;
+       char *output_buffer = NULL;
        int opt = 0;
        int optflag = 0;        
        
@@ -86,7 +88,22 @@ extern int dpkg_deb_main(int argc, char **argv)
                default:
        }
 
-       deb_extract(argv[optind], optflag, argument);
+       output_buffer = deb_extract(argv[optind], optflag, argument, NULL);
+
+       if (optflag & extract_field) {
+               char *field = NULL;
+               int field_length = 0;
+               int field_start = 0;
+
+               while ((field = read_package_field(&output_buffer[field_start])) != NULL) {
+                       field_length = strlen(field);
+                       field_start += (field_length + 1);
+                       if (strstr(field, argument) == field) {
+                               puts(field + strlen(argument) + 2);
+                       }
+                       free(field);
+               }
+       }
 
        return(EXIT_SUCCESS);
 }