-
Notifications
You must be signed in to change notification settings - Fork 0
/
builtins.c
39 lines (35 loc) · 999 Bytes
/
builtins.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "builtins.h"
/**
* get_builtins - get the builtins
* Return: pointer to a NULL-terminated statically-allocated array of builtins
*/
const builtin_t *get_builtins(void)
{
static builtin_t builtins[] = {
{"alias", __alias, ALIAS_HELP, ALIAS_DESC},
{"cd", __cd, CD_HELP, CD_DESC},
{"env", __env, ENV_HELP, ENV_DESC},
{"exec", __exec, EXEC_HELP, EXEC_DESC},
{"exit", __exit, EXIT_HELP, EXIT_DESC},
{"help", __help, HELP_HELP, HELP_DESC},
{"setenv", __setenv, SETENV_HELP, SETENV_DESC},
{"unsetenv", __unsetenv, UNSETENV_HELP, UNSETENV_DESC},
{0}
};
return (builtins);
}
/**
* get_builtin - get a builtin by name
* @name: the name of the builtin to retrieve
* Return: NULL if no match is found, otherwise a pointer to the builtin
*/
const builtin_t *get_builtin(const char *name)
{
const builtin_t *builtin = NULL;
for (builtin = get_builtins(); builtin->name; builtin += 1)
{
if (_strcmp(name, builtin->name) == 0)
return (builtin);
}
return (NULL);
}