#endif
#include <errno.h>
+#include <getopt.h>
+#include <signal.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <pwd.h>
-#include <apr_getopt.h>
-#include <apr_pools.h>
-#include <apr_strings.h>
-
#include <dlfcn.h>
#include "Display.hpp"
static int client_;
static char **Complete(const char *word, int start, int end) {
- rl_attempted_completion_over = TRUE;
+ rl_attempted_completion_over = ~0;
CYLocalPool pool;
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);
-
+int Main(int argc, char * const argv[], char const * const envp[]) {
bool tty(isatty(STDIN_FILENO));
bool compile(false);
bool target(false);
const char *host(NULL);
const char *port(NULL);
- apr_getopt_t *state;
- _aprcall(apr_getopt_init(&state, pool, argc, argv));
+ optind = 1;
for (;;) {
- int opt;
- const char *arg;
-
- apr_status_t status(apr_getopt_long(state, (apr_getopt_option_t[]) {
- {NULL, 'c', false, NULL},
- {NULL, 'g', true, NULL},
- {NULL, 'n', true, NULL},
+ int option(getopt_long(argc, argv,
+ "c"
+ "g:"
+ "n:"
#ifdef CY_ATTACH
- {NULL, 'p', true, NULL},
+ "p:"
#endif
- {NULL, 'r', true, NULL},
- {NULL, 's', false, NULL},
- {0, 0, 0, 0}}, &opt, &arg));
+ "r:"
+ "s"
+ , (struct option[]) {
+ {NULL, no_argument, NULL, 'c'},
+ {NULL, required_argument, NULL, 'g'},
+ {NULL, required_argument, NULL, 'n'},
+#ifdef CY_ATTACH
+ {NULL, required_argument, NULL, 'p'},
+#endif
+ {NULL, required_argument, NULL, 'r'},
+ {NULL, no_argument, NULL, 's'},
+ {0, 0, 0, 0}}, NULL));
- switch (status) {
- case APR_EOF:
+ switch (option) {
+ case -1:
goto getopt;
- case APR_BADCH:
- case APR_BADARG:
+
+ case ':':
+ case '?':
fprintf(stderr,
"usage: cycript [-c]"
#ifdef CY_ATTACH
" [<script> [<arg>...]]\n"
);
return 1;
- default:
- _aprcall(status);
- }
- switch (opt) {
target:
if (!target)
target = true;
case 'g':
if (false);
- else if (strcmp(arg, "rename") == 0)
+ else if (strcmp(optarg, "rename") == 0)
options.verbose_ = true;
#if YYDEBUG
- else if (strcmp(arg, "bison") == 0)
+ else if (strcmp(optarg, "bison") == 0)
bison_ = true;
#endif
else {
case 'n':
if (false);
- else if (strcmp(arg, "minify") == 0)
+ else if (strcmp(optarg, "minify") == 0)
pretty_ = true;
else {
fprintf(stderr, "invalid name for -n\n");
#ifdef CY_ATTACH
case 'p': {
- size_t size(strlen(arg));
+ size_t size(strlen(optarg));
char *end;
- pid = strtoul(arg, &end, 0);
- if (arg + size != end) {
+ pid = strtoul(optarg, &end, 0);
+ if (optarg + size != end) {
// XXX: arg needs to be escaped in some horrendous way of doom
- const char *command(apr_pstrcat(pool, "ps axc|sed -e '/^ *[0-9]/{s/^ *\\([0-9]*\\)\\( *[^ ]*\\)\\{3\\} *-*\\([^ ]*\\)/\\3 \\1/;/^", arg, " /{s/^[^ ]* //;q;};};d'", NULL));
+ // XXX: this is a memory leak now because I just don't care enough
+ char *command;
+ asprintf(&command, "ps axc|sed -e '/^ *[0-9]/{s/^ *\\([0-9]*\\)\\( *[^ ]*\\)\\{3\\} *-*\\([^ ]*\\)/\\3 \\1/;/^%s /{s/^[^ ]* //;q;};};d'", optarg);
if (FILE *pids = popen(command, "r")) {
char value[32];
}
if (pid == _not(pid_t)) {
- fprintf(stderr, "unable to find process `%s' using ps\n", arg);
+ fprintf(stderr, "unable to find process `%s' using ps\n", optarg);
return 1;
}
}
#endif
case 'r': {
- //size_t size(strlen(arg));
+ //size_t size(strlen(optarg));
- char *colon(strrchr(arg, ':'));
+ char *colon(strrchr(optarg, ':'));
if (colon == NULL) {
fprintf(stderr, "missing colon in hostspec\n");
return 1;
/*char *end;
port = strtoul(colon + 1, &end, 10);
- if (end != arg + size) {
+ if (end != optarg + size) {
fprintf(stderr, "invalid port in hostspec\n");
return 1;
}*/
- host = arg;
+ host = optarg;
*colon = '\0';
port = colon + 1;
} goto target;
case 's':
strict_ = true;
break;
+
+ default:
+ _assert(false);
}
- } getopt:;
+ }
+
+ getopt:
+ argc -= optind;
+ argv += optind;
const char *script;
- int ind(state->ind);
#ifdef CY_ATTACH
- if (pid != _not(pid_t) && ind < argc - 1) {
+ if (pid != _not(pid_t) && argc > 1) {
fprintf(stderr, "-p cannot set argv\n");
return 1;
}
#endif
- if (ind == argc)
+ if (argc == 0)
script = NULL;
else {
#ifdef CY_EXECUTE
// XXX: const_cast?! wtf gcc :(
- CYSetArgs(argc - ind - 1, const_cast<const char **>(argv + ind + 1));
+ CYSetArgs(argc - 1, const_cast<const char **>(argv + 1));
#endif
- script = argv[ind];
+ script = argv[0];
if (strcmp(script, "-") == 0)
script = NULL;
}
}
}
- apr_pool_destroy(pool);
-
return 0;
}
-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;
- } else try {
+int main(int argc, char * const argv[], char const * const envp[]) {
+ try {
return Main(argc, argv, envp);
} catch (const CYException &error) {
CYPool pool;
#define _syscall(expr) \
_syscall_(expr, 0, {})
-#define _aprcall(expr) \
- do { \
- apr_status_t _aprstatus((expr)); \
- _assert_("aprcall", _aprstatus == APR_SUCCESS, #expr, ""); \
- } while (false)
-
#define _krncall(expr) \
do { \
kern_return_t _krnstatus((expr)); \
if CY_CONSOLE
bin_PROGRAMS = cycript
cycript_SOURCES = Console.cpp Display.cpp
-cycript_LDADD = libcycript.la $(LTLIBAPR) $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) -ldl
+cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) -ldl
ldid = true
entitle = $(ldid) -S$(srcdir)/cycript.xml
config.guess config.rpath config.sub install-sh missing \
ltmain.sh
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/find_apr.m4 \
- $(top_srcdir)/m4/framework.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/framework.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
cycript_OBJECTS = $(am_cycript_OBJECTS)
@CY_CONSOLE_TRUE@cycript_DEPENDENCIES = libcycript.la \
@CY_CONSOLE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-@CY_CONSOLE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@CY_CONSOLE_TRUE@ $(am__DEPENDENCIES_1)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
LN_S = @LN_S@
LTFLAGS = @LTFLAGS@
LTJAVASCRIPTCORE = @LTJAVASCRIPTCORE@
-LTLIBAPR = @LTLIBAPR@
LTLIBFFI = @LTLIBFFI@
LTLIBGCC = @LTLIBGCC@
LTLIBOBJS = @LTLIBOBJS@
filters = $(CY_FILTERS) $(am__append_4) $(am__append_6)
@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Display.cpp \
@CY_CONSOLE_TRUE@ $(am__append_10)
-@CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBAPR) $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) -ldl
+@CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) -ldl
@CY_CONSOLE_TRUE@ldid = true
@CY_CONSOLE_TRUE@entitle = $(ldid) -S$(srcdir)/cycript.xml
all: config.h
LIBFFI_CFLAGS
CY_EXECUTE_FALSE
CY_EXECUTE_TRUE
-LTLIBAPR
CY_CONSOLE_FALSE
CY_CONSOLE_TRUE
LTJAVASCRIPTCORE
enable_libtool_lock
enable_javascript
enable_console
-with_apr
'
ac_precious_vars='build_alias
host_alias
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
- --with-apr=PATH prefix for installed APR or the full path to
- apr-config
Some influential environment variables:
CC C compiler command
fi
-if test -z "$CY_CONSOLE_TRUE"; then :
-
-if test "x$LTLIBAPR" != x; then :
-
-
-
-else
-
-
- apr_found="no"
-
- if test "$target_os" = "os2-emx"; then
- # Scripts don't pass test -x on OS/2
- TEST_X="test -f"
- else
- TEST_X="test -x"
- fi
-
- acceptable_majors="1"
-
- apr_temp_acceptable_apr_config=""
- for apr_temp_major in $acceptable_majors
- do
- case $apr_temp_major in
- 0)
- apr_temp_acceptable_apr_config="$apr_temp_acceptable_apr_config apr-config"
- ;;
- *)
- apr_temp_acceptable_apr_config="$apr_temp_acceptable_apr_config apr-$apr_temp_major-config"
- ;;
- esac
- done
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for APR" >&5
-$as_echo_n "checking for APR... " >&6; }
-
-# Check whether --with-apr was given.
-if test "${with_apr+set}" = set; then :
- withval=$with_apr;
- if test "$withval" = "no" || test "$withval" = "yes"; then
- as_fn_error $? "--with-apr requires a directory or file to be provided" "$LINENO" 5
- fi
-
- for apr_temp_apr_config_file in $apr_temp_acceptable_apr_config
- do
- for lookdir in "$withval/bin" "$withval"
- do
- if $TEST_X "$lookdir/$apr_temp_apr_config_file"; then
- apr_config="$lookdir/$apr_temp_apr_config_file"
-
- apr_found="yes"
- break 2
- fi
- done
- done
-
- if test "$apr_found" != "yes" && $TEST_X "$withval" && $withval --help > /dev/null 2>&1 ; then
- apr_config="$withval"
- apr_found="yes"
- fi
-
- if test "$apr_found" != "yes"; then
- as_fn_error $? "the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file." "$LINENO" 5
- fi
-
-else
-
- if test -n "1" && test "1" = "1"; then
- for apr_temp_apr_config_file in $apr_temp_acceptable_apr_config
- do
- if $apr_temp_apr_config_file --help > /dev/null 2>&1 ; then
- apr_config="$apr_temp_apr_config_file"
-
- apr_found="yes"
- break
- else
- for lookdir in /usr /usr/local /usr/local/apr /opt/apr; do
- if $TEST_X "$lookdir/bin/$apr_temp_apr_config_file"; then
- apr_config="$lookdir/bin/$apr_temp_apr_config_file"
-
- apr_found="yes"
- break 2
- fi
- done
- fi
- done
- fi
- if test "$apr_found" = "no" && test -d ""; then
- apr_temp_abs_srcdir="`cd && pwd`"
- apr_found="reconfig"
- apr_bundled_major="`sed -n '/#define.*APR_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"/include/apr_version.h\"`"
- case $apr_bundled_major in
- "")
- as_fn_error $? "failed to find major version of bundled APR" "$LINENO" 5
- ;;
- 0)
- apr_temp_apr_config_file="apr-config"
- ;;
- *)
- apr_temp_apr_config_file="apr-$apr_bundled_major-config"
- ;;
- esac
- if test -n ""; then
- apr_config="/$apr_temp_apr_config_file"
- else
- apr_config="/$apr_temp_apr_config_file"
- fi
- fi
-
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $apr_found" >&5
-$as_echo "$apr_found" >&6; }
-
-case $apr_found in #(
- yes) :
-
-
- for element in `$apr_config --includes`; do
- haveit=
- for x in $CPPFLAGS; do
-
- acl_save_prefix="$prefix"
- prefix="$acl_final_prefix"
- acl_save_exec_prefix="$exec_prefix"
- exec_prefix="$acl_final_exec_prefix"
- eval x=\"$x\"
- exec_prefix="$acl_save_exec_prefix"
- prefix="$acl_save_prefix"
-
- if test "X$x" = "X$element"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
- fi
- done
-
-
- for element in `$apr_config --link-libtool`; do
- haveit=
- for x in $LTLIBAPR; do
-
- acl_save_prefix="$prefix"
- prefix="$acl_final_prefix"
- acl_save_exec_prefix="$exec_prefix"
- exec_prefix="$acl_final_exec_prefix"
- eval x=\"$x\"
- exec_prefix="$acl_save_exec_prefix"
- prefix="$acl_save_prefix"
-
- if test "X$x" = "X$element"; then
- haveit=yes
- break
- fi
- done
- if test -z "$haveit"; then
- LTLIBAPR="${LTLIBAPR}${LTLIBAPR:+ }$element"
- fi
- done
-
-
- ;; #(
- *) :
-
- as_fn_error $? "missing \"libapr\"" "$LINENO" 5
- ;;
-esac
-fi
-
-fi
-
if test "x$CY_EXECUTE" = x1; then
AC_ARG_ENABLE([console], AS_HELP_STRING([--disable-console], [disable console]))
AM_CONDITIONAL([CY_CONSOLE], [test "x$enable_console" != "xno"])
-AM_COND_IF([CY_CONSOLE], [
-dnl APR_FIND_APR {{{
-AS_IF([test "x$LTLIBAPR" != x], [
- AC_SUBST([LTLIBAPR])
-], [
- APR_FIND_APR([], [], [1], [1])
-AS_CASE([$apr_found], [yes], [
- AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`])
- AC_LIB_APPENDTOVAR([LTLIBAPR], [`$apr_config --link-libtool`])
- AC_SUBST([LTLIBAPR])
-], [
- AC_MSG_ERROR([missing "libapr"])
-])])
-dnl }}}
-])
-
AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [
PKG_CHECK_MODULES([LIBFFI], [libffi], [
AC_LIB_APPENDTOVAR([CPPFLAGS], [`$PKG_CONFIG --cflags libffi`])
Version: #
Description: runtime execution server and disassembler
Name: Cycript
-Depends: apr-lib, readline, adv-cmds
+Depends: readline, adv-cmds
Pre-Depends: dpkg (>= 1.14.25-8)
Breaks: cydget (<< 0.9.4008)
Author: Jay Freeman (saurik) <saurik@saurik.com>
[[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
# XXX: this is now all broken
-depends := apr-lib, readline, libffi (>= 1:3.0.10-5), adv-cmds
+depends := readline, libffi (>= 1:3.0.10-5), adv-cmds
ifeq ($(depends)$(dll),dylib)
control.tmp: control.in $(binary) .libs/$(lib)cycript.dylib
$(sed) -e 's/&/'"$$(dpkg-query -S $$(otool -lah $(binary) .libs/*.dylib | grep dylib | grep -v ':$$' | $(sed) -e 's/^ *name //;s/ (offset [0-9]*)$$//' | sort -u) 2>/dev/null | $(sed) -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
rm -rf sysroot.ios
mkdir -p sysroot.ios
-for deb in apr-lib_1.3.3-2 ncurses_5.7-12 readline_6.0-7; do
+for deb in ncurses_5.7-12 readline_6.0-7; do
deb=${deb}_iphoneos-arm.deb
[[ -f "${deb}" ]] || wget http://apt.saurik.com/debs/"${deb}"
tar=data.tar.lzma
rm -f "${tar}"
done
-ln -s /usr/include/apr-1 sysroot.ios/usr/include
mv sysroot.ios/usr/lib/_ncurses/* sysroot.ios/usr/lib
rmdir sysroot.ios/usr/lib/_ncurses
if [[ ${arch} != armv6 ]]; then
flg+=(--disable-console)
else
- flg+=(LTLIBAPR="../sysroot.ios/usr/lib/libapr-1.dylib")
flg+=(LTLIBGCC="-lgcc_s.1")
cpf+=" -include ${PWD}/xcode.h"
cpf+=" -mllvm -arm-reserve-r9"
- cpf+=" -I../sysroot.ios/usr/include -I../sysroot.ios/usr/include/apr-1"
+ cpf+=" -I../sysroot.ios/usr/include"
ldf+=" -L../sysroot.ios/usr/lib"
fi