1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
Function: GetActiveLaunchProfileForHost
Declaration: LaunchProfile *GetActiveLaunchProfileForHost(const std::string &hostName) const;
Definition:
// ****************************************************************************
// Method: HostProfileList::GetActiveLaunchProfileForHost
//
// Purpose:
// Returns the active launch profile for the machine with a host name
// pattern matching the specified host name.
//
// Arguments:
// hostName the host name to match with the profile hostname patterns
//
// Returns:
// A pointer to the host profile, or NULL.
//
// Programmer: Jeremy Meredith
// Creation: February 18, 2010
//
// Modifications:
//
// ****************************************************************************
LaunchProfile *
HostProfileList::GetActiveLaunchProfileForHost(const std::string &hostName) const
{
MachineProfile *machine = GetMachineProfileForHost(hostName);
return machine->GetActiveLaunchProfile();
}
Function: GetMachineProfileForHost
Declaration: MachineProfile *GetMachineProfileForHost(const std::string &hostName) const;
Definition:
// ****************************************************************************
// Method: HostProfileList::GetMachineProfileForHost
//
// Purpose:
// Gets the machine profile with a host name pattern
// matching the specified host name.
//
// Arguments:
// hostName the host name to match with the profile hostname patterns
//
// Returns:
// A pointer to the machine profile, or NULL.
//
// Programmer: Jeremy Meredith
// Creation: February 18, 2010
//
// Modifications:
// Brad Whitlock, Tue May 20 11:53:37 PDT 2003
// I moved these include files to here so we can successfully regenerate
// the class.
//
// Jeremy Meredith, Fri Feb 26 09:28:01 EST 2010
// Try matching against the original hostname if matching against the
// resolved host name fails.
//
// David Camp, Fri Feb 26 13:53:28 PST 2010
// Try matching against all of the host's aliases.
// ****************************************************************************
#if defined(_WIN32)
#include <winsock2.h>
#else
#include <netdb.h>
#endif
MachineProfile *
HostProfileList::GetMachineProfileForHost(const std::string &hostName) const
{
// Check for the hostname
for(size_t i = 0; i < machines.size(); i++)
{
MachineProfile *m = (MachineProfile *)(machines[i]);
if (m->ProfileMatchesHost(hostName))
return m;
}
struct hostent *hostEnt = gethostbyname(hostName.c_str());
if (hostEnt)
{
// Check for the official host name
std::string fqhostName(hostEnt->h_name);
for(size_t i = 0; i < machines.size(); i++)
{
MachineProfile *m = (MachineProfile *)(machines[i]);
if (m->ProfileMatchesHost(fqhostName))
return m;
}
// Check all of the aliases
for(int j=0; hostEnt->h_aliases[j] != NULL; j++)
{
fqhostName = std::string(hostEnt->h_aliases[j]);
for(size_t i = 0; i < machines.size(); i++)
{
MachineProfile *m = (MachineProfile *)(machines[i]);
if (m->ProfileMatchesHost(fqhostName))
return m;
}
}
}
return NULL;
}
|