2020-01-14 18:41:28 +01:00
|
|
|
#include "util.h"
|
2019-12-20 11:31:34 +01:00
|
|
|
#include "builtin.h"
|
2020-03-30 00:40:59 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2020-02-05 21:09:39 +01:00
|
|
|
|
|
|
|
// 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] = {
|
2020-02-05 21:09:39 +01:00
|
|
|
{
|
|
|
|
.name = "proc",
|
2020-03-20 22:47:05 +01:00
|
|
|
.entry = (void*)&builtin_proc
|
2020-02-05 21:09:39 +01:00
|
|
|
},
|
2020-03-18 17:48:53 +01:00
|
|
|
{
|
|
|
|
.name = "ram",
|
|
|
|
.entry = NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-02-05 21:09:39 +01:00
|
|
|
|
2019-12-20 11:31:34 +01:00
|
|
|
//TODO: use agc, argv.
|
2020-03-30 00:40:59 +02:00
|
|
|
int check_builtin(int argc, char **argv)
|
2019-12-20 11:31:34 +01:00
|
|
|
{
|
2020-03-30 00:40:59 +02:00
|
|
|
for (int i = 0 ; i < 2 ; ++i)
|
2020-03-18 17:48:53 +01:00
|
|
|
{
|
2020-03-30 00:40:59 +02:00
|
|
|
if (strcmp(builtin[i].name, argv[0]) != 0)
|
2020-03-18 17:48:53 +01:00
|
|
|
continue;
|
|
|
|
if (builtin[i].entry != NULL)
|
2020-03-30 00:40:59 +02:00
|
|
|
(*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
|
|
|
}
|