2024-02-20 04:08:45 +05:30
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2024-04-06 00:10:19 +05:30
|
|
|
#define EOT 4 /* end of transmission */
|
|
|
|
|
2024-02-20 04:08:45 +05:30
|
|
|
typedef size_t freadln_length_type;
|
|
|
|
|
|
|
|
enum freadln_status {
|
2024-03-10 16:49:29 +05:30
|
|
|
freadln_OK,
|
2024-03-10 18:08:14 +05:30
|
|
|
freadln_EOF,
|
2024-02-20 04:08:45 +05:30
|
|
|
freadln_ERROR
|
|
|
|
};
|
|
|
|
|
2024-03-10 17:55:59 +05:30
|
|
|
#define freadln_epilogue do { \
|
2024-02-20 04:08:45 +05:30
|
|
|
(*output)[length] = '\0'; \
|
2024-03-10 16:44:02 +05:30
|
|
|
if (length_out != NULL) \
|
2024-02-20 04:08:45 +05:30
|
|
|
*length_out = length; \
|
2024-02-22 21:39:37 +05:30
|
|
|
} while (0)
|
2024-02-20 04:08:45 +05:30
|
|
|
|
2024-03-10 17:09:10 +05:30
|
|
|
int freadln(FILE* f, char** output, size_t* length_out);
|
|
|
|
#define finreadln(output, length_out) freadln(stdin, output, length_out)
|
2024-02-22 21:39:37 +05:30
|
|
|
|
2024-02-20 04:08:45 +05:30
|
|
|
#endif /* _FREADLN_H */
|