This commit is contained in:
whaffman 2025-02-04 13:45:10 +01:00
commit b74f5062c4
3 changed files with 308 additions and 11 deletions

5
LULDOC-LOLDICK Normal file
View File

@ -0,0 +1,5 @@
Ik heb even alle allowed function door de AI in de readme laten zetten, en een header file gemaakt wat iig alles include
ik ga dit weekend wel door met een basic Makefile en mss een Prompt maken voor readline ofzo. maar drink vooral veel bier en geniet van je weekend
classic de Ai maakt er veel bier van

148
README.md
View File

@ -1,13 +1,139 @@
# Minishell # Minishell
=======
## Allowed Functions
## Alowed functions ### `<fcntl.h>`
readline, rl_clear_history, rl_on_new_line, * `open`
rl_replace_line, rl_redisplay, add_history, * `int open(const char *pathname, int flags, ...);`
printf, malloc, free, write, access, open, read, * Opens a file specified by pathname. The flags argument determines the file access mode and file status flags.
close, fork, wait, waitpid, wait3, wait4, signal,
sigaction, sigemptyset, sigaddset, kill, exit, ### `<dirent.h>`
getcwd, chdir, stat, lstat, fstat, unlink, execve, * `opendir`
dup, dup2, pipe, opendir, readdir, closedir, * `DIR *opendir(const char *name);`
strerror, perror, isatty, ttyname, ttyslot, ioctl, * Opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream.
getenv, tcsetattr, tcgetattr, tgetent, tgetflag, * `readdir`
tgetnum, tgetstr, tgoto, tputs * `struct dirent *readdir(DIR *dirp);`
* Reads the next directory entry from the directory stream pointed to by dirp.
* `closedir`
* `int closedir(DIR *dirp);`
* Closes the directory stream associated with dirp.
### `<stdlib.h>`
* `malloc`
* `void *malloc(size_t size);`
* Allocates size bytes of memory and returns a pointer to the allocated memory.
* `free`
* `void free(void *ptr);`
* Frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc.
### `<stdio.h>`
* `printf`
* `int printf(const char *format, ...);`
* Sends formatted output to stdout.
### `<sys/stat.h>`
* `stat`
* `int stat(const char *pathname, struct stat *statbuf);`
* Retrieves information about the file pointed to by pathname and fills in the stat structure.
* `lstat`
* `int lstat(const char *pathname, struct stat *statbuf);`
* Similar to stat, but does not follow symbolic links.
* `fstat`
* `int fstat(int fd, struct stat *statbuf);`
* Retrieves information about the file referred to by the open file descriptor fd.
### `<sys/wait.h>`
* `wait`
* `pid_t wait(int *wstatus);`
* Suspends execution of the calling process until one of its children terminates.
* `waitpid`
* `pid_t waitpid(pid_t pid, int *wstatus, int options);`
* Suspends execution of the calling process until the child specified by pid changes state.
* `wait3`
* `pid_t wait3(int *wstatus, int options, struct rusage *rusage);`
* Similar to wait, but also returns resource usage information.
* `wait4`
* `pid_t wait4(pid_t pid, int *wstatus, int options, struct rusage *rusage);`
* Similar to waitpid, but also returns resource usage information.
### `<signal.h>`
* `signal`
* `void (*signal(int signum, void (*handler)(int)))(int);`
* Sets a function to handle signal signum.
* `sigaction`
* `int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);`
* Examines and changes the action associated with a specific signal.
* `sigemptyset`
* `int sigemptyset(sigset_t *set);`
* Initializes the signal set pointed to by set to exclude all signals.
* `sigaddset`
* `int sigaddset(sigset_t *set, int signum);`
* Adds the individual signal specified by signum to the signal set pointed to by set.
* `kill`
* `int kill(pid_t pid, int sig);`
* Sends the signal sig to the process specified by pid.
### `<unistd.h>`
* `write`
* `ssize_t write(int fd, const void *buf, size_t count);`
* Writes up to count bytes from the buffer starting at buf to the file referred to by the file descriptor fd.
* `access`
* `int access(const char *pathname, int mode);`
* Checks the file named by pathname for accessibility according to the bit pattern contained in mode.
* `read`
* `ssize_t read(int fd, void *buf, size_t count);`
* Reads up to count bytes from file descriptor fd into the buffer starting at buf.
* `close`
* `int close(int fd);`
* Closes the file descriptor fd.
* `fork`
* `pid_t fork(void);`
* Creates a new process by duplicating the calling process.
### `<readline/readline.h>`
* `readline`
* `char *readline(const char *prompt);`
* Reads a line from the terminal with editing capabilities.
* `rl_clear_history`
* `void rl_clear_history(void);`
* Clears the history of lines read by readline.
* `rl_on_new_line`
* `int rl_on_new_line(void);`
* Resets the state to indicate that a new line of input is being read.
* `rl_replace_line`
* `int rl_replace_line(const char *text, int clear_undo);`
* Replaces the contents of the current line with text.
* `rl_redisplay`
* `int rl_redisplay(void);`
* Redisplays the current input line.
* `add_history`
* `void add_history(const char *line);`
* Adds the line to the history list.
### `<termios.h>`
* `tcsetattr`
* `int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);`
* Sets the parameters associated with the terminal referred to by fd.
* `tcgetattr`
* `int tcgetattr(int fd, struct termios *termios_p);`
* Gets the parameters associated with the terminal referred to by fd.
### `<term.h>`
* `tgetent`
* `int tgetent(char *bp, const char *name);`
* Loads the entry for name from the termcap database.
* `tgetflag`
* `int tgetflag(const char *id);`
* Gets the boolean entry for id from the termcap database.
* `tgetnum`
* `int tgetnum(const char *id);`
* Gets the numeric entry for id from the termcap database.
* `tgetstr`
* `char *tgetstr(const char *id, char **area);`
* Gets the string entry for id from the termcap database.
* `tgoto`
* `char *tgoto(const char *cap, int col, int row);`
* Returns a cursor addressing string for the given capability cap.
* `tputs`
* `int tputs(const char *str, int affcnt, int (*putc)(int));`
* Outputs the string str with padding.

166
inc/minishell.h Normal file
View File

@ -0,0 +1,166 @@
/**
* @file minishell.h
*
* @brief Header file for the Minishell project.
*
* This header file includes all necessary libraries and headers required for the Minishell project.
* The following is a list of included headers and the functions or system calls they provide:
*
* @headerfile <stdio.h>
* - int printf(const char *format, ...);
* - Prints formatted data to stdout.
* - void perror(const char *s);
* - Prints a descriptive error message to stderr.
*
* @headerfile <stdlib.h>
* - void* malloc(size_t size);
* - Allocates memory dynamically.
* - void free(void *ptr);
* - Frees dynamically allocated memory.
* - void exit(int status);
* - Terminates the calling process.
* - char* getenv(const char *name);
* - Retrieves the value of an environment variable.
*
* @headerfile <unistd.h>
* - ssize_t write(int fd, const void *buf, size_t count);
* - Writes data to a file descriptor.
* - int access(const char *pathname, int mode);
* - Checks user's permissions for a file.
* - ssize_t read(int fd, void *buf, size_t count);
* - Reads data from a file descriptor.
* - int close(int fd);
* - Closes a file descriptor.
* - pid_t fork(void);
* - Creates a new process.
* - char* getcwd(char *buf, size_t size);
* - Gets the current working directory.
* - int chdir(const char *path);
* - Changes the current working directory.
* - int unlink(const char *pathname);
* - Deletes a name from the filesystem.
* - int execve(const char *pathname, char *const argv[], char *const envp[]);
* - Executes a program.
* - int dup(int oldfd);
* - Duplicates a file descriptor.
* - int dup2(int oldfd, int newfd);
* - Duplicates a file descriptor to a specific descriptor number.
* - int pipe(int pipefd[2]);
* - Creates a pipe.
* - int isatty(int fd);
* - Checks if a file descriptor refers to a terminal.
* - char* ttyname(int fd);
* - Returns the name of the terminal associated with a file descriptor.
* - int ttyslot(void);
* - Returns the index of the current terminal.
*
* @headerfile <string.h>
* - char* strerror(int errnum);
* - Returns a string describing the error number.
*
* @headerfile <sys/types.h>
* - Required for various system calls and data types.
*
* @headerfile <sys/wait.h>
* - pid_t wait(int *wstatus);
* - Waits for a child process to change state.
* - pid_t waitpid(pid_t pid, int *wstatus, int options);
* - Waits for a specific child process to change state.
* - pid_t wait3(int *wstatus, int options, struct rusage *rusage);
* - Waits for a child process to change state with resource usage information.
* - pid_t wait4(pid_t pid, int *wstatus, int options, struct rusage *rusage);
* - Waits for a specific child process to change state with resource usage information.
*
* @headerfile <fcntl.h>
* - int open(const char *pathname, int flags, ...);
* - Opens a file.
*
* @headerfile <errno.h>
* - Provides access to the errno variable.
*
* @headerfile <signal.h>
* - void (*signal(int signum, void (*handler)(int)))(int);
* - Sets a signal handler.
* - int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
* - Examines and changes a signal action.
* - int sigemptyset(sigset_t *set);
* - Initializes a signal set to empty.
* - int sigaddset(sigset_t *set, int signum);
* - Adds a signal to a signal set.
* - int kill(pid_t pid, int sig);
* - Sends a signal to a process.
*
* @headerfile <readline/readline.h>
* - char* readline(const char *prompt);
* - Reads a line of input from the user.
* - void rl_clear_history(void);
* - Clears the history list.
* - void rl_on_new_line(void);
* - Informs the readline library that the cursor is on a new line.
* - void rl_replace_line(const char *text, int clear_undo);
* - Replaces the contents of the current line.
* - void rl_redisplay(void);
* - Redisplays the current line.
* - void add_history(const char *line);
* - Adds a line to the history list.
*
* @headerfile <dirent.h>
* - DIR* opendir(const char *name);
* - Opens a directory stream.
* - struct dirent* readdir(DIR *dirp);
* - Reads a directory entry.
* - int closedir(DIR *dirp);
* - Closes a directory stream.
*
* @headerfile <sys/stat.h>
* - int stat(const char *pathname, struct stat *statbuf);
* - Gets file status.
* - int lstat(const char *pathname, struct stat *statbuf);
* - Gets file status, not following symbolic links.
* - int fstat(int fd, struct stat *statbuf);
* - Gets file status for an open file descriptor.
*
* @headerfile <sys/ioctl.h>
* - int ioctl(int fd, unsigned long request, ...);
* - Manipulates the underlying device parameters of special files.
*
* @headerfile <termios.h>
* - int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
* - Sets the parameters associated with the terminal.
* - int tcgetattr(int fd, struct termios *termios_p);
* - Gets the parameters associated with the terminal.
*
* @headerfile <term.h>
* - int tgetent(char *bp, const char *name);
* - Loads the terminal entry for a given terminal name.
* - int tgetflag(const char *id);
* - Gets the boolean value of a terminal capability.
* - int tgetnum(const char *id);
* - Gets the numeric value of a terminal capability.
* - char* tgetstr(const char *id, char **area);
* - Gets the string value of a terminal capability.
* - char* tgoto(const char *cap, int col, int row);
* - Computes a cursor movement string.
* - int tputs(const char *str, int affcnt, int (*putc)(int));
* - Outputs a string with padding.
*/
#ifndef MINISHELL_H
# define MINISHELL_H
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <string.h>
# include <sys/types.h>
# include <sys/wait.h>
# include <fcntl.h>
# include <errno.h>
# include <signal.h>
# include <readline/readline.h>
# include <dirent.h>
# include <sys/stat.h>
# include <sys/ioctl.h>
# include <termios.h>
# include <term.h>
#endif // MINISHELL_H