2001-04-21 10:26:15 +00:00
|
|
|
#include <stdlib.h>
|
2001-04-15 12:38:12 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "libbb.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns a [multi-line] package field
|
|
|
|
*/
|
|
|
|
extern char *read_package_field(const char *package_buffer)
|
|
|
|
{
|
|
|
|
int field_length = 0;
|
|
|
|
int buffer_length = 0;
|
|
|
|
|
2001-07-11 15:43:03 +00:00
|
|
|
if (package_buffer == NULL) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
2001-04-15 12:38:12 +00:00
|
|
|
buffer_length = strlen(package_buffer);
|
2001-07-11 15:43:03 +00:00
|
|
|
field_length = strcspn(package_buffer, "\n");
|
|
|
|
while (field_length < buffer_length) {
|
2001-04-15 12:38:12 +00:00
|
|
|
if (package_buffer[field_length + 1] != ' ') {
|
2001-07-11 15:43:03 +00:00
|
|
|
return(xstrndup(package_buffer, field_length));
|
|
|
|
}
|
|
|
|
field_length++;
|
|
|
|
field_length += strcspn(&package_buffer[field_length], "\n");
|
2001-04-15 12:38:12 +00:00
|
|
|
}
|
2001-07-11 15:43:03 +00:00
|
|
|
return(xstrdup(package_buffer));
|
2001-04-15 12:38:12 +00:00
|
|
|
}
|
|
|
|
|