* xmlC14NVisibleNsStackFind: * @ctx: the C14N context * @ns: the namespace to check * * Checks whether the given namespace was already rendered or not * * Returns 1 if we already wrote this namespace or 0 otherwise */
| 393 | * Returns 1 if we already wrote this namespace or 0 otherwise |
| 394 | */ |
| 395 | static int |
| 396 | xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns) |
| 397 | { |
| 398 | int i; |
| 399 | const xmlChar *prefix; |
| 400 | const xmlChar *href; |
| 401 | int has_empty_ns; |
| 402 | |
| 403 | if(cur == NULL) { |
| 404 | xmlC14NErrParam(NULL); |
| 405 | return (0); |
| 406 | } |
| 407 | |
| 408 | /* |
| 409 | * if the default namespace xmlns="" is not defined yet then |
| 410 | * we do not want to print it out |
| 411 | */ |
| 412 | prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix; |
| 413 | href = ((ns == NULL) || (ns->href == NULL)) ? BAD_CAST "" : ns->href; |
| 414 | has_empty_ns = (xmlC14NStrEqual(prefix, NULL) && xmlC14NStrEqual(href, NULL)); |
| 415 | |
| 416 | if (cur->nsTab != NULL) { |
| 417 | int start = (has_empty_ns) ? 0 : cur->nsPrevStart; |
| 418 | for (i = cur->nsCurEnd - 1; i >= start; --i) { |
| 419 | xmlNsPtr ns1 = cur->nsTab[i]; |
| 420 | |
| 421 | if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) { |
| 422 | return(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL)); |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | return(has_empty_ns); |
| 427 | } |
| 428 | |
| 429 | static int |
| 430 | xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx) { |
no test coverage detected