/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2013 Jay Freeman (saurik)
+ * Copyright (C) 2009-2015 Jay Freeman (saurik)
*/
-/* GNU General Public License, Version 3 {{{ */
+/* GNU Affero General Public License, Version 3 {{{ */
/*
- * Cycript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * Cycript is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
/* }}} */
case Parsing:
longjmp(ctrlc_, 1);
case Running:
- throw "*** Ctrl-C";
+ CYCancel();
+ return;
case Sending:
return;
case Waiting:
~History() {
if (append_history$ != NULL) {
- _syscall(close(_syscall(open(histfile_.c_str(), O_CREAT | O_WRONLY, 0600))));
+ int fd(_syscall(open(histfile_.c_str(), O_CREAT | O_WRONLY, 0600)));
+ _syscall(close(fd));
_assert((*append_history$)(histlines_, histfile_.c_str()) == 0);
} else {
_assert(write_history(histfile_.c_str()) == 0);
};
static void Console(CYOptions &options) {
- CYPool pool;
-
- passwd *passwd;
- if (const char *username = getenv("LOGNAME"))
- passwd = getpwnam(username);
- else
- passwd = getpwuid(getuid());
+ std::string basedir;
+ if (const char *home = getenv("HOME"))
+ basedir = home;
+ else {
+ passwd *passwd;
+ if (const char *username = getenv("LOGNAME"))
+ passwd = getpwnam(username);
+ else
+ passwd = getpwuid(getuid());
+ basedir = passwd->pw_dir;
+ }
- std::string basedir(passwd->pw_dir);
basedir += "/.cycript";
mkdir(basedir.c_str(), 0700);
if (parser.parse() != 0 || !driver.errors_.empty()) {
for (CYDriver::Errors::const_iterator error(driver.errors_.begin()); error != driver.errors_.end(); ++error) {
- cy::position begin(error->location_.begin);
+ CYPosition begin(error->location_.begin);
if (begin.line != lines.size() || begin.column < lines.back().size() || error->warning_) {
- cy::position end(error->location_.end);
+ CYPosition end(error->location_.end);
if (begin.line != lines.size()) {
std::cerr << " | ";
}
}
-void InjectLibrary(pid_t pid);
+void InjectLibrary(pid_t, int, const char *[]);
int Main(int argc, char * const argv[], char const * const envp[]) {
bool tty(isatty(STDIN_FILENO));
#endif
"r:"
"s"
- , (struct option[]) {
+ , (const struct option[]) {
{NULL, no_argument, NULL, 'c'},
{NULL, required_argument, NULL, 'g'},
{NULL, required_argument, NULL, 'n'},
memset(&address, 0, sizeof(address));
address.sun_family = AF_UNIX;
- sprintf(address.sun_path, "/tmp/.s.cy.%u", getpid());
+ const char *tmp;
+#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
+ tmp = "/Library/Caches";
+#else
+ tmp = "/tmp";
+#endif
+
+ sprintf(address.sun_path, "%s/.s.cy.%u", tmp, getpid());
unlink(address.sun_path);
struct File {
_syscall(chmod(address.sun_path, 0777));
_syscall(listen(server, 1));
- InjectLibrary(pid);
+ InjectLibrary(pid, 1, (const char *[]) {address.sun_path, NULL});
client_ = _syscall(accept(server, NULL, NULL));
}
#else