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"
27 char main_statusText[100];
31 extern int traceOnPanic;
34 * Notifier function for use by osi_panic
36 void afsd_notifier(char *msgp, char *filep, long line)
40 sprintf(tbuffer, "Error at file %s, line %d", filep, line);
42 strcpy(tbuffer, "Error at unknown location");
45 msgp = "Assertion failure";
47 MessageBox(NULL, tbuffer, msgp, MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
49 afsd_ForceTrace(TRUE);
58 /* Init function called when window application starts. Inits instance and
59 * application together, since in Win32 they're essentially the same.
61 * Function then goes into a loop handling user interface messages. Most are
62 * used to handle redrawing the icon.
66 HINSTANCE hPrevInstance,
72 if (!InitClass(hInstance))
75 if (!InitInstance(hInstance, nCmdShow))
78 while (GetMessage(&msg, NULL, 0, 0)) {
79 TranslateMessage(&msg);
80 DispatchMessage(&msg);
86 /* create the window type for our main window */
87 BOOL InitClass(HANDLE hInstance)
91 wc.style = CS_DBLCLKS; /* double-click messages */
92 wc.lpfnWndProc = (WNDPROC) MainWndProc;
95 wc.hInstance = hInstance;
96 wc.hIcon = LoadIcon(hInstance, "AFSDIcon");
97 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
98 wc.hbrBackground = GetStockObject(WHITE_BRUSH);
99 wc.lpszMenuName = "AFSDMenu";
100 wc.lpszClassName = "AFSDWinClass";
102 return (RegisterClass(&wc));
105 /* initialize the process. Reads the init files to get the appropriate
113 TEXTMETRIC textmetric;
119 /* remember this, since it is a useful thing for some of the Windows
121 main_inst = hInstance;
123 /* create our window */
127 WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
142 /* lookup text dimensions */
144 GetTextMetrics(hDC, &textmetric);
145 nLineHeight = textmetric.tmExternalLeading + textmetric.tmHeight;
147 main_rect.left = GetDeviceCaps(hDC, LOGPIXELSX) / 4; /* 1/4 inch */
148 main_rect.right = GetDeviceCaps(hDC, HORZRES);
149 main_rect.top = GetDeviceCaps(hDC, LOGPIXELSY) / 4; /* 1/4 inch */
150 ReleaseDC(hWnd, hDC);
151 main_rect.bottom = rect.top + nLineHeight;
153 osi_InitPanic(afsd_notifier);
157 code = afsd_InitCM(&reason);
159 osi_panic(reason, __FILE__, __LINE__);
161 code = afsd_InitDaemons(&reason);
163 osi_panic(reason, __FILE__, __LINE__);
165 code = afsd_InitSMB(&reason, MessageBox);
167 osi_panic(reason, __FILE__, __LINE__);
169 ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
174 /* called with no locks with translated messages */
175 LONG APIENTRY MainWndProc(
177 unsigned int message,
181 HDC hDC; /* display-context variable */
182 PAINTSTRUCT ps; /* paint structure */
188 /* block attempts to open the window */
192 /* LOWORD(wParam) is command */
193 return (DefWindowProc(hWnd, message, wParam, lParam));
199 hDC = BeginPaint (hWnd, &ps);
200 /* nothing to print, but this clears invalidated rectangle flag */
205 RpcMgmtStopServerListening(NULL);
210 return (DefWindowProc(hWnd, message, wParam, lParam));