12 #define LINE_SIZE_MAX 1024*2 44 if (af_is_open(*t) == 0) {
45 (*t).fd = fopen((*t).filepath, (*t).io_mode);
62 if (af_is_open(*t) == 1) {
79 int af_is_comment(
const asciiFile_t t,
const char *line) {
96 int af_readline_full_norealloc(
const asciiFile_t t,
char *line,
size_t n) {
97 if (af_is_open(t) == 1) {
98 if (fgets(line, (
int)n, t.
fd) == NULL) {
101 int nread = (int)strlen(line);
102 if ((nread < ((
int)n - 1)) || (line[nread - 1] ==
'\n') || (feof(t.
fd)))
119 int af_readline_full(
const asciiFile_t t,
char **line,
size_t *n) {
120 if (af_is_open(t) == 1) {
121 return (
int)getline(line, n, t.
fd);
133 int af_writeline_full(
const asciiFile_t t,
const char *line) {
134 if (af_is_open(t) == 1)
135 return (
int)fwrite(line, 1, strlen(line), t.
fd);
148 int af_update(
asciiFile_t *t,
const char *filepath,
const char *io_mode) {
166 asciiFile_t asciiFile(
const char *filepath,
const char *io_mode,
167 const char *comment,
const char *newline) {
170 af_update(&t, filepath, io_mode);
const char * filepath
Full path to file.
Definition: AsciiFile.h:16
char comment[64]
Character(s) indicating a comment.
Definition: AsciiFile.h:18
char newline[64]
Character(s) indicating a newline.
Definition: AsciiFile.h:19
char io_mode[64]
I/O mode. 'r' for read, 'w' for write.
Definition: AsciiFile.h:17
Structure containing information about an ASCII text file.
Definition: AsciiFile.h:15
FILE * fd
File identifier for ASCII file when open.
Definition: AsciiFile.h:20