aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-08-15 14:32:20 +0300
committerStefan Bucur <stefan@stefan-ubumac.(none)>2009-03-15 10:10:52 +0200
commit9835385db43656b7ffbaa2e573ee38a439143f4b (patch)
tree9bcec0d3e1ebae7b746280cb9343101e9d0b4be8
parent01c00a3fec3c067ccc380db4c23bb2882cb5adcb (diff)
downloadsyslinux-elf-9835385db43656b7ffbaa2e573ee38a439143f4b.tar.gz
syslinux-elf-9835385db43656b7ffbaa2e573ee38a439143f4b.tar.xz
syslinux-elf-9835385db43656b7ffbaa2e573ee38a439143f4b.zip
Impelmented spawn CLI command.
-rw-r--r--com32/elflink/exec.c3
-rw-r--r--com32/elflink/test_com32.c28
2 files changed, 30 insertions, 1 deletions
diff --git a/com32/elflink/exec.c b/com32/elflink/exec.c
index 58f04b45..4f300c23 100644
--- a/com32/elflink/exec.c
+++ b/com32/elflink/exec.c
@@ -20,6 +20,9 @@ static struct elf_module *mod_root = NULL;
static char *module_get_fullname(const char *name) {
static char name_buff[MODULE_NAME_SIZE];
+ if (name == NULL)
+ return NULL;
+
strcpy(name_buff, EXEC_DIRECTORY);
strcat(name_buff, name);
diff --git a/com32/elflink/test_com32.c b/com32/elflink/test_com32.c
index c197d88c..4aaa5b90 100644
--- a/com32/elflink/test_com32.c
+++ b/com32/elflink/test_com32.c
@@ -11,6 +11,7 @@
#define MAX_COMMAND_SIZE 80
#define COMMAND_DELIM " \t\n"
+#define MAX_COMMAND_ARGS (MAX_COMMAND_SIZE/2)
@@ -52,7 +53,32 @@ int process_command(char *cmd) {
} else if (strcmp(cmd_name, "load") == 0) {
} else if (strcmp(cmd_name, "spawn") == 0) {
-
+ // Compose the command line
+ char **cmd_line = malloc((MAX_COMMAND_ARGS+1)*sizeof(char*));
+ int argc = 0, result;
+ char *crt_arg;
+
+ do {
+ crt_arg = strtok(NULL, COMMAND_DELIM);
+ if (crt_arg != NULL && strlen(crt_arg) > 0) {
+ cmd_line[argc] = crt_arg;
+ argc++;
+ } else {
+ break;
+ }
+ } while (argc < MAX_COMMAND_ARGS);
+
+ cmd_line[argc] = NULL;
+
+ if (cmd_line[0] == NULL) {
+ printf("You must specify an executable module.\n");
+ } else {
+ result = spawnv(cmd_line[0], cmd_line);
+
+ printf("Spawn returned %d\n", result);
+ }
+
+ free(cmd_line);
} else if (strcmp(cmd_name, "unload") == 0) {
} else if (strcmp(cmd_name, "list") == 0) {