Vhex-kernel/src/user/shell/util/check_builtin.c

35 lines
586 B
C
Raw Normal View History

#include "util.h"
2019-12-20 11:31:34 +01:00
#include "builtin.h"
#include <string.h>
#include <unistd.h>
// Internal builtin list
// FIXME: due to PIE binary format, we can not
// FIXME: use address of builtin_proc !!
2020-03-18 17:48:53 +01:00
struct builtin_s builtin[2] = {
{
.name = "proc",
.entry = (void*)&builtin_proc
},
2020-03-18 17:48:53 +01:00
{
.name = "ram",
.entry = NULL
}
};
2019-12-20 11:31:34 +01:00
//TODO: use agc, argv.
int check_builtin(int argc, char **argv)
2019-12-20 11:31:34 +01:00
{
for (int i = 0 ; i < 2 ; ++i)
2020-03-18 17:48:53 +01:00
{
if (strcmp(builtin[i].name, argv[0]) != 0)
2020-03-18 17:48:53 +01:00
continue;
if (builtin[i].entry != NULL)
(*builtin[i].entry)(argc, argv);
2020-03-18 17:48:53 +01:00
return (0);
}
return (-1);
2020-03-15 00:56:31 +01:00
}