home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / misc / prsystem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.3 KB  |  77 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "primpl.h"
  20. #include "prsystem.h"
  21. #include "prprf.h"
  22.  
  23. #if defined(XP_UNIX)
  24. #include <unistd.h>
  25. #include <sys/utsname.h>
  26. #endif
  27.  
  28. PR_IMPLEMENT(char) PR_GetDirectorySepartor()
  29. {
  30.     return PR_DIRECTORY_SEPARATOR;
  31. }  /* PR_GetDirectorySepartor */
  32.  
  33. PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 buflen)
  34. {
  35.     PRUintn len = 0;
  36.  
  37.     if (!_pr_initialized) _PR_ImplicitInitialization();
  38.  
  39.     switch(cmd)
  40.     {
  41.       case PR_SI_HOSTNAME:
  42.         if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen))
  43.             return PR_FAILURE;
  44.         /* Return the unqualified hostname */
  45.             while (buf[len] && (len < buflen)) {
  46.                 if (buf[len] == '.') {
  47.                     buf[len] = '\0';
  48.                     break;
  49.                 }
  50.                 len += 1;
  51.             }    
  52.          break;
  53.  
  54.       case PR_SI_SYSNAME:
  55.         /* Return the operating system name */
  56.         (void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);
  57.         break;
  58.  
  59.       case PR_SI_RELEASE:
  60.         /* Return the version of the operating system */
  61. #if defined(XP_UNIX)
  62.         {
  63.             struct utsname info;
  64.             uname(&info);
  65.             (void)PR_snprintf(buf, buflen, info.release);
  66.         }
  67. #endif
  68.         break;
  69.  
  70.       case PR_SI_ARCHITECTURE:
  71.         /* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/
  72.         (void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);
  73.         break;
  74.     }
  75.     return PR_SUCCESS;
  76. }
  77.