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