#include "nsd.h"Data Structures | |
| struct | keylEntry_t |
| struct | keylIntObj_t |
Defines | |
| #define | TclX_Assert(expr) |
| #define | TRUE 1 |
| #define | FALSE 0 |
| #define | ckstrdup(a) (strcpy(ckalloc((size_t)(strlen((a))+1)),(a))) |
| #define | ckbinstrdup(a, b) ((char*)memcpy(ckalloc((size_t)((b)+1)),(a),(size_t)((b)+1))) |
| #define | KEYEDLIST_ARRAY_INCR_SIZE 16 |
| #define | DupSharedKeyListChild(keylIntPtr, idx) |
| #define | KEYL_REP_ASSERT(keylAIntPtr) |
| #define | UPDATE_STATIC_SIZE 32 |
Functions | |
| void | NsTclInitKeylistType (void) |
| int | TclX_WrongArgs (Tcl_Interp *interp, Tcl_Obj *commandNameObj, char *string) |
| void TclX_AppendObjResult | TCL_VARARGS_DEF (Tcl_Interp *, arg1) |
| int | TclX_IsNullObj (Tcl_Obj *objPtr) |
| int | Tcl_GetKeyedListKeys (Tcl_Interp *interp, CONST char *subFieldName, CONST char *keyedList, int *keyesArgcPtr, char ***keyesArgvPtr) |
| int | Tcl_GetKeyedListField (Tcl_Interp *interp, CONST char *fieldName, CONST char *keyedList, char **fieldValuePtr) |
| char * | Tcl_SetKeyedListField (Tcl_Interp *interp, CONST char *fieldName, CONST char *fieldValue, CONST char *keyedList) |
| char * | Tcl_DeleteKeyedListField (Tcl_Interp *interp, CONST char *fieldName, CONST char *keyedList) |
| int TclX_KeylgetObjCmd | _ANSI_ARGS_ ((ClientDataclientData, Tcl_Interp *interp, intobjc, Tcl_Obj *CONST objv[])) |
| Tcl_Obj * | TclX_NewKeyedListObj () |
| int | TclX_KeyedListGet (Tcl_Interp *interp, Tcl_Obj *keylPtr, char *key, Tcl_Obj **valuePtrPtr) |
| int | TclX_KeyedListSet (Tcl_Interp *interp, Tcl_Obj *keylPtr, char *key, Tcl_Obj *valuePtr) |
| int | TclX_KeyedListDelete (Tcl_Interp *interp, Tcl_Obj *keylPtr, char *key) |
| int | TclX_KeyedListGetKeys (Tcl_Interp *interp, Tcl_Obj *keylPtr, char *key, Tcl_Obj **listObjPtrPtr) |
| int | TclX_KeylgetObjCmd (ClientData clientData, Tcl_Interp *interp, int objc, objv) |
| int | TclX_KeylsetObjCmd (ClientData clientData, Tcl_Interp *interp, int objc, objv) |
| int | TclX_KeyldelObjCmd (ClientData clientData, Tcl_Interp *interp, int objc, objv) |
| int | TclX_KeylkeysObjCmd (ClientData clientData, Tcl_Interp *interp, int objc, objv) |
| void | TclX_KeyedListInit (Tcl_Interp *interp) |
Variables | |
| char * | tclXWrongArgs = "wrong # args: " |
| #define ckbinstrdup | ( | a, | |||
| b | ) | ((char*)memcpy(ckalloc((size_t)((b)+1)),(a),(size_t)((b)+1))) |
| #define ckstrdup | ( | a | ) | (strcpy(ckalloc((size_t)(strlen((a))+1)),(a))) |
Macro that behaves like strdup, only uses ckalloc. Also macro that does the same with a string that might contain zero bytes,
| #define DupSharedKeyListChild | ( | keylIntPtr, | |||
| idx | ) |
Value:
if (Tcl_IsShared (keylIntPtr->entries [idx].valuePtr)) { \
keylIntPtr->entries [idx].valuePtr = \
Tcl_DuplicateObj (keylIntPtr->entries [idx].valuePtr); \
Tcl_IncrRefCount (keylIntPtr->entries [idx].valuePtr); \
}
| #define FALSE 0 |
| #define KEYEDLIST_ARRAY_INCR_SIZE 16 |
Amount to increment array size by when it needs to grow.
| #define KEYL_REP_ASSERT | ( | keylAIntPtr | ) |
Macros to validate an keyed list object or internal representation
| #define TclX_Assert | ( | expr | ) |
Assert macro for use in TclX. Some GCCs libraries are missing a function used by their macro, so we define out own.
| #define TRUE 1 |
| #define UPDATE_STATIC_SIZE 32 |
| int TclX_KeylkeysObjCmd _ANSI_ARGS_ | ( | (ClientDataclientData, Tcl_Interp *interp, intobjc, Tcl_Obj *CONST objv[]) | ) |
| void NsTclInitKeylistType | ( | void | ) |
This is called once from InitInterp() call in tclinit.c for first-time initialization of special Tcl objects.
| char* Tcl_DeleteKeyedListField | ( | Tcl_Interp * | interp, | |
| CONST char * | fieldName, | |||
| CONST char * | keyedList | |||
| ) |
----------------------------------------------------------------------------
Parameters: o interp (I/O) - Error message will be return in result if there is an error. o fieldName (I) - The name of the field to extract. Will recusively process sub-field names seperated by `.'. o fieldValue (I) - The value to set for the field. o keyedList (I) - The keyed list to delete the field from. Returns: A pointer to a dynamically allocated string containing the new list, or NULL if an error occured. --------------------------------------------------------------------------- --
| int Tcl_GetKeyedListField | ( | Tcl_Interp * | interp, | |
| CONST char * | fieldName, | |||
| CONST char * | keyedList, | |||
| char ** | fieldValuePtr | |||
| ) |
----------------------------------------------------------------------------
Parameters: o interp (I/O) - Error message will be return in result if there is an error. o fieldName (I) - The name of the field to extract. Will recusively process sub-field names seperated by `.'. o keyedList (I) - The list to search for the field. o fieldValuePtr (O) - If the field is found, a pointer to a dynamicly allocated string containing the value is returned here. If NULL is specified, then only the presence of the field is validated, the value is not returned. Returns: TCL_OK - If the field was found. TCL_BREAK - If the field was not found. TCL_ERROR - If an error occured. --------------------------------------------------------------------------- --
| int Tcl_GetKeyedListKeys | ( | Tcl_Interp * | interp, | |
| CONST char * | subFieldName, | |||
| CONST char * | keyedList, | |||
| int * | keyesArgcPtr, | |||
| char *** | keyesArgvPtr | |||
| ) |
----------------------------------------------------------------------------
Parameters: o interp (I/O) - Error message will be return in result if there is an error. o subFieldName (I) - If "" or NULL, then the keys are retreved for the top level of the list. If specified, it is name of the field who's subfield keys are to be retrieve. o keyedList (I) - The list to search for the field. o keyesArgcPtr (O) - The number of keys in the keyed list is returned here. o keyesArgvPtr (O) - An argv containing the key names. It is dynamically allocated, containing both the array and the strings. A single call to ckfree will release it. Returns: TCL_OK - If the field was found. TCL_BREAK - If the field was not found. TCL_ERROR - If an error occured. ---------------------------------------------------------------------------
| char* Tcl_SetKeyedListField | ( | Tcl_Interp * | interp, | |
| CONST char * | fieldName, | |||
| CONST char * | fieldValue, | |||
| CONST char * | keyedList | |||
| ) |
----------------------------------------------------------------------------
Parameters: o interp (I/O) - Error message will be return in result if there is an error. o fieldName (I) - The name of the field to extract. Will recusively process sub-field names seperated by `.'. o fieldValue (I) - The value to set for the field. o keyedList (I) - The keyed list to set a field value in, may be an NULL or an empty list to create a new keyed list. Returns: A pointer to a dynamically allocated string, or NULL if an error occured. --------------------------------------------------------------------------- --
| void TclX_AppendObjResult TCL_VARARGS_DEF | ( | Tcl_Interp * | , | |
| arg1 | ||||
| ) |
----------------------------------------------------------------------------- TclX_AppendObjResult --
Append a variable number of strings onto the object result already present for an interpreter. If the object is shared, the current contents are discarded.
Parameters: o interp - Interpreter to set the result in. o args - Strings to append, terminated by a NULL. -----------------------------------------------------------------------------
| int TclX_IsNullObj | ( | Tcl_Obj * | objPtr | ) |
----------------------------------------------------------------------------- TclX_IsNullObj --
Check if an object is {}, either in list or zero-lemngth string form, with out forcing a conversion.
Parameters: o objPtr - Object to check. Returns: True if NULL, FALSE if not. -----------------------------------------------------------------------------
| int TclX_KeyedListDelete | ( | Tcl_Interp * | interp, | |
| Tcl_Obj * | keylPtr, | |||
| char * | key | |||
| ) |
----------------------------------------------------------------------------- TclX_KeyedListDelete -- Delete a key value from keyed list.
Parameters: o interp - Error message will be return in result if there is an error. o keylPtr - Keyed list object to update. o key - The name of the key to extract. Will recusively process sub-key seperated by `.'. Returns: o TCL_OK - If the key was deleted. o TCL_BREAK - If the key was not found. o TCL_ERROR - If an error occured. -----------------------------------------------------------------------------
If not found, return status.
If we are at the last subkey, delete the entry.
If we are not at the last subkey, recurse down. If the entry is deleted and the sub-keyed list is empty, delete it as well. Must invalidate string, as it caches all representations below it.
| int TclX_KeyedListGet | ( | Tcl_Interp * | interp, | |
| Tcl_Obj * | keylPtr, | |||
| char * | key, | |||
| Tcl_Obj ** | valuePtrPtr | |||
| ) |
----------------------------------------------------------------------------- TclX_KeyedListGet -- Retrieve a key value from a keyed list.
Parameters: o interp - Error message will be return in result if there is an error. o keylPtr - Keyed list object to get key from. o key - The name of the key to extract. Will recusively process sub-keys seperated by `.'. o valueObjPtrPtr - If the key is found, a pointer to the key object is returned here. NULL is returned if the key is not present. Returns: o TCL_OK - If the key value was returned. o TCL_BREAK - If the key was not found. o TCL_ERROR - If an error occured. -----------------------------------------------------------------------------
If not found, return status.
If we are at the last subkey, return the entry, otherwise recurse down looking for the entry.
| int TclX_KeyedListGetKeys | ( | Tcl_Interp * | interp, | |
| Tcl_Obj * | keylPtr, | |||
| char * | key, | |||
| Tcl_Obj ** | listObjPtrPtr | |||
| ) |
----------------------------------------------------------------------------- TclX_KeyedListGetKeys -- Retrieve a list of keyed list keys.
Parameters: o interp - Error message will be return in result if there is an error. o keylPtr - Keyed list object to get key from. o key - The name of the key to get the sub keys for. NULL or empty to retrieve all top level keys. o listObjPtrPtr - List object is returned here with key as values. Returns: o TCL_OK - If the zero or more key where returned. o TCL_BREAK - If the key was not found. o TCL_ERROR - If an error occured. -----------------------------------------------------------------------------
If key is not NULL or empty, then recurse down until we go past the end of all of the elements of the key.
Reached the end of the full key, return all keys at this level.
| void TclX_KeyedListInit | ( | Tcl_Interp * | interp | ) |
----------------------------------------------------------------------------- TclX_KeyedListInit -- Initialize the keyed list commands for this interpreter.
Parameters: o interp - Interpreter to add commands to. -----------------------------------------------------------------------------
| int TclX_KeyedListSet | ( | Tcl_Interp * | interp, | |
| Tcl_Obj * | keylPtr, | |||
| char * | key, | |||
| Tcl_Obj * | valuePtr | |||
| ) |
----------------------------------------------------------------------------- TclX_KeyedListSet -- Set a key value in keyed list object.
Parameters: o interp - Error message will be return in result object. o keylPtr - Keyed list object to update. o key - The name of the key to extract. Will recusively process sub-key seperated by `.'. o valueObjPtr - The value to set for the key. Returns: TCL_OK or TCL_ERROR. -----------------------------------------------------------------------------
If we are at the last subkey, either update or add an entry.
If we are not at the last subkey, recurse down, creating new entries if neccessary. If this level key was not found, it means we must build new subtree. Don't insert the new tree until we come back without error.
| int TclX_KeyldelObjCmd | ( | ClientData | clientData, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
----------------------------------------------------------------------------- Tcl_KeyldelObjCmd -- Implements the TCL keyldel command: keyldel listvar key ?key ...? ----------------------------------------------------------------------------
Get the variable that we are going to update. If it is shared by more than being a variable, duplicated it.
| int TclX_KeylgetObjCmd | ( | ClientData | clientData, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
----------------------------------------------------------------------------- Tcl_KeylgetObjCmd -- Implements the TCL keylget command: keylget listvar ?key? ?retvar | {}? -----------------------------------------------------------------------------
Handle request for list of keys, use keylkeys command.
Handle retrieving a value for a specified key.
Handle key not found.
No variable specified, so return value in the result.
Variable (or empty variable name) specified.
| int TclX_KeylkeysObjCmd | ( | ClientData | clientData, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
----------------------------------------------------------------------------- Tcl_KeylkeysObjCmd -- Implements the TCL keylkeys command: keylkeys listvar ?key? -----------------------------------------------------------------------------
If key argument is not specified, then objv [2] is NULL or empty, meaning get top level keys.
| int TclX_KeylsetObjCmd | ( | ClientData | clientData, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
----------------------------------------------------------------------------- Tcl_KeylsetObjCmd -- Implements the TCL keylset command: keylset listvar key value ?key value...? -----------------------------------------------------------------------------
Get the variable that we are going to update. If the var doesn't exist, create it. If it is shared by more than being a variable, duplicated it.
| Tcl_Obj* TclX_NewKeyedListObj | ( | ) |
----------------------------------------------------------------------------- TclX_NewKeyedListObj -- Create and initialize a new keyed list object.
Returns: A pointer to the object. -----------------------------------------------------------------------------
| int TclX_WrongArgs | ( | Tcl_Interp * | interp, | |
| Tcl_Obj * | commandNameObj, | |||
| char * | string | |||
| ) |
----------------------------------------------------------------------------- TclX_WrongArgs --
Easily create "wrong # args" error messages.
Parameters: o commandNameObj - Object containing name of command (objv[0]) o string - Text message to append. Returns: TCL_ERROR -----------------------------------------------------------------------------
| char* tclXWrongArgs = "wrong # args: " |
Used to return argument messages by most commands.
1.5.1