helloJSON/src/main.c

33 lines
544 B
C

#include "aliases.h"
#include "lexer_states.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("NO FILE PROVIDED\n");
return EXIT_FAILURE;
}
FILE *fp = fopen(argv[1], "r");
fseek(fp, 0, SEEK_END);
u64 length = ftell(fp);
fseek(fp, 0, SEEK_SET);
char json[length + 1];
memset(json, 0, length + 1);
fread(json, sizeof(char), length, fp);
fclose(fp);
printf("\n%s\n", validate_json(json) ? "VALID" : "INVALID");
return EXIT_SUCCESS;
}