it compiles

master
bx 2022-04-02 11:40:10 +00:00
commit 5340cd4ef2
9 changed files with 43 additions and 0 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
efn

4
c_quit.c 100644
View File

@ -0,0 +1,4 @@
void
c_quit() {
exit(0);
}

3
commands.c 100644
View File

@ -0,0 +1,3 @@
void (*commands[256])() = {
NULL,
['q'] = c_quit,

2
compile.sh 100755
View File

@ -0,0 +1,2 @@
#!/bin/bash
gcc efn.c -o efn

1
consts.h 100644
View File

@ -0,0 +1 @@
#define ROW_SIZE 100

15
efn.c 100644
View File

@ -0,0 +1,15 @@
#include <stdio.h>
#include "consts.h"
#include "types.h"
#include "efn.h"
#include "main.c"
#include "commands.c"
};
#include "c_quit.c"

4
efn.h 100644
View File

@ -0,0 +1,4 @@
extern void (*commands[256])();
void c_quit();

11
main.c 100644
View File

@ -0,0 +1,11 @@
int
main(int argc, char **argv) {
static char buf[256];
while (1) {
char *com = fgets(buf, sizeof(buf), stdin);
if (com != NULL) {
commands[com[0]]();
}
}
return 0;
}

2
types.h 100644
View File

@ -0,0 +1,2 @@
typedef struct Row Row;
struct Row {Row *p; Row *n; char text[ROW_SIZE]; int line;};