summaryrefslogtreecommitdiffstats
path: root/src/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-09-26 22:39:04 +0200
committerGravatar Martin Szulecki2013-09-26 22:39:04 +0200
commit871ffcdcf06692fd306c8f63cd7796277c2b3d27 (patch)
tree6d1fc3f266af3a99b984ecc627c512f582113321 /src/libirecovery.c
parent6c329b7e20e7511e0be0445e6aeec46d588b2e4b (diff)
downloadlibirecovery-871ffcdcf06692fd306c8f63cd7796277c2b3d27.tar.gz
libirecovery-871ffcdcf06692fd306c8f63cd7796277c2b3d27.tar.bz2
Make irecv_execute_script() use a script as argument instead of a filename
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r--src/libirecovery.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index 54af81d..87ec520 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -1271,33 +1271,31 @@ irecv_error_t irecv_send_exploit(irecv_client_t client) {
return IRECV_E_SUCCESS;
}
-irecv_error_t irecv_execute_script(irecv_client_t client, const char* filename) {
+irecv_error_t irecv_execute_script(irecv_client_t client, const char* script) {
irecv_error_t error = IRECV_E_SUCCESS;
if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
- char* file_data = NULL;
- unsigned int file_size = 0;
- if(irecv_read_file(filename, &file_data, &file_size) < 0) {
- return IRECV_E_FILE_NOT_FOUND;
- }
-
- char* line = strtok(file_data, "\n");
+ char* body = strdup(script);
+ char* line = strtok(body, "\n");
while(line != NULL) {
if(line[0] != '#') {
error = irecv_send_command(client, line);
if(error != IRECV_E_SUCCESS) {
- return error;
+ break;
}
error = irecv_receive(client);
if(error != IRECV_E_SUCCESS) {
- return error;
+ break;
}
}
line = strtok(NULL, "\n");
}
- return IRECV_E_SUCCESS;
+ if (body)
+ free(body);
+
+ return error;
}
irecv_error_t irecv_saveenv(irecv_client_t client) {