blob: 390c6ee1662e8ec20e5fb849c287c5faadc69698 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "getln.h"
#include "sloth.h"
#include <stdlib.h>
#include <stdio.h>
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;
}
|