home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / tests / system.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.8 KB  |  63 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 "prio.h"
  20. #include "prmem.h"
  21. #include "prprf.h"
  22. #include "prsystem.h"
  23.  
  24. #include "plerror.h"
  25.  
  26. static char *tag[] =
  27. {
  28.     "PR_SI_HOSTNAME",
  29.     "PR_SI_SYSNAME",
  30.     "PR_SI_RELEASE",
  31.     "PR_SI_ARCHITECTURE"
  32. };
  33.  
  34. static PRSysInfo Incr(PRSysInfo *cmd)
  35. {
  36.     PRIntn tmp = (PRIntn)*cmd + 1;
  37.     *cmd = (PRSysInfo)tmp;
  38.     return (PRSysInfo)tmp;
  39. }  /* Incr */
  40.  
  41. PRIntn main(PRIntn argc, char **argv)
  42. {
  43.     PRStatus rv;
  44.     PRSysInfo cmd;
  45.     PRFileDesc *output = PR_GetSpecialFD(PR_StandardOutput);
  46.  
  47.     char *info = (char*)PR_Calloc(SYS_INFO_BUFFER_LENGTH, 1);
  48.     for (cmd = PR_SI_HOSTNAME; cmd <= PR_SI_ARCHITECTURE; Incr(&cmd))
  49.     {
  50.         rv = PR_GetSystemInfo(cmd, info, SYS_INFO_BUFFER_LENGTH);
  51.         if (PR_SUCCESS == rv) PR_fprintf(output, "%s: %s\n", tag[cmd], info);
  52.         else PL_FPrintError(output, tag[cmd]);
  53.     }
  54.     PR_DELETE(info);
  55.  
  56.     PR_fprintf(output, "Host page size is %d\n", PR_GetPageSize());
  57.     PR_fprintf(output, "Page shift is %d\n", PR_GetPageShift());
  58.  
  59.     return 0;
  60. }  /* main */
  61.  
  62. /* system.c */
  63.