You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



NSPR Reference
Previous     Contents     Next     


Chapter 25   System Information and Environment Variables

This chapter describes the NSPR API for obtaining system information, such as the host name, system name, system release, and system page size. NSPR also provides a platform-independent accessor for environment variables.

System Information Types
System Information and Environment Variable Functions

System Information Types

The type PRSysInfo is defined to represent system information.

PRSysInfo


Syntax
typedef enum {
   PR_SI_HOSTNAME,      /* name of the host */
   PR_SI_SYSNAME,       /* name of the system */
   PR_SI_RELEASE,       /* release number of the system */
   PR_SI_ARCHITECTURE   /* architecture of the system */
} PRSysInfo;


Description
This structure defines the command argument for the PR_GetSystemInfo function.

System Information and Environment Variable Functions

The system information functions are:

PR_GetSystemInfo
PR_GetPageSize
PR_GetPageShift

The function for obtaining the values of environment variables is:

PR_GetEnv

PR_GetSystemInfo

Retrieves information about the system.


Syntax
#include <prsystem.h>

PRStatus PR_GetSystemInfo (
   PRSysInfo cmd,
   char *buf,
   PRUint32 buflen);


Parameters
The function has the following parameters:

cmd

Specifies the system information required. Possible values are:

 PR_SI_HOSTNAME
 PR_SI_SYSNAME
 PR_SI_RELEASE
 PR_SI_ARCHITECTURE

buf

A pointer to a buffer to hold the NULL-terminated string containing the system information. This buffer must be pre-allocated by the caller.

buflen

The size of the buffer in bytes.


Returns
If successful, PR_SUCCESS; otherwise, PR_FAILURE.


Description
This function retrieves the system information specified by cmd. The type of information is as follows:

PR_SI_HOSTNAME

Name of the host

PR_SI_SYSNAME

Name of the system

PR_SI_RELEASE

Release number of the system

PR_SI_ARCHITECTURE

Architecture of the system

Upon a successful return the system information is contained in a NULL-terminated string in the specified buffer. The buffer must be pre-allocated by the caller and should be at least SYS_INFO_BUFFER_LENGTH bytes in length.

PR_GetPageSize

Retrieves the system page size.


Syntax
#include <prsystem.h>

PRInt32 PR_GetPageSize(void);


Parameters
The function has no parameters.


Returns
A 32-bit number of bytes.


Description
This function returns the number of bytes in a page on the system.

PR_GetPageShift

Retrieves the log2 of the system page size.


Syntax
#include <prsystem.h>

PRInt32 PR_GetPageShift(void);


Parameters
The function has no parameters.


Returns
A 32-bit number.


Description
This function returns the log2 value of the number of bytes in a page on the system.

PR_GetEnv

Retrieves the value of an environment variable.


Syntax
#include <prenv.h

char* PR_GetEnv(const char *name);


Parameters
The function has the following parameter:

name

A pointer to a NULL-terminated string containing the name of the environment variable.


Returns
If the environment variable is defined, returns a pointer to its value; otherwise returns NULL.


Description
This function searches the environment list for a string that contains the specified name, of the form name=value. If a match is found, the function returns a pointer to the value. If the environment variable is not defined, the function returns NULL.

Caution: The returned pointer should be treated as a const char*.


Previous     Contents     Next     

Last Updated May 18, 2001