l33t/l33t.c

51 lines
985 B
C
Raw Normal View History

2024-11-28 23:16:16 +00:00
#include "io.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <stdbool.h>
#include "subprocess.h"
#include "proc.h"
#include "missions/all.h"
#include "state.h"
int main()
{
int pfd = subprocess("bash");
state_t *state = new_state(pfd, STDIN_FILENO, STDOUT_FILENO);
// Running a mission is just a one liner!
run_mission(state, vim1);
char *line;
size_t buffer_size = 1;
int fds[] = {state->pfd, state->ifd, -1};
while (true)
{
int *readable = get_readable(fds);
int index = 0;
int fd;
while ((fd = readable[index]) != -1)
{
char *data = read_line(fd, 1024);
if (fd == state->ifd)
{
write(pfd, data, strlen(data));
}
else
{
printf(data);
}
index++;
}
}
}