From 377b8c176fde2cab27d27c644b6966bf153daad5 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 16 Jun 2009 23:37:49 +0000 Subject: [PATCH] windows-client-config-cell-search-registry-20090616 LICENSE MIT Add registry based cell search functionality to afs_config.exe even though the tool is close to useless at this point. --- src/WINNT/client_config/tab_general.cpp | 25 ++++++++++++++++--------- src/WINNT/client_config/tab_hosts.cpp | 20 ++++++++++++-------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/WINNT/client_config/tab_general.cpp b/src/WINNT/client_config/tab_general.cpp index 5f2459401..3fe83effa 100644 --- a/src/WINNT/client_config/tab_general.cpp +++ b/src/WINNT/client_config/tab_general.cpp @@ -13,6 +13,7 @@ extern "C" { #include #include +#include #include #include } @@ -662,8 +663,19 @@ BOOL fIsCellInCellServDB (LPCTSTR pszCell) { BOOL fFound = FALSE; CELLSERVDB CellServDB; - - if (CSDB_ReadFile (&CellServDB, NULL)) + char cellname[256], i; + + /* we pray for all ascii cellnames */ + for ( i=0 ; pszCell[i] && i < (sizeof(cellname)-1) ; i++ ) + cellname[i] = pszCell[i]; + cellname[i] = '\0'; + + ULONG code = cm_SearchCellRegistry(1, cellname, NULL, NULL, NULL, NULL); + if (code == 0) + fFound = TRUE; + if (!fFound && + (code != CM_ERROR_FORCE_DNS_LOOKUP) && + CSDB_ReadFile (&CellServDB, NULL)) { if (CSDB_FindCell (&CellServDB, pszCell)) fFound = TRUE; @@ -672,16 +684,11 @@ BOOL fIsCellInCellServDB (LPCTSTR pszCell) #ifdef AFS_AFSDB_ENV if ( fFound == FALSE ) { int ttl; - char cellname[128], i; - - /* we pray for all ascii cellnames */ - for ( i=0 ; pszCell[i] && i < (sizeof(cellname)-1) ; i++ ) - cellname[i] = pszCell[i]; - cellname[i] = '\0'; - fFound = !cm_SearchCellByDNS(cellname, NULL, &ttl, NULL, NULL); } #endif + done: + return fFound; } diff --git a/src/WINNT/client_config/tab_hosts.cpp b/src/WINNT/client_config/tab_hosts.cpp index 8a4927482..4859d9c20 100644 --- a/src/WINNT/client_config/tab_hosts.cpp +++ b/src/WINNT/client_config/tab_hosts.cpp @@ -13,6 +13,7 @@ extern "C" { #include #include +#include #include } @@ -183,17 +184,20 @@ BOOL HostsTab_OnApply (HWND hDlg) return FALSE; } - if (!CSDB_FindCell (&g.Configuration.CellServDB, szCell)) + char cellname[256], i; + + /* we pray for all ascii cellnames */ + for ( i=0 ; szCell[i] && i < (sizeof(cellname)-1) ; i++ ) + cellname[i] = szCell[i]; + cellname[i] = '\0'; + + ULONG code = cm_SearchCellRegistry(1, cellname, NULL, NULL, NULL, NULL); + if (code && + code != CM_ERROR_FORCE_DNS_LOOKUP && + !CSDB_FindCell (&g.Configuration.CellServDB, szCell)) { #ifdef AFS_AFSDB_ENV int ttl; - char cellname[128], i; - - /* we pray for all ascii cellnames */ - for ( i=0 ; szCell[i] && i < (sizeof(cellname)-1) ; i++ ) - cellname[i] = szCell[i]; - cellname[i] = '\0'; - if (cm_SearchCellByDNS(cellname, NULL, &ttl, NULL, NULL)) #endif { -- 2.39.5