* xmlXPathRegisterFuncNS: * @ctxt: the XPath context * @name: the function name * @ns_uri: the function namespace URI * @f: the function implementation or NULL * * Register a new function. If @f is NULL it unregisters the function * * Returns 0 in case of success, -1 in case of error */
| 3921 | * Returns 0 in case of success, -1 in case of error |
| 3922 | */ |
| 3923 | int |
| 3924 | xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name, |
| 3925 | const xmlChar *ns_uri, xmlXPathFunction f) { |
| 3926 | int ret; |
| 3927 | |
| 3928 | if (ctxt == NULL) |
| 3929 | return(-1); |
| 3930 | if (name == NULL) |
| 3931 | return(-1); |
| 3932 | |
| 3933 | if (ctxt->funcHash == NULL) |
| 3934 | ctxt->funcHash = xmlHashCreate(0); |
| 3935 | if (ctxt->funcHash == NULL) { |
| 3936 | xmlXPathErrMemory(ctxt); |
| 3937 | return(-1); |
| 3938 | } |
| 3939 | if (f == NULL) |
| 3940 | return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL)); |
| 3941 | XML_IGNORE_FPTR_CAST_WARNINGS |
| 3942 | ret = xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f); |
| 3943 | XML_POP_WARNINGS |
| 3944 | if (ret < 0) { |
| 3945 | xmlXPathErrMemory(ctxt); |
| 3946 | return(-1); |
| 3947 | } |
| 3948 | |
| 3949 | return(0); |
| 3950 | } |
| 3951 | |
| 3952 | /** |
| 3953 | * xmlXPathRegisterFuncLookup: |
no test coverage detected