8 #define LINE_SIZE_MAX 1024*2 40 if (af_is_open(*t) == 0) {
41 (*t).fd = fopen((*t).filepath, (*t).io_mode);
58 if (af_is_open(*t) == 1) {
75 int af_is_comment(
const asciiFile_t t,
const char *line) {
92 int af_readline_full_norealloc(
const asciiFile_t t,
char *line,
size_t n) {
93 if (af_is_open(t) == 1) {
94 if (fgets(line, (
int)n, t.
fd) == NULL) {
97 int nread = (int)strlen(line);
98 if ((nread < ((
int)n - 1)) || (line[nread - 1] ==
'\n') || (feof(t.
fd)))
115 int af_readline_full(
const asciiFile_t t,
char **line,
size_t *n) {
116 if (af_is_open(t) == 1) {
117 return (
int)getline(line, n, t.
fd);
129 int af_writeline_full(
const asciiFile_t t,
const char *line) {
130 if (af_is_open(t) == 1)
131 return (
int)fwrite(line, 1, strlen(line), t.
fd);
144 int af_update(
asciiFile_t *t,
const char *filepath,
const char *io_mode) {
162 asciiFile_t asciiFile(
const char *filepath,
const char *io_mode,
163 const char *comment,
const char *newline) {
166 af_update(&t, filepath, io_mode);
const char * filepath
Full path to file.
Definition: AsciiFile.h:12
char comment[64]
Character(s) indicating a comment.
Definition: AsciiFile.h:14
char newline[64]
Character(s) indicating a newline.
Definition: AsciiFile.h:15
char io_mode[64]
I/O mode. 'r' for read, 'w' for write.
Definition: AsciiFile.h:13
Structure containing information about an ASCII text file.
Definition: AsciiFile.h:11
FILE * fd
File identifier for ASCII file when open.
Definition: AsciiFile.h:16