当前位置: 首页>>代码示例>>C++>>正文


C++ xmlXPathSetArityError函数代码示例

本文整理汇总了C++中xmlXPathSetArityError函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlXPathSetArityError函数的具体用法?C++ xmlXPathSetArityError怎么用?C++ xmlXPathSetArityError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xmlXPathSetArityError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exsltMathLowestFunction

/**
 * exsltMathLowestFunction:
 * @ctxt:  an XPath parser context
 * @nargs:  the number of arguments
 *
 * Wraps #exsltMathLowest for use by the XPath processor
 */
static void
exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) {
    xmlNodeSetPtr ns, ret;
    void *user = NULL;
    

    if (nargs != 1) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    /* We need to delay the freeing of value->user */
    if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) {
        user = ctxt->value->user;
	ctxt->value->boolval = 0;
	ctxt->value->user = NULL;
    }
    ns = xmlXPathPopNodeSet(ctxt);
    if (xmlXPathCheckError(ctxt))
	return;

    ret = exsltMathLowest(ns);

    xmlXPathFreeNodeSet(ns);
    if (user != NULL)
        xmlFreeNodeList((xmlNodePtr)user);

    xmlXPathReturnNodeSet(ctxt, ret);
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:36,代码来源:math.c

示例2: extBitNot

static void
extBitNot (xmlXPathParserContextPtr ctxt, int nargs)
{
    xmlChar *res;
    int width, i;
    xmlXPathObjectPtr xop;

    if (nargs != 1) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    /* Pop args in reverse order */
    xop = valuePop(ctxt);
    if (xop == NULL || xmlXPathCheckError(ctxt))
	return;
    res = extBitStringVal(ctxt, xop);
    if (res == NULL)
	return;

    width = xmlStrlen(res);
    for (i = 0; i < width; i++) {
	xmlChar lb = res[i];
	res[i] = (lb == '0') ? '1' : '0';
    }

    xmlXPathReturnString(ctxt, res);
}
开发者ID:Juniper,项目名称:libslax,代码行数:28,代码来源:ext_bit.c

示例3: exsltMathMaxFunction

static void
exsltMathMaxFunction (xmlXPathParserContextPtr ctxt, int nargs) {
    xmlNodeSetPtr ns;
    double ret;
    void *user = NULL;

    if (nargs != 1) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    
    if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) {
	user = ctxt->value->user;
	ctxt->value->boolval = 0;
	ctxt->value->user = 0;
    }
    ns = xmlXPathPopNodeSet(ctxt);
    if (xmlXPathCheckError(ctxt))
	return;

    ret = exsltMathMax(ns);

    xmlXPathFreeNodeSet(ns);

    if (user != NULL)
        xmlFreeNodeList((xmlNodePtr)user);
    xmlXPathReturnNumber(ctxt, ret);
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:29,代码来源:math.c

示例4: 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);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:32,代码来源:XSLTExtensions.cpp

示例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);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:32,代码来源:XSLTExtensions.cpp

示例6: extBitToInt

static void
extBitToInt (xmlXPathParserContextPtr ctxt, int nargs)
{
    xmlChar *res;
    xmlXPathObjectPtr xop;
    unsigned long long val;
    int i;

    if (nargs != 1) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    xop = valuePop(ctxt);
    if (xop == NULL || xmlXPathCheckError(ctxt))
	return;
    res = extBitStringVal(ctxt, xop);
    if (res == NULL)
	return;

    for (i = 0, val = 0; i <= 64 && res[i]; i++) {
	val <<= 1;
	if (res[i] == '1')
	    val += 1;
    }

    if (i > 64)
	xmlXPathReturnNumber(ctxt, (double) -1);
    else
	xmlXPathReturnNumber(ctxt, (double) val);
}
开发者ID:Juniper,项目名称:libslax,代码行数:31,代码来源:ext_bit.c

示例7: 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)));
}
开发者ID:gitpan,项目名称:XML-LibXSLT-Processor,代码行数:8,代码来源:xsltp_extension.c

示例8: extBitCompare

static void
extBitCompare (xmlXPathParserContextPtr ctxt, int nargs)
{
    xmlChar *res1, *res2;
    xmlXPathObjectPtr xop;
    int width1, width2, off1, off2, rc, delta;

    if (nargs != 2) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    /* Pop args in reverse order */
    xop = valuePop(ctxt);
    if (xop == NULL || xmlXPathCheckError(ctxt))
	return;
    res2 = extBitStringVal(ctxt, xop);
    if (res2 == NULL)
	return;

    xop = valuePop(ctxt);
    if (xop == NULL || xmlXPathCheckError(ctxt))
	return;
    res1 = extBitStringVal(ctxt, xop);
    if (res1 == NULL)
	return;

    width1 = xmlStrlen(res1);
    width2 = xmlStrlen(res2);
    delta = width1 - width2;

    rc = 0;
    off1 = off2 = 0;
    if (delta < 0) {
	for ( ; delta < 0; delta++, off2++) {
	    if (res2[off2] != '0') {
		rc = -1;
		goto done;
	    }
	}

    } else if (delta > 0) {
	for ( ; delta > 0; delta--, off1++) {
	    if (res1[off1] != '0') {
		rc = 1;
		goto done;
	    }
	}
    }

    rc = xmlStrcmp(res1 + off1, res2 + off2);

 done:
    xmlFree(res1);
    xmlFree(res2);

    xmlXPathReturnNumber(ctxt, rc);
}
开发者ID:Juniper,项目名称:libslax,代码行数:58,代码来源:ext_bit.c

示例9: 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);
}
开发者ID:BillTian,项目名称:libxslt,代码行数:65,代码来源:strings.c

示例10: 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);
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:64,代码来源:crypto.c

示例11: 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));
}
开发者ID:tycho01,项目名称:parsley,代码行数:54,代码来源:regexp.c

示例12: 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);
    }
}
开发者ID:Ashod,项目名称:WinCairoRequirements,代码行数:52,代码来源:common.c

示例13: exsltMathRandomFunction

/**
 * exsltMathRandomFunction:
 * @ctxt:  an XPath parser context
 * @nargs:  the number of arguments
 *
 * Wraps #exsltMathRandom for use by the XPath processor.
 */
static void
exsltMathRandomFunction (xmlXPathParserContextPtr ctxt, int nargs) {
    double ret;

    if (nargs != 0) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    ret = exsltMathRandom();

    xmlXPathReturnNumber(ctxt, ret);
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:20,代码来源:math.c

示例14: extBitOperation

static void
extBitOperation (xmlXPathParserContextPtr ctxt, int nargs,
		 slax_bit_callback_t func, const char *name)
{
    xmlChar *lv, *rv, *res;
    int llen, rlen, width, i;
    xmlXPathObjectPtr xop;

    if (nargs != 2) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    /* Pop args in reverse order */
    xop = valuePop(ctxt);
    if (xop == NULL || xmlXPathCheckError(ctxt))
	return;
    rv = extBitStringVal(ctxt, xop);
    if (rv == NULL)
	return;

    xop = valuePop(ctxt);
    if (xop == NULL || xmlXPathCheckError(ctxt))
	return;
    lv = extBitStringVal(ctxt, xop);
    if (lv == NULL) {
	xmlFree(rv);
	return;
    }

    llen = xmlStrlen(lv);
    rlen = xmlStrlen(rv);
    width = (llen > rlen) ? llen : rlen;

    res = xmlMalloc(width + 1);
    if (res) {
	res[width] = '\0';
	for (i = 0; i < width; i++) {
	    xmlChar lb = (i >= width - llen) ? lv[i - (width - llen)] : '0';
	    xmlChar rb = (i >= width - rlen) ? rv[i - (width - rlen)] : '0';
	    res[i] = (*func)(lb, rb);
	}
    }

    slaxLog("bit:%s:: %d [%s] -> [%s] == [%s]", name, width, lv, rv, res);

    xmlFree(lv);
    xmlFree(rv);

    xmlXPathReturnString(ctxt, res);
}
开发者ID:Juniper,项目名称:libslax,代码行数:51,代码来源:ext_bit.c

示例15: 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);
}
开发者ID:Juniper,项目名称:libslax,代码行数:50,代码来源:ext_bit.c


注:本文中的xmlXPathSetArityError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。