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