int main(int argc, char *argv[]) { int r = 0; srand(getpid()); if (argc >= 2 && argv[1][0] == 'r' || argc == 3 && argv[2][0] == 'r') r = rand() % 32; mprotect((void*)((unsigned int)Name & 0xfffffffffffff000), 1, PROT_READ | PROT_WRITE /* | PROT_EXEC */); // cannot execute !!! if (argc >= 2 && argv[1][0] == 's' || argc == 3 && argv[2][0] == 's') init_sandbox(); #ifdef DEBUG printf("grade %x Name %x r %d\n", grade, Name, r); #endif printf("What is your name?\n"); readString(Name, r); if (strcmp(Name, "Andrew Appel") == 0) grade = 'C'; printf("Thank you, %s.\n", Name); printf("I recommend that you get a grade of %c on this assignment.\n", grade); exit(0); }
void init(int32_t argc, char *argv[]) { ::setlocale(LC_ALL, ""); if (options(&argc, argv)) _exit(0); int32_t cpus = 0; os_base::CPUs(cpus); if (cpus < 2) cpus = 2; exlib::Service::init(cpus + 1); init_prof(); init_argv(argc, argv); init_date(); init_rt(); init_sandbox(); init_acThread(); init_logger(); init_net(); init_fiber(); srand((unsigned int)time(0)); v8::Platform *platform = v8::platform::CreateDefaultPlatform(); v8::V8::InitializePlatform(platform); v8::V8::Initialize(); }
void lua_player::run_global_scope() { QObject::disconnect(this, SIGNAL (started ())); luaL_openlibs(L); luabind::open(L); luabind::module(L, "ghtv") [ luabind::class_<lua_player>("lua_player") ]; init_sandbox(); init_canvas(); init_event(); start_time = boost::posix_time::microsec_clock::universal_time(); QObject::connect(this, SIGNAL(resume_current_frame_signal (int)), this , SLOT(resume_current_frame (int)), Qt::QueuedConnection); QObject::connect(this, SIGNAL(run_require_signal (std::string)), this , SLOT(run_require_slot (std::string)), Qt::QueuedConnection); try { main_file_url = player::create_url(path, root_path); lua_path = main_file_url.path ().toStdString (); { std::string::reverse_iterator iterator = std::find(lua_path.rbegin(), lua_path.rend(), '/') , iterator_backslash = std::find(lua_path.rbegin(), lua_path.rend(), '\\'); iterator = (std::min)(iterator, iterator_backslash); if(iterator != lua_path.rend()) lua_path.erase(boost::prior(iterator.base()), lua_path.end()); else { std::string error_msg = "Couldn't create a absolute path from the path for the NCL file: "; error_msg += lua_path; ncl_window->error_occurred(error_msg); return; } } activate_frame(path, main_file_url.toString ().toStdString ()); QObject::connect(current_activation_frame (), SIGNAL(execution_finished ()) , this, SLOT(global_scope_finished ())); QObject::connect(this, SIGNAL(signal_all_execution_finished ()) , this, SLOT(try_unqueue_events ()), Qt::QueuedConnection); QObject::connect(this, SIGNAL(signal_try_unqueue_event ()) , this, SLOT(try_unqueue_event ()), Qt::QueuedConnection); assert(pending_download_file == 0); pending_download_file = new player::url_file(main_file_url, this); if(!pending_download_file->local()) { QObject::connect(this, SIGNAL(download_lua_signal ()), this , SLOT(download_global ()), Qt::QueuedConnection); QObject::connect(pending_download_file, SIGNAL(download_finished_signal()), this , SLOT(download_lua())); QObject::connect(pending_download_file, SIGNAL(error_signal(std::string)), this , SLOT(download_error(std::string))); } else { QObject::connect(this, SIGNAL(download_lua_signal ()), this , SLOT(download_global ()), Qt::QueuedConnection); Q_EMIT download_lua_signal(); } } catch(std::exception const& e) { std::string error = "Error loading file "; error += root_path; error += '/'; error += path; error += " with error: "; error += e.what(); ncl_window->error_occurred(error); } }