summaryrefslogtreecommitdiffstats
path: root/src/irecovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-07 05:18:45 -0400
committerGravatar Joshua Hill2010-06-07 05:18:45 -0400
commit671640f5e2c9908a3807d537e9e761e398347b57 (patch)
tree40a121d5b9c13bae16ba8309add3b80879dafd67 /src/irecovery.c
parent09caab6993bfe2e696ab47776189a4216547c6a9 (diff)
downloadlibirecovery-671640f5e2c9908a3807d537e9e761e398347b57.tar.gz
libirecovery-671640f5e2c9908a3807d537e9e761e398347b57.tar.bz2
a few small bugfixes and updated the TODO list
Diffstat (limited to 'src/irecovery.c')
-rw-r--r--src/irecovery.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/irecovery.c b/src/irecovery.c
index fcc745c..baae17e 100644
--- a/src/irecovery.c
+++ b/src/irecovery.c
@@ -139,24 +139,33 @@ int precommand_cb(irecv_client_t client, const irecv_event_t* event) {
}
int postcommand_cb(irecv_client_t client, const irecv_event_t* event) {
- unsigned char* value = NULL;
+ char* value = NULL;
+ char* action = NULL;
+ char* command = NULL;
+ char* argument = NULL;
+ irecv_error_t error = IRECV_E_SUCCESS;
+
if (event->type == IRECV_POSTCOMMAND) {
- irecv_error_t error = 0;
- if (strstr(event->data, "getenv") != NULL) {
- error = irecv_getenv(client, &value);
+ command = strdup(event->data);
+ action = strtok(command, " ");
+ if (!strcmp(action, "getenv")) {
+ argument = strtok(NULL, " ");
+ error = irecv_getenv(client, argument, &value);
if (error != IRECV_E_SUCCESS) {
debug("%s\n", irecv_strerror(error));
+ free(command);
return error;
}
printf("%s\n", value);
+ free(value);
}
- if (!strcmp(event->data, "reboot")) {
+ if (!strcmp(action, "reboot")) {
quit = 1;
}
}
- if (value != NULL) free(value);
+ if (command) free(command);
return 0;
}