win32-name-event-objects-20040228
[openafs.git] / src / WINNT / afssvrmgr / svc_general.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "svrmgr.h"
16 #include "svc_general.h"
17
18
19 /*
20  * ROUTINES ___________________________________________________________________
21  *
22  */
23
24 void Services_GuessLogName (LPTSTR pszLogFile, LPIDENT lpiService)
25 {
26    TCHAR szService[ cchRESOURCE ];
27    lpiService->GetServiceName (szService);
28    Services_GuessLogName (pszLogFile, szService);
29 }
30
31 void Services_GuessLogName (LPTSTR pszLogFile, LPTSTR pszService)
32 {
33    if (!lstrcmpi (pszService, TEXT("BOS")))
34       lstrcpy (pszLogFile, TEXT("BosLog"));
35    else if (!lstrcmpi (pszService, TEXT("kaserver")))
36       lstrcpy (pszLogFile, TEXT("AuthLog"));
37    else if (!lstrcmpi (pszService, TEXT("buserver")))
38       lstrcpy (pszLogFile, TEXT("BackupLog"));
39    else if (!lstrcmpi (pszService, TEXT("fileserver")))
40       lstrcpy (pszLogFile, TEXT("FileLog"));
41    else if (!lstrcmpi (pszService, TEXT("fs")))
42       lstrcpy (pszLogFile, TEXT("FileLog"));
43    else if (!lstrcmpi (pszService, TEXT("volserver")))
44       lstrcpy (pszLogFile, TEXT("VolserLog"));
45    else if (!lstrcmpi (pszService, TEXT("ptserver")))
46       lstrcpy (pszLogFile, TEXT("PtLog"));
47    else if (!lstrcmpi (pszService, TEXT("salvager")))
48       lstrcpy (pszLogFile, TEXT("SalvageLog"));
49    else if (!lstrcmpi (pszService, TEXT("vlserver")))
50       lstrcpy (pszLogFile, TEXT("VLLog"));
51    else if (!lstrcmpi (pszService, TEXT("upclient")))
52       pszLogFile[0] = TEXT('\0');
53    else if (!lstrcmpi (pszService, TEXT("upserver")))
54       pszLogFile[0] = TEXT('\0');
55    else
56       pszLogFile[0] = TEXT('\0');
57 }
58
59
60 PVOID Services_LoadPreferences (LPIDENT lpiService)
61 {
62    LPSERVICE_PREF psp = New (SERVICE_PREF);
63
64    if (!RestorePreferences (lpiService, psp, sizeof(SERVICE_PREF)))
65       {
66       psp->fWarnSvcStop = TRUE;
67       Alert_SetDefaults (&psp->oa);
68
69       Services_GuessLogName (psp->szLogFile, lpiService);
70
71       // write the logfile down so we won't have to guess again.
72       StorePreferences (lpiService, psp, sizeof(SERVICE_PREF));
73       }
74
75    Alert_Initialize (&psp->oa);
76    return psp;
77 }
78
79
80 BOOL Services_SavePreferences (LPIDENT lpiService)
81 {
82    BOOL rc = FALSE;
83
84    PVOID psp = lpiService->GetUserParam();
85    if (psp != NULL)
86       {
87       rc = StorePreferences (lpiService, psp, sizeof(SERVICE_PREF));
88       }
89
90    return rc;
91 }
92