**/
/* }}} */
+#include "cycript.hpp"
+
#include <dlfcn.h>
#include <pthread.h>
#include <unistd.h>
#include <CoreFoundation/CoreFoundation.h>
#endif
-#include "cycript.hpp"
-
+#include "Driver.hpp"
#include "JavaScript.hpp"
-#include "Parser.hpp"
+#include "Syntax.hpp"
#include "Pooling.hpp"
-#include "Cycript.tab.hh"
-#include "Driver.hpp"
-
struct CYExecute_ {
CYPool &pool_;
const char * volatile data_;
return NULL;
}
-extern "C" void CYHandleClient(int socket) {
+void CYHandleClient(int socket) {
// XXX: this leaks memory... really?
CYPool *pool(new CYPool());
CYClient *client(new(*pool) CYClient(socket));
CYHandleClient(socket);
}
-extern "C" void CYHandleServer(pid_t pid) { try {
+_extern void CYHandleServer(pid_t pid) { try {
char path[1024];
sprintf(path, "/tmp/.s.cy.%u", pid);
CYHandleSocket(path);
fprintf(stderr, "%s\n", error.PoolCString(pool));
} }
-extern "C" char *MSmain0(int argc, char *argv[]) { try {
+_extern char *MSmain0(int argc, char *argv[]) { try {
_assert(argc == 2);
CYHandleSocket(argv[1]);
void Listen() {
socket_ = _syscall(::socket(PF_INET, SOCK_STREAM, 0)); try {
+ int value;
+ _syscall(::setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &(value = 1), sizeof(value)));
+
sockaddr_in address;
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
return NULL;
}
-extern "C" void CYListenServer(short port) {
+_extern void CYListenServer(short port) {
CYInitializeDynamic();
CYServer *server(new CYServer(port));