2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
19 #include "afsd_init.h"
23 #include <winnt/osi_malloc.h>
28 char main_statusText[100];
32 extern int traceOnPanic;
35 * Notifier function for use by osi_panic
37 void afsd_notifier(char *msgp, char *filep, long line)
41 sprintf(tbuffer, "Error at file %s, line %d", filep, line);
43 strcpy(tbuffer, "Error at unknown location");
46 msgp = "Assertion failure";
48 MessageBox(NULL, tbuffer, msgp, MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
50 afsd_ForceTrace(TRUE);
59 /* Init function called when window application starts. Inits instance and
60 * application together, since in Win32 they're essentially the same.
62 * Function then goes into a loop handling user interface messages. Most are
63 * used to handle redrawing the icon.
67 HINSTANCE hPrevInstance,
73 if (!InitClass(hInstance))
76 if (!InitInstance(hInstance, nCmdShow))
79 while (GetMessage(&msg, NULL, 0, 0)) {
80 TranslateMessage(&msg);
81 DispatchMessage(&msg);
87 /* create the window type for our main window */
88 BOOL InitClass(HANDLE hInstance)
92 wc.style = CS_DBLCLKS; /* double-click messages */
93 wc.lpfnWndProc = (WNDPROC) MainWndProc;
96 wc.hInstance = hInstance;
97 wc.hIcon = LoadIcon(hInstance, "AFSDIcon");
98 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
99 wc.hbrBackground = GetStockObject(WHITE_BRUSH);
100 wc.lpszMenuName = "AFSDMenu";
101 wc.lpszClassName = "AFSDWinClass";
103 return (RegisterClass(&wc));
106 /* initialize the process. Reads the init files to get the appropriate
114 TEXTMETRIC textmetric;
120 /* remember this, since it is a useful thing for some of the Windows
122 main_inst = hInstance;
124 /* create our window */
128 WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
143 /* lookup text dimensions */
145 GetTextMetrics(hDC, &textmetric);
146 nLineHeight = textmetric.tmExternalLeading + textmetric.tmHeight;
148 main_rect.left = GetDeviceCaps(hDC, LOGPIXELSX) / 4; /* 1/4 inch */
149 main_rect.right = GetDeviceCaps(hDC, HORZRES);
150 main_rect.top = GetDeviceCaps(hDC, LOGPIXELSY) / 4; /* 1/4 inch */
151 ReleaseDC(hWnd, hDC);
152 main_rect.bottom = rect.top + nLineHeight;
154 osi_InitPanic(afsd_notifier);
158 code = afsd_InitCM(&reason);
160 osi_panic(reason, __FILE__, __LINE__);
162 code = afsd_InitDaemons(&reason);
164 osi_panic(reason, __FILE__, __LINE__);
166 code = afsd_InitSMB(&reason, MessageBox);
168 osi_panic(reason, __FILE__, __LINE__);
170 ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
175 /* called with no locks with translated messages */
176 LONG APIENTRY MainWndProc(
178 unsigned int message,
182 HDC hDC; /* display-context variable */
183 PAINTSTRUCT ps; /* paint structure */
189 /* block attempts to open the window */
193 /* LOWORD(wParam) is command */
194 return (DefWindowProc(hWnd, message, wParam, lParam));
200 hDC = BeginPaint (hWnd, &ps);
201 /* nothing to print, but this clears invalidated rectangle flag */
206 RpcMgmtStopServerListening(NULL);
211 return (DefWindowProc(hWnd, message, wParam, lParam));