summaryrefslogtreecommitdiffstats
path: root/src/irecovery.c
diff options
context:
space:
mode:
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) {
139} 139}
140 140
141int postcommand_cb(irecv_client_t client, const irecv_event_t* event) { 141int postcommand_cb(irecv_client_t client, const irecv_event_t* event) {
142 unsigned char* value = NULL; 142 char* value = NULL;
143 char* action = NULL;
144 char* command = NULL;
145 char* argument = NULL;
146 irecv_error_t error = IRECV_E_SUCCESS;
147
143 if (event->type == IRECV_POSTCOMMAND) { 148 if (event->type == IRECV_POSTCOMMAND) {
144 irecv_error_t error = 0; 149 command = strdup(event->data);
145 if (strstr(event->data, "getenv") != NULL) { 150 action = strtok(command, " ");
146 error = irecv_getenv(client, &value); 151 if (!strcmp(action, "getenv")) {
152 argument = strtok(NULL, " ");
153 error = irecv_getenv(client, argument, &value);
147 if (error != IRECV_E_SUCCESS) { 154 if (error != IRECV_E_SUCCESS) {
148 debug("%s\n", irecv_strerror(error)); 155 debug("%s\n", irecv_strerror(error));
156 free(command);
149 return error; 157 return error;
150 } 158 }
151 printf("%s\n", value); 159 printf("%s\n", value);
160 free(value);
152 } 161 }
153 162
154 if (!strcmp(event->data, "reboot")) { 163 if (!strcmp(action, "reboot")) {
155 quit = 1; 164 quit = 1;
156 } 165 }
157 } 166 }
158 167
159 if (value != NULL) free(value); 168 if (command) free(command);
160 return 0; 169 return 0;
161} 170}
162 171