本文整理汇总了C++中xmlStrlen函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlStrlen函数的具体用法?C++ xmlStrlen怎么用?C++ xmlStrlen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlStrlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trim_whitespace
static inline xmlChar* trim_whitespace(xmlChar* str)
{
xmlChar* ret = str;
int len;
if (!str)
return NULL;
while (*ret && isspace(*ret))
++ret;
len = xmlStrlen(ret);
if (len)
while (isspace(ret[len-1])) --len;
ret = xmlStrndup(ret, len);
xmlFree(str);
return ret;
}
示例2: xml_cdpUTF8ToStr
static char * xml_cdpUTF8ToStr( xmlChar * szStr, HB_SIZE * pnLen, const char * pszCdpOut )
{
PHB_CODEPAGE cdpIn = hb_cdpFindExt( XML_UTF8_HB_CDP );
PHB_CODEPAGE cdpOut = pszCdpOut ? hb_cdpFindExt( pszCdpOut ) : hb_vmCDP();
char * szDest = NULL;
if( cdpIn && cdpOut && szStr )
{
int len = xmlStrlen( szStr );
memcpy( pnLen, &len, sizeof( len ) );
szDest = hb_cdpnDup( ( const char * ) szStr, pnLen, cdpIn, cdpOut );
}
return szDest;
}
示例3: get_children
/**
* \brief Get the node's children node with given name.
* @param[in] node Search in the children nodes of this node.
* @param[in] children_name Name of the requested children node.
* @return Pointer to the children node with requested name. It should not be
* freed since it is children of given node.
*/
static inline xmlNodePtr get_children(xmlNodePtr node, const xmlChar* children_name)
{
/* check validity of parameters */
if (!node || !children_name) {
return (NULL);
}
xmlNodePtr children = node->children;
while (children) {
if (!xmlStrncmp(children->name, children_name, xmlStrlen(children_name) + 1)) {
return (children);
}
children = children->next;
}
return (children);
}
示例4: domcomment_substringData
static HRESULT WINAPI domcomment_substringData(
IXMLDOMComment *iface,
long offset, long count, BSTR *p)
{
domcomment *This = impl_from_IXMLDOMComment( iface );
xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node );
xmlChar *pContent;
long nLength = 0;
HRESULT hr = S_FALSE;
TRACE("%p\n", iface);
if(!p)
return E_INVALIDARG;
*p = NULL;
if(offset < 0 || count < 0)
return E_INVALIDARG;
if(count == 0)
return hr;
pContent = xmlNodeGetContent(pDOMNode->node);
if(pContent)
{
nLength = xmlStrlen(pContent);
if( offset < nLength)
{
BSTR sContent = bstr_from_xmlChar(pContent);
if(offset + count > nLength)
*p = SysAllocString(&sContent[offset]);
else
*p = SysAllocStringLen(&sContent[offset], count);
SysFreeString(sContent);
hr = S_OK;
}
xmlFree(pContent);
}
return hr;
}
示例5: exsltStrPaddingFunction
/**
* exsltStrPaddingFunction:
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
* Creates a padding string of a certain length.
*/
static void
exsltStrPaddingFunction (xmlXPathParserContextPtr ctxt, int nargs) {
int number, str_len = 0, str_size = 0;
xmlChar *str = NULL, *ret = NULL;
if ((nargs < 1) || (nargs > 2)) {
xmlXPathSetArityError(ctxt);
return;
}
if (nargs == 2) {
str = xmlXPathPopString(ctxt);
str_len = xmlUTF8Strlen(str);
str_size = xmlStrlen(str);
}
if (str_len == 0) {
if (str != NULL) xmlFree(str);
str = xmlStrdup((const xmlChar *) " ");
str_len = 1;
str_size = 1;
}
number = (int) xmlXPathPopNumber(ctxt);
if (number <= 0) {
xmlXPathReturnEmptyString(ctxt);
xmlFree(str);
return;
}
while (number >= str_len) {
ret = xmlStrncat(ret, str, str_size);
number -= str_len;
}
if (number > 0) {
str_size = xmlUTF8Strsize(str, number);
ret = xmlStrncat(ret, str, str_size);
}
xmlXPathReturnString(ctxt, ret);
if (str != NULL)
xmlFree(str);
}
示例6: return
/**
* soap_walk_tree
* @node: pointer to an XML subtree
* @colonstring: node name strings that are being searched; for example, to
* search for nodes "a", then "b", then "c", pass "a:b:c"
*
* Searches an XML subtree, looking for a named node. Very similar to
* soap_find_node() above, but uses an entirely different algorithm, both for
* efficiency and to make response parsing more pedantic.
*
* The passed colonstring is a list of tree node names separated by ':'. At
* each level of the tree, the corresponding name must match. This means that
* the whole XML tree doesn't need to be searched, and that you know you've
* found the right node, not one that is similarly-named but is in a different
* part of the XML tree.
*
* Return value: the XML node, if found, or NULL.
**/
xmlNode *soap_walk_tree(xmlNode *node, char *colonstring)
{
char *next;
char *c;
int len; /* Length of node name string */
if ((! node) ||
(! colonstring) ||
(! *colonstring) ||
(*colonstring == ':')) {
return(NULL);
}
/* Break string at ':' */
c = strchr(colonstring, ':');
if (c) {
len = c - colonstring;
next = c + 1;
}
else {
len = strlen(colonstring);
next = colonstring + len;
}
/* Look for this in the node tree's children */
node = node->children;
while (node) {
if ((! xmlStrncmp(node->name,
(const xmlChar *)colonstring,
len)) &&
(xmlStrlen(node->name) == len)) {
if (*next) {
return(soap_walk_tree(node, next));
}
else {
/* Done searching */
return(node);
}
}
node = node->next;
}
return(NULL);
}
示例7: xmlBufAddHead
/**
* xmlBufAddHead:
* @buf: the buffer
* @str: the #xmlChar string
* @len: the number of #xmlChar to add
*
* Add a string range to the beginning of an XML buffer.
* if len == -1, the length of @str is recomputed.
*
* Returns 0 successful, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) {
unsigned int needSize;
if ((buf == NULL) || (buf->error))
return(-1);
CHECK_COMPAT(buf)
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
if (str == NULL) {
#ifdef DEBUG_BUFFER
xmlGenericError(xmlGenericErrorContext,
"xmlBufAddHead: str == NULL\n");
#endif
return -1;
}
if (len < -1) {
#ifdef DEBUG_BUFFER
xmlGenericError(xmlGenericErrorContext,
"xmlBufAddHead: len < 0\n");
#endif
return -1;
}
if (len == 0) return 0;
if (len < 0)
len = xmlStrlen(str);
if (len <= 0) return -1;
if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
size_t start_buf = buf->content - buf->contentIO;
if (start_buf > (unsigned int) len) {
/*
* We can add it in the space previously shrinked
*/
buf->content -= len;
memmove(&buf->content[0], str, len);
buf->use += len;
buf->size += len;
UPDATE_COMPAT(buf)
return(0);
}
示例8: dt_hash
static DWORD dt_hash(xmlChar const* str, int len /* calculated if -1 */)
{
DWORD hval = (len == -1)? xmlStrlen(str) : len;
switch (hval)
{
default:
hval += hash_assoc_values[str[10]];
/*FALLTHROUGH*/
case 10:
hval += hash_assoc_values[str[9]];
/*FALLTHROUGH*/
case 9:
hval += hash_assoc_values[str[8]];
/*FALLTHROUGH*/
case 8:
hval += hash_assoc_values[str[7]];
/*FALLTHROUGH*/
case 7:
hval += hash_assoc_values[str[6]];
/*FALLTHROUGH*/
case 6:
hval += hash_assoc_values[str[5]];
/*FALLTHROUGH*/
case 5:
hval += hash_assoc_values[str[4]];
/*FALLTHROUGH*/
case 4:
hval += hash_assoc_values[str[3]];
/*FALLTHROUGH*/
case 3:
hval += hash_assoc_values[str[2]];
/*FALLTHROUGH*/
case 2:
hval += hash_assoc_values[str[1]];
/*FALLTHROUGH*/
case 1:
hval += hash_assoc_values[str[0]];
break;
}
return hval;
}
示例9: walk_doc_tree
/*
* There are functions to get stuff out of node - such as xmlGetProp(node, xmlChar *name),
* xmlNodeGetContent(), xmlGetNodePath(),
*/
void
walk_doc_tree(xmlNodePtr node, int level)
{
xmlChar* empty = (xmlChar*)"";
xmlChar* prefix = empty;
if (node->ns) {
size_t len = (xmlStrlen(node->ns->href) * sizeof(xmlChar)) + 3;
prefix = xmlMalloc(len);
snprintf((char*)prefix, len, "{%s}", node->ns->href);
}
if (node->type == XML_ELEMENT_NODE) {
xmlNodePtr att = (xmlNodePtr) node->properties; /* similar casts in e.g. xmlschemas.c */
const xmlChar* closeMe = node->name;
printf("<%s%s", prefix, closeMe);
while (att != NULL) {
walk_doc_tree(att, level + 1);
att = att->next;
}
printf(">");
node = node->children;
while (node != NULL) {
walk_doc_tree(node, level + 1);
node = node->next;
}
if (closeMe != NULL)
printf("</%s%s>", prefix, closeMe);
} else if (node->type == XML_ATTRIBUTE_NODE) {
printf(" %s%s=\"%s\"", prefix, node->name, xmlNodeGetContent(node)); /* xmlNodeListGetString ? */
} else if (node->type == XML_TEXT_NODE) {
printf("%s", xmlNodeGetContent(node));
} else
printf("node %p type: %-20s node name: %s%-20s\n",
(void *)node, type_names[node->type], prefix, node->name);
if (prefix != empty)
xmlFree(prefix);
if (level == 0)
printf("\n");
}
示例10: find_element
xmlDocPtr find_element(xmlDocPtr xml_document_pointer, char* element_name)
{
if(NULL != xml_document_pointer &&
NULL != element_name)
{
while(true)
{
if(NULL == xml_document_pointer)
{
break;
}
if(0 == xmlStrncmp(xml_document_pointer->name, element_name, xmlStrlen(element_name)))
{
return (xmlDocPtr)xml_document_pointer;
}
xml_document_pointer = (xmlDocPtr)xml_document_pointer->next;
}
}
return NULL;
}
示例11: xmlStrstr
const xmlChar *
xmlStrstr(const xmlChar *str, const xmlChar *val)
{
int n;
if (str == NULL) return(NULL);
if (val == NULL) return(NULL);
n = xmlStrlen(val);
if (n == 0) return(str);
while (*str != 0)
{ /* non input consuming */
if (*str == *val)
{
if (!xmlStrncmp(str, val, n)) return((const xmlChar *) str);
}
str++;
}
return(NULL);
}
示例12: web_child
void
web_child(int sockfd)
{
ssize_t n;
char tcp_recv_buff[MAXLINE];
xmlChar * tcp_send_buff;
memset(tcp_recv_buff,0,MAXLINE);
if( (n=read(sockfd,tcp_recv_buff,MAXLINE))>0)
{
//tcp_recv_buff[n]='\0';
//printf("pthread %d recv:\n%s\n",(int)pthread_self(),tcp_recv_buff);
tcp_send_buff=process_request(tcp_recv_buff);
Writen(sockfd,(char *)tcp_send_buff,xmlStrlen(tcp_send_buff));
//printf("pthread %d send:\n%s\n",(int)pthread_self(),tcp_send_buff);
xmlFree(tcp_send_buff);
}
else if(n<0)
err_sys("read erro");
}
示例13: LocateTo
const char *ermXmlGetAttributeStringBuffer(const erManifest *pCtx, const char *express, const char *attrName, int *length)
{
*length = 0;
xmlXPathObjectPtr xpathObj = LocateTo(express, pCtx);
if (NULL == xpathObj)
return NULL;
/* read from path object */
xmlNodeSetPtr nodes = xpathObj->nodesetval;
if (nodes && nodes->nodeNr && nodes->nodeTab[0])
{
xmlChar *pSrc = xmlGetProp(nodes->nodeTab[0], attrName);
xmlXPathFreeObject(xpathObj);
*length = xmlStrlen(pSrc);
return pSrc;
}
xmlXPathFreeObject(xpathObj);
return NULL;
}
示例14: xmlStrncat
xmlChar *
xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
int size;
xmlChar *ret;
if ((add == NULL) || (len == 0))
return(cur);
if (cur == NULL)
return(xmlStrndup(add, len));
size = xmlStrlen(cur);
ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar));
if (ret == NULL) {
xmlErrMemory(NULL, NULL);
return(cur);
}
memcpy(&ret[size], add, len * sizeof(xmlChar));
ret[size + len] = 0;
return(ret);
}
示例15: parseEpigraph
static void
parseEpigraph (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb)
{
xmlChar *content;
cur = cur->children;
while (cur != NULL) {
if (xmlNodeIsText(cur)) {
/*
content = xmlNodeGetContent(cur);
bufferAppend(content, xmlStrlen(content), fb);
xmlFree(content);
*/
} else if (!xmlStrcmp(cur->name, (const xmlChar *)"cite")) {
parseCite(doc, cur, fb);
} else if (!xmlStrcmp(cur->name, (const xmlChar *)"poem")) {
parsePoem(doc, cur, fb);
} else if (!xmlStrcmp(cur->name, (const xmlChar *)"p")) {
parseP(doc, cur, 1, fb);
} else if (!xmlStrcmp(cur->name, (const xmlChar *)"empty-line")) {
bufferAppend("\n", 1, fb);
} else if (!xmlStrcmp(cur->name, (const xmlChar *)"text-author")) {
content = xmlNodeGetContent(cur->children);
if (content) {
bufferAppend("\t", 1, fb);
bufferAppend(content, xmlStrlen(content), fb);
bufferAppend("\n", 1, fb);
}
xmlFree(content);
}
cur = cur->next;
}
return;
}