本文整理汇总了C++中xmlXPathPopString函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlXPathPopString函数的具体用法?C++ xmlXPathPopString怎么用?C++ xmlXPathPopString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlXPathPopString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exsltStrAlignFunction
/**
* exsltStrAlignFunction:
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
* Aligns a string within another string.
*/
static void
exsltStrAlignFunction (xmlXPathParserContextPtr ctxt, int nargs) {
xmlChar *str, *padding, *alignment, *ret;
int str_l, padding_l;
if ((nargs < 2) || (nargs > 3)) {
xmlXPathSetArityError(ctxt);
return;
}
if (nargs == 3)
alignment = xmlXPathPopString(ctxt);
else
alignment = NULL;
padding = xmlXPathPopString(ctxt);
str = xmlXPathPopString(ctxt);
str_l = xmlUTF8Strlen (str);
padding_l = xmlUTF8Strlen (padding);
if (str_l == padding_l) {
xmlXPathReturnString (ctxt, str);
xmlFree(padding);
xmlFree(alignment);
return;
}
if (str_l > padding_l) {
ret = xmlUTF8Strndup (str, padding_l);
} else {
if (xmlStrEqual(alignment, (const xmlChar *) "right")) {
ret = xmlUTF8Strndup (padding, padding_l - str_l);
ret = xmlStrcat (ret, str);
} else if (xmlStrEqual(alignment, (const xmlChar *) "center")) {
int left = (padding_l - str_l) / 2;
int right_start;
ret = xmlUTF8Strndup (padding, left);
ret = xmlStrcat (ret, str);
right_start = xmlUTF8Strsize (padding, left + str_l);
ret = xmlStrcat (ret, padding + right_start);
} else {
int str_s;
str_s = xmlUTF8Strsize(padding, str_l);
ret = xmlStrdup (str);
ret = xmlStrcat (ret, padding + str_s);
}
}
xmlXPathReturnString (ctxt, ret);
xmlFree(str);
xmlFree(padding);
xmlFree(alignment);
}
示例2: exsltCryptoRc4DecryptFunction
/**
* exsltCryptoRc4DecryptFunction:
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
* computes the sha1 hash of a string and returns as hex
*/
static void
exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
int key_len = 0, key_size = 0;
int str_len = 0, bin_len = 0, ret_len = 0;
xmlChar *key = NULL, *str = NULL, *padkey = NULL, *bin =
NULL, *ret = NULL;
if ((nargs < 1) || (nargs > 3)) {
xmlXPathSetArityError (ctxt);
return;
}
str = xmlXPathPopString (ctxt);
str_len = xmlUTF8Strlen (str);
if (str_len == 0) {
xmlXPathReturnEmptyString (ctxt);
xmlFree (str);
return;
}
key = xmlXPathPopString (ctxt);
key_len = xmlUTF8Strlen (str);
if (key_len == 0) {
xmlXPathReturnEmptyString (ctxt);
xmlFree (key);
xmlFree (str);
return;
}
padkey = xmlMallocAtomic (RC4_KEY_LENGTH);
key_size = xmlUTF8Strsize (key, key_len);
memcpy (padkey, key, key_size);
memset (padkey + key_size, '\0', sizeof (padkey));
/* decode hex to binary */
bin_len = str_len;
bin = xmlMallocAtomic (bin_len);
ret_len = exsltCryptoHex2Bin (str, str_len, bin, bin_len);
/* decrypt the binary blob */
ret = xmlMallocAtomic (ret_len);
PLATFORM_RC4_DECRYPT (ctxt, padkey, bin, ret_len, ret, ret_len);
xmlXPathReturnString (ctxt, ret);
if (key != NULL)
xmlFree (key);
if (str != NULL)
xmlFree (str);
if (padkey != NULL)
xmlFree (padkey);
if (bin != NULL)
xmlFree (bin);
}
示例3: exsltRegexpTestFunction
static void
exsltRegexpTestFunction (xmlXPathParserContextPtr ctxt, int nargs)
{
xmlChar *haystack, *regexp_middle, *regexp, *flagstr;
int rc = 0, flags, global, ovector[3];
if ((nargs < 1) || (nargs > 3)) {
xmlXPathSetArityError(ctxt);
return;
}
if(nargs > 2) {
flagstr = xmlXPathPopString(ctxt);
if (xmlXPathCheckError(ctxt) || (flagstr == NULL)) {
return;
}
} else {
flagstr = xmlStrdup("");
}
regexp_middle = xmlXPathPopString(ctxt);
if (xmlXPathCheckError(ctxt) || (regexp_middle == NULL)) {
xmlFree(flagstr);
return;
}
haystack = xmlXPathPopString(ctxt);
if (xmlXPathCheckError(ctxt) || (haystack == NULL)) {
xmlFree(regexp_middle);
xmlFree(flagstr);
return;
}
/* build the regexp */
regexp = xmlStrdup("\\A");
regexp = xmlStrcat(regexp, regexp_middle);
regexp = xmlStrcat(regexp, "\\Z");
exsltRegexpFlagsFromString(flagstr, &global, &flags);
rc = exsltRegexpExecute(ctxt, haystack, regexp, flags,
ovector, sizeof(ovector)/sizeof(int));
fail:
if (flagstr != NULL)
xmlFree(flagstr);
if (regexp != NULL)
xmlFree(regexp);
if (regexp_middle != NULL)
xmlFree(regexp_middle);
if (haystack != NULL)
xmlFree(haystack);
xmlXPathReturnBoolean(ctxt, (rc > 0));
}
示例4: XSLPattern_OP_IGEq
static void XSLPattern_OP_IGEq(xmlXPathParserContextPtr pctx, int nargs)
{
xmlChar *arg1, *arg2;
XSLPATTERN_CHECK_ARGS(2);
arg2 = xmlXPathPopString(pctx);
arg1 = xmlXPathPopString(pctx);
xmlXPathReturnBoolean(pctx, xmlStrcasecmp(arg1, arg2) >= 0);
xmlFree(arg1);
xmlFree(arg2);
}
示例5: exsltNodeSetFunction
// FIXME: This code is taken from libexslt 1.1.11; should sync with newer
// versions.
static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs)
{
xmlChar* strval;
xmlNodePtr retNode;
xmlXPathObjectPtr ret;
if (nargs != 1) {
xmlXPathSetArityError(ctxt);
return;
}
if (xmlXPathStackIsNodeSet(ctxt)) {
xsltFunctionNodeSet(ctxt, nargs);
return;
}
strval = xmlXPathPopString(ctxt);
retNode = xmlNewDocText(0, strval);
ret = xmlXPathNewValueTree(retNode);
// FIXME: It might be helpful to push any errors from xmlXPathNewValueTree
// up to the Javascript Console.
if (ret)
ret->type = XPATH_NODESET;
if (strval)
xmlFree(strval);
valuePush(ctxt, ret);
}
示例6: extBitStringVal
static xmlChar *
extBitStringVal (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr xop)
{
if (xop->type == XPATH_NUMBER) {
xmlChar *res;
int width;
unsigned long long val = xop->floatval, v2;
if (xop->floatval >= pow(2, 64))
val = (unsigned long long) -1;
xmlXPathFreeObject(xop);
for (width = 0, v2 = val; v2; width++, v2 /= 2)
continue;
if (width == 0) /* Gotta have one zero */
width = 1;
res = xmlMalloc(width + 1);
if (res == NULL)
return NULL;
res[width] = '\0';
for (width--, v2 = val; width >= 0; width--, v2 /= 2)
res[width] = (v2 & 1) ? '1' : '0';
return res;
}
/* Make libxml do the work for us */
valuePush(ctxt, xop);
return xmlXPathPopString(ctxt);
}
示例7: exsltDynEvaluateFunction
static void
exsltDynEvaluateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlChar *str = NULL;
xmlXPathObjectPtr ret = NULL;
if (ctxt == NULL)
return;
if (nargs != 1) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"dyn:evalute() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
return;
}
str = xmlXPathPopString(ctxt);
if (!str||!xmlStrlen(str)) {
if (str) xmlFree(str);
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
return;
}
ret = xmlXPathEval(str,ctxt->context);
if (ret)
valuePush(ctxt,ret);
else {
xsltGenericError(xsltGenericErrorContext,
"dyn:evaluate() : unable to evaluate expression '%s'\n",str);
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
}
xmlFree(str);
return;
}
示例8: exsltNodeSetFunction
// FIXME: This code is taken from libexslt 1.1.11; should sync with newer versions.
static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs)
{
xmlChar *strval;
xmlNodePtr retNode;
xmlXPathObjectPtr ret;
if (nargs != 1) {
xmlXPathSetArityError(ctxt);
return;
}
if (xmlXPathStackIsNodeSet(ctxt)) {
xsltFunctionNodeSet(ctxt, nargs);
return;
}
strval = xmlXPathPopString(ctxt);
retNode = xmlNewDocText(NULL, strval);
ret = xmlXPathNewValueTree(retNode);
if (ret == NULL) {
xsltGenericError(xsltGenericErrorContext,
"exsltNodeSetFunction: ret == NULL\n");
} else {
ret->type = XPATH_NODESET;
}
if (strval != NULL)
xmlFree(strval);
valuePush(ctxt, ret);
}
示例9: exsltStrDecodeUriFunction
/**
* exsltStrDecodeUriFunction:
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
* reverses URI-Escaping of a string
*/
static void
exsltStrDecodeUriFunction (xmlXPathParserContextPtr ctxt, int nargs) {
int str_len = 0;
xmlChar *str = NULL, *ret = NULL, *tmp;
if ((nargs < 1) || (nargs > 2)) {
xmlXPathSetArityError(ctxt);
return;
}
if (nargs >= 2) {
/* check for UTF-8 if encoding was explicitly given;
we don't support anything else yet */
tmp = xmlXPathPopString(ctxt);
if (xmlUTF8Strlen(tmp) != 5 || xmlStrcmp((const xmlChar *)"UTF-8",tmp)) {
xmlXPathReturnEmptyString(ctxt);
xmlFree(tmp);
return;
}
xmlFree(tmp);
}
str = xmlXPathPopString(ctxt);
str_len = xmlUTF8Strlen(str);
if (str_len == 0) {
xmlXPathReturnEmptyString(ctxt);
xmlFree(str);
return;
}
ret = (xmlChar *) xmlURIUnescapeString((const char *)str,0,NULL);
if (!xmlCheckUTF8(ret)) {
/* FIXME: instead of throwing away the whole URI, we should
only discard the invalid sequence(s). How to do that? */
xmlXPathReturnEmptyString(ctxt);
xmlFree(str);
xmlFree(ret);
return;
}
xmlXPathReturnString(ctxt, ret);
if (str != NULL)
xmlFree(str);
}
示例10: xsltp_extension_string_rtrim
static void
xsltp_extension_string_rtrim(xmlXPathParserContextPtr ctxt, int nargs) {
if (nargs != 1) {
xmlXPathSetArityError(ctxt);
return;
}
xmlXPathReturnString(ctxt, _xsltp_extension_string_rtrim(xmlXPathPopString(ctxt)));
}
示例11: exsltNodeSetFunction
static void
exsltNodeSetFunction (xmlXPathParserContextPtr ctxt, int nargs) {
if (nargs != 1) {
xmlXPathSetArityError(ctxt);
return;
}
if (xmlXPathStackIsNodeSet (ctxt)) {
xsltFunctionNodeSet (ctxt, nargs);
return;
} else {
xmlDocPtr fragment;
xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt);
xmlNodePtr txt;
xmlChar *strval;
xmlXPathObjectPtr obj;
/*
* SPEC EXSLT:
* "You can also use this function to turn a string into a text
* node, which is helpful if you want to pass a string to a
* function that only accepts a node-set."
*/
fragment = xsltCreateRVT(tctxt);
if (fragment == NULL) {
xsltTransformError(tctxt, NULL, tctxt->inst,
"exsltNodeSetFunction: Failed to create a tree fragment.\n");
tctxt->state = XSLT_STATE_STOPPED;
return;
}
xsltRegisterLocalRVT(tctxt, fragment);
strval = xmlXPathPopString (ctxt);
txt = xmlNewDocText (fragment, strval);
xmlAddChild((xmlNodePtr) fragment, txt);
obj = xmlXPathNewNodeSet(txt);
if (obj == NULL) {
xsltTransformError(tctxt, NULL, tctxt->inst,
"exsltNodeSetFunction: Failed to create a node set object.\n");
tctxt->state = XSLT_STATE_STOPPED;
} else {
/*
* Mark it as a function result in order to avoid garbage
* collecting of tree fragments
*/
xsltExtensionInstructionResultRegister(tctxt, obj);
}
if (strval != NULL)
xmlFree (strval);
valuePush (ctxt, obj);
}
}
示例12: exsltStrEncodeUriFunction
/**
* exsltStrEncodeUriFunction:
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
* URI-Escapes a string
*/
static void
exsltStrEncodeUriFunction (xmlXPathParserContextPtr ctxt, int nargs) {
int escape_all = 1, str_len = 0;
xmlChar *str = NULL, *ret = NULL, *tmp;
if ((nargs < 2) || (nargs > 3)) {
xmlXPathSetArityError(ctxt);
return;
}
if (nargs >= 3) {
/* check for UTF-8 if encoding was explicitly given;
we don't support anything else yet */
tmp = xmlXPathPopString(ctxt);
if (xmlUTF8Strlen(tmp) != 5 || xmlStrcmp((const xmlChar *)"UTF-8",tmp)) {
xmlXPathReturnEmptyString(ctxt);
xmlFree(tmp);
return;
}
xmlFree(tmp);
}
escape_all = xmlXPathPopBoolean(ctxt);
str = xmlXPathPopString(ctxt);
str_len = xmlUTF8Strlen(str);
if (str_len == 0) {
xmlXPathReturnEmptyString(ctxt);
xmlFree(str);
return;
}
ret = xmlURIEscapeStr(str,(const xmlChar *)(escape_all?"-_.!~*'()":"-_.!~*'();/?:@&=+$,[]"));
xmlXPathReturnString(ctxt, ret);
if (str != NULL)
xmlFree(str);
}
示例13: extBitFromHex
static void
extBitFromHex (xmlXPathParserContextPtr ctxt, int nargs)
{
xmlChar *res;
int maxw = 0, width = 0, i;
unsigned long long val, v2;
if (nargs != 1 && nargs != 2) {
xmlXPathSetArityError(ctxt);
return;
}
/* Pop args in reverse order */
if (nargs == 2) {
maxw = xmlXPathPopNumber(ctxt);
if (maxw < 0 || xmlXPathCheckError(ctxt))
return;
}
res = xmlXPathPopString(ctxt);
if (res == NULL || xmlXPathCheckError(ctxt))
return;
val = strtoull((char *) res, 0, 0x10);
for (width = 0, v2 = val; v2; width++, v2 /= 2)
continue;
if (width == 0) /* Gotta have one zero */
width = 1;
if (maxw < width)
maxw = width;
res = xmlRealloc(res, maxw + 1);
if (res) {
res[maxw] = '\0';
for (i = maxw - 1, v2 = val; i >= 0; i--) {
if (width-- <= 0)
res[i] = '0';
else {
res[i] = (v2 & 1) ? '1' : '0';
v2 /= 2;
}
}
}
xmlXPathReturnString(ctxt, res);
}
示例14: xsltp_extension_string_lc
static void
xsltp_extension_string_lc(xmlXPathParserContextPtr ctxt, int nargs) {
xmlChar *str;
if (nargs != 1) {
xmlXPathSetArityError(ctxt);
return;
}
str = xmlXPathPopString(ctxt);
xmlXPathReturnString(ctxt, (xmlChar *) g_utf8_strdown((const gchar *) str, -1));
xmlFree(str);
}
示例15: 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);
}