aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-08-15 15:44:46 +0300
committerStefan Bucur <stefan@stefan-ubumac.(none)>2009-03-15 10:10:52 +0200
commitd7c4f9bc3852fa77c0dd9ea119f91993fa52663d (patch)
treec8e1a87826ec9549f1616b72cdee434ec7834475
parent9835385db43656b7ffbaa2e573ee38a439143f4b (diff)
downloadsyslinux-elf-d7c4f9bc3852fa77c0dd9ea119f91993fa52663d.tar.gz
syslinux-elf-d7c4f9bc3852fa77c0dd9ea119f91993fa52663d.tar.xz
syslinux-elf-d7c4f9bc3852fa77c0dd9ea119f91993fa52663d.zip
Implemented library load and unload CLI interface.
-rw-r--r--com32/elflink/test_com32.c82
1 files changed, 54 insertions, 28 deletions
diff --git a/com32/elflink/test_com32.c b/com32/elflink/test_com32.c
index 4aaa5b90..ea2a9581 100644
--- a/com32/elflink/test_com32.c
+++ b/com32/elflink/test_com32.c
@@ -40,6 +40,57 @@ void read_command(char *cmd, int size) {
*nl = '\0';
}
+void process_spawn() {
+ // 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);
+}
+
+void process_library(int load) {
+ char *crt_lib;
+ int result;
+
+ while ((crt_lib = strtok(NULL, COMMAND_DELIM)) != NULL) {
+ if (strlen(crt_lib) > 0) {
+ if (load)
+ result = load_library(crt_lib);
+ else
+ result = unload_library(crt_lib);
+
+ if (result == 0) {
+ printf("Library '%s' %sloaded successfully.\n", crt_lib,
+ load ? "" : "un");
+ } else {
+ printf("Could not %sload library '%s': error %d\n",
+ load ? "" : "un", crt_lib, result);
+ }
+ }
+ }
+}
+
int process_command(char *cmd) {
char *cmd_name;
@@ -51,36 +102,11 @@ int process_command(char *cmd) {
} else if (strcmp(cmd_name, "help") == 0) {
print_help();
} else if (strcmp(cmd_name, "load") == 0) {
-
+ process_library(1);
} 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);
+ process_spawn();
} else if (strcmp(cmd_name, "unload") == 0) {
-
+ process_library(0);
} else if (strcmp(cmd_name, "list") == 0) {
}