ae38ad68eaec06f618dc24153dbc815d1de2efb9
[openwrt/svn-archive/archive.git] / tools / mkimage / patches / 100-portability.patch
1 --- a/tools/kwbimage.c
2 +++ b/tools/kwbimage.c
3 @@ -206,6 +206,28 @@ INVL_DATA:
4 exit (EXIT_FAILURE);
5 }
6
7 +#ifndef __GLIBC__
8 +static ssize_t
9 +getline(char **line, size_t *len, FILE *fd)
10 +{
11 + char *tmp;
12 + int tmplen;
13 +
14 + tmp = fgetln(fd, &tmplen);
15 + if (!tmp)
16 + return -1;
17 +
18 + if (!*line || tmplen > *len) {
19 + *len = tmplen + 1;
20 + *line = realloc(*line, *len);
21 + }
22 +
23 + strncpy(*line, tmp, tmplen);
24 + line[tmplen] = 0;
25 + return tmplen;
26 +}
27 +#endif
28 +
29 /*
30 * this function sets the kwbimage header by-
31 * 1. Abstracting input command line arguments data