diff options
author | Glenn L McGrath | 2001-04-15 12:38:12 +0000 |
---|---|---|
committer | Glenn L McGrath | 2001-04-15 12:38:12 +0000 |
commit | 5faef74bae317156c9c199b942f018683080a77e (patch) | |
tree | 6b307d52c36999d2be077760138e8949af100ebd | |
parent | 65708e4cd1b234501aec3af0970f21ad6736aa44 (diff) | |
download | busybox-5faef74bae317156c9c199b942f018683080a77e.zip busybox-5faef74bae317156c9c199b942f018683080a77e.tar.gz |
Reads a field from a debian control (status or available) file, handles multi-line fields.
-rw-r--r-- | libbb/read_package_field.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libbb/read_package_field.c b/libbb/read_package_field.c new file mode 100644 index 0000000..4ba0bc6 --- /dev/null +++ b/libbb/read_package_field.c @@ -0,0 +1,31 @@ +//#include <stdio.h> +#include <string.h> +#include "libbb.h" + +/* + * Returns a [multi-line] package field + */ +extern char *read_package_field(const char *package_buffer) +{ + char *field = NULL; + int field_length = 0; + int buffer_length = 0; + + buffer_length = strlen(package_buffer); + field = xcalloc(1, buffer_length + 1); + + while ((field = strchr(&package_buffer[field_length], '\n')) != NULL) { + field_length = buffer_length - strlen(field); + if (package_buffer[field_length + 1] != ' ') { + break; + } else { + field_length++; + } + } + if (field_length == 0) { + return(NULL); + } else { + return(xstrndup(package_buffer, field_length)); + } +} + |