S & U

                                                                                                                                                                                                                                                                                                                                      Back to [Book]     [Topic]

Functions and Macros beginning with S and U

The following functions and macros are discussed in this section:

sendfile() Function session_dns() Function session_maxdns() Function shexp_casecmp() Function shexp_cmp() Function
shexp_match() Function shexp_valid() Function STRDUP() Macro system_errmsg() Function system_fclose() Function
system_flock() Function system_fopenRO() Function system_fopenRW() Function system_fopenWA() Function system_fread() Function
system_fwrite() Function system_fwrite_atomic() Function system_gmtime() Function system_localtime() Function system_lseek() Function
system_rename() Function system_ulock() Function system_unix2local() Function systhread_attach() Function systhread_current() Function
systhread_getdata() Function systhread_newkey() Function systhread_setdata() Function systhread_sleep() Function systhread_start() Function
systhread_timerset() Function USE_NSAPI_VERSION() Macro util_can_exec() Function (UNIX Only) util_chdir2path() Function util_cookie_find() Function
util_env_find() Function util_env_create() Function util_env_free() Function util_env_replace() Function util_env_str() Function
util_getline() Function util_hostname() Function util_is_mozilla() Function util_is_url() Function util_itoa() Function util_later_than() Function
util_sh_escape() Function util_snprintf() Function util_sprintf() Function util_strcasecmp() Function util_strftime() Function util_strncasecmp() Function
util_uri_escape() Function util_uri_is_evil() Function util_uri_parse() Function util_uri_unescape() Function util_vsnprintf() Function util_vsprintf() Function

sendfile() Function

The sendfile filter method is called when the contents of a file are to be sent. Filters that modify or consume outgoing data can choose to implement the sendfile filter method.

If a filter implements the write filter method but not the sendfile filter method, the server will automatically translate net_sendfile() calls to net_write() calls. As a result, filters interested in the outgoing data stream do not need to implement the sendfile filter method. However, for performance reasons, filters that implement the write filter method should also implement the sendfile filter method.

Syntax Return Values Parameters Example
int sendfile(FilterLayer *layer, const sendfiledata *data);

The number of bytes consumed, which might be less than the requested amount if an error occurred. FilterLayer *layer is the filter layer in which the filter is installed.
const sendfiledata *sfd identifies the data to send.
int myfilter_sendfile(FilterLayer *layer, const sendfiledata *sfd)
{
    return net_sendfile(layer->lower, sfd);
}

See Also

session_dns() Function

The session_dns function resolves the IP address of the client associated with a specified session into its DNS name. The function returns a newly allocated string. You can use session_dns to change the numeric IP address into something more readable.

The session_maxdns function verifies that the client matches its claimed identity. The session_dns function does not perform this verification.

Note -
This function works only if the DNS directive is enabled in the magnus.conf file. For more information, see Appendix B: Alphabetical List of NSAPI Functions and Macros.
Syntax Return Values Parameters
char *session_dns(Session *sn);

A string containing the host name, or NULL if the DNS name cannot be found for the IP address. Session *sn is the session.
The Session is the same parameter as the one passed to your SAF.

session_maxdns() Function

The session_maxdns function resolves the IP address of the client associated with a specified session into its DNS name. This function returns a newly allocated string. You can use session_maxdns to change the numeric IP address into something more readable.

Note -
This function works only if the DNS directive is enabled in the magnus.conf file. For more information, see Appendix B: Alphabetical List of NSAPI Functions and Macros.
Syntax Return Values Parameters
char *session_maxdns(Session *sn);

A string containing the host name, or NULL if the DNS name cannot be found for the IP address. Session *sn is the Session.
The Session is the same parameter as the one passed to your SAF.

shexp_casecmp() Function

The shexp_casecmp function validates a specified shell expression and compares it with a specified string. This function returns one of three possible values representing match, no match, and invalid comparison. The comparison, in contrast to the comparison made by the shexp_cmp function is not case sensitive.

Use this function if you have a shell expression like *.netscape.com and make sure that a string matches it, such as foo.netscape.com.

Syntax Return Values Parameters
int shexp_casecmp(char *str, char *exp);

0 if a match was found.
1 if no match was found.
-1 if the comparison resulted in an invalid expression.
char *str is the string to be compared.
char *exp is the shell expression (wildcard pattern) to compare against.

See Also

shexp_cmp() Function

The shexp_cmp function validates a specified shell expression and compares it with a specified string. This returns one of three possible values representing match, no match, and invalid comparison. The comparison in contrast to the comparison made by the shexp_casecmp function is case sensitive.

Use this function for a shell expression like *.netscape.com and make sure that a string matches it, such as foo.netscape.com.

Syntax Return Values Parameters Example
int shexp_cmp(char *str, char *exp);

0 if a match was found.
1 if no match was found.
-1 if the comparison resulted in an invalid expression.
char *str is the string to be compared.
char *exp is the shell expression (wildcard pattern) to compare against.
/* Use wildcard match to see if this path is one we want */
char *path;
char *match = "/usr/netscape/*";
if (shexp_cmp(path, match) != 0)    
    return REQ_NOACTION;   /* no match */

See Also

shexp_match() Function

The shexp_match function compares a specified pre-validated shell expression against a specified string. This function returns one of three possible values representing match, no match, and invalid comparison. The comparison in contrast to the contrast made by the shexp_casecmp function is case sensitive.

The shexp_match function does not perform validation of the shell expression. To perform validation, use shexp_valid().

Use this function for a shell expression such as *.netscape.com, and make sure that a string matches it, such as foo.netscape.com.

Syntax Return Values Parameters
int shexp_match(char *str, char *exp);

0 if a match was found.
1 if no match was found.
-1 if the comparison resulted in an invalid expression.
char *str is the string to be compared.
char *exp is the prevalidated shell expression (wildcard pattern) to compare against.

See Also

shexp_valid() Function

The shexp_valid function validates a specified shell expression named by exp. Use this function to validate a shell expression before using the function shexp_match to compare the expression with a string.

Syntax Return Values Parameters
int shexp_valid(char *exp);

The constant NON_SXP if exp is a standard string.
The constant INVALID_SXP if exp is an invalid shell expression.
The constant VALID_SXP if exp is a valid shell expression.
char *exp is the shell expression (wildcard pattern) to be validated.

See Also

STRDUP() Macro

The STRDUP macro is a platform-independent substitute for the C library routine strdup. This macro creates a new copy of a string in the request’s memory pool. The memory can be explicitly freed by a call to FREE. If the memory is not explicitly freed, it is automatically freed after processing the current request. If pooled memory has been disabled in the configuration file with the built-in pool-init SAF, PERM_STRDUP and STRDUP both obtain their memory from the system heap. However, because the memory allocated by STRDUP is automatically freed, do not share this memory between threads.

The STRDUP routine is functionally equivalent to:

newstr = (char *) MALLOC(strlen(str) + 1);
strcpy(newstr, str);       
Syntax Return Values Parameters Example
char *STRDUP(char *ptr);

A pointer to the new string. char *ptr is a pointer to a string.
char *name1 = "MyName";
char *name2 = STRDUP(name1);

See Also

system_errmsg() Function

The system_errmsg function returns the last error that occurred from the most recent system call. This function is implemented as a macro that returns an entry from the global array sys_errlist. Use this macro to help with I/O error diagnostics.

Syntax Return Values Parameters
char *system_errmsg(int param1);

A string containing the text of the latest error message that resulted from a system call. Do not FREE this string. int param1 is reserved, and should always have the value 0.

See Also

system_fclose() Function

The system_fclose function closes a specified file descriptor. The system_fclose function must be called for every file descriptor opened by any of the system_fopen functions.

Syntax Return Values Parameters Example
int system_fclose(SYS_FILE fd);

0 if the close succeeds, or the constant IO_ERROR if the close fails. SYS_FILE fd is the platform-independent file descriptor.
SYS_FILE logfd; 
system_fclose(logfd);

See Also

system_flock() Function

The system_flock function locks the specified file against interference from other processes. Use system_flock if you do not want other processes to use the file you currently have open. Overusing file locking can cause performance degradation and possibly lead to deadlocks.

Syntax Return Values Parameters
int system_flock(SYS_FILE fd);

The constant IO_OKAY if the lock succeeds, or the constant IO_ERROR if the lock fails. SYS_FILE fd is the platform-independent file descriptor.

See Also

system_fopenRO() Function

The system_fopenRO function opens the file identified by path in read-only mode and returns a valid file descriptor. Use this function to open files that will not be modified by your program. In addition, you can use system_fopenRO to open a new file buffer structure using filebuf_open.

Syntax Return Values Parameters
SYS_FILE system_fopenRO(char *path);

The system-independent file descriptor (SYS_FILE) if the open succeeds, or 0 if the open fails. char *path is the file name.

See Also

system_fopenRW() Function

The system_fopenRW function opens the file identified by path in read-write mode and returns a valid file descriptor. If the file already exists, system_fopenRW does not truncate it. Use this function to open files that can be read and written by your program.

Syntax Return Values Parameters Example
SYS_FILE system_fopenRW(char *path);

The system-independent file descriptor (SYS_FILE) if the open succeeds, or 0 if the open fails. char *path is the file name.
SYS_FILE fd;
fd = system_fopenRO(pathname);
if (fd == SYS_ERROR_FD)    
break;

See Also

system_fopenWA() Function

The system_fopenWA function opens the file identified by path in write-append mode and returns a valid file descriptor. Use this function to open those files to which your program will append data.

Syntax Return Values Parameters
SYS_FILE system_fopenWA(char *path);

The system-independent file descriptor (SYS_FILE) if the open succeeds, or 0 if the open fails. char *path is the file name.

See Also

system_fread() Function

The system_fread function reads a specified number of bytes from a specified file into a specified buffer. This function returns the number of bytes read. Before system_fread can be used, you must open the file using any of the system_fopen functions except system_fopenWA.

Syntax Return Values Parameters
int system_fread(SYS_FILE fd, char *buf, int sz);

The number of bytes read, which might be less than the requested size if an error occurs, or if the end of the file was reached before that number of characters were obtained. SYS_FILE fd is the platform-independent file descriptor.
char *buf is the buffer to receive the bytes.
int sz is the number of bytes to read.

See Also

system_fwrite() Function

The system_fwrite function writes a specified number of bytes from a specified buffer into a specified file.

Before system_fwrite can be used, you must open the file using any of the system_fopen functions except system_fopenRO.

Syntax Return Values Parameters
int system_fwrite(SYS_FILE fd, char *buf, int sz);

The constant IO_OKAY if the write succeeds, or the constant IO_ERROR if the write fails. SYS_FILE fd is the platform-independent file descriptor.
char *buf is the buffer containing the bytes to be written.
int sz is the number of bytes to write to the file.

See Also

system_fwrite_atomic() Function

The system_fwrite_atomic function writes a specified number of bytes from a specified buffer into a specified file. This function also locks the file prior to performing the write, and then unlocks it when done, thereby avoiding interference between simultaneous write actions. Before system_fwrite_atomic can be used, you must open the file using any of the system_fopen functions except system_fopenRO.

Syntax Return Values Parameters Example
int system_fwrite_atomic(SYS_FILE fd, char *buf, int sz);

The constant IO_OKAY if the write/lock succeeds, or the constant IO_ERROR if the write/lock fails. SYS_FILE fd is the platform-independent file descriptor.
char *buf is the buffer containing the bytes to be written.
int sz is the number of bytes to write to the file.
SYS_FILE logfd;
char *logmsg = "An error occurred.";
system_fwrite_atomic(logfd, logmsg, strlen(logmsg));

See Also

system_gmtime() Function

The system_gmtime function is a thread-safe version of the standard gmtime function. This function returns the current time adjusted to Greenwich Mean Time.

Syntax Return Values Parameters Example
struct tm *system_gmtime(const time_t *tp, const struct tm *res);

A pointer to a calendar time (tm) structure containing the GMT time. Depending on your system, the pointer might point to the data item represented by the second parameter, or the pointer might point to a statically allocated item. For portability, do not assume either situation. time_t *tp is an arithmetic time.
tm *res is a pointer to a calendar time (tm) structure.
time_t tp;
struct tm res, *resp;
tp = time(NULL);
resp = system_gmtime(&tp, &res);

See Also

system_localtime() Function

The system_localtime function is a thread-safe version of the standard localtime function. This function returns the current time in the local time zone.

Syntax Return Values Parameters
struct tm *system_localtime(const time_t *tp, const struct tm *res);

A pointer to a calendar time (tm) structure containing the local time. Depending on your system, the pointer might point to the data item represented by the second parameter, or the pointer might point to a statically allocated item. For portability, do not assume either situation. time_t *tp is an arithmetic time.
tm *res is a pointer to a calendar time (tm) structure.

See Also

system_lseek() Function

The system_lseek function sets the file position of a file. This position affects where data from system_fread or system_fwrite is read or written.

Syntax Return Values Parameters
int system_lseek(SYS_FILE fd, int offset, int whence);

The offset, in bytes, of the new position from the beginning of the file if the operation succeeds, or -1 if the operation fails. SYS_FILE fd is the platform-independent file descriptor.
int offset is a number of bytes relative to whence. This value may be negative.
int whence is one of the following constants:
  • SEEK_SET, from the beginning of the file.
  • SEEK_CUR, from the current file position.
  • SEEK_END, from the end of the file.

See Also

system_rename() Function

The system_rename function renames a file. This function does not work on directories if the old and new directories are on different file systems.

Syntax Return Values Parameters
int system_rename(char *old, char *new);

0 if the operation succeeds, or -1 if the operation fails. char *old is the old name of the file.
char *new is the new name for the file.

system_ulock() Function

The system_ulock function unlocks the specified file that has been locked by the function system_lock. For more information about locking, see system_flock() Function.

Syntax Return Values Parameters
int system_ulock(SYS_FILE fd);

The constant IO_OKAY if the operation succeeds, or the constant IO_ERROR if the operation fails. SYS_FILE fd is the platform-independent file descriptor.

See Also

system_unix2local() Function

The system_unix2local function converts a specified UNIX-style path name to a local file system path name. Use this function when you have a file name in the UNIX format such as one containing forward slashes, and you need to access a file on another system such as Windows. You can use system_unix2local to convert the UNIX file name into the format that Windows accepts. In the UNIX environment this function has no effect, but can be called for portability.

Syntax Return Values Parameters
char *system_unix2local(char *path, char *lp);

A pointer to the local file system path string. char *path is the UNIX-style path name to be converted.
char *lp is the local path name.
You must allocate the parameter lp, which must contain enough space to hold the local path name.

See Also

systhread_attach() Function

The systhread_attach function makes an existing thread into a platform-independent thread.

Syntax Return Values Parameters
SYS_THREAD systhread_attach(void);

A SYS_THREAD pointer to the platform-independent thread. None

See Also

systhread_current() Function

The systhread_current function returns a pointer to the current thread.

Syntax Return Values Parameters
SYS_THREAD systhread_current(void);

A SYS_THREAD pointer to the current thread. None

See Also

systhread_getdata() Function

The systhread_getdata function gets data that is associated with a specified key in the current thread.

Syntax Return Values Parameters
void *systhread_getdata(int key);

A pointer to the data that was earlier used with the systhread_setkey function from the current thread, using the same value of key if the call succeeds. Return Values NULL if the call does not succeed, for example, if the systhread_setkey function was never called with the specified key during this session. int key is the value associated with the stored data by a systhread_setdata function. Keys are assigned by the systhread_newkey function.

See Also

systhread_newkey() Function

The systhread_newkey function allocates a new integer key (identifier) for thread-private data. Use this key to identify a variable that you want to localize to the current thread, then use the systhread_setdata function to associate a value with the key.

Syntax Return Values Parameters
int systhread_newkey(void);

An integer key. None

See Also

systhread_setdata() Function

The systhread_setdata function associates data with a specified key number for the current thread. Keys are assigned by the systhread_newkey function.

Syntax Return Values Parameters
void systhread_setdata(int key, void *data);

void int key is the priority of the thread.
void *data is the pointer to the string of data to be associated with the value of key.

See Also

systhread_sleep() Function

The systhread_sleep function puts the calling thread to sleep for a given time.

Syntax Return Values Parameters
void systhread_sleep(int milliseconds);

void int milliseconds is the number of milliseconds the thread is to sleep.

See Also

systhread_start() Function

The systhread_start function creates a thread with the given priority, allocates a stack of a specified number of bytes, and calls a specified function with a specified argument.

Syntax Return Values Parameters
SYS_THREAD systhread_start(int prio, int stksz, void (*fn)(void *), void *arg);

A new SYS_THREAD pointer if the call succeeds, or the constant SYS_THREAD_ERROR if the call does not succeed. int prio is the priority of the thread. Priorities are system-dependent.
int stksz is the stack size in bytes. If stksz is zero (0), the function allocates a default size.
void (*fn)(void *) is the function to call.
void *arg is the argument for the fn function.

See Also

systhread_timerset() Function

The systhread_timerset function starts or resets the interrupt timer interval for a thread system.

Note -
Because most systems do not allow the timer interval to be changed, this function should be considered a suggestion rather than a command.
Syntax Return Values Parameters
void systhread_timerset(int usec);

void int usec is the time in microseconds.

See Also

USE_NSAPI_VERSION() Macro

Plug-in developers can define the USE_NSAPI_VERSION macro before including the nsapi.h header file to request a particular version of NSAPI. The requested NSAPI version is encoded by multiplying the major version number by 100 and then adding the resulting value to the minor version number. For example, the following code requests NSAPI 3.2 features:

#define USE_NSAPI_VERSION 302 /* We want NSAPI 3.2 (Web Server 6.1) */
#include "nsapi.h"

To develop a plug-in that is compatible across multiple server versions, define USE_NSAPI_VERSION as the highest NSAPI version supported by all of the target server versions.

The following table lists server versions and the highest NSAPI version supported by each.

Table 6-2 NSAPI Versions Supported by Different Servers

Server Version NSAPI Version
iPlanet Web Server 4.1 3.0
iPlanet Web Server 6.0 3.1
Netscape Enterprise Server 6.0 3.1
Netscape Enterprise Server 6.1 3.1
Sun ONE Application Server 7.0 3.1
Sun ONE Web Server 6.1 3.2
Sun Java System Web Proxy Server 4.0 3.3
Sun Java System Web Server 7.0 Update 2 3.3

Do not request a version of NSAPI higher than the highest version supported by the nsapi.h header that the plug-in is being compiled against. Additionally, to use USE_NSAPI_VERSION, you must compile against an nsapi.h header file that supports NSAPI 3.2 or higher.

Syntax Example
int USE_NSAPI_VERSION
The following code can be used when building a plug-in designed to work with iPlanet Web Server 4.1 and Sun Java System Web Server 7.0 Update 2:
#define USE_NSAPI_VERSION 300 /* We want NSAPI 3.0 (Web Server 4.1) */
#include "nsapi.h"

See Also

util_can_exec() Function (UNIX Only)

The util_can_exec function checks that a specified file can be executed, returning either a 1 (executable) or a 0. The function checks whether the file can be executed by the user with the given user and group ID.

Use this function before executing a program using the exec system call.

Syntax Return Values Parameters
int util_can_exec(struct stat *finfo, uid_t uid, gid_t gid);

1 if the file is executable, or 0 if the file is not executable. stat *finfo is the stat structure associated with a file.
uid_t uid is the UNIX user ID.
gid_t gid is the UNIX group ID. Together with uid, this value determines the permissions of the UNIX user.

See Also

util_chdir2path() Function

The util_chdir2path function changes the current working directory. Because a server process can service multiple requests concurrently but has only a single current working directory, this function should not be used.

Syntax Return Values Parameters
int util_chdir2path(char *path);

0 if the directory change succeeds, or -1 if the directory can not be changed. char *path is the name of a directory.
The parameter must be a writable string.

util_cookie_find() Function

The util_cookie_find function finds a specific cookie in a cookie string and returns its value.

Syntax Return Values Parameters
char *util_cookie_find(char *cookie, char *name);

If successful, this function returns a pointer to the NULL-terminated value of the cookie. Otherwise, this function returns NULL. This function modifies the cookie string parameter by null-terminating the name and value. char *cookie is the value of the Cookie: request header.
char *name is the name of the cookie whose value is to be retrieved.

util_env_find() Function

The util_env_find function locates the string denoted by a name in a specified environment and returns the associated value. Use this function to find an entry in an environment.

Syntax Return Values Parameters
char *util_env_find(char **env, char *name);

The value of the environment variable if the string is found, or NULL if the string was not found. char **env is the environment.
char *name is the name of an environment variable in env.

See Also

util_env_create() Function

The util_env_create function creates and allocates the environment specified by env and returns a pointer to the environment. If the parameter env is NULL, the function allocates a new environment. Use util_env_create to create an environment when executing a new program.

Syntax Return Values Parameters
#include <base/util.h>
char **util_env_create(char **_env_, int _n_, int *_pos_);

A pointer to an environment. char **env is the environment or NULL.
int n is the maximum number of environment entries that you want in the environment.
int *pos is an integer that keeps track of the number of entries used in the environment.

See Also

util_env_free() Function

The util_env_free function frees a specified environment. Use this function to deallocate an environment you created using the function util_env_create.

Syntax Return Values Parameters
void util_env_free(char **env);

void char **env is the environment to be freed.

See Also

util_env_replace() Function

The util_env_replace function replaces the occurrence of the variable denoted by a name in a specified environment with a specified value. Use this function to change the value of a setting in an environment.

Syntax Return Values Parameters
void util_env_replace(char **env, char *name, char *value);

void char **env is the environment.
char *name is the name of a name-value pair.
char *value is the new value to be stored.

See Also

util_env_str() Function

The util_env_str function creates an environment entry and returns the entry. This function does not check for non-alphanumeric symbols in the name, for example, the equal sign “=”. You can use this function to create a new environment entry.

Syntax Return Values Parameters
char *util_env_str(char *name, char *value);

A newly allocated string containing the name-value pair. char *name is the name of a name-value pair.
char *value is the new value to be stored.

See Also

util_getline() Function

The util_getline function scans the specified file buffer to find a line feed or carriage return/line feed terminated string. The string is copied into the specified buffer, and NULL-terminates it. The function returns a value that indicates whether the operation stored a string in the buffer, encountered an error, or reached the end of the file.

Use this function to scan lines out of a text file, such as a configuration file.

Syntax Return Values Parameters
int util_getline(filebuf *buf, int lineno, int maxlen, char *line);

0 if successful, line contains the string.
1 if the end of file is reached, line contains the string.
-1 if an error occurs, line contains a description of the error.
filebuf *buf is the file buffer to be scanned.
int lineno is used to include the line number in the error message when an error occurs. The caller is responsible for making sure the line number is accurate.
int maxlen is the maximum number of characters that can be written into l.
char *l is the buffer in which to store the string. The user is responsible for allocating and deallocating line.

util_hostname() Function

The util_hostname function retrieves the local host name and returns it as a string. If the function cannot find a fully qualified domain name, it returns NULL. You can reallocate or free this string. Use this function to determine the name of the system you are on.

Syntax Return Values Parameters
char *util_hostname(void);

A string containing the name, if a fully qualified domain name is found. Otherwise, the function returns NULL. None

util_is_mozilla() Function

The util_is_mozilla function checks whether a specified user-agent header string is a Mozilla browser of at least a specified revision level. The function returns a 1 if the level matches, and 0 otherwise. This function uses strings to specify the revision level to avoid ambiguities such as 1.56 > 1.5.

Syntax Return Values Parameters
int util_is_mozilla(char *ua, char *major, char *minor);

1 if the user-agent is a Mozilla browser, or 0 if the user-agent is not a Mozilla browser. char *ua is the user-agent string from the request headers.
char *major is the major release number, found to the left of the decimal point.
char *minor is the minor release number, found to the right of the decimal point.

See Also

util_is_url() Function

The util_is_url function checks whether a string is a URL, returns 1 if the string is a URL and 0 otherwise. The string is a URL if it begins with alphabetic characters followed by a colon ( : ).

Syntax Return Values Parameters
int util_is_url(char *url);

1 if the string specified by url is a URL, or 0 if the string specified by url is not a URL. char *url is the string to be examined.

See Also

util_itoa() Function

The util_itoa function converts a specified integer to a string, and returns the length of the string. Use this function to create a textual representation of a number.

Syntax Return Values Parameters
int util_itoa(int i, char *a);

The length of the string created. int i is the integer to be converted.
char *a is the ASCII string that represents the value. The user is responsible for the allocation and deallocation of a. The string should be at least 32 bytes long.

util_later_than() Function

The util_later_than function compares the date specified in a time structure against a date specified in a string. If the date in the string is later than or equal to the one in the time structure, the function returns 1. Use this function to handle RFC 822, RFC 850, and ctime formats.

Syntax Return Values Parameters
int util_later_than(struct tm *lms, char *ims);

1 if the date represented by ims is the same as or later than that represented by the lms, or 0 if the date represented by ims is earlier than that represented by the lms. tm *lms is the time structure containing a date.
char *ims is the string containing a date.

See Also

util_sh_escape() Function

The util_sh_escape function parses a specified string and places a backslash ({{}}) in front of any shell-special characters, returning the resulting string. Use this function to ensure that strings from clients do not cause a shell to do anything unexpected.

The shell-special characters are the space plus the following characters:

&;`'"|*?~<>^()[]{}$\#!
Syntax Return Values Parameters
char *util_sh_escape(char *s);

A newly allocated string. char *s is the string to be parsed.

See Also

util_snprintf() Function

The util_snprintf function formats a specified string, using a specified format, into a specified buffer using the printf-style syntax and performs bounds checking. This function returns the number of characters in the formatted buffer.

For more information, see the documentation on the printf function for the runtime library of your compiler.

Syntax Return Values Parameters
int util_snprintf(char *s, int n, char *fmt, ...);

The number of characters formatted into the buffer. char *s is the buffer to receive the formatted string.
int n is the maximum number of bytes allowed to be copied.
char *fmt is the format string. The function handles only %d and %s strings; it does not handle any width or precision strings.
... represents a sequence of parameters for the printf function.

See Also

util_sprintf() Function

The util_sprintf function formats a specified string, using a specified format, into a specified buffer, using the printf-style syntax without bounds checking. This function returns the number of characters in the formatted buffer.

Because util_sprintf does not perform bounds checking, use this function only if you are certain that the string fits the buffer. Otherwise, use the function util_snprintf. For more information, see the documentation on the printf function for the runtime library of your compiler.

Syntax Return Values Parameters Example
int util_sprintf(char *s, char *fmt, ...);

The number of characters formatted into the buffer. char *s is the buffer to receive the formatted string.
char *fmt is the format string. The function handles only %d and %s strings. The function does not handle any width or precision strings.
... represents a sequence of parameters for the printf function.
char *logmsg;
int len;
logmsg = (char *) MALLOC(256);
len = util_sprintf(logmsg, "%s %s %s\n", ip, method, uri);

See Also

util_strcasecmp() Function

The util_strcasecmp function performs a comparison of two alphanumeric strings and returns a -1, 0, or 1 to signal which string is larger or the strings are identical.

The comparison is not case sensitive.

Syntax Return Values Parameters
int util_strcasecmp(const char *s1, const char *s2);

1 if s1 is greater than s2.
0 if s1 is equal to s2.
-1 if s1 is less than s2.
char *s1 is the first string.
char *s2 is the second string.

See Also

util_strftime() Function

The util_strftime function translates a tm structure, which is a structure describing a system time, into a textual representation. util_strftime is a thread-safe version of the standard strftime function.

Syntax Return Values Parameters
int util_strftime(char *s, const char *format, const struct tm *t);

The number of characters placed into s, not counting the terminating NULL character. char *s is the string buffer to put the text into. This function does not perform bounds checking, so you must make sure that the buffer is large enough for the text of the date.
const char *format is a format string, similar to printf string in that it consists of text with certain %x substrings. You can use the constant HTTP_DATE_FMT to create date strings in the standard Internet format. For more information, see the documentation on the printf function for the runtime library of your compiler. For more information on time formats, see the Sun Java System Web Server Administrator's Configuration File Reference.
const struct tm *t is a pointer to a calendar time (tm) structure, usually created by the function system_localtime or system_gmtime.

See Also

util_strncasecmp() Function

The util_strncasecmp function performs a comparison of the first n characters in the alphanumeric strings and returns a -1, 0, or 1 to signal which string is larger or that the strings are identical.

The function’s comparison is not case-sensitive.

Syntax Return Values Parameters
int util_strncasecmp(const char *s1, const char *s2, int n);

1 if s1 is greater than s2.
0 if s1 is equal to s2.
-1 if s1 is less than s2.
char *s1 is the first string.
char *s2 is the second string.
int n is the number of initial characters to compare.

See Also

util_uri_escape() Function

The util_uri_escape function converts any special characters in the URI into the URI format. This format is %XX, where XX is the hexadecimal equivalent of the ASCII character. This function returns the escaped string. The special characters are %?#:+&*"<>, space, carriage return, and line feed.

Use util_uri_escape before sending a URI back to the client.

Syntax Return Values Parameters
char *util_uri_escape(char *d, char *s);

The string possibly newly allocated with escaped characters replaced. char *d is a string. If d is not NULL, the function copies the formatted string into d and returns it. If d is NULL, the function allocates a properly sized string and copies the formatted special characters into the new string, then returns it.
The util_uri_escape function does not check bounds for the parameter d. Therefore, if d is not NULL, it should be at least three times as large as the string s.
char *s is the string containing the original unescaped URI.

See Also

util_uri_is_evil() Function

The util_uri_is_evil function checks a specified URI for insecure path characters. Insecure path characters include //, /./, /../ and{{/.}}, /.. (also for Windows{{./}}) at the end of the URI. Use this function to see whether a URI requested by the client is insecure.

Syntax Return Values Parameters
int util_uri_is_evil(char *t);

1 if the URI is insecure, or 0 if the URI is secure. char *t is the URI to be checked.

See Also

util_uri_parse() Function

The util_uri_parse function converts //, /./, and /*/../ into / in the specified URI, where * is any character other than /. You can use this function to convert a URI’s bad sequences into valid ones. First, use the function util_uri_is_evil to determine whether the function has a bad sequence.

Syntax Return Values Parameters
void util_uri_parse(char *uri);

void char *uri is the URI to be converted.

See Also

util_uri_unescape() Function

The util_uri_unescape function converts the encoded characters of a URI into their ASCII equivalents. Encoded characters appear as %XX, where XX is a hexadecimal equivalent of the character.

Note -
You cannot use an embedded null in a string, because NSAPI functions assume that a null is the end of the string. Therefore, passing Unicode-encoded content through an NSAPI plug-in does not work.
Syntax Return Values Parameters
void util_uri_unescape(char *uri);

void char *uri is the URI to be converted.

See Also

util_vsnprintf() Function

The util_vsnprintf function formats a specified string, using a specified format, into a specified buffer using the vprintf-style syntax and performs bounds checking. This function returns the number of characters in the formatted buffer.

For more information, see the documentation on the printf function for the runtime library of your compiler.

Syntax Return Values Parameters
int util_vsnprintf(char *s, int n, register char *fmt, va_list args);

The number of characters formatted into the buffer. char *s is the buffer to receive the formatted string.
int n is the maximum number of bytes allowed to be copied.
register char *fmt is the format string. The function handles only %d and %s strings. This function does not handle any width or precision strings.
va_list args is an STD argument variable obtained from a previous call to va_start.

See Also

util_vsprintf() Function

The util_vsprintf function formats a specified string, using a specified format, into a specified buffer using the vprintf-style syntax without bounds checking. This function returns the number of characters in the formatted buffer.

For more information, see the documentation on the printf function for the runtime library of your compiler.

Syntax Return Values Parameters
int util_vsprintf(char *s, register char *fmt, va_list args);

The number of characters formatted into the buffer. char *s is the buffer to receive the formatted string.
register char *fmt is the format string. The function handles only %d and %s strings; it does not handle any width or precision strings.
va_list args is an STD argument variable obtained from a previous call to va_start.

See Also

Labels

java java Delete
server server Delete
sun sun Delete
webserver webserver Delete
application application Delete
system system Delete
webtier webtier Delete
guide guide Delete
webserver70 webserver70 Delete
sunjava sunjava Delete
nsapi nsapi Delete
nsapidevelopersguide nsapidevelopersguide Delete
developers developers Delete
web web Delete
+nsapiguide +nsapiguide Delete
nsapiguide nsapiguide Delete
developersguide developersguide Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact