74e2e8c772
Signed-off-by: Ian Moffett <ian@mirocom.org>
67 lines
1.0 KiB
C
67 lines
1.0 KiB
C
/*
|
|
* Copyright (c) 2026, Chloe M.
|
|
* Provided under the BSD-3 clause
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include "cescal/state.h"
|
|
#include "cescal/parser.h"
|
|
#include "cescal/log.h"
|
|
|
|
static void
|
|
help(void)
|
|
{
|
|
printf("usage: ./cescal [flags]\n");
|
|
printf("[-h] Display this help menu\n");
|
|
}
|
|
|
|
static int
|
|
compile(const char *pathname)
|
|
{
|
|
struct cescal_state st;
|
|
|
|
if (pathname == NULL) {
|
|
return -1;
|
|
}
|
|
|
|
if (state_init(&st, pathname) < 0) {
|
|
return -1;
|
|
}
|
|
|
|
if (parser_parse(&st) < 0) {
|
|
return -1;
|
|
}
|
|
|
|
state_close(&st);
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
int opt;
|
|
|
|
if (argc < 2) {
|
|
cc_error("too few arguments\n");
|
|
help();
|
|
return -1;
|
|
}
|
|
|
|
while ((opt = getopt(argc, argv, "h")) != -1) {
|
|
switch (opt) {
|
|
case 'h':
|
|
help();
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
while (optind < argc) {
|
|
if (compile(argv[optind++]) < 0) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|