1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2025-01-11 02:42:09 +05:30
gists/c-programming/io/freadln.h

33 lines
793 B
C
Raw Normal View History

2024-02-20 01:38:45 +03:00
/*
* freadln.h
*
* Author: Intel A80486DX2-66
* License: Creative Commons Zero 1.0 Universal
*/
#ifndef _FREADLN_H
#define _FREADLN_H
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
typedef size_t freadln_length_type;
enum freadln_status {
2024-03-10 14:19:29 +03:00
freadln_OK,
freadln_EOF,
2024-02-20 01:38:45 +03:00
freadln_ERROR
};
2024-03-10 15:25:59 +03:00
#define freadln_epilogue do { \
2024-02-20 01:38:45 +03:00
(*output)[length] = '\0'; \
2024-03-10 14:14:02 +03:00
if (length_out != NULL) \
2024-02-20 01:38:45 +03:00
*length_out = length; \
2024-02-22 19:09:37 +03:00
} while (0)
2024-02-20 01:38:45 +03:00
int freadln(FILE* f, char** output, size_t* length_out);
#define finreadln(output, length_out) freadln(stdin, output, length_out)
2024-02-22 19:09:37 +03:00
2024-02-20 01:38:45 +03:00
#endif /* _FREADLN_H */