X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/9185d5ef70289d99e212f2dd04457b05716e222e..f37e350174fca2296b6052746d6e0a9796ad67cb:/Console.cpp diff --git a/Console.cpp b/Console.cpp index 503a3e8..7f97963 100644 --- a/Console.cpp +++ b/Console.cpp @@ -63,6 +63,8 @@ #include #include +#include + static volatile enum { Working, Parsing, @@ -332,7 +334,9 @@ static void *Map(const char *path, size_t *psize) { return base; } -int main(int argc, char *argv[]) { +int main(int argc, char const * const argv[], char const * const envp[]) { + _aprcall(apr_app_initialize(&argc, &argv, &envp)); + bool tty(isatty(STDIN_FILENO)); bool compile(false); @@ -340,70 +344,89 @@ int main(int argc, char *argv[]) { pid_t pid(_not(pid_t)); #endif - for (;;) switch (getopt(argc, argv, - "cg:n:" + CYPool pool; + apr_getopt_t *state; + _aprcall(apr_getopt_init(&state, pool, argc, argv)); + + for (;;) { + char opt; + const char *arg; + + apr_status_t status(apr_getopt(state, + "cg:n:" #ifdef CY_ATTACH - "p:" + "p:" #endif - "s" - )) { - case -1: - goto getopt; - case '?': - fprintf(stderr, "usage: cycript [-c]" + "s" + , &opt, &arg)); + + switch (status) { + case APR_EOF: + goto getopt; + case APR_BADCH: + case APR_BADARG: + fprintf(stderr, + "usage: cycript [-c]" #ifdef CY_ATTACH - " [-p ]" + " [-p ]" #endif - " [