/* ************************************************************************** */ /* _____ _ */ /* main.c |_ _|__ _ _| |__ ___ _ _ */ /* | Project: mcsfile | |/ _ \| | | | '_ \ / _ \ | | | */ /* | | (_) | |_| | | | | __/ |_| | */ /* By: thomas |_|\___/ \__,_|_| |_|\___|\__, |.fr */ /* Last updated: 2016/12/18 01:19:25 |___/ */ /* */ /* ************************************************************************** */ #include "main.h" #include #include #include #define cry(S, ...) fprintf(stderr, (S), ##__VA_ARGS__) /** * main: * Entry point of the program. * * @arg ac the arguments count. * @arg av the arguments values. * @return the status code (0 if ok). */ int main(int ac, char **av) { /* set the locale */ setlocale(LC_ALL, ""); /* parse arguments */ const char *path; if (parse_args(ac, av, &path)) return (0); /* parse */ g1m_t *handle; int err; if ((err = g1m_open(&handle, path, g1m_type_mcs))) switch (err) { case g1m_error_wrong_type: cry("An MCS file was expected (g1m/g1r, g1m/g2r, g3m)\n"); return (0); case g1m_error_nostream: cry("Could not open file: %s\n", strerror(errno)); return (0); case g1m_error_magic: cry("Magic error: file might be corrupted\n"); return (0); case g1m_error_eof: cry("Unexpected end of file\n"); return (0); } /* read */ put_files(handle); /* no error */ g1m_free(handle); return (0); }