1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2025-01-10 17:32:05 +05:30
gists/c-programming/io/freadln.h

35 lines
808 B
C
Raw Normal View History

2024-02-20 01:38:45 +03:00
/*
* freadln.h
*
* Author: Intel A80486DX2-66
2024-04-25 23:16:39 +03:00
* License: Unlicense
2024-02-20 01:38:45 +03:00
*/
#ifndef _FREADLN_H
#define _FREADLN_H
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
2024-04-05 21:40:19 +03:00
#define EOT 4 /* end of transmission */
2024-02-20 01:38:45 +03:00
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 */