37 printf(
"\n\033[32m%s\n\033[92m>\033[m ", cwd);
66 if (status > 0 && status <
EMAX)
76 printf(
"shell: %llu\n", status);
105 switch (result->
type)
122 printf(
"\033[0m\033[?25h");
237 printf(
"Welcome to the PatchworkOS Shell!\n");
238 printf(
"Type \033[92mhelp\033[m for information on how to use the shell.\n");
#define MAX_PATH
Maximum length of filepaths.
void ansi_init(ansi_t *ansi)
uint64_t ansi_parse(ansi_t *ansi, char input, ansi_result_t *result)
#define EMAX
Maximum value for all error codes (not inclusive)
#define errno
Error number variable.
_PUBLIC sighandler_t signal(int sig, sighandler_t func)
#define UNUSED(x)
Mark a variable as unused.
#define F(format,...)
Allocates a formatted string on the stack.
size_t readfile(const char *path, void *buffer, size_t count, size_t offset)
Wrapper for reading a file directly using a path.
size_t read(fd_t fd, void *buffer, size_t count)
System call for reading from files.
#define STDOUT_FILENO
Standard output file descriptor.
#define STDERR_FILENO
Standard error file descriptor.
#define RETRY_EINTR(expr)
Macro to automatically retry a function that returns an integer if it errors and errno == EINTR.
#define STDIN_FILENO
Standard input file descriptor.
_NORETURN void _exit(const char *status)
System call that handles pending notes for the current thread.
#define NULL
Pointer error value.
#define ERR
Integer error value.
const char * history_previous(history_t *history)
void history_push(history_t *history, const char *entry)
void history_init(history_t *history)
const char * history_next(history_t *history)
static void interactive_execute(void)
void interactive_shell(void)
static void interactive_handle_ansi(ansi_result_t *result)
static void interactive_handle_input(const char *input, uint64_t length)
static void interactive_sigint_handler(int sig)
static void interactive_prompt(void)
static char buffer[MAX_PATH]
void pipeline_deinit(pipeline_t *pipeline)
void pipeline_wait(pipeline_t *pipeline)
uint64_t pipeline_init(pipeline_t *pipeline, const char *cmdline, fd_t stdin, fd_t stdout, fd_t stderr)
void pipeline_execute(pipeline_t *pipeline)
_PUBLIC int sscanf(const char *_RESTRICT s, const char *_RESTRICT format,...)
_PUBLIC int fflush(FILE *stream)
_PUBLIC int printf(const char *_RESTRICT format,...)
_PUBLIC _NORETURN void exit(int status)
_PUBLIC char * strerror(int errnum)
_PUBLIC void * memmove(void *_RESTRICT s1, const void *_RESTRICT s2, size_t n)
_PUBLIC char * strncpy(char *_RESTRICT s1, const char *_RESTRICT s2, size_t n)
_PUBLIC size_t strlen(const char *s)
_PUBLIC char * strcpy(char *_RESTRICT s1, const char *_RESTRICT s2)
_PUBLIC int strcmp(const char *s1, const char *s2)
_PUBLIC void * memset(void *s, int c, size_t n)