2 * Copyright (C) 1998, 1989 Transarc Corporation - All rights reserved
4 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
5 * LICENSED MATERIALS - PROPERTY OF IBM
18 #include "afsd_init.h"
26 char main_statusText[100];
30 extern int traceOnPanic;
33 * Notifier function for use by osi_panic
35 void afsd_notifier(char *msgp, char *filep, long line)
39 sprintf(tbuffer, "Error at file %s, line %d", filep, line);
41 strcpy(tbuffer, "Error at unknown location");
44 msgp = "Assertion failure";
46 MessageBox(NULL, tbuffer, msgp, MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
48 afsd_ForceTrace(TRUE);
57 /* Init function called when window application starts. Inits instance and
58 * application together, since in Win32 they're essentially the same.
60 * Function then goes into a loop handling user interface messages. Most are
61 * used to handle redrawing the icon.
65 HINSTANCE hPrevInstance,
71 if (!InitClass(hInstance))
74 if (!InitInstance(hInstance, nCmdShow))
77 while (GetMessage(&msg, NULL, 0, 0)) {
78 TranslateMessage(&msg);
79 DispatchMessage(&msg);
85 /* create the window type for our main window */
86 BOOL InitClass(HANDLE hInstance)
90 wc.style = CS_DBLCLKS; /* double-click messages */
91 wc.lpfnWndProc = (WNDPROC) MainWndProc;
94 wc.hInstance = hInstance;
95 wc.hIcon = LoadIcon(hInstance, "AFSDIcon");
96 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
97 wc.hbrBackground = GetStockObject(WHITE_BRUSH);
98 wc.lpszMenuName = "AFSDMenu";
99 wc.lpszClassName = "AFSDWinClass";
101 return (RegisterClass(&wc));
104 /* initialize the process. Reads the init files to get the appropriate
112 TEXTMETRIC textmetric;
118 /* remember this, since it is a useful thing for some of the Windows
120 main_inst = hInstance;
122 /* create our window */
126 WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
141 /* lookup text dimensions */
143 GetTextMetrics(hDC, &textmetric);
144 nLineHeight = textmetric.tmExternalLeading + textmetric.tmHeight;
146 main_rect.left = GetDeviceCaps(hDC, LOGPIXELSX) / 4; /* 1/4 inch */
147 main_rect.right = GetDeviceCaps(hDC, HORZRES);
148 main_rect.top = GetDeviceCaps(hDC, LOGPIXELSY) / 4; /* 1/4 inch */
149 ReleaseDC(hWnd, hDC);
150 main_rect.bottom = rect.top + nLineHeight;
152 osi_InitPanic(afsd_notifier);
156 code = afsd_InitCM(&reason);
158 osi_panic(reason, __FILE__, __LINE__);
160 code = afsd_InitDaemons(&reason);
162 osi_panic(reason, __FILE__, __LINE__);
164 code = afsd_InitSMB(&reason, MessageBox);
166 osi_panic(reason, __FILE__, __LINE__);
168 ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
173 /* called with no locks with translated messages */
174 LONG APIENTRY MainWndProc(
176 unsigned int message,
180 HDC hDC; /* display-context variable */
181 PAINTSTRUCT ps; /* paint structure */
187 /* block attempts to open the window */
191 /* LOWORD(wParam) is command */
192 return (DefWindowProc(hWnd, message, wParam, lParam));
198 hDC = BeginPaint (hWnd, &ps);
199 /* nothing to print, but this clears invalidated rectangle flag */
204 RpcMgmtStopServerListening(NULL);
209 return (DefWindowProc(hWnd, message, wParam, lParam));