httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/support/win32 ApacheMonitor.c ApacheMonitor.h ApacheMonitor.rc
Date Sat, 06 Oct 2001 18:59:08 GMT
wrowe       01/10/06 11:59:08

  Modified:    support/win32 ApacheMonitor.c ApacheMonitor.h
                        ApacheMonitor.rc
  Log:
    Allow ApacheBench to connect to and control Apache on other WinNT/2K
    machines.
  
  Submitted by:	Mladen Turk <mturk@mappingsoft.com>
  
  Revision  Changes    Path
  1.14      +97 -15    httpd-2.0/support/win32/ApacheMonitor.c
  
  Index: ApacheMonitor.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/win32/ApacheMonitor.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ApacheMonitor.c	2001/09/24 22:50:50	1.13
  +++ ApacheMonitor.c	2001/10/06 18:59:07	1.14
  @@ -109,8 +109,9 @@
   
   /* Global variables */
   HINSTANCE         g_hInstance = NULL;
  -TCHAR             *g_szTitle;          /* The title bar text */
  -TCHAR             *g_szWindowClass;    /* Window Class Name  */
  +CHAR              *g_szTitle;          /* The title bar text */
  +CHAR              *g_szWindowClass;    /* Window Class Name  */
  +CHAR              *g_szComputer;       /* Connected computer */
   HICON             g_icoStop;
   HICON             g_icoRun;
   UINT              g_bUiTaskbarCreated;
  @@ -125,6 +126,7 @@
   HWND              g_hwndServiceDlg;
   HWND              g_hwndMain;
   HWND              g_hwndStdoutList;
  +HWND              g_hwndConnectDlg;
   HCURSOR           g_hCursorHourglass;
   HCURSOR           g_hCursorArrow;
   
  @@ -136,8 +138,8 @@
   LANGID            g_LangID;
   PROCESS_INFORMATION g_lpRedirectProc;
   CRITICAL_SECTION    g_stcSection;
  +HKEY                g_hKeyRemote;
   
  -
   /* locale language support */
   static CHAR *g_lpMsg[IDS_MSG_LAST - IDS_MSG_FIRST + 1];
   
  @@ -185,7 +187,7 @@
   
   LPSTR GetStringRes(int id)
   {
  -  static TCHAR buffer[MAX_PATH];
  +  static CHAR buffer[MAX_PATH];
   
     buffer[0] = 0;
     LoadString(GetModuleHandle (NULL), id, buffer, MAX_PATH);
  @@ -639,7 +641,7 @@
           else
               return FALSE;
           schSCManager = OpenSCManager(
  -            NULL,
  +            g_szComputer,
               NULL,
               SC_MANAGER_ALL_ACCESS
              );
  @@ -786,7 +788,7 @@
   
           dwPid = 0;
           schSCManager = OpenSCManager(
  -                            NULL,
  +                            g_szComputer,
                               NULL,
                               SC_MANAGER_ALL_ACCESS
                              );
  @@ -850,7 +852,7 @@
   
       g_bRescanServices = FALSE;
   
  -    retCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  +    retCode = RegOpenKeyEx(g_hKeyRemote ? g_hKeyRemote : HKEY_LOCAL_MACHINE,
                               "System\\CurrentControlSet\\Services\\",
                               0, KEY_READ, &hKey);
       if (retCode != ERROR_SUCCESS)
  @@ -868,7 +870,7 @@
               lstrcpy(szKey, "System\\CurrentControlSet\\Services\\");
               lstrcat(szKey, achKey);
   
  -            if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, 
  +            if (RegOpenKeyEx(g_hKeyRemote ? g_hKeyRemote : HKEY_LOCAL_MACHINE, szKey, 0,

                   KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
               {
                   dwBufLen = MAX_PATH;
  @@ -908,6 +910,64 @@
       return TRUE;
   }
   
  +LRESULT CALLBACK ConnectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  +{
  +    CHAR szCmp[MAX_COMPUTERNAME_LENGTH+4];
  +    CHAR szTmp[MAX_PATH];
  +    DWORD d;
  +    switch (message) 
  +    { 
  + 
  +        case WM_INITDIALOG: 
  +            ShowWindow(hDlg, SW_HIDE);
  +            g_hwndConnectDlg = hDlg;
  +            CenterWindow(hDlg);
  +            ShowWindow(hDlg, SW_SHOW);
  +            SetFocus(GetDlgItem(hDlg, IDC_COMPUTER));
  +            return TRUE;
  +        case WM_COMMAND: 
  +            switch (LOWORD(wParam)) 
  +            { 
  +                case IDOK: 
  +                    ZeroMemory(szCmp, MAX_COMPUTERNAME_LENGTH+4);
  +                    strcpy(szCmp, "\\\\");
  +                    SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), WM_GETTEXT, 
  +                        (WPARAM) MAX_COMPUTERNAME_LENGTH, (LPARAM) szCmp+2); 
  +
  +                    if (g_hKeyRemote)
  +                        RegCloseKey(g_hKeyRemote);
  +                    g_hKeyRemote = NULL;
  +                    if (RegConnectRegistry(szCmp, HKEY_LOCAL_MACHINE, &g_hKeyRemote)
!= ERROR_SUCCESS)
  +                    {
  +                        sprintf(szTmp, g_lpMsg[IDS_MSG_ECONNECT-IDS_MSG_FIRST], szCmp);
  +                        d = MAX_COMPUTERNAME_LENGTH+1;
  +                        GetComputerName(szCmp+2, &d);                             
          
  +                        ErrorMessage(szTmp, FALSE);
  +                    }
  +                    LoadString(g_hInstance, IDS_APMONITORTITLE, szTmp, MAX_LOADSTRING);
  +                    strcat(szTmp, "@");
  +                    strcat(szTmp, szCmp+2);
  +                    free(g_szTitle);
  +                    free(g_szComputer);
  +                    g_szTitle = strdup(szTmp);
  +                    g_szComputer = strdup(szCmp);
  +                    SetWindowText(g_hwndServiceDlg, szTmp);                     
  +                    SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0);            
           
  +                case IDCANCEL:
  +                    EndDialog(hDlg, TRUE); 
  +                    return TRUE; 
  +            }
  +        break;
  +        case WM_QUIT:
  +        case WM_CLOSE: 
  +            EndDialog(hDlg, TRUE);
  +            return TRUE;
  +        default:
  +            return FALSE;
  +    }
  +    return FALSE;
  +
  +}
   
   LRESULT CALLBACK ServiceDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   {
  @@ -930,14 +990,21 @@
           case WM_INITDIALOG: 
               ShowWindow(hDlg, SW_HIDE);
               g_hwndServiceDlg = hDlg;
  -
  +            SetWindowText(hDlg, g_szTitle);
               Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
               Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
               Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  -
  +            SetWindowText(GetDlgItem(hDlg, IDC_SSTART), g_lpMsg[IDS_MSG_SSTART-IDS_MSG_FIRST]);
  +            SetWindowText(GetDlgItem(hDlg, IDC_SSTOP), g_lpMsg[IDS_MSG_SSTOP-IDS_MSG_FIRST]);
  +            SetWindowText(GetDlgItem(hDlg, IDC_SRESTART), g_lpMsg[IDS_MSG_SRESTART-IDS_MSG_FIRST]);
  +            SetWindowText(GetDlgItem(hDlg, IDC_SMANAGER), g_lpMsg[IDS_MSG_SERVICES-IDS_MSG_FIRST]);
  +            SetWindowText(GetDlgItem(hDlg, IDC_SCONNECT), g_lpMsg[IDS_MSG_CONNECT-IDS_MSG_FIRST]);
  +            SetWindowText(GetDlgItem(hDlg, IDC_SEXIT), g_lpMsg[IDS_MSG_MNUEXIT-IDS_MSG_FIRST]);
               if (g_dwOSVersion < OS_VERSION_WINNT)
  +            {
                   ShowWindow(GetDlgItem(hDlg, IDC_SMANAGER), SW_HIDE);
  -
  +                ShowWindow(GetDlgItem(hDlg, IDC_SCONNECT), SW_HIDE);
  +            }
               hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
               g_hwndStdoutList = GetDlgItem(hDlg, IDL_STDOUT);
               hStatusBar = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */
  @@ -1149,6 +1216,10 @@
                       EndDialog( hDlg, TRUE);
                       SendMessage( g_hwndMain, WM_COMMAND, (WPARAM)IDM_EXIT, 0);
                       return TRUE;
  +                case IDC_SCONNECT: 
  +                    DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGCONNECT),
  +                                    hDlg, (DLGPROC)ConnectDlgProc);
  +                    return TRUE;
                }
           break;
           case WM_SIZE:
  @@ -1187,7 +1258,6 @@
               ShowNotifyIcon(hWnd, NIM_ADD);
               SetTimer(hWnd, WM_TIMER_REFRESH, REFRESH_TIME, NULL);
               SetTimer(hWnd, WM_TIMER_RESCAN,  RESCAN_TIME, NULL);
  -            g_hwndServiceDlg = NULL;                      
               break;
           case WM_TIMER:
               switch (wParam)
  @@ -1254,7 +1324,7 @@
                          g_bDlgServiceOn = FALSE;
                          g_hwndServiceDlg = NULL;
                      }
  -                   else if (g_hwndServiceDlg)
  +                   else if (IsWindow(g_hwndServiceDlg))
                      {
                          /* Dirty hack to bring the window to the foreground */
                          SetWindowPos(g_hwndServiceDlg, HWND_TOPMOST, 0, 0, 0, 0,
  @@ -1305,7 +1375,7 @@
                          g_bDlgServiceOn = FALSE;
                          g_hwndServiceDlg = NULL;
                      }
  -                   else if (g_hwndServiceDlg)
  +                   else if (IsWindow(g_hwndServiceDlg))
                          SetFocus(g_hwndServiceDlg);
                      break;
                   case IDC_SMANAGER: 
  @@ -1369,11 +1439,13 @@
                       LPSTR lpCmdLine,
                       int nCmdShow)
   {
  -    TCHAR szTmp[MAX_LOADSTRING];
  +    CHAR szTmp[MAX_LOADSTRING];
  +    CHAR szCmp[MAX_COMPUTERNAME_LENGTH+4];
       MSG     msg;
       /* single instance mutex */
       HANDLE hMutex;
       int i;
  +    DWORD d;
   
       g_LangID = GetUserDefaultLangID();
       if ((g_LangID & 0xFF) != LANG_ENGLISH)
  @@ -1384,9 +1456,16 @@
           g_lpMsg[i - IDS_MSG_FIRST] = strdup(szTmp);
       }
       LoadString(hInstance, IDS_APMONITORTITLE, szTmp, MAX_LOADSTRING);
  +    strcat(szTmp, "@");
  +    d = MAX_COMPUTERNAME_LENGTH+1;
  +    strcpy(szCmp, "\\\\");
  +    GetComputerName(szCmp+2, &d);
  +    strcat(szTmp, szCmp+2);
       g_szTitle = strdup(szTmp);
  +    g_szComputer = strdup(szCmp);
       LoadString(hInstance, IDS_APMONITORCLASS, szTmp, MAX_LOADSTRING);
       g_szWindowClass = strdup(szTmp);
  +    g_hKeyRemote = NULL;
   
       g_icoStop          = LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICOSTOP),
                                      IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
  @@ -1417,6 +1496,7 @@
       g_hwndMain = CreateMainWindow(hInstance);
       g_bUiTaskbarCreated = RegisterWindowMessage("TaskbarCreated");
       InitializeCriticalSection(&g_stcSection);
  +    g_hwndServiceDlg = NULL;                      
       if (g_hwndMain != NULL)
       {
           while (GetMessage(&msg, NULL, 0, 0) == TRUE) 
  @@ -1426,6 +1506,8 @@
           }    
           am_ClearServicesSt();
       }
  +    if (g_hKeyRemote)
  +        RegCloseKey(g_hKeyRemote);
       DeleteCriticalSection(&g_stcSection);
       CloseHandle(hMutex);
       DestroyIcon(g_icoStop);
  
  
  
  1.6       +8 -2      httpd-2.0/support/win32/ApacheMonitor.h
  
  Index: ApacheMonitor.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/win32/ApacheMonitor.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ApacheMonitor.h	2001/08/16 16:51:48	1.5
  +++ ApacheMonitor.h	2001/10/06 18:59:07	1.6
  @@ -1,4 +1,4 @@
  -#define IDD_DLGSERVICES		        101
  +#define IDD_DLGSERVICES                 101
   #define IDS_APMONITORTITLE              102
   #define IDS_APMONITORCLASS              103
   #define IDM_RESTORE                     104
  @@ -18,6 +18,10 @@
   #define IDC_SRESTART                    118
   #define IDC_SEXIT                       119
   #define IDC_SMANAGER                    120
  +#define IDD_DLGCONNECT                  121
  +#define IDC_LREMOTE                     122
  +#define IDC_COMPUTER                    123
  +#define IDC_SCONNECT                    124
   #define IDS_MSG_FIRST                   256
   #define IDS_MSG_APPRUNNING              256
   #define IDS_MSG_ERROR                   257
  @@ -39,7 +43,9 @@
   #define IDS_MSG_SSTOP                   273
   #define IDS_MSG_SRESTART                274
   #define IDS_MSG_SERVICES                275
  -#define IDS_MSG_LAST                    275
  +#define IDS_MSG_CONNECT                 276
  +#define IDS_MSG_ECONNECT                277
  +#define IDS_MSG_LAST                    277
   #define IDM_SM_SERVICE                  0x1100
   #define IDM_SM_START                    0x1200
   #define IDM_SM_STOP                     0x1400
  
  
  
  1.8       +19 -3     httpd-2.0/support/win32/ApacheMonitor.rc
  
  Index: ApacheMonitor.rc
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/win32/ApacheMonitor.rc,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ApacheMonitor.rc	2001/08/17 00:11:26	1.7
  +++ ApacheMonitor.rc	2001/10/06 18:59:07	1.8
  @@ -6,7 +6,7 @@
   
   #include "ApacheMonitorVersion.rc"
   
  -IDD_DLGSERVICES DIALOGEX 0, 0, 350, 174
  +IDD_DLGSERVICES DIALOGEX 0, 0, 350, 188
   STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_MINIMIZEBOX | WS_VISIBLE | 
       WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
   EXSTYLE WS_EX_CONTROLPARENT
  @@ -18,16 +18,30 @@
       LISTBOX         IDL_SERVICES,2,49,285,73,LBS_OWNERDRAWFIXED | 
                       LBS_HASSTRINGS | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | 
                       LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
  -    LISTBOX         IDL_STDOUT,2,124,285,37,LBS_NOINTEGRALHEIGHT | 
  +    LISTBOX         IDL_STDOUT,2,124,285,51,LBS_NOINTEGRALHEIGHT | 
                       LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL
       PUSHBUTTON      "&Start",IDC_SSTART,298,75,50,14
       PUSHBUTTON      "S&top",IDC_SSTOP,298,91,50,14
       PUSHBUTTON      "&Restart",IDC_SRESTART,298,107,50,14
       PUSHBUTTON      "Ser&vices",IDC_SMANAGER,298,123,50,14
       CONTROL         113,IDC_STATIC,"Static",SS_BITMAP,0,0,349,38
  -    PUSHBUTTON      "E&xit",IDC_SEXIT,298,147,50,14
  +    PUSHBUTTON      "&Connect",IDC_SCONNECT,298,139,50,14
  +    PUSHBUTTON      "E&xit",IDC_SEXIT,298,161,50,14
   END
   
  +IDD_DLGCONNECT DIALOGEX 0, 0, 186, 54
  +STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_VISIBLE | 
  +    WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
  +EXSTYLE WS_EX_CONTROLPARENT
  +CAPTION "Connect Remote Computer"
  +FONT 8, "MS Sans Serif"
  +BEGIN
  +    DEFPUSHBUTTON   "&OK",IDOK,127,31,50,14
  +    LTEXT           "Computer name:",IDC_LREMOTE,7,1,155,8
  +    PUSHBUTTON      "&Cancel",IDCANCEL,8,31,50,14
  +    EDITTEXT        IDC_COMPUTER,7,12,169,14,ES_AUTOHSCROLL
  +END
  +
   IDB_BMPSTOP             BITMAP  DISCARDABLE     "sstop.bmp"
   IDB_BMPRUN              BITMAP  DISCARDABLE     "srun.bmp"
   IDB_BMPHEADER           BITMAP  DISCARDABLE     "apache_header.bmp"
  @@ -60,4 +74,6 @@
       IDS_MSG_SSTOP           "S&top"
       IDS_MSG_SRESTART        "&Restart"
       IDS_MSG_SERVICES        "Ser&vices"
  +    IDS_MSG_CONNECT         "&Connect"
  +    IDS_MSG_ECONNECT        "Unable to connect remote registry on %s"
   END
  
  
  

Mime
View raw message