dev/cpp/tex_parser/tex_table_class_test.cpp
Kolan Sh 7359589f6d вычисление среднего для знаковых целых и массивов (ну и парсер TeX немного)
--HG--
rename : c/tex_parser/get_tags.sh => cpp/tex_parser/get_tags.sh
rename : c/tex_parser/tables4.tex => cpp/tex_parser/tables4.tex
rename : c/tex_parser/tables5.tex => cpp/tex_parser/tables5.tex
rename : c/tex_parser/tex_table_class.hpp => cpp/tex_parser/tex_table_class.hpp
rename : c/tex_parser/tex_table_class_tags.hpp => cpp/tex_parser/tex_table_class_tags.hpp
2011-06-07 19:08:15 +04:00

42 lines
810 B
C++

#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "xerror.h"
#include "xmalloc.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;
}