it compiles
This commit is contained in:
commit
5340cd4ef2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
efn
|
4
c_quit.c
Normal file
4
c_quit.c
Normal file
@ -0,0 +1,4 @@
|
||||
void
|
||||
c_quit() {
|
||||
exit(0);
|
||||
}
|
3
commands.c
Normal file
3
commands.c
Normal file
@ -0,0 +1,3 @@
|
||||
void (*commands[256])() = {
|
||||
NULL,
|
||||
['q'] = c_quit,
|
2
compile.sh
Executable file
2
compile.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
gcc efn.c -o efn
|
1
consts.h
Normal file
1
consts.h
Normal file
@ -0,0 +1 @@
|
||||
#define ROW_SIZE 100
|
15
efn.c
Normal file
15
efn.c
Normal 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
Normal file
4
efn.h
Normal file
@ -0,0 +1,4 @@
|
||||
extern void (*commands[256])();
|
||||
|
||||
void c_quit();
|
||||
|
11
main.c
Normal file
11
main.c
Normal 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
Normal file
2
types.h
Normal file
@ -0,0 +1,2 @@
|
||||
typedef struct Row Row;
|
||||
struct Row {Row *p; Row *n; char text[ROW_SIZE]; int line;};
|
Loading…
x
Reference in New Issue
Block a user