Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sobj_ucx.c File Reference


Detailed Description

Functions for handling extended UNICODE strings (UCX strings).

The functions in this file handle extended UNICODE strings (UCX strings). UCX strings are strings containing variable refereces enclosed in ESC/ESC-ACK pairs. A literal ESC character is represented by ESC-ESC.

A variable referece is counted as a single character, so variable refereces may be addressed in index operations but not be broken apart.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "sobject_p.h"

Include dependency graph for sobj_ucx.c:

Include dependency graph

Functions

const char * sobj_ucx_match (const char *, const char *)
 Find the first matching grouping character.
size_t sobj_ucx_group_quote (const char *, const char *, char, char *, ptrdiff_t)
 Quote parentheses enclosed in a matching pair of grouping characters.
const char * sobj_ucx_next (const char *ucx)
 Skip to the next UTF-8 character or variable referece in an UCX.
const char * sobj_ucx_next_bounded (const char *ucx, const char *ucx_end)
 Skip to the next UTF-8 character or variable referece in an UCX.
const char * sobj_ucx_next_strict (const char *ucx)
 Skip to the next UTF-8 character or variable referece in an UCX.
size_t sobj_ucx_strlen (const char *ucx)
 Compute the length of an extended UNICODE string.
size_t sobj_ucx_strnlen (const char *ucx, ptrdiff_t buffer_size)
 Compute the length of an extended UNICODE string.
const char * sobj_ucx_string_index (const char *ucx, size_t index)
 Find the character or variable referece at the specified index.
size_t sobj_ucx_string_replace (const char *ucx, ptrdiff_t position, ptrdiff_t length, const char *replace, char *buffer)
 Replace a substring of an extended UNICODE string.
bool sobj_ucx_string_ok (const char *ucx, ptrdiff_t ucx_size)
 Check if a UCX string is valid.
size_t sobj_uc_to_ucx (const char *uc, ptrdiff_t uc_size, char *buffer)
 Convert an UTF-8 encoded UNICODE string to an UCX string.
size_t sobj_ucx_vref_quote (const char *ucx, bool embedded, char *buffer, ptrdiff_t buffer_length)
 Quote a variable referece in an extended string.
size_t sobj_ucx_string_quote (const char *ucx, char *buffer, ptrdiff_t buffer_size)
 Create a quoted string representation of an extended UNICODE string.
size_t sobj_ucx_vref_resolve (const char *ucx, struct sobj_env *env, struct sobj_buffer *buffer)
 Resolve a variable referece in an extended UNICODE string.
size_t sobj_ucx_string_resolve (const char *ucx, struct sobj_env *env, struct sobj_buffer *buffer)
 Resolve all variable refereces in an extended UNICODE string.

Variables

const char ASCII_ESC = 0x1b
 The ASCII ESC character.
const char ASCII_STX = 0x2
 The ASCII STX character.
const char ASCII_ETX = 0x3
 The ASCII ETX character.

Function Documentation

size_t sobj_ucx_group_quote const char *  ucx,
const char *  ucx_end,
char  end_group,
char *  buffer,
ptrdiff_t  buffer_length
[static]
 

Quote parentheses enclosed in a matching pair of grouping characters.

The function quotes a part of a variable referece enclosed in a matching pair of grouping characters. Grouping characters that match are not quoted.

Parameters:
ucx The beginning of the part of the variable referece.
ucx_end The end of the part of the variable referece.
end_group The end grouping character. Occurances of the end grouping character are quoted using a single backslash character.
buffer Pointer to the buffer receiving the quoted part of the variable referece. If this is a null-pointer, no output is generated.
buffer_length The length of the buffer.
Returns:
The function returns the number of characters in the quoted string, not counting the terminating null-character.

const char * sobj_ucx_match const char *  ucx,
const char *  ucx_end
[static]
 

Find the first matching grouping character.

The function scans the string for the first matching grouping character.

Parameters:
ucx The extended UNICODE string to be scanned. The string must either point to the end of the string or start with an opening grouping character match.
ucx_end The end of the extended UNICODE string.
Returns:
If a matching grouping character is found, the function returns a pointer to the character following the match. If no matching grouping character is found, a null-pointer is returned.

size_t sobj_ucx_vref_quote const char *  ucx,
bool  embedded,
char *  buffer,
ptrdiff_t  buffer_length
 

Quote a variable referece in an extended string.

The function quotes a variable referece in an extended string.

Parameters:
ucx The extended UNICODE string vref.
embedded Flag indicating if the vref is embedded within an extended string. If embedded is true, ucx points to the ESC-STX sequences introducing the embedded vref. If embedded is false, ucx points to the first character of the referece string.
buffer The buffer receiving the quoted variable referece, including a terminating null-byte. If this is a null-pointer, no output is generated.
buffer_length The size of the specified buffer. If this is 0 or negative, no output is generated.
Returns:
The function returns the number of bytes requires to store the quoted variable referece, not counting the terminating null-byte.

size_t sobj_ucx_vref_resolve const char *  ucx,
struct sobj_env env,
struct sobj_buffer buffer
 

Resolve a variable referece in an extended UNICODE string.

The function recursively resolves a variable referece in an extended UNICODE string.

Parameters:
ucx Pointer to the first character of a variable referece.
env The environment. This may be a null-pointer.
buffer The buffer receiving the resolved string, not including a terminating null-byte. The resolved string is appended to the buffer.
Returns:
The function returns the number of bytes of the resolved variable referece.
Note:
The string created will not be null-terminated.


Variable Documentation

const char ASCII_ESC = 0x1b
 

The ASCII ESC character.

const char ASCII_ETX = 0x3
 

The ASCII ETX character.

const char ASCII_STX = 0x2
 

The ASCII STX character.


Generated on Sat Jul 23 16:05:45 2005 for sobject by  doxygen 1.3.9.1