efn/main.c

21 lines
537 B
C
Raw Normal View History

2022-04-02 11:40:10 +00:00
int
main(int argc, char **argv) {
static char buf[COM_BUF_SIZE];
while(1) {
2022-04-02 12:46:20 +00:00
memset(buf, 0, sizeof(buf));
printf(" > ");
2022-04-02 12:46:20 +00:00
char *com = fgets(buf, sizeof(buf), stdin);
for (int i = 0; i < sizeof(buf); i++)
if (buf[i] == '\n')
buf[i] = '\0';
2022-04-02 11:40:10 +00:00
if (com != NULL) {
2022-04-02 12:46:20 +00:00
if (commands[com[0]] != NULL) commands[com[0]](buf);
else puts("invalid command.");
}
}
return 0;
2022-04-02 11:40:10 +00:00
}
2022-04-02 12:46:20 +00:00