From 58ee168aadf62f2d184d787451601c90bebd2879 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 29 Jul 2010 21:29:39 +0400 Subject: [PATCH] fixed runner to run batch, removed linux runner, fixed django default port --- native/runner/runneru/.cproject | 925 ------------------ native/runner/runneru/.project | 71 -- .../org.eclipse.cdt.managedbuilder.core.prefs | 14 - native/runner/runneru/runneru.cpp | 115 --- native/runner/runnerw/runnerw.cpp | 42 +- 5 files changed, 23 insertions(+), 1144 deletions(-) delete mode 100644 native/runner/runneru/.cproject delete mode 100644 native/runner/runneru/.project delete mode 100644 native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs delete mode 100644 native/runner/runneru/runneru.cpp diff --git a/native/runner/runneru/.cproject b/native/runner/runneru/.cproject deleted file mode 100644 index 0bf8f81bacef..000000000000 --- a/native/runner/runneru/.cproject +++ /dev/null @@ -1,925 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/native/runner/runneru/.project b/native/runner/runneru/.project deleted file mode 100644 index 8c2fbf2e74b2..000000000000 --- a/native/runner/runneru/.project +++ /dev/null @@ -1,71 +0,0 @@ - - - runneru - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/runneru/Debug} - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index 74bd0864eb02..000000000000 --- a/native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -#Sat Jul 17 14:31:13 MSD 2010 -eclipse.preferences.version=1 -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPATH/delimiter=; -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPLUS_INCLUDE_PATH/delimiter=; -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPLUS_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/C_INCLUDE_PATH/delimiter=; -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/C_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/append=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/appendContributed=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/LIBRARY_PATH/delimiter=; -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/LIBRARY_PATH/operation=remove -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/append=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/appendContributed=true diff --git a/native/runner/runneru/runneru.cpp b/native/runner/runneru/runneru.cpp deleted file mode 100644 index 2bc002639b14..000000000000 --- a/native/runner/runneru/runneru.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -void print_usage() { - printf("Usage: runneru \n"); - printf("where is console application and it's arguments.\n"); - printf("\n"); - printf( - "Runner executes an application as a process with inherited input and output streams.\n"); - printf( - "Input stream is scanned for presence of 2 char 255(IAC) and 243(BRK) sequence and generates Ctrl-C(SIGING) event in that case.\n"); - - exit(0); -} - -void sigint_handler(int sig) -{ - kill(0, SIGINT); - signal(SIGINT, SIG_DFL); - kill(getpid(), SIGINT); -} - -void generate_break(int pid) { - kill(0, SIGINT); - exit(0); -} - -char IAC = 255; -char BRK = 243; - -int main(int argc, char **argv) { - if (argc < 2) { - print_usage(); - } - - char* argv2[argc]; - - for (int i = 1; i < argc; i++) { - argv2[i-1]=argv[i]; - } - argv2[argc-1]=0; - - if (strlen(argv[0]) == 0) { - print_usage(); - } - - int write_pipe[2]; /* Pipe toward child */ - - signal(SIGINT, &sigint_handler); - - /* Open pipes */ - if (pipe(write_pipe) == -1) { - perror("pipe"); - exit(1); - } - - /* Fork child */ - int pid = fork(); - switch (pid) { - case -1: - perror("fork"); - exit(1); - - case 0: - /* Child section */ - - if (dup2(write_pipe[0], STDIN_FILENO) == -1) { - perror("dup2"); - exit(1); - } - - /* Close unused fildes. */ - close(write_pipe[0]); - close(write_pipe[1]); - - /* Exec! */ - - execv(argv[0], argv2); - - perror("execv"); - exit(1); - - default: - - close(write_pipe[0]); - - int is_iac = 0; - char buf[1]; - while (1) { - char c = fgetc(stdin); - - if (is_iac) { - if (c == BRK) { - generate_break(pid); - } else { - is_iac = 0; - } - } - if (c == IAC) { - is_iac = 1; - } - buf[0] = c; - write(write_pipe[1], buf, 1); - } - - } - - /* All done */ - return 0; -} diff --git a/native/runner/runnerw/runnerw.cpp b/native/runner/runnerw/runnerw.cpp index 098f1ab9f5f3..d145c8cca49c 100644 --- a/native/runner/runnerw/runnerw.cpp +++ b/native/runner/runnerw/runnerw.cpp @@ -74,33 +74,28 @@ BOOL CtrlHandler(DWORD fdwCtrlType) { } } -struct StdInThreadParams -{ +struct StdInThreadParams { HANDLE hEvent; HANDLE write_stdin; }; -DWORD WINAPI StdInThread(void *param) -{ +DWORD WINAPI StdInThread(void *param) { StdInThreadParams *threadParams = (StdInThreadParams *) param; char buf[1]; memset(buf, 0, sizeof(buf)); HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); - while(true) - { + while (true) { DWORD cbRead = 0; DWORD cbWrite = 0; char c; ReadFile(hStdin, &c, 1, &cbRead, NULL); - if (cbRead > 0) - { + if (cbRead > 0) { buf[0] = c; bool ctrlBroken = Scan(buf, 1); WriteFile(threadParams->write_stdin, buf, 1, &cbWrite, NULL); - if (ctrlBroken) - { + if (ctrlBroken) { SetEvent(threadParams->hEvent); break; } @@ -109,6 +104,15 @@ DWORD WINAPI StdInThread(void *param) return 0; } +bool hasEnding(std::string const &fullString, std::string const &ending) { + if (fullString.length() > ending.length()) { + return (0 == fullString.compare(fullString.length() - ending.length(), + ending.length(), ending)); + } else { + return false; + } +} + int main(int argc, char * argv[]) { if (argc < 2) { PrintUsage(); @@ -119,14 +123,11 @@ int main(int argc, char * argv[]) { for (int i = 2; i < argc; i++) { args += " "; - if (strchr(argv [i], ' ')) - { + if (strchr(argv[i], ' ')) { args += "\""; args += argv[i]; args += "\""; - } - else - { + } else { args += argv[i]; } } @@ -162,6 +163,11 @@ int main(int argc, char * argv[]) { char* c_app = new char[app.size() + 1]; strcpy(c_app, app.c_str()); + if (hasEnding(app, std::string(".bat"))) { + args = app + " " + args; + c_app = NULL; + } + char* c_args = new char[args.size() + 1]; strcpy(c_args, args.c_str()); @@ -192,11 +198,9 @@ int main(int argc, char * argv[]) { objects_to_wait[0] = threadEvent; objects_to_wait[1] = pi.hProcess; - while(true) - { + while (true) { int rc = WaitForMultipleObjects(2, objects_to_wait, FALSE, INFINITE); - if (rc == WAIT_OBJECT_0 + 1) - { + if (rc == WAIT_OBJECT_0 + 1) { break; } }