/home/gigerk/eth/sa2/libxpsh-0.0.1/libxpsh/xpsh.c File Reference

#include "xpsh.h"

Functions

SXP_NodeType getNodeType_i (SXP_Node node)
 returns the node type
const SXP_char * getNodeName_i (SXP_Node node)
 returns the name of the node
const SXP_char * getNodeNameURI_i (SXP_Node node)
 returns the namespace URI of the node
const SXP_char * getNodeNameLocal_i (SXP_Node node)
 return the local part of the node name
const SXP_char * getNodeValue_i (SXP_Node node)
 returns the node value
SXP_Node getNextSibling_i (SXP_Node node)
 returns the next sibling of the node
SXP_Node getPreviousSibling_i (SXP_Node node)
 returns the previous sibling of the node
int getChildCount_i (SXP_Node node)
 counts the children of a node
int getAttributeCount_i (SXP_Node node)
 counts the attributes of a node
int getNamespaceCount_i (SXP_Node node)
 returns the number of namespace declarations belonging to this node
SXP_Node getNamespaceNo_i (SXP_Node node, int n)
 returns the namespace node with a given index
SXP_Node getParent_i (SXP_Node node)
 returns the parent of the context node
SXP_Document getOwnerDocument_i (SXP_Node node)
 returns the owner document of the given node
int compareNodes_i (SXP_Node node1, SXP_Node node2)
 compares two nodes
char * pathname (SXP_Node node)
 generates the absolute path of the node
void append_path (char *ret, node_xpsh *node)
 appends the name of the actual node-name to a given string
SXP_Node genParents (const char *path)
 generate the ancestor nodes up to the root node
node_type getDirentType (struct dirent *dir, char *pn)
 returns the FSX-nodetype of a file or dirent-structure
node_xpshcreateNewNode (node_xpsh *parent, node_type t, char *name, char *value, node_xpsh *prev, node_xpsh *child)
 allocates memory for a new node and sets initial values
char * getMimeType (node_xpsh *node, char dest[])
 returns the MIME type of a node (i.e. file)
void loadMimeTypes (void)
 loads the MIME types in the configuration file in an internal array
void clearLastpn (void)
 clears the pn history
void declareNamespaces (QueryContext Q)
 declare the internal namespaces in SXP
void xpsh_clear (void)
 cleans up the library
void xpsh_clear_mime (mime_type *mt)
 cleans up the mime_type linked-list
void xpsh_clear_internal (node_xpsh *node)
 cleans up a node and recursively clean up all nodes with parent=this node
FILE * openConfigFile (void)
 opens the XPsh-configuration file

Detailed Description

Author:
Kaspar Giger
Date:
04-2006

Function Documentation

void append_path char *  ret,
node_xpsh node
 

before that, the same function is called recursively for its parent.

Parameters:
[in,out] ret the destination string
node the node for which the pathname should be generated

void clearLastpn void   ) 
 

should only used if the library is compiled with WITH_PN_HISTORY but doesn't hurt anyone

int compareNodes_i SXP_Node  node1,
SXP_Node  node2
 

Parameters:
node1 the first node
node2 the second node
Returns:
-1 if node1<node2, +1 if node1>node2, 0 if they are identical

node_xpsh* createNewNode node_xpsh parent,
node_type  t,
char *  name,
char *  value,
node_xpsh prev,
node_xpsh child
 

Parameters:
parent the parent node
t the node type
name the name of the node
value the value of the node
prev the previous Sibling (if there is one)
child the first Child (if there is one)
Returns:
the new node

void declareNamespaces QueryContext  Q  ) 
 

the namespace that are defined by Shell environment variables and those defined in the adaptors.

Parameters:
Q the SXP QueryContext

SXP_Node genParents const char *  path  ) 
 

(including all its children, for speed reasons)

Parameters:
path the path to the node
Returns:
the node (the context node)

int getAttributeCount_i SXP_Node  node  ) 
 

if the node is not an element 0 is returned.

Parameters:
node the context node
Returns:
the number of attributes of the context node

int getChildCount_i SXP_Node  node  ) 
 

if the node is neither an element nor a document node, 0 should be returned.

Parameters:
node the context node
Returns:
the number of children of the context node

node_type getDirentType struct dirent *  dir,
char *  pn
 

because the dirent-structure hasn't the complete information on all operating systems the type could also be extracted out of the path to a file.

Parameters:
dir a dirent structure pointing to the file
pn the absolute path to the file
Returns:
the FSX-nodetype

char* getMimeType node_xpsh node,
char  dest[]
 

the MIME type is built out of the filename-ending. This mapping is defined in the configuration file in lines starting with MIME. The MIE-type of a directory is 'application/directory', of a symlink 'application/symlink'.

Parameters:
node the (file) node
[out] dest the destination array where to copy the MIME type in
Returns:
the MIME type (e.g. as defined by IANA)

int getNamespaceCount_i SXP_Node  node  ) 
 

Remarks:
not used for the current project, so no functionality
Parameters:
node the node
Returns:
the number of namespaces

SXP_Node getNamespaceNo_i SXP_Node  node,
int  n
 

if the index is out of bounds, NULL is returned.

Remarks:
not used in the current project
Parameters:
node the node
n the index of the namespace-node
Returns:
the namespace-node

SXP_Node getNextSibling_i SXP_Node  node  ) 
 

Parameters:
node the node
Returns:
the next sibling

const SXP_char* getNodeName_i SXP_Node  node  ) 
 

Remarks:
never called in SXP and therefore not proper implemented

const SXP_char* getNodeNameLocal_i SXP_Node  node  ) 
 

as defined by DOM Level 2 core specification, with the namespace addition SXP defines.

Parameters:
node the node
Returns:
the local part of the node name

const SXP_char* getNodeNameURI_i SXP_Node  node  ) 
 

if the node has an explicit namespace node, its URI is returned, otherwise the fsx-URI (http://fsx.org/fsx) is returned.

Parameters:
node the node
Returns:
the namespace URI of the node

SXP_NodeType getNodeType_i SXP_Node  node  ) 
 

as defined by enum SXP_NodeType. The root node of the FSX-tree is of type DOCUMENT_NODE, attribute nodes (fsx_ATTRIBUTE) of type ATTRIBUTE_NODE, namespace nodes (fsx_NS) of type NAMESPACE_NODE, text nodes (fsx_TEXT) of type TEXT_NODE. All other nodes are element nodes (ELEMENT_NODE).

Parameters:
node the node
Returns:
the node type of the node (defined as enum SXP_NodeType)

const SXP_char* getNodeValue_i SXP_Node  node  ) 
 

as defined by DOM Level 1 core specification, with the namespace addition SXP defines.

Parameters:
node the node
Returns:
the node value

SXP_Document getOwnerDocument_i SXP_Node  node  ) 
 

in other words: the root node

Parameters:
node the node
Returns:
the owner document

SXP_Node getParent_i SXP_Node  node  ) 
 

because the parent ancestor-axis is created at the start, all parents are expanded and linked in the tree. so nothing has to be generated here. But the node could have no parent (for example if it's the root node).

Parameters:
node the context node
Returns:
the parent node

SXP_Node getPreviousSibling_i SXP_Node  node  ) 
 

Parameters:
node the node
Returns:
the previous sibling of the node

void loadMimeTypes void   ) 
 

all lines in the configuration file starting with MIME contain a mapping of an extension to a MIME type. Each one is stored in a mime_type entry, as part of a linked list.

FILE* openConfigFile void   ) 
 

it is located either in the home-directory of the user with the filename .xpsh or globally in the /etc directory with filename xpsh

Returns:
the FILE-pointer to the configuration file

char* pathname SXP_Node  node  ) 
 

don't forget to free the memory of the returned string!

Parameters:
node the node
Returns:
the path to the node (no trailing slash)

void xpsh_clear_internal node_xpsh node  ) 
 

Parameters:
node the node

void xpsh_clear_mime mime_type mt  ) 
 

Parameters:
mt an element of the linked-list


Generated on Mon Apr 17 18:39:46 2006 for Libxpsh by  doxygen 1.4.6