@ -1,6 +1,6 @@
# include "nssm.h"
# include "nssm.h"
static enum { NSSM_TAB_APPLICATION , NSSM_TAB_SHUTDOWN , NSSM_TAB_EXIT , NSSM_TAB_IO , NSSM_TAB_ ENVIRONMENT, NSSM_NUM_TABS } ;
static enum { NSSM_TAB_APPLICATION , NSSM_TAB_SHUTDOWN , NSSM_TAB_EXIT , NSSM_TAB_IO , NSSM_TAB_ ROTATION, NSSM_TAB_ ENVIRONMENT, NSSM_NUM_TABS } ;
static HWND tablist [ NSSM_NUM_TABS ] ;
static HWND tablist [ NSSM_NUM_TABS ] ;
static int selected_tab ;
static int selected_tab ;
@ -135,12 +135,24 @@ int install(HWND window) {
check_io ( _T ( " stdin " ) , service - > stdin_path , sizeof ( service - > stdin_path ) , IDC_STDIN ) ;
check_io ( _T ( " stdin " ) , service - > stdin_path , sizeof ( service - > stdin_path ) , IDC_STDIN ) ;
check_io ( _T ( " stdout " ) , service - > stdout_path , sizeof ( service - > stdout_path ) , IDC_STDOUT ) ;
check_io ( _T ( " stdout " ) , service - > stdout_path , sizeof ( service - > stdout_path ) , IDC_STDOUT ) ;
check_io ( _T ( " stderr " ) , service - > stderr_path , sizeof ( service - > stderr_path ) , IDC_STDERR ) ;
check_io ( _T ( " stderr " ) , service - > stderr_path , sizeof ( service - > stderr_path ) , IDC_STDERR ) ;
/* Override stdout and/or stderr. */
/* Override stdout and/or stderr. */
if ( SendDlgItemMessage ( tablist [ NSSM_TAB_ IO] , IDC_TRUNCATE , BM_GETCHECK , 0 , 0 ) & BST_CHECKED ) {
if ( SendDlgItemMessage ( tablist [ NSSM_TAB_ ROTAT ION ] , IDC_TRUNCATE , BM_GETCHECK , 0 , 0 ) & BST_CHECKED ) {
if ( service - > stdout_path [ 0 ] ) service - > stdout_disposition = CREATE_ALWAYS ;
if ( service - > stdout_path [ 0 ] ) service - > stdout_disposition = CREATE_ALWAYS ;
if ( service - > stderr_path [ 0 ] ) service - > stderr_disposition = CREATE_ALWAYS ;
if ( service - > stderr_path [ 0 ] ) service - > stderr_disposition = CREATE_ALWAYS ;
}
}
/* Get rotation stuff. */
if ( SendDlgItemMessage ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE , BM_GETCHECK , 0 , 0 ) & BST_CHECKED ) {
service - > rotate_files = true ;
}
if ( SendDlgItemMessage ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_SECONDS_ENABLED , BM_GETCHECK , 0 , 0 ) & BST_CHECKED ) {
check_method_timeout ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_SECONDS , & service - > rotate_seconds ) ;
}
if ( SendDlgItemMessage ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_BYTES_LOW_ENABLED , BM_GETCHECK , 0 , 0 ) & BST_CHECKED ) {
check_method_timeout ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_BYTES_LOW , & service - > rotate_bytes_low ) ;
}
/* Get environment. */
/* Get environment. */
unsigned long envlen = ( unsigned long ) SendMessage ( GetDlgItem ( tablist [ NSSM_TAB_ENVIRONMENT ] , IDC_ENVIRONMENT ) , WM_GETTEXTLENGTH , 0 , 0 ) ;
unsigned long envlen = ( unsigned long ) SendMessage ( GetDlgItem ( tablist [ NSSM_TAB_ENVIRONMENT ] , IDC_ENVIRONMENT ) , WM_GETTEXTLENGTH , 0 , 0 ) ;
if ( envlen ) {
if ( envlen ) {
@ -367,6 +379,7 @@ INT_PTR CALLBACK tab_dlg(HWND tab, UINT message, WPARAM w, LPARAM l) {
case WM_COMMAND :
case WM_COMMAND :
HWND dlg ;
HWND dlg ;
TCHAR buffer [ MAX_PATH ] ;
TCHAR buffer [ MAX_PATH ] ;
unsigned long state ;
switch ( LOWORD ( w ) ) {
switch ( LOWORD ( w ) ) {
/* Browse for application. */
/* Browse for application. */
@ -416,6 +429,17 @@ INT_PTR CALLBACK tab_dlg(HWND tab, UINT message, WPARAM w, LPARAM l) {
GetDlgItemText ( tab , IDC_STDERR , buffer , sizeof ( buffer ) ) ;
GetDlgItemText ( tab , IDC_STDERR , buffer , sizeof ( buffer ) ) ;
browse ( dlg , buffer , 0 , NSSM_GUI_BROWSE_FILTER_ALL_FILES , 0 ) ;
browse ( dlg , buffer , 0 , NSSM_GUI_BROWSE_FILTER_ALL_FILES , 0 ) ;
break ;
break ;
/* Rotation. */
case IDC_ROTATE :
case IDC_ROTATE_SECONDS_ENABLED :
case IDC_ROTATE_BYTES_LOW_ENABLED :
if ( SendDlgItemMessage ( tab , LOWORD ( w ) , BM_GETCHECK , 0 , 0 ) & BST_CHECKED ) state = BST_CHECKED ;
else state = BST_UNCHECKED ;
SendDlgItemMessage ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE , BM_SETCHECK , state , 0 ) ;
SendDlgItemMessage ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_SECONDS_ENABLED , BM_SETCHECK , state , 0 ) ;
SendDlgItemMessage ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_BYTES_LOW_ENABLED , BM_SETCHECK , state , 0 ) ;
break ;
}
}
return 1 ;
return 1 ;
}
}
@ -486,6 +510,17 @@ INT_PTR CALLBACK install_dlg(HWND window, UINT message, WPARAM w, LPARAM l) {
tablist [ NSSM_TAB_IO ] = CreateDialog ( 0 , MAKEINTRESOURCE ( IDD_IO ) , window , tab_dlg ) ;
tablist [ NSSM_TAB_IO ] = CreateDialog ( 0 , MAKEINTRESOURCE ( IDD_IO ) , window , tab_dlg ) ;
ShowWindow ( tablist [ NSSM_TAB_IO ] , SW_HIDE ) ;
ShowWindow ( tablist [ NSSM_TAB_IO ] , SW_HIDE ) ;
/* Rotation tab. */
tab . pszText = message_string ( NSSM_GUI_TAB_ROTATION ) ;
tab . cchTextMax = ( int ) _tcslen ( tab . pszText ) + 1 ;
SendMessage ( tabs , TCM_INSERTITEM , NSSM_TAB_ROTATION , ( LPARAM ) & tab ) ;
tablist [ NSSM_TAB_ROTATION ] = CreateDialog ( 0 , MAKEINTRESOURCE ( IDD_ROTATION ) , window , tab_dlg ) ;
ShowWindow ( tablist [ NSSM_TAB_ROTATION ] , SW_HIDE ) ;
/* Set defaults. */
SetDlgItemInt ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_SECONDS , 0 , 0 ) ;
SetDlgItemInt ( tablist [ NSSM_TAB_ROTATION ] , IDC_ROTATE_BYTES_LOW , 0 , 0 ) ;
/* Environment tab. */
/* Environment tab. */
tab . pszText = message_string ( NSSM_GUI_TAB_ENVIRONMENT ) ;
tab . pszText = message_string ( NSSM_GUI_TAB_ENVIRONMENT ) ;
tab . cchTextMax = ( int ) _tcslen ( tab . pszText ) + 1 ;
tab . cchTextMax = ( int ) _tcslen ( tab . pszText ) + 1 ;