diff --git a/src/console_line.c b/src/console_line.c index 30f71eb..c316297 100644 --- a/src/console_line.c +++ b/src/console_line.c @@ -21,12 +21,20 @@ #include #include +/** + * Get the logged in user's username. + * @return Returns the logged in user's username. + */ char *get_user() { struct passwd *pass; pass = getpwuid(getuid()); return pass->pw_name; } +/** + * Get the current working directory of the shell. + * @return Returns the current working directory. + */ char *get_working_directory() { char *cwd = NULL; cwd = getcwd(NULL, PATH_MAX); @@ -39,6 +47,9 @@ char *get_working_directory() { } } +/** + * Print the console line before the user input. + */ void print_input_line() { char *name = get_user(); char *cwd = get_working_directory(); diff --git a/src/loop.c b/src/loop.c index f5233e7..cd41cfe 100644 --- a/src/loop.c +++ b/src/loop.c @@ -19,10 +19,17 @@ #include #include "console_line.h" +/** + * Remove new line from the end of a string. + * @param line The string to remove the new line from. + */ void remove_new_line(char* line) { line[strcspn(line, "\n")] = 0; } +/** + * This is the loop that checks for user input and acts on it. + */ void loop() { size_t buffer_size = 0; char *line = NULL; diff --git a/src/myshellin.c b/src/myshellin.c index 79024c1..479acae 100644 --- a/src/myshellin.c +++ b/src/myshellin.c @@ -16,6 +16,11 @@ #include #include "loop.h" +/** + * The main entry point to the program. + * @param argc The number of arguments passed. + * @return Returns 0 on success or an error code on failure. + */ int main(int argc, char **argv) { loop(); return EXIT_SUCCESS;