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