home *** CD-ROM | disk | FTP | other *** search
/ ftp.ncftp.com / ftp.ncftp.com.zip / ftp.ncftp.com / libncftp / libncftp-3.2.5-src.zip / libncftp-3.2.5 / sio / DNSUtil.c < prev    next >
C/C++ Source or Header  |  2009-10-23  |  15KB  |  618 lines

  1. #include "syshdrs.h"
  2. #ifdef PRAGMA_HDRSTOP
  3. #    pragma hdrstop
  4. #endif
  5.  
  6. #define _CRT_SECURE_NO_WARNINGS 1
  7.  
  8. #ifndef STRNCPY
  9. #    define STRNCPY(a,b) strncpy(a, b, sizeof(a)); a[sizeof(a) - 1] = '\0'
  10. #    define Strncpy(a,b,s) strncpy(a, b, s); a[s - 1] = '\0' 
  11. #    define Strncat(a,b,s)\
  12.     { \
  13.         size_t alen = strlen(a); \
  14.         if (alen < s) { \
  15.             strncpy(a + alen, b, s - alen); \
  16.         } \
  17.         a[s - 1] = '\0'  \
  18.     }
  19. #endif
  20.  
  21. #if (((defined(MACOSX)) && (MACOSX < 10300)) || (defined(AIX) && (AIX < 430)) || (defined(DIGITAL_UNIX)) || (defined(SOLARIS)) || (defined(SCO)) || (defined(HPUX)))
  22. extern int getdomainname(char *name, gethostname_size_t namelen);
  23. #endif
  24.  
  25.  
  26. int
  27. GetHostByName(struct hostent *const hp, const char *const name, char *const hpbuf, size_t hpbufsize)
  28. {
  29. #if defined(DNSSEC_LOCAL_VALIDATION)
  30.     char *usehpbuf;
  31.     struct hostent *h;
  32.     int my_h_errno, rc;
  33.         val_status_t val_status;
  34.  
  35.     usehpbuf = hpbuf;
  36.     forever {
  37.         errno = 0;
  38.         my_h_errno = 0;
  39.         h = NULL;
  40.         memset(usehpbuf, 0, hpbufsize);
  41.         rc = val_gethostbyname2_r(NULL, name, AF_INET, hp, usehpbuf,
  42.                                           hpbufsize, &h, &my_h_errno,
  43.                                           &val_status);
  44.         if ((rc == 0) && (h != NULL)) {
  45.                     if (!val_istrusted(val_status))
  46.             return (-2);
  47.                     return (0);
  48.                 }
  49.         if ((rc == 0) && (my_h_errno != 0))
  50.             errno = ENOENT;
  51.         break;
  52.     }
  53. #elif defined(HAVE_GETHOSTBYNAME_R) && (defined(SOLARIS) || defined(IRIX) || defined(BSDOS))
  54.     struct hostent *h;
  55.     int h_errno_unused = 0;
  56.     memset(hpbuf, 0, hpbufsize);
  57.     h = gethostbyname_r(name, hp, hpbuf, hpbufsize, &h_errno_unused);
  58.     if (h != NULL)
  59.         return (0);
  60. #elif defined(HAVE_GETHOSTBYNAME2_R) && defined(LINUX) && defined(HAVE_ALLOCA)
  61.     char *usehpbuf;
  62.     struct hostent *h;
  63.     int my_h_errno, rc;
  64.  
  65.     usehpbuf = hpbuf;
  66.     forever {
  67.         errno = 0;
  68.         my_h_errno = 0;
  69.         h = NULL;
  70.         memset(usehpbuf, 0, hpbufsize);
  71.         rc = gethostbyname2_r(name, AF_INET, hp, usehpbuf, hpbufsize, &h, &my_h_errno);
  72.         if ((rc == 0) && (h != NULL))
  73.             return (0);
  74.         if ((rc == ERANGE) || ((rc == -1) && (errno == ERANGE))) {
  75.             hpbufsize *= 2;
  76.             usehpbuf = alloca(hpbufsize);
  77.             if (usehpbuf == NULL) {
  78.                 errno = ENOMEM;
  79.                 return (-1);
  80.             }
  81.             continue;
  82.         }
  83.         if ((rc == 0) && (my_h_errno != 0))
  84.             errno = ENOENT;
  85.         break;
  86.     }
  87. #elif defined(HAVE_GETHOSTBYNAME_R) && defined(LINUX) && defined(HAVE_ALLOCA)
  88.     char *usehpbuf;
  89.     struct hostent *h;
  90.     int my_h_errno, rc;
  91.  
  92.     usehpbuf = hpbuf;
  93.     forever {
  94.         errno = 0;
  95.         my_h_errno = 0;
  96.         h = NULL;
  97.         memset(usehpbuf, 0, hpbufsize);
  98.         rc = gethostbyname_r(name, hp, usehpbuf, hpbufsize, &h, &my_h_errno);
  99.         if ((rc == 0) && (h != NULL))
  100.             return (0);
  101.         if ((rc == ERANGE) || ((rc == -1) && (errno == ERANGE))) {
  102.             hpbufsize *= 2;
  103.             usehpbuf = alloca(hpbufsize);
  104.             if (usehpbuf == NULL) {
  105.                 errno = ENOMEM;
  106.                 return (-1);
  107.             }
  108.             continue;
  109.         }
  110.         if ((rc == 0) && (my_h_errno != 0))
  111.             errno = ENOENT;
  112.         break;
  113.     }
  114. #elif defined(HAVE_GETHOSTBYNAME_R) && defined(AIX)
  115.     struct hostent_data hed;
  116.     memset(hpbuf, 0, hpbufsize);
  117.     memset(&hed, 0, sizeof(hed));
  118.     if (gethostbyname_r(name, hp, &hed) == 0)
  119.         return (0);
  120. #else
  121.     /* Note: gethostbyname is already threadsafe on: HP-UX, Tru64 */
  122.     struct hostent *h;
  123.     h = gethostbyname(name);
  124.     if (h != NULL) {
  125.         memcpy(hp, h, sizeof(struct hostent));
  126.         return (0);
  127.     } else {
  128.         memset(hp, 0, sizeof(struct hostent));
  129.         memset(hpbuf, 0, hpbufsize);
  130.     }
  131. #endif
  132.     return (-1);
  133. }    /* GetHostByName */
  134.  
  135.  
  136.  
  137.  
  138. int
  139. GetHostByAddr(struct hostent *const hp, void *addr, int asize, int atype, char *const hpbuf, size_t hpbufsize)
  140. {
  141. #if defined(DNSSEC_LOCAL_VALIDATION)
  142.     struct hostent *h;
  143.     int h_errno_unused = 0, rc;
  144.     val_status_t val_status;
  145.  
  146.     memset(hpbuf, 0, hpbufsize);
  147.     rc = val_gethostbyaddr_r(NULL, addr, asize, atype,
  148.                                  hp, hpbuf, hpbufsize, &h, &h_errno_unused,
  149.                                  &val_status);
  150.     if ((rc == 0) && (h != NULL)) {
  151.         if (!val_istrusted(val_status))
  152.             return (-2);
  153.         return (0);
  154.     }
  155. #elif defined(HAVE_GETHOSTBYADDR_R) && (defined(SOLARIS) || defined(IRIX) || defined(BSDOS))
  156.     struct hostent *h;
  157.     int h_errno_unused = 0;
  158.     memset(hpbuf, 0, hpbufsize);
  159.     h = gethostbyaddr_r((gethost_addrptr_t) addr, asize, atype, hp, hpbuf, hpbufsize, &h_errno_unused);
  160.     if (h != NULL)
  161.         return (0);
  162. #elif defined(HAVE_GETHOSTBYADDR_R) && defined(LINUX) && defined(HAVE_ALLOCA)
  163.     char *usehpbuf;
  164.     struct hostent *h;
  165.     int my_h_errno, rc;
  166.  
  167.     usehpbuf = hpbuf;
  168.     forever {
  169.         errno = 0;
  170.         my_h_errno = 0;
  171.         h = NULL;
  172.         memset(usehpbuf, 0, hpbufsize);
  173.         rc = gethostbyaddr_r((gethost_addrptr_t) addr, asize, atype, hp, usehpbuf, hpbufsize, &h, &my_h_errno);
  174.         if ((rc == 0) && (h != NULL))
  175.             return (0);
  176.         if ((rc == ERANGE) || ((rc == -1) && (errno == ERANGE))) {
  177.             hpbufsize *= 2;
  178.             usehpbuf = alloca(hpbufsize);
  179.             if (usehpbuf == NULL) {
  180.                 errno = ENOMEM;
  181.                 return (-1);
  182.             }
  183.             continue;
  184.         }
  185.         if ((rc == 0) && (my_h_errno != 0))
  186.             errno = ENOENT;
  187.         break;
  188.     }
  189. #elif defined(HAVE_GETHOSTBYADDR_R) && defined(AIX)
  190.     struct hostent_data hed;
  191.     memset(hpbuf, 0, hpbufsize);
  192.     memset(&hed, 0, sizeof(hed));
  193.     if (gethostbyaddr_r(addr, asize, atype, hp, &hed) == 0)
  194.         return (0);
  195. #else
  196.     /* Note: gethostbyaddr is already threadsafe on: HP-UX, Tru64 */
  197.     struct hostent *h;
  198.     h = gethostbyaddr((gethost_addrptr_t) addr, asize, atype);
  199.     if (h != NULL) {
  200.         memcpy(hp, h, sizeof(struct hostent));
  201.         return (0);
  202.     } else {
  203.         memset(hp, 0, sizeof(struct hostent));
  204.         memset(hpbuf, 0, hpbufsize);
  205.     }
  206. #endif
  207.     return (-1);
  208. }    /* GetHostByAddr */
  209.  
  210.  
  211.  
  212.  
  213. /* On entry, you should have 'host' be set to a symbolic name (like
  214.  * cse.unl.edu), or set to a numeric address (like 129.93.3.1).
  215.  * If the function fails, it will return NULL, but if the host was
  216.  * a numeric style address, you'll have the ip_address to fall back on.
  217.  */
  218.  
  219. int
  220. GetHostEntry(struct hostent *const hp, const char *const host, struct in_addr *const ip_address, char *const hpbuf, size_t hpbufsize)
  221. {
  222.     struct in_addr ip;
  223.     int rc;
  224.     
  225.     /* See if the host was given in the dotted IP format, like "36.44.0.2."
  226.      * If it was, inet_addr will convert that to a 32-bit binary value;
  227.      * if not, inet_addr will return (-1L).
  228.      */
  229.     ip.s_addr = inet_addr(host);
  230.     if (ip.s_addr != INADDR_NONE) {
  231.         rc = GetHostByAddr(hp, (char *) &ip, (int) sizeof(ip), AF_INET, hpbuf, hpbufsize);
  232.         if (rc == 0) {
  233.             rc = 0;
  234.             if (ip_address != NULL)
  235.                 (void) memcpy(&ip_address->s_addr, hp->h_addr_list[0], (size_t) hp->h_length);
  236.         } else if (ip_address != NULL) {
  237.             (void) memcpy(ip_address, &ip, sizeof(struct in_addr));
  238.         }
  239.     } else {
  240.         /* No IP address, so it must be a hostname, like ftp.wustl.edu. */
  241.         if (ip_address != NULL)
  242.             ip_address->s_addr = INADDR_NONE;
  243.         rc = GetHostByName(hp, host, hpbuf, hpbufsize);
  244.         if (rc == 0) {
  245.             if (ip_address != NULL)
  246.                 (void) memcpy(&ip_address->s_addr, hp->h_addr_list[0], (size_t) hp->h_length);
  247.         }
  248.     }
  249. #if defined(DNSSEC_LOCAL_VALIDATION)
  250.     if ((rc < 0) && (rc != -2))
  251.         rc = -1;
  252. #else
  253.     if ((rc < 0) && (rc != -1))
  254.         rc = -1;
  255. #endif
  256.     return (rc);
  257. }    /* GetHostEntry */
  258.  
  259.  
  260.  
  261.  
  262. static char *
  263. strtokc(char *parsestr, const char *delims, char **context)
  264. {
  265.     char *cp;
  266.     const char *cp2;
  267.     char c, c2;
  268.     char *start;
  269.  
  270.     if (parsestr == NULL)
  271.         start = *context;
  272.     else
  273.         start = parsestr;
  274.  
  275.     if ((start == NULL) || (delims == NULL)) {
  276.         *context = NULL;
  277.         return NULL;
  278.     }
  279.  
  280.     /* Eat leading delimiters. */
  281.     for (cp = start; ; ) {
  282. next1:
  283.         c = *cp++;
  284.         if (c == '\0') {
  285.             /* No more tokens. */
  286.             *context = NULL;
  287.             return (NULL);
  288.         }
  289.         for (cp2 = delims; ; ) {
  290.             c2 = (char) *cp2++;
  291.             if (c2 == '\0') {
  292.                 /* This character was not a delimiter.
  293.                  * The token starts here.
  294.                  */
  295.                 start = cp - 1;
  296.                 goto starttok;
  297.             }
  298.             if (c2 == c) {
  299.                 /* This char was a delimiter. */
  300.                 /* Skip it, look at next character. */
  301.                 goto next1;
  302.             }
  303.         }
  304.         /*NOTREACHED*/
  305.     }
  306.  
  307. starttok:
  308.     for ( ; ; cp++) {
  309.         c = *cp;
  310.         if (c == '\0') {
  311.             /* Token is finished. */
  312.             *context = cp;
  313.             break;
  314.         }
  315.         for (cp2 = delims; ; ) {
  316.             c2 = (char) *cp2++;
  317.             if (c2 == '\0') {
  318.                 /* This character was not a delimiter.
  319.                  * Keep it as part of current token.
  320.                  */
  321.                 break;
  322.             }
  323.             if (c2 == c) {
  324.                 /* This char was a delimiter. */
  325.                 /* End of token. */
  326.                 *cp++ = '\0';
  327.                 *context = cp;
  328.                 return (start);
  329.             }
  330.         }
  331.     }
  332.     return (start);
  333. }    /* strtokc */
  334.  
  335.  
  336.  
  337. #if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__)
  338. int
  339. getdomainname(char *const domain, unsigned int dsize)
  340. {
  341.     HKEY hkey;
  342.     DWORD rc;
  343.     DWORD valSize;
  344.  
  345.     /* Works for Win NT/2000/XP */
  346.     rc = RegOpenKeyEx(
  347.             HKEY_LOCAL_MACHINE,
  348.             "System\\CurrentControlSet\\Services\\Tcpip\\Parameters",
  349.             0,
  350.             KEY_READ,
  351.             &hkey
  352.     );
  353.  
  354.     if (rc == ERROR_SUCCESS) {
  355.         valSize = (DWORD) (dsize - 1);
  356.         memset(domain, 0, dsize);
  357.         rc = RegQueryValueEx(
  358.             hkey,
  359.             "DhcpDomain",
  360.             NULL,
  361.             NULL,
  362.             (LPBYTE) domain,
  363.             &valSize
  364.         );
  365.  
  366.         if ((rc == ERROR_SUCCESS) && (domain[0] != '\0')) {
  367.             RegCloseKey(hkey);
  368.             return (0);
  369.         }
  370.  
  371.         valSize = (DWORD) (dsize - 1);
  372.         memset(domain, 0, dsize);
  373.         rc = RegQueryValueEx(
  374.             hkey,
  375.             "Domain",
  376.             NULL,
  377.             NULL,
  378.             (LPBYTE) domain,
  379.             &valSize
  380.         );
  381.  
  382.         if ((rc == ERROR_SUCCESS) && (domain[0] != '\0')) {
  383.             RegCloseKey(hkey);
  384.             return (0);
  385.         }
  386.  
  387.         RegCloseKey(hkey);
  388.     }
  389.  
  390.     /* Works for Win 9x */
  391.     rc = RegOpenKeyEx(
  392.             HKEY_LOCAL_MACHINE,
  393.             "System\\CurrentControlSet\\Services\\VxD\\MSTCP",
  394.             0,
  395.             KEY_READ,
  396.             &hkey
  397.     );
  398.  
  399.     if (rc == ERROR_SUCCESS) {
  400.         valSize = (DWORD) (dsize - 1);
  401.         memset(domain, 0, dsize);
  402.         rc = RegQueryValueEx(
  403.             hkey,
  404.             "Domain",
  405.             NULL,
  406.             NULL,
  407.             (LPBYTE) domain,
  408.             &valSize
  409.         );
  410.  
  411.         if ((rc == ERROR_SUCCESS) && (domain[0] != '\0')) {
  412.             RegCloseKey(hkey);
  413.             return (0);
  414.         }
  415.  
  416.         RegCloseKey(hkey);
  417.     }
  418.  
  419.     memset(domain, 0, dsize);
  420.     return (-1);
  421. }    /* getdomainname */
  422. #endif    /* WINDOWS */
  423.  
  424.  
  425.  
  426. /* Makes every effort to return a fully qualified domain name. */
  427. int
  428. GetOurHostName(char *const host, const size_t siz)
  429. {
  430. #ifdef HOSTNAME
  431.     /* You can hardcode in the name if this routine doesn't work
  432.      * the way you want it to.
  433.      */
  434.     (void) Strncpy(host, HOSTNAME, siz);
  435.     return (kHostnameHardCoded);        /* Success */
  436. #else
  437.     struct hostent hp;
  438.     struct in_addr ip;
  439.     int result;
  440.     char **curAlias;
  441.     char domain[128];
  442.     char hpbuf[1024];
  443.     char *cp;
  444.     char *dlim, *dcp;
  445.     char *ctext;
  446.     int rc = 0;
  447.  
  448.     memset(host, 0, siz);
  449.     result = gethostname(host, (gethostname_size_t) siz);
  450.     if ((result < 0) || (host[0] == '\0')) {
  451.         rc = kGethostnameFailed;
  452.         goto done;    /* Failure */
  453.     }
  454.  
  455.     if (strchr(host, '.') != NULL) {
  456.         /* gethostname returned full name (like "cse.unl.edu"), instead
  457.          * of just the node name (like "cse").
  458.          */
  459.         rc = kGethostnameFullyQualified;
  460.         goto done;    /* Success */
  461.     }
  462.  
  463.     if ((GetHostByName(&hp, host, hpbuf, sizeof(hpbuf)) == 0) && (hp.h_name != NULL) && (hp.h_name[0] != '\0')) {
  464.         /* Maybe the host entry has the full name. */
  465.         cp = strchr((char *) hp.h_name, '.');
  466.         if ((cp != NULL) && (cp[1] != '\0')) {
  467.             /* The 'name' field for the host entry had full name. */
  468.             (void) Strncpy(host, (char *) hp.h_name, siz);
  469.             rc = kGethostbynameFullyQualified;
  470.             goto done;    /* Success */
  471.         }
  472.  
  473.         /* Make note of the IP address. */
  474.         ip = * ((struct in_addr **) hp.h_addr_list)[0];
  475.  
  476.         /* Now try the list of aliases, to see if any of those look real. */
  477.         for (curAlias = hp.h_aliases; *curAlias != NULL; curAlias++) {
  478.             cp = strchr(*curAlias, '.');
  479.             if ((cp != NULL) && (cp[1] != '\0')) {
  480.                 (void) Strncpy(host, *curAlias, siz);
  481.                 rc = kGethostbynameHostAliasFullyQualified;
  482.                 goto done;    /* Success */
  483.             }
  484.         }
  485.  
  486.         /* Use saved IP address to lookup the record by IP address. */
  487.         if (ip.s_addr != INADDR_NONE) {
  488.             if (GetHostByAddr(&hp, (char *) &ip, (int) sizeof(ip), AF_INET, hpbuf, sizeof(hpbuf)) == 0) {
  489.                 /* Maybe the host entry has the full name. */
  490.                 cp = strchr((char *) hp.h_name, '.');
  491.                 if ((cp != NULL) && (cp[1] != '\0')) {
  492.                     /* The 'name' field for the host entry had full name. */
  493.                     (void) Strncpy(host, (char *) hp.h_name, siz);
  494.                     rc = kGethostbyaddrFullyQualified;
  495.                     goto done;    /* Success */
  496.                 }
  497.  
  498.                 /* Now try the list of aliases, to see if any of those look real. */
  499.                 for (curAlias = hp.h_aliases; *curAlias != NULL; curAlias++) {
  500.                     cp = strchr(*curAlias, '.');
  501.                     if ((cp != NULL) && (cp[1] != '\0')) {
  502.                         (void) Strncpy(host, *curAlias, siz);
  503.                         rc = kGethostbyaddrHostAliasFullyQualified;
  504.                         goto done;    /* Success */
  505.                     }
  506.                 }
  507.             }
  508.         }
  509.     }
  510.  
  511.     /* Otherwise, we just have the node name.  See if we can get the
  512.      * domain name ourselves.
  513.      */
  514. #ifdef DOMAINNAME
  515.     (void) STRNCPY(domain, DOMAINNAME);
  516.     rc = kDomainnameHardCoded;
  517. #else
  518.     rc = kDomainnameUnknown;
  519.     domain[0] = '\0';
  520.  
  521. #    if defined(HAVE_RES_INIT) && defined(HAVE__RES_DEFDNAME)
  522.     if (domain[0] == '\0') {
  523.         res_init();
  524.         if ((_res.defdname != NULL) && (_res.defdname[0] != '\0')) {
  525.             STRNCPY(domain, _res.defdname);
  526.             rc = kResInitDomainnameFound;
  527.         }
  528.     }
  529. #    endif    /* HAVE_RES_INIT && HAVE__RES_DEFDNAME */
  530.     
  531.     if (domain[0] == '\0') {
  532.         FILE *fp;
  533.         char line[256];
  534.         char srch[128];
  535.         char *tok;
  536.  
  537.         fp = fopen("/etc/resolv.conf", "r");
  538.         if (fp != NULL) {
  539.             srch[0] = '\0';
  540.             memset(line, 0, sizeof(line));
  541.             while (fgets(line, sizeof(line) - 1, fp) != NULL) {
  542.                 if (!isalpha((int) line[0]))
  543.                     continue;    /* Skip comment lines. */
  544.                 ctext = NULL;
  545.                 tok = strtokc(line, " \t\n\r", &ctext);
  546.                 if (tok == NULL)
  547.                     continue;    /* Impossible */
  548.                 if (strcmp(tok, "domain") == 0) {
  549.                     tok = strtokc(NULL, " \t\n\r", &ctext);
  550.                     if (tok == NULL)
  551.                         continue;    /* syntax error */
  552.                     (void) STRNCPY(domain, tok);
  553.                     rc = kEtcResolvConfDomainFound;
  554.                     break;    /* Done. */
  555.                 } else if (strcmp(tok, "search") == 0) {
  556.                     tok = strtokc(NULL, " \t\n\r", &ctext);
  557.                     if (tok == NULL)
  558.                         continue;    /* syntax error */
  559.                     (void) STRNCPY(srch, tok);
  560.                     /* continue */
  561.                 }
  562.             }
  563.             (void) fclose(fp);
  564.  
  565.             if ((domain[0] == '\0') && (srch[0] != '\0')) {
  566.                 (void) STRNCPY(domain, srch);
  567.                 rc = kEtcResolvConfSearchFound;
  568.             }
  569.         }
  570.     }
  571.  
  572. #    if defined(HAVE_GETDOMAINNAME) || \
  573.         ((defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__))
  574.     if (domain[0] == '\0') {
  575.         if (getdomainname(domain, (gethostname_size_t) (sizeof(domain) - 1)) != 0) {
  576.             domain[0] = '\0';
  577.         } else if (strchr(domain, '.') == NULL) {
  578.             /* Probably a NIS domain, not a DNS domain name */
  579.             domain[0] = '\0';
  580.         }
  581.     }
  582. #    endif    /* HAVE_GETDOMAINNAME */
  583. #endif    /* DOMAINNAME */
  584.  
  585.     if (domain[0] != '\0') {
  586.         /* Supposedly, it's legal for a domain name with
  587.          * a period at the end.
  588.          */
  589.         cp = domain + strlen(domain) - 1;
  590.         if (*cp == '.')
  591.             *cp = '\0';
  592.         cp = domain;
  593.         dcp = host + strlen(host);
  594.         dlim = host + siz - 1;
  595.         if ((domain[0] != '.') && (dcp < dlim))
  596.             *dcp++ = '.';
  597.         while (*cp) {
  598.             if (dcp < dlim)
  599.                 *dcp++ = *cp;
  600.             cp++;
  601.         }
  602.         *dcp = '\0';
  603.     }
  604. done:
  605.     if (rc < 0)
  606.         memset(host, 0, siz);
  607.     if (host[siz - 1] != '\0') {
  608.         /* Hostname (most likely) couldn't fit.
  609.          * Return failure, but unlike other
  610.          * failures, leave what we had before
  611.          * it was truncated.
  612.          */
  613.         rc = kFullyQualifiedHostNameTooLongForBuffer;
  614.     }
  615.     return (rc);    /* Success */
  616. #endif    /* !HOSTNAME */
  617. }    /* GetOurHostName */
  618.