* details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
#define X_INCLUDE_NETDB_H
#define XOS_USE_XT_LOCKING
-#if defined(linux) || defined(CSRG_BASED)
+#if defined(__linux__) || defined(CSRG_BASED)
#define index
#define rindex
#endif
#include <X11/Xos_r.h>
-#if defined(linux) || defined(CSRG_BASED)
+#if defined(__linux__) || defined(CSRG_BASED)
#undef index
#undef rindex
#endif
_Tt_hostname_cache()
{
hostname = (_Tt_string) 0;
+ addr_length = 0;
}
_Tt_hostname_cache::
_Tt_string h_prefix = host, l_prefix = localhost,
h, l, rpart_host, rpart_localhost;
-#ifdef notdef
-printf("DEBUG prefix_host: host = %s, localhost = %s\n",
- (char *) host, (char *) localhost);
-#endif
-
while (rpart_host == rpart_localhost) {
h = h_prefix;
l = l_prefix;
rpart_localhost = l.split(j, l_prefix);
}
-#ifdef notdef
-printf("DEBUG prefix_host: returning %s\n", (char *) h);
-#endif
return h;
}
{
// First try a simple comparison.
if (host1 == host2) {
-#ifdef notdef
-printf("DEBUG hostname_equiv: host1 == host2, returning 1\n");
-#endif
return 1;
}
// so do just one comparison.
if (short_tmp != long_prefix) {
-#ifdef notdef
-printf("DEBUG hostname_equiv: short_tmp %s != long_prefix %s, returning 0\n",
- (char *) short_tmp, (char *) long_prefix);
-#endif
return 0;
}
is_found = 1;
}
if (short_prefix != long_prefix) {
-#ifdef notdef
-printf("DEBUG hostname_equiv: short_prefix %s != long_prefix %s, returning 0\n",
- (char *) short_prefix, (char *) long_prefix);
-#endif
return 0;
}
}
if (is_found != 1) {
-#ifdef notdef
-printf("DEBUG hostname_equiv: is_found != 1, returning 0\n");
-#endif
return 0; // no prefix was found
}
if (_cache_it(sh, shorthost) == 1) {
_cache_table->insert(sh);
} else {
-#ifdef notdef
-printf("DEBUG hostname_equiv: sh.is_null(): returning 0\n");
-#endif
return 0;
}
}
if (_cache_it(lh, longhost) == 1) {
_cache_table->insert(lh);
} else {
-#ifdef notdef
-printf("DEBUG hostname_equiv: lh.is_null(): returning 0\n");
-#endif
return 0;
}
}
// This will probably never happen but why
// not be careful?
if (sh->addr_length != lh->addr_length) {
-#ifdef notdef
-printf("DEBUG hostname_equiv: sh->addr_length %d != h->addr_length %d, returning 0\n",
- sh->addr_length, lh->addr_length);
-#endif
return 0;
}
while (sh_c.next()) {
while (lh_c.next()) {
-#ifdef notdef
-printf("DEBUG hostname_equiv: checking address at 0x%x w/ 0x%x\n",
- (char *) *sh_c, (char *) *lh_c);
-#endif
// Do the IP addresses match?
if (memcmp((char *) *sh_c, (char *) *lh_c,
sh->addr_length) == 0) {
// success!
-#ifdef notdef
-printf("DEBUG hostname_equiv: found match!\n");
-#endif
return 1;
}
}
_Tt_hostname_cache_ptr sh, lh;
struct hostent *host_ret;
_Xgethostbynameparams host_buf;
- int failed = 0;
char **h_addr_list;