54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
/* ************************************************************************** */
|
|
/* _____ _ */
|
|
/* main.c |_ _|__ _ _| |__ ___ _ _ */
|
|
/* | Project: mcsfile | |/ _ \| | | | '_ \ / _ \ | | | */
|
|
/* | | (_) | |_| | | | | __/ |_| | */
|
|
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
|
|
/* Last updated: 2016/12/18 01:19:25 |___/ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include "main.h"
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
/* 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:
|
|
fprintf(stderr, "An MCS file was expected (g1m/g1r, g1m/g2r, g3m)\n");
|
|
return (0);
|
|
case g1m_error_nostream:
|
|
fprintf(stderr, "Could not open file: %s\n", strerror(errno));
|
|
return (0);
|
|
case g1m_error_magic:
|
|
fprintf(stderr, "Magic error: file might be corrupted\n");
|
|
return (0);
|
|
case g1m_error_eof:
|
|
fprintf(stderr, "Unexpected end of file\n");
|
|
return (0);
|
|
}
|
|
|
|
/* read */
|
|
put_files(handle);
|
|
|
|
/* no error */
|
|
g1m_free(handle);
|
|
return (0);
|
|
}
|