#include #include #include #include //~ #include //~ #include //~ #include #include "xmalloc.h" #include "xerror.h" using namespace std; int main(int argc, char *argv[]) { if (argc != 1) { die("Usage: ./tex_table_class_test /path/to/table.tex", -1); } FILE *tex_file = fopen(argv[1], "rb"); if (!tex_file) die("main()", errno); struct stat stat_buf; int result = fstat(fileno(tex_file), &stat_buf); if (result == -1) die("main()", errno); char *tex_buf = (char *)xmalloc((size_t)stat_buf.st_size + 1); if (fread(tex_buf, 1, (size_t)stat_buf.st_size, tex_file) != (size_t)stat_buf.st_size) die("main()", errno); tex_buf[stat_buf.st_size] = 0; fclose(tex_file); return EXIT_SUCCESS; }