blob: 246285f8ec4ada00a921c55a6848ebd890c27825 [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{
10 char *field = NULL;
11 int field_length = 0;
12 int buffer_length = 0;
13
14 buffer_length = strlen(package_buffer);
Glenn L McGrath5faef742001-04-15 12:38:12 +000015
16 while ((field = strchr(&package_buffer[field_length], '\n')) != NULL) {
17 field_length = buffer_length - strlen(field);
18 if (package_buffer[field_length + 1] != ' ') {
19 break;
20 } else {
21 field_length++;
22 }
23 }
24 if (field_length == 0) {
25 return(NULL);
26 } else {
27 return(xstrndup(package_buffer, field_length));
28 }
29}
30