psh/src/builtin.h

56 lines
1.2 KiB
C
Raw Normal View History

2023-08-04 21:52:07 +02:00
/**
* @file: src/builtin.h
* @author: Jozef Nagy <schkwve@gmail.com>
* @copyright: MIT (See LICENSE.md)
* @brief: This file contains the routines for
* built-in commands.
*/
#ifndef __BUILTIN_H_
#define __BUILTIN_H_
2023-08-05 23:35:20 +02:00
#define NOT_IMPLEMENTED() \
printf("%s has not been implemented yet.\n", __func__);
2023-08-05 12:51:27 +02:00
2023-08-05 13:05:48 +02:00
typedef int (*builtin_func)(int argc, const char **);
2023-08-04 21:52:07 +02:00
/**
* @brief This routine creates and fills a hashtable
* with pointers to built-in command functions.
*/
void builtin_init();
2023-08-04 21:52:07 +02:00
2023-08-05 12:51:27 +02:00
/**
* @brief This routine returns 1.
*/
2023-08-05 13:05:48 +02:00
int psh_true(int argc, const char **argv);
2023-08-05 12:51:27 +02:00
/**
* @brief This routine returns 0.
*/
2023-08-05 13:05:48 +02:00
int psh_false(int argc, const char **argv);
2023-08-05 12:51:27 +02:00
2023-08-05 13:43:31 +02:00
/**
* @brief This routines opens and prints the contents of a file from argv[1].
*/
int psh_cat(int argc, const char **argv);
/**
* @brief This routine prints every argument back to stdio.
*/
2023-08-05 13:05:48 +02:00
int psh_echo(int argc, const char **argv);
/**
* @brief This routine changes the current working directory to argv[1].
* If no arguments are present, change to $HOME.
*/
int psh_chdir(int argc, const char **argv);
/**
* @brief This routine exits with an exit code.
* If exit code is not set, return 0.
*/
int psh_exit(int argc, const char **argv);
2023-08-04 21:52:07 +02:00
#endif // __BUILTIN_H_