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
14 #include <afs/param.h>
17 #include <afs/cm_config.h>
20 #include "afs_config.h"
21 #include "tab_hosts.h"
25 * PROTOTYPES _________________________________________________________________
29 void HostsTab_OnInitDialog (HWND hDlg);
30 BOOL HostsTab_OnApply (HWND hDlg);
31 void HostsTab_OnSelect (HWND hDlg);
32 void HostsTab_OnAdd (HWND hDlg);
33 void HostsTab_OnEdit (HWND hDlg);
34 void HostsTab_OnRemove (HWND hDlg);
36 void HostsTab_FillList (HWND hDlg);
38 BOOL CALLBACK CellEdit_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
39 void CellEdit_OnInitDialog (HWND hDlg);
40 void CellEdit_OnDestroy (HWND hDlg);
41 void CellEdit_OnApply (HWND hDlg);
42 void CellEdit_OnSelect (HWND hDlg);
43 void CellEdit_OnAdd (HWND hDlg);
44 void CellEdit_OnEdit (HWND hDlg);
45 void CellEdit_OnRemove (HWND hDlg);
46 void CellEdit_Enable (HWND hDlg);
47 void CellEdit_AddServerEntry (HWND hDlg, PCELLDBLINE pLine, int iOrder);
48 int CALLBACK CellEdit_SortFunction (HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2);
50 BOOL CALLBACK ServerEdit_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
51 void ServerEdit_OnInitDialog (HWND hDlg);
52 BOOL ServerEdit_OnOK (HWND hDlg);
54 BOOL TextToAddr (SOCKADDR_IN *pAddr, LPTSTR pszServer);
58 * ROUTINES ___________________________________________________________________
62 BOOL CALLBACK HostsTab_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
68 Main_OnInitDialog (GetParent(hDlg));
69 HostsTab_OnInitDialog (hDlg);
76 if (!HostsTab_OnApply (hDlg))
77 SetWindowLongPtr (hDlg, DWLP_MSGRESULT, TRUE);
81 HostsTab_OnAdd (hDlg);
85 HostsTab_OnEdit (hDlg);
89 HostsTab_OnRemove (hDlg);
93 HostsTab_DlgProc (hDlg, WM_HELP, 0, 0);
100 WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_GENERAL_CCENTER);
102 WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_CELLS);
106 switch (((LPNMHDR)lp)->code)
109 HostsTab_OnSelect (hDlg);
113 if (IsWindowEnabled (GetDlgItem (hDlg, IDC_EDIT)))
114 HostsTab_OnEdit (hDlg);
124 void HostsTab_OnInitDialog (HWND hDlg)
126 if (!g.Configuration.CellServDB.pFirst)
128 CSDB_ReadFile (&g.Configuration.CellServDB, NULL);
130 // Fill in our list with cell names.
132 HostsTab_FillList (hDlg);
133 HostsTab_OnSelect (hDlg);
135 // If this is the Control Center applet, shove the default cell
136 // name onto the tab too.
140 Config_GetCellName (g.Configuration.szCell);
141 SetDlgItemText (hDlg, IDC_CELL, g.Configuration.szCell);
147 BOOL HostsTab_CommitChanges (BOOL fForce)
150 if ((hDlg = PropSheet_FindTabWindow (g.psh, (DLGPROC)HostsTab_DlgProc)) == NULL)
153 SetWindowLongPtr (hDlg, DWLP_MSGRESULT, FALSE); // Make sure we try to apply
154 if (HostsTab_OnApply (hDlg))
156 SetWindowLongPtr (hDlg, DWLP_MSGRESULT, TRUE);
161 BOOL HostsTab_OnApply (HWND hDlg)
163 // Don't try to do anything if we've already failed the apply
164 if (GetWindowLongPtr (hDlg, DWLP_MSGRESULT))
167 if (!CSDB_WriteFile (&g.Configuration.CellServDB))
170 // If this is the Control Center applet, we'll have to validate
171 // the cell name too.
175 TCHAR szNoCell[ cchRESOURCE ];
176 GetString (szNoCell, IDS_CELL_UNKNOWN);
178 TCHAR szCell[ cchRESOURCE ];
179 GetDlgItemText (hDlg, IDC_CELL, szCell, cchRESOURCE);
181 if ((!szCell[0]) || (!lstrcmpi (szNoCell, szCell)))
183 Message (MB_ICONASTERISK | MB_OK, GetErrorTitle(), IDS_NOCELL_DESC_CC);
187 char cellname[256], i;
189 /* we pray for all ascii cellnames */
190 for ( i=0 ; szCell[i] && i < (sizeof(cellname)-1) ; i++ )
191 cellname[i] = szCell[i];
194 ULONG code = cm_SearchCellRegistry(1, cellname, NULL, NULL, NULL, NULL);
196 code != CM_ERROR_FORCE_DNS_LOOKUP &&
197 !CSDB_FindCell (&g.Configuration.CellServDB, szCell))
201 if (cm_SearchCellByDNS(cellname, NULL, &ttl, NULL, NULL))
204 Message (MB_ICONASTERISK | MB_OK, GetErrorTitle(), IDS_BADCELL_DESC_CC);
209 if (!Config_SetCellName (szCell))
211 lstrcpy (g.Configuration.szCell, szCell);
218 void HostsTab_OnSelect (HWND hDlg)
220 HWND hList = GetDlgItem (hDlg, IDC_LIST);
221 HLISTITEM hItem = FastList_FindFirstSelected (hList);
222 HLISTITEM hNext = FastList_FindNextSelected (hList, hItem);
224 EnableWindow (GetDlgItem (hDlg, IDC_EDIT), !!hItem && !hNext);
225 EnableWindow (GetDlgItem (hDlg, IDC_REMOVE), !!hItem);
229 void HostsTab_OnAdd (HWND hDlg)
231 TCHAR szTitle[ cchRESOURCE ];
232 GetString (szTitle, IDS_CELLADD_TITLE);
234 LPPROPSHEET psh = PropSheet_Create (szTitle, FALSE, GetParent(hDlg), 0);
235 psh->sh.dwFlags |= PSH_NOAPPLYNOW; // Remove the Apply button
236 psh->sh.dwFlags |= PSH_HASHELP; // Add a Help button instead
237 PropSheet_AddTab (psh, szTitle, IDD_CELL_EDIT, (DLGPROC)CellEdit_DlgProc, 0, TRUE);
238 PropSheet_ShowModal (psh);
240 HostsTab_FillList (hDlg);
241 HostsTab_OnSelect (hDlg);
245 void HostsTab_OnEdit (HWND hDlg)
247 HWND hList = GetDlgItem (hDlg, IDC_LIST);
248 HLISTITEM hItem = FastList_FindFirstSelected (hList);
251 PCELLDBLINE pLine = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
253 CSDB_CrackLine (&Info, pLine->szLine);
255 LPTSTR pszTitle = FormatString (IDS_CELLEDIT_TITLE, TEXT("%s"), ((Info.szComment[0]) ? Info.szComment : Info.szCell));
257 LPPROPSHEET psh = PropSheet_Create (pszTitle, FALSE, GetParent(hDlg), (LPARAM)pLine);
258 psh->sh.dwFlags |= PSH_NOAPPLYNOW; // Remove the Apply button
259 psh->sh.dwFlags |= PSH_HASHELP; // Add a Help button instead
260 PropSheet_AddTab (psh, ((Info.szComment[0]) ? Info.szComment : Info.szCell), IDD_CELL_EDIT, (DLGPROC)CellEdit_DlgProc, (LPARAM)pLine, TRUE);
261 PropSheet_ShowModal (psh);
263 FreeString (pszTitle);
266 HostsTab_FillList (hDlg);
267 HostsTab_OnSelect (hDlg);
271 void HostsTab_OnRemove (HWND hDlg)
273 HWND hList = GetDlgItem (hDlg, IDC_LIST);
274 HLISTITEM hItem = FastList_FindFirstSelected (hList);
275 HLISTITEM hNext = FastList_FindNextSelected (hList, hItem);
283 if (Message (MB_ICONEXCLAMATION | MB_OKCANCEL, GetCautionTitle(), IDS_HOSTREM_MANY) != IDOK)
288 PCELLDBLINE pLine = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
290 CSDB_CrackLine (&Info, pLine->szLine);
292 if (Message (MB_ICONEXCLAMATION | MB_OKCANCEL, GetCautionTitle(), IDS_HOSTREM_ONE, TEXT("%s"), Info.szCell) != IDOK)
296 for ( ; hItem; hItem = FastList_FindNextSelected (hList, hItem))
298 PCELLDBLINE pLine = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
299 CSDB_RemoveCell (&g.Configuration.CellServDB, pLine);
302 HostsTab_FillList (hDlg);
303 HostsTab_OnSelect (hDlg);
307 void HostsTab_FillList (HWND hDlg)
309 HWND hList = GetDlgItem (hDlg, IDC_LIST);
310 FastList_Begin (hList);
311 FastList_RemoveAll (hList);
313 for (PCELLDBLINE pLine = g.Configuration.CellServDB.pFirst; pLine; pLine = pLine->pNext)
316 if (!CSDB_CrackLine (&Info, pLine->szLine))
321 TCHAR szText[ MAX_PATH ];
322 lstrcpy (szText, Info.szCell);
324 #if 0 // Add this if you like a more verbose Cell Hosts tab
326 wsprintf (&szText[ lstrlen(szText) ], TEXT(" (%s)"), Info.szComment);
330 memset (&ai, 0x00, sizeof(ai));
331 ai.iFirstImage = IMAGE_NOIMAGE;
332 ai.iSecondImage = IMAGE_NOIMAGE;
334 ai.lParam = (LPARAM)pLine;
335 FastList_AddItem (hList, &ai);
338 FastList_End (hList);
342 BOOL CALLBACK CellEdit_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
347 CellEdit_OnInitDialog (hDlg);
351 CellEdit_OnDestroy (hDlg);
358 CellEdit_OnApply (hDlg);
362 CellEdit_Enable (hDlg);
366 CellEdit_Enable (hDlg);
370 CellEdit_OnAdd (hDlg);
371 CellEdit_Enable (hDlg);
375 CellEdit_OnEdit (hDlg);
376 CellEdit_Enable (hDlg);
380 CellEdit_OnRemove (hDlg);
381 CellEdit_Enable (hDlg);
385 CellEdit_DlgProc (hDlg, WM_HELP, 0, 0);
391 if (PropSheet_FindTabParam (hDlg))
392 WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_CELLPROP_EDIT);
394 WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_CELLPROP_ADD);
398 switch (((LPNMHDR)lp)->code)
401 CellEdit_OnSelect (hDlg);
405 if (IsWindowEnabled (GetDlgItem (hDlg, IDC_EDIT)))
406 CellEdit_OnEdit (hDlg);
407 CellEdit_Enable (hDlg);
417 void CellEdit_OnInitDialog (HWND hDlg)
419 PCELLDBLINE pLine = (PCELLDBLINE)PropSheet_FindTabParam (hDlg);
423 CSDB_CrackLine (&Info, pLine->szLine);
424 SetDlgItemText (hDlg, IDC_CELL, Info.szCell);
425 SetDlgItemText (hDlg, IDC_COMMENT, Info.szComment);
428 for (pLine = pLine->pNext; pLine; pLine = pLine->pNext)
431 if (!CSDB_CrackLine (&Info, pLine->szLine))
436 CellEdit_AddServerEntry (hDlg, pLine, iOrder++);
440 // Prepare the columns on the server list
442 HWND hList = GetDlgItem (hDlg, IDC_LIST);
444 FASTLISTCOLUMN Column;
445 Column.dwFlags = FLCF_JUSTIFY_LEFT;
446 Column.cxWidth = 200;
447 GetString (Column.szText, IDS_SVRCOL_COMMENT);
448 FastList_SetColumn (hList, 0, &Column);
450 Column.dwFlags = FLCF_JUSTIFY_LEFT;
451 Column.cxWidth = 100;
452 GetString (Column.szText, IDS_SVRCOL_SERVER);
453 FastList_SetColumn (hList, 1, &Column);
455 FastList_SetSortFunction (hList, CellEdit_SortFunction);
457 // Remove the Context Help [?] thing from the title bar
459 DWORD dwStyle = GetWindowLong (GetParent (hDlg), GWL_STYLE);
460 dwStyle &= ~DS_CONTEXTHELP;
461 SetWindowLong (GetParent (hDlg), GWL_STYLE, dwStyle);
463 dwStyle = GetWindowLong (GetParent (hDlg), GWL_EXSTYLE);
464 dwStyle &= ~WS_EX_CONTEXTHELP;
465 SetWindowLong (GetParent (hDlg), GWL_EXSTYLE, dwStyle);
467 // A little cleanup and we're done!
469 CellEdit_Enable (hDlg);
470 CellEdit_OnSelect (hDlg);
474 void CellEdit_OnDestroy (HWND hDlg)
476 HWND hList = GetDlgItem (hDlg, IDC_LIST);
477 for (HLISTITEM hItem = FastList_FindFirst (hList); hItem; hItem = FastList_FindNext (hList, hItem))
479 PCELLDBLINE pInfo = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
485 void CellEdit_OnApply (HWND hDlg)
487 TCHAR szCell[ cchCELLDBLINE ];
488 GetDlgItemText (hDlg, IDC_CELL, szCell, cchCELLDBLINE);
490 TCHAR szComment[ cchCELLDBLINE ];
491 GetDlgItemText (hDlg, IDC_COMMENT, szComment, cchCELLDBLINE);
493 TCHAR szLinkedCell[ cchCELLDBLINE ] = TEXT("");
495 // Find out if there's already an entry in CellServDB for this cell
497 PCELLDBLINE pCellLine;
498 if ((pCellLine = CSDB_FindCell (&g.Configuration.CellServDB, szCell)) != NULL)
501 if (CSDB_CrackLine (&Info, pCellLine->szLine))
502 lstrcpy (szLinkedCell, Info.szLinkedCell);
505 // Replace our cell's entry in CellServDB, or add one if necessary.
507 if ((pCellLine = CSDB_AddCell (&g.Configuration.CellServDB, szCell, szLinkedCell, szComment)) != NULL)
509 // Remove the old servers from this cell
511 CSDB_RemoveCellServers (&g.Configuration.CellServDB, pCellLine);
513 // Add the servers from our list to the CellServDB
515 PCELLDBLINE pAppendTo = pCellLine;
517 HWND hList = GetDlgItem (hDlg, IDC_LIST);
518 for (HLISTITEM hItem = FastList_FindFirst (hList); hItem; hItem = FastList_FindNext (hList, hItem))
520 PCELLDBLINE pFromList = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
522 pAppendTo = CSDB_AddLine (&g.Configuration.CellServDB, pAppendTo, pFromList->szLine);
528 void CellEdit_OnSelect (HWND hDlg)
530 HWND hList = GetDlgItem (hDlg, IDC_LIST);
531 HLISTITEM hItem = FastList_FindFirstSelected (hList);
532 HLISTITEM hNext = FastList_FindNextSelected (hList, hItem);
534 EnableWindow (GetDlgItem (hDlg, IDC_EDIT), !!hItem && !hNext);
535 EnableWindow (GetDlgItem (hDlg, IDC_REMOVE), !!hItem);
539 void CellEdit_OnAdd (HWND hDlg)
542 memset (&Line, 0x00, sizeof(CELLDBLINE));
546 HWND hList = GetDlgItem (hDlg, IDC_LIST);
547 for (HLISTITEM hItem = FastList_FindFirst (hList); hItem; hItem = FastList_FindNext (hList, hItem))
549 PCELLDBLINE pInfo = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
550 iOrder = max (iOrder, 1+ (int)(pInfo->pNext));
553 if (ModalDialogParam (IDD_SERVER_EDIT, hDlg, (DLGPROC)ServerEdit_DlgProc, (LPARAM)&Line) == IDOK)
555 CellEdit_AddServerEntry (hDlg, &Line, iOrder);
560 void CellEdit_OnEdit (HWND hDlg)
562 HWND hList = GetDlgItem (hDlg, IDC_LIST);
563 HLISTITEM hItem = FastList_FindFirstSelected (hList);
564 PCELLDBLINE pInfo = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
567 memcpy (&Line, pInfo, sizeof(CELLDBLINE));
569 if (ModalDialogParam (IDD_SERVER_EDIT, hDlg, (DLGPROC)ServerEdit_DlgProc, (LPARAM)&Line) == IDOK)
572 CSDB_CrackLine (&Info, Line.szLine);
574 TCHAR szServer[ cchRESOURCE ];
575 lstrcpy (szServer, inet_ntoa (*(struct in_addr *)&Info.ipServer));
577 FastList_SetItemText (hList, hItem, 0, Info.szComment);
578 FastList_SetItemText (hList, hItem, 1, szServer);
580 lstrcpy (pInfo->szLine, Line.szLine);
585 void CellEdit_OnRemove (HWND hDlg)
587 HWND hList = GetDlgItem (hDlg, IDC_LIST);
588 FastList_Begin (hList);
591 while ((hItem = FastList_FindFirstSelected (hList)) != NULL)
593 PCELLDBLINE pInfo = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
595 FastList_RemoveItem (hList, hItem);
598 FastList_End (hList);
602 void CellEdit_Enable (HWND hDlg)
606 TCHAR szText[ cchRESOURCE ];
607 GetDlgItemText (hDlg, IDC_CELL, szText, cchRESOURCE);
611 if (!FastList_FindFirst (GetDlgItem (hDlg, IDC_LIST)))
614 EnableWindow (GetDlgItem (GetParent (hDlg), IDOK), fEnable);
618 void CellEdit_AddServerEntry (HWND hDlg, PCELLDBLINE pLine, int iOrder)
620 HWND hList = GetDlgItem (hDlg, IDC_LIST);
622 PCELLDBLINE pCopy = New (CELLDBLINE);
623 memcpy (pCopy, pLine, sizeof(CELLDBLINE));
625 pCopy->pNext = (PCELLDBLINE)iOrder;
628 CSDB_CrackLine (&Info, pCopy->szLine);
630 TCHAR szServer[ cchRESOURCE ];
631 lstrcpy (szServer, inet_ntoa (*(struct in_addr *)&Info.ipServer));
634 memset (&ai, 0x00, sizeof(ai));
635 ai.iFirstImage = IMAGE_NOIMAGE;
636 ai.iSecondImage = IMAGE_NOIMAGE;
637 ai.pszText = Info.szComment;
638 ai.lParam = (LPARAM)pCopy;
639 HLISTITEM hItem = FastList_AddItem (hList, &ai);
641 FastList_SetItemText (hList, hItem, 1, szServer);
645 int CALLBACK CellEdit_SortFunction (HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2)
647 if (!hItem1 || !hItem2)
650 PCELLDBLINE pLine1 = (PCELLDBLINE)lpItem1;
651 PCELLDBLINE pLine2 = (PCELLDBLINE)lpItem2;
653 int iOrder1 = (int)(pLine1->pNext);
654 int iOrder2 = (int)(pLine2->pNext);
655 return iOrder1 - iOrder2;
659 BOOL CALLBACK ServerEdit_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
664 SetWindowLongPtr (hDlg, DWLP_USER, lp);
665 ServerEdit_OnInitDialog (hDlg);
672 if (ServerEdit_OnOK (hDlg))
673 EndDialog (hDlg, IDOK);
677 EndDialog (hDlg, IDCANCEL);
681 ServerEdit_DlgProc (hDlg, WM_HELP, 0, 0);
684 case IDC_ADDR_SPECIFIC:
685 case IDC_ADDR_LOOKUP:
686 EnableWindow (GetDlgItem (hDlg, IDC_SERVER), IsDlgButtonChecked (hDlg, IDC_ADDR_SPECIFIC));
693 pLine = (PCELLDBLINE)GetWindowLongPtr (hDlg, DWLP_USER);
696 if (!CSDB_CrackLine (&Info, pLine->szLine))
697 WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_CELLPROP_SERVER_ADD);
699 WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_CELLPROP_SERVER_EDIT);
707 void ServerEdit_OnInitDialog (HWND hDlg)
709 PCELLDBLINE pLine = (PCELLDBLINE)GetWindowLongPtr (hDlg, DWLP_USER);
711 TCHAR szTitle[ cchRESOURCE ];
713 if (!CSDB_CrackLine (&Info, pLine->szLine))
714 GetString (szTitle, IDS_ADDSERVER_TITLE);
716 GetString (szTitle, IDS_EDITSERVER_TITLE);
717 SetWindowText (hDlg, szTitle);
720 memset (&Addr, 0x00, sizeof(SOCKADDR_IN));
721 Addr.sin_family = AF_INET;
722 Addr.sin_addr.s_addr = Info.ipServer;
723 SA_SetAddr (GetDlgItem (hDlg, IDC_SERVER), &Addr);
725 CheckDlgButton (hDlg, IDC_ADDR_SPECIFIC, !!Info.ipServer);
726 CheckDlgButton (hDlg, IDC_ADDR_LOOKUP, !Info.ipServer);
727 EnableWindow (GetDlgItem (hDlg, IDC_SERVER), IsDlgButtonChecked (hDlg, IDC_ADDR_SPECIFIC));
729 SetDlgItemText (hDlg, IDC_COMMENT, Info.szComment);
733 BOOL ServerEdit_OnOK (HWND hDlg)
735 PCELLDBLINE pLine = (PCELLDBLINE)GetWindowLongPtr (hDlg, DWLP_USER);
737 TCHAR szComment[ cchCELLDBLINE ];
738 GetDlgItemText (hDlg, IDC_COMMENT, szComment, cchCELLDBLINE);
741 if (IsDlgButtonChecked (hDlg, IDC_ADDR_SPECIFIC))
743 SA_GetAddr (GetDlgItem (hDlg, IDC_SERVER), &Addr);
744 lstrcpy (szComment, inet_ntoa (*(struct in_addr *)&Addr.sin_addr.s_addr));
746 if (!TextToAddr (&Addr, szComment))
748 Message (MB_ICONHAND, GetErrorTitle(), IDS_BADLOOKUP_DESC, TEXT("%s"), szComment);
752 TCHAR szServer[ cchCELLDBLINE ];
753 lstrcpy (szServer, inet_ntoa (*(struct in_addr *)&Addr.sin_addr.s_addr));
755 CSDB_FormatLine (pLine->szLine, szServer, NULL, szComment, FALSE);
760 BOOL TextToAddr (SOCKADDR_IN *pAddr, LPTSTR pszServer)
762 if (!pszServer || !*pszServer)
766 memset (pAddr, 0x00, sizeof(SOCKADDR_IN));
767 pAddr->sin_family = AF_INET;
769 if ((*pszServer >= TEXT('0')) && (*pszServer <= TEXT('9')))
771 if ((pAddr->sin_addr.s_addr = inet_addr (pszServer)) == 0)
775 if ((pEntry = gethostbyaddr ((char*)&pAddr->sin_addr.s_addr, sizeof(int), AF_INET)) == NULL)
778 if (pEntry->h_name[0])
779 lstrcpy (pszServer, pEntry->h_name); // return the server's fqdn
781 else // Need to lookup the server by its name
784 if ((pEntry = gethostbyname (pszServer)) == NULL)
787 memcpy (&pAddr->sin_addr, (struct in_addr *)pEntry->h_addr, sizeof(struct in_addr));
788 if (!pAddr->sin_addr.s_addr)
791 if (pEntry->h_name[0])
792 lstrcpy (pszServer, pEntry->h_name); // return the server's fqdn