Bugzilla Bug 322956: added PR_SI_HOSTNAME_UNTRUNCATED, which does not
authorwtchang%redhat.com
Thu, 19 Jan 2006 22:11:59 +0000
changeset 3551 3f795764998f6d6c4bff7ba9bafb0343a02db263
parent 3542 3c265df58a5e9d6da13b21715b37e8772655bf87
child 3556 d9baa449663b87aaa48f8753a19e820b08c00802
push idunknown
push userunknown
push dateunknown
bugs322956
Bugzilla Bug 322956: added PR_SI_HOSTNAME_UNTRUNCATED, which does not strip the domain name (if any). The patch is contributed by Philip Prindeville <philipp@redfish-solutions.com>. r=wtc,darin. Modified files: prsystem.h prsystem.c
pr/include/prsystem.h
pr/src/misc/prsystem.c
--- a/pr/include/prsystem.h
+++ b/pr/include/prsystem.h
@@ -65,20 +65,23 @@ NSPR_API(char) PR_GetDirectorySepartor(v
 **  Paths are assumed to be of the form:
 **      <directory>[<sep><directory>]*
 */
 
 NSPR_API(char) PR_GetPathSeparator(void);
 
 /* Types of information available via PR_GetSystemInfo(...) */
 typedef enum {
-    PR_SI_HOSTNAME,
+    PR_SI_HOSTNAME,  /* the hostname with the domain name (if any)
+                      * removed */
     PR_SI_SYSNAME,
     PR_SI_RELEASE,
-    PR_SI_ARCHITECTURE
+    PR_SI_ARCHITECTURE,
+    PR_SI_HOSTNAME_UNTRUNCATED  /* the hostname exactly as configured
+                                 * on the system */
 } PRSysInfo;
 
 
 /*
 ** If successful returns a null termintated string in 'buf' for
 ** the information indicated in 'cmd'. If unseccussful the reason for
 ** the failure can be retrieved from PR_GetError().
 **
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -129,18 +129,22 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(
 {
     PRUintn len = 0;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     switch(cmd)
     {
       case PR_SI_HOSTNAME:
+      case PR_SI_HOSTNAME_UNTRUNCATED:
         if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen))
             return PR_FAILURE;
+
+        if (cmd == PR_SI_HOSTNAME_UNTRUNCATED)
+            break;
         /*
          * On some platforms a system does not have a hostname and
          * its IP address is returned instead.   The following code
          * should be skipped on those platforms.
          */
 #ifndef _PR_GET_HOST_ADDR_AS_NAME
         /* Return the unqualified hostname */
             while (buf[len] && (len < buflen)) {