NSPR Reference Previous Contents Next |
Chapter 25 System Information and Environment Variables
System Information Types
System Information and Environment Variable Functions
System Information Types
The typePRSysInfo
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 thePR_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_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:Returns
If successful,PR_SUCCESS
; otherwise, PR_FAILURE
.
Description
This function retrieves the system information specified bycmd
. 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 returnsNULL
.
Description
This function searches the environment list for a string that contains the specified name, of the formname=
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*
.
Last Updated May 18, 2001