mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-04-05 14:45:20 +05:30
freadln: add more flavors
This commit is contained in:
parent
39de2a67d8
commit
ae4a82c2aa
@ -79,6 +79,15 @@ int freadln(FILE* f, char** output, size_t* length_out) {
|
||||
return freadln_OK;
|
||||
}
|
||||
|
||||
inline char* freadln_ptr(FILE* f, size_t* length_out) {
|
||||
char* output = NULL;
|
||||
|
||||
if (freadln(f, &output, length_out) == freadln_OK)
|
||||
return output;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
# include <ctype.h>
|
||||
# include <inttypes.h>
|
||||
|
@ -30,6 +30,12 @@ enum freadln_status {
|
||||
} while (0)
|
||||
|
||||
int freadln(FILE* f, char** output, size_t* length_out);
|
||||
char* freadln_ptr(FILE* f, size_t* length_out);
|
||||
#define freadln_stream(f, output) freadln(f, output, NULL)
|
||||
#define freadln_ptr_stream(f) freadln_ptr(f, NULL)
|
||||
#define finreadln(output, length_out) freadln(stdin, output, length_out)
|
||||
#define finreadln_ptr(length_out) freadln_ptr(stdin, length_out)
|
||||
#define finreadln_stream(output) freadln(stdin, output, NULL)
|
||||
#define finreadln_ptr_stream() freadln_ptr(stdin, NULL)
|
||||
|
||||
#endif /* _FREADLN_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user