-/* Cycript - Remove Execution Server and Disassembler
+/* Cycript - Inlining/Optimizing JavaScript Compiler
* Copyright (C) 2009 Jay Freeman (saurik)
*/
#include <apr_getopt.h>
+#include <dlfcn.h>
+
static volatile enum {
Working,
Parsing,
Run(client, code.c_str(), code.size(), fout, expand);
}
+int (*append_history$)(int, const char *);
+
static void Console(apr_pool_t *pool, int client) {
passwd *passwd;
if (const char *username = getenv("LOGNAME"))
mode_ = Working;
if (line == NULL)
break;
+ if (line[0] == '\0')
+ goto read;
if (!extra) {
extra = true;
if (debug)
std::cout << code << std::endl;
+ code = "with(Cycript.all){" + code + "}";
Run(client, code, fout, expand);
}
- _syscall(close(_syscall(open(histfile, O_CREAT | O_WRONLY, 0600))));
- append_history(histlines, histfile);
+ if (append_history$ != NULL) {
+ _syscall(close(_syscall(open(histfile, O_CREAT | O_WRONLY, 0600))));
+ (*append_history$)(histlines, histfile);
+ } else {
+ write_history(histfile);
+ }
fputs("\n", fout);
fflush(fout);
bool tty(isatty(STDIN_FILENO));
bool compile(false);
+ append_history$ = reinterpret_cast<int (*)(int, const char *)>(dlsym(RTLD_DEFAULT, "append_history"));
+
#ifdef CY_ATTACH
pid_t pid(_not(pid_t));
#endif
int main(int argc, char const * const argv[], char const * const envp[]) {
apr_status_t status(apr_app_initialize(&argc, &argv, &envp));
+
if (status != APR_SUCCESS) {
fprintf(stderr, "apr_app_initialize() != APR_SUCCESS\n");
return 1;