X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=gui.cpp;h=7cc5bc4efc91d8e3a34f5a4bc980cc6b2266298d;hb=c1bc67d13894b1b9456fb85abdabc4dbb5d71bcc;hp=4bcb144c6e1398608fab329476e41dd0054ac3b8;hpb=277723e318f71a9ff9948e3286df509af79c1dc8;p=nssm.git diff --git a/gui.cpp b/gui.cpp index 4bcb144..7cc5bc4 100644 --- a/gui.cpp +++ b/gui.cpp @@ -4,15 +4,6 @@ static enum { NSSM_TAB_APPLICATION, NSSM_TAB_SHUTDOWN, NSSM_TAB_EXIT, NSSM_TAB_I static HWND tablist[NSSM_NUM_TABS]; static int selected_tab; -static void strip_basename(char *buffer) { - size_t len = strlen(buffer); - size_t i; - for (i = len; i && buffer[i] != '\\' && buffer[i] != '/'; i--); - /* X:\ is OK. */ - if (i && buffer[i-1] == ':') i++; - buffer[i] = '\0'; -} - int nssm_gui(int resource, char *name) { /* Create window */ HWND dlg = CreateDialog(0, MAKEINTRESOURCE(resource), 0, install_dlg); @@ -143,6 +134,21 @@ int install(HWND window) { check_io("stdin", service->stdin_path, sizeof(service->stdin_path), IDC_STDIN); check_io("stdout", service->stdout_path, sizeof(service->stdout_path), IDC_STDOUT); check_io("stderr", service->stderr_path, sizeof(service->stderr_path), IDC_STDERR); + /* I/O defaults. */ + service->stdin_sharing = NSSM_STDIN_SHARING; + service->stdin_disposition = NSSM_STDIN_DISPOSITION; + service->stdin_flags = NSSM_STDIN_FLAGS; + service->stdout_sharing = NSSM_STDOUT_SHARING; + service->stdout_disposition = NSSM_STDOUT_DISPOSITION; + service->stdout_flags = NSSM_STDOUT_FLAGS; + service->stderr_sharing = NSSM_STDERR_SHARING; + service->stderr_disposition = NSSM_STDERR_DISPOSITION; + service->stderr_flags = NSSM_STDERR_FLAGS; + /* Override stdout and/or stderr. */ + if (SendDlgItemMessage(tablist[NSSM_TAB_IO], IDC_TRUNCATE, BM_GETCHECK, 0, 0) & BST_CHECKED) { + if (service->stdout_path[0]) service->stdout_disposition = CREATE_ALWAYS; + if (service->stderr_path[0]) service->stderr_disposition = CREATE_ALWAYS; + } /* Get environment. */ unsigned long envlen = (unsigned long) SendMessage(GetDlgItem(tablist[NSSM_TAB_ENVIRONMENT], IDC_ENVIRONMENT), WM_GETTEXTLENGTH, 0, 0); @@ -166,7 +172,7 @@ int install(HWND window) { unsigned long i, j; for (i = 0; i < envlen; i++) if (env[i] != '\r') newlen++; /* Must end with two NULLs. */ - newlen++; + newlen += 2; char *newenv = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newlen); if (! newenv) { @@ -444,6 +450,8 @@ INT_PTR CALLBACK install_dlg(HWND window, UINT message, WPARAM w, LPARAM l) { switch (message) { /* Creating the dialogue */ case WM_INITDIALOG: + SetFocus(GetDlgItem(window, IDC_NAME)); + HWND tabs; HWND combo; tabs = GetDlgItem(window, IDC_TAB1);