X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/c15969fd0a6280c60d2f35876b5343004fed2b11..62d94d32a0cf73f0813aae5d4b0433816bca81e6:/Console.cpp diff --git a/Console.cpp b/Console.cpp index 99421d8..fe03c31 100644 --- a/Console.cpp +++ b/Console.cpp @@ -47,11 +47,11 @@ #include #include +#include #include #include #include - -#include "Cycript.tab.hh" +#include #include #include @@ -60,11 +60,16 @@ #include #include +#include +#include #include -#include "Replace.hpp" #include "Display.hpp" +#include "Replace.hpp" + +#include "Cycript.tab.hh" +#include "Driver.hpp" static volatile enum { Working, @@ -114,7 +119,7 @@ void Setup(CYOutput &out, CYDriver &driver, CYOptions &options) { static CYUTF8String Run(CYPool &pool, int client, CYUTF8String code) { const char *json; - size_t size; + uint32_t size; if (client == -1) { mode_ = Running; @@ -135,7 +140,7 @@ static CYUTF8String Run(CYPool &pool, int client, CYUTF8String code) { CYSendAll(client, code.data, code.size); mode_ = Waiting; CYRecvAll(client, &size, sizeof(size)); - if (size == _not(size_t)) + if (size == _not(uint32_t)) json = NULL; else { char *temp(new(pool) char[size + 1]); @@ -392,8 +397,8 @@ static void Console(CYOptions &options) { else passwd = getpwuid(getuid()); - const char *basedir(apr_psprintf(pool, "%s/.cycript", passwd->pw_dir)); - const char *histfile(apr_psprintf(pool, "%s/history", basedir)); + const char *basedir(pool.strcat(passwd->pw_dir, "/.cycript", NULL)); + const char *histfile(pool.strcat(basedir, "/history", NULL)); size_t histlines(0); rl_initialize(); @@ -598,6 +603,11 @@ static void *Map(const char *path, size_t *psize) { void InjectLibrary(pid_t pid); int Main(int argc, char const * const argv[], char const * const envp[]) { + _aprcall(apr_initialize()); + + apr_pool_t *pool; + apr_pool_create(&pool, NULL); + bool tty(isatty(STDIN_FILENO)); bool compile(false); CYOptions options; @@ -608,7 +618,9 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { pid_t pid(_not(pid_t)); #endif - CYPool pool; + const char *host(NULL); + const char *port(NULL); + apr_getopt_t *state; _aprcall(apr_getopt_init(&state, pool, argc, argv)); @@ -621,6 +633,7 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { #ifdef CY_ATTACH "p:" #endif + "r:" "s" , &opt, &arg)); @@ -634,6 +647,7 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { #ifdef CY_ATTACH " [-p ]" #endif + " [-r ]" " [