blob: 3715230feab3a003b3766867e1715a1fed605c38 [file] [log] [blame]
Glenn L McGrathee0d93e2001-04-21 10:26:15 +00001#include <stdlib.h>
Glenn L McGrath5faef742001-04-15 12:38:12 +00002#include <string.h>
3#include "libbb.h"
4
5/*
6 * Returns a [multi-line] package field
7 */
8extern char *read_package_field(const char *package_buffer)
9{
Glenn L McGrath5faef742001-04-15 12:38:12 +000010 int field_length = 0;
11 int buffer_length = 0;
12
Glenn L McGrath481d19b2001-07-11 15:43:03 +000013 if (package_buffer == NULL) {
Glenn L McGrath5faef742001-04-15 12:38:12 +000014 return(NULL);
Glenn L McGrath5faef742001-04-15 12:38:12 +000015 }
Glenn L McGrath481d19b2001-07-11 15:43:03 +000016 buffer_length = strlen(package_buffer);
17 field_length = strcspn(package_buffer, "\n");
18 while (field_length < buffer_length) {
19 if (package_buffer[field_length + 1] != ' ') {
20 return(xstrndup(package_buffer, field_length));
21 }
22 field_length++;
23 field_length += strcspn(&package_buffer[field_length], "\n");
24 }
25 return(xstrdup(package_buffer));
Glenn L McGrath5faef742001-04-15 12:38:12 +000026}
27