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
11 * INCLUDES _________________________________________________________________
19 #include "validation.h"
23 * DEFINITIONS _________________________________________________________________
29 * PROTOTYPES _________________________________________________________________
32 static BOOL
CheckAfsPartitionName(TCHAR
*pszInput
, int &nErrorMsgResID
);
33 static BOOL
CheckAfsCellName(TCHAR
*pszInput
, int &nErrorMsgResID
);
34 static BOOL
CheckAfsPassword(TCHAR
*pszInput
, int &nErrorMsgResID
);
35 static BOOL
CheckAfsUid(TCHAR
*pszInput
, int &nErrorMsgResID
);
36 static BOOL
CheckAfsServerName(TCHAR
*pszInput
, int &nErrorMsgResID
);
37 static void ShowError(int nErrorMsgResID
);
41 * EXPORTED FUNCTIONS _________________________________________________________________
44 BOOL
Validation_IsValid(TCHAR
*pszInput
, VALIDATION_TYPE type
, BOOL bShowError
)
50 case VALID_AFS_PARTITION_NAME
:
51 bValid
= CheckAfsPartitionName(pszInput
, nErrorMsgResID
);
54 case VALID_AFS_CELL_NAME
:
55 bValid
= CheckAfsCellName(pszInput
, nErrorMsgResID
);
58 case VALID_AFS_PASSWORD
:
59 bValid
= CheckAfsPassword(pszInput
, nErrorMsgResID
);
63 bValid
= CheckAfsUid(pszInput
, nErrorMsgResID
);
66 case VALID_AFS_SERVER_NAME
:
67 bValid
= CheckAfsServerName(pszInput
, nErrorMsgResID
);
76 if (!bValid
&& bShowError
)
77 ShowError(nErrorMsgResID
);
85 * STATIC FUNCTIONS _________________________________________________________________
90 * Utility Functions _________________________________________________________________
93 static BOOL
CheckAfsPartitionName(TCHAR
*pszPartitionName
, int &nErrorMsgResID
)
98 char *pszName
= new char[strlen("/vicpe") + lstrlen(pszPartitionName
) + 1];
104 strcpy(pszName
, "/vicep");
105 strcat(pszName
, S2A(pszPartitionName
));
107 int nResult
= cfg_HostPartitionNameValid(pszName
, &bIsValid
, &nStatus
);
111 nErrorMsgResID
= IDS_PARTITION_NAME_VALIDATION_TYPE
;
118 static BOOL
CheckAfsCellName(TCHAR
*pszInput
, int &nErrorMsgResID
)
125 static BOOL
CheckAfsPassword(TCHAR
*pszInput
, int &nErrorMsgResID
)
132 static BOOL
CheckAfsUid(TCHAR
*pszInput
, int &nErrorMsgResID
)
139 static BOOL
CheckAfsServerName(TCHAR
*pszInput
, int &nErrorMsgResID
)
146 static void ShowError(int nErrorMsgResID
)
148 Message(MB_ICONSTOP
| MB_OK
, GetAppTitleID(), IDS_VALIDATION_ERROR_TEMPLATE
, TEXT("%m%m"), nErrorMsgResID
, nErrorMsgResID
);