-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaansh.c
58 lines (51 loc) · 1.04 KB
/
taansh.c
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#define RL_BUFFER 1000
int buffer = RL_BUFFER;
char input[];
char *builtins[6] = {
"help",
"hello",
"deadmilkmen",
"cd",
"pwd",
"exit"
};
int taansh_hello(void);
int taansh_help(void);
int taansh_exit(void);
int taansh_intro(void) {
printf("We jumped up on the table\n");
printf("And shouted \"ANARCHY!\"\n\n\n");
printf("\t Welcome to TAANSH: This Ain't A Normal SHell\n");
printf("you-cant-type-anything-yet-because-i-have-to-add-readline-functions:-$ \n");
exit(EXIT_SUCCESS);
taansh_rl();
}
int taansh_rl(void) {
int allocbuffer = malloc(buffer);
int c;
int position = 0;
if (!buffer) {
perror("No buffer somehow idk\n");
exit(EXIT_FAILURE);
}
while(1) {
c = getchar();
if (c == EOF || c == '\n') {
input[position] = '\0';
return buffer;
}
else {
input[position] = c;
}
}
}
int taansh_exit(void) {
exit(EXIT_SUCCESS);
}
int taansh_hello(void) {
printf("Hello please kill me\n");
}