#include "getln.h" #include "sloth.h" #include #include int main(int argc, char **argv) { (void)argc, (void)argv; /* Initialize sloth. */ Sloth *const sloth = calloc(1, sizeof(Sloth)); SlothError err; if (sloth == NULL) return 1; err = sloth_init(sloth); if (err != NULL) { fprintf(stderr, "%s\n", err); free(sloth); return 1; } puts("sloth v0.0.0, Copyright (c) 2023 kdx"); puts("sloth comes with ABSOLUTELY NO WARRANTY."); puts("Enter EOF to exit."); /* Read stdin line by line until exhaustion. */ char *line = NULL; while ((line = getln(stdin)) != NULL) { err = sloth_exec_line(sloth, line); free(line); if (err != NULL) fprintf(stderr, "%s\n", err); } /* Free everything. */ getln_cleanup(); sloth_deinit(sloth); free(sloth); return 0; }