freewrt_1_0
freewrt_2_0
| Line | |
|---|
| 1 | #define _GNU_SOURCE
|
|---|
| 2 | #include <sys/types.h>
|
|---|
| 3 | #include <sys/cdefs.h>
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 | #include <string.h>
|
|---|
| 6 |
|
|---|
| 7 | #ifdef __GLIBC__
|
|---|
| 8 | char *
|
|---|
| 9 | fgetln (stream, len)
|
|---|
| 10 | FILE *stream;
|
|---|
| 11 | size_t *len;
|
|---|
| 12 | {
|
|---|
| 13 | char *line=NULL;
|
|---|
| 14 | size_t nread = 0;
|
|---|
| 15 |
|
|---|
| 16 | while (nread == 1) {
|
|---|
| 17 | nread = getline (&line, len, stream);
|
|---|
| 18 | if (nread == -1)
|
|---|
| 19 | return NULL;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | (*len)--; /* get rid of the trailing \0, fgetln
|
|---|
| 23 | does not have it */
|
|---|
| 24 |
|
|---|
| 25 | return line;
|
|---|
| 26 | }
|
|---|
| 27 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.