Cari di JavaScript 
    JavaScript Manual
Daftar Isi
(Sebelumnya) getOptionValueCount, isNaN, Nu ...ssjs_getClientID, String, tain ... (Berikutnya)

registerCFunction

Registers an external function for use with a server-side JavaScript application.

Server-side function

Implemented in

LiveWire 1.0

Syntax

registerCFunction(JSFunctionName, libraryPath,
   externalFunctionName)

Parameters

JSFunctionName
The name of the function as it is called in JavaScript.

libraryPath
The full filename and path of the library, using the conventions of your operating system.

externalFunctionName
The name of the function as it is defined in the library.

Description

registerCFunction is a top-level server-side JavaScript function that is not associated with any object.

Use registerCFunction to make an external function available to a server-side JavaScript application. The function can be written in any language, but you must use C calling conventions.

To use an external function in a server-side JavaScript application, register the function with registerCFunction, and then call it with the callC function. Once an application registers a function, you can call the function any number of times.

The registerCFunction function returns true if the external function is registered successfully; otherwise, it returns false. For example, registerCFunction can return false if the JavaScript runtime engine cannot find either the library or the specified function inside the library.

To use a backslash () character as a directory separator in the libraryPath parameter, you must enter a double backslash (). The single backslash is a reserved character.

Examples

See the example for the callC function.

See also

callC


ssjs_generateClientID

Returns a unique string you can use to uniquely specify the client object.

Server-side function

Implemented in

Netscape Server 3.0

Syntax

ssjs_generateClientID()

Parameters

None.

Description

This function is closely related to ssjs_getClientID. See the description of that function for information on these functions and the differences between them.


ssjs_getCGIVariable

Returns the value of the specified environment variable set in the server process, including some CGI variables.

Server-side function

Implemented in

Netscape Server 3.0

Syntax

ssjs_getCGIVariable(varName)

Parameters

varName
A string containing the name of the environment variable to retrieve.

Description

ssjs_getCGIVariable lets you access the environment variables set in the server process, including the CGI variables listed in Table 13.2.

Table 13.2 CGI variables accessible through ssjs_getCGIVariable  

VariableDescription
AUTH_TYPE
The authorization type, if the request is protected by any type of authorization. Netscape web servers support HTTP basic access authorization. Example value: basic

HTTPS
If security is active on the server, the value of this variable is ON; otherwise, it is OFF. Example value: ON

HTTPS_KEYSIZE
The number of bits in the session key used to encrypt the session, if security is on. Example value: 128

HTTPS_SECRETKEYSIZE
The number of bits used to generate the server's private key. Example value: 128

PATH_INFO
Path information, as sent by the browser. Example value: /cgivars/cgivars.html

PATH_TRANSLATED
The actual system-specific pathname of the path contained in PATH_INFO. Example value: /usr/ns-home/myhttpd/js/samples/cgivars/cgivars.html

QUERY_STRING
Information from the requesting HTML page; if "?" is present, the information in the URL that comes after the "?". Example value: x=42

REMOTE_ADDR
The IP address of the host that submitted the request. Example value: 198.93.95.47

REMOTE_HOST
If DNS is turned on for the server, the name of the host that submitted the request; otherwise, its IP address. Example value: www.netscape.com

REMOTE_USER
The name of the local HTTP user of the web browser, if HTTP access authorization has been activated for this URL. Note that this is not a way to determine the user name of any person accessing your program. Example value: ksmith

REQUEST_METHOD
The HTTP method associated with the request. An application can use this to determine the proper response to a request. Example value: GET

SCRIPT_NAME
The pathname to this page, as it appears in the URL. Example value: cgivars.html

SERVER_NAME
The hostname or IP address on which the JavaScript application is running, as it appears in the URL. Example value: piccolo.mcom.com

SERVER_PORT
The TCP port on which the server is running. Example value: 2020

SERVER_PROTOCOL
The HTTP protocol level supported by the client's software. Example value: HTTP/1.0

SERVER_URL
The URL that the user typed to access this server. Example value: https://piccolo:2020

If you supply an argument that isn't one of the CGI variables listed in n, the runtime engine looks for an environment variable by that name in the server environment. If found, the runtime engine returns the value; otherwise, it returns null. For example, the following code assigns the value of the standard CLASSPATH environment variable to the JavaScript variable classpath:

classpath = ssjs_getCGIVariable("CLASSPATH");
(Sebelumnya) getOptionValueCount, isNaN, Nu ...ssjs_getClientID, String, tain ... (Berikutnya)