Last active
July 5, 2017 09:30
-
-
Save sunwayforever/594bdb363dd7a30f17016e5ab8507436 to your computer and use it in GitHub Desktop.
exev example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cutils/properties.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <android/log.h> | |
#define SALSA_TRANSLATOR "/system/bin/salsa_translator" | |
#define SALSA_TRANSLATOR_ARGC 20 | |
int main(int orig_argc, char *orig_argv[]) { | |
char **argv = malloc((SALSA_TRANSLATOR_ARGC + orig_argc) * sizeof(char *)); | |
memset(argv, 0, SALSA_TRANSLATOR_ARGC + orig_argc); | |
int use_preopt = property_get_bool("persist.salsa.use_preopt", 0); | |
int argc = 0; | |
argv[argc++] = SALSA_TRANSLATOR; | |
if (use_preopt) { | |
argv[argc++] = "-N"; | |
} | |
char debug[PROPERTY_VALUE_MAX] = {0}; | |
property_get("persist.salsa.debug", debug, ""); | |
if (strcmp(debug, "")) { | |
argv[argc++] = "-d"; | |
argv[argc++] = debug; | |
} | |
char log[PROPERTY_VALUE_MAX] = {0}; | |
property_get("persist.salsa.log_dir", log, ""); | |
if (strcmp(log, "")) { | |
argv[argc++] = "-l"; | |
argv[argc++] = log; | |
} | |
int i = 0; | |
for (i = 1; i < orig_argc; i++) { | |
argv[argc++ ] = orig_argv[i]; | |
} | |
execv(SALSA_TRANSLATOR, argv); | |
printf("execve failed: %d\n", errno); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment