dpkg-deb -f and partial -I commands, adds 600 bytes
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index 3bec8cf..7c5a5de 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -20,11 +20,11 @@
 
 extern int dpkg_deb_main(int argc, char **argv)
 {
-	char *target_dir;
+	char *argument = NULL;
 	int opt = 0;
 	int optflag = 0;	
 	
-	while ((opt = getopt(argc, argv, "cetXxl")) != -1) {
+	while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
 		switch (opt) {
 			case 'c':
 				optflag |= extract_contents;
@@ -32,6 +32,9 @@
 			case 'e':
 				optflag |= extract_control;
 				break;
+			case 'f':
+				optflag |= extract_field;
+				break;
 			case 't':
 				optflag |= extract_fsys_tarfile;
 				break;
@@ -41,13 +44,9 @@
 			case 'x':
 				optflag |= extract_extract;
 				break;
-			case 'l':
-				optflag |= extract_list;
-				break;
-/*			case 'I':
+			case 'I':
 				optflag |= extract_info;
 				break;
-*/
 			default:
 				show_usage();
 		}
@@ -61,26 +60,33 @@
 		case (extract_control):
 		case (extract_extract):
 		case (extract_verbose_extract):
+			/* argument is a dir name */
 			if ( (optind + 1) == argc ) {
-				target_dir = (char *) xmalloc(7);
-				strcpy(target_dir, "DEBIAN");
+				argument = xstrdup("DEBIAN");
 			} else {
-				target_dir = (char *) xmalloc(strlen(argv[optind + 1]) + 1);
-				strcpy(target_dir, argv[optind + 1]);
+				argument = xstrdup(argv[optind + 1]);
 			}
 			break;
+		case (extract_field):
+			/* argument is a control field name */
+			if ((optind + 1) != argc) {
+				argument = xstrdup(argv[optind + 1]);				
+			}
+			break;
+		case (extract_info):
+			/* argument is a control field name */
+			if ((optind + 1) != argc) {
+				argument = xstrdup(argv[optind + 1]);
+				break;
+			} else {
+				error_msg("-I currently requires a filename to be specifies");
+				return(EXIT_FAILURE);
+			}
+			/* argument is a filename */
 		default:
-			target_dir = NULL;
 	}
 
-	deb_extract(argv[optind], optflag, target_dir);
-/*	else if (optflag & dpkg_deb_info) {
-		extract_flag = TRUE;
-		extract_to_stdout = TRUE;
-		strcpy(ar_filename, "control.tar.gz");
-		extract_list = argv+optind+1;
-		printf("list one is [%s]\n",extract_list[0]);
-	}
-*/
+	deb_extract(argv[optind], optflag, argument);
+
 	return(EXIT_SUCCESS);
 }
diff --git a/dpkg_deb.c b/dpkg_deb.c
index 3bec8cf..7c5a5de 100644
--- a/dpkg_deb.c
+++ b/dpkg_deb.c
@@ -20,11 +20,11 @@
 
 extern int dpkg_deb_main(int argc, char **argv)
 {
-	char *target_dir;
+	char *argument = NULL;
 	int opt = 0;
 	int optflag = 0;	
 	
-	while ((opt = getopt(argc, argv, "cetXxl")) != -1) {
+	while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
 		switch (opt) {
 			case 'c':
 				optflag |= extract_contents;
@@ -32,6 +32,9 @@
 			case 'e':
 				optflag |= extract_control;
 				break;
+			case 'f':
+				optflag |= extract_field;
+				break;
 			case 't':
 				optflag |= extract_fsys_tarfile;
 				break;
@@ -41,13 +44,9 @@
 			case 'x':
 				optflag |= extract_extract;
 				break;
-			case 'l':
-				optflag |= extract_list;
-				break;
-/*			case 'I':
+			case 'I':
 				optflag |= extract_info;
 				break;
-*/
 			default:
 				show_usage();
 		}
@@ -61,26 +60,33 @@
 		case (extract_control):
 		case (extract_extract):
 		case (extract_verbose_extract):
+			/* argument is a dir name */
 			if ( (optind + 1) == argc ) {
-				target_dir = (char *) xmalloc(7);
-				strcpy(target_dir, "DEBIAN");
+				argument = xstrdup("DEBIAN");
 			} else {
-				target_dir = (char *) xmalloc(strlen(argv[optind + 1]) + 1);
-				strcpy(target_dir, argv[optind + 1]);
+				argument = xstrdup(argv[optind + 1]);
 			}
 			break;
+		case (extract_field):
+			/* argument is a control field name */
+			if ((optind + 1) != argc) {
+				argument = xstrdup(argv[optind + 1]);				
+			}
+			break;
+		case (extract_info):
+			/* argument is a control field name */
+			if ((optind + 1) != argc) {
+				argument = xstrdup(argv[optind + 1]);
+				break;
+			} else {
+				error_msg("-I currently requires a filename to be specifies");
+				return(EXIT_FAILURE);
+			}
+			/* argument is a filename */
 		default:
-			target_dir = NULL;
 	}
 
-	deb_extract(argv[optind], optflag, target_dir);
-/*	else if (optflag & dpkg_deb_info) {
-		extract_flag = TRUE;
-		extract_to_stdout = TRUE;
-		strcpy(ar_filename, "control.tar.gz");
-		extract_list = argv+optind+1;
-		printf("list one is [%s]\n",extract_list[0]);
-	}
-*/
+	deb_extract(argv[optind], optflag, argument);
+
 	return(EXIT_SUCCESS);
 }
diff --git a/include/libbb.h b/include/libbb.h
index bc8e3c5..515bf27 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -235,10 +235,11 @@
 	extract_extract = 8,
 	extract_verbose_extract = 16,
 	extract_list = 32,
-	extract_fsys_tarfile = 64
+	extract_fsys_tarfile = 64,
+	extract_field = 128
 } extract_function_t;
 extern int deb_extract(const char *package_filename, int function, char *target_dir);
-extern int untar(FILE *src_tar_file, int untar_function, char *base_path);
+extern int untar(FILE *src_tar_file, const int untar_function, const char *argument);
 
 extern int unzip(FILE *l_in_file, FILE *l_out_file);
 extern void gz_close(int gunzip_pid);
diff --git a/libbb/deb_extract.c b/libbb/deb_extract.c
index d3e6153..0f5a570 100644
--- a/libbb/deb_extract.c
+++ b/libbb/deb_extract.c
@@ -30,7 +30,11 @@
 #include <signal.h>
 #include "libbb.h"
 
-extern int deb_extract(const char *package_filename, int function, char *target_dir)
+/*
+ * The contents of argument depend on the value of function.
+ * It is either a dir name or a control file or field name(see dpkg_deb.c)
+ */
+extern int deb_extract(const char *package_filename, int function, char *argument)
 {
 
 	FILE *deb_file, *uncompressed_file;
@@ -41,6 +45,7 @@
 	switch (function) {
 		case (extract_info):
 		case (extract_control):
+		case (extract_field):
 			ared_file = xstrdup("control.tar.gz");
 			break;
 		default:
@@ -70,7 +75,7 @@
 	if (function & extract_fsys_tarfile) {
 		copy_file_chunk(uncompressed_file, stdout, -1);
 	} else {
-		untar(uncompressed_file, function, target_dir);
+		untar(uncompressed_file, function, argument);
 	}
 	/* we are deliberately terminating the child so we can safely ignore this */
 	gz_close(gunzip_pid);
diff --git a/libbb/libbb.h b/libbb/libbb.h
index bc8e3c5..515bf27 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -235,10 +235,11 @@
 	extract_extract = 8,
 	extract_verbose_extract = 16,
 	extract_list = 32,
-	extract_fsys_tarfile = 64
+	extract_fsys_tarfile = 64,
+	extract_field = 128
 } extract_function_t;
 extern int deb_extract(const char *package_filename, int function, char *target_dir);
-extern int untar(FILE *src_tar_file, int untar_function, char *base_path);
+extern int untar(FILE *src_tar_file, const int untar_function, const char *argument);
 
 extern int unzip(FILE *l_in_file, FILE *l_out_file);
 extern void gz_close(int gunzip_pid);
diff --git a/libbb/untar.c b/libbb/untar.c
index d3e424e..b768c0b 100644
--- a/libbb/untar.c
+++ b/libbb/untar.c
@@ -22,7 +22,7 @@
 #include <unistd.h>
 #include "libbb.h"
 
-extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
+extern int untar(FILE *src_tar_file, const int untar_function, const char *argument)
 {
 	typedef struct raw_tar_header {
         char name[100];               /*   0-99 */
@@ -101,37 +101,18 @@
 		if (size % 512 != 0) {
 			next_header_offset += (512 - size % 512);
 		}
-		/*
-		 * seek to start of control file, return length
-		 *
-		if (dpkg_untar_function & dpkg_untar_seek_control) {
-			if ((raw_tar_header.typeflag == '0') || (raw_tar_header.typeflag == '\0')) {
-				char *tar_filename;
 
-				tar_filename = strrchr(raw_tar_header.name, '/');
-				if (tar_filename == NULL) {
-					tar_filename = strdup(raw_tar_header.name);
-				} else {
-					tar_filename++;
-				}
-
-				if (strcmp(tar_filename, "control") == 0) {
-					return(size);
-				}
-			}
-
-		}
-*/
 		if (untar_function & (extract_contents | extract_verbose_extract)) {
 			printf("%s\n", raw_tar_header.name);
 		}
 
 		/* extract files */
-		if (base_path != NULL) {
-			dir = xmalloc(strlen(raw_tar_header.name) + strlen(base_path) + 2);
-			sprintf(dir, "%s/%s", base_path, raw_tar_header.name);
+		if (untar_function & (extract_extract | extract_verbose_extract | extract_control)) {
+			dir = xmalloc(strlen(raw_tar_header.name) + strlen(argument) + 2);
+			sprintf(dir, "%s/%s", argument, raw_tar_header.name);
 			create_path(dir, 0777);
 		}
+
 		switch (raw_tar_header.typeflag ) {
 			case '0':
 			case '\0':
@@ -145,14 +126,28 @@
 						uncompressed_count += size;
 						fclose(dst_file);
 					}
-					while (uncompressed_count < next_header_offset) {
-						if (fgetc(src_tar_file) == EOF) {
-							perror_msg("untar");
-							break;
+					else if (untar_function & extract_info) {
+						if (strstr(raw_tar_header.name, argument) != NULL) {
+							copy_file_chunk(src_tar_file, stdout, (unsigned long long) size);
+							uncompressed_count += size;
 						}
-						uncompressed_count++;
 					}
-					uncompressed_count += size;
+					else if (untar_function & extract_field) {
+						if (strstr(raw_tar_header.name, "./control") != NULL) {
+							char *line;
+							while ((line = get_line_from_file(src_tar_file)) != NULL) {
+								uncompressed_count += strlen(line);
+								if (argument == NULL) {
+									printf("%s",line);
+								}
+								else if (strncmp(line, argument, strlen(argument)) == 0) {
+									char *file_ptr;
+									file_ptr = strstr(line, ": ");
+									printf("%s", file_ptr + 2);
+								}
+ 							}
+						}
+					}
 					break;
 				}
 			case '5':
@@ -193,6 +188,17 @@
 				free(dir);
 				return(EXIT_FAILURE);
 		}
+
+		/*
+		 * Seek to start of next block, cant use fseek as unzip() does support it
+		 */
+		while (uncompressed_count < next_header_offset) {
+			if (fgetc(src_tar_file) == EOF) {
+				break;
+			}
+			uncompressed_count++;
+		}
+
 //		free(dir);
 	}
 	return(EXIT_SUCCESS);