34 lines
698 B
C
34 lines
698 B
C
#include "tome_utils.h"
|
|
|
|
int main(int argc, char *argv[]) {
|
|
char *data;
|
|
int fd = ERR;
|
|
// INFO: I'm sorry, I don't have much time left to implement a pipe input.
|
|
if (argc < 2) {
|
|
printer("Usage: ./tome_reader <file>\n");
|
|
exit(1);
|
|
} else {
|
|
fd = get_fd(argv[1], O_RDONLY);
|
|
if (fd == ERR) {
|
|
printer("Error: Unable to open file\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
printer("--------------");
|
|
// Loop until we get nothing
|
|
while ((data = tome_reader(fd)) != NULL) {
|
|
|
|
printer("\n");
|
|
printer("New line: ");
|
|
printer(data);
|
|
printer("--------------");
|
|
free(data);
|
|
}
|
|
printer("\n");
|
|
if (fd != 0)
|
|
close(fd); // Close the file descriptor
|
|
|
|
return 0;
|
|
}
|