static int execute_csharp_using_sscli (const char *assembly_path, const char * const *libdirs, unsigned int libdirs_count, const char * const *args, unsigned int nargs, bool verbose, bool quiet, execute_fn *executer, void *private_data) { static bool clix_tested; static bool clix_present; if (!clix_tested) { /* Test for presence of clix: "clix >/dev/null 2>/dev/null ; test $? = 1" */ char *argv[2]; int exitstatus; argv[0] = "clix"; argv[1] = NULL; exitstatus = execute ("clix", "clix", argv, false, false, true, true, true, false, NULL); clix_present = (exitstatus == 0 || exitstatus == 1); clix_tested = true; } if (clix_present) { char *old_clixpath; char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); unsigned int i; bool err; /* Set clix' PATH variable. */ old_clixpath = set_clixpath (libdirs, libdirs_count, false, verbose); argv[0] = "clix"; argv[1] = (char *) assembly_path; for (i = 0; i <= nargs; i++) argv[2 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("clix", "clix", argv, private_data); /* Reset clix' PATH variable. */ reset_clixpath (old_clixpath); freea (argv); return err; } else return -1; }
int main(int argc, char* argv[]) { // exactly two parameters should be passed if (argc != 3) { std::cerr << "Usage: " << argv[0] << " {query number} {full path to the file with query}" << std::endl; return -1; } // query id and object representing query itself int query_id = atoi(argv[1]); Operation query; // parse the protocol-buffer binary file and create query object int file = open(argv[2], O_RDONLY); google::protobuf::io::FileInputStream input(file); google::protobuf::TextFormat::Parse(&input, &query); // create server which will serve the data Server *server = CreateServer(query_id); // execute query OperationExecuter executer(query, server); executer.executeToServer(); // delete server - this stops the timer // and triggers correctness check delete server; return 0; }
int main(int argc, char** argv) { //First, we need to create a state to keep our script. //It is recommended to have only one state across the program. lw::cState state; //Lets open our state: state.open(); //Register the class: MyClass::registerClass(state); //Create an executer so we can load and run a script lw::cExecuter executer(state); //Run the script executer.loadAndRunScript("script.lua"); //Note: The executer accepts exported classes as a function parameter (executer.push(<class instance>) //This way, you can instance classes in C++, and pass them to lua. //We're done, destroy the state: state.destroy(); return 0; }
/* ** Calls execve if necessary */ void execve_call(char **instrucs, int i, t_list **my_environ) { if (!(instrucs[i + 1] && get_redirec(instrucs[i + 1]) && get_redirec(instrucs[i + 1]) != red_pipe)) executer(instrucs[i], my_environ); else exit(1); }
// Main bool AppMain(const std::vector<std::wstring>& Args) { if (Args.size() != 4) { Usage(); return true; } const auto pid = std::stoul(Args[1]); const auto installationMethod = std::wstring(Args[2]); const auto executionMethod = std::wstring(Args[3]); std::shared_ptr<REMOTE_MEMORY_BLOCK>(*installer)(HANDLE) = nullptr; if (installationMethod == L"alloc") { installer = InstallCodeWithVirtualAllocEx; } else if (installationMethod == L"section") { installer = InstallCodeWithZwMapViewOfSection; } DWORD (*executer)(HANDLE, REMOTE_MEMORY_BLOCK*) = nullptr; if (executionMethod == L"remote") { executer = ExecuteCodeWithCreateRemoteThread; } else if (executionMethod == L"context") { executer = ExecuteCodeWithSetThreadContext; } if (!installer || !executer) { Usage(); return false; } const auto processHandle = stdexp::make_unique_resource(Open32BitProcess(pid), &::CloseHandle); if (!processHandle) { return false; } // Inject code const auto remoteMemory = installer(processHandle.get()); if (!remoteMemory) { return false; } std::cout << "Remote Address : " << std::hex << remoteMemory.get() << std::endl; // Execute code const auto remoteThreadId = executer(processHandle.get(), remoteMemory.get()); if (!remoteThreadId) { return false; } std::cout << "Remote Thread ID : " << std::dec << remoteThreadId << std::endl; // Do not execute a destructor for remoteMemory that will release remote code ::ExitProcess(EXIT_SUCCESS); }
void ReconstructionManagerTestFixture::reconstruct() { mOutput.clear(); cx::UsReconstructionServicePtr reconstructer = this->getManager(); bool createBModeWhenAngio = reconstructer->getParam("Dual Angio")->getValueAsVariant().toBool(); cx::ReconstructionExecuterPtr executer(new cx::ReconstructionExecuter(mPatientModelService, mViewService)); executer->startNonThreadedReconstruction(reconstructer->createAlgorithm(), reconstructer->createCoreParameters(), reconstructer->getSelectedFileData(), createBModeWhenAngio); mOutput = executer->getResult(); }
void STimer::AddTask( tick_t elapsed_ms, TaskExecute&& executer ) { if(_stop || !executer) { return; } auto self = shared_from_this(); _timer->AddTask( elapsed_ms, [=] { _mutex.lock(); if(!self->_stop) { executer(); } _mutex.unlock(); } ); }
int main() { FP fp1; // 함수 포인터 별칭으로 변수 선언 fp1 = add; printf("%d\n", fp1(10, 20)); // 30 FP fp[10]; // 함수 포인터 별칭으로 배열 선언 fp[0] = add; printf("%d\n", fp[0](30, 40)); // 70 struct Calc c; c.fp = add; printf("%d\n", c.fp(50, 60)); // 110 executer(add); // 150: executer를 호출할 때 add 함수의 메모리 주소를 전달 return 0; }
int PCB_ExecuteInstruction(int line) { char sentence[50]; char instruction[5]; int (*executer)(char *); int paramStart; strncpy(sentence, PCB.Code[line], 50); strncpy(instruction, sentence, 4); instruction[4] = '\0'; Log_printf( log_info, "Sentencia: %s", sentence ); Log_printf( log_info, "Comando: %s", instruction ); if ( !strcmp("MEM ", instruction) ) { executer = PCB_ExecuteMem; } else if ( !strcmp("OPER", instruction) ) { executer = PCB_ExecuteOper; } else if ( !strcmp("SOL ", instruction) ) { executer = PCB_ExecuteSol; } else if ( !strcmp("DEV ", instruction) ) { executer = PCB_ExecuteDev; } else if ( !strcmp("IMP ", instruction) ) { executer = PCB_ExecuteImp; } else if ( !strcmp("PUSH", instruction) ) { executer = PCB_ExecutePush; } else if ( !strncmp("POP", instruction, 3) ) { executer = PCB_ExecutePop; } else { Log_log( log_error, "Comando no reconocido, checkee el script"); } if ( sentence[3] == ' ' ) { paramStart = 4; } else if ( sentence[4] == ' ') { paramStart = 5; } executer(sentence+paramStart); /*SetRemainingTime(PCB_RemainingTimeExecution());*/ return 0; }
void UsReconstructionImplService::startReconstruction() { if(!mOutputVolumeParams.isValid()) { reportError("Cannot reconstruct from invalid ultrasound data"); return; } ReconstructionMethodService* algo = this->createAlgorithm(); ReconstructCore::InputParams par = this->createCoreParameters(); USReconstructInputData fileData = mOriginalFileData; fileData.mUsRaw = mOriginalFileData.mUsRaw->copy(); ReconstructionExecuterPtr executer(new ReconstructionExecuter(mPatientModelService, mViewService)); connect(executer.get(), SIGNAL(reconstructAboutToStart()), this, SIGNAL(reconstructAboutToStart())); connect(executer.get(), SIGNAL(reconstructStarted()), this, SIGNAL(reconstructStarted())); connect(executer.get(), SIGNAL(reconstructFinished()), this, SIGNAL(reconstructFinished())); connect(executer.get(), SIGNAL(reconstructFinished()), this, SLOT(reconstructFinishedSlot())); mExecuters.push_back(executer); executer->startReconstruction(algo, par, fileData, mParams->getCreateBModeWhenAngio()->getValue()); }
void ReconstructionManagerTestFixture::threadedReconstruct() { mOutput.clear(); cx::UsReconstructionServicePtr reconstructer = this->getManager(); cx::ReconstructionExecuterPtr executer(new cx::ReconstructionExecuter(mPatientModelService, mViewService)); bool createBModeWhenAngio = reconstructer->getParam("Dual Angio")->getValueAsVariant().toBool(); executer->startReconstruction(reconstructer->createAlgorithm(), reconstructer->createCoreParameters(), reconstructer->getSelectedFileData(), createBModeWhenAngio); cx::TimedAlgorithmPtr thread = executer->getThread(); QObject::connect(thread.get(), SIGNAL(finished()), qApp, SLOT(quit())); qApp->exec(); REQUIRE(thread->isFinished()); REQUIRE(!thread->isRunning()); mOutput = executer->getResult(); }
int main() { //preparing char order[INPUT_LENGTH]; int executer_returned; //change directory char *home_path; home_path = getenv("HOME"); chdir(home_path); //read config FILE *stdin_backup = stdin; if ((stdin = fopen(CONFIG_FILE_PATH, "r")) == 0) stdin = stdin_backup; //main loop while (1) { if (stdin == stdin_backup) printf(">"); for (int i = 0; i < INPUT_LENGTH; i++) order[i] = 0; scanf("%s", order); executer_returned = executer(order); if (executer_returned && (stdin == stdin_backup)) break; else if (executer_returned && (stdin != stdin_backup)) { fclose(stdin); stdin = stdin_backup; printf("\nWelcome to Musica\n" "If you don't know how to use it,entry \"help\"\n"); } } printf("Bye!\n"); return 0; }
int main(int argc, char** argv) { //First, we need to create a state to keep our script. //It is recommended to have only one state accross the program. lw::cState state; //Lets open our state: state.open(); //Register the function state.registerFunction("myCFunction", myFunction); //Create an executer so we can load and run a script lw::cExecuter executer(state); //Run the script //Note that running the script is needed to put the byte code on the stack executer.loadAndRunScript("script.lua"); //We're done, destroy the state: state.destroy(); return 0; }
int main() { struct Person p[3]; p[0].print = print; p[1].print = print; p[2].print = print; scanf("%s %d %s %d %s %d", p[0].name, &p[0].age, p[1].name, &p[1].age, p[2].name, &p[2].age ); void (*fp[3])(struct Person *); for (int i = 0; i < sizeof(p) / sizeof(struct Person); i++) { fp[i] = getPrintFunc(&p[i]); } executer(fp, p, sizeof(p) / sizeof(struct Person)); return 0; }
static int execute_csharp_using_pnet (const char *assembly_path, const char * const *libdirs, unsigned int libdirs_count, const char * const *args, unsigned int nargs, bool verbose, bool quiet, execute_fn *executer, void *private_data) { static bool ilrun_tested; static bool ilrun_present; if (!ilrun_tested) { /* Test for presence of ilrun: "ilrun --version >/dev/null 2>/dev/null" */ char *argv[3]; int exitstatus; argv[0] = "ilrun"; argv[1] = "--version"; argv[2] = NULL; exitstatus = execute ("ilrun", "ilrun", argv, false, false, true, true, true, false, NULL); ilrun_present = (exitstatus == 0); ilrun_tested = true; } if (ilrun_present) { unsigned int argc; char **argv; char **argp; unsigned int i; bool err; argc = 1 + 2 * libdirs_count + 1 + nargs; argv = (char **) xmalloca ((argc + 1) * sizeof (char *)); argp = argv; *argp++ = "ilrun"; for (i = 0; i < libdirs_count; i++) { *argp++ = "-L"; *argp++ = (char *) libdirs[i]; } *argp++ = (char *) assembly_path; for (i = 0; i < nargs; i++) *argp++ = (char *) args[i]; *argp = NULL; /* Ensure argv length was correctly calculated. */ if (argp - argv != argc) abort (); if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("ilrun", "ilrun", argv, private_data); freea (argv); return err; } else return -1; }
static int execute_csharp_using_mono (const char *assembly_path, const char * const *libdirs, unsigned int libdirs_count, const char * const *args, unsigned int nargs, bool verbose, bool quiet, execute_fn *executer, void *private_data) { static bool mono_tested; static bool mono_present; if (!mono_tested) { /* Test for presence of mono: "mono --version >/dev/null 2>/dev/null" */ char *argv[3]; int exitstatus; argv[0] = "mono"; argv[1] = "--version"; argv[2] = NULL; exitstatus = execute ("mono", "mono", argv, false, false, true, true, true, false, NULL); mono_present = (exitstatus == 0); mono_tested = true; } if (mono_present) { char *old_monopath; char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); unsigned int i; bool err; /* Set MONO_PATH. */ old_monopath = set_monopath (libdirs, libdirs_count, false, verbose); argv[0] = "mono"; argv[1] = (char *) assembly_path; for (i = 0; i <= nargs; i++) argv[2 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("mono", "mono", argv, private_data); /* Reset MONO_PATH. */ reset_monopath (old_monopath); freea (argv); return err; } else return -1; }
bool execute_java_class (const char *class_name, const char * const *classpaths, unsigned int classpaths_count, bool use_minimal_classpath, const char *exe_dir, const char * const *args, bool verbose, bool quiet, execute_fn *executer, void *private_data) { bool err = false; unsigned int nargs; char *old_JAVA_HOME; /* Count args. */ { const char * const *arg; for (nargs = 0, arg = args; *arg != NULL; nargs++, arg++) ; } /* First, try a class compiled to a native code executable. */ if (exe_dir != NULL) { char *exe_pathname = concatenated_filename (exe_dir, class_name, EXEEXT); char *old_classpath; char **argv = (char **) xmalloca ((1 + nargs + 1) * sizeof (char *)); unsigned int i; /* Set CLASSPATH. */ old_classpath = set_classpath (classpaths, classpaths_count, use_minimal_classpath, verbose); argv[0] = exe_pathname; for (i = 0; i <= nargs; i++) argv[1 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer (class_name, exe_pathname, argv, private_data); /* Reset CLASSPATH. */ reset_classpath (old_classpath); freea (argv); goto done1; } { const char *java = getenv ("JAVA"); if (java != NULL && java[0] != '\0') { /* Because $JAVA may consist of a command and options, we use the shell. Because $JAVA has been set by the user, we leave all all environment variables in place, including JAVA_HOME, and we don't erase the user's CLASSPATH. */ char *old_classpath; unsigned int command_length; char *command; char *argv[4]; const char * const *arg; char *p; /* Set CLASSPATH. */ old_classpath = set_classpath (classpaths, classpaths_count, false, verbose); command_length = strlen (java); command_length += 1 + shell_quote_length (class_name); for (arg = args; *arg != NULL; arg++) command_length += 1 + shell_quote_length (*arg); command_length += 1; command = (char *) xmalloca (command_length); p = command; /* Don't shell_quote $JAVA, because it may consist of a command and options. */ memcpy (p, java, strlen (java)); p += strlen (java); *p++ = ' '; p = shell_quote_copy (p, class_name); for (arg = args; *arg != NULL; arg++) { *p++ = ' '; p = shell_quote_copy (p, *arg); } *p++ = '\0'; /* Ensure command_length was correctly calculated. */ if (p - command > command_length) abort (); if (verbose) printf ("%s\n", command); argv[0] = "/bin/sh"; argv[1] = "-c"; argv[2] = command; argv[3] = NULL; err = executer (java, "/bin/sh", argv, private_data); freea (command); /* Reset CLASSPATH. */ reset_classpath (old_classpath); goto done1; } } /* Unset the JAVA_HOME environment variable. */ old_JAVA_HOME = getenv ("JAVA_HOME"); if (old_JAVA_HOME != NULL) { old_JAVA_HOME = xstrdup (old_JAVA_HOME); unsetenv ("JAVA_HOME"); } { static bool gij_tested; static bool gij_present; if (!gij_tested) { /* Test for presence of gij: "gij --version > /dev/null" */ char *argv[3]; int exitstatus; argv[0] = "gij"; argv[1] = "--version"; argv[2] = NULL; exitstatus = execute ("gij", "gij", argv, false, false, true, true, true, false); gij_present = (exitstatus == 0); gij_tested = true; } if (gij_present) { char *old_classpath; char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); unsigned int i; /* Set CLASSPATH. */ old_classpath = set_classpath (classpaths, classpaths_count, use_minimal_classpath, verbose); argv[0] = "gij"; argv[1] = (char *) class_name; for (i = 0; i <= nargs; i++) argv[2 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("gij", "gij", argv, private_data); /* Reset CLASSPATH. */ reset_classpath (old_classpath); freea (argv); goto done2; } } { static bool java_tested; static bool java_present; if (!java_tested) { /* Test for presence of java: "java -version 2> /dev/null" */ char *argv[3]; int exitstatus; argv[0] = "java"; argv[1] = "-version"; argv[2] = NULL; exitstatus = execute ("java", "java", argv, false, false, true, true, true, false); java_present = (exitstatus == 0); java_tested = true; } if (java_present) { char *old_classpath; char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); unsigned int i; /* Set CLASSPATH. We don't use the "-classpath ..." option because in JDK 1.1.x its argument should also contain the JDK's classes.zip, but we don't know its location. (In JDK 1.3.0 it would work.) */ old_classpath = set_classpath (classpaths, classpaths_count, use_minimal_classpath, verbose); argv[0] = "java"; argv[1] = (char *) class_name; for (i = 0; i <= nargs; i++) argv[2 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("java", "java", argv, private_data); /* Reset CLASSPATH. */ reset_classpath (old_classpath); freea (argv); goto done2; } } { static bool jre_tested; static bool jre_present; if (!jre_tested) { /* Test for presence of jre: "jre 2> /dev/null ; test $? = 1" */ char *argv[2]; int exitstatus; argv[0] = "jre"; argv[1] = NULL; exitstatus = execute ("jre", "jre", argv, false, false, true, true, true, false); jre_present = (exitstatus == 0 || exitstatus == 1); jre_tested = true; } if (jre_present) { char *old_classpath; char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); unsigned int i; /* Set CLASSPATH. We don't use the "-classpath ..." option because in JDK 1.1.x its argument should also contain the JDK's classes.zip, but we don't know its location. */ old_classpath = set_classpath (classpaths, classpaths_count, use_minimal_classpath, verbose); argv[0] = "jre"; argv[1] = (char *) class_name; for (i = 0; i <= nargs; i++) argv[2 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("jre", "jre", argv, private_data); /* Reset CLASSPATH. */ reset_classpath (old_classpath); freea (argv); goto done2; } } #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ /* Win32, Cygwin */ { static bool jview_tested; static bool jview_present; if (!jview_tested) { /* Test for presence of jview: "jview -? >nul ; test $? = 1" */ char *argv[3]; int exitstatus; argv[0] = "jview"; argv[1] = "-?"; argv[2] = NULL; exitstatus = execute ("jview", "jview", argv, false, false, true, true, true, false); jview_present = (exitstatus == 0 || exitstatus == 1); jview_tested = true; } if (jview_present) { char *old_classpath; char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); unsigned int i; /* Set CLASSPATH. */ old_classpath = set_classpath (classpaths, classpaths_count, use_minimal_classpath, verbose); argv[0] = "jview"; argv[1] = (char *) class_name; for (i = 0; i <= nargs; i++) argv[2 + i] = (char *) args[i]; if (verbose) { char *command = shell_quote_argv (argv); printf ("%s\n", command); free (command); } err = executer ("jview", "jview", argv, private_data); /* Reset CLASSPATH. */ reset_classpath (old_classpath); freea (argv); goto done2; } } #endif if (!quiet) error (0, 0, _("Java virtual machine not found, try installing gij or set $JAVA")); err = true; done2: if (old_JAVA_HOME != NULL) { xsetenv ("JAVA_HOME", old_JAVA_HOME, 1); free (old_JAVA_HOME); } done1: return err; }
void process_char() { signal_safe_executer executer(create_signal_mask()); std::function<void()> func = [](){ rl_callback_read_char(); }; executer.execute(func); }
void password_input_handler(char *raw_data) { signal_safe_executer executer(create_signal_mask()); std::function<void()> func = [raw_data](){ password_input_handler_impl(raw_data); }; executer.execute(func); }
void Block::Run() { for_each(run_seq.begin(),run_seq.end(),executer()); }
SCM executer_wrapper(SCM x) { return scm_from_int(executer(scm_to_locale_stringn(x, 0))); }
int main() { printf("Variante %d: %s\n", VARIANTE, VARIANTE_STRING); #ifdef USE_GUILE scm_init_guile(); /* register "executer" function in scheme */ scm_c_define_gsubr("executer", 1, 0, 0, executer_wrapper); #endif while (1) { //struct cmdline *l; char *line=0; //int i, j; char *prompt = "ensishell>"; /* Readline use some internal memory structure that can not be cleaned at the end of the program. Thus one memory leak per command seems unavoidable yet */ line = readline(prompt); if (line == 0 || ! strncmp(line,"exit", 4)) { terminate(line); } if(!strncmp(line,"jobs",4)) { print_bg(liste_children_bg); } #ifdef USE_GNU_READLINE add_history(line); #endif #ifdef USE_GUILE /* The line is a scheme command */ if (line[0] == '(') { char catchligne[strlen(line) + 256]; sprintf(catchligne, "(catch #t (lambda () %s) (lambda (key . parameters) (display \"mauvaise expression/bug en scheme\n\")))", line); scm_eval_string(scm_from_locale_string(catchligne)); free(line); continue; } #endif update_bg(&liste_children_bg); executer(line); /* parsecmd free line and set it up to 0 */ //l = parsecmd( & line); ///* If input stream closed, normal termination */ //if (!l) { // terminate(0); //} //if (l->err) { // /* Syntax error, read another command */ // printf("error: %s\n", l->err); // continue; //} //if (l->in) printf("in: %s\n", l->in); //if (l->out) printf("out: %s\n", l->out); //if (l->bg) printf("background (&)\n"); ///* Display each command of the pipe */ //for (i=0; l->seq[i]!=0; i++) { // char **cmd = l->seq[i]; // printf("seq[%d]: ", i); // for (j=0; cmd[j]!=0; j++) { // printf("'%s' ", cmd[j]); // } // printf("\n"); //} } }