From cd2fb8f34d6bee984a5c0c25b49f0707808ddd11 Mon Sep 17 00:00:00 2001 From: "Chrome Release Bot (LUCI)" Date: Wed, 8 Feb 2023 21:35:29 +0000 Subject: [PATCH 1/2] Publish DEPS for 96.0.4664.153 git-subtree-dir: third_party/libxml git-subtree-split: abb3b00ed5496bfe4d0183dcd5cc6313f608416a --- BUILD.gn | 325 + DEPS | 3 + DIR_METADATA | 3 + OWNERS | 5 + README.chromium | 28 + chromium/chromium-issue-599427.patch | 28 + chromium/chromium-issue-628581.patch | 178 + chromium/chromium-issue-708434.patch | 19 + chromium/chromium-issue-894933.patch | 113 + ...ml2-2.9.4-security-xpath-nodetab-uaf.patch | 15 + chromium/libxml_utils.cc | 17 + chromium/libxml_utils.h | 39 + chromium/roll.py | 481 + chromium/xml_reader.cc | 228 + chromium/xml_reader.h | 108 + chromium/xml_writer.cc | 67 + chromium/xml_writer.h | 74 + fuzz/README | 22 + .../0046047b00a82a1fe56d88665c5f08eb2913cf03 | 15 + .../006c315fc21acb1b5ce82c7a6b355a091cb2fc49 | 13 + .../00945a5dd7a52774fdd9aead9269e5bd2f847ce2 | 9 + .../00b1bb2a809832b240779bc1e50fcd3a2ab14fd4 | 24 + .../00dafde86ff0f8c9036591cc30b72d0f7490cfcd | 7 + .../01148aca72bb87dd2df0016e94e34b04c34edfe6 | 9 + .../0199b3c9a99e71a24cd9126a922533c2b14a60c8 | 20 + .../0199e2ffeafeed2c63576109cab1131c2182c49c | 10 + .../0199fc60e9af21a3be8cbdc03622c3ebad9c2f2d | 10 + .../0212f02cef3483152bb9871fd93aa4a69ea181a6 | 14 + .../025dbaa618983aba2fd0ba6b6a803cdd0de76460 | 5 + .../0299a259ba8264e3aec403d768db7ad3a0a93e4a | 1 + .../02d7a5beb17053ac8020ed23c0489f93d39c5321 | 1 + .../034e3c37a5f06912e1ff8fc7b90a26175bccf935 | 28 + .../03713dd0e13838f82b527912f3748e2d1171fb91 | 12 + .../041ac56e4bfd93af5cc2e4aaa053f11c23c61d19 | 31 + .../049f9eb07492c4966b1f5b781bff895f3fab33c0 | 46 + .../04b1f0de43822b89a75416e2a0f4ab8da98ab9a0 | 18 + .../04c408efc27d601dbd1e91148e2e37ae969fb97e | 9 + .../04dabdaea684ba279bbf03b0ae22b366083ff7aa | 1 + .../04e0d9e30029cd448cd9c2a4c964ce012c976d90 | 22 + .../04ef401357f30717ba5862256fca75cda1436157 | 173 + .../052e9d557fe9d32b953adcdfca65788e07ead143 | 10 + .../0533c0ff80dcd22bd55bb8bc8993cd84b1b97914 | 7 + .../058df98d84d0037f011420c5c29c45e6b88bbadd | 7 + .../05f1cd6c5d6d21ae108cbcdde5e57ae914568082 | 22 + .../06060a5bfcbd6220ca5a522be3bd58dedc6bedd8 | 11 + .../064e4c40476264152302e53a5d5d68c90f36a9bb | 8 + .../0666dce9a0f535c4b9fb1af43c0239f4fae6d0fb | 6 + .../06f5fd11efe6278ce31ac322099eea1580f3cc80 | 1 + .../07028eb348b8c531e11c70e5e6acf6e44b12268e | 8 + .../0704cd3859fa29b00abc00048c8f2dc7697d2149 | 12 + .../070b97218d858e0b8633f8cb8950f0dd399fb74b | 1665 + .../07e10835dd988dbe50d5b6fd31764d861be92472 | 12 + .../084e64a61efd93c01013fd8e4d5c85c06b06ed30 | 24 + .../08c7c9747d2d903aa36313b9411946c71662f377 | 2 + .../090413ef009359b0c1306316fc170553544f2b61 | 4 + .../0a204a26abfc429052d195a53e54e59546cbea8e | 2 + .../0a20515ebc673a7189a9c85df27537ce1facde25 | 3 + .../0a6fe19b30ff4214e9c0ba8de22ddfb62bab749d | 36 + .../0a8ae185eb95921dda7c1904eaf2e8eb6d86cb1b | 3 + .../0a993ba3d08d0a13561b372c1b8a5d3e699cd869 | 5 + .../0ad8a19515bb609baceb2b3945e86ef0b2e5a5fb | 5 + .../0b4909764c156be5c065dcc16c1e567b31017e9e | 14 + .../0b654d50c2764ecf5d674bca11f08afeaf54fae4 | 12 + .../0b7091f77ebe7860c8c8554eebb6765252d6e592 | 9 + .../0b9629a73f555d8289186e30d742aabbc50bcd5a | 21 + .../0badf8f46e8416ed41f758e79210a509dfb2d922 | 986 + .../0c156d7e289aa9daed03ee5219c1087f304e0ff5 | 26 + .../0c81f2be59d6e8d407560df61f70fea33f628619 | 14 + .../0c9f98eb422a59137fcf6e8368b2d91b00a5cfb0 | 16 + .../0cca701ea25dab8e47ffee1d41ae5b2fa80d75ce | 7 + .../0d187520e9f41b00153249383f24c77fd5d4cd99 | 1 + .../0d3a2bdc316b17dfbd0b7ccd44737d8caa63792c | 3 + .../0d3d85ffa5363ae5691afddfb0a630d45739179a | 17 + .../0d553bbcd73a23a541c68ffdf8cf60d386a67d92 | 7 + .../0d75321585730f6bc551f43ba86cb3aaec49d14d | 89 + .../0dd6288030245d6321791f5d145d5c465912945c | 1 + .../0e6f212f04c1659140cc135cc8ebb1313254c219 | 3 + .../0e7113fb5f90187c68454342ff4b918fd89df95b | 1 + .../0e75e6935de80d924277e5328d68a23d8de6ba3f | 26 + .../0ea5bd004cf7e082db96ec3773cc1d3020ea0678 | 3 + .../0ed173519dbf72a643ebac81117507a13fc33701 | 24 + .../0f4b109b7485f97b414203e5c8fcbe9d79ad44ed | 9 + .../0f5106937b68ba39686ca3bdb64695d2457451ca | 25 + .../0f84ad0758d9add8fab470f16befdfaae099ddda | 14 + .../0fd7bee6fde35437645194d8c45aaee9cac11b6a | 2 + .../0ffd3e46edeb253b94d35fcc9c65fb353b49c486 | 30 + .../10252b88a86e33e88effc97d948ac80c6416aa8f | 58 + .../10427462d18f60de0727ae71f8b30e67bae5e300 | 18 + .../11151c1f8a1da7fc9510eb6ac06e6b9c5efe6d89 | 15 + .../11272849809f3bdf65ceb37ac7aa447459334b46 | 1 + .../115b37a602de376022be7161cb23d8200aee712b | 23 + .../11635af037a796739b803b1d67e59aee152fb35e | 16 + .../11c3681bb5b2ea9cfdecb79f3a3124cb4c8858f9 | 10 + .../11dab67b78d459826ae4cfcdc05cf91c1fc9fd7a | 3 + .../120a2fbfabf37ad14df7ed82c2d89088dfe15d19 | 10 + .../12e7780fd2e88bce7460167ee15bcd8f84be0fbf | 11 + .../1370fc03d0009a05614a134847afd8188fd76cc1 | 12 + .../13799b7fe169c8de8889234e7b33e0cdde0cc47e | 3 + .../13b919c1f1c19522473beaba623afed955e65f92 | 29 + .../13fb4d418998bdb16f027dfc2842d46ede5129b0 | 2 + .../1437e5e33198fa59e55fe2a8dcd3edac07102e64 | 7 + .../143eddcb3c1e41ca0e773b91ba0bfa3b0888b085 | 24 + .../156207e9ec9a86691595dd77cb0490a247fe175e | 6 + .../15970946eb9a2ed52ad09fc78e61e1cf4e741018 | 18 + .../15d3ac6444c917fd769d0ce83bfc31dc4466980b | 24 + .../15de524d7bfcddd2b2ffc89f02230740b71fe042 | 9 + .../15ff9e809d0bfa67e482541391d3ec5fc9844a96 | 3 + .../1600d482d58bc75d288aedadef3a11135788dc5c | 1 + .../16783e74638cfe8030490b0180fd7fbc765780d7 | 18 + .../16f348235a0080206b00be3f9231e418aa5d67da | 25 + .../179b0cb5a01db1510b23f5cc531ea0ac3bfe4d98 | 2 + .../17b31bb2ef7f3a15434478f422276fcd736f0ff7 | 20 + .../18093e2a54c73c34b3160fb1bccafeed58db0bd5 | 5 + .../1818ac1aa7f2fb815428dd95acf8fe0691455e16 | 2 + .../18455d3de982d262231a468c0c47e783805cc1fd | 7 + .../185d7bb0d1416c764345bac8dc713f3fe296dff7 | 9 + .../191750348d3607f07c1ac636303daa558bc31697 | 3 + .../19204df7ab4eae999ecc6ea0bded083cb946dc85 | 15 + .../19384a4d87395788c83ac27934cd3cf71d0e5406 | 12 + .../195c9d4c518ea0b2717c281feb289b6553326abd | 12 + .../198eb5d4de042d0b430acfedb5f08b70a9bc4267 | 8 + .../19a80b448405a19fbb41592734b6d4af617d0459 | 8 + .../1a0798fcc3d279d54727b8531527edcda35079d8 | 12 + .../1a69f9c493e3409a297ef54cd2709c6c8b155cd7 | 1 + .../1afdab953f153ad082284ab6579dfa97e9db25e3 | 7 + .../1b03d02961926db0a5b2867291d30951c39d148b | 32 + .../1b6b1588fd94a28c0184b532083d2d4aaa4125aa | 8 + .../1c325aae428d9e024730d89afdfbcfd9dfd05755 | 6 + .../1c967d0cbfb53d1c1184b8d27f2c0b1f9cb4326c | 13 + .../1d2e7871a709b88c0f4e07b959c103070768a5b5 | 1 + .../1e791b3905ff171de1c06a26fdff4d262d5d4be2 | 9 + .../1e82fff4b132ce695652529980f1c904d28b7791 | 30 + .../1ed76a4de1c73b3f5883f0ca110a96be8aa12c1e | 13 + .../1ee55697ce9055cfe227685daca3c57b4318cfa0 | 5 + .../1f50fd9aa3a95df4a16b2ff4ce266ca83a4ff1fc | 6 + .../1f61817349b114163accd91d7718ccd8a22fbfa2 | 27 + .../1f954acde14869cc13df666d262a96000bbfb5dc | 14 + .../1fd59752baa6bc81f102ba96945a8026d8715adc | 5 + .../200d267a8bfc425839e40d407199ea7ff82fe346 | 9 + .../200d6d0432577c34fc801d4fee24b3393d7c05b4 | 2 + .../210a5f90b6ae0cd6cb95edbde77d52d450eeb1fc | 11 + .../210cab277f69b056d63542bc6940ea2cca8a558a | 7 + .../211cf9d35b1d4679671b4ac3d4e89fc075613ab3 | 7 + .../21f4384140618ecb5caadcfeb123bd6f7d1bcbfe | 2 + .../21f9abf973c92ec0a51656f3a76dbdad0bad769c | 5 + .../22421149badaedff85e55e4cab3b08502a92c36f | 1 + .../22d1271153c5b90a31a6a3924787b98a750344eb | 1 + .../23343eefaf46c5fbfe5a5ed489b125cf38741d14 | 1558 + .../23aefbf61990ccfb3812eb85aa16969aa9c741e5 | 8 + .../23e1b677b9923e2d7d3351edbfb6d6f3f900968f | 59 + .../24112ff255332818fa2c677b91428aebcfa2771e | 13 + .../243261fb3a9034eaf3108beef61b3f4acbabd2ff | 3 + .../246d63002273f1f18d853d41f1e078466918b0fa | 1 + .../24d5c3998d909457df8a5ebda0d2f13ce97bb75a | 10 + .../24e96912408f5d59c13dcd310a0a0399bafc427a | 2 + .../2526e9fd2e7dc170f96a1138764506f28d213770 | 5 + .../257b66031fd4022497978b05e01f4157af963b1c | 1 + .../258200972a08001ab73d3a9cc1bca434edf8ac54 | 11 + .../268941309b3d09b155480b78c886976d9eac0658 | 37 + .../26bb4c75d24f2a674163677f8af8f34c83f45b47 | 5 + .../272d4ce45d79ec367eb0b3ba6fd637215c05cf3f | 7 + .../279887432540854d81ed9214156f2e3a9860dd80 | 249 + .../27bcdce6c0a5968b3d3b2820f22e9ab211bd1f66 | 3 + .../27bfe8bc3ce62b01ae4b0e8073db7bb8dae1bacf | 9 + .../27d3fdcc4901e5b6d3350fe46e495f78880b9615 | 12 + .../27f93269230c2cdac3686c0ef8bf494689e07148 | 85 + .../28c1d7135e399a43882ad2d71df0ecc354305bdf | 8 + .../295eea46f015e02b3a518db800bf9fa93505773b | 11 + .../299d543a09f90c6aeeb787277cd870affd2a6645 | 1173 + .../29a32d7418008301e60cf31b6a830f029bf70620 | 25 + .../2a0b940c5134f02d3a32cf2cee38a74d5ab1c8fa | 1 + .../2a8b610bfb16745a14e58d879a9415b70fe60c3f | 8 + .../2a986afeaeece3a69206754e654d83221f3d4e3f | 4 + .../2adaf0d8e75c41100623c410be3dea8dd30b4d69 | 72 + .../2b20f5ba42cc907d756768ad36e7d90ea1ec2625 | 3 + .../2b29f5ebce426a5bbfe986324ba833b3b4eda61e | 1 + .../2b9b98aa420ec906d5b6da3234174e59b545b7d7 | 11 + .../2bf06d0674a90839c365de7cd703f2cf371cb39c | 1633 + .../2c17df372ab3e6ccb0708a1cf42f3cf0624c4cfd | 1 + .../2c3804c6aa81bfef7ddba8bd392f0d8968c6bcb4 | 11 + .../2ca8525d0ef8ef80c4cffeb1d6ca35b171832867 | 17 + .../2cb101abf3950cb2d16e120a8388cdf3fa696b74 | 5 + .../2ce1c305d0d78f9723c9e64b4faf9ea18665742d | 4 + .../2d01ccd503d780469651df3b4bfec6d609820c44 | 6 + .../2d1090e9e9674e281a7383e2e5d137174df9ae24 | 68 + .../2d4938de49e0ab437dc84b2b4d0cd436ef30a188 | 4 + .../2d571657158293cbeb414954c868b7d059f18202 | 2 + .../2db003f3dd00fd677ec17137c627baa9aa65956a | 12 + .../2dcf80305d3a0dbe303d3327b0fc3fefa84d6163 | 33 + .../2de6eaa9ea8b2c3315c76c444d363d747310cd41 | 7 + .../2e8bbbb3d3b04f9832e3cc27e71e480bb7cc7053 | 10 + .../2ea6d56fdb6dff6d7419d04feb8c487ed1bc9449 | 1 + .../2edd283c71f81215a507cc9fb09ea820e7883c75 | 117 + .../2ef2e635bc69fe780e952fc98be6310e257bfc9b | 1 + .../2f69fe1657e0fa419119d088df4d7fabd1349375 | 1 + .../2f9d077a8d222d675767c15f40f4e02b5af87fbb | 1 + .../2fc3463adc8d5efee1d1264b040d4f7592f0f25b | 6 + .../2ff26c57e9859c67ce742f7d9e3998d221a6b3ed | 13 + .../3033050fc78db9c6ae43d421ab0c6ac919508c4c | 5 + .../306a8956f55a33546f18cf9e074260c213a2650e | 13 + .../312ea7279fbd73cb85b56f4b091d5fa30d5edf7d | 1 + .../315af194713e19575d14219f809979c413352caa | 10 + .../31bb7a40c73fb9d577cac3a77f5d2f3dba735e9a | 53 + .../3200c178d8bf3a746a4896fb23f0ca07ffa3a252 | 3 + .../325141a45d26c576c5f6d4e25f29af6b3d3b2bca | 1 + .../328781b84caf8ec37b9a0d723938810d40fe4719 | 14 + .../32bb4cd890770928b31d81934920acaae0b02106 | 2 + .../32f877dee5fdbf4544c8eb601367508bb39f4678 | 1 + .../33417f3b4591d775c4cfe7ce2def35bc06c8e5f8 | 17 + .../336db03b7edf31bcd28841ecbe5ab4be0c2337ff | 15 + .../33b9edc2a8b46940af9b62e871b640b8810ca177 | 11 + .../33d4e2071e444fef93043f9f8f95ff74c1915b53 | 18 + .../33d68da1f9e21a0e30a5a81ebc2bbf57d2a9fb87 | 34 + .../3457d93607d3999e321617680bed3ddca1f44bf3 | 1 + .../34675d3c7f8e4a39df7ac2c6bc0a06612f5319e0 | 7 + .../34f7d2c6f3468da3f3ff5f21164a2801a0f9925a | 14 + .../34f892bb3c2e5d05fd6082da5ba25d932a5dea2f | 3 + .../35023a7259bc97894808e681da25db0a9643746c | 7 + .../35343925d7c2fe1f6246096652ac3f588f197d37 | 1 + .../3553d1e2ae4f4bf2dd64e22920ee093c1246375a | 5 + .../3573efff01f53fb99cc1f62025782687a8492389 | 6 + .../359efdf116e99b035ad8a7143e0008c726f8e89a | 8 + .../35adadef5ed7f8904b95b896ceb98c0c67b7c4d9 | 14 + .../35e835321db6aadf8e91b0c5349ca32d5dcfaca0 | 5 + .../362061c13eb3be9264e4d6fd796b65e67e06d15f | 23 + .../367c8849eb9c664ffd8fca01ae437693e7c300f1 | 3 + .../369cde0f03fa526fa88cb0962ad9df3db638f974 | 14 + .../36a3a042b66d27d82b3c33ba30f12b3ace42b992 | 8 + .../3763091a5b9d668ead99e1859df607ebaa818660 | 163 + .../37d81231057d12730464baf1d81ef8463d8a3ba8 | 8 + .../37f690b3337edd9e89cf7b8181a612674979125e | 19 + .../37f92f2750a7f26f9055119d80f6cd1ebbf756f2 | 6 + .../3825c09a96e5e05f4092ae01d96c209db1f8f050 | 4 + .../38515283cea851779d8e8d3b0aad93be591fddca | 4 + .../38adf992bf07f252b47363b333b6d90402124062 | 24 + .../38ca080f40a7d3c2546bb8a6f724a1d24c45c0c1 | 1 + .../392bf6b64c0e639ddae18ff6fc312d383a7823c1 | 3 + .../392e0963a6e4f6ccc286f097d86f26292258b29c | 8 + .../394d289b3ca309b56508d8e49ba7b33d6f0a3c7f | 13 + .../39a4d06da6128e34fbaf2492613a8a35dd3c1172 | 45 + .../39da01073207d77452a8e9207324ad9c733b72a8 | 9 + .../3a0a830b4c2564ac6580153175cdd7d65a9ab21a | 35 + .../3a43d6ed6c7f14912ef4e83ada972310d391e8ac | 11 + .../3ab4c074cd1471d049ac1f69e9c73e316b12abc6 | 44 + .../3ae23066e6ca32d416573bf52ee2229db42b91ce | 1 + .../3b1dd9cc6f8bc9de8eed5355b05b8baa508052d9 | 15 + .../3b4f01db792431dd373134595aa08cc7ff84868c | 5 + .../3b9311d5a10bd7b1907ce53f0fdf0dea196e9958 | 4 + .../3bde163d787b60d1ac3ff67bbe0af0530ee38e75 | 10 + .../3bfbfe5be753aa28efc91a7a3d50aada9b6dc00f | 7 + .../3c2b83c121df18fcc68b9c8a7ae2eca64f5d90fe | 23 + .../3c561c0cda15985767ee01971a9690b95797b410 | 8 + .../3c69b57233d9b642e5049ace8a6f2d5abdde04c1 | 8 + .../3c982eeabfa96702cfb1f7e00ae1d77400be1cf5 | 11 + .../3ca4c964b9792ca5363239457e5c1420da58a1f3 | 7 + .../3cb01cf8d387cfe9ae2e23f1bfb6d0e8e98e9b0e | 53 + .../3cc0358ad28a8aa873572699c3dad054b9f4b36c | 24 + .../3d3aaf13fa606e4d1f9578525670886e42f24c5c | 9 + .../3d50175e6eec31cf51792765c26e1e52e7082e52 | 10 + .../3d5670df150b1ef15cd0b5a864b453df8b60c070 | 4 + .../3d75659fae1ba8a57edf94fcd929e838884ec628 | 93 + .../3dc6a326d54c4ad851e746c41d4f589a2a7a81dc | 33 + .../3df6ab31f8c924814d6ec41254d11b4b3734784a | 2413 + .../3eadf8140e3e4f143237295ded4432e590149796 | 24 + .../3ed6e5c140bae24b255cb44442523965ab7a42f8 | 17 + .../3f55d0379c0e80b6f010820df52b0cb386ed8c61 | 12 + .../401543482823f51516d893bd40e21f62a7095390 | 3 + .../4082d19ec13578dcd0e426fd90f95292d0fd17ba | 1102 + .../409a08aae1b84dfbd1edf7042b9668a99832f13c | 3 + .../40b77e5ae2f82dfde535ad24b584755f303fc1a4 | 8 + .../40c5aae0f98020db8a707f95d88df88bb040c9f7 | 3 + .../40c82af59b9824a310ef8b7666f7878db41d8a86 | 1311 + .../40ffa2012989f4f9e244d0cdd15602cf06b5be6a | 1 + .../4118fee45a9c3137ac87597ed92acc6b8dbf7835 | 16 + .../417dba73318503bd669248490380fa6f095fd137 | 3 + .../419195bd3ad69e448e63afd9355c2c6d18c6ed52 | 7 + .../41bdffcb56ac2aab0b529d18eed2d1df0fdbc2b3 | 1 + .../427cbae095793e5bfdd99d74aab07afd1c9ad3ca | 7 + .../42a6a0349a82750fa6c3d4c8352309d810b52d00 | 67 + .../42fee542d8ff480328efa55e776f7d86a7f785f7 | 28 + .../4329a86c75c6710c55fdaed2a83afa132269cbe7 | 21 + .../43a8002ae75dc483d657b93bf90be537f51e311b | 20 + .../43e3e620b4a80fddf9757b0654f7d88f893b45f0 | 12 + .../43ef53483f81d8d37ef3a506e188a13432a13b18 | 1 + .../43f0facfb33120a131a205db34a3fe227b4e70c6 | 24 + .../4488cc2cc0807fb5ab9bcd16ee7c9dacadb9214c | 6 + .../44a4b22ac657794f39cdda1dc9008f3226dc89a0 | 3 + .../44d64981fbbd355fecc095c46fcd91e1aa05abec | 7 + .../44f4b6c5c6540ae1bed988d4487db558e0f7bbe6 | 9 + .../4536f5776d343fcb123edece5fc1cdf5c6ed2c50 | 11 + .../45406f6ab8ec5b8e0cd3b53f1e9ddf22229164bf | 23 + .../46257dd92641aad954c2c044e970aa7ca0e2c754 | 10 + .../464c8fcee563a32e7cb205f551928eb5f4dc1933 | 12 + .../4658d404a743dceff6fc22cb94a33e6402574915 | 10 + .../46683fe43cfa4089d2f77b35d19d8ef303e084d3 | 2 + .../47424d8a8e83b35bedbf27bcfdb2ac189ee2bb1e | 4 + .../4743c78e83308ea513d4f381e8d7b31d5539ea6a | 6 + .../4781476c90a04890336cb413464e4395b77e4eca | 33 + .../47b45388a5ac65198523036beb5ab4c2a7ba46d1 | 5 + .../47c2a2a47068329771380ce60cdc1357e2c9a7dc | 16 + .../480521dea9eca7fcb11fcb91f2f7c9c4c09d6b71 | 1 + .../480818cd511bf7fa9b81336e3328d77fa158b765 | 1 + .../483f0f90e088d334f471a93ecc7f0725943c0bef | 1 + .../4852652e0e37a94d4f90572d995536b5e4ba89c7 | 12 + .../48f438485efe8c9a5c34eaf6e0024268bce6ff0c | 8 + .../49ca2a82b912ca616d9d471f3e4f5562a53b71c4 | 10 + .../4a194b0925b048e8b6291dafbfa651d5c53cd283 | 12 + .../4a2757541d7829e1f204f6dc5b208289b5eaf980 | 5 + .../4a43a4e1c4e9dfca40efb0fbd6f6d1a6411b1107 | 41 + .../4acdb070b5b06a7f4be41f3bb99069aada552179 | 6 + .../4af3620e1994108a73f1fd5a5b4ba55b35ae02e5 | 5 + .../4b5c1f8a6ceb49ff6decb04bd00b98aaf7c1b1cd | 6 + .../4b67b181831ff6621088e3ccf7c8d7b1c4fa5d77 | 1 + .../4b703fd43074948f2c72ed24ca9e17d23e25c32a | 20 + .../4bbb4624f4d93f1a3f651608645391c84c36f4b5 | 26 + .../4bea843a4333d5e29c7abc2bb499b7d450c9842d | 14 + .../4bf6ebf590bf2b858824697a241340d053fee781 | 10 + .../4c4cec9b73d30e9a3e2374b8c12688a475f9296a | 41 + .../4c9427251bffa8ec07f62d5d1ed14c5e2d4a1e36 | 177 + .../4cb66bc008b9d1e5b88463dcd2ac5793e54c5cb1 | 27 + .../4ce5ce6249ea49457dd8dfa450ff74560d6d7715 | 4 + .../4ce8dbe5d8fe97177d838802c7f0abd770c49453 | 253 + .../4d19324092ee9096d1fbf4388eb615996cc18950 | 1 + .../4d4c13117d6e9ed6a34c2788fafb71b817303efe | 1 + .../4e4027f40b8e1c1a6ba70d29349f4bbdf8fd8ce4 | 15 + .../4e9ded0041672e93f57529a3f4eac76346ab9bc6 | 7 + .../4ed56ff66d71f85b09f702026ed92a7184c4e08f | 99 + .../4edd7bf919d26f02cf0aa25ed518e8ff6642e066 | 6 + .../4ee63249a9782f1c07aa0ac6765fcf805bab62ac | 1004 + .../4efbcc22ad3903c6da4503c806c257ecb49e8ee7 | 11 + .../4f0b4f0c0a1ab5357b685020fa52f6ca00f299b5 | 1505 + .../4f0e428b168f9e0c0097c13f4d27df23b3cb9e87 | 1 + .../4f1cf7603c13087f1ca2c6f7871366a830282e1e | 7 + .../4f2e0e0472d181cc8f28a17c2bc7caf508b70442 | 18 + .../4f303abba6d7b9e8480ff0b62e21c0185c1b024f | 5 + .../4fdd1e32ed7a2bfc01c5e84e2c0850efd184a7d2 | 9 + .../4ff17ce8da70de5a7c8da2509618d12b57f30156 | 32 + .../4ff2cfdf87cd976aa9c447de5dd84afd3bb5407a | 13 + .../5013d9f2aa7285f8e044bdf18606dceb8c4d298a | 3 + .../503fbe110e1acb177aa715e87571864419348239 | 1 + .../50784dd9ece4c9fe863d7e6d1f19dfd56b74cb21 | 5 + .../507c20ff48de0ee77b9edfd5468a7dd7d10c2988 | 48 + .../507f785de339557ac967f7c224f5c0bcb62c6c6d | 11 + .../50d9b549a915f5064a2c42f3c7300b8dc960e801 | 7 + .../50e38c6f79608773138f87f2a2c57fb0478848fe | 3 + .../513e1171b324de6a4ef006d844a51c23ad653416 | 2079 + .../5182a07d95e6b67cad8f2627d20b86d82e670153 | 14 + .../524f15c8a4bf2a6eff88f9369350a86b4886ae58 | 3 + .../52f1454ab8d4e723ba4f5b6e8329a675b8ddeae8 | 6 + .../532d6adc3c29f79675b7ef687de4e78970766e83 | 282 + .../5352e2f72312130f51d4ac7582d8111fe73a2915 | 111 + .../538365fe0eb2b8eddb957e393d58ce2b2964be33 | 12 + .../539a982b428e0e3ae9c2800c2d7a9dff0d9a5f80 | 39 + .../5417cf5468298cbb802d4b50a2c7887d48444217 | 122 + .../55464f8e197c6786fdd2863dcf1ad7adab2250d5 | 1 + .../555e6e4146007a7e0f75a48c3803939f54fa1c0f | 28 + .../55672fa125643998bd33dd6ee638fc2bbf9c9cfc | 1 + .../55a40d3fb150cfb1e9a4a9603b79f6572d368e82 | 9 + .../55c253c203f74e71c081d2ccd7c41c0619ed3356 | 12 + .../55fe918b256dddc9a0ae57ef1450389aff0a2e00 | 3 + .../560d8154f1460978fa0fc9e4229c14c8eac4bd51 | 17 + .../561f5175c68d68cc130bf08948b186be930f303e | 14 + .../563962cf2e742f56516404e010e70563dcdc2b02 | 20 + .../56aef1d358243504189ee0a78b856fe588f88398 | 20 + .../56b4f44bec49bbcee0cce977a8a266b834647ddc | 9 + .../56dac335de8fa2900e0e83ee4ed73d7ca9da9d00 | 15 + .../56f1391fa175711c6d1283b78972369768dae34c | 5 + .../57310dd73395497908722a558d16c8905e68f30c | 2 + .../579869ad538f409879032fecb224892dc24d3c3c | 5 + .../57f5bc58cf0f47f9300dee878113c54b7354b44a | 6 + .../58954c17802ce440f8f3e856de1203b91db0860e | 12 + .../58b308881595a707934969bc06b3c618cdee1d7b | 3 + .../58f57f2f1d0b0aa1e673c608f894a28881e73c37 | 4 + .../597ab70ad943125c31f6f968bdd2fde252e64212 | 6 + .../5a3cf187c6e1e924014f8301e3bd74d417b53792 | 7 + .../5aaf47510fc324ff42645f8a0ebe1ee0a3d70e9d | 806 + .../5af549baf4c3cb8b4d388b124707db855bcf6a5a | 8 + .../5b0f4a37988f819558110ecfddee3b92a2362077 | 1 + .../5b1b33f44dd48aeb8929d4a7daf87b178a8bf395 | 3 + .../5b2074a4c214ad1a3be4d58bd74fd47f4ff46d80 | 1 + .../5b3de5182cab27fd312aaa5255983f386f655ba0 | 2 + .../5b3fdf55aa19abd6531bcff7b036b925eedf1cb3 | Bin 0 -> 10374 bytes .../5baac57602e14608d0140d5f345f014e4e46ef22 | 275 + .../5bb8c285d98615ef25b44894a73dfd00b3d7ff25 | 7 + .../5bbfae7061d2f7091265014f9c6aa5b7211f0e15 | 14 + .../5c15a9f0773b83943aed2431841a30313a048970 | 23 + .../5c1c50b69371c23acc7cfd00560a0b8297e4a2e1 | 4 + .../5cfb92ac6c6c7e8e0b2a7382b69c057f60521a43 | 5 + .../5d0bb7643ee98b79f8b765e4fbd1ac5c7bdc559c | 2 + .../5d2f869e80b1b6b121e6b0d627529e50212cd112 | 13 + .../5eca276cdaa08ea3a53693aba3670a451e53905e | 5 + .../5f16b42510c4d4972269b88408507b9a928f1c37 | 19 + .../5f319f08e3c52d2d2fd1932309ab118cd1623ed2 | 7 + .../5f5f3a69819ce2049ff5b1f9c8e3cad2cca963a9 | 3 + .../5fb13e5aba1bfdac70b6a309ef596623e004a2b9 | 7 + .../5fc7c4b6db220782517635f7711ca8388c728f0e | 2 + .../600a34d4da4a6fc71015b65c039c68447b5b7a28 | 4 + .../60fe79dc22db48c99f1527da238e35c37ffdbb02 | 27 + .../616205f0905dfe0af385e82a68275dab02746c60 | 851 + .../616f8ed5c640e2a0df8f17d1a8a3d3e2f3cfe093 | 229 + .../61c137a2d172157a9636a814c7b2e88a3cc16f27 | 972 + .../61daa071fecd91e30c36bf5ff9f09676f54e477d | Bin 0 -> 98 bytes .../627ec43b7388a228fcdc30ebcd9b3bd5b14bc84d | 19 + .../628cc9031030cbb14613eb0e821e5032c87bfca2 | 17 + .../62aa12471846f560d51fac5ee1b83c15dec6bb2a | 12 + .../639a043a6fd2802e99bc12a93475c143479cf1c7 | 9 + .../639c88003025596bfab25bcb5890f8be11ad7c80 | 19 + .../64d101bddef3caa00b9c816400de68db34e5c69a | 16 + .../656cdb2768a229123d7ceccd4d70d4a07e3a8e8e | 1 + .../656e7de87d66733aca5e29a05713ae9414377dbd | 5 + .../6570af3254bdeb56c2604569dd7e6299dafc3e44 | 23 + .../658df221c6641622c83b0440879a58a53ed7eb73 | 36 + .../6592fc5e65ce07cc6f1d860231ca614255d2eb82 | 7 + .../66397361ea0cd879565fce9fd5091ab38b0b5c4d | 7 + .../671a654d51aa9e2dc3006e715af08668c8998682 | 34 + .../672a6c9387c4b738c650e03058bd4af4cbd112ff | 16 + .../6735bb0236484acdaf1fb09097d8461ce25f7ff3 | 7 + .../677b126fac521c3333e2964692f55eb9991a3f14 | 5 + .../67b597d5c85d0f80d6354a253a1fbdd83931066b | 20 + .../6837c85f0d43aaefa7a2cf240118cf25b082ca91 | 3 + .../683f55a4b2e3d5d79de93da904a6f9b5ffca90bc | 13 + .../68924ed2f6378dba57b8d7ece7595d8837fa3763 | 5 + .../68a952113a08cd3fc90f7cfd53a651efc5042cbd | 33 + .../68c51ab273511385a5d511c6840063e745e68aca | 23 + .../697e6f3800afb5879e0128864027efd2794353eb | 5 + .../6a09daa4480137ab69dfbfc1aaca44b5b73577f5 | 25 + .../6a1b89be3f3b76f3d1186b1901831959a642276e | 4 + .../6a3bf591f45d93c6c89edbb804e2148dcd911e1f | 11 + .../6aa57746a1aad289d984e7580b7160b0b371fcf7 | 1 + .../6aaa42de07dd5b363f7ededbfbae922c8fa2490e | 111 + .../6abd8fb5d1ab4d116daf4429678ca9bb0947e51b | 1 + .../6ae10aeb6fd0f9346db450029b0c1a06738a77a3 | 8 + .../6b3f3b53af613de99f9d50a42fb28b6c98ff7f9e | 66 + .../6bb5f98c0532382370c94c29910d06ce65ed2e36 | 96 + .../6c78a975633639ff2e3214dc4cfd8b280405a276 | 10 + .../6c9ca209c620ccc5b6feb7aeb546a20afd7d80d6 | 17 + .../6d1a623334c2a5a928192d4edfb971be0f584b42 | 16 + .../6d93d9820e7b8f16da82c94a4bb2386b4abaa1f8 | 2 + .../6da35dbfced7087910ad73348df7ff8a395a3c32 | 5 + .../6ea1d8bab04f9cef7f5704850f74a21b0bf55230 | 4 + .../6eaf066f91ef68a2668e2ac83ede7d1bed8a899d | 6 + .../6ebd108c726bd5379ebd60e9e85b58f1fa1e6289 | 343 + .../6ee4a7f863fe05823a2640a3c040fab72abce298 | 6 + .../6f60864db263a826653e36f59579336df447313d | 7 + .../6fbe3a751d4a6e5c82c26fabda5c41ca9b097833 | 5 + .../6fd3150c77c1067333f444472c8a9d74cbc39116 | 1 + .../701b2b9e1218eb518a7ec30ec71b474c8c9dcadd | 19 + .../705a3c3778f48975bed31e1e9bd72b3de2426e02 | 11 + .../71375f731776dcad926888e614d139763da17b9f | 21 + .../71511f010813ef7a90ce1eaf18d4f6f6aae88f9a | 7 + .../716a187708f9fde686d26d56d5639fbf916f64e2 | 20 + .../71dbd4ef4bda3e726cc9ce3daca1e56fe33a02fd | 8 + .../720fea1a8439bb20b10fd64a3e84fc8d3efde291 | 10 + .../7236669e099aaa4dac168e5ffb2abb0804016506 | 43 + .../72b3c8f8967f260de2a05e0e9978ec0136dc2cd0 | 7 + .../7306ab382f44b9481eb079c245bba6d2c412018c | 79 + .../7326dc66f20c41c41aaaebbcf12f02a716b9bff9 | 13 + .../733825ed3f72e15c43e243ec4c5e91e4719bb486 | 1 + .../73589b6ebbdfb9b56e27e47d37f451a27083dfc3 | 2 + .../737300f263749bbb1e349d2b79daa8055c2e4511 | 12 + .../7395743f1738a28d98df08deb700f18eb9669867 | 60 + .../73b1ef9f2bd6a869854af4befb12b3485e3c621d | 3 + .../73fe3cf2705d803262c7d7903e24fd0c89686bbc | 36 + .../741bc7f1a0bcc05c05328c39ddc541c41fa86082 | 5 + .../742928dec5d193cd93774db31ae0eb9b9c412b4d | 9 + .../74b47ceb2af543ec62b2c3925d76ef7c86383bf6 | 9 + .../74c22ea74f3df081095861f7a8e7db2a73d6b928 | 11 + .../74e57dd82b745f81379d53fe84f0d89dd668bc3d | 8 + .../74fa7a7901379ffe690ba9b471bc74995bb5302c | 498 + .../750c15ca3c858f9880c1127450118b4d94598c96 | 7 + .../75188bed69917fd60549ec46a8dfded0364af9f5 | 3 + .../754e7a4d805c02735bb3ea29acacda16e79d7367 | 8 + .../75976256975be166dbd17c861bd59cf3af76ee23 | 119 + .../75a7a83756947e988df92e4c449c01bbca9bd18d | 3 + .../75e0e6e7449e64982bfa5dda52ad9a239ae89cf8 | 13 + .../75e496951d439ff1c85071904e5a83a01e5a9555 | 69 + .../75ead4ce617162e5eb3e2ffc33c4f2f8826614c4 | 11 + .../7640bed796785a43dbabce33e359ec6cb777275e | 18 + .../765b92b183650022c8828e2249e9f0161712f123 | 3 + .../7692c5aefdd5a1e43595e3d61b1afd0e025104dd | 12 + .../76a7c7ba72492e944863c9067fe6bb6b4323d006 | 12 + .../774d96e7e04c32f0b5e4b9ae545421d0f550b25d | 12 + .../776150e93fd52b4eed4c713ff033886cd051f12a | 5 + .../77ebf6c9faa3011ffe21fd373bcf24c9930caea4 | 30 + .../780ff3212a9dfc11ec0ade964d36066289df20b2 | 1 + .../7872b3c54d64a73f1ba61e95d3058f21d21c00f6 | 7 + .../78a7e6c6c82b095036be729e3240939f8d05141b | 1 + .../790b51f10d107a5d311973297211d6e7d4be4ea1 | 1 + .../79453c6b9b66e27860684227f2bf18f628122cf4 | 1223 + .../79691b43957989a7ac01dbaf765109f53b0c2f6c | 35 + .../7989e60b91f860c4e7e59060d2eda94038b91a5c | 2 + .../79feaa14e0272d4920f0668fdbf2c809110eceec | 5 + .../7a060dde82e3692da7fc95108145a86ce85b9f3d | 144 + .../7a35b45a813cdb47f0c8dfff5afd0caa3eb9a19e | 15 + .../7a59f97c7e838d967f0222b77ad65a4c9e9c3eb3 | 8 + .../7a629aa047f6cecaf17ec48d79d58c535277ca0e | 6 + .../7aa5de3e001eff1ecaa37566fd45342bf6ffcb98 | 8 + .../7af10d0ae984ef19d8db1268df1eec2d420f1374 | 2 + .../7b07c8e1083c71288120e57950f95b0f28cc0eff | 1 + .../7b46ce0b61f4bc2b7fa72c2921c85caf34a910d7 | 22 + .../7b60a73d9e8ebc85bd25531ee58238f3650a31ef | 1 + .../7b8c31b8c3dad1ff9b943cd0ad0b6db25a4f20b0 | 24 + .../7b917fc10629b19c40df0eb76cc82e64deb137db | 3 + .../7baca30e020070ddde4b2fcae7c72c5caa7cf178 | 24 + .../7bb0f3f2a9714927663d90b40580969592f5989b | 15 + .../7bc19bc980a07fec3523ee9ada0b3ddee1fa774b | 8 + .../7c0fcbbc3a9add6cbe45167c553f2f26433d0c5f | 2 + .../7c211433f02071597741e6ff5a8ea34789abbf43 | 1 + .../7c2e5e524d126fb3df8144599b3b6f05b81570ac | 22 + .../7c85c028ae7d172131b6f464bde9f32826e94ef5 | 4 + .../7cb1dc4d1a66084e136cec80191db79004f7d881 | 11 + .../7cd16a6770cbde1158be465442a8d2f6d3ee6151 | 10 + .../7ce0cb194006f3f9446b13257e532181ccb4d690 | 8 + .../7d0e97685b4f2b497b8afc5be617b6725f042f5d | 3193 + .../7d62086ba1a855963273de7fe48d3dd03373e3c7 | 3 + .../7d7b180aa02ec5614ede7215ee71a2da5ada9c8f | 1 + .../7d8a71f28307f5fde233975b156ce0c7753d6e80 | 1 + .../7da9aadc61efbf87721a356af3254d37eb2c0f20 | 1 + .../7de13be5eeb2eecaf2cdc74d0c2bd0ea6b7c6321 | 6 + .../7e4e69c985366bf1858406110a39892313a7c493 | 13 + .../7e641e43a098f4fab7665342745c10c28e89939a | 8 + .../7ebc3a901368f17eb0b187ffc0491400e12fe9b9 | 2 + .../7ed60fa7c3717de45b17ee68ec1783c7480d58a1 | 43 + .../7f0abc1c206fe282b9c426ac221c78bbb0814173 | 16 + .../7f47e1db739cfe08b61962939dbd91a764e26b0e | 4 + .../7f621cd731ad008c88ebb4f78ffe9e1cc3a5b15f | 14 + .../7fde29284068ea511b9b2be6dd901afb585d8064 | 163 + .../8009a62e67818ddf363f49775f8b3e281e8fa04c | 11 + .../801d22b517df552c84c59feef532047455669503 | 9 + .../8107206fa6e510fd3b3faa09c11bc54b5f3e0b53 | Bin 0 -> 346 bytes .../810e451e6ad1f1c8680db315bb56c75941df82c7 | 18 + .../8139c334fd7029acc0185cd17ac297ba8c31f3a7 | 18 + .../813ea194416cf7a07ceb9fbbadb6ad95f1681424 | 21 + .../814696d90cc9eb8d7673dea191aa107e69f13a60 | 4 + .../81900cdf0f2e39732efec7b29854ba59dee6ff2b | 7 + .../819a7632e78054517b5e55a3040e35bb963936e7 | 7 + .../81aedd976c16631f3d4d4ac1a5e00fd2371d34f2 | 343 + .../820fa5ffd74c5e842892ebfa6b7be36d63d370b4 | 6 + .../82785abe0718426456457956f3a300b9e3ba2ea3 | 8 + .../827c33d56454cd2748018ba925dcaae7b18bc54f | 4 + .../835d34f465ab2e11016c1d47403d3883d4eacb35 | 238 + .../83d964194f3c6931cdf09f8c6aa572ee4f0a5d92 | 5 + .../83ef3875de50ff739e8734af789bd0626be0ba0d | 1 + .../83fd01d94e4c127179e05ceab010b8c948384433 | 5 + .../8417b375ee04fc01fb076db23961076133df89e5 | 4 + .../842e36feb35a81b08ef1b5aa735f8cea615e6b88 | 9 + .../846b75d8201bc4be99b7f09e9afdbea164af9e5a | 4 + .../850d7f2be8432c8de1bbca56f707ad51d0c4abe8 | 5 + .../857fca83124e5f00ec124068ce52269724f5a72b | 13 + .../8588b54ec193e3458c35a268e00797b24c0cc142 | 7 + .../859ced85aa5862070f5b29f71e3964b35313ca53 | 1 + .../86734dd3530bddd9c5f9b476e92ca59e90b2afff | 9 + .../86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 | 1 + .../877409204f0de5d4ed884498ce8daaf153b8864c | 1 + .../878356f08f838142fc384df34b3a17df61b8292a | 2 + .../87e5bf9a5001599b7129c3e25585b27d367303aa | 2 + .../884afcdfc84b1f0c7ad6f50ca6b5bc93896dd0f8 | 1 + .../8887177540290a0076f883559c2a98cffd3cc2f6 | 544 + .../88f441da69c62e97531be947885d667dc74feb0c | 1 + .../8917c5f3ef5e81df9afb1066c255d5026bfd60cc | 1 + .../89260f0b6eec54e5f08f7d84b1866c963ffe71b0 | 20 + .../8963f87b9328c9d602c9995b105074c6ec825122 | 8 + .../89c0961db858d6de841f30462694d870e1de6d39 | 19 + .../89cb2e5aa7972899aa1d0095bb78b5f48ed19c4d | 6 + .../89d905e5699bccb75f335191d92655986b943b80 | 12 + .../8a266e439cc8bdd31c8930fb82ad086ee98cc7e1 | 23 + .../8a38a42e8ed434e7fd85d3031fce504a760aa24b | 34 + .../8a9c98c29c12d19ea2446c319c2655ccb3df188f | 13 + .../8abf3faaa71c4a6765901bb7abdfb339a45c360f | 1 + .../8ac5645ab138ff454b8cd5410d6c43453f58d35b | 56 + .../8c0cf798c2168950b2ebcdb2ca17c68731a52e64 | 17 + .../8c917b16c6eb86a29207bc0dbf26e7121cb0f047 | 3 + .../8ccef0cdd6149cda4059a91943cb00549a8ca71b | 1 + .../8d1f2e6ebd62a8cae3ecdc2b3c79fae65f81628b | 8 + .../8d388f2d9c257a4dcad5264043d0b48a5ed97354 | 4 + .../8e8b74f62c484f2da007454c3f2d840d3135c34b | 3 + .../8ee397e9f2535ca02779820367212d184fc5abc7 | 18 + .../8ee4ec247ee5588249dd3736e5989afa7df33d99 | 63 + .../8eead2134322a2c7ed1795ca2ac9a447017b665b | 3 + .../8f32615410d86304e89d426982559ca7444f1c39 | 5 + .../8f8ae74202ec25228b8f03c2c1dcb22b520b2b74 | 14 + .../8fe1b82e17f7d261af3afa559576ac06006c5bbe | 7 + .../8fe51a539d8f16b217de6aa8df5aa3fa51354d4c | 13 + .../903f6155689859ec4d0acf87bc2733956e2007c8 | 1 + .../904c61a798ae76ecaef0f6158b4ef3403b20d2e0 | 36 + .../906c8ed21f324f22c94c108a3b2b2ab71e57a17c | 12 + .../90d942f05414a5e75f009b436e63b8c9aa99564b | 7 + .../9175ea05ca9c358924d31558bf8c26c24a506ed4 | 1 + .../91817b85cffb36dae26eb991977743f486ec0bd4 | 3 + .../918b86ec3933223d08a79988bf48e171a5b0cd6e | 1 + .../918ec5eb28a03b4389994c4b03448ff84244b8f3 | 9 + .../91c53a0ba38caedb6aedb428044de8690e571eb2 | 10 + .../9206fc32327e79d9444a95e9eab9873ea3c0cc24 | 11 + .../926ef7f39a5d67671db2ef56b3ad52b4021318f5 | 1 + .../928567fc69eae9e536c8cefa3b7654bf63ecc032 | 1194 + .../92c7b1ed4b5bb9fd903e941dec640be37dfeaafb | 11 + .../92cc73c67540ad637fd8890c5e44e49ebac8fb59 | 2 + .../92d264ce8685b25ce23f85cc9528833487eebdf7 | 179 + .../93f8de76de6f88df08f467f599c954c8ddc12170 | 14 + .../940863cdaeac10969e9dd60aa5dcf6ba6df4ad03 | 9 + .../943fff6ebe05ba44475aa82880008862ffaa68da | 1 + .../944c3c5375b82e3274fbc765951c97c155ca810e | 51 + .../948413ad9f30726920f53ed384ce679da6451197 | 7 + .../949dbbf408f355b6b930966198039573adf116b3 | 223 + .../94e17da53e77c29e161281f54475026bb5a11569 | 6 + .../94eff61344efe569152a192f5dd15b5576fdb3c7 | 10 + .../9524f282b0bb308fb1e9eaf213956edaf2ce0b33 | 8 + .../958a39844e0cbefb774f1971230f717a1ba3cf9a | 15 + .../9592d346a3cf7521e067d8fb016300cae1d99f5e | 4 + .../96b764d23faf6202f259ede9a3a3cc360a3f513d | 13 + .../96ba2f1e1c31550146f4f395f07f6351ed78ca3c | 22 + .../96d61008474b512bbd5508ea4d9e13fcb13ed4e4 | 12 + .../9722173218adf17b18b5e55fbe9664fae1160541 | 3 + .../98388026d03211bd53544270577d912c94deba19 | 529 + .../985fbaac3b6d3528467187f08fd8f18fb49aaf7b | 8 + .../98a842537cd90630cb5cf8c257ad890f5d03a8fc | 5 + .../98f3b9397b1eaa11e72fd584c6af99cfc2283d2f | 16 + .../98fbfa6c62c30329c879684800e4ba7a7adf6fb2 | 3 + .../99047872cfd306a40075a79e7f142c48de9dd085 | 57 + .../9906041487a221ef5aaae6b3136079f257eaa279 | 33 + .../99461fa0587d9c1dcc9bfaecbcb50d90d0f9fc9e | 22 + .../99e01d1fc129fb19ef635abcc6651e66a47824c0 | 11 + .../9a084e7bdaf5ada2b6fab19bc3f39f7a00d40cd7 | 9 + .../9a2e82d3a88590acfabb0a4b802e95e0122ed7af | 1 + .../9a41829154ea33050146281db0b71487f6752a89 | 6 + .../9aa02917d7765db4c8f9ec2cfbc83488dad5f3d7 | 20 + .../9aabee56f9cc56c02fe2519b37952ed00ea909d6 | 1 + .../9b4ccde252cfe3ed8ff6b03d3f225d0541cb2211 | 5 + .../9b6d872506e2d8e85c3cfd499375946e11c675a7 | 16 + .../9b75744b5800f2b02356669863eb7b3bb18a5e10 | 8 + .../9bc90f962db634de77a1c130aab3dcaefe9567a6 | 1 + .../9c337669960abecc2c6b681f1c12cfc457030f59 | 20 + .../9ca88b6c982c8702def62862162f877e40c71dbc | 28 + .../9cd20220c5e2e9140edf30960fbfe7ce6305d445 | 1 + .../9cecdfd2a3cdbd835d1542703bfea2288d71d3be | 2 + .../9d249724eb4ac0bdf1691e81dc64f29ec0106f82 | 4 + .../9d67253f7b024d0c5ed12e62fb2f54d3223fd20b | 1 + .../9d69c52c2b47d5ce898720d16cd59f73dce33554 | 26 + .../9d6f91da6de2e2b45a597c6bc4642cbebd11d37a | 150 + .../9dba6059f6f285ddf3e0b25ee6bc4a43b438cee8 | 7 + .../9de04ffa9771c61b055b3a79ab8114e36c5bc852 | 2240 + .../9de0bf4e8e6d38de4a71975c776f35f5249d1320 | 4 + .../9e0957ff11807ee924bb76fdadc2b01cad441b8d | 4 + .../9e11a5d29f5a4904ff2a26bfa874efec6ffc1225 | 1 + .../9e335a49fead8a4176605ff6de99c5c7c094ed50 | 6 + .../9e46cac97cd53b54068f8b61000d51beb98c1251 | 7 + .../9e71d646d2f96560c894bb4f69595012b081cbcb | 1 + .../9ee967dbb13315de75c9f1650293741282b1b8be | 9 + .../a05d91cbf0902b0fe341c979e9fc18fc69813f55 | 1 + .../a09c49e53e2f72cfc69fe1535b75e398b9e2da0a | 1 + .../a0ace750155ff7b4d004337328e0f73fff48296c | 2 + .../a12d2d35439a7b325daeae7dda813d8d9fd8ec9a | 14 + .../a15a2d4bda5afc0283b7922b22f9b2f81372b52f | 6 + .../a1a5c9bf5b4d3ea28f7aebe6a36ef925c8684e20 | 21 + .../a1c61928dc8532f92366646305c9d925515f5f4f | 39 + .../a1dcdf33e4b1c0d3dca3b36163ab1a74492dfffd | 39 + .../a217169ba383b0b37c6459e99f42351885a9cf9a | 3 + .../a2a94f5d52603abb1ae457737e115edd8570e800 | 24 + .../a2b7cc8c6f518f6e0552c467cb215aaa2cb8c789 | 10 + .../a2ffb091ea66b2c5be67d36428c637fe70bb055b | 1 + .../a351e39e1c2534d882df78962d3f836451656a54 | 3 + .../a35deba5506c7fa4a0a540463f56237e0862c224 | 9 + .../a397c927fcbce17d573ef6e6b51efda250fb2517 | 14 + .../a3e3ee2699da83f568819bb981addcb38092ae1f | 8 + .../a43e4f54e355294d149252cc0f0ce05f7cac63ad | 8 + .../a46db0975b681d55cbc40686a0cafa4b45a9a17f | 11 + .../a47f943f8458185f6adce2f55037703765f232da | 3 + .../a515ea2917796f92e9c96dec3b60f816cdd5b85c | 13 + .../a55ddf0e4881941b2bd3d3a3ebc251fda4cd26d3 | 6 + .../a5adf3a4d1833b1fc94d4903eca9686a7e845442 | 3 + .../a5f16b6b5cd78f6331ab247a3c978beaa632bede | 5 + .../a61f7009b571c49c0639e88668ee34b65a022fef | 3 + .../a66f2c59b5542bed70cd9bbf640466103a086cb1 | 17 + .../a6a6367c0ca61341ec7c77300bee0c6648467357 | 1 + .../a6d363497c7966d8af00f0f4fad5a578b484695b | 5 + .../a736ece169eac1afc7b083d22d60e6650b64d3a8 | 19 + .../a74a6dbf569e64d1117c109356151a6edd5710b3 | 6 + .../a76019df02dfbfeede9e2bec4c49b63751d3329a | 8 + .../a7c82c056aea3e1c467839b6db69f4e2015c478a | 14 + .../a7caca25f9d08d19a6acea2dd2e8acd414244e62 | 1 + .../a7de32bceaa8574c10988e703a3eb79b50fea650 | 4 + .../a825a411610ce28d84d7ea236b0891172cffd1e7 | 12 + .../a9399ac14de393924993c2e2b7cef86ecb543bd1 | 6 + .../a946c6f0e7e270604c5f2a3014cc6053d6f5a478 | 2 + .../a986aeb1ad825a9f45a0cec25a31e4ad64659627 | 20 + .../a9ebffabd9677a657a9ef44e5540e5ed517cf393 | 20 + .../aa02af41473cf07008dd6edcf33cd800414f4628 | 6 + .../aa21bdc5bc23663fe7fe93bc64abdab3e1c6c969 | 19 + .../aa4466264322911f4e340e82b8ede8c4d4e40de1 | 17 + .../aa5f416a1b24637bee0ee023c58d7d82b780af38 | 26 + .../aa7a6b9666bc5abdbafeff6ad604fee839cff4cf | 73 + .../aaa952e35e8e86cb684097528b1a02313ecf9d9e | 5 + .../aabc5ff93ae73f7eb85001270335a3fe49523298 | 14 + .../aabce40b41089adaf52c4973989ba9a4f96ef6bc | 3 + .../aad059c552093c84159931adb386895717ff34f1 | 1 + .../ab460127b776a022baebfe44e7fe099ba5f6fc61 | 6 + .../ab76f337b38a2434c70af0392982f5f0f05465ca | 8 + .../ab81bc3803000942f2e8ec4a95377bdba3b46b1f | 4 + .../ab834372595e54c6f796953decf9ee7e498f455a | 7 + .../aba1fdc077a4b189ffbffb1c0a486df597464f42 | 48 + .../acfcfe811ca61bbd0dd108e0088b9ff4e59bf546 | 1 + .../ad5a1e8e7bb5385d01789c44ee20bb43739e0231 | 8 + .../ae589c86e618d6ee0662ab077f6a56cdd2830aec | 37 + .../aef3356d35a1ef1c662976964bf605e463f0eddb | 4 + .../af3ca51d1e20efbcb7a52077d36362c489b6fb41 | 242 + .../af87d01e96497931b9b2294ad19592dfc8fcfdc9 | 21 + .../af92c19e28175ffedb2e4e057e525000c8957aa8 | 12 + .../afdd6ffe65a766b43299ec8c12d12a43bd65e770 | 28 + .../b01cece4a6652972462aef17952e990ea33978d1 | 1258 + .../b07412ff29ba83b3e65d270d9185583a9cc549d5 | 6 + .../b088b9b031752adc71958aceebc53e140cc7b745 | 10 + .../b0d9f006a7407b4b19712b85948a441920e0f087 | 17 + .../b1cae8bc746a5f0c90e837a86644f14f1b8a61f6 | 1 + .../b2b4e17c2181218c026883f4c37ffd575970433d | 23 + .../b2cd7fc6e6ee01c4ff356cd89c8070a5654d722d | 20 + .../b2debffda9a50311d654f3e56bdb22d144192b25 | 6 + .../b2eb9577cac455e58141bf0eccb73e8064a45c42 | 4 + .../b304d40c287feafe05f482628ddbde4f5f7b1336 | 1 + .../b31d7370c53d261b0fdbdfb6da2faa257967ee1d | 3 + .../b3268aeb1a6072253a1f47b703f6793766f61e6d | 61 + .../b35723dce5a5fa5cd828d57182cae241bf38bdcd | 13 + .../b3809062894fb329d7d6316c760f92437a7aed85 | 5 + .../b3a27a573559d424cdc8c229940d0755667d9e15 | 12 + .../b3b51c4f00d47f3259c2808fcf33267453afdca0 | 3 + .../b4146bf40551c98dc173d1788ab0f41acb65247f | 8 + .../b44c7604df02ba25ffa5f7223a5bf59b638ac162 | 1 + .../b5d70dc665888663f6099ff71791b3b919a95ba6 | 8 + .../b5e888307bdab943abd4b259d65c88dcaf7a7cb7 | 14 + .../b611704b84c0dc7432f806fdc918731de39dd5d1 | 3 + .../b64c4b370a571587ada55f2cdb4bf029190643ce | 1633 + .../b6d4d1c8a965aa01843fcd511a56ab50d625722a | 9 + .../b6d5046653658bb25225dd94ce6c07b0cb084d04 | 17 + .../b6f408a3a503e1d7c06e8ccd92dbcfd7eec654c6 | 10 + .../b71d03df33da644d74372c7469f533392262071e | 29 + .../b73857fa60381099a6d8627cf39f8b6c580624de | 1 + .../b7a42292653c269389c14a66d1ad85361fb2f4a7 | 1 + .../b7e3712d393926b6cb8794da4eddf040651e0fe8 | 42 + .../b7ede270b7df17a6d9c88b2c749d0e4ab85affc9 | 17 + .../b82652a86c1b0352780cda33c30760eeb166a69f | 13 + .../b8451678adf7bd03b74b089b62ea6e3532d6a85a | 4 + .../b8bb2a22a06ca43ed33ec94c1df22ec57ff3fedb | 1 + .../b9101ee7d5775e24163b8b5a5ae129103f5143cd | 4 + .../b910d78be99309f293372435a4beb19c58dae1bd | 7 + .../bbc8c30cff99d78697c62d67820b5b66175d909d | 10 + .../bc34ba5577cab989aa32e90b54e74e8f01fa7de0 | 16 + .../bc414ce2319a4395d2256621c378534061c83102 | 182 + .../bc9e0d50a6b072a7c7fc8edb5c4aa280f7481dc3 | 5 + .../bcbbb0c5f49bb7829d5836812bc63d56584dab71 | 5 + .../bd58da440a540eaaea9bfe74047fd31c9c483c52 | 8 + .../bd902356757c0a1ee644a6fd83f66730a9e76c8d | 7 + .../bdb849ba8abe7b00117e38535d7416831f8c80df | 5 + .../be56eac98f35828749978c202513175413106946 | 22 + .../be9a95e698a2e0944da7d4a23f1243ecce599875 | 5 + .../bec6cb3b489cd3f3fa596ca828a447dc6ec9a342 | 1 + .../beddada5d3d19dc39630dfd44f69ad74d5291673 | 1 + .../bedf97ed0e035cd4ab9e0fc945ec811f7d2c6e39 | 7 + .../bf29f700d6fd9e85071d12cf214db4b8e4546146 | 4 + .../bf2c5dffdd21801c84d3143a0aaf48befa3c72ba | 7 + .../bf7a039b3bd8e1dd92e8717e7cbfe1596ff5b525 | 2 + .../c00ffcb19683bce5d06900ecfed5694756a7a022 | 8 + .../c06564709f0c1936b27fcf3cafbb277df3f163c0 | 5 + .../c08d7c366ec2bcbca632b0626ecef13b28960ee6 | 4 + .../c0f62f1fdbf485e9abbbc79f6fd250ced4f16c9f | 12 + .../c18484ea6703d83675d3686201770a6a0973c776 | 1 + .../c1a5b33c0ddd62fb5efa04d43504179a96e2c232 | 6 + .../c20ea41108b8430cb59d86cb60c15e524a37db91 | 1 + .../c258f1b95eaafd8396a4f50dc9d4859f41bcdb81 | 4 + .../c26d0a6661eac07a37052737917a1a2b7d4d1681 | 1802 + .../c29c1e921a9f56339b41124453929a4afec5992d | 5 + .../c3014cb665379d148e1dea12276ce46edaaeee28 | 8 + .../c373841e84fdd1e4a2ffa813107bba145619ae5f | 13 + .../c37d07e19843eed44df009ae214a8212efbba5e3 | 12 + .../c3828414f84041f5c719ff8ea3bda92a109c9102 | 4 + .../c3e76d78bb16f3a6a328733e4dfcc24c812d85af | 15 + .../c43e7d43be7422f8f4d2e6e61ba9f700ec8e0e89 | 21 + .../c517b723b0c92f577c5675cc4948789ac6855750 | 16 + .../c556f5ce9d21845a21bf0db288303b79fe414947 | 6 + .../c5d1592b8bc0f0d16da2d176da07fa45c363760a | 1 + .../c623c7ef85b0cfb30620665505d993c4d5cb29d8 | 6 + .../c627de28402aa769f395f3db1460b2e257edccae | 4 + .../c65dca0533da176138223dd544b7a956212258d9 | 13 + .../c6c7bf0ce0efad6032bbb1431acfacdfcf9a1c04 | 1 + .../c72455f2c0a7156e0c6ecd2e6d1edae8eccb51ac | 32 + .../c7b8c43e25d751c7987ae8bd7df982074a821cdd | 9 + .../c80f7e4f796e528bffd8ab665754df3ab3c30115 | 25 + .../c82d2e61e7fe29344c2e321ba1db4353ae12dfa7 | 6 + .../c91088fb387ecb298053a47627cee65b70acfe69 | 326 + .../c913c9b25838e522b8775ea0244b6ce3feaf166d | 1 + .../c9a6d1fafdfbd7166197bf2918a3a3a7146b5fe3 | 46 + .../c9ea4b99fb7c8ba39b7cf248eb5ee3f41d2b0537 | 6 + .../ca1472b18ce12cbd062e4526259f4cb3187907be | 14 + .../caabcdc6c450ee18ad88a5fc6d593075aefa216d | 37 + .../cab9852805a552872d47b06b3595e5d4d39330e2 | 47 + .../cb0b2785b3352b163e15a1f435fea8f9b281e59d | 2 + .../cc1d57b4024554fe8675440990fd86de535a1477 | 8 + .../ccb50e4e061089731ddd7e5870a23e5d9f4eb828 | 6 + .../cd2c5d0cdf115ffc2a511a903619ec080083780d | 1 + .../cd331c7d8e0a4bfdd4f55c51f6eff362a6c3c7cb | 39 + .../cd5b68f158f64e27aac4431d102f8bde77c57810 | 3 + .../cdabfa9636c78a896945c1f46a7192fd5e5b0a7b | 13 + .../cdb76e98cb99e6ac5ad72f1efdd2aa58a883048e | 2 + .../ceef31bfd53b0799e6abcf38748ad9bb5990b9b8 | 1 + .../cf4e53a8a18f969ac9b43aeff78198c86d41f36a | 21 + .../cf6c779194b5e51558577fcf30769b56ade5e2d7 | 9 + .../cf7f942399c5a3b845cc136fa34e5ad861acdb54 | 14 + .../cffc6536c4d44d7e75e34b3dfed7f93acf4f50d5 | 1 + .../d00322e8441004cde775bb40c871b728e42be99b | 4 + .../d0570ecf8851adfd1bd51a2465e6862d8d6b2ec9 | 8 + .../d06163d6976510c6cb7da7f76c988f041cb258df | 23 + .../d0ff6fb09092fde34239c08deb10862622a818be | 13 + .../d11072038cf17c70152ca73d3069444ffbbfcc44 | 33 + .../d15e570269e7ec579721d504f093f078172e8523 | 5 + .../d1d8224f7b7a88e4b55244ea9e541e74c26a9ec6 | 23 + .../d26d73648a64321fe7fe62dc0b93cd66b2570084 | 2 + .../d2fb7a23688ec0dc72148289c3b725fad3661521 | 381 + .../d2fc6888be1d6890414aec9b8a044c8e833e32ba | 1 + .../d30ff2eef4d06f11e87d3b6538697533c53baf6d | 18 + .../d4570dfefc02165f1cdd17b23dd164560c98f297 | 4 + .../d4b04c80d79456ddd29852ff2e0f755fb9da3cfd | 9 + .../d4bece7633136a773438a856b74b90a7a18f6288 | 7 + .../d546e9f4c80cddec5cf2c0009f28261abc8b49f7 | 3 + .../d576d262b13fe5a6132d2fce3b579e7abadae94f | 196 + .../d58cd2595ea80d158f85c2b4295f4d0d5b3712f3 | 6 + .../d5d8f4fccebbb9251a71eed7f47dacd469614e16 | 1 + .../d6203ff7f7c9bcfb31249135d523ebe5a0725101 | 9 + .../d6c851486e045537153a935e0e42415fd61381d3 | 12 + .../d6e9358cf1fe2861822540c6932388340387c699 | 10 + .../d79f3ae0e96910f4fe5dd6ffd5ab8f86f56c39de | 5 + .../d7c291bdab167059f6f899e382f8f47e0b13c4f9 | 977 + .../d7f464863375cce2782560dc3b9fd9c2cdb8926a | 8 + .../d81428626958abd518d6c134d7a9ea87b5cff318 | 7 + .../d82702d7ec184d55abed27ef3ccb661946d6b8a5 | 2 + .../d8b697195e3739a40d1f319bb9694a4f950a271d | 4 + .../d8b6ee7feabb35bfc3a4d0a57cca57256a00f32e | 46 + .../d8cd7c6cbd7df0ccaf2775eb871056c8e1440492 | 1 + .../d8d8458b41bfd1be0666219c48753b978f07220d | 2 + .../d8db597176d451fd8cba11f0a2f3a10fc4cdc28c | 1 + .../d8f64185ec3cad1500438e167d9aa29c431c232a | 1 + .../d91875585187f6f307fced086265751d8d06db4b | 29 + .../d947c15aeab4efb0c9a1e94218d4f670b8b3118a | 22 + .../d9589c6b55abf58559c539e210ef83ee6d77ffa5 | 45 + .../d97616c1b428d480df45dc0cb9bfb47e1923eac4 | 18 + .../d99811f11d8cd0ed2f9773e452d52f5d698b6159 | 30 + .../d9f18950b3e5d0d82affa99864bce27bbf37318e | 1 + .../da0113f5e076c5cc48013f0bb94a647225494fdb | 9 + .../da24b9bd2c3089307c7ca096c0e3c3168f2f136e | 5 + .../da409847feb7307a2d99da1736335903e7a08c9d | 17 + .../da461c67c6e157aae3f1926e74e3c009d4c81ce7 | 22 + .../da77e89d8b7151b40e88ddd72fc12c259558fed2 | 6 + .../da8b41e4e393198ec1c82a03fae293739270d5fa | 9 + .../daa2d31781655a5b1d8446b8136b95318a0966b1 | 2 + .../db0ca64ef24fa55f812e91ac4e62c0eed8fd761e | 12 + .../dbe773660384362ed0203ab45d99676bb8f125d7 | 29 + .../dbf232a7b5d62cdaed37fd767dfd4c4bc5a2e62f | 7 + .../dc388ade7cb417aef05e482226e6ac0f6b14aa8a | 2 + .../dc79db881ce47a17d41f3fd1aa2a8ef25a39e702 | 21 + .../dcda58a9de184153339f6e034f1197971a52be9d | 1 + .../dd42a77d0a26e247393e219ae118099704fe49d9 | 38 + .../dd6b7d4ecf5e7c9d958f189612eea4e2ae76ef29 | 9 + .../ddcaee92a22818af70f51925a99fe49a493f047f | 64 + .../de782e47c0ff425acef9e69ed2add0a53e0ed06d | 3 + .../de878075f6782e9760e8c39be348d36e4c4b415d | 1 + .../defe04240669688418387bbb8e173b5f8e130bac | 30 + .../df3072782ab255b28e0d96a5227077e28181b1d9 | 4 + .../df6e3e838051c8daf8612a6c17efd8f22bbfc812 | 33 + .../df7870165674d3250df81caa6050f27cacb6b3ad | 2 + .../df898e40bbd3e5274f557d7ca2771ee917a16813 | 15 + .../e01768c294422ab08779476b523cef496b78cc4f | 21 + .../e022d6598576e548d57ca817dbc6b643894d99c1 | 21 + .../e05805587d52c07c8930c58157324b9a891db980 | 6 + .../e18853f27569684ef04566f8a6a6f7ff0f98699f | 1 + .../e1d9f0d7e34932a19083fe2d07610b95458b3f12 | 64 + .../e1dd3a83e770c4a0e2298081e3a6c6f3bf090b23 | 9 + .../e283a860ffbdc2eba98723494005fe69b9a8fdec | 14 + .../e2a0cdbc0db446b490f062e0a48dba4e3ea4ac53 | 81 + .../e2b27751d61baec65ec11a90bdb6b6bea9b6b8f0 | 2 + .../e33e55e325ec80d814bf28ca49f840353307a7bb | 14 + .../e350256d18eb9558310d1be0f28f65ededf073e1 | 10 + .../e35736ef1899750598c0d39238bb4b7fb06b45c8 | 11 + .../e3711bd4ec51bf3c4bf714e7cc03dbdfe9359c88 | 16 + .../e37c75a17d04c0f0bf59da4112e6d3786b194f7b | 7 + .../e3a53f28379e13087721b1aeb56cc3cba0a15d0e | 24 + .../e42c8c2aadd5f098057e5172cbf634f216e2993d | 8 + .../e446ff7d794da14a04824b58fb83e892a3979632 | 11 + .../e45fb8b623f480a7a5504ab0e6b6fc601d746ea0 | 2 + .../e4acd859bafa872425093eee79f9f86aaf9c40f3 | 6 + .../e4b4eb474268499df29d7bb2a9f32a327c972c19 | 69 + .../e5ddf81c4676e07f7dd05fbc9b06bb0d581e204e | 12 + .../e5f8e32c54beaaa027714bad3ad61f6197c39d47 | 2 + .../e63873194590e5597125d736bfff6609c1d9284b | 1 + .../e66ea97d349ef03ee5be65751bb22500492c7fda | 4 + .../e68268693c6cbf457c55fdffe4842ae5c2b6b0bf | 5 + .../e6878382c8b650c1b21618f674eeca251fed95d5 | 49 + .../e6ba493eb6a8bc75fd51f701327ecc645b28b36d | 3 + .../e78326a60256a40c1af7de4c242522c7a251d7a7 | 14 + .../e7eed1001cfb9e584dc49c4a45ce272eccbb2e2e | 35 + .../e850afad5db2691b9bdab3186e33e1c3fd4a2422 | 9 + .../e98f2dca1b4b0ad9090fff2718e08f8d5e76ea95 | 6 + .../e9f4d7d5f5513df4063664282feed769a1913667 | 13 + .../ea2f58cedd76ed86230f95dbe6c0552c310870c8 | 1 + .../ea307355d613abc8753b3dbb3e1c665622818f96 | 12 + .../ea3a686218a1712857a4480bcc00fb0322769112 | 23 + .../ea7a291d9f89ea7194f8ccf2691f008d4575ed52 | 6 + .../ea95fd405c17ebb43d435ed0f2dc035b55da755c | 16 + .../eadfdf6cd427e4112da2c3c92709e16293c29399 | 24 + .../eaeacf56eda88e8c339dea608655a5e5c4fad218 | 1 + .../eb0ca34c35ef83f6a22f102cf93518cd053a3021 | 495 + .../eb36d039e3d4684168e891f622ac594cc3fbaf42 | Bin 0 -> 98 bytes .../eb9e916f423bcf760684662475c708a025b95b4e | 4 + .../ebaca305f93bd06424883010a0f632a919978edf | 1 + .../ebf3b1699b7b6329fb99c382af456012e67f5179 | 53 + .../ebfdf168cbd0b6544f85ef6981e85eb3e84cac28 | 7 + .../eca395361e001e5fb922e39e07ed183adb01e320 | 10 + .../ecd7838d793f699b0486c6c324978e736ef61619 | 8 + .../ed206eab22275377ad5c1da293035b31681ddad7 | 12 + .../ed43278c90877dd1ee7697e843f546a07aad9551 | 3 + .../ed494ca370b9903b2ff256781b75a6571d1d5a11 | 7 + .../ee0a1f3873684bcf96086ce968ef405058c321a7 | 10 + .../ee1753eec5e01838716ff9cc2ea9cfc6a9515c89 | 4 + .../ee358b6c00d270f249fc2adf44e6c4a817da34b6 | 37 + .../ee576bfe8296364856100aa291be0f674fcec238 | 14 + .../ee9f91652a85a8ab60d49c264814b7eb39aa0005 | 3 + .../ef6238d1f01ecc4837c37d151e0073d64fa64021 | 61 + .../efe16059300229cc741b1e0e0b5b8dcf8bd3016a | 9 + .../effeacf25e65f710df82a417e717e1475422ca6d | 22 + .../f020f897246b789dbb0ee0546adcc31aed2a9ee0 | 5 + .../f0723ab9a1646520de4b5f31a7815d3ea7cdd51b | 32 + .../f090836861567a731c9ff9a0cc442ec2f84ecde7 | 8 + .../f0a7ed887160790e58fdc3da2ff945de1292c092 | 1 + .../f0acca34675a484e17c4a37d21d1b750802ef0e8 | 16 + .../f0cde31202f994b0a110b32e975d8e426c5fea87 | 164 + .../f0ce65ba63d77082ebf72bdd754e9974b9265385 | 19 + .../f0ed91f4691325b8d18a1bc957f1458d5986080e | 10 + .../f1741ff0cf92c3fcc2457b0ddeaf361c641e1f7f | 177 + .../f1860ac11f7e00cf33f11cdae78eb6dea2e5cc4e | 9 + .../f1f92206392a06f94ae57ecf1a2633a1abad6e23 | 10 + .../f209388ec3e50da32cb1d6300f187ecfb56ddd5b | 1708 + .../f26b7b6046881d29051125a558146bad500d9ea9 | 112 + .../f2de7fa0a17499f6b233db120d5a1a18ef440f00 | 4 + .../f310c45fdfa4895fcb578cf5a4267bcfe0da0bf5 | 18 + .../f312081b10d97bf57c9aa4b3edc9119a285daca7 | 13 + .../f559e4a5a9778ee70994b3f5e5717dd65ec50be6 | 1 + .../f596ecbc4c176f72de5c9b96bf7a3b4372c297ff | 28 + .../f60cdbe3f8ed30f11ffff0fa13fd0f1bbdb74f9f | 10 + .../f611b5aff1df08a9ef90a9ab3b8eb2c7066fd5d7 | 13 + .../f6367e7d51f3131f915ebdb0dea0ab7d85996abf | 3 + .../f6b84f405673899265d312a025824cffaf3c5602 | 16 + .../f72ac7db80028034dbce84de2aba0d3c9130d83a | 11 + .../f7414f33a411a27a9f58a8fd7a13ac0dc538ee35 | 1 + .../f755658e54ba2c60b31185eb6dc8a8e4a45f2ff1 | 5 + .../f7c6d96423611b00e09749905ddd73fac4da09fa | 2 + .../f80b1212109606ae9430eb0798a9274bb965df1b | 5 + .../f82ce14867e33546972cfe50f05ded5f345ca2a9 | 9 + .../f8ad4720f083362a24c5963814415c7be11a7e79 | 227 + .../f915aa5bc416b6bdd19e7c0b0f6b4c19953a29f8 | 33 + .../f94f6f4d473d9c94bfe19ca2c9974fe789ed89da | 13 + .../f9546aaaffe76c7a4b3afc0eb9a312799ce40ea5 | 11 + .../f96987a68d8061bb01bd1eeacbfca277e032012c | 22 + .../f9c716c6e1f3ac4e832f55dc011bfe4085a01db8 | 3 + .../fa4d70596680927bfd981d5241a7da346beeb3ed | 12 + .../faafa8ee7573f5bb95383ccfeb954bf381d20908 | 516 + .../fabeea396572fe8077d643f7a4669a6d88ae0ffe | 26 + .../fad544376cf60a6890cf92176fa131711462b407 | 7 + .../fada6bbfeb016ac55774da7e82d09d0d337ebea9 | 26 + .../fb423796352beb7e2c43e48123b5fd618e81ee54 | 1 + .../fb676b7944c1360a8a6a548cf3e3b03573f1c154 | 27 + .../fb72df780abbd6764dfe18e2ddd8ca4c58faf92f | 51 + .../fbc675a6b2d1a45be278954494ee34d4c2324245 | 3 + .../fbcdd7a1e0f5b2e115172130a7c514ac9a6dd62d | Bin 0 -> 256 bytes .../fbd91b3106732ac8dbbb4e004059863e5f52c13c | Bin 0 -> 344 bytes .../fbddeb5bcd495bea003d6cb25fd30b7e3116db11 | 107 + .../fbfe47c7706c079e2c44afee40e3524c2440029e | 3 + .../fbff3217c31fb539f0569beb0d664343ede5cc40 | 334 + .../fc06ad946ed7f4571e5930d6a384c659f84c4188 | 10 + .../fc3356c1ca991cf185c46c51a64a12d8f2c493be | 1 + .../fca35dd48ecd9ca7c40e2da79be8eb85576afbcf | 21 + .../fcb613d231528bc7d607472cd2cab2a5e0f67691 | 3 + .../fd04e1aa723bcb93112c09c67a15490942737641 | 30 + .../fd63b95f8af23f1259eb5a65024ad98c3d05cb51 | 42 + .../fd936eb09ddf3f09ee1f0fecfd3fae7e18e1dc12 | 7 + .../fdd2445027e39637bb4167d42d309b3e84f0c864 | 7 + .../fe2353aca291b4df4bd6f4e86038d3e079551ca6 | 13 + .../fe2f2896838152f14b4515fad701da97e6ebb34c | 22 + .../fe331c4e77bd414496d817c48d65dad2ef5ca715 | 8 + .../fe47d9336fd3bd30d01191bce1a0abfce0622a71 | 5 + .../fe656c49ba6f5f55afc0560faf29542ce744d8f2 | 17 + .../feaddd2bfb7ee62a7fdbde7891b47e1633387800 | 9 + .../febb40c376d47ed2104875a83128d287c32a5596 | 1 + .../fed9e49575133eeb6fd117175447e2ebb69cb99c | 6 + .../ff0ecae15d2a85c2565c63a7581d534173b0010d | 18 + .../ff80ec4e56255991bed8921019f2d413767a2fed | 4 + fuzz/seed_corpus/input0 | 1 + fuzz/seed_corpus/input1 | 53 + fuzz/seed_corpus/input10 | 2 + fuzz/seed_corpus/input11 | 6 + fuzz/seed_corpus/input2 | 19 + fuzz/seed_corpus/input3 | 1 + fuzz/seed_corpus/input4 | 1 + fuzz/seed_corpus/input5 | 1 + fuzz/seed_corpus/input6 | 5 + fuzz/seed_corpus/input7 | 1 + fuzz/seed_corpus/input8 | 1 + fuzz/seed_corpus/input9 | 3 + fuzz/xml.dict | 125 + libxml_visibility.gni | 13 + linux/config.h | 291 + linux/include/libxml/xmlversion.h | 485 + linux/xml2-config | 110 + mac/config.h | 293 + mac/include/libxml/xmlversion.h | 485 + src/AUTHORS | 5 + src/CMakeLists.txt | 772 + src/ChangeLog | 19678 ++++++ src/Copyright | 23 + src/HTMLparser.c | 7287 +++ src/HTMLtree.c | 1200 + src/Makefile.am | 1327 + src/Makefile.tests | 41 + src/NEWS | 3085 + src/README | 40 + src/README.tests | 39 + src/README.zOS | 212 + src/SAX2.c | 3036 + src/TODO | 278 + src/TODO_SCHEMAS | 31 + src/acinclude.m4 | 28 + src/aclocal.m4 | 1450 + src/buf.c | 1351 + src/buf.h | 72 + src/check-relaxng-test-suite.py | 394 + src/check-relaxng-test-suite2.py | 418 + src/check-xinclude-test-suite.py | 221 + src/check-xml-test-suite.py | 409 + src/check-xsddata-test-suite.py | 420 + src/chvalid.c | 336 + src/config.h.cmake.in | 288 + src/config.h.in | 292 + src/configure.ac | 1728 + src/dbgen.pl | 43 + src/dbgenattr.pl | 42 + src/dict.c | 1298 + src/elfgcchack.h | 17818 ++++++ src/enc.h | 32 + src/encoding.c | 3975 ++ src/entities.c | 1165 + src/error.c | 998 + src/fuzz/Makefile.am | 140 + src/fuzz/Makefile.in | 973 + src/fuzz/README | 19 + src/fuzz/fuzz.c | 355 + src/fuzz/fuzz.h | 91 + src/fuzz/genSeed.c | 427 + src/fuzz/html.c | 82 + src/fuzz/html.dict | 124 + src/fuzz/regexp.c | 47 + src/fuzz/regexp.dict | 155 + src/fuzz/schema.c | 44 + src/fuzz/schema.dict | 55 + src/fuzz/seed/regexp/branch-1 | Bin 0 -> 21 bytes src/fuzz/seed/regexp/branch-10 | Bin 0 -> 22 bytes src/fuzz/seed/regexp/branch-11 | Bin 0 -> 21 bytes src/fuzz/seed/regexp/branch-12 | Bin 0 -> 22 bytes src/fuzz/seed/regexp/branch-13 | Bin 0 -> 22 bytes src/fuzz/seed/regexp/branch-2 | Bin 0 -> 21 bytes src/fuzz/seed/regexp/branch-3 | Bin 0 -> 22 bytes src/fuzz/seed/regexp/branch-4 | Bin 0 -> 22 bytes src/fuzz/seed/regexp/branch-5 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/branch-6 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/branch-7 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/branch-8 | Bin 0 -> 21 bytes src/fuzz/seed/regexp/branch-9 | Bin 0 -> 22 bytes src/fuzz/seed/regexp/bug316338-1 | Bin 0 -> 71 bytes src/fuzz/seed/regexp/bug316338-10 | Bin 0 -> 487 bytes src/fuzz/seed/regexp/bug316338-11 | Bin 0 -> 85 bytes src/fuzz/seed/regexp/bug316338-12 | Bin 0 -> 88 bytes src/fuzz/seed/regexp/bug316338-13 | Bin 0 -> 89 bytes src/fuzz/seed/regexp/bug316338-14 | Bin 0 -> 93 bytes src/fuzz/seed/regexp/bug316338-15 | Bin 0 -> 500 bytes src/fuzz/seed/regexp/bug316338-16 | Bin 0 -> 1355 bytes src/fuzz/seed/regexp/bug316338-2 | Bin 0 -> 74 bytes src/fuzz/seed/regexp/bug316338-3 | Bin 0 -> 75 bytes src/fuzz/seed/regexp/bug316338-4 | Bin 0 -> 79 bytes src/fuzz/seed/regexp/bug316338-5 | Bin 0 -> 487 bytes src/fuzz/seed/regexp/bug316338-6 | Bin 0 -> 71 bytes src/fuzz/seed/regexp/bug316338-7 | Bin 0 -> 74 bytes src/fuzz/seed/regexp/bug316338-8 | Bin 0 -> 75 bytes src/fuzz/seed/regexp/bug316338-9 | Bin 0 -> 79 bytes src/fuzz/seed/regexp/bug420596-1 | Bin 0 -> 25 bytes src/fuzz/seed/regexp/bug420596-2 | Bin 0 -> 25 bytes src/fuzz/seed/regexp/bug420596-3 | Bin 0 -> 25 bytes src/fuzz/seed/regexp/bug420596-4 | Bin 0 -> 25 bytes src/fuzz/seed/regexp/bug420596-5 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/bug420596-6 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/bug420596-7 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/bug420596-8 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/content-1 | Bin 0 -> 17 bytes src/fuzz/seed/regexp/content-10 | Bin 0 -> 33 bytes src/fuzz/seed/regexp/content-2 | Bin 0 -> 17 bytes src/fuzz/seed/regexp/content-3 | Bin 0 -> 18 bytes src/fuzz/seed/regexp/content-4 | Bin 0 -> 17 bytes src/fuzz/seed/regexp/content-5 | Bin 0 -> 32 bytes src/fuzz/seed/regexp/content-6 | Bin 0 -> 33 bytes src/fuzz/seed/regexp/content-7 | Bin 0 -> 34 bytes src/fuzz/seed/regexp/content-8 | Bin 0 -> 35 bytes src/fuzz/seed/regexp/content-9 | Bin 0 -> 40 bytes src/fuzz/seed/regexp/hard-1 | Bin 0 -> 37 bytes src/fuzz/seed/regexp/hard-10 | Bin 0 -> 28 bytes src/fuzz/seed/regexp/hard-2 | Bin 0 -> 38 bytes src/fuzz/seed/regexp/hard-3 | Bin 0 -> 41 bytes src/fuzz/seed/regexp/hard-4 | Bin 0 -> 37 bytes src/fuzz/seed/regexp/hard-5 | Bin 0 -> 40 bytes src/fuzz/seed/regexp/hard-6 | Bin 0 -> 39 bytes src/fuzz/seed/regexp/hard-7 | Bin 0 -> 29 bytes src/fuzz/seed/regexp/hard-8 | Bin 0 -> 33 bytes src/fuzz/seed/regexp/hard-9 | Bin 0 -> 27 bytes src/fuzz/seed/regexp/ncname-1 | Bin 0 -> 19 bytes src/fuzz/seed/regexp/ncname-2 | Bin 0 -> 21 bytes src/fuzz/seed/regexp/ncname-3 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/ncname-4 | Bin 0 -> 21 bytes src/fuzz/seed/regexp/ncname-5 | Bin 0 -> 23 bytes src/fuzz/seed/regexp/ranges-1 | Bin 0 -> 8 bytes src/fuzz/seed/regexp/ranges-10 | Bin 0 -> 18 bytes src/fuzz/seed/regexp/ranges-11 | Bin 0 -> 16 bytes src/fuzz/seed/regexp/ranges-12 | Bin 0 -> 19 bytes src/fuzz/seed/regexp/ranges-2 | Bin 0 -> 9 bytes src/fuzz/seed/regexp/ranges-3 | Bin 0 -> 10 bytes src/fuzz/seed/regexp/ranges-4 | Bin 0 -> 11 bytes src/fuzz/seed/regexp/ranges-5 | Bin 0 -> 12 bytes src/fuzz/seed/regexp/ranges-6 | Bin 0 -> 13 bytes src/fuzz/seed/regexp/ranges-7 | Bin 0 -> 14 bytes src/fuzz/seed/regexp/ranges-8 | Bin 0 -> 15 bytes src/fuzz/seed/regexp/ranges-9 | Bin 0 -> 17 bytes src/fuzz/seed/regexp/ranges2-1 | Bin 0 -> 17 bytes src/fuzz/seed/regexp/ranges2-10 | Bin 0 -> 42 bytes src/fuzz/seed/regexp/ranges2-11 | Bin 0 -> 43 bytes src/fuzz/seed/regexp/ranges2-12 | Bin 0 -> 43 bytes src/fuzz/seed/regexp/ranges2-2 | Bin 0 -> 18 bytes src/fuzz/seed/regexp/ranges2-3 | Bin 0 -> 17 bytes src/fuzz/seed/regexp/ranges2-4 | Bin 0 -> 18 bytes src/fuzz/seed/regexp/ranges2-5 | Bin 0 -> 19 bytes src/fuzz/seed/regexp/ranges2-6 | Bin 0 -> 20 bytes src/fuzz/seed/regexp/ranges2-7 | Bin 0 -> 18 bytes src/fuzz/seed/regexp/ranges2-8 | Bin 0 -> 18 bytes src/fuzz/seed/regexp/ranges2-9 | Bin 0 -> 41 bytes src/fuzz/seed/regexp/xpath-1 | Bin 0 -> 181 bytes src/fuzz/seed/regexp/xpath-10 | Bin 0 -> 212 bytes src/fuzz/seed/regexp/xpath-11 | Bin 0 -> 181 bytes src/fuzz/seed/regexp/xpath-12 | Bin 0 -> 183 bytes src/fuzz/seed/regexp/xpath-13 | Bin 0 -> 183 bytes src/fuzz/seed/regexp/xpath-14 | Bin 0 -> 182 bytes src/fuzz/seed/regexp/xpath-15 | Bin 0 -> 191 bytes src/fuzz/seed/regexp/xpath-16 | Bin 0 -> 181 bytes src/fuzz/seed/regexp/xpath-17 | Bin 0 -> 241 bytes src/fuzz/seed/regexp/xpath-18 | Bin 0 -> 204 bytes src/fuzz/seed/regexp/xpath-19 | Bin 0 -> 262 bytes src/fuzz/seed/regexp/xpath-2 | Bin 0 -> 241 bytes src/fuzz/seed/regexp/xpath-20 | Bin 0 -> 181 bytes src/fuzz/seed/regexp/xpath-21 | Bin 0 -> 277 bytes src/fuzz/seed/regexp/xpath-22 | Bin 0 -> 337 bytes src/fuzz/seed/regexp/xpath-23 | Bin 0 -> 277 bytes src/fuzz/seed/regexp/xpath-24 | Bin 0 -> 279 bytes src/fuzz/seed/regexp/xpath-25 | Bin 0 -> 282 bytes src/fuzz/seed/regexp/xpath-26 | Bin 0 -> 281 bytes src/fuzz/seed/regexp/xpath-27 | Bin 0 -> 281 bytes src/fuzz/seed/regexp/xpath-28 | Bin 0 -> 287 bytes src/fuzz/seed/regexp/xpath-29 | Bin 0 -> 295 bytes src/fuzz/seed/regexp/xpath-3 | Bin 0 -> 181 bytes src/fuzz/seed/regexp/xpath-30 | Bin 0 -> 308 bytes src/fuzz/seed/regexp/xpath-31 | Bin 0 -> 277 bytes src/fuzz/seed/regexp/xpath-32 | Bin 0 -> 279 bytes src/fuzz/seed/regexp/xpath-33 | Bin 0 -> 279 bytes src/fuzz/seed/regexp/xpath-34 | Bin 0 -> 278 bytes src/fuzz/seed/regexp/xpath-35 | Bin 0 -> 287 bytes src/fuzz/seed/regexp/xpath-4 | Bin 0 -> 183 bytes src/fuzz/seed/regexp/xpath-5 | Bin 0 -> 186 bytes src/fuzz/seed/regexp/xpath-6 | Bin 0 -> 185 bytes src/fuzz/seed/regexp/xpath-7 | Bin 0 -> 185 bytes src/fuzz/seed/regexp/xpath-8 | Bin 0 -> 191 bytes src/fuzz/seed/regexp/xpath-9 | Bin 0 -> 199 bytes src/fuzz/seed/uri/dot | 1 + src/fuzz/seed/uri/full | Bin 0 -> 36 bytes src/fuzz/testFuzzer.c | 188 + src/fuzz/uri.c | 48 + src/fuzz/xml.c | 104 + src/fuzz/xml.dict | 89 + src/fuzz/xpath.c | 52 + src/fuzz/xpath.dict | 94 + src/genUnicode.py | 478 + src/gentest.py | 989 + src/globals.c | 1126 + src/hash.c | 1146 + src/include/Makefile.am | 5 + src/include/libxml/DOCBparser.h | 96 + src/include/libxml/HTMLparser.h | 306 + src/include/libxml/HTMLtree.h | 147 + src/include/libxml/Makefile.am | 54 + src/include/libxml/SAX.h | 173 + src/include/libxml/SAX2.h | 178 + src/include/libxml/c14n.h | 128 + src/include/libxml/catalog.h | 182 + src/include/libxml/chvalid.h | 230 + src/include/libxml/debugXML.h | 217 + src/include/libxml/dict.h | 79 + src/include/libxml/encoding.h | 245 + src/include/libxml/entities.h | 157 + src/include/libxml/globals.h | 508 + src/include/libxml/hash.h | 236 + src/include/libxml/list.h | 137 + src/include/libxml/nanoftp.h | 163 + src/include/libxml/nanohttp.h | 81 + src/include/libxml/parser.h | 1243 + src/include/libxml/parserInternals.h | 644 + src/include/libxml/pattern.h | 100 + src/include/libxml/relaxng.h | 217 + src/include/libxml/schemasInternals.h | 958 + src/include/libxml/schematron.h | 142 + src/include/libxml/threads.h | 89 + src/include/libxml/tree.h | 1311 + src/include/libxml/uri.h | 94 + src/include/libxml/valid.h | 458 + src/include/libxml/xinclude.h | 129 + src/include/libxml/xlink.h | 189 + src/include/libxml/xmlIO.h | 368 + src/include/libxml/xmlautomata.h | 146 + src/include/libxml/xmlerror.h | 945 + src/include/libxml/xmlexports.h | 77 + src/include/libxml/xmlmemory.h | 224 + src/include/libxml/xmlmodule.h | 57 + src/include/libxml/xmlreader.h | 428 + src/include/libxml/xmlregexp.h | 222 + src/include/libxml/xmlsave.h | 88 + src/include/libxml/xmlschemas.h | 246 + src/include/libxml/xmlschemastypes.h | 151 + src/include/libxml/xmlstring.h | 140 + src/include/libxml/xmlunicode.h | 202 + src/include/libxml/xmlversion.h.in | 485 + src/include/libxml/xmlwriter.h | 488 + src/include/libxml/xpath.h | 564 + src/include/libxml/xpathInternals.h | 632 + src/include/libxml/xpointer.h | 114 + src/include/win32config.h | 122 + src/include/wsockcompat.h | 54 + src/libxml-2.0-uninstalled.pc.in | 12 + src/libxml-2.0.pc.in | 13 + src/libxml.3 | 71 + src/libxml.h | 134 + src/libxml.m4 | 192 + src/libxml.spec.in | 209 + src/libxml2-config.cmake.cmake.in | 136 + src/libxml2-config.cmake.in | 115 + src/libxml2.spec | 209 + src/libxml2.syms | 2295 + src/list.c | 779 + src/macos/README | 8 + src/macos/src/XMLTestPrefix.h | 1 + src/macos/src/XMLTestPrefix2.h | 1 + src/macos/src/config-mac.h | 150 + src/macos/src/libxml2_GUSIConfig.cp | 1 + src/macos/src/macos_main.c | 1 + src/nanoftp.c | 2118 + src/nanohttp.c | 1899 + src/parser.c | 15571 +++++ src/parserInternals.c | 2169 + src/pattern.c | 2621 + src/regressions.py | 350 + src/regressions.xml | 226 + src/runsuite.c | 1157 + src/runtest.c | 4606 ++ src/runxmlconf.c | 607 + src/save.h | 36 + src/testAutomata.c | 309 + src/testC14N.c | 373 + src/testHTML.c | 880 + src/testModule.c | 82 + src/testReader.c | 145 + src/testRegexp.c | 402 + src/testRelax.c | 188 + src/testSAX.c | 1198 + src/testSchemas.c | 179 + src/testThreads.c | 275 + src/testURI.c | 135 + src/testXPath.c | 229 + src/testapi.c | 52376 ++++++++++++++++ src/testchar.c | 617 + src/testdict.c | 444 + src/testdso.c | 12 + src/testlimits.c | 1638 + src/testrecurse.c | 965 + src/threads.c | 1049 + src/timsort.h | 601 + src/tree.c | 10183 +++ src/triodef.h | 228 + src/trionan.c | 914 + src/trionan.h | 84 + src/uri.c | 2561 + src/valid.c | 7138 +++ src/win32/Makefile.bcb | 347 + src/win32/Makefile.mingw | 337 + src/win32/Makefile.msvc | 502 + src/win32/Readme.txt | 226 + src/win32/VC10/README.vc10 | 27 + src/win32/VC10/RuleSet1.ruleset | 3 + src/win32/configure.js | 718 + src/win32/defgen.xsl | 288 + src/win32/libxml2.def.src | 3191 + src/win32/libxml2.rc | 36 + src/xml2-config.1 | 31 + src/xml2Conf.sh.in | 8 + src/xmlIO.c | 4135 ++ src/xmlmemory.c | 1163 + src/xmlreader.c | 6033 ++ src/xmlsave.c | 2735 + src/xmlstring.c | 1054 + src/xmlunicode.c | 3179 + src/xmlwriter.c | 4738 ++ src/xpath.c | 14734 +++++ src/xzlib.h | 19 + win32/config.h | 122 + win32/include/libxml/xmlversion.h | 485 + 1319 files changed, 312728 insertions(+) create mode 100644 BUILD.gn create mode 100644 DEPS create mode 100644 DIR_METADATA create mode 100644 OWNERS create mode 100644 README.chromium create mode 100644 chromium/chromium-issue-599427.patch create mode 100644 chromium/chromium-issue-628581.patch create mode 100644 chromium/chromium-issue-708434.patch create mode 100644 chromium/chromium-issue-894933.patch create mode 100644 chromium/libxml2-2.9.4-security-xpath-nodetab-uaf.patch create mode 100644 chromium/libxml_utils.cc create mode 100644 chromium/libxml_utils.h create mode 100755 chromium/roll.py create mode 100644 chromium/xml_reader.cc create mode 100644 chromium/xml_reader.h create mode 100644 chromium/xml_writer.cc create mode 100644 chromium/xml_writer.h create mode 100644 fuzz/README create mode 100644 fuzz/seed_corpus/0046047b00a82a1fe56d88665c5f08eb2913cf03 create mode 100644 fuzz/seed_corpus/006c315fc21acb1b5ce82c7a6b355a091cb2fc49 create mode 100644 fuzz/seed_corpus/00945a5dd7a52774fdd9aead9269e5bd2f847ce2 create mode 100644 fuzz/seed_corpus/00b1bb2a809832b240779bc1e50fcd3a2ab14fd4 create mode 100644 fuzz/seed_corpus/00dafde86ff0f8c9036591cc30b72d0f7490cfcd create mode 100644 fuzz/seed_corpus/01148aca72bb87dd2df0016e94e34b04c34edfe6 create mode 100644 fuzz/seed_corpus/0199b3c9a99e71a24cd9126a922533c2b14a60c8 create mode 100644 fuzz/seed_corpus/0199e2ffeafeed2c63576109cab1131c2182c49c create mode 100644 fuzz/seed_corpus/0199fc60e9af21a3be8cbdc03622c3ebad9c2f2d create mode 100644 fuzz/seed_corpus/0212f02cef3483152bb9871fd93aa4a69ea181a6 create mode 100644 fuzz/seed_corpus/025dbaa618983aba2fd0ba6b6a803cdd0de76460 create mode 100644 fuzz/seed_corpus/0299a259ba8264e3aec403d768db7ad3a0a93e4a create mode 100644 fuzz/seed_corpus/02d7a5beb17053ac8020ed23c0489f93d39c5321 create mode 100644 fuzz/seed_corpus/034e3c37a5f06912e1ff8fc7b90a26175bccf935 create mode 100644 fuzz/seed_corpus/03713dd0e13838f82b527912f3748e2d1171fb91 create mode 100644 fuzz/seed_corpus/041ac56e4bfd93af5cc2e4aaa053f11c23c61d19 create mode 100644 fuzz/seed_corpus/049f9eb07492c4966b1f5b781bff895f3fab33c0 create mode 100644 fuzz/seed_corpus/04b1f0de43822b89a75416e2a0f4ab8da98ab9a0 create mode 100644 fuzz/seed_corpus/04c408efc27d601dbd1e91148e2e37ae969fb97e create mode 100644 fuzz/seed_corpus/04dabdaea684ba279bbf03b0ae22b366083ff7aa create mode 100644 fuzz/seed_corpus/04e0d9e30029cd448cd9c2a4c964ce012c976d90 create mode 100644 fuzz/seed_corpus/04ef401357f30717ba5862256fca75cda1436157 create mode 100644 fuzz/seed_corpus/052e9d557fe9d32b953adcdfca65788e07ead143 create mode 100644 fuzz/seed_corpus/0533c0ff80dcd22bd55bb8bc8993cd84b1b97914 create mode 100644 fuzz/seed_corpus/058df98d84d0037f011420c5c29c45e6b88bbadd create mode 100644 fuzz/seed_corpus/05f1cd6c5d6d21ae108cbcdde5e57ae914568082 create mode 100644 fuzz/seed_corpus/06060a5bfcbd6220ca5a522be3bd58dedc6bedd8 create mode 100644 fuzz/seed_corpus/064e4c40476264152302e53a5d5d68c90f36a9bb create mode 100644 fuzz/seed_corpus/0666dce9a0f535c4b9fb1af43c0239f4fae6d0fb create mode 100644 fuzz/seed_corpus/06f5fd11efe6278ce31ac322099eea1580f3cc80 create mode 100644 fuzz/seed_corpus/07028eb348b8c531e11c70e5e6acf6e44b12268e create mode 100644 fuzz/seed_corpus/0704cd3859fa29b00abc00048c8f2dc7697d2149 create mode 100644 fuzz/seed_corpus/070b97218d858e0b8633f8cb8950f0dd399fb74b create mode 100644 fuzz/seed_corpus/07e10835dd988dbe50d5b6fd31764d861be92472 create mode 100644 fuzz/seed_corpus/084e64a61efd93c01013fd8e4d5c85c06b06ed30 create mode 100644 fuzz/seed_corpus/08c7c9747d2d903aa36313b9411946c71662f377 create mode 100644 fuzz/seed_corpus/090413ef009359b0c1306316fc170553544f2b61 create mode 100644 fuzz/seed_corpus/0a204a26abfc429052d195a53e54e59546cbea8e create mode 100644 fuzz/seed_corpus/0a20515ebc673a7189a9c85df27537ce1facde25 create mode 100644 fuzz/seed_corpus/0a6fe19b30ff4214e9c0ba8de22ddfb62bab749d create mode 100644 fuzz/seed_corpus/0a8ae185eb95921dda7c1904eaf2e8eb6d86cb1b create mode 100644 fuzz/seed_corpus/0a993ba3d08d0a13561b372c1b8a5d3e699cd869 create mode 100644 fuzz/seed_corpus/0ad8a19515bb609baceb2b3945e86ef0b2e5a5fb create mode 100644 fuzz/seed_corpus/0b4909764c156be5c065dcc16c1e567b31017e9e create mode 100644 fuzz/seed_corpus/0b654d50c2764ecf5d674bca11f08afeaf54fae4 create mode 100644 fuzz/seed_corpus/0b7091f77ebe7860c8c8554eebb6765252d6e592 create mode 100644 fuzz/seed_corpus/0b9629a73f555d8289186e30d742aabbc50bcd5a create mode 100644 fuzz/seed_corpus/0badf8f46e8416ed41f758e79210a509dfb2d922 create mode 100644 fuzz/seed_corpus/0c156d7e289aa9daed03ee5219c1087f304e0ff5 create mode 100644 fuzz/seed_corpus/0c81f2be59d6e8d407560df61f70fea33f628619 create mode 100644 fuzz/seed_corpus/0c9f98eb422a59137fcf6e8368b2d91b00a5cfb0 create mode 100644 fuzz/seed_corpus/0cca701ea25dab8e47ffee1d41ae5b2fa80d75ce create mode 100644 fuzz/seed_corpus/0d187520e9f41b00153249383f24c77fd5d4cd99 create mode 100644 fuzz/seed_corpus/0d3a2bdc316b17dfbd0b7ccd44737d8caa63792c create mode 100644 fuzz/seed_corpus/0d3d85ffa5363ae5691afddfb0a630d45739179a create mode 100644 fuzz/seed_corpus/0d553bbcd73a23a541c68ffdf8cf60d386a67d92 create mode 100644 fuzz/seed_corpus/0d75321585730f6bc551f43ba86cb3aaec49d14d create mode 100644 fuzz/seed_corpus/0dd6288030245d6321791f5d145d5c465912945c create mode 100644 fuzz/seed_corpus/0e6f212f04c1659140cc135cc8ebb1313254c219 create mode 100644 fuzz/seed_corpus/0e7113fb5f90187c68454342ff4b918fd89df95b create mode 100644 fuzz/seed_corpus/0e75e6935de80d924277e5328d68a23d8de6ba3f create mode 100644 fuzz/seed_corpus/0ea5bd004cf7e082db96ec3773cc1d3020ea0678 create mode 100644 fuzz/seed_corpus/0ed173519dbf72a643ebac81117507a13fc33701 create mode 100644 fuzz/seed_corpus/0f4b109b7485f97b414203e5c8fcbe9d79ad44ed create mode 100644 fuzz/seed_corpus/0f5106937b68ba39686ca3bdb64695d2457451ca create mode 100644 fuzz/seed_corpus/0f84ad0758d9add8fab470f16befdfaae099ddda create mode 100644 fuzz/seed_corpus/0fd7bee6fde35437645194d8c45aaee9cac11b6a create mode 100644 fuzz/seed_corpus/0ffd3e46edeb253b94d35fcc9c65fb353b49c486 create mode 100644 fuzz/seed_corpus/10252b88a86e33e88effc97d948ac80c6416aa8f create mode 100644 fuzz/seed_corpus/10427462d18f60de0727ae71f8b30e67bae5e300 create mode 100644 fuzz/seed_corpus/11151c1f8a1da7fc9510eb6ac06e6b9c5efe6d89 create mode 100644 fuzz/seed_corpus/11272849809f3bdf65ceb37ac7aa447459334b46 create mode 100644 fuzz/seed_corpus/115b37a602de376022be7161cb23d8200aee712b create mode 100644 fuzz/seed_corpus/11635af037a796739b803b1d67e59aee152fb35e create mode 100644 fuzz/seed_corpus/11c3681bb5b2ea9cfdecb79f3a3124cb4c8858f9 create mode 100644 fuzz/seed_corpus/11dab67b78d459826ae4cfcdc05cf91c1fc9fd7a create mode 100644 fuzz/seed_corpus/120a2fbfabf37ad14df7ed82c2d89088dfe15d19 create mode 100644 fuzz/seed_corpus/12e7780fd2e88bce7460167ee15bcd8f84be0fbf create mode 100644 fuzz/seed_corpus/1370fc03d0009a05614a134847afd8188fd76cc1 create mode 100644 fuzz/seed_corpus/13799b7fe169c8de8889234e7b33e0cdde0cc47e create mode 100644 fuzz/seed_corpus/13b919c1f1c19522473beaba623afed955e65f92 create mode 100644 fuzz/seed_corpus/13fb4d418998bdb16f027dfc2842d46ede5129b0 create mode 100644 fuzz/seed_corpus/1437e5e33198fa59e55fe2a8dcd3edac07102e64 create mode 100644 fuzz/seed_corpus/143eddcb3c1e41ca0e773b91ba0bfa3b0888b085 create mode 100644 fuzz/seed_corpus/156207e9ec9a86691595dd77cb0490a247fe175e create mode 100644 fuzz/seed_corpus/15970946eb9a2ed52ad09fc78e61e1cf4e741018 create mode 100644 fuzz/seed_corpus/15d3ac6444c917fd769d0ce83bfc31dc4466980b create mode 100644 fuzz/seed_corpus/15de524d7bfcddd2b2ffc89f02230740b71fe042 create mode 100644 fuzz/seed_corpus/15ff9e809d0bfa67e482541391d3ec5fc9844a96 create mode 100644 fuzz/seed_corpus/1600d482d58bc75d288aedadef3a11135788dc5c create mode 100644 fuzz/seed_corpus/16783e74638cfe8030490b0180fd7fbc765780d7 create mode 100644 fuzz/seed_corpus/16f348235a0080206b00be3f9231e418aa5d67da create mode 100644 fuzz/seed_corpus/179b0cb5a01db1510b23f5cc531ea0ac3bfe4d98 create mode 100644 fuzz/seed_corpus/17b31bb2ef7f3a15434478f422276fcd736f0ff7 create mode 100644 fuzz/seed_corpus/18093e2a54c73c34b3160fb1bccafeed58db0bd5 create mode 100644 fuzz/seed_corpus/1818ac1aa7f2fb815428dd95acf8fe0691455e16 create mode 100644 fuzz/seed_corpus/18455d3de982d262231a468c0c47e783805cc1fd create mode 100644 fuzz/seed_corpus/185d7bb0d1416c764345bac8dc713f3fe296dff7 create mode 100644 fuzz/seed_corpus/191750348d3607f07c1ac636303daa558bc31697 create mode 100644 fuzz/seed_corpus/19204df7ab4eae999ecc6ea0bded083cb946dc85 create mode 100644 fuzz/seed_corpus/19384a4d87395788c83ac27934cd3cf71d0e5406 create mode 100644 fuzz/seed_corpus/195c9d4c518ea0b2717c281feb289b6553326abd create mode 100644 fuzz/seed_corpus/198eb5d4de042d0b430acfedb5f08b70a9bc4267 create mode 100644 fuzz/seed_corpus/19a80b448405a19fbb41592734b6d4af617d0459 create mode 100644 fuzz/seed_corpus/1a0798fcc3d279d54727b8531527edcda35079d8 create mode 100644 fuzz/seed_corpus/1a69f9c493e3409a297ef54cd2709c6c8b155cd7 create mode 100644 fuzz/seed_corpus/1afdab953f153ad082284ab6579dfa97e9db25e3 create mode 100644 fuzz/seed_corpus/1b03d02961926db0a5b2867291d30951c39d148b create mode 100644 fuzz/seed_corpus/1b6b1588fd94a28c0184b532083d2d4aaa4125aa create mode 100644 fuzz/seed_corpus/1c325aae428d9e024730d89afdfbcfd9dfd05755 create mode 100644 fuzz/seed_corpus/1c967d0cbfb53d1c1184b8d27f2c0b1f9cb4326c create mode 100644 fuzz/seed_corpus/1d2e7871a709b88c0f4e07b959c103070768a5b5 create mode 100644 fuzz/seed_corpus/1e791b3905ff171de1c06a26fdff4d262d5d4be2 create mode 100644 fuzz/seed_corpus/1e82fff4b132ce695652529980f1c904d28b7791 create mode 100644 fuzz/seed_corpus/1ed76a4de1c73b3f5883f0ca110a96be8aa12c1e create mode 100644 fuzz/seed_corpus/1ee55697ce9055cfe227685daca3c57b4318cfa0 create mode 100644 fuzz/seed_corpus/1f50fd9aa3a95df4a16b2ff4ce266ca83a4ff1fc create mode 100644 fuzz/seed_corpus/1f61817349b114163accd91d7718ccd8a22fbfa2 create mode 100644 fuzz/seed_corpus/1f954acde14869cc13df666d262a96000bbfb5dc create mode 100644 fuzz/seed_corpus/1fd59752baa6bc81f102ba96945a8026d8715adc create mode 100644 fuzz/seed_corpus/200d267a8bfc425839e40d407199ea7ff82fe346 create mode 100644 fuzz/seed_corpus/200d6d0432577c34fc801d4fee24b3393d7c05b4 create mode 100644 fuzz/seed_corpus/210a5f90b6ae0cd6cb95edbde77d52d450eeb1fc create mode 100644 fuzz/seed_corpus/210cab277f69b056d63542bc6940ea2cca8a558a create mode 100644 fuzz/seed_corpus/211cf9d35b1d4679671b4ac3d4e89fc075613ab3 create mode 100644 fuzz/seed_corpus/21f4384140618ecb5caadcfeb123bd6f7d1bcbfe create mode 100644 fuzz/seed_corpus/21f9abf973c92ec0a51656f3a76dbdad0bad769c create mode 100644 fuzz/seed_corpus/22421149badaedff85e55e4cab3b08502a92c36f create mode 100644 fuzz/seed_corpus/22d1271153c5b90a31a6a3924787b98a750344eb create mode 100644 fuzz/seed_corpus/23343eefaf46c5fbfe5a5ed489b125cf38741d14 create mode 100644 fuzz/seed_corpus/23aefbf61990ccfb3812eb85aa16969aa9c741e5 create mode 100644 fuzz/seed_corpus/23e1b677b9923e2d7d3351edbfb6d6f3f900968f create mode 100644 fuzz/seed_corpus/24112ff255332818fa2c677b91428aebcfa2771e create mode 100644 fuzz/seed_corpus/243261fb3a9034eaf3108beef61b3f4acbabd2ff create mode 100644 fuzz/seed_corpus/246d63002273f1f18d853d41f1e078466918b0fa create mode 100644 fuzz/seed_corpus/24d5c3998d909457df8a5ebda0d2f13ce97bb75a create mode 100644 fuzz/seed_corpus/24e96912408f5d59c13dcd310a0a0399bafc427a create mode 100644 fuzz/seed_corpus/2526e9fd2e7dc170f96a1138764506f28d213770 create mode 100644 fuzz/seed_corpus/257b66031fd4022497978b05e01f4157af963b1c create mode 100644 fuzz/seed_corpus/258200972a08001ab73d3a9cc1bca434edf8ac54 create mode 100644 fuzz/seed_corpus/268941309b3d09b155480b78c886976d9eac0658 create mode 100644 fuzz/seed_corpus/26bb4c75d24f2a674163677f8af8f34c83f45b47 create mode 100644 fuzz/seed_corpus/272d4ce45d79ec367eb0b3ba6fd637215c05cf3f create mode 100644 fuzz/seed_corpus/279887432540854d81ed9214156f2e3a9860dd80 create mode 100644 fuzz/seed_corpus/27bcdce6c0a5968b3d3b2820f22e9ab211bd1f66 create mode 100644 fuzz/seed_corpus/27bfe8bc3ce62b01ae4b0e8073db7bb8dae1bacf create mode 100644 fuzz/seed_corpus/27d3fdcc4901e5b6d3350fe46e495f78880b9615 create mode 100644 fuzz/seed_corpus/27f93269230c2cdac3686c0ef8bf494689e07148 create mode 100644 fuzz/seed_corpus/28c1d7135e399a43882ad2d71df0ecc354305bdf create mode 100644 fuzz/seed_corpus/295eea46f015e02b3a518db800bf9fa93505773b create mode 100644 fuzz/seed_corpus/299d543a09f90c6aeeb787277cd870affd2a6645 create mode 100644 fuzz/seed_corpus/29a32d7418008301e60cf31b6a830f029bf70620 create mode 100644 fuzz/seed_corpus/2a0b940c5134f02d3a32cf2cee38a74d5ab1c8fa create mode 100644 fuzz/seed_corpus/2a8b610bfb16745a14e58d879a9415b70fe60c3f create mode 100644 fuzz/seed_corpus/2a986afeaeece3a69206754e654d83221f3d4e3f create mode 100644 fuzz/seed_corpus/2adaf0d8e75c41100623c410be3dea8dd30b4d69 create mode 100644 fuzz/seed_corpus/2b20f5ba42cc907d756768ad36e7d90ea1ec2625 create mode 100644 fuzz/seed_corpus/2b29f5ebce426a5bbfe986324ba833b3b4eda61e create mode 100644 fuzz/seed_corpus/2b9b98aa420ec906d5b6da3234174e59b545b7d7 create mode 100644 fuzz/seed_corpus/2bf06d0674a90839c365de7cd703f2cf371cb39c create mode 100644 fuzz/seed_corpus/2c17df372ab3e6ccb0708a1cf42f3cf0624c4cfd create mode 100644 fuzz/seed_corpus/2c3804c6aa81bfef7ddba8bd392f0d8968c6bcb4 create mode 100644 fuzz/seed_corpus/2ca8525d0ef8ef80c4cffeb1d6ca35b171832867 create mode 100644 fuzz/seed_corpus/2cb101abf3950cb2d16e120a8388cdf3fa696b74 create mode 100644 fuzz/seed_corpus/2ce1c305d0d78f9723c9e64b4faf9ea18665742d create mode 100644 fuzz/seed_corpus/2d01ccd503d780469651df3b4bfec6d609820c44 create mode 100644 fuzz/seed_corpus/2d1090e9e9674e281a7383e2e5d137174df9ae24 create mode 100644 fuzz/seed_corpus/2d4938de49e0ab437dc84b2b4d0cd436ef30a188 create mode 100644 fuzz/seed_corpus/2d571657158293cbeb414954c868b7d059f18202 create mode 100644 fuzz/seed_corpus/2db003f3dd00fd677ec17137c627baa9aa65956a create mode 100644 fuzz/seed_corpus/2dcf80305d3a0dbe303d3327b0fc3fefa84d6163 create mode 100644 fuzz/seed_corpus/2de6eaa9ea8b2c3315c76c444d363d747310cd41 create mode 100644 fuzz/seed_corpus/2e8bbbb3d3b04f9832e3cc27e71e480bb7cc7053 create mode 100644 fuzz/seed_corpus/2ea6d56fdb6dff6d7419d04feb8c487ed1bc9449 create mode 100644 fuzz/seed_corpus/2edd283c71f81215a507cc9fb09ea820e7883c75 create mode 100644 fuzz/seed_corpus/2ef2e635bc69fe780e952fc98be6310e257bfc9b create mode 100644 fuzz/seed_corpus/2f69fe1657e0fa419119d088df4d7fabd1349375 create mode 100644 fuzz/seed_corpus/2f9d077a8d222d675767c15f40f4e02b5af87fbb create mode 100644 fuzz/seed_corpus/2fc3463adc8d5efee1d1264b040d4f7592f0f25b create mode 100644 fuzz/seed_corpus/2ff26c57e9859c67ce742f7d9e3998d221a6b3ed create mode 100644 fuzz/seed_corpus/3033050fc78db9c6ae43d421ab0c6ac919508c4c create mode 100644 fuzz/seed_corpus/306a8956f55a33546f18cf9e074260c213a2650e create mode 100644 fuzz/seed_corpus/312ea7279fbd73cb85b56f4b091d5fa30d5edf7d create mode 100644 fuzz/seed_corpus/315af194713e19575d14219f809979c413352caa create mode 100644 fuzz/seed_corpus/31bb7a40c73fb9d577cac3a77f5d2f3dba735e9a create mode 100644 fuzz/seed_corpus/3200c178d8bf3a746a4896fb23f0ca07ffa3a252 create mode 100644 fuzz/seed_corpus/325141a45d26c576c5f6d4e25f29af6b3d3b2bca create mode 100644 fuzz/seed_corpus/328781b84caf8ec37b9a0d723938810d40fe4719 create mode 100644 fuzz/seed_corpus/32bb4cd890770928b31d81934920acaae0b02106 create mode 100644 fuzz/seed_corpus/32f877dee5fdbf4544c8eb601367508bb39f4678 create mode 100644 fuzz/seed_corpus/33417f3b4591d775c4cfe7ce2def35bc06c8e5f8 create mode 100644 fuzz/seed_corpus/336db03b7edf31bcd28841ecbe5ab4be0c2337ff create mode 100644 fuzz/seed_corpus/33b9edc2a8b46940af9b62e871b640b8810ca177 create mode 100644 fuzz/seed_corpus/33d4e2071e444fef93043f9f8f95ff74c1915b53 create mode 100644 fuzz/seed_corpus/33d68da1f9e21a0e30a5a81ebc2bbf57d2a9fb87 create mode 100644 fuzz/seed_corpus/3457d93607d3999e321617680bed3ddca1f44bf3 create mode 100644 fuzz/seed_corpus/34675d3c7f8e4a39df7ac2c6bc0a06612f5319e0 create mode 100644 fuzz/seed_corpus/34f7d2c6f3468da3f3ff5f21164a2801a0f9925a create mode 100644 fuzz/seed_corpus/34f892bb3c2e5d05fd6082da5ba25d932a5dea2f create mode 100644 fuzz/seed_corpus/35023a7259bc97894808e681da25db0a9643746c create mode 100644 fuzz/seed_corpus/35343925d7c2fe1f6246096652ac3f588f197d37 create mode 100644 fuzz/seed_corpus/3553d1e2ae4f4bf2dd64e22920ee093c1246375a create mode 100644 fuzz/seed_corpus/3573efff01f53fb99cc1f62025782687a8492389 create mode 100644 fuzz/seed_corpus/359efdf116e99b035ad8a7143e0008c726f8e89a create mode 100644 fuzz/seed_corpus/35adadef5ed7f8904b95b896ceb98c0c67b7c4d9 create mode 100644 fuzz/seed_corpus/35e835321db6aadf8e91b0c5349ca32d5dcfaca0 create mode 100644 fuzz/seed_corpus/362061c13eb3be9264e4d6fd796b65e67e06d15f create mode 100644 fuzz/seed_corpus/367c8849eb9c664ffd8fca01ae437693e7c300f1 create mode 100644 fuzz/seed_corpus/369cde0f03fa526fa88cb0962ad9df3db638f974 create mode 100644 fuzz/seed_corpus/36a3a042b66d27d82b3c33ba30f12b3ace42b992 create mode 100644 fuzz/seed_corpus/3763091a5b9d668ead99e1859df607ebaa818660 create mode 100644 fuzz/seed_corpus/37d81231057d12730464baf1d81ef8463d8a3ba8 create mode 100644 fuzz/seed_corpus/37f690b3337edd9e89cf7b8181a612674979125e create mode 100644 fuzz/seed_corpus/37f92f2750a7f26f9055119d80f6cd1ebbf756f2 create mode 100644 fuzz/seed_corpus/3825c09a96e5e05f4092ae01d96c209db1f8f050 create mode 100644 fuzz/seed_corpus/38515283cea851779d8e8d3b0aad93be591fddca create mode 100644 fuzz/seed_corpus/38adf992bf07f252b47363b333b6d90402124062 create mode 100644 fuzz/seed_corpus/38ca080f40a7d3c2546bb8a6f724a1d24c45c0c1 create mode 100644 fuzz/seed_corpus/392bf6b64c0e639ddae18ff6fc312d383a7823c1 create mode 100644 fuzz/seed_corpus/392e0963a6e4f6ccc286f097d86f26292258b29c create mode 100644 fuzz/seed_corpus/394d289b3ca309b56508d8e49ba7b33d6f0a3c7f create mode 100644 fuzz/seed_corpus/39a4d06da6128e34fbaf2492613a8a35dd3c1172 create mode 100644 fuzz/seed_corpus/39da01073207d77452a8e9207324ad9c733b72a8 create mode 100644 fuzz/seed_corpus/3a0a830b4c2564ac6580153175cdd7d65a9ab21a create mode 100644 fuzz/seed_corpus/3a43d6ed6c7f14912ef4e83ada972310d391e8ac create mode 100644 fuzz/seed_corpus/3ab4c074cd1471d049ac1f69e9c73e316b12abc6 create mode 100644 fuzz/seed_corpus/3ae23066e6ca32d416573bf52ee2229db42b91ce create mode 100644 fuzz/seed_corpus/3b1dd9cc6f8bc9de8eed5355b05b8baa508052d9 create mode 100644 fuzz/seed_corpus/3b4f01db792431dd373134595aa08cc7ff84868c create mode 100644 fuzz/seed_corpus/3b9311d5a10bd7b1907ce53f0fdf0dea196e9958 create mode 100644 fuzz/seed_corpus/3bde163d787b60d1ac3ff67bbe0af0530ee38e75 create mode 100644 fuzz/seed_corpus/3bfbfe5be753aa28efc91a7a3d50aada9b6dc00f create mode 100644 fuzz/seed_corpus/3c2b83c121df18fcc68b9c8a7ae2eca64f5d90fe create mode 100644 fuzz/seed_corpus/3c561c0cda15985767ee01971a9690b95797b410 create mode 100644 fuzz/seed_corpus/3c69b57233d9b642e5049ace8a6f2d5abdde04c1 create mode 100644 fuzz/seed_corpus/3c982eeabfa96702cfb1f7e00ae1d77400be1cf5 create mode 100644 fuzz/seed_corpus/3ca4c964b9792ca5363239457e5c1420da58a1f3 create mode 100644 fuzz/seed_corpus/3cb01cf8d387cfe9ae2e23f1bfb6d0e8e98e9b0e create mode 100644 fuzz/seed_corpus/3cc0358ad28a8aa873572699c3dad054b9f4b36c create mode 100644 fuzz/seed_corpus/3d3aaf13fa606e4d1f9578525670886e42f24c5c create mode 100644 fuzz/seed_corpus/3d50175e6eec31cf51792765c26e1e52e7082e52 create mode 100644 fuzz/seed_corpus/3d5670df150b1ef15cd0b5a864b453df8b60c070 create mode 100644 fuzz/seed_corpus/3d75659fae1ba8a57edf94fcd929e838884ec628 create mode 100644 fuzz/seed_corpus/3dc6a326d54c4ad851e746c41d4f589a2a7a81dc create mode 100644 fuzz/seed_corpus/3df6ab31f8c924814d6ec41254d11b4b3734784a create mode 100644 fuzz/seed_corpus/3eadf8140e3e4f143237295ded4432e590149796 create mode 100644 fuzz/seed_corpus/3ed6e5c140bae24b255cb44442523965ab7a42f8 create mode 100644 fuzz/seed_corpus/3f55d0379c0e80b6f010820df52b0cb386ed8c61 create mode 100644 fuzz/seed_corpus/401543482823f51516d893bd40e21f62a7095390 create mode 100644 fuzz/seed_corpus/4082d19ec13578dcd0e426fd90f95292d0fd17ba create mode 100644 fuzz/seed_corpus/409a08aae1b84dfbd1edf7042b9668a99832f13c create mode 100644 fuzz/seed_corpus/40b77e5ae2f82dfde535ad24b584755f303fc1a4 create mode 100644 fuzz/seed_corpus/40c5aae0f98020db8a707f95d88df88bb040c9f7 create mode 100644 fuzz/seed_corpus/40c82af59b9824a310ef8b7666f7878db41d8a86 create mode 100644 fuzz/seed_corpus/40ffa2012989f4f9e244d0cdd15602cf06b5be6a create mode 100644 fuzz/seed_corpus/4118fee45a9c3137ac87597ed92acc6b8dbf7835 create mode 100644 fuzz/seed_corpus/417dba73318503bd669248490380fa6f095fd137 create mode 100644 fuzz/seed_corpus/419195bd3ad69e448e63afd9355c2c6d18c6ed52 create mode 100644 fuzz/seed_corpus/41bdffcb56ac2aab0b529d18eed2d1df0fdbc2b3 create mode 100644 fuzz/seed_corpus/427cbae095793e5bfdd99d74aab07afd1c9ad3ca create mode 100644 fuzz/seed_corpus/42a6a0349a82750fa6c3d4c8352309d810b52d00 create mode 100644 fuzz/seed_corpus/42fee542d8ff480328efa55e776f7d86a7f785f7 create mode 100644 fuzz/seed_corpus/4329a86c75c6710c55fdaed2a83afa132269cbe7 create mode 100644 fuzz/seed_corpus/43a8002ae75dc483d657b93bf90be537f51e311b create mode 100644 fuzz/seed_corpus/43e3e620b4a80fddf9757b0654f7d88f893b45f0 create mode 100644 fuzz/seed_corpus/43ef53483f81d8d37ef3a506e188a13432a13b18 create mode 100644 fuzz/seed_corpus/43f0facfb33120a131a205db34a3fe227b4e70c6 create mode 100644 fuzz/seed_corpus/4488cc2cc0807fb5ab9bcd16ee7c9dacadb9214c create mode 100644 fuzz/seed_corpus/44a4b22ac657794f39cdda1dc9008f3226dc89a0 create mode 100644 fuzz/seed_corpus/44d64981fbbd355fecc095c46fcd91e1aa05abec create mode 100644 fuzz/seed_corpus/44f4b6c5c6540ae1bed988d4487db558e0f7bbe6 create mode 100644 fuzz/seed_corpus/4536f5776d343fcb123edece5fc1cdf5c6ed2c50 create mode 100644 fuzz/seed_corpus/45406f6ab8ec5b8e0cd3b53f1e9ddf22229164bf create mode 100644 fuzz/seed_corpus/46257dd92641aad954c2c044e970aa7ca0e2c754 create mode 100644 fuzz/seed_corpus/464c8fcee563a32e7cb205f551928eb5f4dc1933 create mode 100644 fuzz/seed_corpus/4658d404a743dceff6fc22cb94a33e6402574915 create mode 100644 fuzz/seed_corpus/46683fe43cfa4089d2f77b35d19d8ef303e084d3 create mode 100644 fuzz/seed_corpus/47424d8a8e83b35bedbf27bcfdb2ac189ee2bb1e create mode 100644 fuzz/seed_corpus/4743c78e83308ea513d4f381e8d7b31d5539ea6a create mode 100644 fuzz/seed_corpus/4781476c90a04890336cb413464e4395b77e4eca create mode 100644 fuzz/seed_corpus/47b45388a5ac65198523036beb5ab4c2a7ba46d1 create mode 100644 fuzz/seed_corpus/47c2a2a47068329771380ce60cdc1357e2c9a7dc create mode 100644 fuzz/seed_corpus/480521dea9eca7fcb11fcb91f2f7c9c4c09d6b71 create mode 100644 fuzz/seed_corpus/480818cd511bf7fa9b81336e3328d77fa158b765 create mode 100644 fuzz/seed_corpus/483f0f90e088d334f471a93ecc7f0725943c0bef create mode 100644 fuzz/seed_corpus/4852652e0e37a94d4f90572d995536b5e4ba89c7 create mode 100644 fuzz/seed_corpus/48f438485efe8c9a5c34eaf6e0024268bce6ff0c create mode 100644 fuzz/seed_corpus/49ca2a82b912ca616d9d471f3e4f5562a53b71c4 create mode 100644 fuzz/seed_corpus/4a194b0925b048e8b6291dafbfa651d5c53cd283 create mode 100644 fuzz/seed_corpus/4a2757541d7829e1f204f6dc5b208289b5eaf980 create mode 100644 fuzz/seed_corpus/4a43a4e1c4e9dfca40efb0fbd6f6d1a6411b1107 create mode 100644 fuzz/seed_corpus/4acdb070b5b06a7f4be41f3bb99069aada552179 create mode 100644 fuzz/seed_corpus/4af3620e1994108a73f1fd5a5b4ba55b35ae02e5 create mode 100644 fuzz/seed_corpus/4b5c1f8a6ceb49ff6decb04bd00b98aaf7c1b1cd create mode 100644 fuzz/seed_corpus/4b67b181831ff6621088e3ccf7c8d7b1c4fa5d77 create mode 100644 fuzz/seed_corpus/4b703fd43074948f2c72ed24ca9e17d23e25c32a create mode 100644 fuzz/seed_corpus/4bbb4624f4d93f1a3f651608645391c84c36f4b5 create mode 100644 fuzz/seed_corpus/4bea843a4333d5e29c7abc2bb499b7d450c9842d create mode 100644 fuzz/seed_corpus/4bf6ebf590bf2b858824697a241340d053fee781 create mode 100644 fuzz/seed_corpus/4c4cec9b73d30e9a3e2374b8c12688a475f9296a create mode 100644 fuzz/seed_corpus/4c9427251bffa8ec07f62d5d1ed14c5e2d4a1e36 create mode 100644 fuzz/seed_corpus/4cb66bc008b9d1e5b88463dcd2ac5793e54c5cb1 create mode 100644 fuzz/seed_corpus/4ce5ce6249ea49457dd8dfa450ff74560d6d7715 create mode 100644 fuzz/seed_corpus/4ce8dbe5d8fe97177d838802c7f0abd770c49453 create mode 100644 fuzz/seed_corpus/4d19324092ee9096d1fbf4388eb615996cc18950 create mode 100644 fuzz/seed_corpus/4d4c13117d6e9ed6a34c2788fafb71b817303efe create mode 100644 fuzz/seed_corpus/4e4027f40b8e1c1a6ba70d29349f4bbdf8fd8ce4 create mode 100644 fuzz/seed_corpus/4e9ded0041672e93f57529a3f4eac76346ab9bc6 create mode 100644 fuzz/seed_corpus/4ed56ff66d71f85b09f702026ed92a7184c4e08f create mode 100644 fuzz/seed_corpus/4edd7bf919d26f02cf0aa25ed518e8ff6642e066 create mode 100644 fuzz/seed_corpus/4ee63249a9782f1c07aa0ac6765fcf805bab62ac create mode 100644 fuzz/seed_corpus/4efbcc22ad3903c6da4503c806c257ecb49e8ee7 create mode 100644 fuzz/seed_corpus/4f0b4f0c0a1ab5357b685020fa52f6ca00f299b5 create mode 100644 fuzz/seed_corpus/4f0e428b168f9e0c0097c13f4d27df23b3cb9e87 create mode 100644 fuzz/seed_corpus/4f1cf7603c13087f1ca2c6f7871366a830282e1e create mode 100644 fuzz/seed_corpus/4f2e0e0472d181cc8f28a17c2bc7caf508b70442 create mode 100644 fuzz/seed_corpus/4f303abba6d7b9e8480ff0b62e21c0185c1b024f create mode 100644 fuzz/seed_corpus/4fdd1e32ed7a2bfc01c5e84e2c0850efd184a7d2 create mode 100644 fuzz/seed_corpus/4ff17ce8da70de5a7c8da2509618d12b57f30156 create mode 100644 fuzz/seed_corpus/4ff2cfdf87cd976aa9c447de5dd84afd3bb5407a create mode 100644 fuzz/seed_corpus/5013d9f2aa7285f8e044bdf18606dceb8c4d298a create mode 100644 fuzz/seed_corpus/503fbe110e1acb177aa715e87571864419348239 create mode 100644 fuzz/seed_corpus/50784dd9ece4c9fe863d7e6d1f19dfd56b74cb21 create mode 100644 fuzz/seed_corpus/507c20ff48de0ee77b9edfd5468a7dd7d10c2988 create mode 100644 fuzz/seed_corpus/507f785de339557ac967f7c224f5c0bcb62c6c6d create mode 100644 fuzz/seed_corpus/50d9b549a915f5064a2c42f3c7300b8dc960e801 create mode 100644 fuzz/seed_corpus/50e38c6f79608773138f87f2a2c57fb0478848fe create mode 100644 fuzz/seed_corpus/513e1171b324de6a4ef006d844a51c23ad653416 create mode 100644 fuzz/seed_corpus/5182a07d95e6b67cad8f2627d20b86d82e670153 create mode 100644 fuzz/seed_corpus/524f15c8a4bf2a6eff88f9369350a86b4886ae58 create mode 100644 fuzz/seed_corpus/52f1454ab8d4e723ba4f5b6e8329a675b8ddeae8 create mode 100644 fuzz/seed_corpus/532d6adc3c29f79675b7ef687de4e78970766e83 create mode 100644 fuzz/seed_corpus/5352e2f72312130f51d4ac7582d8111fe73a2915 create mode 100644 fuzz/seed_corpus/538365fe0eb2b8eddb957e393d58ce2b2964be33 create mode 100644 fuzz/seed_corpus/539a982b428e0e3ae9c2800c2d7a9dff0d9a5f80 create mode 100644 fuzz/seed_corpus/5417cf5468298cbb802d4b50a2c7887d48444217 create mode 100644 fuzz/seed_corpus/55464f8e197c6786fdd2863dcf1ad7adab2250d5 create mode 100644 fuzz/seed_corpus/555e6e4146007a7e0f75a48c3803939f54fa1c0f create mode 100644 fuzz/seed_corpus/55672fa125643998bd33dd6ee638fc2bbf9c9cfc create mode 100644 fuzz/seed_corpus/55a40d3fb150cfb1e9a4a9603b79f6572d368e82 create mode 100644 fuzz/seed_corpus/55c253c203f74e71c081d2ccd7c41c0619ed3356 create mode 100644 fuzz/seed_corpus/55fe918b256dddc9a0ae57ef1450389aff0a2e00 create mode 100644 fuzz/seed_corpus/560d8154f1460978fa0fc9e4229c14c8eac4bd51 create mode 100644 fuzz/seed_corpus/561f5175c68d68cc130bf08948b186be930f303e create mode 100644 fuzz/seed_corpus/563962cf2e742f56516404e010e70563dcdc2b02 create mode 100644 fuzz/seed_corpus/56aef1d358243504189ee0a78b856fe588f88398 create mode 100644 fuzz/seed_corpus/56b4f44bec49bbcee0cce977a8a266b834647ddc create mode 100644 fuzz/seed_corpus/56dac335de8fa2900e0e83ee4ed73d7ca9da9d00 create mode 100644 fuzz/seed_corpus/56f1391fa175711c6d1283b78972369768dae34c create mode 100644 fuzz/seed_corpus/57310dd73395497908722a558d16c8905e68f30c create mode 100644 fuzz/seed_corpus/579869ad538f409879032fecb224892dc24d3c3c create mode 100644 fuzz/seed_corpus/57f5bc58cf0f47f9300dee878113c54b7354b44a create mode 100644 fuzz/seed_corpus/58954c17802ce440f8f3e856de1203b91db0860e create mode 100644 fuzz/seed_corpus/58b308881595a707934969bc06b3c618cdee1d7b create mode 100644 fuzz/seed_corpus/58f57f2f1d0b0aa1e673c608f894a28881e73c37 create mode 100644 fuzz/seed_corpus/597ab70ad943125c31f6f968bdd2fde252e64212 create mode 100644 fuzz/seed_corpus/5a3cf187c6e1e924014f8301e3bd74d417b53792 create mode 100644 fuzz/seed_corpus/5aaf47510fc324ff42645f8a0ebe1ee0a3d70e9d create mode 100644 fuzz/seed_corpus/5af549baf4c3cb8b4d388b124707db855bcf6a5a create mode 100644 fuzz/seed_corpus/5b0f4a37988f819558110ecfddee3b92a2362077 create mode 100644 fuzz/seed_corpus/5b1b33f44dd48aeb8929d4a7daf87b178a8bf395 create mode 100644 fuzz/seed_corpus/5b2074a4c214ad1a3be4d58bd74fd47f4ff46d80 create mode 100644 fuzz/seed_corpus/5b3de5182cab27fd312aaa5255983f386f655ba0 create mode 100644 fuzz/seed_corpus/5b3fdf55aa19abd6531bcff7b036b925eedf1cb3 create mode 100644 fuzz/seed_corpus/5baac57602e14608d0140d5f345f014e4e46ef22 create mode 100644 fuzz/seed_corpus/5bb8c285d98615ef25b44894a73dfd00b3d7ff25 create mode 100644 fuzz/seed_corpus/5bbfae7061d2f7091265014f9c6aa5b7211f0e15 create mode 100644 fuzz/seed_corpus/5c15a9f0773b83943aed2431841a30313a048970 create mode 100644 fuzz/seed_corpus/5c1c50b69371c23acc7cfd00560a0b8297e4a2e1 create mode 100644 fuzz/seed_corpus/5cfb92ac6c6c7e8e0b2a7382b69c057f60521a43 create mode 100644 fuzz/seed_corpus/5d0bb7643ee98b79f8b765e4fbd1ac5c7bdc559c create mode 100644 fuzz/seed_corpus/5d2f869e80b1b6b121e6b0d627529e50212cd112 create mode 100644 fuzz/seed_corpus/5eca276cdaa08ea3a53693aba3670a451e53905e create mode 100644 fuzz/seed_corpus/5f16b42510c4d4972269b88408507b9a928f1c37 create mode 100644 fuzz/seed_corpus/5f319f08e3c52d2d2fd1932309ab118cd1623ed2 create mode 100644 fuzz/seed_corpus/5f5f3a69819ce2049ff5b1f9c8e3cad2cca963a9 create mode 100644 fuzz/seed_corpus/5fb13e5aba1bfdac70b6a309ef596623e004a2b9 create mode 100644 fuzz/seed_corpus/5fc7c4b6db220782517635f7711ca8388c728f0e create mode 100644 fuzz/seed_corpus/600a34d4da4a6fc71015b65c039c68447b5b7a28 create mode 100644 fuzz/seed_corpus/60fe79dc22db48c99f1527da238e35c37ffdbb02 create mode 100644 fuzz/seed_corpus/616205f0905dfe0af385e82a68275dab02746c60 create mode 100644 fuzz/seed_corpus/616f8ed5c640e2a0df8f17d1a8a3d3e2f3cfe093 create mode 100644 fuzz/seed_corpus/61c137a2d172157a9636a814c7b2e88a3cc16f27 create mode 100644 fuzz/seed_corpus/61daa071fecd91e30c36bf5ff9f09676f54e477d create mode 100644 fuzz/seed_corpus/627ec43b7388a228fcdc30ebcd9b3bd5b14bc84d create mode 100644 fuzz/seed_corpus/628cc9031030cbb14613eb0e821e5032c87bfca2 create mode 100644 fuzz/seed_corpus/62aa12471846f560d51fac5ee1b83c15dec6bb2a create mode 100644 fuzz/seed_corpus/639a043a6fd2802e99bc12a93475c143479cf1c7 create mode 100644 fuzz/seed_corpus/639c88003025596bfab25bcb5890f8be11ad7c80 create mode 100644 fuzz/seed_corpus/64d101bddef3caa00b9c816400de68db34e5c69a create mode 100644 fuzz/seed_corpus/656cdb2768a229123d7ceccd4d70d4a07e3a8e8e create mode 100644 fuzz/seed_corpus/656e7de87d66733aca5e29a05713ae9414377dbd create mode 100644 fuzz/seed_corpus/6570af3254bdeb56c2604569dd7e6299dafc3e44 create mode 100644 fuzz/seed_corpus/658df221c6641622c83b0440879a58a53ed7eb73 create mode 100644 fuzz/seed_corpus/6592fc5e65ce07cc6f1d860231ca614255d2eb82 create mode 100644 fuzz/seed_corpus/66397361ea0cd879565fce9fd5091ab38b0b5c4d create mode 100644 fuzz/seed_corpus/671a654d51aa9e2dc3006e715af08668c8998682 create mode 100644 fuzz/seed_corpus/672a6c9387c4b738c650e03058bd4af4cbd112ff create mode 100644 fuzz/seed_corpus/6735bb0236484acdaf1fb09097d8461ce25f7ff3 create mode 100644 fuzz/seed_corpus/677b126fac521c3333e2964692f55eb9991a3f14 create mode 100644 fuzz/seed_corpus/67b597d5c85d0f80d6354a253a1fbdd83931066b create mode 100644 fuzz/seed_corpus/6837c85f0d43aaefa7a2cf240118cf25b082ca91 create mode 100644 fuzz/seed_corpus/683f55a4b2e3d5d79de93da904a6f9b5ffca90bc create mode 100644 fuzz/seed_corpus/68924ed2f6378dba57b8d7ece7595d8837fa3763 create mode 100644 fuzz/seed_corpus/68a952113a08cd3fc90f7cfd53a651efc5042cbd create mode 100644 fuzz/seed_corpus/68c51ab273511385a5d511c6840063e745e68aca create mode 100644 fuzz/seed_corpus/697e6f3800afb5879e0128864027efd2794353eb create mode 100644 fuzz/seed_corpus/6a09daa4480137ab69dfbfc1aaca44b5b73577f5 create mode 100644 fuzz/seed_corpus/6a1b89be3f3b76f3d1186b1901831959a642276e create mode 100644 fuzz/seed_corpus/6a3bf591f45d93c6c89edbb804e2148dcd911e1f create mode 100644 fuzz/seed_corpus/6aa57746a1aad289d984e7580b7160b0b371fcf7 create mode 100644 fuzz/seed_corpus/6aaa42de07dd5b363f7ededbfbae922c8fa2490e create mode 100644 fuzz/seed_corpus/6abd8fb5d1ab4d116daf4429678ca9bb0947e51b create mode 100644 fuzz/seed_corpus/6ae10aeb6fd0f9346db450029b0c1a06738a77a3 create mode 100644 fuzz/seed_corpus/6b3f3b53af613de99f9d50a42fb28b6c98ff7f9e create mode 100644 fuzz/seed_corpus/6bb5f98c0532382370c94c29910d06ce65ed2e36 create mode 100644 fuzz/seed_corpus/6c78a975633639ff2e3214dc4cfd8b280405a276 create mode 100644 fuzz/seed_corpus/6c9ca209c620ccc5b6feb7aeb546a20afd7d80d6 create mode 100644 fuzz/seed_corpus/6d1a623334c2a5a928192d4edfb971be0f584b42 create mode 100644 fuzz/seed_corpus/6d93d9820e7b8f16da82c94a4bb2386b4abaa1f8 create mode 100644 fuzz/seed_corpus/6da35dbfced7087910ad73348df7ff8a395a3c32 create mode 100644 fuzz/seed_corpus/6ea1d8bab04f9cef7f5704850f74a21b0bf55230 create mode 100644 fuzz/seed_corpus/6eaf066f91ef68a2668e2ac83ede7d1bed8a899d create mode 100644 fuzz/seed_corpus/6ebd108c726bd5379ebd60e9e85b58f1fa1e6289 create mode 100644 fuzz/seed_corpus/6ee4a7f863fe05823a2640a3c040fab72abce298 create mode 100644 fuzz/seed_corpus/6f60864db263a826653e36f59579336df447313d create mode 100644 fuzz/seed_corpus/6fbe3a751d4a6e5c82c26fabda5c41ca9b097833 create mode 100644 fuzz/seed_corpus/6fd3150c77c1067333f444472c8a9d74cbc39116 create mode 100644 fuzz/seed_corpus/701b2b9e1218eb518a7ec30ec71b474c8c9dcadd create mode 100644 fuzz/seed_corpus/705a3c3778f48975bed31e1e9bd72b3de2426e02 create mode 100644 fuzz/seed_corpus/71375f731776dcad926888e614d139763da17b9f create mode 100644 fuzz/seed_corpus/71511f010813ef7a90ce1eaf18d4f6f6aae88f9a create mode 100644 fuzz/seed_corpus/716a187708f9fde686d26d56d5639fbf916f64e2 create mode 100644 fuzz/seed_corpus/71dbd4ef4bda3e726cc9ce3daca1e56fe33a02fd create mode 100644 fuzz/seed_corpus/720fea1a8439bb20b10fd64a3e84fc8d3efde291 create mode 100644 fuzz/seed_corpus/7236669e099aaa4dac168e5ffb2abb0804016506 create mode 100644 fuzz/seed_corpus/72b3c8f8967f260de2a05e0e9978ec0136dc2cd0 create mode 100644 fuzz/seed_corpus/7306ab382f44b9481eb079c245bba6d2c412018c create mode 100644 fuzz/seed_corpus/7326dc66f20c41c41aaaebbcf12f02a716b9bff9 create mode 100644 fuzz/seed_corpus/733825ed3f72e15c43e243ec4c5e91e4719bb486 create mode 100644 fuzz/seed_corpus/73589b6ebbdfb9b56e27e47d37f451a27083dfc3 create mode 100644 fuzz/seed_corpus/737300f263749bbb1e349d2b79daa8055c2e4511 create mode 100644 fuzz/seed_corpus/7395743f1738a28d98df08deb700f18eb9669867 create mode 100644 fuzz/seed_corpus/73b1ef9f2bd6a869854af4befb12b3485e3c621d create mode 100644 fuzz/seed_corpus/73fe3cf2705d803262c7d7903e24fd0c89686bbc create mode 100644 fuzz/seed_corpus/741bc7f1a0bcc05c05328c39ddc541c41fa86082 create mode 100644 fuzz/seed_corpus/742928dec5d193cd93774db31ae0eb9b9c412b4d create mode 100644 fuzz/seed_corpus/74b47ceb2af543ec62b2c3925d76ef7c86383bf6 create mode 100644 fuzz/seed_corpus/74c22ea74f3df081095861f7a8e7db2a73d6b928 create mode 100644 fuzz/seed_corpus/74e57dd82b745f81379d53fe84f0d89dd668bc3d create mode 100644 fuzz/seed_corpus/74fa7a7901379ffe690ba9b471bc74995bb5302c create mode 100644 fuzz/seed_corpus/750c15ca3c858f9880c1127450118b4d94598c96 create mode 100644 fuzz/seed_corpus/75188bed69917fd60549ec46a8dfded0364af9f5 create mode 100644 fuzz/seed_corpus/754e7a4d805c02735bb3ea29acacda16e79d7367 create mode 100644 fuzz/seed_corpus/75976256975be166dbd17c861bd59cf3af76ee23 create mode 100644 fuzz/seed_corpus/75a7a83756947e988df92e4c449c01bbca9bd18d create mode 100644 fuzz/seed_corpus/75e0e6e7449e64982bfa5dda52ad9a239ae89cf8 create mode 100644 fuzz/seed_corpus/75e496951d439ff1c85071904e5a83a01e5a9555 create mode 100644 fuzz/seed_corpus/75ead4ce617162e5eb3e2ffc33c4f2f8826614c4 create mode 100644 fuzz/seed_corpus/7640bed796785a43dbabce33e359ec6cb777275e create mode 100644 fuzz/seed_corpus/765b92b183650022c8828e2249e9f0161712f123 create mode 100644 fuzz/seed_corpus/7692c5aefdd5a1e43595e3d61b1afd0e025104dd create mode 100644 fuzz/seed_corpus/76a7c7ba72492e944863c9067fe6bb6b4323d006 create mode 100644 fuzz/seed_corpus/774d96e7e04c32f0b5e4b9ae545421d0f550b25d create mode 100644 fuzz/seed_corpus/776150e93fd52b4eed4c713ff033886cd051f12a create mode 100644 fuzz/seed_corpus/77ebf6c9faa3011ffe21fd373bcf24c9930caea4 create mode 100644 fuzz/seed_corpus/780ff3212a9dfc11ec0ade964d36066289df20b2 create mode 100644 fuzz/seed_corpus/7872b3c54d64a73f1ba61e95d3058f21d21c00f6 create mode 100644 fuzz/seed_corpus/78a7e6c6c82b095036be729e3240939f8d05141b create mode 100644 fuzz/seed_corpus/790b51f10d107a5d311973297211d6e7d4be4ea1 create mode 100644 fuzz/seed_corpus/79453c6b9b66e27860684227f2bf18f628122cf4 create mode 100644 fuzz/seed_corpus/79691b43957989a7ac01dbaf765109f53b0c2f6c create mode 100644 fuzz/seed_corpus/7989e60b91f860c4e7e59060d2eda94038b91a5c create mode 100644 fuzz/seed_corpus/79feaa14e0272d4920f0668fdbf2c809110eceec create mode 100644 fuzz/seed_corpus/7a060dde82e3692da7fc95108145a86ce85b9f3d create mode 100644 fuzz/seed_corpus/7a35b45a813cdb47f0c8dfff5afd0caa3eb9a19e create mode 100644 fuzz/seed_corpus/7a59f97c7e838d967f0222b77ad65a4c9e9c3eb3 create mode 100644 fuzz/seed_corpus/7a629aa047f6cecaf17ec48d79d58c535277ca0e create mode 100644 fuzz/seed_corpus/7aa5de3e001eff1ecaa37566fd45342bf6ffcb98 create mode 100644 fuzz/seed_corpus/7af10d0ae984ef19d8db1268df1eec2d420f1374 create mode 100644 fuzz/seed_corpus/7b07c8e1083c71288120e57950f95b0f28cc0eff create mode 100644 fuzz/seed_corpus/7b46ce0b61f4bc2b7fa72c2921c85caf34a910d7 create mode 100644 fuzz/seed_corpus/7b60a73d9e8ebc85bd25531ee58238f3650a31ef create mode 100644 fuzz/seed_corpus/7b8c31b8c3dad1ff9b943cd0ad0b6db25a4f20b0 create mode 100644 fuzz/seed_corpus/7b917fc10629b19c40df0eb76cc82e64deb137db create mode 100644 fuzz/seed_corpus/7baca30e020070ddde4b2fcae7c72c5caa7cf178 create mode 100644 fuzz/seed_corpus/7bb0f3f2a9714927663d90b40580969592f5989b create mode 100644 fuzz/seed_corpus/7bc19bc980a07fec3523ee9ada0b3ddee1fa774b create mode 100644 fuzz/seed_corpus/7c0fcbbc3a9add6cbe45167c553f2f26433d0c5f create mode 100644 fuzz/seed_corpus/7c211433f02071597741e6ff5a8ea34789abbf43 create mode 100644 fuzz/seed_corpus/7c2e5e524d126fb3df8144599b3b6f05b81570ac create mode 100644 fuzz/seed_corpus/7c85c028ae7d172131b6f464bde9f32826e94ef5 create mode 100644 fuzz/seed_corpus/7cb1dc4d1a66084e136cec80191db79004f7d881 create mode 100644 fuzz/seed_corpus/7cd16a6770cbde1158be465442a8d2f6d3ee6151 create mode 100644 fuzz/seed_corpus/7ce0cb194006f3f9446b13257e532181ccb4d690 create mode 100644 fuzz/seed_corpus/7d0e97685b4f2b497b8afc5be617b6725f042f5d create mode 100644 fuzz/seed_corpus/7d62086ba1a855963273de7fe48d3dd03373e3c7 create mode 100644 fuzz/seed_corpus/7d7b180aa02ec5614ede7215ee71a2da5ada9c8f create mode 100644 fuzz/seed_corpus/7d8a71f28307f5fde233975b156ce0c7753d6e80 create mode 100644 fuzz/seed_corpus/7da9aadc61efbf87721a356af3254d37eb2c0f20 create mode 100644 fuzz/seed_corpus/7de13be5eeb2eecaf2cdc74d0c2bd0ea6b7c6321 create mode 100644 fuzz/seed_corpus/7e4e69c985366bf1858406110a39892313a7c493 create mode 100644 fuzz/seed_corpus/7e641e43a098f4fab7665342745c10c28e89939a create mode 100644 fuzz/seed_corpus/7ebc3a901368f17eb0b187ffc0491400e12fe9b9 create mode 100644 fuzz/seed_corpus/7ed60fa7c3717de45b17ee68ec1783c7480d58a1 create mode 100644 fuzz/seed_corpus/7f0abc1c206fe282b9c426ac221c78bbb0814173 create mode 100644 fuzz/seed_corpus/7f47e1db739cfe08b61962939dbd91a764e26b0e create mode 100644 fuzz/seed_corpus/7f621cd731ad008c88ebb4f78ffe9e1cc3a5b15f create mode 100644 fuzz/seed_corpus/7fde29284068ea511b9b2be6dd901afb585d8064 create mode 100644 fuzz/seed_corpus/8009a62e67818ddf363f49775f8b3e281e8fa04c create mode 100644 fuzz/seed_corpus/801d22b517df552c84c59feef532047455669503 create mode 100644 fuzz/seed_corpus/8107206fa6e510fd3b3faa09c11bc54b5f3e0b53 create mode 100644 fuzz/seed_corpus/810e451e6ad1f1c8680db315bb56c75941df82c7 create mode 100644 fuzz/seed_corpus/8139c334fd7029acc0185cd17ac297ba8c31f3a7 create mode 100644 fuzz/seed_corpus/813ea194416cf7a07ceb9fbbadb6ad95f1681424 create mode 100644 fuzz/seed_corpus/814696d90cc9eb8d7673dea191aa107e69f13a60 create mode 100644 fuzz/seed_corpus/81900cdf0f2e39732efec7b29854ba59dee6ff2b create mode 100644 fuzz/seed_corpus/819a7632e78054517b5e55a3040e35bb963936e7 create mode 100644 fuzz/seed_corpus/81aedd976c16631f3d4d4ac1a5e00fd2371d34f2 create mode 100644 fuzz/seed_corpus/820fa5ffd74c5e842892ebfa6b7be36d63d370b4 create mode 100644 fuzz/seed_corpus/82785abe0718426456457956f3a300b9e3ba2ea3 create mode 100644 fuzz/seed_corpus/827c33d56454cd2748018ba925dcaae7b18bc54f create mode 100644 fuzz/seed_corpus/835d34f465ab2e11016c1d47403d3883d4eacb35 create mode 100644 fuzz/seed_corpus/83d964194f3c6931cdf09f8c6aa572ee4f0a5d92 create mode 100644 fuzz/seed_corpus/83ef3875de50ff739e8734af789bd0626be0ba0d create mode 100644 fuzz/seed_corpus/83fd01d94e4c127179e05ceab010b8c948384433 create mode 100644 fuzz/seed_corpus/8417b375ee04fc01fb076db23961076133df89e5 create mode 100644 fuzz/seed_corpus/842e36feb35a81b08ef1b5aa735f8cea615e6b88 create mode 100644 fuzz/seed_corpus/846b75d8201bc4be99b7f09e9afdbea164af9e5a create mode 100644 fuzz/seed_corpus/850d7f2be8432c8de1bbca56f707ad51d0c4abe8 create mode 100644 fuzz/seed_corpus/857fca83124e5f00ec124068ce52269724f5a72b create mode 100644 fuzz/seed_corpus/8588b54ec193e3458c35a268e00797b24c0cc142 create mode 100644 fuzz/seed_corpus/859ced85aa5862070f5b29f71e3964b35313ca53 create mode 100644 fuzz/seed_corpus/86734dd3530bddd9c5f9b476e92ca59e90b2afff create mode 100644 fuzz/seed_corpus/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 create mode 100644 fuzz/seed_corpus/877409204f0de5d4ed884498ce8daaf153b8864c create mode 100644 fuzz/seed_corpus/878356f08f838142fc384df34b3a17df61b8292a create mode 100644 fuzz/seed_corpus/87e5bf9a5001599b7129c3e25585b27d367303aa create mode 100644 fuzz/seed_corpus/884afcdfc84b1f0c7ad6f50ca6b5bc93896dd0f8 create mode 100644 fuzz/seed_corpus/8887177540290a0076f883559c2a98cffd3cc2f6 create mode 100644 fuzz/seed_corpus/88f441da69c62e97531be947885d667dc74feb0c create mode 100644 fuzz/seed_corpus/8917c5f3ef5e81df9afb1066c255d5026bfd60cc create mode 100644 fuzz/seed_corpus/89260f0b6eec54e5f08f7d84b1866c963ffe71b0 create mode 100644 fuzz/seed_corpus/8963f87b9328c9d602c9995b105074c6ec825122 create mode 100644 fuzz/seed_corpus/89c0961db858d6de841f30462694d870e1de6d39 create mode 100644 fuzz/seed_corpus/89cb2e5aa7972899aa1d0095bb78b5f48ed19c4d create mode 100644 fuzz/seed_corpus/89d905e5699bccb75f335191d92655986b943b80 create mode 100644 fuzz/seed_corpus/8a266e439cc8bdd31c8930fb82ad086ee98cc7e1 create mode 100644 fuzz/seed_corpus/8a38a42e8ed434e7fd85d3031fce504a760aa24b create mode 100644 fuzz/seed_corpus/8a9c98c29c12d19ea2446c319c2655ccb3df188f create mode 100644 fuzz/seed_corpus/8abf3faaa71c4a6765901bb7abdfb339a45c360f create mode 100644 fuzz/seed_corpus/8ac5645ab138ff454b8cd5410d6c43453f58d35b create mode 100644 fuzz/seed_corpus/8c0cf798c2168950b2ebcdb2ca17c68731a52e64 create mode 100644 fuzz/seed_corpus/8c917b16c6eb86a29207bc0dbf26e7121cb0f047 create mode 100644 fuzz/seed_corpus/8ccef0cdd6149cda4059a91943cb00549a8ca71b create mode 100644 fuzz/seed_corpus/8d1f2e6ebd62a8cae3ecdc2b3c79fae65f81628b create mode 100644 fuzz/seed_corpus/8d388f2d9c257a4dcad5264043d0b48a5ed97354 create mode 100644 fuzz/seed_corpus/8e8b74f62c484f2da007454c3f2d840d3135c34b create mode 100644 fuzz/seed_corpus/8ee397e9f2535ca02779820367212d184fc5abc7 create mode 100644 fuzz/seed_corpus/8ee4ec247ee5588249dd3736e5989afa7df33d99 create mode 100644 fuzz/seed_corpus/8eead2134322a2c7ed1795ca2ac9a447017b665b create mode 100644 fuzz/seed_corpus/8f32615410d86304e89d426982559ca7444f1c39 create mode 100644 fuzz/seed_corpus/8f8ae74202ec25228b8f03c2c1dcb22b520b2b74 create mode 100644 fuzz/seed_corpus/8fe1b82e17f7d261af3afa559576ac06006c5bbe create mode 100644 fuzz/seed_corpus/8fe51a539d8f16b217de6aa8df5aa3fa51354d4c create mode 100644 fuzz/seed_corpus/903f6155689859ec4d0acf87bc2733956e2007c8 create mode 100644 fuzz/seed_corpus/904c61a798ae76ecaef0f6158b4ef3403b20d2e0 create mode 100644 fuzz/seed_corpus/906c8ed21f324f22c94c108a3b2b2ab71e57a17c create mode 100644 fuzz/seed_corpus/90d942f05414a5e75f009b436e63b8c9aa99564b create mode 100644 fuzz/seed_corpus/9175ea05ca9c358924d31558bf8c26c24a506ed4 create mode 100644 fuzz/seed_corpus/91817b85cffb36dae26eb991977743f486ec0bd4 create mode 100644 fuzz/seed_corpus/918b86ec3933223d08a79988bf48e171a5b0cd6e create mode 100644 fuzz/seed_corpus/918ec5eb28a03b4389994c4b03448ff84244b8f3 create mode 100644 fuzz/seed_corpus/91c53a0ba38caedb6aedb428044de8690e571eb2 create mode 100644 fuzz/seed_corpus/9206fc32327e79d9444a95e9eab9873ea3c0cc24 create mode 100644 fuzz/seed_corpus/926ef7f39a5d67671db2ef56b3ad52b4021318f5 create mode 100644 fuzz/seed_corpus/928567fc69eae9e536c8cefa3b7654bf63ecc032 create mode 100644 fuzz/seed_corpus/92c7b1ed4b5bb9fd903e941dec640be37dfeaafb create mode 100644 fuzz/seed_corpus/92cc73c67540ad637fd8890c5e44e49ebac8fb59 create mode 100644 fuzz/seed_corpus/92d264ce8685b25ce23f85cc9528833487eebdf7 create mode 100644 fuzz/seed_corpus/93f8de76de6f88df08f467f599c954c8ddc12170 create mode 100644 fuzz/seed_corpus/940863cdaeac10969e9dd60aa5dcf6ba6df4ad03 create mode 100644 fuzz/seed_corpus/943fff6ebe05ba44475aa82880008862ffaa68da create mode 100644 fuzz/seed_corpus/944c3c5375b82e3274fbc765951c97c155ca810e create mode 100644 fuzz/seed_corpus/948413ad9f30726920f53ed384ce679da6451197 create mode 100644 fuzz/seed_corpus/949dbbf408f355b6b930966198039573adf116b3 create mode 100644 fuzz/seed_corpus/94e17da53e77c29e161281f54475026bb5a11569 create mode 100644 fuzz/seed_corpus/94eff61344efe569152a192f5dd15b5576fdb3c7 create mode 100644 fuzz/seed_corpus/9524f282b0bb308fb1e9eaf213956edaf2ce0b33 create mode 100644 fuzz/seed_corpus/958a39844e0cbefb774f1971230f717a1ba3cf9a create mode 100644 fuzz/seed_corpus/9592d346a3cf7521e067d8fb016300cae1d99f5e create mode 100644 fuzz/seed_corpus/96b764d23faf6202f259ede9a3a3cc360a3f513d create mode 100644 fuzz/seed_corpus/96ba2f1e1c31550146f4f395f07f6351ed78ca3c create mode 100644 fuzz/seed_corpus/96d61008474b512bbd5508ea4d9e13fcb13ed4e4 create mode 100644 fuzz/seed_corpus/9722173218adf17b18b5e55fbe9664fae1160541 create mode 100644 fuzz/seed_corpus/98388026d03211bd53544270577d912c94deba19 create mode 100644 fuzz/seed_corpus/985fbaac3b6d3528467187f08fd8f18fb49aaf7b create mode 100644 fuzz/seed_corpus/98a842537cd90630cb5cf8c257ad890f5d03a8fc create mode 100644 fuzz/seed_corpus/98f3b9397b1eaa11e72fd584c6af99cfc2283d2f create mode 100644 fuzz/seed_corpus/98fbfa6c62c30329c879684800e4ba7a7adf6fb2 create mode 100644 fuzz/seed_corpus/99047872cfd306a40075a79e7f142c48de9dd085 create mode 100644 fuzz/seed_corpus/9906041487a221ef5aaae6b3136079f257eaa279 create mode 100644 fuzz/seed_corpus/99461fa0587d9c1dcc9bfaecbcb50d90d0f9fc9e create mode 100644 fuzz/seed_corpus/99e01d1fc129fb19ef635abcc6651e66a47824c0 create mode 100644 fuzz/seed_corpus/9a084e7bdaf5ada2b6fab19bc3f39f7a00d40cd7 create mode 100644 fuzz/seed_corpus/9a2e82d3a88590acfabb0a4b802e95e0122ed7af create mode 100644 fuzz/seed_corpus/9a41829154ea33050146281db0b71487f6752a89 create mode 100644 fuzz/seed_corpus/9aa02917d7765db4c8f9ec2cfbc83488dad5f3d7 create mode 100644 fuzz/seed_corpus/9aabee56f9cc56c02fe2519b37952ed00ea909d6 create mode 100644 fuzz/seed_corpus/9b4ccde252cfe3ed8ff6b03d3f225d0541cb2211 create mode 100644 fuzz/seed_corpus/9b6d872506e2d8e85c3cfd499375946e11c675a7 create mode 100644 fuzz/seed_corpus/9b75744b5800f2b02356669863eb7b3bb18a5e10 create mode 100644 fuzz/seed_corpus/9bc90f962db634de77a1c130aab3dcaefe9567a6 create mode 100644 fuzz/seed_corpus/9c337669960abecc2c6b681f1c12cfc457030f59 create mode 100644 fuzz/seed_corpus/9ca88b6c982c8702def62862162f877e40c71dbc create mode 100644 fuzz/seed_corpus/9cd20220c5e2e9140edf30960fbfe7ce6305d445 create mode 100644 fuzz/seed_corpus/9cecdfd2a3cdbd835d1542703bfea2288d71d3be create mode 100644 fuzz/seed_corpus/9d249724eb4ac0bdf1691e81dc64f29ec0106f82 create mode 100644 fuzz/seed_corpus/9d67253f7b024d0c5ed12e62fb2f54d3223fd20b create mode 100644 fuzz/seed_corpus/9d69c52c2b47d5ce898720d16cd59f73dce33554 create mode 100644 fuzz/seed_corpus/9d6f91da6de2e2b45a597c6bc4642cbebd11d37a create mode 100644 fuzz/seed_corpus/9dba6059f6f285ddf3e0b25ee6bc4a43b438cee8 create mode 100644 fuzz/seed_corpus/9de04ffa9771c61b055b3a79ab8114e36c5bc852 create mode 100644 fuzz/seed_corpus/9de0bf4e8e6d38de4a71975c776f35f5249d1320 create mode 100644 fuzz/seed_corpus/9e0957ff11807ee924bb76fdadc2b01cad441b8d create mode 100644 fuzz/seed_corpus/9e11a5d29f5a4904ff2a26bfa874efec6ffc1225 create mode 100644 fuzz/seed_corpus/9e335a49fead8a4176605ff6de99c5c7c094ed50 create mode 100644 fuzz/seed_corpus/9e46cac97cd53b54068f8b61000d51beb98c1251 create mode 100644 fuzz/seed_corpus/9e71d646d2f96560c894bb4f69595012b081cbcb create mode 100644 fuzz/seed_corpus/9ee967dbb13315de75c9f1650293741282b1b8be create mode 100644 fuzz/seed_corpus/a05d91cbf0902b0fe341c979e9fc18fc69813f55 create mode 100644 fuzz/seed_corpus/a09c49e53e2f72cfc69fe1535b75e398b9e2da0a create mode 100644 fuzz/seed_corpus/a0ace750155ff7b4d004337328e0f73fff48296c create mode 100644 fuzz/seed_corpus/a12d2d35439a7b325daeae7dda813d8d9fd8ec9a create mode 100644 fuzz/seed_corpus/a15a2d4bda5afc0283b7922b22f9b2f81372b52f create mode 100644 fuzz/seed_corpus/a1a5c9bf5b4d3ea28f7aebe6a36ef925c8684e20 create mode 100644 fuzz/seed_corpus/a1c61928dc8532f92366646305c9d925515f5f4f create mode 100644 fuzz/seed_corpus/a1dcdf33e4b1c0d3dca3b36163ab1a74492dfffd create mode 100644 fuzz/seed_corpus/a217169ba383b0b37c6459e99f42351885a9cf9a create mode 100644 fuzz/seed_corpus/a2a94f5d52603abb1ae457737e115edd8570e800 create mode 100644 fuzz/seed_corpus/a2b7cc8c6f518f6e0552c467cb215aaa2cb8c789 create mode 100644 fuzz/seed_corpus/a2ffb091ea66b2c5be67d36428c637fe70bb055b create mode 100644 fuzz/seed_corpus/a351e39e1c2534d882df78962d3f836451656a54 create mode 100644 fuzz/seed_corpus/a35deba5506c7fa4a0a540463f56237e0862c224 create mode 100644 fuzz/seed_corpus/a397c927fcbce17d573ef6e6b51efda250fb2517 create mode 100644 fuzz/seed_corpus/a3e3ee2699da83f568819bb981addcb38092ae1f create mode 100644 fuzz/seed_corpus/a43e4f54e355294d149252cc0f0ce05f7cac63ad create mode 100644 fuzz/seed_corpus/a46db0975b681d55cbc40686a0cafa4b45a9a17f create mode 100644 fuzz/seed_corpus/a47f943f8458185f6adce2f55037703765f232da create mode 100644 fuzz/seed_corpus/a515ea2917796f92e9c96dec3b60f816cdd5b85c create mode 100644 fuzz/seed_corpus/a55ddf0e4881941b2bd3d3a3ebc251fda4cd26d3 create mode 100644 fuzz/seed_corpus/a5adf3a4d1833b1fc94d4903eca9686a7e845442 create mode 100644 fuzz/seed_corpus/a5f16b6b5cd78f6331ab247a3c978beaa632bede create mode 100644 fuzz/seed_corpus/a61f7009b571c49c0639e88668ee34b65a022fef create mode 100644 fuzz/seed_corpus/a66f2c59b5542bed70cd9bbf640466103a086cb1 create mode 100644 fuzz/seed_corpus/a6a6367c0ca61341ec7c77300bee0c6648467357 create mode 100644 fuzz/seed_corpus/a6d363497c7966d8af00f0f4fad5a578b484695b create mode 100644 fuzz/seed_corpus/a736ece169eac1afc7b083d22d60e6650b64d3a8 create mode 100644 fuzz/seed_corpus/a74a6dbf569e64d1117c109356151a6edd5710b3 create mode 100644 fuzz/seed_corpus/a76019df02dfbfeede9e2bec4c49b63751d3329a create mode 100644 fuzz/seed_corpus/a7c82c056aea3e1c467839b6db69f4e2015c478a create mode 100644 fuzz/seed_corpus/a7caca25f9d08d19a6acea2dd2e8acd414244e62 create mode 100644 fuzz/seed_corpus/a7de32bceaa8574c10988e703a3eb79b50fea650 create mode 100644 fuzz/seed_corpus/a825a411610ce28d84d7ea236b0891172cffd1e7 create mode 100644 fuzz/seed_corpus/a9399ac14de393924993c2e2b7cef86ecb543bd1 create mode 100644 fuzz/seed_corpus/a946c6f0e7e270604c5f2a3014cc6053d6f5a478 create mode 100644 fuzz/seed_corpus/a986aeb1ad825a9f45a0cec25a31e4ad64659627 create mode 100644 fuzz/seed_corpus/a9ebffabd9677a657a9ef44e5540e5ed517cf393 create mode 100644 fuzz/seed_corpus/aa02af41473cf07008dd6edcf33cd800414f4628 create mode 100644 fuzz/seed_corpus/aa21bdc5bc23663fe7fe93bc64abdab3e1c6c969 create mode 100644 fuzz/seed_corpus/aa4466264322911f4e340e82b8ede8c4d4e40de1 create mode 100644 fuzz/seed_corpus/aa5f416a1b24637bee0ee023c58d7d82b780af38 create mode 100644 fuzz/seed_corpus/aa7a6b9666bc5abdbafeff6ad604fee839cff4cf create mode 100644 fuzz/seed_corpus/aaa952e35e8e86cb684097528b1a02313ecf9d9e create mode 100644 fuzz/seed_corpus/aabc5ff93ae73f7eb85001270335a3fe49523298 create mode 100644 fuzz/seed_corpus/aabce40b41089adaf52c4973989ba9a4f96ef6bc create mode 100644 fuzz/seed_corpus/aad059c552093c84159931adb386895717ff34f1 create mode 100644 fuzz/seed_corpus/ab460127b776a022baebfe44e7fe099ba5f6fc61 create mode 100644 fuzz/seed_corpus/ab76f337b38a2434c70af0392982f5f0f05465ca create mode 100644 fuzz/seed_corpus/ab81bc3803000942f2e8ec4a95377bdba3b46b1f create mode 100644 fuzz/seed_corpus/ab834372595e54c6f796953decf9ee7e498f455a create mode 100644 fuzz/seed_corpus/aba1fdc077a4b189ffbffb1c0a486df597464f42 create mode 100644 fuzz/seed_corpus/acfcfe811ca61bbd0dd108e0088b9ff4e59bf546 create mode 100644 fuzz/seed_corpus/ad5a1e8e7bb5385d01789c44ee20bb43739e0231 create mode 100644 fuzz/seed_corpus/ae589c86e618d6ee0662ab077f6a56cdd2830aec create mode 100644 fuzz/seed_corpus/aef3356d35a1ef1c662976964bf605e463f0eddb create mode 100644 fuzz/seed_corpus/af3ca51d1e20efbcb7a52077d36362c489b6fb41 create mode 100644 fuzz/seed_corpus/af87d01e96497931b9b2294ad19592dfc8fcfdc9 create mode 100644 fuzz/seed_corpus/af92c19e28175ffedb2e4e057e525000c8957aa8 create mode 100644 fuzz/seed_corpus/afdd6ffe65a766b43299ec8c12d12a43bd65e770 create mode 100644 fuzz/seed_corpus/b01cece4a6652972462aef17952e990ea33978d1 create mode 100644 fuzz/seed_corpus/b07412ff29ba83b3e65d270d9185583a9cc549d5 create mode 100644 fuzz/seed_corpus/b088b9b031752adc71958aceebc53e140cc7b745 create mode 100644 fuzz/seed_corpus/b0d9f006a7407b4b19712b85948a441920e0f087 create mode 100644 fuzz/seed_corpus/b1cae8bc746a5f0c90e837a86644f14f1b8a61f6 create mode 100644 fuzz/seed_corpus/b2b4e17c2181218c026883f4c37ffd575970433d create mode 100644 fuzz/seed_corpus/b2cd7fc6e6ee01c4ff356cd89c8070a5654d722d create mode 100644 fuzz/seed_corpus/b2debffda9a50311d654f3e56bdb22d144192b25 create mode 100644 fuzz/seed_corpus/b2eb9577cac455e58141bf0eccb73e8064a45c42 create mode 100644 fuzz/seed_corpus/b304d40c287feafe05f482628ddbde4f5f7b1336 create mode 100644 fuzz/seed_corpus/b31d7370c53d261b0fdbdfb6da2faa257967ee1d create mode 100644 fuzz/seed_corpus/b3268aeb1a6072253a1f47b703f6793766f61e6d create mode 100644 fuzz/seed_corpus/b35723dce5a5fa5cd828d57182cae241bf38bdcd create mode 100644 fuzz/seed_corpus/b3809062894fb329d7d6316c760f92437a7aed85 create mode 100644 fuzz/seed_corpus/b3a27a573559d424cdc8c229940d0755667d9e15 create mode 100644 fuzz/seed_corpus/b3b51c4f00d47f3259c2808fcf33267453afdca0 create mode 100644 fuzz/seed_corpus/b4146bf40551c98dc173d1788ab0f41acb65247f create mode 100644 fuzz/seed_corpus/b44c7604df02ba25ffa5f7223a5bf59b638ac162 create mode 100644 fuzz/seed_corpus/b5d70dc665888663f6099ff71791b3b919a95ba6 create mode 100644 fuzz/seed_corpus/b5e888307bdab943abd4b259d65c88dcaf7a7cb7 create mode 100644 fuzz/seed_corpus/b611704b84c0dc7432f806fdc918731de39dd5d1 create mode 100644 fuzz/seed_corpus/b64c4b370a571587ada55f2cdb4bf029190643ce create mode 100644 fuzz/seed_corpus/b6d4d1c8a965aa01843fcd511a56ab50d625722a create mode 100644 fuzz/seed_corpus/b6d5046653658bb25225dd94ce6c07b0cb084d04 create mode 100644 fuzz/seed_corpus/b6f408a3a503e1d7c06e8ccd92dbcfd7eec654c6 create mode 100644 fuzz/seed_corpus/b71d03df33da644d74372c7469f533392262071e create mode 100644 fuzz/seed_corpus/b73857fa60381099a6d8627cf39f8b6c580624de create mode 100644 fuzz/seed_corpus/b7a42292653c269389c14a66d1ad85361fb2f4a7 create mode 100644 fuzz/seed_corpus/b7e3712d393926b6cb8794da4eddf040651e0fe8 create mode 100644 fuzz/seed_corpus/b7ede270b7df17a6d9c88b2c749d0e4ab85affc9 create mode 100644 fuzz/seed_corpus/b82652a86c1b0352780cda33c30760eeb166a69f create mode 100644 fuzz/seed_corpus/b8451678adf7bd03b74b089b62ea6e3532d6a85a create mode 100644 fuzz/seed_corpus/b8bb2a22a06ca43ed33ec94c1df22ec57ff3fedb create mode 100644 fuzz/seed_corpus/b9101ee7d5775e24163b8b5a5ae129103f5143cd create mode 100644 fuzz/seed_corpus/b910d78be99309f293372435a4beb19c58dae1bd create mode 100644 fuzz/seed_corpus/bbc8c30cff99d78697c62d67820b5b66175d909d create mode 100644 fuzz/seed_corpus/bc34ba5577cab989aa32e90b54e74e8f01fa7de0 create mode 100644 fuzz/seed_corpus/bc414ce2319a4395d2256621c378534061c83102 create mode 100644 fuzz/seed_corpus/bc9e0d50a6b072a7c7fc8edb5c4aa280f7481dc3 create mode 100644 fuzz/seed_corpus/bcbbb0c5f49bb7829d5836812bc63d56584dab71 create mode 100644 fuzz/seed_corpus/bd58da440a540eaaea9bfe74047fd31c9c483c52 create mode 100644 fuzz/seed_corpus/bd902356757c0a1ee644a6fd83f66730a9e76c8d create mode 100644 fuzz/seed_corpus/bdb849ba8abe7b00117e38535d7416831f8c80df create mode 100644 fuzz/seed_corpus/be56eac98f35828749978c202513175413106946 create mode 100644 fuzz/seed_corpus/be9a95e698a2e0944da7d4a23f1243ecce599875 create mode 100644 fuzz/seed_corpus/bec6cb3b489cd3f3fa596ca828a447dc6ec9a342 create mode 100644 fuzz/seed_corpus/beddada5d3d19dc39630dfd44f69ad74d5291673 create mode 100644 fuzz/seed_corpus/bedf97ed0e035cd4ab9e0fc945ec811f7d2c6e39 create mode 100644 fuzz/seed_corpus/bf29f700d6fd9e85071d12cf214db4b8e4546146 create mode 100644 fuzz/seed_corpus/bf2c5dffdd21801c84d3143a0aaf48befa3c72ba create mode 100644 fuzz/seed_corpus/bf7a039b3bd8e1dd92e8717e7cbfe1596ff5b525 create mode 100644 fuzz/seed_corpus/c00ffcb19683bce5d06900ecfed5694756a7a022 create mode 100644 fuzz/seed_corpus/c06564709f0c1936b27fcf3cafbb277df3f163c0 create mode 100644 fuzz/seed_corpus/c08d7c366ec2bcbca632b0626ecef13b28960ee6 create mode 100644 fuzz/seed_corpus/c0f62f1fdbf485e9abbbc79f6fd250ced4f16c9f create mode 100644 fuzz/seed_corpus/c18484ea6703d83675d3686201770a6a0973c776 create mode 100644 fuzz/seed_corpus/c1a5b33c0ddd62fb5efa04d43504179a96e2c232 create mode 100644 fuzz/seed_corpus/c20ea41108b8430cb59d86cb60c15e524a37db91 create mode 100644 fuzz/seed_corpus/c258f1b95eaafd8396a4f50dc9d4859f41bcdb81 create mode 100644 fuzz/seed_corpus/c26d0a6661eac07a37052737917a1a2b7d4d1681 create mode 100644 fuzz/seed_corpus/c29c1e921a9f56339b41124453929a4afec5992d create mode 100644 fuzz/seed_corpus/c3014cb665379d148e1dea12276ce46edaaeee28 create mode 100644 fuzz/seed_corpus/c373841e84fdd1e4a2ffa813107bba145619ae5f create mode 100644 fuzz/seed_corpus/c37d07e19843eed44df009ae214a8212efbba5e3 create mode 100644 fuzz/seed_corpus/c3828414f84041f5c719ff8ea3bda92a109c9102 create mode 100644 fuzz/seed_corpus/c3e76d78bb16f3a6a328733e4dfcc24c812d85af create mode 100644 fuzz/seed_corpus/c43e7d43be7422f8f4d2e6e61ba9f700ec8e0e89 create mode 100644 fuzz/seed_corpus/c517b723b0c92f577c5675cc4948789ac6855750 create mode 100644 fuzz/seed_corpus/c556f5ce9d21845a21bf0db288303b79fe414947 create mode 100644 fuzz/seed_corpus/c5d1592b8bc0f0d16da2d176da07fa45c363760a create mode 100644 fuzz/seed_corpus/c623c7ef85b0cfb30620665505d993c4d5cb29d8 create mode 100644 fuzz/seed_corpus/c627de28402aa769f395f3db1460b2e257edccae create mode 100644 fuzz/seed_corpus/c65dca0533da176138223dd544b7a956212258d9 create mode 100644 fuzz/seed_corpus/c6c7bf0ce0efad6032bbb1431acfacdfcf9a1c04 create mode 100644 fuzz/seed_corpus/c72455f2c0a7156e0c6ecd2e6d1edae8eccb51ac create mode 100644 fuzz/seed_corpus/c7b8c43e25d751c7987ae8bd7df982074a821cdd create mode 100644 fuzz/seed_corpus/c80f7e4f796e528bffd8ab665754df3ab3c30115 create mode 100644 fuzz/seed_corpus/c82d2e61e7fe29344c2e321ba1db4353ae12dfa7 create mode 100644 fuzz/seed_corpus/c91088fb387ecb298053a47627cee65b70acfe69 create mode 100644 fuzz/seed_corpus/c913c9b25838e522b8775ea0244b6ce3feaf166d create mode 100644 fuzz/seed_corpus/c9a6d1fafdfbd7166197bf2918a3a3a7146b5fe3 create mode 100644 fuzz/seed_corpus/c9ea4b99fb7c8ba39b7cf248eb5ee3f41d2b0537 create mode 100644 fuzz/seed_corpus/ca1472b18ce12cbd062e4526259f4cb3187907be create mode 100644 fuzz/seed_corpus/caabcdc6c450ee18ad88a5fc6d593075aefa216d create mode 100644 fuzz/seed_corpus/cab9852805a552872d47b06b3595e5d4d39330e2 create mode 100644 fuzz/seed_corpus/cb0b2785b3352b163e15a1f435fea8f9b281e59d create mode 100644 fuzz/seed_corpus/cc1d57b4024554fe8675440990fd86de535a1477 create mode 100644 fuzz/seed_corpus/ccb50e4e061089731ddd7e5870a23e5d9f4eb828 create mode 100644 fuzz/seed_corpus/cd2c5d0cdf115ffc2a511a903619ec080083780d create mode 100644 fuzz/seed_corpus/cd331c7d8e0a4bfdd4f55c51f6eff362a6c3c7cb create mode 100644 fuzz/seed_corpus/cd5b68f158f64e27aac4431d102f8bde77c57810 create mode 100644 fuzz/seed_corpus/cdabfa9636c78a896945c1f46a7192fd5e5b0a7b create mode 100644 fuzz/seed_corpus/cdb76e98cb99e6ac5ad72f1efdd2aa58a883048e create mode 100644 fuzz/seed_corpus/ceef31bfd53b0799e6abcf38748ad9bb5990b9b8 create mode 100644 fuzz/seed_corpus/cf4e53a8a18f969ac9b43aeff78198c86d41f36a create mode 100644 fuzz/seed_corpus/cf6c779194b5e51558577fcf30769b56ade5e2d7 create mode 100644 fuzz/seed_corpus/cf7f942399c5a3b845cc136fa34e5ad861acdb54 create mode 100644 fuzz/seed_corpus/cffc6536c4d44d7e75e34b3dfed7f93acf4f50d5 create mode 100644 fuzz/seed_corpus/d00322e8441004cde775bb40c871b728e42be99b create mode 100644 fuzz/seed_corpus/d0570ecf8851adfd1bd51a2465e6862d8d6b2ec9 create mode 100644 fuzz/seed_corpus/d06163d6976510c6cb7da7f76c988f041cb258df create mode 100644 fuzz/seed_corpus/d0ff6fb09092fde34239c08deb10862622a818be create mode 100644 fuzz/seed_corpus/d11072038cf17c70152ca73d3069444ffbbfcc44 create mode 100644 fuzz/seed_corpus/d15e570269e7ec579721d504f093f078172e8523 create mode 100644 fuzz/seed_corpus/d1d8224f7b7a88e4b55244ea9e541e74c26a9ec6 create mode 100644 fuzz/seed_corpus/d26d73648a64321fe7fe62dc0b93cd66b2570084 create mode 100644 fuzz/seed_corpus/d2fb7a23688ec0dc72148289c3b725fad3661521 create mode 100644 fuzz/seed_corpus/d2fc6888be1d6890414aec9b8a044c8e833e32ba create mode 100644 fuzz/seed_corpus/d30ff2eef4d06f11e87d3b6538697533c53baf6d create mode 100644 fuzz/seed_corpus/d4570dfefc02165f1cdd17b23dd164560c98f297 create mode 100644 fuzz/seed_corpus/d4b04c80d79456ddd29852ff2e0f755fb9da3cfd create mode 100644 fuzz/seed_corpus/d4bece7633136a773438a856b74b90a7a18f6288 create mode 100644 fuzz/seed_corpus/d546e9f4c80cddec5cf2c0009f28261abc8b49f7 create mode 100644 fuzz/seed_corpus/d576d262b13fe5a6132d2fce3b579e7abadae94f create mode 100644 fuzz/seed_corpus/d58cd2595ea80d158f85c2b4295f4d0d5b3712f3 create mode 100644 fuzz/seed_corpus/d5d8f4fccebbb9251a71eed7f47dacd469614e16 create mode 100644 fuzz/seed_corpus/d6203ff7f7c9bcfb31249135d523ebe5a0725101 create mode 100644 fuzz/seed_corpus/d6c851486e045537153a935e0e42415fd61381d3 create mode 100644 fuzz/seed_corpus/d6e9358cf1fe2861822540c6932388340387c699 create mode 100644 fuzz/seed_corpus/d79f3ae0e96910f4fe5dd6ffd5ab8f86f56c39de create mode 100644 fuzz/seed_corpus/d7c291bdab167059f6f899e382f8f47e0b13c4f9 create mode 100644 fuzz/seed_corpus/d7f464863375cce2782560dc3b9fd9c2cdb8926a create mode 100644 fuzz/seed_corpus/d81428626958abd518d6c134d7a9ea87b5cff318 create mode 100644 fuzz/seed_corpus/d82702d7ec184d55abed27ef3ccb661946d6b8a5 create mode 100644 fuzz/seed_corpus/d8b697195e3739a40d1f319bb9694a4f950a271d create mode 100644 fuzz/seed_corpus/d8b6ee7feabb35bfc3a4d0a57cca57256a00f32e create mode 100644 fuzz/seed_corpus/d8cd7c6cbd7df0ccaf2775eb871056c8e1440492 create mode 100644 fuzz/seed_corpus/d8d8458b41bfd1be0666219c48753b978f07220d create mode 100644 fuzz/seed_corpus/d8db597176d451fd8cba11f0a2f3a10fc4cdc28c create mode 100644 fuzz/seed_corpus/d8f64185ec3cad1500438e167d9aa29c431c232a create mode 100644 fuzz/seed_corpus/d91875585187f6f307fced086265751d8d06db4b create mode 100644 fuzz/seed_corpus/d947c15aeab4efb0c9a1e94218d4f670b8b3118a create mode 100644 fuzz/seed_corpus/d9589c6b55abf58559c539e210ef83ee6d77ffa5 create mode 100644 fuzz/seed_corpus/d97616c1b428d480df45dc0cb9bfb47e1923eac4 create mode 100644 fuzz/seed_corpus/d99811f11d8cd0ed2f9773e452d52f5d698b6159 create mode 100644 fuzz/seed_corpus/d9f18950b3e5d0d82affa99864bce27bbf37318e create mode 100644 fuzz/seed_corpus/da0113f5e076c5cc48013f0bb94a647225494fdb create mode 100644 fuzz/seed_corpus/da24b9bd2c3089307c7ca096c0e3c3168f2f136e create mode 100644 fuzz/seed_corpus/da409847feb7307a2d99da1736335903e7a08c9d create mode 100644 fuzz/seed_corpus/da461c67c6e157aae3f1926e74e3c009d4c81ce7 create mode 100644 fuzz/seed_corpus/da77e89d8b7151b40e88ddd72fc12c259558fed2 create mode 100644 fuzz/seed_corpus/da8b41e4e393198ec1c82a03fae293739270d5fa create mode 100644 fuzz/seed_corpus/daa2d31781655a5b1d8446b8136b95318a0966b1 create mode 100644 fuzz/seed_corpus/db0ca64ef24fa55f812e91ac4e62c0eed8fd761e create mode 100644 fuzz/seed_corpus/dbe773660384362ed0203ab45d99676bb8f125d7 create mode 100644 fuzz/seed_corpus/dbf232a7b5d62cdaed37fd767dfd4c4bc5a2e62f create mode 100644 fuzz/seed_corpus/dc388ade7cb417aef05e482226e6ac0f6b14aa8a create mode 100644 fuzz/seed_corpus/dc79db881ce47a17d41f3fd1aa2a8ef25a39e702 create mode 100644 fuzz/seed_corpus/dcda58a9de184153339f6e034f1197971a52be9d create mode 100644 fuzz/seed_corpus/dd42a77d0a26e247393e219ae118099704fe49d9 create mode 100644 fuzz/seed_corpus/dd6b7d4ecf5e7c9d958f189612eea4e2ae76ef29 create mode 100644 fuzz/seed_corpus/ddcaee92a22818af70f51925a99fe49a493f047f create mode 100644 fuzz/seed_corpus/de782e47c0ff425acef9e69ed2add0a53e0ed06d create mode 100644 fuzz/seed_corpus/de878075f6782e9760e8c39be348d36e4c4b415d create mode 100644 fuzz/seed_corpus/defe04240669688418387bbb8e173b5f8e130bac create mode 100644 fuzz/seed_corpus/df3072782ab255b28e0d96a5227077e28181b1d9 create mode 100644 fuzz/seed_corpus/df6e3e838051c8daf8612a6c17efd8f22bbfc812 create mode 100644 fuzz/seed_corpus/df7870165674d3250df81caa6050f27cacb6b3ad create mode 100644 fuzz/seed_corpus/df898e40bbd3e5274f557d7ca2771ee917a16813 create mode 100644 fuzz/seed_corpus/e01768c294422ab08779476b523cef496b78cc4f create mode 100644 fuzz/seed_corpus/e022d6598576e548d57ca817dbc6b643894d99c1 create mode 100644 fuzz/seed_corpus/e05805587d52c07c8930c58157324b9a891db980 create mode 100644 fuzz/seed_corpus/e18853f27569684ef04566f8a6a6f7ff0f98699f create mode 100644 fuzz/seed_corpus/e1d9f0d7e34932a19083fe2d07610b95458b3f12 create mode 100644 fuzz/seed_corpus/e1dd3a83e770c4a0e2298081e3a6c6f3bf090b23 create mode 100644 fuzz/seed_corpus/e283a860ffbdc2eba98723494005fe69b9a8fdec create mode 100644 fuzz/seed_corpus/e2a0cdbc0db446b490f062e0a48dba4e3ea4ac53 create mode 100644 fuzz/seed_corpus/e2b27751d61baec65ec11a90bdb6b6bea9b6b8f0 create mode 100644 fuzz/seed_corpus/e33e55e325ec80d814bf28ca49f840353307a7bb create mode 100644 fuzz/seed_corpus/e350256d18eb9558310d1be0f28f65ededf073e1 create mode 100644 fuzz/seed_corpus/e35736ef1899750598c0d39238bb4b7fb06b45c8 create mode 100644 fuzz/seed_corpus/e3711bd4ec51bf3c4bf714e7cc03dbdfe9359c88 create mode 100644 fuzz/seed_corpus/e37c75a17d04c0f0bf59da4112e6d3786b194f7b create mode 100644 fuzz/seed_corpus/e3a53f28379e13087721b1aeb56cc3cba0a15d0e create mode 100644 fuzz/seed_corpus/e42c8c2aadd5f098057e5172cbf634f216e2993d create mode 100644 fuzz/seed_corpus/e446ff7d794da14a04824b58fb83e892a3979632 create mode 100644 fuzz/seed_corpus/e45fb8b623f480a7a5504ab0e6b6fc601d746ea0 create mode 100644 fuzz/seed_corpus/e4acd859bafa872425093eee79f9f86aaf9c40f3 create mode 100644 fuzz/seed_corpus/e4b4eb474268499df29d7bb2a9f32a327c972c19 create mode 100644 fuzz/seed_corpus/e5ddf81c4676e07f7dd05fbc9b06bb0d581e204e create mode 100644 fuzz/seed_corpus/e5f8e32c54beaaa027714bad3ad61f6197c39d47 create mode 100644 fuzz/seed_corpus/e63873194590e5597125d736bfff6609c1d9284b create mode 100644 fuzz/seed_corpus/e66ea97d349ef03ee5be65751bb22500492c7fda create mode 100644 fuzz/seed_corpus/e68268693c6cbf457c55fdffe4842ae5c2b6b0bf create mode 100644 fuzz/seed_corpus/e6878382c8b650c1b21618f674eeca251fed95d5 create mode 100644 fuzz/seed_corpus/e6ba493eb6a8bc75fd51f701327ecc645b28b36d create mode 100644 fuzz/seed_corpus/e78326a60256a40c1af7de4c242522c7a251d7a7 create mode 100644 fuzz/seed_corpus/e7eed1001cfb9e584dc49c4a45ce272eccbb2e2e create mode 100644 fuzz/seed_corpus/e850afad5db2691b9bdab3186e33e1c3fd4a2422 create mode 100644 fuzz/seed_corpus/e98f2dca1b4b0ad9090fff2718e08f8d5e76ea95 create mode 100644 fuzz/seed_corpus/e9f4d7d5f5513df4063664282feed769a1913667 create mode 100644 fuzz/seed_corpus/ea2f58cedd76ed86230f95dbe6c0552c310870c8 create mode 100644 fuzz/seed_corpus/ea307355d613abc8753b3dbb3e1c665622818f96 create mode 100644 fuzz/seed_corpus/ea3a686218a1712857a4480bcc00fb0322769112 create mode 100644 fuzz/seed_corpus/ea7a291d9f89ea7194f8ccf2691f008d4575ed52 create mode 100644 fuzz/seed_corpus/ea95fd405c17ebb43d435ed0f2dc035b55da755c create mode 100644 fuzz/seed_corpus/eadfdf6cd427e4112da2c3c92709e16293c29399 create mode 100644 fuzz/seed_corpus/eaeacf56eda88e8c339dea608655a5e5c4fad218 create mode 100644 fuzz/seed_corpus/eb0ca34c35ef83f6a22f102cf93518cd053a3021 create mode 100644 fuzz/seed_corpus/eb36d039e3d4684168e891f622ac594cc3fbaf42 create mode 100644 fuzz/seed_corpus/eb9e916f423bcf760684662475c708a025b95b4e create mode 100644 fuzz/seed_corpus/ebaca305f93bd06424883010a0f632a919978edf create mode 100644 fuzz/seed_corpus/ebf3b1699b7b6329fb99c382af456012e67f5179 create mode 100644 fuzz/seed_corpus/ebfdf168cbd0b6544f85ef6981e85eb3e84cac28 create mode 100644 fuzz/seed_corpus/eca395361e001e5fb922e39e07ed183adb01e320 create mode 100644 fuzz/seed_corpus/ecd7838d793f699b0486c6c324978e736ef61619 create mode 100644 fuzz/seed_corpus/ed206eab22275377ad5c1da293035b31681ddad7 create mode 100644 fuzz/seed_corpus/ed43278c90877dd1ee7697e843f546a07aad9551 create mode 100644 fuzz/seed_corpus/ed494ca370b9903b2ff256781b75a6571d1d5a11 create mode 100644 fuzz/seed_corpus/ee0a1f3873684bcf96086ce968ef405058c321a7 create mode 100644 fuzz/seed_corpus/ee1753eec5e01838716ff9cc2ea9cfc6a9515c89 create mode 100644 fuzz/seed_corpus/ee358b6c00d270f249fc2adf44e6c4a817da34b6 create mode 100644 fuzz/seed_corpus/ee576bfe8296364856100aa291be0f674fcec238 create mode 100644 fuzz/seed_corpus/ee9f91652a85a8ab60d49c264814b7eb39aa0005 create mode 100644 fuzz/seed_corpus/ef6238d1f01ecc4837c37d151e0073d64fa64021 create mode 100644 fuzz/seed_corpus/efe16059300229cc741b1e0e0b5b8dcf8bd3016a create mode 100644 fuzz/seed_corpus/effeacf25e65f710df82a417e717e1475422ca6d create mode 100644 fuzz/seed_corpus/f020f897246b789dbb0ee0546adcc31aed2a9ee0 create mode 100644 fuzz/seed_corpus/f0723ab9a1646520de4b5f31a7815d3ea7cdd51b create mode 100644 fuzz/seed_corpus/f090836861567a731c9ff9a0cc442ec2f84ecde7 create mode 100644 fuzz/seed_corpus/f0a7ed887160790e58fdc3da2ff945de1292c092 create mode 100644 fuzz/seed_corpus/f0acca34675a484e17c4a37d21d1b750802ef0e8 create mode 100644 fuzz/seed_corpus/f0cde31202f994b0a110b32e975d8e426c5fea87 create mode 100644 fuzz/seed_corpus/f0ce65ba63d77082ebf72bdd754e9974b9265385 create mode 100644 fuzz/seed_corpus/f0ed91f4691325b8d18a1bc957f1458d5986080e create mode 100644 fuzz/seed_corpus/f1741ff0cf92c3fcc2457b0ddeaf361c641e1f7f create mode 100644 fuzz/seed_corpus/f1860ac11f7e00cf33f11cdae78eb6dea2e5cc4e create mode 100644 fuzz/seed_corpus/f1f92206392a06f94ae57ecf1a2633a1abad6e23 create mode 100644 fuzz/seed_corpus/f209388ec3e50da32cb1d6300f187ecfb56ddd5b create mode 100644 fuzz/seed_corpus/f26b7b6046881d29051125a558146bad500d9ea9 create mode 100644 fuzz/seed_corpus/f2de7fa0a17499f6b233db120d5a1a18ef440f00 create mode 100644 fuzz/seed_corpus/f310c45fdfa4895fcb578cf5a4267bcfe0da0bf5 create mode 100644 fuzz/seed_corpus/f312081b10d97bf57c9aa4b3edc9119a285daca7 create mode 100644 fuzz/seed_corpus/f559e4a5a9778ee70994b3f5e5717dd65ec50be6 create mode 100644 fuzz/seed_corpus/f596ecbc4c176f72de5c9b96bf7a3b4372c297ff create mode 100644 fuzz/seed_corpus/f60cdbe3f8ed30f11ffff0fa13fd0f1bbdb74f9f create mode 100644 fuzz/seed_corpus/f611b5aff1df08a9ef90a9ab3b8eb2c7066fd5d7 create mode 100644 fuzz/seed_corpus/f6367e7d51f3131f915ebdb0dea0ab7d85996abf create mode 100644 fuzz/seed_corpus/f6b84f405673899265d312a025824cffaf3c5602 create mode 100644 fuzz/seed_corpus/f72ac7db80028034dbce84de2aba0d3c9130d83a create mode 100644 fuzz/seed_corpus/f7414f33a411a27a9f58a8fd7a13ac0dc538ee35 create mode 100644 fuzz/seed_corpus/f755658e54ba2c60b31185eb6dc8a8e4a45f2ff1 create mode 100644 fuzz/seed_corpus/f7c6d96423611b00e09749905ddd73fac4da09fa create mode 100644 fuzz/seed_corpus/f80b1212109606ae9430eb0798a9274bb965df1b create mode 100644 fuzz/seed_corpus/f82ce14867e33546972cfe50f05ded5f345ca2a9 create mode 100644 fuzz/seed_corpus/f8ad4720f083362a24c5963814415c7be11a7e79 create mode 100644 fuzz/seed_corpus/f915aa5bc416b6bdd19e7c0b0f6b4c19953a29f8 create mode 100644 fuzz/seed_corpus/f94f6f4d473d9c94bfe19ca2c9974fe789ed89da create mode 100644 fuzz/seed_corpus/f9546aaaffe76c7a4b3afc0eb9a312799ce40ea5 create mode 100644 fuzz/seed_corpus/f96987a68d8061bb01bd1eeacbfca277e032012c create mode 100644 fuzz/seed_corpus/f9c716c6e1f3ac4e832f55dc011bfe4085a01db8 create mode 100644 fuzz/seed_corpus/fa4d70596680927bfd981d5241a7da346beeb3ed create mode 100644 fuzz/seed_corpus/faafa8ee7573f5bb95383ccfeb954bf381d20908 create mode 100644 fuzz/seed_corpus/fabeea396572fe8077d643f7a4669a6d88ae0ffe create mode 100644 fuzz/seed_corpus/fad544376cf60a6890cf92176fa131711462b407 create mode 100644 fuzz/seed_corpus/fada6bbfeb016ac55774da7e82d09d0d337ebea9 create mode 100644 fuzz/seed_corpus/fb423796352beb7e2c43e48123b5fd618e81ee54 create mode 100644 fuzz/seed_corpus/fb676b7944c1360a8a6a548cf3e3b03573f1c154 create mode 100644 fuzz/seed_corpus/fb72df780abbd6764dfe18e2ddd8ca4c58faf92f create mode 100644 fuzz/seed_corpus/fbc675a6b2d1a45be278954494ee34d4c2324245 create mode 100644 fuzz/seed_corpus/fbcdd7a1e0f5b2e115172130a7c514ac9a6dd62d create mode 100644 fuzz/seed_corpus/fbd91b3106732ac8dbbb4e004059863e5f52c13c create mode 100644 fuzz/seed_corpus/fbddeb5bcd495bea003d6cb25fd30b7e3116db11 create mode 100644 fuzz/seed_corpus/fbfe47c7706c079e2c44afee40e3524c2440029e create mode 100644 fuzz/seed_corpus/fbff3217c31fb539f0569beb0d664343ede5cc40 create mode 100644 fuzz/seed_corpus/fc06ad946ed7f4571e5930d6a384c659f84c4188 create mode 100644 fuzz/seed_corpus/fc3356c1ca991cf185c46c51a64a12d8f2c493be create mode 100644 fuzz/seed_corpus/fca35dd48ecd9ca7c40e2da79be8eb85576afbcf create mode 100644 fuzz/seed_corpus/fcb613d231528bc7d607472cd2cab2a5e0f67691 create mode 100644 fuzz/seed_corpus/fd04e1aa723bcb93112c09c67a15490942737641 create mode 100644 fuzz/seed_corpus/fd63b95f8af23f1259eb5a65024ad98c3d05cb51 create mode 100644 fuzz/seed_corpus/fd936eb09ddf3f09ee1f0fecfd3fae7e18e1dc12 create mode 100644 fuzz/seed_corpus/fdd2445027e39637bb4167d42d309b3e84f0c864 create mode 100644 fuzz/seed_corpus/fe2353aca291b4df4bd6f4e86038d3e079551ca6 create mode 100644 fuzz/seed_corpus/fe2f2896838152f14b4515fad701da97e6ebb34c create mode 100644 fuzz/seed_corpus/fe331c4e77bd414496d817c48d65dad2ef5ca715 create mode 100644 fuzz/seed_corpus/fe47d9336fd3bd30d01191bce1a0abfce0622a71 create mode 100644 fuzz/seed_corpus/fe656c49ba6f5f55afc0560faf29542ce744d8f2 create mode 100644 fuzz/seed_corpus/feaddd2bfb7ee62a7fdbde7891b47e1633387800 create mode 100644 fuzz/seed_corpus/febb40c376d47ed2104875a83128d287c32a5596 create mode 100644 fuzz/seed_corpus/fed9e49575133eeb6fd117175447e2ebb69cb99c create mode 100644 fuzz/seed_corpus/ff0ecae15d2a85c2565c63a7581d534173b0010d create mode 100644 fuzz/seed_corpus/ff80ec4e56255991bed8921019f2d413767a2fed create mode 100644 fuzz/seed_corpus/input0 create mode 100644 fuzz/seed_corpus/input1 create mode 100644 fuzz/seed_corpus/input10 create mode 100644 fuzz/seed_corpus/input11 create mode 100644 fuzz/seed_corpus/input2 create mode 100644 fuzz/seed_corpus/input3 create mode 100644 fuzz/seed_corpus/input4 create mode 100644 fuzz/seed_corpus/input5 create mode 100644 fuzz/seed_corpus/input6 create mode 100644 fuzz/seed_corpus/input7 create mode 100644 fuzz/seed_corpus/input8 create mode 100644 fuzz/seed_corpus/input9 create mode 100644 fuzz/xml.dict create mode 100644 libxml_visibility.gni create mode 100644 linux/config.h create mode 100644 linux/include/libxml/xmlversion.h create mode 100755 linux/xml2-config create mode 100644 mac/config.h create mode 100644 mac/include/libxml/xmlversion.h create mode 100644 src/AUTHORS create mode 100644 src/CMakeLists.txt create mode 100644 src/ChangeLog create mode 100644 src/Copyright create mode 100644 src/HTMLparser.c create mode 100644 src/HTMLtree.c create mode 100644 src/Makefile.am create mode 100644 src/Makefile.tests create mode 100644 src/NEWS create mode 100644 src/README create mode 100644 src/README.tests create mode 100644 src/README.zOS create mode 100644 src/SAX2.c create mode 100644 src/TODO create mode 100644 src/TODO_SCHEMAS create mode 100644 src/acinclude.m4 create mode 100644 src/aclocal.m4 create mode 100644 src/buf.c create mode 100644 src/buf.h create mode 100755 src/check-relaxng-test-suite.py create mode 100755 src/check-relaxng-test-suite2.py create mode 100755 src/check-xinclude-test-suite.py create mode 100755 src/check-xml-test-suite.py create mode 100755 src/check-xsddata-test-suite.py create mode 100644 src/chvalid.c create mode 100644 src/config.h.cmake.in create mode 100644 src/config.h.in create mode 100644 src/configure.ac create mode 100755 src/dbgen.pl create mode 100755 src/dbgenattr.pl create mode 100644 src/dict.c create mode 100644 src/elfgcchack.h create mode 100644 src/enc.h create mode 100644 src/encoding.c create mode 100644 src/entities.c create mode 100644 src/error.c create mode 100644 src/fuzz/Makefile.am create mode 100644 src/fuzz/Makefile.in create mode 100644 src/fuzz/README create mode 100644 src/fuzz/fuzz.c create mode 100644 src/fuzz/fuzz.h create mode 100644 src/fuzz/genSeed.c create mode 100644 src/fuzz/html.c create mode 100644 src/fuzz/html.dict create mode 100644 src/fuzz/regexp.c create mode 100644 src/fuzz/regexp.dict create mode 100644 src/fuzz/schema.c create mode 100644 src/fuzz/schema.dict create mode 100644 src/fuzz/seed/regexp/branch-1 create mode 100644 src/fuzz/seed/regexp/branch-10 create mode 100644 src/fuzz/seed/regexp/branch-11 create mode 100644 src/fuzz/seed/regexp/branch-12 create mode 100644 src/fuzz/seed/regexp/branch-13 create mode 100644 src/fuzz/seed/regexp/branch-2 create mode 100644 src/fuzz/seed/regexp/branch-3 create mode 100644 src/fuzz/seed/regexp/branch-4 create mode 100644 src/fuzz/seed/regexp/branch-5 create mode 100644 src/fuzz/seed/regexp/branch-6 create mode 100644 src/fuzz/seed/regexp/branch-7 create mode 100644 src/fuzz/seed/regexp/branch-8 create mode 100644 src/fuzz/seed/regexp/branch-9 create mode 100644 src/fuzz/seed/regexp/bug316338-1 create mode 100644 src/fuzz/seed/regexp/bug316338-10 create mode 100644 src/fuzz/seed/regexp/bug316338-11 create mode 100644 src/fuzz/seed/regexp/bug316338-12 create mode 100644 src/fuzz/seed/regexp/bug316338-13 create mode 100644 src/fuzz/seed/regexp/bug316338-14 create mode 100644 src/fuzz/seed/regexp/bug316338-15 create mode 100644 src/fuzz/seed/regexp/bug316338-16 create mode 100644 src/fuzz/seed/regexp/bug316338-2 create mode 100644 src/fuzz/seed/regexp/bug316338-3 create mode 100644 src/fuzz/seed/regexp/bug316338-4 create mode 100644 src/fuzz/seed/regexp/bug316338-5 create mode 100644 src/fuzz/seed/regexp/bug316338-6 create mode 100644 src/fuzz/seed/regexp/bug316338-7 create mode 100644 src/fuzz/seed/regexp/bug316338-8 create mode 100644 src/fuzz/seed/regexp/bug316338-9 create mode 100644 src/fuzz/seed/regexp/bug420596-1 create mode 100644 src/fuzz/seed/regexp/bug420596-2 create mode 100644 src/fuzz/seed/regexp/bug420596-3 create mode 100644 src/fuzz/seed/regexp/bug420596-4 create mode 100644 src/fuzz/seed/regexp/bug420596-5 create mode 100644 src/fuzz/seed/regexp/bug420596-6 create mode 100644 src/fuzz/seed/regexp/bug420596-7 create mode 100644 src/fuzz/seed/regexp/bug420596-8 create mode 100644 src/fuzz/seed/regexp/content-1 create mode 100644 src/fuzz/seed/regexp/content-10 create mode 100644 src/fuzz/seed/regexp/content-2 create mode 100644 src/fuzz/seed/regexp/content-3 create mode 100644 src/fuzz/seed/regexp/content-4 create mode 100644 src/fuzz/seed/regexp/content-5 create mode 100644 src/fuzz/seed/regexp/content-6 create mode 100644 src/fuzz/seed/regexp/content-7 create mode 100644 src/fuzz/seed/regexp/content-8 create mode 100644 src/fuzz/seed/regexp/content-9 create mode 100644 src/fuzz/seed/regexp/hard-1 create mode 100644 src/fuzz/seed/regexp/hard-10 create mode 100644 src/fuzz/seed/regexp/hard-2 create mode 100644 src/fuzz/seed/regexp/hard-3 create mode 100644 src/fuzz/seed/regexp/hard-4 create mode 100644 src/fuzz/seed/regexp/hard-5 create mode 100644 src/fuzz/seed/regexp/hard-6 create mode 100644 src/fuzz/seed/regexp/hard-7 create mode 100644 src/fuzz/seed/regexp/hard-8 create mode 100644 src/fuzz/seed/regexp/hard-9 create mode 100644 src/fuzz/seed/regexp/ncname-1 create mode 100644 src/fuzz/seed/regexp/ncname-2 create mode 100644 src/fuzz/seed/regexp/ncname-3 create mode 100644 src/fuzz/seed/regexp/ncname-4 create mode 100644 src/fuzz/seed/regexp/ncname-5 create mode 100644 src/fuzz/seed/regexp/ranges-1 create mode 100644 src/fuzz/seed/regexp/ranges-10 create mode 100644 src/fuzz/seed/regexp/ranges-11 create mode 100644 src/fuzz/seed/regexp/ranges-12 create mode 100644 src/fuzz/seed/regexp/ranges-2 create mode 100644 src/fuzz/seed/regexp/ranges-3 create mode 100644 src/fuzz/seed/regexp/ranges-4 create mode 100644 src/fuzz/seed/regexp/ranges-5 create mode 100644 src/fuzz/seed/regexp/ranges-6 create mode 100644 src/fuzz/seed/regexp/ranges-7 create mode 100644 src/fuzz/seed/regexp/ranges-8 create mode 100644 src/fuzz/seed/regexp/ranges-9 create mode 100644 src/fuzz/seed/regexp/ranges2-1 create mode 100644 src/fuzz/seed/regexp/ranges2-10 create mode 100644 src/fuzz/seed/regexp/ranges2-11 create mode 100644 src/fuzz/seed/regexp/ranges2-12 create mode 100644 src/fuzz/seed/regexp/ranges2-2 create mode 100644 src/fuzz/seed/regexp/ranges2-3 create mode 100644 src/fuzz/seed/regexp/ranges2-4 create mode 100644 src/fuzz/seed/regexp/ranges2-5 create mode 100644 src/fuzz/seed/regexp/ranges2-6 create mode 100644 src/fuzz/seed/regexp/ranges2-7 create mode 100644 src/fuzz/seed/regexp/ranges2-8 create mode 100644 src/fuzz/seed/regexp/ranges2-9 create mode 100644 src/fuzz/seed/regexp/xpath-1 create mode 100644 src/fuzz/seed/regexp/xpath-10 create mode 100644 src/fuzz/seed/regexp/xpath-11 create mode 100644 src/fuzz/seed/regexp/xpath-12 create mode 100644 src/fuzz/seed/regexp/xpath-13 create mode 100644 src/fuzz/seed/regexp/xpath-14 create mode 100644 src/fuzz/seed/regexp/xpath-15 create mode 100644 src/fuzz/seed/regexp/xpath-16 create mode 100644 src/fuzz/seed/regexp/xpath-17 create mode 100644 src/fuzz/seed/regexp/xpath-18 create mode 100644 src/fuzz/seed/regexp/xpath-19 create mode 100644 src/fuzz/seed/regexp/xpath-2 create mode 100644 src/fuzz/seed/regexp/xpath-20 create mode 100644 src/fuzz/seed/regexp/xpath-21 create mode 100644 src/fuzz/seed/regexp/xpath-22 create mode 100644 src/fuzz/seed/regexp/xpath-23 create mode 100644 src/fuzz/seed/regexp/xpath-24 create mode 100644 src/fuzz/seed/regexp/xpath-25 create mode 100644 src/fuzz/seed/regexp/xpath-26 create mode 100644 src/fuzz/seed/regexp/xpath-27 create mode 100644 src/fuzz/seed/regexp/xpath-28 create mode 100644 src/fuzz/seed/regexp/xpath-29 create mode 100644 src/fuzz/seed/regexp/xpath-3 create mode 100644 src/fuzz/seed/regexp/xpath-30 create mode 100644 src/fuzz/seed/regexp/xpath-31 create mode 100644 src/fuzz/seed/regexp/xpath-32 create mode 100644 src/fuzz/seed/regexp/xpath-33 create mode 100644 src/fuzz/seed/regexp/xpath-34 create mode 100644 src/fuzz/seed/regexp/xpath-35 create mode 100644 src/fuzz/seed/regexp/xpath-4 create mode 100644 src/fuzz/seed/regexp/xpath-5 create mode 100644 src/fuzz/seed/regexp/xpath-6 create mode 100644 src/fuzz/seed/regexp/xpath-7 create mode 100644 src/fuzz/seed/regexp/xpath-8 create mode 100644 src/fuzz/seed/regexp/xpath-9 create mode 100644 src/fuzz/seed/uri/dot create mode 100644 src/fuzz/seed/uri/full create mode 100644 src/fuzz/testFuzzer.c create mode 100644 src/fuzz/uri.c create mode 100644 src/fuzz/xml.c create mode 100644 src/fuzz/xml.dict create mode 100644 src/fuzz/xpath.c create mode 100644 src/fuzz/xpath.dict create mode 100755 src/genUnicode.py create mode 100755 src/gentest.py create mode 100644 src/globals.c create mode 100644 src/hash.c create mode 100644 src/include/Makefile.am create mode 100644 src/include/libxml/DOCBparser.h create mode 100644 src/include/libxml/HTMLparser.h create mode 100644 src/include/libxml/HTMLtree.h create mode 100644 src/include/libxml/Makefile.am create mode 100644 src/include/libxml/SAX.h create mode 100644 src/include/libxml/SAX2.h create mode 100644 src/include/libxml/c14n.h create mode 100644 src/include/libxml/catalog.h create mode 100644 src/include/libxml/chvalid.h create mode 100644 src/include/libxml/debugXML.h create mode 100644 src/include/libxml/dict.h create mode 100644 src/include/libxml/encoding.h create mode 100644 src/include/libxml/entities.h create mode 100644 src/include/libxml/globals.h create mode 100644 src/include/libxml/hash.h create mode 100644 src/include/libxml/list.h create mode 100644 src/include/libxml/nanoftp.h create mode 100644 src/include/libxml/nanohttp.h create mode 100644 src/include/libxml/parser.h create mode 100644 src/include/libxml/parserInternals.h create mode 100644 src/include/libxml/pattern.h create mode 100644 src/include/libxml/relaxng.h create mode 100644 src/include/libxml/schemasInternals.h create mode 100644 src/include/libxml/schematron.h create mode 100644 src/include/libxml/threads.h create mode 100644 src/include/libxml/tree.h create mode 100644 src/include/libxml/uri.h create mode 100644 src/include/libxml/valid.h create mode 100644 src/include/libxml/xinclude.h create mode 100644 src/include/libxml/xlink.h create mode 100644 src/include/libxml/xmlIO.h create mode 100644 src/include/libxml/xmlautomata.h create mode 100644 src/include/libxml/xmlerror.h create mode 100644 src/include/libxml/xmlexports.h create mode 100644 src/include/libxml/xmlmemory.h create mode 100644 src/include/libxml/xmlmodule.h create mode 100644 src/include/libxml/xmlreader.h create mode 100644 src/include/libxml/xmlregexp.h create mode 100644 src/include/libxml/xmlsave.h create mode 100644 src/include/libxml/xmlschemas.h create mode 100644 src/include/libxml/xmlschemastypes.h create mode 100644 src/include/libxml/xmlstring.h create mode 100644 src/include/libxml/xmlunicode.h create mode 100644 src/include/libxml/xmlversion.h.in create mode 100644 src/include/libxml/xmlwriter.h create mode 100644 src/include/libxml/xpath.h create mode 100644 src/include/libxml/xpathInternals.h create mode 100644 src/include/libxml/xpointer.h create mode 100644 src/include/win32config.h create mode 100644 src/include/wsockcompat.h create mode 100644 src/libxml-2.0-uninstalled.pc.in create mode 100644 src/libxml-2.0.pc.in create mode 100644 src/libxml.3 create mode 100644 src/libxml.h create mode 100644 src/libxml.m4 create mode 100644 src/libxml.spec.in create mode 100644 src/libxml2-config.cmake.cmake.in create mode 100644 src/libxml2-config.cmake.in create mode 100644 src/libxml2.spec create mode 100644 src/libxml2.syms create mode 100644 src/list.c create mode 100644 src/macos/README create mode 100644 src/macos/src/XMLTestPrefix.h create mode 100644 src/macos/src/XMLTestPrefix2.h create mode 100644 src/macos/src/config-mac.h create mode 100644 src/macos/src/libxml2_GUSIConfig.cp create mode 100644 src/macos/src/macos_main.c create mode 100644 src/nanoftp.c create mode 100644 src/nanohttp.c create mode 100644 src/parser.c create mode 100644 src/parserInternals.c create mode 100644 src/pattern.c create mode 100755 src/regressions.py create mode 100644 src/regressions.xml create mode 100644 src/runsuite.c create mode 100644 src/runtest.c create mode 100644 src/runxmlconf.c create mode 100644 src/save.h create mode 100644 src/testAutomata.c create mode 100644 src/testC14N.c create mode 100644 src/testHTML.c create mode 100644 src/testModule.c create mode 100644 src/testReader.c create mode 100644 src/testRegexp.c create mode 100644 src/testRelax.c create mode 100644 src/testSAX.c create mode 100644 src/testSchemas.c create mode 100644 src/testThreads.c create mode 100644 src/testURI.c create mode 100644 src/testXPath.c create mode 100644 src/testapi.c create mode 100644 src/testchar.c create mode 100644 src/testdict.c create mode 100644 src/testdso.c create mode 100644 src/testlimits.c create mode 100644 src/testrecurse.c create mode 100644 src/threads.c create mode 100644 src/timsort.h create mode 100644 src/tree.c create mode 100644 src/triodef.h create mode 100644 src/trionan.c create mode 100644 src/trionan.h create mode 100644 src/uri.c create mode 100644 src/valid.c create mode 100644 src/win32/Makefile.bcb create mode 100644 src/win32/Makefile.mingw create mode 100644 src/win32/Makefile.msvc create mode 100644 src/win32/Readme.txt create mode 100644 src/win32/VC10/README.vc10 create mode 100644 src/win32/VC10/RuleSet1.ruleset create mode 100644 src/win32/configure.js create mode 100644 src/win32/defgen.xsl create mode 100644 src/win32/libxml2.def.src create mode 100644 src/win32/libxml2.rc create mode 100644 src/xml2-config.1 create mode 100644 src/xml2Conf.sh.in create mode 100644 src/xmlIO.c create mode 100644 src/xmlmemory.c create mode 100644 src/xmlreader.c create mode 100644 src/xmlsave.c create mode 100644 src/xmlstring.c create mode 100644 src/xmlunicode.c create mode 100644 src/xmlwriter.c create mode 100644 src/xpath.c create mode 100644 src/xzlib.h create mode 100644 win32/config.h create mode 100644 win32/include/libxml/xmlversion.h diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 000000000000..5ade3efc432d --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,325 @@ +# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Define an "os_include" variable that points at the OS-specific generated +# headers. These were generated by running the configure script offline. +if (is_linux || is_chromeos || is_android || is_nacl || is_fuchsia) { + os_include = "linux" +} else if (is_apple) { + os_include = "mac" +} else if (is_win) { + os_include = "win32" +} + +import("//third_party/libxml/libxml_visibility.gni") + +config("libxml_config") { + # Define LIBXML_STATIC as nothing to match how libxml.h (an internal header) + # defines LIBXML_STATIC, otherwise we get the macro redefined warning from + # GCC. ("defines" does "-DFOO" which defines the macro FOO as 1.) + cflags = [ "-DLIBXML_STATIC=" ] + + include_dirs = [ + "src/include", + "$os_include/include", + ] +} + +config("libxml_warnings") { + if (is_win) { + cflags_c = [ + "/wd4018", # Signed/unsigned mismatch in comparison. + "/wd4267", # TODO(brucedawson): http://crbug.com/554200 fix C4267 + "/wd4311", # and C4311 warnings. + ] + } + if (is_clang) { + cflags = [ + # libxml passes `const unsigned char*` through `const char*`. + "-Wno-pointer-sign", + + # pattern.c and uri.c both have an intentional `for (...);` / + # `while(...);` loop. I submitted a patch to move the `'` to its own + # line, but until that's landed suppress the warning: + "-Wno-empty-body", + + # debugXML.c compares array 'arg' to NULL. + "-Wno-tautological-pointer-compare", + + # threads.c attempts to forward declare a pthread_equal which doesn't + # match the prototype in pthreads.h + "-Wno-ignored-attributes", + + # libxml casts from int to long to void*. + "-Wno-int-to-void-pointer-cast", + + # libxml passes a volatile LPCRITICAL_SECTION* to a function expecting + # a void* volatile*. + "-Wno-incompatible-pointer-types", + + # trio_is_special_quantity and trio_is_negative are only + # used with certain preprocessor defines set. + "-Wno-unused-function", + + # Comparison between xmlElementType and xmlXPathTypeVal. + # TODO(hans): See if we can fix upstream (http://crbug.com/763944). + "-Wno-enum-compare", + ] + } else if (is_linux || is_chromeos) { + cflags = [ + # gcc spits out a bunch of warnings about passing too many arguments to + # __xmlSimpleError. + "-Wno-format-extra-args", + ] + } +} + +static_library("xml_reader") { + # Do not expand this visibility list without first consulting with the + # Security Team. + visibility = [ + "//base/test:test_support", + "//components/policy/core/common:unit_tests", + "//services/data_decoder:*", + "//tools/traffic_annotation/auditor:auditor_sources", + ] + if (is_win) { + visibility += [ "//components/wifi" ] + } + sources = [ + "chromium/xml_reader.cc", + "chromium/xml_reader.h", + ] + deps = [ + ":libxml", + ":libxml_utils", + ] + configs += [ ":libxml_config" ] +} + +static_library("xml_writer") { + # The XmlWriter is considered safe to use from any target. + visibility = [ "*" ] + sources = [ + "chromium/xml_writer.cc", + "chromium/xml_writer.h", + ] + deps = [ + ":libxml", + ":libxml_utils", + ] + configs += [ ":libxml_config" ] +} + +static_library("libxml_utils") { + # Do not expand this visibility list without first consulting with the + # Security Team. + visibility = [ + ":xml_reader", + ":xml_writer", + "//base/test:test_support", + "//services/data_decoder:xml_parser_fuzzer", + ] + sources = [ + "chromium/libxml_utils.cc", + "chromium/libxml_utils.h", + ] + deps = [ ":libxml" ] + public_deps = [ "//third_party/icu:icuuc" ] + public_configs = [ ":libxml_config" ] +} + +static_library("libxml") { + # Do not expand this visibility list without first consulting with the + # Security Team. + visibility = [ + ":libxml_utils", + ":xml_reader", + ":xml_writer", + "//chromecast/internal", + "//testing/libfuzzer/*", + "//third_party/blink/renderer/*", + "//third_party/fontconfig", + "//third_party/libxslt", + "//third_party/maldoca/*", + ] + if (is_ios) { + foreach(tgt, ios_libxml_visibility_additions) { + visibility += [ "//ios_internal/$tgt" ] + } + } + + output_name = "libxml2" + + # Commented out sources are libxml2 files we do not want to include. They are + # here to make it easy to identify files which are new. + sources = [ + #"src/DOCBparser.c", + "src/HTMLparser.c", + "src/HTMLtree.c", + + #"src/SAX.c", + "src/SAX2.c", + "src/buf.c", + "src/buf.h", + + #"src/c14n.c", + #"src/catalog.c", + "src/chvalid.c", + + #"src/debugXML.c", + "src/dict.c", + "src/elfgcchack.h", + "src/enc.h", + "src/encoding.c", + "src/entities.c", + "src/error.c", + "src/globals.c", + "src/hash.c", + "src/include/libxml/DOCBparser.h", + "src/include/libxml/HTMLparser.h", + "src/include/libxml/HTMLtree.h", + "src/include/libxml/SAX.h", + "src/include/libxml/SAX2.h", + "src/include/libxml/c14n.h", + "src/include/libxml/catalog.h", + "src/include/libxml/chvalid.h", + "src/include/libxml/debugXML.h", + "src/include/libxml/dict.h", + "src/include/libxml/encoding.h", + "src/include/libxml/entities.h", + "src/include/libxml/globals.h", + "src/include/libxml/hash.h", + "src/include/libxml/list.h", + "src/include/libxml/nanoftp.h", + "src/include/libxml/nanohttp.h", + "src/include/libxml/parser.h", + "src/include/libxml/parserInternals.h", + "src/include/libxml/pattern.h", + "src/include/libxml/relaxng.h", + "src/include/libxml/schemasInternals.h", + "src/include/libxml/schematron.h", + "src/include/libxml/threads.h", + "src/include/libxml/tree.h", + "src/include/libxml/uri.h", + "src/include/libxml/valid.h", + "src/include/libxml/xinclude.h", + "src/include/libxml/xlink.h", + "src/include/libxml/xmlIO.h", + "src/include/libxml/xmlautomata.h", + "src/include/libxml/xmlerror.h", + "src/include/libxml/xmlexports.h", + "src/include/libxml/xmlmemory.h", + "src/include/libxml/xmlmodule.h", + "src/include/libxml/xmlreader.h", + "src/include/libxml/xmlregexp.h", + "src/include/libxml/xmlsave.h", + "src/include/libxml/xmlschemas.h", + "src/include/libxml/xmlschemastypes.h", + "src/include/libxml/xmlstring.h", + "src/include/libxml/xmlunicode.h", + "src/include/libxml/xmlwriter.h", + "src/include/libxml/xpath.h", + "src/include/libxml/xpathInternals.h", + "src/include/libxml/xpointer.h", + + #"src/legacy.c", + "src/libxml.h", + "src/list.c", + "src/parser.c", + "src/parserInternals.c", + "src/pattern.c", + + #"src/relaxng.c", + "src/save.h", + + #"src/schematron.c", + "src/threads.c", + "src/timsort.h", + "src/tree.c", + "src/triodef.h", + "src/trionan.h", + + #"src/trio.c", + #"src/trio.h", + #"src/triodef.h", + # Note: xpath.c #includes trionan.c + #"src/trionan.c", + #"src/triop.h", + #"src/triostr.c", + #"src/triostr.h", + "src/uri.c", + "src/valid.c", + + #"src/xinclude.c", + #"src/xlink.c", + "src/xmlIO.c", + "src/xmlmemory.c", + + #"src/xmlmodule.c", + "src/xmlreader.c", + + #"src/xmlregexp.c", + "src/xmlsave.c", + + #"src/xmlschemas.c", + #"src/xmlschemastypes.c", + "src/xmlstring.c", + "src/xmlunicode.c", + "src/xmlwriter.c", + "src/xpath.c", + + #"src/xpointer.c", + #"src/xzlib.c", + "src/xzlib.h", + ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + + # Must be after no_chromium_code for warning flags to be ordered correctly. + ":libxml_warnings", + ] + + if (is_linux || is_chromeos) { + sources += [ + "linux/config.h", + "linux/include/libxml/xmlversion.h", + ] + } + + if (is_mac) { + sources += [ + "mac/config.h", + "mac/include/libxml/xmlversion.h", + ] + } + + if (is_win) { + sources += [ + "src/include/win32config.h", + "src/include/wsockcompat.h", + "win32/config.h", + "win32/include/libxml/xmlversion.h", + ] + + # libxml2 already defines WIN32_LEAN_AND_MEAN. + configs -= [ "//build/config/win:lean_and_mean" ] + } + + public_configs = [ ":libxml_config" ] + public_deps = [ "//third_party/icu:icuuc" ] + deps = [ "//third_party/zlib" ] + + if (is_apple || is_android || is_fuchsia) { + # http://www.xmlsoft.org/threads.html says that this is required when using + # libxml from several threads, which can possibly happen in chrome. On + # linux, this is picked up by transitivity from pkg-config output from + # build/linux/system.gyp. + defines = [ "_REENTRANT" ] + } + + include_dirs = [ "$os_include" ] +} diff --git a/DEPS b/DEPS new file mode 100644 index 000000000000..6dcfa1577702 --- /dev/null +++ b/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+libxml', +] diff --git a/DIR_METADATA b/DIR_METADATA new file mode 100644 index 000000000000..a0e30b3eb068 --- /dev/null +++ b/DIR_METADATA @@ -0,0 +1,3 @@ +monorail: { + component: "Blink>XML" +} diff --git a/OWNERS b/OWNERS new file mode 100644 index 000000000000..536598c59280 --- /dev/null +++ b/OWNERS @@ -0,0 +1,5 @@ +# There's no real owners here. If you're familiar with the code please send +# a CL to add yourself here. +dcheng@chromium.org +schenney@chromium.org +jarhar@chromium.org diff --git a/README.chromium b/README.chromium new file mode 100644 index 000000000000..1d1d773b6dfd --- /dev/null +++ b/README.chromium @@ -0,0 +1,28 @@ +Name: libxml +URL: http://xmlsoft.org +Version: dea91c97debeac7c1aaf9c19f79029809e23a353 +CPEPrefix: cpe:/a:xmlsoft:libxml2:2.9.12 +License: MIT +License File: src/Copyright +Security Critical: yes + +Description: + +libxml2 from libxml.org. + +Modifications: + +- chromium-issue-599427.patch: workaround for VS 2015 Update 2 code-gen bug +- chromium-issue-628581.patch: See https://crbug.com/628581#c18 +- chromium-issue-894933.patch: Use ptrdiff_t instead of unsigned long for + pointer differences in parser.c +- libxml2-2.9.4-security-CVE-2017-7376-nanohttp-out-of-bounds-write.patch: + See https://crbug.com/708433 +- libxml2-2.9.4-security-xpath-nodetab-uaf.patch: See https://crbug.com/705445 +- chromium-issue-708434.patch: Guard against input counter overflow. +- chromium-issue-1138555.patch: Change TRUE to 1 for ICU68 which remove the + #define of TRUE. +- Add helper classes in the chromium/ subdirectory. +- Delete various unused files, see chromium/roll.py + +This import was generated by the chromium/roll.py script. diff --git a/chromium/chromium-issue-599427.patch b/chromium/chromium-issue-599427.patch new file mode 100644 index 000000000000..20e26c51942a --- /dev/null +++ b/chromium/chromium-issue-599427.patch @@ -0,0 +1,28 @@ +--- a/xmlstring.c 2016-05-13 17:24:58.870079372 +0900 ++++ b/xmlstring.c 2016-04-25 13:58:09.879238595 +0900 +@@ -835,16 +835,20 @@ + while ( len-- > 0) { + if ( !*ptr ) + break; +- if ( (ch = *ptr++) & 0x80) +- while ((ch<<=1) & 0x80 ) { +- if (*ptr == 0) break; ++ if ( (ch = *ptr++) & 0x80) { ++ // Workaround for an optimization bug in VS 2015 Update 2, remove ++ // once the fix is released. crbug.com/599427 ++ // https://connect.microsoft.com/VisualStudio/feedback/details/2582138 ++ xmlChar ch2 = ch; ++ while ((ch2<<=1) & 0x80 ) { + ptr++; +- } ++ if (*ptr == 0) break; ++ } ++ } + } + return (ptr - utf); + } + +- + /** + * xmlUTF8Strndup: + * @utf: the input UTF8 * diff --git a/chromium/chromium-issue-628581.patch b/chromium/chromium-issue-628581.patch new file mode 100644 index 000000000000..a4bb7141d39d --- /dev/null +++ b/chromium/chromium-issue-628581.patch @@ -0,0 +1,178 @@ +diff --git a/entities.c b/entities.c +index 43549bc5..e4a09d62 100644 +--- a/entities.c ++++ b/entities.c +@@ -164,6 +164,7 @@ xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type, + memset(ret, 0, sizeof(xmlEntity)); + ret->type = XML_ENTITY_DECL; + ret->checked = 0; ++ ret->guard = XML_ENTITY_NOT_BEING_CHECKED; + + /* + * fill the structure. +@@ -936,6 +937,7 @@ xmlCopyEntity(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) { + cur->orig = xmlStrdup(ent->orig); + if (ent->URI != NULL) + cur->URI = xmlStrdup(ent->URI); ++ cur->guard = 0; + return(cur); + } + +diff --git a/include/libxml/entities.h b/include/libxml/entities.h +index 47b4573e..012efab2 100644 +--- a/include/libxml/entities.h ++++ b/include/libxml/entities.h +@@ -35,8 +35,13 @@ typedef enum { + * and the linkind data needed for the linking in the hash table. + */ + ++typedef enum { ++ XML_ENTITY_NOT_BEING_CHECKED, ++ XML_ENTITY_BEING_CHECKED /* entity check is in progress */ ++} xmlEntityRecursionGuard; ++ + struct _xmlEntity { +- void *_private; /* application data */ ++ void *_private; /* application data */ + xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ + const xmlChar *name; /* Entity name */ + struct _xmlNode *children; /* First child link */ +@@ -56,10 +61,11 @@ struct _xmlEntity { + struct _xmlEntity *nexte; /* unused */ + const xmlChar *URI; /* the full URI as computed */ + int owner; /* does the entity own the childrens */ +- int checked; /* was the entity content checked */ +- /* this is also used to count entities +- * references done from that entity +- * and if it contains '<' */ ++ int checked; /* was the entity content checked and */ ++ /* l.o. bit: replacement contains '<' */ ++ /* remaining bits: one plus count of */ ++ /* entity references from this entity */ ++ xmlEntityRecursionGuard guard; + }; + + /* +diff --git a/parser.c b/parser.c +index ca9fde2c..4264445a 100644 +--- a/parser.c ++++ b/parser.c +@@ -143,18 +143,25 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, + * This may look absurd but is needed to detect + * entities problems + */ ++ if ((ent != NULL) && (ent->guard == XML_ENTITY_BEING_CHECKED)) { ++ xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); ++ return (1); ++ } ++ + if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && + (ent->content != NULL) && (ent->checked == 0) && + (ctxt->errNo != XML_ERR_ENTITY_LOOP)) { + unsigned long oldnbent = ctxt->nbentities, diff; + xmlChar *rep; + ++ ent->guard = XML_ENTITY_BEING_CHECKED; + ent->checked = 1; + + ++ctxt->depth; + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, 0, 0, 0); + --ctxt->depth; ++ ent->guard = XML_ENTITY_NOT_BEING_CHECKED; + if ((rep == NULL) || (ctxt->errNo == XML_ERR_ENTITY_LOOP)) { + ent->content[0] = 0; + } +@@ -7116,23 +7123,28 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { + * if its replacement text matches the production labeled + * content. + */ +- if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { +- ctxt->depth++; +- ret = xmlParseBalancedChunkMemoryInternal(ctxt, ent->content, +- user_data, &list); +- ctxt->depth--; +- +- } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) { +- ctxt->depth++; +- ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax, +- user_data, ctxt->depth, ent->URI, +- ent->ExternalID, &list); +- ctxt->depth--; +- } else { +- ret = XML_ERR_ENTITY_PE_INTERNAL; +- xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, +- "invalid entity type found\n", NULL); +- } ++ if (ent->guard == XML_ENTITY_BEING_CHECKED) { ++ ret = XML_ERR_ENTITY_LOOP; ++ } else { ++ ent->guard = XML_ENTITY_BEING_CHECKED; ++ if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { ++ ctxt->depth++; ++ ret = xmlParseBalancedChunkMemoryInternal(ctxt, ent->content, ++ user_data, &list); ++ ctxt->depth--; ++ } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) { ++ ctxt->depth++; ++ ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax, ++ user_data, ctxt->depth, ent->URI, ++ ent->ExternalID, &list); ++ ctxt->depth--; ++ } else { ++ ret = XML_ERR_ENTITY_PE_INTERNAL; ++ xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, ++ "invalid entity type found\n", NULL); ++ } ++ ent->guard = XML_ENTITY_NOT_BEING_CHECKED; ++ } + + /* + * Store the number of entities needing parsing for this entity +@@ -7239,23 +7251,29 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { + else + user_data = ctxt->userData; + +- if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { +- ctxt->depth++; +- ret = xmlParseBalancedChunkMemoryInternal(ctxt, +- ent->content, user_data, NULL); +- ctxt->depth--; +- } else if (ent->etype == +- XML_EXTERNAL_GENERAL_PARSED_ENTITY) { +- ctxt->depth++; +- ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, +- ctxt->sax, user_data, ctxt->depth, +- ent->URI, ent->ExternalID, NULL); +- ctxt->depth--; +- } else { +- ret = XML_ERR_ENTITY_PE_INTERNAL; +- xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, +- "invalid entity type found\n", NULL); +- } ++ if (ent->guard == XML_ENTITY_BEING_CHECKED) { ++ ret = XML_ERR_ENTITY_LOOP; ++ } else { ++ ent->guard = XML_ENTITY_BEING_CHECKED; ++ if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { ++ ctxt->depth++; ++ ret = xmlParseBalancedChunkMemoryInternal(ctxt, ++ ent->content, user_data, NULL); ++ ctxt->depth--; ++ } else if (ent->etype == ++ XML_EXTERNAL_GENERAL_PARSED_ENTITY) { ++ ctxt->depth++; ++ ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ++ ctxt->sax, user_data, ctxt->depth, ++ ent->URI, ent->ExternalID, NULL); ++ ctxt->depth--; ++ } else { ++ ret = XML_ERR_ENTITY_PE_INTERNAL; ++ xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, ++ "invalid entity type found\n", NULL); ++ } ++ ent->guard = XML_ENTITY_NOT_BEING_CHECKED; ++ } + if (ret == XML_ERR_ENTITY_LOOP) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return; diff --git a/chromium/chromium-issue-708434.patch b/chromium/chromium-issue-708434.patch new file mode 100644 index 000000000000..bd8e1a6ac994 --- /dev/null +++ b/chromium/chromium-issue-708434.patch @@ -0,0 +1,19 @@ +diff --git a/third_party/libxml/src/parserInternals.c b/third_party/libxml/src/parserInternals.c +index bfc778ac1f77..286fdcea9760 100644 +--- src/parserInternals.c ++++ src/parserInternals.c +@@ -1369,8 +1369,13 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) { + * should not happen while parsing which is the situation where + * the id is actually needed. + */ +- if (ctxt != NULL) ++ if (ctxt != NULL) { ++ if (ctxt->input_id >= INT_MAX) { ++ xmlErrMemory(ctxt, "Input ID overflow\n"); ++ return(NULL); ++ } + input->id = ctxt->input_id++; ++ } + + return(input); + } diff --git a/chromium/chromium-issue-894933.patch b/chromium/chromium-issue-894933.patch new file mode 100644 index 000000000000..418fed541144 --- /dev/null +++ b/chromium/chromium-issue-894933.patch @@ -0,0 +1,113 @@ +diff --git a/third_party/libxml/src/parser.c b/third_party/libxml/src/parser.c +index 3a8a0d79e966..4e767091683d 100644 +--- a/third_party/libxml/src/parser.c ++++ b/third_party/libxml/src/parser.c +@@ -2081,8 +2081,8 @@ static void xmlSHRINK (xmlParserCtxtPtr ctxt) { + xmlGROW (ctxt); + + static void xmlGROW (xmlParserCtxtPtr ctxt) { +- unsigned long curEnd = ctxt->input->end - ctxt->input->cur; +- unsigned long curBase = ctxt->input->cur - ctxt->input->base; ++ ptrdiff_t curEnd = ctxt->input->end - ctxt->input->cur; ++ ptrdiff_t curBase = ctxt->input->cur - ctxt->input->base; + + if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) || + (curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) && +@@ -8857,6 +8857,18 @@ xmlParseQNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *name, + * caller if it was copied, this can be detected by val[*len] == 0. + */ + ++#define GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end) \ ++ const xmlChar *oldbase = ctxt->input->base;\ ++ GROW;\ ++ if (ctxt->instate == XML_PARSER_EOF)\ ++ return(NULL);\ ++ if (oldbase != ctxt->input->base) {\ ++ ptrdiff_t delta = ctxt->input->base - oldbase;\ ++ start = start + delta;\ ++ in = in + delta;\ ++ }\ ++ end = ctxt->input->end; ++ + static xmlChar * + xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + int normalize) +@@ -8886,14 +8898,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + end = ctxt->input->end; + start = in; + if (in >= end) { +- const xmlChar *oldbase = ctxt->input->base; +- GROW; +- if (oldbase != ctxt->input->base) { +- long delta = ctxt->input->base - oldbase; +- start = start + delta; +- in = in + delta; +- } +- end = ctxt->input->end; ++ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end) + } + if (normalize) { + /* +@@ -8910,16 +8915,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + in++; + start = in; + if (in >= end) { +- const xmlChar *oldbase = ctxt->input->base; +- GROW; +- if (ctxt->instate == XML_PARSER_EOF) +- return(NULL); +- if (oldbase != ctxt->input->base) { +- long delta = ctxt->input->base - oldbase; +- start = start + delta; +- in = in + delta; +- } +- end = ctxt->input->end; ++ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end) + if (((in - start) > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, +@@ -8933,16 +8929,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + col++; + if ((*in++ == 0x20) && (*in == 0x20)) break; + if (in >= end) { +- const xmlChar *oldbase = ctxt->input->base; +- GROW; +- if (ctxt->instate == XML_PARSER_EOF) +- return(NULL); +- if (oldbase != ctxt->input->base) { +- long delta = ctxt->input->base - oldbase; +- start = start + delta; +- in = in + delta; +- } +- end = ctxt->input->end; ++ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end) + if (((in - start) > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, +@@ -8971,7 +8958,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + if (oldbase != ctxt->input->base) { +- long delta = ctxt->input->base - oldbase; ++ ptrdiff_t delta = ctxt->input->base - oldbase; + start = start + delta; + in = in + delta; + last = last + delta; +@@ -8998,16 +8985,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + in++; + col++; + if (in >= end) { +- const xmlChar *oldbase = ctxt->input->base; +- GROW; +- if (ctxt->instate == XML_PARSER_EOF) +- return(NULL); +- if (oldbase != ctxt->input->base) { +- long delta = ctxt->input->base - oldbase; +- start = start + delta; +- in = in + delta; +- } +- end = ctxt->input->end; ++ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end) + if (((in - start) > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, diff --git a/chromium/libxml2-2.9.4-security-xpath-nodetab-uaf.patch b/chromium/libxml2-2.9.4-security-xpath-nodetab-uaf.patch new file mode 100644 index 000000000000..ecf93074a680 --- /dev/null +++ b/chromium/libxml2-2.9.4-security-xpath-nodetab-uaf.patch @@ -0,0 +1,15 @@ +not upstream yet, fix from nmehta@ +see https://docs.google.com/document/d/1-Cd_Yq8MZ7am2ZhKhbDhqZ_L0aLJPBg0w1QLXGVoNmY/edit +and https://bugs.chromium.org/p/chromium/issues/detail?id=705445 + +--- src/xpath.c 2016-12-25 17:26:52.000000000 -0800 ++++ src/xpath.c 2017-03-30 11:15:41.000000000 -0700 +@@ -4368,7 +4368,7 @@ + } + memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); + ret->type = XPATH_XSLT_TREE; +- ret->boolval = 1; ++ ret->boolval = 0; + ret->user = (void *) val; + ret->nodesetval = xmlXPathNodeSetCreate(val); + #ifdef XP_DEBUG_OBJ_USAGE diff --git a/chromium/libxml_utils.cc b/chromium/libxml_utils.cc new file mode 100644 index 000000000000..917564c3e79a --- /dev/null +++ b/chromium/libxml_utils.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/libxml/chromium/libxml_utils.h" + +namespace internal { + +std::string XmlStringToStdString(const xmlChar* xmlstring) { + if (!xmlstring) + return std::string(); + + // xmlChar*s are UTF-8, so this cast is safe. + return std::string(reinterpret_cast(xmlstring)); +} + +} // namespace internal diff --git a/chromium/libxml_utils.h b/chromium/libxml_utils.h new file mode 100644 index 000000000000..8b2383f9c8bd --- /dev/null +++ b/chromium/libxml_utils.h @@ -0,0 +1,39 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_LIBXML_CHROMIUM_LIBXML_UTILS_H_ +#define THIRD_PARTY_LIBXML_CHROMIUM_LIBXML_UTILS_H_ + +#include + +#include + +// libxml uses a global error function pointer for reporting errors. +// A ScopedXmlErrorFunc object lets you change the global error pointer +// for the duration of the object's lifetime. +class ScopedXmlErrorFunc { + public: + ScopedXmlErrorFunc(void* context, xmlGenericErrorFunc func) { + old_error_func_ = xmlGenericError; + old_error_context_ = xmlGenericErrorContext; + xmlSetGenericErrorFunc(context, func); + } + ~ScopedXmlErrorFunc() { + xmlSetGenericErrorFunc(old_error_context_, old_error_func_); + } + + private: + xmlGenericErrorFunc old_error_func_; + void* old_error_context_; +}; + +namespace internal { + +// Converts a libxml xmlChar* into a UTF-8 std::string. +// Null inputs produce an empty string. +std::string XmlStringToStdString(const xmlChar* xmlstring); + +} // namespace internal + +#endif // THIRD_PARTY_LIBXML_CHROMIUM_INCLUDE_LIBXML_LIBXML_UTILS_H_ diff --git a/chromium/roll.py b/chromium/roll.py new file mode 100755 index 000000000000..ef23d4c3a7b4 --- /dev/null +++ b/chromium/roll.py @@ -0,0 +1,481 @@ +#!/usr/bin/env python + +# Copyright 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import argparse +import os +import os.path +import shutil +import subprocess +import sys +import stat +import tempfile + +# How to patch libxml2 in Chromium: +# +# 1. Write a .patch file and add it to third_party/libxml/chromium. +# 2. Apply the patch in src: patch -p1 <../chromium/foo.patch +# 3. Add the patch to the list of patches in this file. +# 4. Update README.chromium with the provenance of the patch. +# 5. Upload a change with the modified documentation, roll script, +# patch, applied patch and any other relevant changes like +# regression tests. Go through the usual review and commit process. +# +# How to roll libxml2 in Chromium: +# +# Prerequisites: +# +# 1. Check out Chromium somewhere on Linux, Mac and Windows. +# 2. On Linux: +# a. sudo apt-get install libicu-dev +# b. git clone https://github.com/GNOME/libxml2.git somewhere +# 3. On Mac, install these packages with brew: +# autoconf automake libtool pkgconfig icu4c +# +# Procedure: +# +# Warning: This process is destructive. Run it on a clean branch. +# +# 1. On Linux, in the libxml2 repo directory: +# a. git remote update origin +# b. git checkout origin/master +# +# This will be the upstream version of libxml you are rolling to. +# +# 2. On Linux, in the Chromium src director: +# a. third_party/libxml/chromium/roll.py --linux /path/to/libxml2 +# +# If this fails, it may be a patch no longer applies. Reset to +# head; modify the patch files, this script, and +# README.chromium; then commit the result and run it again. +# +# b. Upload a CL, but do not Start Review. +# +# 2. On Windows, in the Chromium src directory: +# a. git cl patch +# b. third_party\libxml\chromium\roll.py --win32 +# c. git cl upload +# +# 3. On Mac, in the Chromium src directory: +# a. git cl patch +# b. third_party/libxml/chromium/roll.py --mac --icu4c_path=~/homebrew/opt/icu4c +# c. Make and commit any final changes to README.chromium, BUILD.gn, etc. +# d. git cl upload +# e. Complete the review as usual + +PATCHES = [ + 'chromium-issue-599427.patch', + 'chromium-issue-628581.patch', + 'libxml2-2.9.4-security-xpath-nodetab-uaf.patch', + 'chromium-issue-708434.patch', +] + + +# See libxml2 configure.ac and win32/configure.js to learn what +# options are available. We include every option here to more easily track +# changes from one version to the next, and to be sure we only include what +# we need. +# These two sets of options should be in sync. You can check the +# generated #defines in (win32|mac|linux)/include/libxml/xmlversion.h to confirm +# this. +# We would like to disable python but it introduces a host of build errors +SHARED_XML_CONFIGURE_OPTIONS = [ + # These options are turned ON + ('--with-html', 'html=yes'), + ('--with-icu', 'icu=yes'), + ('--with-output', 'output=yes'), + ('--with-push', 'push=yes'), + ('--with-python', 'python=yes'), + ('--with-reader', 'reader=yes'), + ('--with-sax1', 'sax1=yes'), + ('--with-tree', 'tree=yes'), + ('--with-writer', 'writer=yes'), + ('--with-xpath', 'xpath=yes'), + # These options are turned OFF + ('--without-c14n', 'c14n=no'), + ('--without-catalog', 'catalog=no'), + ('--without-debug', 'xml_debug=no'), + ('--without-docbook', 'docb=no'), + ('--without-ftp', 'ftp=no'), + ('--without-http', 'http=no'), + ('--without-iconv', 'iconv=no'), + ('--without-iso8859x', 'iso8859x=no'), + ('--without-legacy', 'legacy=no'), + ('--without-lzma', 'lzma=no'), + ('--without-mem-debug', 'mem_debug=no'), + ('--without-modules', 'modules=no'), + ('--without-pattern', 'pattern=no'), + ('--without-regexps', 'regexps=no'), + ('--without-run-debug', 'run_debug=no'), + ('--without-schemas', 'schemas=no'), + ('--without-schematron', 'schematron=no'), + ('--without-threads', 'threads=no'), + ('--without-valid', 'valid=no'), + ('--without-xinclude', 'xinclude=no'), + ('--without-xptr', 'xptr=no'), + ('--without-zlib', 'zlib=no'), +] + + +# These options are only available in configure.ac for Linux and Mac. +EXTRA_NIX_XML_CONFIGURE_OPTIONS = [ + '--without-fexceptions', + '--without-minimum', + '--without-readline', + '--without-history', +] + + +# These options are only available in win32/configure.js for Windows. +EXTRA_WIN32_XML_CONFIGURE_OPTIONS = [ + 'trio=no', + 'walker=no', +] + + +XML_CONFIGURE_OPTIONS = ( + [option[0] for option in SHARED_XML_CONFIGURE_OPTIONS] + + EXTRA_NIX_XML_CONFIGURE_OPTIONS) + + +XML_WIN32_CONFIGURE_OPTIONS = ( + [option[1] for option in SHARED_XML_CONFIGURE_OPTIONS] + + EXTRA_WIN32_XML_CONFIGURE_OPTIONS) + + +FILES_TO_REMOVE = [ + 'src/DOCBparser.c', + 'src/HACKING', + 'src/INSTALL', + 'src/INSTALL.libxml2', + 'src/MAINTAINERS', + 'src/Makefile.in', + 'src/Makefile.win', + 'src/README.cvs-commits', + # This is unneeded "legacy" SAX API, even though we enable SAX1. + 'src/SAX.c', + 'src/VxWorks', + 'src/autogen.sh', + 'src/autom4te.cache', + 'src/bakefile', + 'src/build_glob.py', + 'src/c14n.c', + 'src/catalog.c', + 'src/compile', + 'src/config.guess', + 'src/config.sub', + 'src/configure', + 'src/chvalid.def', + 'src/debugXML.c', + 'src/depcomp', + 'src/doc', + 'src/example', + 'src/genChRanges.py', + 'src/global.data', + 'src/include/libxml/Makefile.in', + 'src/include/libxml/xmlversion.h', + 'src/include/libxml/xmlwin32version.h', + 'src/include/libxml/xmlwin32version.h.in', + 'src/include/Makefile.in', + 'src/install-sh', + 'src/legacy.c', + 'src/libxml2.doap', + 'src/ltmain.sh', + 'src/m4', + 'src/macos/libxml2.mcp.xml.sit.hqx', + 'src/missing', + 'src/optim', + 'src/os400', + 'src/python', + 'src/relaxng.c', + 'src/result', + 'src/rngparser.c', + 'src/schematron.c', + 'src/test', + 'src/testOOM.c', + 'src/testOOMlib.c', + 'src/testOOMlib.h', + 'src/trio.c', + 'src/trio.h', + 'src/triop.h', + 'src/triostr.c', + 'src/triostr.h', + 'src/vms', + 'src/win32/VC10/config.h', + 'src/win32/wince', + 'src/xinclude.c', + 'src/xlink.c', + 'src/xml2-config.in', + 'src/xmlcatalog.c', + 'src/xmllint.c', + 'src/xmlmodule.c', + 'src/xmlregexp.c', + 'src/xmlschemas.c', + 'src/xmlschemastypes.c', + 'src/xpointer.c', + 'src/xstc', + 'src/xzlib.c', +] + + +THIRD_PARTY_LIBXML_SRC = 'third_party/libxml/src' + + +class WorkingDir(object): + """"Changes the working directory and resets it on exit.""" + def __init__(self, path): + self.prev_path = os.getcwd() + self.path = path + + def __enter__(self): + os.chdir(self.path) + + def __exit__(self, exc_type, exc_value, traceback): + if exc_value: + print('was in %s; %s before that' % (self.path, self.prev_path)) + os.chdir(self.prev_path) + + +def git(*args): + """Runs a git subcommand. + + On Windows this uses the shell because there's a git wrapper + batch file in depot_tools. + + Arguments: + args: The arguments to pass to git. + """ + command = ['git'] + list(args) + subprocess.check_call(command, shell=(os.name == 'nt')) + + +def remove_tracked_and_local_dir(path): + """Removes the contents of a directory from git, and the filesystem. + + Arguments: + path: The path to remove. + """ + remove_tracked_files([path]) + shutil.rmtree(path, ignore_errors=True) + os.mkdir(path) + + +def remove_tracked_files(files_to_remove): + """Removes tracked files from git. + + Arguments: + files_to_remove: The files to remove. + """ + files_to_remove = [f for f in files_to_remove if os.path.exists(f)] + if files_to_remove: + git('rm', '-rf', *files_to_remove) + + +def sed_in_place(input_filename, program): + """Replaces text in a file. + + Arguments: + input_filename: The file to edit. + program: The sed program to perform edits on the file. + """ + # OS X's sed requires -e + subprocess.check_call(['sed', '-i', '-e', program, input_filename]) + + +def check_copying(full_path_to_third_party_libxml_src): + path = os.path.join(full_path_to_third_party_libxml_src, 'COPYING') + if not os.path.exists(path): + return + with open(path) as f: + s = f.read() + if 'GNU' in s: + raise Exception('check COPYING') + + +def prepare_libxml_distribution(src_path, libxml2_repo_path, temp_dir): + """Makes a libxml2 distribution. + + Args: + src_path: The path to the Chromium checkout. + libxml2_repo_path: The path to the local clone of the libxml2 repo. + temp_dir: A temporary directory to stage the distribution to. + + Returns: A tuple of commit hash and full path to the archive. + """ + # If it was necessary to push from a distribution prepared upstream, + # this is the point to inject it: Return the version string and the + # distribution tar file. + + # The libxml2 repo we're pulling changes from should not have + # local changes. This *should* be a commit that's publicly visible + # in the upstream repo; reviewers should check this. + check_clean(libxml2_repo_path) + + temp_config_path = os.path.join(temp_dir, 'config') + os.mkdir(temp_config_path) + temp_src_path = os.path.join(temp_dir, 'src') + os.mkdir(temp_src_path) + + with WorkingDir(libxml2_repo_path): + commit = subprocess.check_output( + ['git', 'log', '-n', '1', '--pretty=format:%H', 'HEAD']) + subprocess.check_call( + 'git archive HEAD | tar -x -C "%s"' % temp_src_path, + shell=True) + with WorkingDir(temp_src_path): + os.remove('.gitignore') + for patch in PATCHES: + print('applying %s' % patch) + subprocess.check_call( + 'patch -p1 --fuzz=0 < %s' % os.path.join( + src_path, THIRD_PARTY_LIBXML_SRC, '..', 'chromium', patch), + shell=True) + + with WorkingDir(temp_config_path): + print('../src/autogen.sh %s' % XML_CONFIGURE_OPTIONS) + subprocess.check_call(['../src/autogen.sh'] + XML_CONFIGURE_OPTIONS) + subprocess.check_call(['make', 'dist-all']) + + # Work out what it is called + tar_file = subprocess.check_output( + '''awk '/PACKAGE =/ {p=$3} /VERSION =/ {v=$3} ''' + '''END {printf("%s-%s.tar.gz", p, v)}' Makefile''', + shell=True) + return commit, os.path.abspath(tar_file) + + +def roll_libxml_linux(src_path, libxml2_repo_path): + with WorkingDir(src_path): + # Export the upstream git repo. + try: + temp_dir = tempfile.mkdtemp() + print('temporary directory: %s' % temp_dir) + + commit, tar_file = prepare_libxml_distribution( + src_path, libxml2_repo_path, temp_dir) + + # Remove all of the old libxml to ensure only desired cruft + # accumulates + remove_tracked_and_local_dir(THIRD_PARTY_LIBXML_SRC) + + # Update the libxml repo and export it to the Chromium tree + with WorkingDir(THIRD_PARTY_LIBXML_SRC): + subprocess.check_call( + 'tar xzf %s --strip-components=1' % tar_file, + shell=True) + finally: + shutil.rmtree(temp_dir) + + with WorkingDir(THIRD_PARTY_LIBXML_SRC): + # Put the version number is the README file + sed_in_place('../README.chromium', + 's/Version: .*$/Version: %s/' % commit) + + with WorkingDir('../linux'): + subprocess.check_call( + ['../src/autogen.sh'] + XML_CONFIGURE_OPTIONS) + check_copying(os.getcwd()) + sed_in_place('config.h', 's/#define HAVE_RAND_R 1//') + + # Add *everything* + with WorkingDir('../src'): + git('add', '*') + git('commit', '-am', '%s libxml, linux' % commit) + print('Now push to Windows and run steps there.') + + +def roll_libxml_win32(src_path): + with WorkingDir(src_path): + # Run the configure script. + with WorkingDir(os.path.join(THIRD_PARTY_LIBXML_SRC, 'win32')): + subprocess.check_call( + ['cscript', '//E:jscript', 'configure.js', 'compiler=msvc'] + + XML_WIN32_CONFIGURE_OPTIONS) + + # Add and commit the result. + shutil.move('../config.h', '../../win32/config.h') + git('add', '../../win32/config.h') + shutil.move('../include/libxml/xmlversion.h', + '../../win32/include/libxml/xmlversion.h') + git('add', '../../win32/include/libxml/xmlversion.h') + git('commit', '--allow-empty', '-m', 'Windows') + git('clean', '-f') + print('Now push to Mac and run steps there.') + + +def roll_libxml_mac(src_path, icu4c_path): + icu4c_path = os.path.abspath(os.path.expanduser(icu4c_path)) + os.environ["LDFLAGS"] = "-L" + os.path.join(icu4c_path, 'lib') + os.environ["CPPFLAGS"] = "-I" + os.path.join(icu4c_path, 'include') + os.environ["PKG_CONFIG_PATH"] = os.path.join(icu4c_path, 'lib/pkgconfig') + + full_path_to_third_party_libxml = os.path.join( + src_path, THIRD_PARTY_LIBXML_SRC, '..') + + with WorkingDir(os.path.join(full_path_to_third_party_libxml, 'mac')): + subprocess.check_call(['autoreconf', '-i', '../src']) + os.chmod('../src/configure', + os.stat('../src/configure').st_mode | stat.S_IXUSR) + subprocess.check_call(['../src/configure'] + XML_CONFIGURE_OPTIONS) + sed_in_place('config.h', 's/#define HAVE_RAND_R 1//') + + with WorkingDir(full_path_to_third_party_libxml): + commit = subprocess.check_output(['awk', '/Version:/ {print $2}', + 'README.chromium']) + remove_tracked_files(FILES_TO_REMOVE) + commit_message = 'Roll libxml to %s' % commit + git('commit', '-am', commit_message) + print('Now upload for review, etc.') + + +def check_clean(path): + with WorkingDir(path): + status = subprocess.check_output(['git', 'status', '-s']) + if len(status) > 0: + raise Exception('repository at %s is not clean' % path) + + +def main(): + src_dir = os.getcwd() + if not os.path.exists(os.path.join(src_dir, 'third_party')): + print('error: run this script from the Chromium src directory') + sys.exit(1) + + parser = argparse.ArgumentParser( + description='Roll the libxml2 dependency in Chromium') + platform = parser.add_mutually_exclusive_group(required=True) + platform.add_argument('--linux', action='store_true') + platform.add_argument('--win32', action='store_true') + platform.add_argument('--mac', action='store_true') + parser.add_argument( + 'libxml2_repo_path', + type=str, + nargs='?', + help='The path to the local clone of the libxml2 git repo.') + parser.add_argument( + '--icu4c_path', + help='The path to the homebrew installation of icu4c.') + args = parser.parse_args() + + if args.linux: + libxml2_repo_path = args.libxml2_repo_path + if not libxml2_repo_path: + print('Specify the path to the local libxml2 repo clone.') + sys.exit(1) + libxml2_repo_path = os.path.abspath(libxml2_repo_path) + roll_libxml_linux(src_dir, libxml2_repo_path) + elif args.win32: + roll_libxml_win32(src_dir) + elif args.mac: + icu4c_path = args.icu4c_path + if not icu4c_path: + print('Specify the path to the homebrew installation of icu4c with --icu4c_path.') + print(' ex: roll.py --mac --icu4c_path=~/homebrew/opt/icu4c') + sys.exit(1) + roll_libxml_mac(src_dir, icu4c_path) + + +if __name__ == '__main__': + main() diff --git a/chromium/xml_reader.cc b/chromium/xml_reader.cc new file mode 100644 index 000000000000..899ccefb7c8e --- /dev/null +++ b/chromium/xml_reader.cc @@ -0,0 +1,228 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/libxml/chromium/xml_reader.h" + +#include + +#include + +#include "third_party/libxml/chromium/libxml_utils.h" + +using internal::XmlStringToStdString; + +namespace { + +// Same as XmlStringToStdString but also frees |xmlstring|. +std::string XmlStringToStdStringWithDelete(xmlChar* xmlstring) { + std::string result = XmlStringToStdString(xmlstring); + xmlFree(xmlstring); + return result; +} + +enum GetAttributesQueryType { ATTRIBUTES, NAMESPACES_PREFIXES }; + +// Populates |names| with the names of the attributes or prefix of namespaces +// (depending on |query_type|) for the current node in |reader|. +// Returns true if attribute names/namespace prefixes were retrieved, false +// otherwise. +// Note the strings in |names| are valid as long as |reader| is valid and should +// not be deleted. +bool GetNodeAttributeNames(xmlTextReaderPtr reader, + GetAttributesQueryType query_type, + std::vector* names) { + if (xmlTextReaderHasAttributes(reader) <= 0) + return false; + + if (!xmlTextReaderMoveToFirstAttribute(reader)) + return false; + + do { + bool is_namespace = xmlTextReaderIsNamespaceDecl(reader) == 1; + if (query_type == NAMESPACES_PREFIXES && is_namespace) { + // Use the local name for namespaces so we don't include 'xmlns:". + names->push_back(xmlTextReaderConstLocalName(reader)); + } else if (query_type == ATTRIBUTES && !is_namespace) { + // Use the fully qualified name for attributes. + names->push_back(xmlTextReaderConstName(reader)); + } + } while (xmlTextReaderMoveToNextAttribute(reader) > 0); + + // Move the reader from the attributes back to the containing element. + if (!xmlTextReaderMoveToElement(reader)) + return false; + + return true; +} + +} // namespace + +XmlReader::XmlReader() : reader_(nullptr) {} + +XmlReader::~XmlReader() { + if (reader_) + xmlFreeTextReader(reader_); +} + +bool XmlReader::Load(const std::string& input) { + const int kParseOptions = XML_PARSE_NONET; // forbid network access + // TODO(evanm): Verify it's OK to pass nullptr for the URL and encoding. + // The libxml code allows for these, but it's unclear what effect is has. + reader_ = xmlReaderForMemory(input.data(), static_cast(input.size()), + nullptr, nullptr, kParseOptions); + return reader_ != nullptr; +} + +bool XmlReader::LoadFile(const std::string& file_path) { + const int kParseOptions = XML_PARSE_NONET; // forbid network access + reader_ = xmlReaderForFile(file_path.c_str(), nullptr, kParseOptions); + return reader_ != nullptr; +} + +bool XmlReader::Read() { + return xmlTextReaderRead(reader_) == 1; +} + +// Next(), when pointing at an opening tag, advances to the node after +// the matching closing tag. Returns false on EOF or error. +bool XmlReader::Next() { + return xmlTextReaderNext(reader_) == 1; +} + +// Return the depth in the tree of the current node. +int XmlReader::Depth() { + return xmlTextReaderDepth(reader_); +} + +std::string XmlReader::NodeName() { + return XmlStringToStdString(xmlTextReaderConstLocalName(reader_)); +} + +std::string XmlReader::NodeFullName() { + return XmlStringToStdString(xmlTextReaderConstName(reader_)); +} + +bool XmlReader::NodeAttribute(const char* name, std::string* out) { + xmlChar* value = xmlTextReaderGetAttribute(reader_, BAD_CAST name); + if (!value) + return false; + *out = XmlStringToStdStringWithDelete(value); + return true; +} + +bool XmlReader::GetAllNodeAttributes( + std::map* attributes) { + std::vector attribute_names; + if (!GetNodeAttributeNames(reader_, ATTRIBUTES, &attribute_names)) + return false; + + // Retrieve the attribute values. + for (const auto* name : attribute_names) { + (*attributes)[XmlStringToStdString(name)] = XmlStringToStdStringWithDelete( + xmlTextReaderGetAttribute(reader_, name)); + } + return true; +} + +bool XmlReader::GetAllDeclaredNamespaces( + std::map* namespaces) { + std::vector prefixes; + if (!GetNodeAttributeNames(reader_, NAMESPACES_PREFIXES, &prefixes)) + return false; + + // Retrieve the namespace URIs. + for (const auto* prefix : prefixes) { + bool default_namespace = xmlStrcmp(prefix, BAD_CAST "xmlns") == 0; + + std::string value = XmlStringToStdStringWithDelete( + xmlTextReaderLookupNamespace(reader_, prefix)); + if (value.empty() && default_namespace) { + // Default namespace is treated as an attribute for some reason. + value = XmlStringToStdStringWithDelete( + xmlTextReaderGetAttribute(reader_, prefix)); + } + (*namespaces)[default_namespace ? "" : XmlStringToStdString(prefix)] = + value; + } + return true; +} + +bool XmlReader::GetTextIfTextElement(std::string* content) { + if (NodeType() != XML_READER_TYPE_TEXT) + return false; + + *content = XmlStringToStdString(xmlTextReaderConstValue(reader_)); + return true; +} + +bool XmlReader::GetTextIfCDataElement(std::string* content) { + if (NodeType() != XML_READER_TYPE_CDATA) + return false; + + *content = XmlStringToStdString(xmlTextReaderConstValue(reader_)); + return true; +} + +bool XmlReader::IsElement() { + return NodeType() == XML_READER_TYPE_ELEMENT; +} + +bool XmlReader::IsClosingElement() { + return NodeType() == XML_READER_TYPE_END_ELEMENT; +} + +bool XmlReader::IsEmptyElement() { + return xmlTextReaderIsEmptyElement(reader_); +} + +bool XmlReader::ReadElementContent(std::string* content) { + const int start_depth = Depth(); + + if (xmlTextReaderIsEmptyElement(reader_)) { + // Empty tag. We succesfully read the content, but it's + // empty. + *content = ""; + // Advance past this empty tag. + if (!Read()) + return false; + return true; + } + + // Advance past opening element tag. + if (!Read()) + return false; + + // Read the content. We read up until we hit a closing tag at the + // same level as our starting point. + while (NodeType() != XML_READER_TYPE_END_ELEMENT || Depth() != start_depth) { + *content += XmlStringToStdString(xmlTextReaderConstValue(reader_)); + if (!Read()) + return false; + } + + // Advance past ending element tag. + if (!Read()) + return false; + + return true; +} + +bool XmlReader::SkipToElement() { + do { + switch (NodeType()) { + case XML_READER_TYPE_ELEMENT: + return true; + case XML_READER_TYPE_END_ELEMENT: + return false; + default: + // Skip all other node types. + continue; + } + } while (Read()); + return false; +} + +int XmlReader::NodeType() { + return xmlTextReaderNodeType(reader_); +} diff --git a/chromium/xml_reader.h b/chromium/xml_reader.h new file mode 100644 index 000000000000..eb1ae63807f6 --- /dev/null +++ b/chromium/xml_reader.h @@ -0,0 +1,108 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_LIBXML_CHROMIUM_XML_READER_H_ +#define THIRD_PARTY_LIBXML_CHROMIUM_XML_READER_H_ + +#include +#include + +extern "C" { +struct _xmlTextReader; +} + +// XmlReader is a wrapper class around libxml's xmlReader, +// providing a simplified C++ API. +class XmlReader { + public: + XmlReader(); + ~XmlReader(); + + // Load a document into the reader from memory. |input| must be UTF-8 and + // exist for the lifetime of this object. Returns false on error. + // TODO(evanm): handle encodings other than UTF-8? + bool Load(const std::string& input); + + // Load a document into the reader from a file. Returns false on error. + bool LoadFile(const std::string& file_path); + + // Wrappers around libxml functions ----------------------------------------- + + // Read() advances to the next node. Returns false on EOF or error. + bool Read(); + + // Next(), when pointing at an opening tag, advances to the node after + // the matching closing tag. Returns false on EOF or error. + bool Next(); + + // Return the depth in the tree of the current node. + int Depth(); + + // Returns the "local" name of the current node. + // For a tag like , this is the string "bar". + std::string NodeName(); + + // Returns the name of the current node. + // For a tag like , this is the string "foo:bar". + std::string NodeFullName(); + + // When pointing at a tag, retrieves the value of an attribute. + // Returns false on failure. + // E.g. for , NodeAttribute("bar:baz", &value) + // returns true and |value| is set to "a". + bool NodeAttribute(const char* name, std::string* value); + + // Populates |attributes| with all the attributes of the current tag and + // returns true. Note that namespace declarations are not reported. + // Returns false if there are no attributes in the current tag. + bool GetAllNodeAttributes(std::map* attributes); + + // Populates |namespaces| with all the namespaces (prefix/URI pairs) declared + // in the current tag and returns true. Note that the default namespace, if + // declared in the tag, is populated with an empty prefix. + // Returns false if there are no namespaces declared in the current tag. + bool GetAllDeclaredNamespaces(std::map* namespaces); + + // Sets |content| to the content of the current node if it is a #text/#cdata + // node. + // Returns true if the current node is a #text/#cdata node, false otherwise. + bool GetTextIfTextElement(std::string* content); + bool GetTextIfCDataElement(std::string* content); + + // Returns true if the node is an element (e.g. ). Note this returns + // false for self-closing elements (e.g. ). Use IsEmptyElement() to + // check for those. + bool IsElement(); + + // Returns true if the node is a closing element (e.g. ). + bool IsClosingElement(); + + // Returns true if the current node is an empty (self-closing) element (e.g. + // ). + bool IsEmptyElement(); + + // Helper functions not provided by libxml ---------------------------------- + + // Return the string content within an element. + // "bar" is a sequence of three nodes: + // (1) open tag, (2) text, (3) close tag. + // With the reader currently at (1), this returns the text of (2), + // and advances past (3). + // Returns false on error. + bool ReadElementContent(std::string* content); + + // Skip to the next opening tag, returning false if we reach a closing + // tag or EOF first. + // If currently on an opening tag, doesn't advance at all. + bool SkipToElement(); + + private: + // Returns the libxml node type of the current node. + int NodeType(); + + // The underlying libxml xmlTextReader. + _xmlTextReader* reader_; +}; + +#endif // THIRD_PARTY_LIBXML_CHROMIUM_XML_READER_H_ diff --git a/chromium/xml_writer.cc b/chromium/xml_writer.cc new file mode 100644 index 000000000000..7c58031fe2d2 --- /dev/null +++ b/chromium/xml_writer.cc @@ -0,0 +1,67 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/libxml/chromium/xml_writer.h" + +#include + +#include "third_party/libxml/chromium/libxml_utils.h" + +XmlWriter::XmlWriter() : writer_(nullptr), buffer_(nullptr) {} + +XmlWriter::~XmlWriter() { + if (writer_) + xmlFreeTextWriter(writer_); + if (buffer_) + xmlBufferFree(buffer_); +} + +void XmlWriter::StartWriting() { + buffer_ = xmlBufferCreate(); + writer_ = xmlNewTextWriterMemory(buffer_, 0); + xmlTextWriterSetIndent(writer_, 1); + xmlTextWriterStartDocument(writer_, nullptr, nullptr, nullptr); +} + +void XmlWriter::StopWriting() { + xmlTextWriterEndDocument(writer_); + xmlFreeTextWriter(writer_); + writer_ = nullptr; +} + +void XmlWriter::StartIndenting() { + xmlTextWriterSetIndent(writer_, 1); +} + +void XmlWriter::StopIndenting() { + xmlTextWriterSetIndent(writer_, 0); +} + +bool XmlWriter::StartElement(const std::string& element_name) { + return xmlTextWriterStartElement(writer_, BAD_CAST element_name.c_str()) >= 0; +} + +bool XmlWriter::EndElement() { + return xmlTextWriterEndElement(writer_) >= 0; +} + +bool XmlWriter::AppendElementContent(const std::string& content) { + return xmlTextWriterWriteString(writer_, BAD_CAST content.c_str()) >= 0; +} + +bool XmlWriter::AddAttribute(const std::string& attribute_name, + const std::string& attribute_value) { + return xmlTextWriterWriteAttribute(writer_, BAD_CAST attribute_name.c_str(), + BAD_CAST attribute_value.c_str()) >= 0; +} + +bool XmlWriter::WriteElement(const std::string& element_name, + const std::string& content) { + return xmlTextWriterWriteElement(writer_, BAD_CAST element_name.c_str(), + BAD_CAST content.c_str()) >= 0; +} + +std::string XmlWriter::GetWrittenString() { + return buffer_ ? internal::XmlStringToStdString(buffer_->content) : ""; +} diff --git a/chromium/xml_writer.h b/chromium/xml_writer.h new file mode 100644 index 000000000000..9b65e759d440 --- /dev/null +++ b/chromium/xml_writer.h @@ -0,0 +1,74 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_LIBXML_CHROMIUM_XML_WRITER_H_ +#define THIRD_PARTY_LIBXML_CHROMIUM_XML_WRITER_H_ + +#include + +extern "C" { +struct _xmlBuffer; +struct _xmlTextWriter; +} + +// XmlWriter is a wrapper class around libxml's xmlWriter, +// providing a simplified C++ API. +// StartWriting must be called before other methods, and StopWriting +// must be called before GetWrittenString() will return results. +class XmlWriter { + public: + XmlWriter(); + ~XmlWriter(); + + // Allocates the xmlTextWriter and an xmlBuffer and starts an XML document. + // This must be called before any other functions. By default, indenting is + // set to true. + void StartWriting(); + + // Ends the XML document and frees the xmlTextWriter. + // This must be called before GetWrittenString() is called. + void StopWriting(); + + // Wrappers around libxml functions ----------------------------------------- + + // All following elements will be indented to match their depth. + void StartIndenting(); + + // All follow elements will not be indented. + void StopIndenting(); + + // Start an element with the given name. All future elements added will be + // children of this element, until it is ended. Returns false on error. + bool StartElement(const std::string& element_name); + + // Ends the current open element. Returns false on error. + bool EndElement(); + + // Appends to the content of the current open element. + bool AppendElementContent(const std::string& content); + + // Adds an attribute to the current open element. Returns false on error. + bool AddAttribute(const std::string& attribute_name, + const std::string& attribute_value); + + // Adds a new element with name |element_name| and content |content| + // to the buffer. Example: <|element_name|>|content| + // Returns false on errors. + bool WriteElement(const std::string& element_name, + const std::string& content); + + // Helper functions not provided by xmlTextWriter --------------------------- + + // Returns the string that has been written to the buffer. + std::string GetWrittenString(); + + private: + // The underlying libxml xmlTextWriter. + _xmlTextWriter* writer_; + + // Stores the output. + _xmlBuffer* buffer_; +}; + +#endif // THIRD_PARTY_LIBXML_CHROMIUM_XML_WRITER_H_ diff --git a/fuzz/README b/fuzz/README new file mode 100644 index 000000000000..d2b85bbc5db8 --- /dev/null +++ b/fuzz/README @@ -0,0 +1,22 @@ +# Seed Corpus + +The `seed_corpus` directory was created using test data from the libxml2 repo by +running the following commands: + +```bash +# Minimize the test data using xml_parser_fuzzer. +$ xml_parser_fuzzer -use_value_profile=1 -max_len=65536 -rss_limit_mb=8192 -merge=1 xml_min1 ~/Projects/libxml2/test + +# Minimize the test data using libxml_xml_read_memory_fuzzer. +$ libxml_xml_read_memory_fuzzer -use_value_profile=1 -max_len=65536 -rss_limit_mb=8192 -merge=1 xml_min2 ~/Projects/libxml2/test + +# Merge the two minimized versions (the majority of the files are the same). +$ cp xml_min1/* xml_min2/* seed_corpus/ +``` + +This corpus gives a good code coverage for the existing XML fuzzers in Chromium. +See //testing/libfuzzer/README.md for more information about fuzzing. + +# Dictionary + +The `xml.dict` was taken from AFL fuzzer with a few minor additions being made. diff --git a/fuzz/seed_corpus/0046047b00a82a1fe56d88665c5f08eb2913cf03 b/fuzz/seed_corpus/0046047b00a82a1fe56d88665c5f08eb2913cf03 new file mode 100644 index 000000000000..e8e94d01ffe0 --- /dev/null +++ b/fuzz/seed_corpus/0046047b00a82a1fe56d88665c5f08eb2913cf03 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/006c315fc21acb1b5ce82c7a6b355a091cb2fc49 b/fuzz/seed_corpus/006c315fc21acb1b5ce82c7a6b355a091cb2fc49 new file mode 100644 index 000000000000..73640344dab7 --- /dev/null +++ b/fuzz/seed_corpus/006c315fc21acb1b5ce82c7a6b355a091cb2fc49 @@ -0,0 +1,13 @@ + + + + + + +
    +
  • First item +
  • Second item, closes the first one +
+ + diff --git a/fuzz/seed_corpus/00945a5dd7a52774fdd9aead9269e5bd2f847ce2 b/fuzz/seed_corpus/00945a5dd7a52774fdd9aead9269e5bd2f847ce2 new file mode 100644 index 000000000000..4985aa3b5b58 --- /dev/null +++ b/fuzz/seed_corpus/00945a5dd7a52774fdd9aead9269e5bd2f847ce2 @@ -0,0 +1,9 @@ + + + + + + + diff --git a/fuzz/seed_corpus/00b1bb2a809832b240779bc1e50fcd3a2ab14fd4 b/fuzz/seed_corpus/00b1bb2a809832b240779bc1e50fcd3a2ab14fd4 new file mode 100644 index 000000000000..f72c31612fcf --- /dev/null +++ b/fuzz/seed_corpus/00b1bb2a809832b240779bc1e50fcd3a2ab14fd4 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/00dafde86ff0f8c9036591cc30b72d0f7490cfcd b/fuzz/seed_corpus/00dafde86ff0f8c9036591cc30b72d0f7490cfcd new file mode 100644 index 000000000000..0a62e91a8463 --- /dev/null +++ b/fuzz/seed_corpus/00dafde86ff0f8c9036591cc30b72d0f7490cfcd @@ -0,0 +1,7 @@ + +%c; + +%a; + +%b; + diff --git a/fuzz/seed_corpus/01148aca72bb87dd2df0016e94e34b04c34edfe6 b/fuzz/seed_corpus/01148aca72bb87dd2df0016e94e34b04c34edfe6 new file mode 100644 index 000000000000..2c81c0943f7f --- /dev/null +++ b/fuzz/seed_corpus/01148aca72bb87dd2df0016e94e34b04c34edfe6 @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/fuzz/seed_corpus/0199b3c9a99e71a24cd9126a922533c2b14a60c8 b/fuzz/seed_corpus/0199b3c9a99e71a24cd9126a922533c2b14a60c8 new file mode 100644 index 000000000000..4cd118ce5a10 --- /dev/null +++ b/fuzz/seed_corpus/0199b3c9a99e71a24cd9126a922533c2b14a60c8 @@ -0,0 +1,20 @@ + + + +gnome-xml push mode bug + + + + + + + + +
+ Foo1 + + +
Foo2

+
Foo3
+ + diff --git a/fuzz/seed_corpus/0199e2ffeafeed2c63576109cab1131c2182c49c b/fuzz/seed_corpus/0199e2ffeafeed2c63576109cab1131c2182c49c new file mode 100644 index 000000000000..3f27aed41829 --- /dev/null +++ b/fuzz/seed_corpus/0199e2ffeafeed2c63576109cab1131c2182c49c @@ -0,0 +1,10 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:e11] + diff --git a/fuzz/seed_corpus/0199fc60e9af21a3be8cbdc03622c3ebad9c2f2d b/fuzz/seed_corpus/0199fc60e9af21a3be8cbdc03622c3ebad9c2f2d new file mode 100644 index 000000000000..819323172f42 --- /dev/null +++ b/fuzz/seed_corpus/0199fc60e9af21a3be8cbdc03622c3ebad9c2f2d @@ -0,0 +1,10 @@ + + + +]> + + + + + diff --git a/fuzz/seed_corpus/0212f02cef3483152bb9871fd93aa4a69ea181a6 b/fuzz/seed_corpus/0212f02cef3483152bb9871fd93aa4a69ea181a6 new file mode 100644 index 000000000000..37a87c9f5c84 --- /dev/null +++ b/fuzz/seed_corpus/0212f02cef3483152bb9871fd93aa4a69ea181a6 @@ -0,0 +1,14 @@ + + + + + + 1 + 2 + 3 + + + + + + diff --git a/fuzz/seed_corpus/025dbaa618983aba2fd0ba6b6a803cdd0de76460 b/fuzz/seed_corpus/025dbaa618983aba2fd0ba6b6a803cdd0de76460 new file mode 100644 index 000000000000..c849c03390fe --- /dev/null +++ b/fuzz/seed_corpus/025dbaa618983aba2fd0ba6b6a803cdd0de76460 @@ -0,0 +1,5 @@ + + This should fail + diff --git a/fuzz/seed_corpus/0299a259ba8264e3aec403d768db7ad3a0a93e4a b/fuzz/seed_corpus/0299a259ba8264e3aec403d768db7ad3a0a93e4a new file mode 100644 index 000000000000..d5cdd7ccb2f8 --- /dev/null +++ b/fuzz/seed_corpus/0299a259ba8264e3aec403d768db7ad3a0a93e4a @@ -0,0 +1 @@ +is a test diff --git a/fuzz/seed_corpus/02d7a5beb17053ac8020ed23c0489f93d39c5321 b/fuzz/seed_corpus/02d7a5beb17053ac8020ed23c0489f93d39c5321 new file mode 100644 index 000000000000..b2980859f2e6 --- /dev/null +++ b/fuzz/seed_corpus/02d7a5beb17053ac8020ed23c0489f93d39c5321 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/034e3c37a5f06912e1ff8fc7b90a26175bccf935 b/fuzz/seed_corpus/034e3c37a5f06912e1ff8fc7b90a26175bccf935 new file mode 100644 index 000000000000..fa935770eae5 --- /dev/null +++ b/fuzz/seed_corpus/034e3c37a5f06912e1ff8fc7b90a26175bccf935 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/03713dd0e13838f82b527912f3748e2d1171fb91 b/fuzz/seed_corpus/03713dd0e13838f82b527912f3748e2d1171fb91 new file mode 100644 index 000000000000..87c6802899d2 --- /dev/null +++ b/fuzz/seed_corpus/03713dd0e13838f82b527912f3748e2d1171fb91 @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/041ac56e4bfd93af5cc2e4aaa053f11c23c61d19 b/fuzz/seed_corpus/041ac56e4bfd93af5cc2e4aaa053f11c23c61d19 new file mode 100644 index 000000000000..50b5b16b7277 --- /dev/null +++ b/fuzz/seed_corpus/041ac56e4bfd93af5cc2e4aaa053f11c23c61d19 @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/049f9eb07492c4966b1f5b781bff895f3fab33c0 b/fuzz/seed_corpus/049f9eb07492c4966b1f5b781bff895f3fab33c0 new file mode 100644 index 000000000000..db23275606a7 --- /dev/null +++ b/fuzz/seed_corpus/049f9eb07492c4966b1f5b781bff895f3fab33c0 @@ -0,0 +1,46 @@ + + + + +Char* ']]>' Char*)) +']]>' +CDATA sections +| '<!DOCTYPE' +(Char - ('[' | ']'))+ +('[' +simpleDTD* +']')? '>' +doc type declaration +simpleDTD +'<!&como;' +(Char* - +(Char* '&comc;' Char*)) +'&comc;>'--> + diff --git a/fuzz/seed_corpus/04c408efc27d601dbd1e91148e2e37ae969fb97e b/fuzz/seed_corpus/04c408efc27d601dbd1e91148e2e37ae969fb97e new file mode 100644 index 000000000000..a742a0d2323a --- /dev/null +++ b/fuzz/seed_corpus/04c408efc27d601dbd1e91148e2e37ae969fb97e @@ -0,0 +1,9 @@ + + + $File: //depot/NNL/R1.0_SandM_Dev/Projects/SandM/src/uisupport +/xml/cliTestCommands.xml $ + + diff --git a/fuzz/seed_corpus/04dabdaea684ba279bbf03b0ae22b366083ff7aa b/fuzz/seed_corpus/04dabdaea684ba279bbf03b0ae22b366083ff7aa new file mode 100644 index 000000000000..45b4857fc89a --- /dev/null +++ b/fuzz/seed_corpus/04dabdaea684ba279bbf03b0ae22b366083ff7aa @@ -0,0 +1 @@ +1.2 3.4 5 6 7 8 diff --git a/fuzz/seed_corpus/04e0d9e30029cd448cd9c2a4c964ce012c976d90 b/fuzz/seed_corpus/04e0d9e30029cd448cd9c2a4c964ce012c976d90 new file mode 100644 index 000000000000..11376625a4a3 --- /dev/null +++ b/fuzz/seed_corpus/04e0d9e30029cd448cd9c2a4c964ce012c976d90 @@ -0,0 +1,22 @@ + + + + + + + write + exclusive + + http://foo.com/doc/ + + Jane Smith + Infinite + + iamuri:unique!!!!! + + + + + HTTP/1.1 200 OK + + diff --git a/fuzz/seed_corpus/04ef401357f30717ba5862256fca75cda1436157 b/fuzz/seed_corpus/04ef401357f30717ba5862256fca75cda1436157 new file mode 100644 index 000000000000..9cfe8c6eddf2 --- /dev/null +++ b/fuzz/seed_corpus/04ef401357f30717ba5862256fca75cda1436157 @@ -0,0 +1,173 @@ + + + + + + This schema describes giml dialog sources + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/052e9d557fe9d32b953adcdfca65788e07ead143 b/fuzz/seed_corpus/052e9d557fe9d32b953adcdfca65788e07ead143 new file mode 100644 index 000000000000..dac71f9b1f25 --- /dev/null +++ b/fuzz/seed_corpus/052e9d557fe9d32b953adcdfca65788e07ead143 @@ -0,0 +1,10 @@ + + + There is no b.xml ... + + + There is no c.xml ... + + + + diff --git a/fuzz/seed_corpus/0533c0ff80dcd22bd55bb8bc8993cd84b1b97914 b/fuzz/seed_corpus/0533c0ff80dcd22bd55bb8bc8993cd84b1b97914 new file mode 100644 index 000000000000..a88115f386d2 --- /dev/null +++ b/fuzz/seed_corpus/0533c0ff80dcd22bd55bb8bc8993cd84b1b97914 @@ -0,0 +1,7 @@ + + + + +]> + diff --git a/fuzz/seed_corpus/058df98d84d0037f011420c5c29c45e6b88bbadd b/fuzz/seed_corpus/058df98d84d0037f011420c5c29c45e6b88bbadd new file mode 100644 index 000000000000..8af51ec0052e --- /dev/null +++ b/fuzz/seed_corpus/058df98d84d0037f011420c5c29c45e6b88bbadd @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/05f1cd6c5d6d21ae108cbcdde5e57ae914568082 b/fuzz/seed_corpus/05f1cd6c5d6d21ae108cbcdde5e57ae914568082 new file mode 100644 index 000000000000..9a63917de7d6 --- /dev/null +++ b/fuzz/seed_corpus/05f1cd6c5d6d21ae108cbcdde5e57ae914568082 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/06060a5bfcbd6220ca5a522be3bd58dedc6bedd8 b/fuzz/seed_corpus/06060a5bfcbd6220ca5a522be3bd58dedc6bedd8 new file mode 100644 index 000000000000..41171cb47cb8 --- /dev/null +++ b/fuzz/seed_corpus/06060a5bfcbd6220ca5a522be3bd58dedc6bedd8 @@ -0,0 +1,11 @@ + + +]> + + + + + + + diff --git a/fuzz/seed_corpus/064e4c40476264152302e53a5d5d68c90f36a9bb b/fuzz/seed_corpus/064e4c40476264152302e53a5d5d68c90f36a9bb new file mode 100644 index 000000000000..40b2f1299122 --- /dev/null +++ b/fuzz/seed_corpus/064e4c40476264152302e53a5d5d68c90f36a9bb @@ -0,0 +1,8 @@ + + + + + +]> + diff --git a/fuzz/seed_corpus/0666dce9a0f535c4b9fb1af43c0239f4fae6d0fb b/fuzz/seed_corpus/0666dce9a0f535c4b9fb1af43c0239f4fae6d0fb new file mode 100644 index 000000000000..e9cbc0c85fc1 --- /dev/null +++ b/fuzz/seed_corpus/0666dce9a0f535c4b9fb1af43c0239f4fae6d0fb @@ -0,0 +1,6 @@ + + + +]> + diff --git a/fuzz/seed_corpus/06f5fd11efe6278ce31ac322099eea1580f3cc80 b/fuzz/seed_corpus/06f5fd11efe6278ce31ac322099eea1580f3cc80 new file mode 100644 index 000000000000..cb5b1a665d71 --- /dev/null +++ b/fuzz/seed_corpus/06f5fd11efe6278ce31ac322099eea1580f3cc80 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/07028eb348b8c531e11c70e5e6acf6e44b12268e b/fuzz/seed_corpus/07028eb348b8c531e11c70e5e6acf6e44b12268e new file mode 100644 index 000000000000..fae9af1a5473 --- /dev/null +++ b/fuzz/seed_corpus/07028eb348b8c531e11c70e5e6acf6e44b12268e @@ -0,0 +1,8 @@ + + + + 123 + 456 + + diff --git a/fuzz/seed_corpus/0704cd3859fa29b00abc00048c8f2dc7697d2149 b/fuzz/seed_corpus/0704cd3859fa29b00abc00048c8f2dc7697d2149 new file mode 100644 index 000000000000..92c5322f89bb --- /dev/null +++ b/fuzz/seed_corpus/0704cd3859fa29b00abc00048c8f2dc7697d2149 @@ -0,0 +1,12 @@ + + + + + +]> + + &ent1;, &ent2;! + + + diff --git a/fuzz/seed_corpus/070b97218d858e0b8633f8cb8950f0dd399fb74b b/fuzz/seed_corpus/070b97218d858e0b8633f8cb8950f0dd399fb74b new file mode 100644 index 000000000000..195d5892f1b0 --- /dev/null +++ b/fuzz/seed_corpus/070b97218d858e0b8633f8cb8950f0dd399fb74b @@ -0,0 +1,1665 @@ + + + + ncurses4 + 4.2 + 3 + i386 + Linux + DLD + delix Computer GmbH + Till Bubeck <bubeck@delix.de>, Ngo Than <than@delix.de> + Libraries + Bibliothek zur Ansteuerung von Terminals + Diese Library stellt dem Programmierer vom Terminal unabhängige +Routinen zur Ansteuerung Ihres Bildschirms zur Verfügung, die +speziell optimiert sind. +Diese Version ist die 'new curses' (ncurses) Variante und ist der +anerkannte Ersatz für die klassische Curses-Library, die nicht mehr +weiterentwickelt wird. + GPL + ncurses4-4.2-3.src.rpm + Tue May 12 19:30:26 1998 + 895015826 + 1373513 + erdbeere.delix.de + + + ncurses4 + libpanel.so.4 + libncurses.so.4 + libmenu.so.4 + libform.so.4 + ncurses + + + /lib/libncurses.so.4 +/lib/libncurses.so.4.2 +/usr/doc/ncurses4-4.2-3 +/usr/doc/ncurses4-4.2-3/ANNOUNCE.gz +/usr/doc/ncurses4-4.2-3/NEWS.gz +/usr/doc/ncurses4-4.2-3/README.gz +/usr/doc/ncurses4-4.2-3/TO-DO.gz +/usr/lib/libform.so.4 +/usr/lib/libform.so.4.2 +/usr/lib/libmenu.so.4 +/usr/lib/libmenu.so.4.2 +/usr/lib/libpanel.so.4 +/usr/lib/libpanel.so.4.2 +/usr/share/ncurses4 +/usr/share/ncurses4/tabset +/usr/share/ncurses4/tabset/std +/usr/share/ncurses4/tabset/stdcrt +/usr/share/ncurses4/tabset/vt100 +/usr/share/ncurses4/tabset/vt300 +/usr/share/ncurses4/terminfo +/usr/share/ncurses4/terminfo/1 +/usr/share/ncurses4/terminfo/1/1178 +/usr/share/ncurses4/terminfo/1/1730-lm +/usr/share/ncurses4/terminfo/2 +/usr/share/ncurses4/terminfo/2/2621 +/usr/share/ncurses4/terminfo/2/2621-wl +/usr/share/ncurses4/terminfo/2/2621A +/usr/share/ncurses4/terminfo/2/2621a +/usr/share/ncurses4/terminfo/3 +/usr/share/ncurses4/terminfo/3/386at +/usr/share/ncurses4/terminfo/3/3b1 +/usr/share/ncurses4/terminfo/4 +/usr/share/ncurses4/terminfo/4/4025ex +/usr/share/ncurses4/terminfo/4/4027ex +/usr/share/ncurses4/terminfo/4/4410-w +/usr/share/ncurses4/terminfo/5 +/usr/share/ncurses4/terminfo/5/5051 +/usr/share/ncurses4/terminfo/5/5410-w +/usr/share/ncurses4/terminfo/5/5620 +/usr/share/ncurses4/terminfo/5/5630-24 +/usr/share/ncurses4/terminfo/5/5630DMD-24 +/usr/share/ncurses4/terminfo/6 +/usr/share/ncurses4/terminfo/6/630-lm +/usr/share/ncurses4/terminfo/6/630MTG-24 +/usr/share/ncurses4/terminfo/7 +/usr/share/ncurses4/terminfo/7/730MTG-24 +/usr/share/ncurses4/terminfo/7/730MTG-41 +/usr/share/ncurses4/terminfo/7/730MTG-41r +/usr/share/ncurses4/terminfo/7/730MTGr +/usr/share/ncurses4/terminfo/7/730MTGr-24 +/usr/share/ncurses4/terminfo/8 +/usr/share/ncurses4/terminfo/8/8510 +/usr/share/ncurses4/terminfo/9 +/usr/share/ncurses4/terminfo/9/955-hb +/usr/share/ncurses4/terminfo/9/955-w +/usr/share/ncurses4/terminfo/P +/usr/share/ncurses4/terminfo/P/P12 +/usr/share/ncurses4/terminfo/P/P12-M +/usr/share/ncurses4/terminfo/P/P12-M-W +/usr/share/ncurses4/terminfo/P/P12-W +/usr/share/ncurses4/terminfo/P/P14 +/usr/share/ncurses4/terminfo/P/P14-M +/usr/share/ncurses4/terminfo/P/P14-M-W +/usr/share/ncurses4/terminfo/P/P14-W +/usr/share/ncurses4/terminfo/P/P4 +/usr/share/ncurses4/terminfo/P/P5 +/usr/share/ncurses4/terminfo/P/P7 +/usr/share/ncurses4/terminfo/P/P8 +/usr/share/ncurses4/terminfo/P/P8-W +/usr/share/ncurses4/terminfo/P/P9 +/usr/share/ncurses4/terminfo/P/P9-8 +/usr/share/ncurses4/terminfo/P/P9-8-W +/usr/share/ncurses4/terminfo/P/P9-W +/usr/share/ncurses4/terminfo/X +/usr/share/ncurses4/terminfo/X/X-hpterm +/usr/share/ncurses4/terminfo/a +/usr/share/ncurses4/terminfo/a/a210 +/usr/share/ncurses4/terminfo/a/a80 +/usr/share/ncurses4/terminfo/a/a980 +/usr/share/ncurses4/terminfo/a/aa4080 +/usr/share/ncurses4/terminfo/a/aaa +/usr/share/ncurses4/terminfo/a/aaa+dec +/usr/share/ncurses4/terminfo/a/aaa+rv +/usr/share/ncurses4/terminfo/a/aaa+unk +/usr/share/ncurses4/terminfo/a/aaa-18 +/usr/share/ncurses4/terminfo/a/aaa-18-rv +/usr/share/ncurses4/terminfo/a/aaa-20 +/usr/share/ncurses4/terminfo/a/aaa-22 +/usr/share/ncurses4/terminfo/a/aaa-24 +/usr/share/ncurses4/terminfo/a/aaa-24-rv +/usr/share/ncurses4/terminfo/a/aaa-26 +/usr/share/ncurses4/terminfo/a/aaa-28 +/usr/share/ncurses4/terminfo/a/aaa-30 +/usr/share/ncurses4/terminfo/a/aaa-30-ctxt +/usr/share/ncurses4/terminfo/a/aaa-30-rv +/usr/share/ncurses4/terminfo/a/aaa-30-rv-ctxt +/usr/share/ncurses4/terminfo/a/aaa-30-s +/usr/share/ncurses4/terminfo/a/aaa-30-s-ctxt +/usr/share/ncurses4/terminfo/a/aaa-30-s-rv +/usr/share/ncurses4/terminfo/a/aaa-30-s-rv-ct +/usr/share/ncurses4/terminfo/a/aaa-36 +/usr/share/ncurses4/terminfo/a/aaa-36-rv +/usr/share/ncurses4/terminfo/a/aaa-40 +/usr/share/ncurses4/terminfo/a/aaa-40-rv +/usr/share/ncurses4/terminfo/a/aaa-48 +/usr/share/ncurses4/terminfo/a/aaa-48-rv +/usr/share/ncurses4/terminfo/a/aaa-60 +/usr/share/ncurses4/terminfo/a/aaa-60-dec-rv +/usr/share/ncurses4/terminfo/a/aaa-60-rv +/usr/share/ncurses4/terminfo/a/aaa-60-s +/usr/share/ncurses4/terminfo/a/aaa-60-s-rv +/usr/share/ncurses4/terminfo/a/aaa-ctxt +/usr/share/ncurses4/terminfo/a/aaa-db +/usr/share/ncurses4/terminfo/a/aaa-rv +/usr/share/ncurses4/terminfo/a/aaa-rv-ctxt +/usr/share/ncurses4/terminfo/a/aaa-rv-unk +/usr/share/ncurses4/terminfo/a/aaa-s +/usr/share/ncurses4/terminfo/a/aaa-s-ctxt +/usr/share/ncurses4/terminfo/a/aaa-s-rv +/usr/share/ncurses4/terminfo/a/aaa-s-rv-ctxt +/usr/share/ncurses4/terminfo/a/aaa-unk +/usr/share/ncurses4/terminfo/a/aas1901 +/usr/share/ncurses4/terminfo/a/abm80 +/usr/share/ncurses4/terminfo/a/abm85 +/usr/share/ncurses4/terminfo/a/abm85e +/usr/share/ncurses4/terminfo/a/abm85h +/usr/share/ncurses4/terminfo/a/abm85h-old +/usr/share/ncurses4/terminfo/a/act4 +/usr/share/ncurses4/terminfo/a/act5 +/usr/share/ncurses4/terminfo/a/addrinfo +/usr/share/ncurses4/terminfo/a/adds980 +/usr/share/ncurses4/terminfo/a/addsviewpoint +/usr/share/ncurses4/terminfo/a/addsvp60 +/usr/share/ncurses4/terminfo/a/adm+sgr +/usr/share/ncurses4/terminfo/a/adm1 +/usr/share/ncurses4/terminfo/a/adm11 +/usr/share/ncurses4/terminfo/a/adm1178 +/usr/share/ncurses4/terminfo/a/adm12 +/usr/share/ncurses4/terminfo/a/adm1a +/usr/share/ncurses4/terminfo/a/adm2 +/usr/share/ncurses4/terminfo/a/adm20 +/usr/share/ncurses4/terminfo/a/adm21 +/usr/share/ncurses4/terminfo/a/adm22 +/usr/share/ncurses4/terminfo/a/adm3 +/usr/share/ncurses4/terminfo/a/adm31 +/usr/share/ncurses4/terminfo/a/adm31-old +/usr/share/ncurses4/terminfo/a/adm36 +/usr/share/ncurses4/terminfo/a/adm3a +/usr/share/ncurses4/terminfo/a/adm3a+ +/usr/share/ncurses4/terminfo/a/adm42 +/usr/share/ncurses4/terminfo/a/adm42-ns +/usr/share/ncurses4/terminfo/a/adm5 +/usr/share/ncurses4/terminfo/a/aepro +/usr/share/ncurses4/terminfo/a/aixterm-m +/usr/share/ncurses4/terminfo/a/aixterm-m-old +/usr/share/ncurses4/terminfo/a/aj +/usr/share/ncurses4/terminfo/a/aj510 +/usr/share/ncurses4/terminfo/a/aj830 +/usr/share/ncurses4/terminfo/a/aj832 +/usr/share/ncurses4/terminfo/a/alt2 +/usr/share/ncurses4/terminfo/a/alt3 +/usr/share/ncurses4/terminfo/a/alt4 +/usr/share/ncurses4/terminfo/a/alt5 +/usr/share/ncurses4/terminfo/a/alt7 +/usr/share/ncurses4/terminfo/a/alt7pc +/usr/share/ncurses4/terminfo/a/alto-h19 +/usr/share/ncurses4/terminfo/a/alto-heath +/usr/share/ncurses4/terminfo/a/altoh19 +/usr/share/ncurses4/terminfo/a/altoheath +/usr/share/ncurses4/terminfo/a/altos-2 +/usr/share/ncurses4/terminfo/a/altos-3 +/usr/share/ncurses4/terminfo/a/altos-4 +/usr/share/ncurses4/terminfo/a/altos-5 +/usr/share/ncurses4/terminfo/a/altos2 +/usr/share/ncurses4/terminfo/a/altos3 +/usr/share/ncurses4/terminfo/a/altos4 +/usr/share/ncurses4/terminfo/a/altos5 +/usr/share/ncurses4/terminfo/a/altos7 +/usr/share/ncurses4/terminfo/a/altos7pc +/usr/share/ncurses4/terminfo/a/ambas +/usr/share/ncurses4/terminfo/a/ambassador +/usr/share/ncurses4/terminfo/a/amiga +/usr/share/ncurses4/terminfo/a/amiga-h +/usr/share/ncurses4/terminfo/a/amp219 +/usr/share/ncurses4/terminfo/a/amp219w +/usr/share/ncurses4/terminfo/a/ampex-219 +/usr/share/ncurses4/terminfo/a/ampex-219w +/usr/share/ncurses4/terminfo/a/ampex-232 +/usr/share/ncurses4/terminfo/a/ampex175 +/usr/share/ncurses4/terminfo/a/ampex175-b +/usr/share/ncurses4/terminfo/a/ampex210 +/usr/share/ncurses4/terminfo/a/ampex219 +/usr/share/ncurses4/terminfo/a/ampex219w +/usr/share/ncurses4/terminfo/a/ampex232 +/usr/share/ncurses4/terminfo/a/ampex232w +/usr/share/ncurses4/terminfo/a/ampex80 +/usr/share/ncurses4/terminfo/a/annarbor4080 +/usr/share/ncurses4/terminfo/a/ansi +/usr/share/ncurses4/terminfo/a/ansi-color-2-emx +/usr/share/ncurses4/terminfo/a/ansi-color-3-emx +/usr/share/ncurses4/terminfo/a/ansi-emx +/usr/share/ncurses4/terminfo/a/ansi-m +/usr/share/ncurses4/terminfo/a/ansi-mini +/usr/share/ncurses4/terminfo/a/ansi-mono +/usr/share/ncurses4/terminfo/a/ansi-nt +/usr/share/ncurses4/terminfo/a/ansi.sys +/usr/share/ncurses4/terminfo/a/ansi.sys-old +/usr/share/ncurses4/terminfo/a/ansi.sysk +/usr/share/ncurses4/terminfo/a/ansi43m +/usr/share/ncurses4/terminfo/a/ansi77 +/usr/share/ncurses4/terminfo/a/ansi80x25 +/usr/share/ncurses4/terminfo/a/ansi80x25-mono +/usr/share/ncurses4/terminfo/a/ansi80x25-raw +/usr/share/ncurses4/terminfo/a/ansi80x30 +/usr/share/ncurses4/terminfo/a/ansi80x30-mono +/usr/share/ncurses4/terminfo/a/ansi80x43 +/usr/share/ncurses4/terminfo/a/ansi80x43-mono +/usr/share/ncurses4/terminfo/a/ansi80x50 +/usr/share/ncurses4/terminfo/a/ansi80x50-mono +/usr/share/ncurses4/terminfo/a/ansi80x60 +/usr/share/ncurses4/terminfo/a/ansi80x60-mono +/usr/share/ncurses4/terminfo/a/ansil +/usr/share/ncurses4/terminfo/a/ansil-mono +/usr/share/ncurses4/terminfo/a/ansis +/usr/share/ncurses4/terminfo/a/ansis-mono +/usr/share/ncurses4/terminfo/a/ansisysk +/usr/share/ncurses4/terminfo/a/ansiw +/usr/share/ncurses4/terminfo/a/ap-vm80 +/usr/share/ncurses4/terminfo/a/apl +/usr/share/ncurses4/terminfo/a/apollo +/usr/share/ncurses4/terminfo/a/apollo_15P +/usr/share/ncurses4/terminfo/a/apollo_19L +/usr/share/ncurses4/terminfo/a/apollo_color +/usr/share/ncurses4/terminfo/a/apple-80 +/usr/share/ncurses4/terminfo/a/apple-ae +/usr/share/ncurses4/terminfo/a/apple-soroc +/usr/share/ncurses4/terminfo/a/apple-uterm +/usr/share/ncurses4/terminfo/a/apple-uterm-vb +/usr/share/ncurses4/terminfo/a/apple-videx +/usr/share/ncurses4/terminfo/a/apple-videx2 +/usr/share/ncurses4/terminfo/a/apple-videx3 +/usr/share/ncurses4/terminfo/a/apple-vm80 +/usr/share/ncurses4/terminfo/a/apple2e +/usr/share/ncurses4/terminfo/a/apple2e-p +/usr/share/ncurses4/terminfo/a/apple80p +/usr/share/ncurses4/terminfo/a/appleII +/usr/share/ncurses4/terminfo/a/appleIIc +/usr/share/ncurses4/terminfo/a/appleIIe +/usr/share/ncurses4/terminfo/a/appleIIgs +/usr/share/ncurses4/terminfo/a/at386 +/usr/share/ncurses4/terminfo/a/atari +/usr/share/ncurses4/terminfo/a/att2300 +/usr/share/ncurses4/terminfo/a/att2350 +/usr/share/ncurses4/terminfo/a/att4410 +/usr/share/ncurses4/terminfo/a/att4410-w +/usr/share/ncurses4/terminfo/a/att4410v1 +/usr/share/ncurses4/terminfo/a/att4410v1-w +/usr/share/ncurses4/terminfo/a/att4415 +/usr/share/ncurses4/terminfo/a/att4415+nl +/usr/share/ncurses4/terminfo/a/att4415-nl +/usr/share/ncurses4/terminfo/a/att4415-rv +/usr/share/ncurses4/terminfo/a/att4415-rv-nl +/usr/share/ncurses4/terminfo/a/att4415-w +/usr/share/ncurses4/terminfo/a/att4415-w-nl +/usr/share/ncurses4/terminfo/a/att4415-w-rv +/usr/share/ncurses4/terminfo/a/att4415-w-rv-n +/usr/share/ncurses4/terminfo/a/att4418 +/usr/share/ncurses4/terminfo/a/att4418-w +/usr/share/ncurses4/terminfo/a/att4420 +/usr/share/ncurses4/terminfo/a/att4424 +/usr/share/ncurses4/terminfo/a/att4424-1 +/usr/share/ncurses4/terminfo/a/att4424m +/usr/share/ncurses4/terminfo/a/att4425 +/usr/share/ncurses4/terminfo/a/att4425-nl +/usr/share/ncurses4/terminfo/a/att4425-w +/usr/share/ncurses4/terminfo/a/att4426 +/usr/share/ncurses4/terminfo/a/att500 +/usr/share/ncurses4/terminfo/a/att505 +/usr/share/ncurses4/terminfo/a/att505-24 +/usr/share/ncurses4/terminfo/a/att510a +/usr/share/ncurses4/terminfo/a/att510d +/usr/share/ncurses4/terminfo/a/att513 +/usr/share/ncurses4/terminfo/a/att5310 +/usr/share/ncurses4/terminfo/a/att5320 +/usr/share/ncurses4/terminfo/a/att5410 +/usr/share/ncurses4/terminfo/a/att5410-w +/usr/share/ncurses4/terminfo/a/att5410v1 +/usr/share/ncurses4/terminfo/a/att5410v1-w +/usr/share/ncurses4/terminfo/a/att5418 +/usr/share/ncurses4/terminfo/a/att5418-w +/usr/share/ncurses4/terminfo/a/att5420 +/usr/share/ncurses4/terminfo/a/att5420+nl +/usr/share/ncurses4/terminfo/a/att5420-nl +/usr/share/ncurses4/terminfo/a/att5420-rv +/usr/share/ncurses4/terminfo/a/att5420-rv-nl +/usr/share/ncurses4/terminfo/a/att5420-w +/usr/share/ncurses4/terminfo/a/att5420-w-nl +/usr/share/ncurses4/terminfo/a/att5420-w-rv +/usr/share/ncurses4/terminfo/a/att5420-w-rv-n +/usr/share/ncurses4/terminfo/a/att5420_2 +/usr/share/ncurses4/terminfo/a/att5420_2-w +/usr/share/ncurses4/terminfo/a/att5425 +/usr/share/ncurses4/terminfo/a/att5425-nl +/usr/share/ncurses4/terminfo/a/att5425-w +/usr/share/ncurses4/terminfo/a/att5430 +/usr/share/ncurses4/terminfo/a/att5620 +/usr/share/ncurses4/terminfo/a/att5620-1 +/usr/share/ncurses4/terminfo/a/att5620-24 +/usr/share/ncurses4/terminfo/a/att5620-34 +/usr/share/ncurses4/terminfo/a/att5620-s +/usr/share/ncurses4/terminfo/a/att605 +/usr/share/ncurses4/terminfo/a/att605-pc +/usr/share/ncurses4/terminfo/a/att605-w +/usr/share/ncurses4/terminfo/a/att610 +/usr/share/ncurses4/terminfo/a/att610-103k +/usr/share/ncurses4/terminfo/a/att610-103k-w +/usr/share/ncurses4/terminfo/a/att610-w +/usr/share/ncurses4/terminfo/a/att615 +/usr/share/ncurses4/terminfo/a/att615-103k +/usr/share/ncurses4/terminfo/a/att615-103k-w +/usr/share/ncurses4/terminfo/a/att615-w +/usr/share/ncurses4/terminfo/a/att620 +/usr/share/ncurses4/terminfo/a/att620-103k +/usr/share/ncurses4/terminfo/a/att620-103k-w +/usr/share/ncurses4/terminfo/a/att620-w +/usr/share/ncurses4/terminfo/a/att630 +/usr/share/ncurses4/terminfo/a/att630-24 +/usr/share/ncurses4/terminfo/a/att6386 +/usr/share/ncurses4/terminfo/a/att730 +/usr/share/ncurses4/terminfo/a/att730-24 +/usr/share/ncurses4/terminfo/a/att730-41 +/usr/share/ncurses4/terminfo/a/att7300 +/usr/share/ncurses4/terminfo/a/att730r +/usr/share/ncurses4/terminfo/a/att730r-24 +/usr/share/ncurses4/terminfo/a/att730r-41 +/usr/share/ncurses4/terminfo/a/avatar +/usr/share/ncurses4/terminfo/a/avatar0 +/usr/share/ncurses4/terminfo/a/avatar0+ +/usr/share/ncurses4/terminfo/a/avatar1 +/usr/share/ncurses4/terminfo/a/avt +/usr/share/ncurses4/terminfo/a/avt+s +/usr/share/ncurses4/terminfo/a/avt-ns +/usr/share/ncurses4/terminfo/a/avt-rv +/usr/share/ncurses4/terminfo/a/avt-rv-ns +/usr/share/ncurses4/terminfo/a/avt-rv-s +/usr/share/ncurses4/terminfo/a/avt-s +/usr/share/ncurses4/terminfo/a/avt-w +/usr/share/ncurses4/terminfo/a/avt-w-ns +/usr/share/ncurses4/terminfo/a/avt-w-rv +/usr/share/ncurses4/terminfo/a/avt-w-rv-ns +/usr/share/ncurses4/terminfo/a/avt-w-rv-s +/usr/share/ncurses4/terminfo/a/avt-w-s +/usr/share/ncurses4/terminfo/a/aws +/usr/share/ncurses4/terminfo/a/awsc +/usr/share/ncurses4/terminfo/b +/usr/share/ncurses4/terminfo/b/b-128 +/usr/share/ncurses4/terminfo/b/bantam +/usr/share/ncurses4/terminfo/b/basic4 +/usr/share/ncurses4/terminfo/b/basis +/usr/share/ncurses4/terminfo/b/bct510a +/usr/share/ncurses4/terminfo/b/bct510d +/usr/share/ncurses4/terminfo/b/beacon +/usr/share/ncurses4/terminfo/b/bee +/usr/share/ncurses4/terminfo/b/beehive +/usr/share/ncurses4/terminfo/b/beehive3 +/usr/share/ncurses4/terminfo/b/beehive4 +/usr/share/ncurses4/terminfo/b/beehiveIIIm +/usr/share/ncurses4/terminfo/b/beterm +/usr/share/ncurses4/terminfo/b/bg1.25 +/usr/share/ncurses4/terminfo/b/bg1.25nv +/usr/share/ncurses4/terminfo/b/bg1.25rv +/usr/share/ncurses4/terminfo/b/bg2.0 +/usr/share/ncurses4/terminfo/b/bg2.0nv +/usr/share/ncurses4/terminfo/b/bg2.0rv +/usr/share/ncurses4/terminfo/b/bg3.10 +/usr/share/ncurses4/terminfo/b/bg3.10nv +/usr/share/ncurses4/terminfo/b/bg3.10rv +/usr/share/ncurses4/terminfo/b/bh3m +/usr/share/ncurses4/terminfo/b/bh4 +/usr/share/ncurses4/terminfo/b/bitgraph +/usr/share/ncurses4/terminfo/b/blit +/usr/share/ncurses4/terminfo/b/bobcat +/usr/share/ncurses4/terminfo/b/bsdos +/usr/share/ncurses4/terminfo/b/bsdos-bold +/usr/share/ncurses4/terminfo/c +/usr/share/ncurses4/terminfo/c/c100 +/usr/share/ncurses4/terminfo/c/c100-1p +/usr/share/ncurses4/terminfo/c/c100-4p +/usr/share/ncurses4/terminfo/c/c100-rv +/usr/share/ncurses4/terminfo/c/c100-rv-4p +/usr/share/ncurses4/terminfo/c/c104 +/usr/share/ncurses4/terminfo/c/c108 +/usr/share/ncurses4/terminfo/c/c108-4p +/usr/share/ncurses4/terminfo/c/c108-8p +/usr/share/ncurses4/terminfo/c/c108-rv +/usr/share/ncurses4/terminfo/c/c108-rv-4p +/usr/share/ncurses4/terminfo/c/c108-rv-8p +/usr/share/ncurses4/terminfo/c/c108-w +/usr/share/ncurses4/terminfo/c/c108-w-8p +/usr/share/ncurses4/terminfo/c/c300 +/usr/share/ncurses4/terminfo/c/c301 +/usr/share/ncurses4/terminfo/c/c321 +/usr/share/ncurses4/terminfo/c/ca22851 +/usr/share/ncurses4/terminfo/c/cad68-2 +/usr/share/ncurses4/terminfo/c/cad68-3 +/usr/share/ncurses4/terminfo/c/cbblit +/usr/share/ncurses4/terminfo/c/cbunix +/usr/share/ncurses4/terminfo/c/cci +/usr/share/ncurses4/terminfo/c/cci1 +/usr/share/ncurses4/terminfo/c/cdc456 +/usr/share/ncurses4/terminfo/c/cdc721 +/usr/share/ncurses4/terminfo/c/cdc721-esc +/usr/share/ncurses4/terminfo/c/cdc721ll +/usr/share/ncurses4/terminfo/c/cdc752 +/usr/share/ncurses4/terminfo/c/cdc756 +/usr/share/ncurses4/terminfo/c/cg7900 +/usr/share/ncurses4/terminfo/c/cgc2 +/usr/share/ncurses4/terminfo/c/cgc3 +/usr/share/ncurses4/terminfo/c/chromatics +/usr/share/ncurses4/terminfo/c/ci8510 +/usr/share/ncurses4/terminfo/c/cit-80 +/usr/share/ncurses4/terminfo/c/cit101 +/usr/share/ncurses4/terminfo/c/cit101e +/usr/share/ncurses4/terminfo/c/cit101e-132 +/usr/share/ncurses4/terminfo/c/cit101e-n +/usr/share/ncurses4/terminfo/c/cit101e-n132 +/usr/share/ncurses4/terminfo/c/cit101e-rv +/usr/share/ncurses4/terminfo/c/cit500 +/usr/share/ncurses4/terminfo/c/cit80 +/usr/share/ncurses4/terminfo/c/citc +/usr/share/ncurses4/terminfo/c/citoh +/usr/share/ncurses4/terminfo/c/citoh-6lpi +/usr/share/ncurses4/terminfo/c/citoh-8lpi +/usr/share/ncurses4/terminfo/c/citoh-comp +/usr/share/ncurses4/terminfo/c/citoh-elite +/usr/share/ncurses4/terminfo/c/citoh-pica +/usr/share/ncurses4/terminfo/c/citoh-prop +/usr/share/ncurses4/terminfo/c/citoh-ps +/usr/share/ncurses4/terminfo/c/coco3 +/usr/share/ncurses4/terminfo/c/coherent +/usr/share/ncurses4/terminfo/c/color_xterm +/usr/share/ncurses4/terminfo/c/colorscan +/usr/share/ncurses4/terminfo/c/commodore +/usr/share/ncurses4/terminfo/c/concept +/usr/share/ncurses4/terminfo/c/concept-avt +/usr/share/ncurses4/terminfo/c/concept100 +/usr/share/ncurses4/terminfo/c/concept100-rv +/usr/share/ncurses4/terminfo/c/concept108 +/usr/share/ncurses4/terminfo/c/concept108-4p +/usr/share/ncurses4/terminfo/c/concept108-8p +/usr/share/ncurses4/terminfo/c/concept108-w-8 +/usr/share/ncurses4/terminfo/c/concept108-w8p +/usr/share/ncurses4/terminfo/c/concept108rv4p +/usr/share/ncurses4/terminfo/c/cons25 +/usr/share/ncurses4/terminfo/c/cons25-iso-m +/usr/share/ncurses4/terminfo/c/cons25-iso8859 +/usr/share/ncurses4/terminfo/c/cons25-koi8-r +/usr/share/ncurses4/terminfo/c/cons25-koi8r-m +/usr/share/ncurses4/terminfo/c/cons25-m +/usr/share/ncurses4/terminfo/c/cons25l1 +/usr/share/ncurses4/terminfo/c/cons25l1-m +/usr/share/ncurses4/terminfo/c/cons25r +/usr/share/ncurses4/terminfo/c/cons25r-m +/usr/share/ncurses4/terminfo/c/cons25w +/usr/share/ncurses4/terminfo/c/cons30 +/usr/share/ncurses4/terminfo/c/cons30-m +/usr/share/ncurses4/terminfo/c/cons43 +/usr/share/ncurses4/terminfo/c/cons43-m +/usr/share/ncurses4/terminfo/c/cons50 +/usr/share/ncurses4/terminfo/c/cons50-iso-m +/usr/share/ncurses4/terminfo/c/cons50-iso8859 +/usr/share/ncurses4/terminfo/c/cons50-koi8r +/usr/share/ncurses4/terminfo/c/cons50-koi8r-m +/usr/share/ncurses4/terminfo/c/cons50-m +/usr/share/ncurses4/terminfo/c/cons50l1 +/usr/share/ncurses4/terminfo/c/cons50l1-m +/usr/share/ncurses4/terminfo/c/cons50r +/usr/share/ncurses4/terminfo/c/cons50r-m +/usr/share/ncurses4/terminfo/c/cons60 +/usr/share/ncurses4/terminfo/c/cons60-iso +/usr/share/ncurses4/terminfo/c/cons60-iso-m +/usr/share/ncurses4/terminfo/c/cons60-koi8r +/usr/share/ncurses4/terminfo/c/cons60-koi8r-m +/usr/share/ncurses4/terminfo/c/cons60-m +/usr/share/ncurses4/terminfo/c/cons60l1 +/usr/share/ncurses4/terminfo/c/cons60l1-m +/usr/share/ncurses4/terminfo/c/cons60r +/usr/share/ncurses4/terminfo/c/cons60r-m +/usr/share/ncurses4/terminfo/c/contel300 +/usr/share/ncurses4/terminfo/c/contel301 +/usr/share/ncurses4/terminfo/c/contel320 +/usr/share/ncurses4/terminfo/c/contel321 +/usr/share/ncurses4/terminfo/c/cops +/usr/share/ncurses4/terminfo/c/cops-10 +/usr/share/ncurses4/terminfo/c/cops10 +/usr/share/ncurses4/terminfo/c/cs10 +/usr/share/ncurses4/terminfo/c/cs10-w +/usr/share/ncurses4/terminfo/c/ct82 +/usr/share/ncurses4/terminfo/c/ct8500 +/usr/share/ncurses4/terminfo/c/ctrm +/usr/share/ncurses4/terminfo/c/cx +/usr/share/ncurses4/terminfo/c/cx100 +/usr/share/ncurses4/terminfo/c/cyb110 +/usr/share/ncurses4/terminfo/c/cyb83 +/usr/share/ncurses4/terminfo/d +/usr/share/ncurses4/terminfo/d/d132 +/usr/share/ncurses4/terminfo/d/d80 +/usr/share/ncurses4/terminfo/d/d800 +/usr/share/ncurses4/terminfo/d/datagraphix +/usr/share/ncurses4/terminfo/d/datamedia2500 +/usr/share/ncurses4/terminfo/d/datapoint +/usr/share/ncurses4/terminfo/d/dataspeed40 +/usr/share/ncurses4/terminfo/d/dd5000 +/usr/share/ncurses4/terminfo/d/ddr +/usr/share/ncurses4/terminfo/d/ddr3180 +/usr/share/ncurses4/terminfo/d/dec-vt100 +/usr/share/ncurses4/terminfo/d/dec-vt220 +/usr/share/ncurses4/terminfo/d/dec-vt330 +/usr/share/ncurses4/terminfo/d/dec-vt340 +/usr/share/ncurses4/terminfo/d/dec-vt400 +/usr/share/ncurses4/terminfo/d/decpro +/usr/share/ncurses4/terminfo/d/decwriter +/usr/share/ncurses4/terminfo/d/delta +/usr/share/ncurses4/terminfo/d/dg-ansi +/usr/share/ncurses4/terminfo/d/dg100 +/usr/share/ncurses4/terminfo/d/dg200 +/usr/share/ncurses4/terminfo/d/dg210 +/usr/share/ncurses4/terminfo/d/dg211 +/usr/share/ncurses4/terminfo/d/dg450 +/usr/share/ncurses4/terminfo/d/dg460-ansi +/usr/share/ncurses4/terminfo/d/dg6053 +/usr/share/ncurses4/terminfo/d/dg6134 +/usr/share/ncurses4/terminfo/d/diablo +/usr/share/ncurses4/terminfo/d/diablo-lm +/usr/share/ncurses4/terminfo/d/diablo1620 +/usr/share/ncurses4/terminfo/d/diablo1620-m8 +/usr/share/ncurses4/terminfo/d/diablo1640 +/usr/share/ncurses4/terminfo/d/diablo1640-lm +/usr/share/ncurses4/terminfo/d/diablo1640-m8 +/usr/share/ncurses4/terminfo/d/diablo1720 +/usr/share/ncurses4/terminfo/d/diablo1730 +/usr/share/ncurses4/terminfo/d/diablo1740 +/usr/share/ncurses4/terminfo/d/diablo1740-lm +/usr/share/ncurses4/terminfo/d/diablo450 +/usr/share/ncurses4/terminfo/d/diablo630 +/usr/share/ncurses4/terminfo/d/dialogue +/usr/share/ncurses4/terminfo/d/dialogue80 +/usr/share/ncurses4/terminfo/d/digilog +/usr/share/ncurses4/terminfo/d/dku7003 +/usr/share/ncurses4/terminfo/d/dku7003-dumb +/usr/share/ncurses4/terminfo/d/dm1520 +/usr/share/ncurses4/terminfo/d/dm1521 +/usr/share/ncurses4/terminfo/d/dm2500 +/usr/share/ncurses4/terminfo/d/dm3025 +/usr/share/ncurses4/terminfo/d/dm3045 +/usr/share/ncurses4/terminfo/d/dm80 +/usr/share/ncurses4/terminfo/d/dm80w +/usr/share/ncurses4/terminfo/d/dmchat +/usr/share/ncurses4/terminfo/d/dmd +/usr/share/ncurses4/terminfo/d/dmd-24 +/usr/share/ncurses4/terminfo/d/dmd-34 +/usr/share/ncurses4/terminfo/d/dmd1 +/usr/share/ncurses4/terminfo/d/dmdt80 +/usr/share/ncurses4/terminfo/d/dmdt80w +/usr/share/ncurses4/terminfo/d/dmterm +/usr/share/ncurses4/terminfo/d/dp3360 +/usr/share/ncurses4/terminfo/d/dp8242 +/usr/share/ncurses4/terminfo/d/ds40 +/usr/share/ncurses4/terminfo/d/ds40-2 +/usr/share/ncurses4/terminfo/d/dt-100 +/usr/share/ncurses4/terminfo/d/dt-100w +/usr/share/ncurses4/terminfo/d/dt100 +/usr/share/ncurses4/terminfo/d/dt100w +/usr/share/ncurses4/terminfo/d/dt110 +/usr/share/ncurses4/terminfo/d/dt80 +/usr/share/ncurses4/terminfo/d/dt80-sas +/usr/share/ncurses4/terminfo/d/dt80w +/usr/share/ncurses4/terminfo/d/dtc300s +/usr/share/ncurses4/terminfo/d/dtc382 +/usr/share/ncurses4/terminfo/d/dtterm +/usr/share/ncurses4/terminfo/d/dumb +/usr/share/ncurses4/terminfo/d/dw +/usr/share/ncurses4/terminfo/d/dw1 +/usr/share/ncurses4/terminfo/d/dw2 +/usr/share/ncurses4/terminfo/d/dw3 +/usr/share/ncurses4/terminfo/d/dw4 +/usr/share/ncurses4/terminfo/d/dwk +/usr/share/ncurses4/terminfo/d/dwk-vt +/usr/share/ncurses4/terminfo/e +/usr/share/ncurses4/terminfo/e/ecma+color +/usr/share/ncurses4/terminfo/e/ecma+sgr +/usr/share/ncurses4/terminfo/e/emots +/usr/share/ncurses4/terminfo/e/emu +/usr/share/ncurses4/terminfo/e/env230 +/usr/share/ncurses4/terminfo/e/envision230 +/usr/share/ncurses4/terminfo/e/ep40 +/usr/share/ncurses4/terminfo/e/ep4000 +/usr/share/ncurses4/terminfo/e/ep4080 +/usr/share/ncurses4/terminfo/e/ep48 +/usr/share/ncurses4/terminfo/e/ergo4000 +/usr/share/ncurses4/terminfo/e/esprit +/usr/share/ncurses4/terminfo/e/esprit-am +/usr/share/ncurses4/terminfo/e/eterm +/usr/share/ncurses4/terminfo/e/ex155 +/usr/share/ncurses4/terminfo/e/excel62 +/usr/share/ncurses4/terminfo/e/excel62-rv +/usr/share/ncurses4/terminfo/e/excel62-w +/usr/share/ncurses4/terminfo/e/excel64 +/usr/share/ncurses4/terminfo/e/excel64-rv +/usr/share/ncurses4/terminfo/e/excel64-w +/usr/share/ncurses4/terminfo/e/exec80 +/usr/share/ncurses4/terminfo/f +/usr/share/ncurses4/terminfo/f/f100 +/usr/share/ncurses4/terminfo/f/f100-rv +/usr/share/ncurses4/terminfo/f/f110 +/usr/share/ncurses4/terminfo/f/f110-14 +/usr/share/ncurses4/terminfo/f/f110-14w +/usr/share/ncurses4/terminfo/f/f110-w +/usr/share/ncurses4/terminfo/f/f1720 +/usr/share/ncurses4/terminfo/f/f1720a +/usr/share/ncurses4/terminfo/f/f200 +/usr/share/ncurses4/terminfo/f/f200-w +/usr/share/ncurses4/terminfo/f/f200vi +/usr/share/ncurses4/terminfo/f/f200vi-w +/usr/share/ncurses4/terminfo/f/falco +/usr/share/ncurses4/terminfo/f/falco-p +/usr/share/ncurses4/terminfo/f/fenix +/usr/share/ncurses4/terminfo/f/fenixw +/usr/share/ncurses4/terminfo/f/fixterm +/usr/share/ncurses4/terminfo/f/fortune +/usr/share/ncurses4/terminfo/f/fos +/usr/share/ncurses4/terminfo/f/fox +/usr/share/ncurses4/terminfo/f/freedom +/usr/share/ncurses4/terminfo/f/freedom-rv +/usr/share/ncurses4/terminfo/f/freedom100 +/usr/share/ncurses4/terminfo/f/freedom110 +/usr/share/ncurses4/terminfo/f/freedom200 +/usr/share/ncurses4/terminfo/g +/usr/share/ncurses4/terminfo/g/gator +/usr/share/ncurses4/terminfo/g/gator-52 +/usr/share/ncurses4/terminfo/g/gator-52t +/usr/share/ncurses4/terminfo/g/gator-t +/usr/share/ncurses4/terminfo/g/gigi +/usr/share/ncurses4/terminfo/g/glasstty +/usr/share/ncurses4/terminfo/g/go-225 +/usr/share/ncurses4/terminfo/g/go140 +/usr/share/ncurses4/terminfo/g/go140w +/usr/share/ncurses4/terminfo/g/go225 +/usr/share/ncurses4/terminfo/g/graphos +/usr/share/ncurses4/terminfo/g/graphos-30 +/usr/share/ncurses4/terminfo/g/gs5430 +/usr/share/ncurses4/terminfo/g/gs5430-22 +/usr/share/ncurses4/terminfo/g/gs5430-24 +/usr/share/ncurses4/terminfo/g/gs6300 +/usr/share/ncurses4/terminfo/g/gsi +/usr/share/ncurses4/terminfo/g/gt100 +/usr/share/ncurses4/terminfo/g/gt100a +/usr/share/ncurses4/terminfo/g/gt40 +/usr/share/ncurses4/terminfo/g/gt42 +/usr/share/ncurses4/terminfo/g/guru +/usr/share/ncurses4/terminfo/g/guru+rv +/usr/share/ncurses4/terminfo/g/guru+s +/usr/share/ncurses4/terminfo/g/guru+unk +/usr/share/ncurses4/terminfo/g/guru-24 +/usr/share/ncurses4/terminfo/g/guru-33 +/usr/share/ncurses4/terminfo/g/guru-33-rv +/usr/share/ncurses4/terminfo/g/guru-33-s +/usr/share/ncurses4/terminfo/g/guru-44 +/usr/share/ncurses4/terminfo/g/guru-44-s +/usr/share/ncurses4/terminfo/g/guru-76 +/usr/share/ncurses4/terminfo/g/guru-76-lp +/usr/share/ncurses4/terminfo/g/guru-76-s +/usr/share/ncurses4/terminfo/g/guru-76-w +/usr/share/ncurses4/terminfo/g/guru-76-w-s +/usr/share/ncurses4/terminfo/g/guru-76-wm +/usr/share/ncurses4/terminfo/g/guru-lp +/usr/share/ncurses4/terminfo/g/guru-nctxt +/usr/share/ncurses4/terminfo/g/guru-rv +/usr/share/ncurses4/terminfo/g/guru-s +/usr/share/ncurses4/terminfo/h +/usr/share/ncurses4/terminfo/h/h-100 +/usr/share/ncurses4/terminfo/h/h-100bw +/usr/share/ncurses4/terminfo/h/h100 +/usr/share/ncurses4/terminfo/h/h100bw +/usr/share/ncurses4/terminfo/h/h19 +/usr/share/ncurses4/terminfo/h/h19-a +/usr/share/ncurses4/terminfo/h/h19-b +/usr/share/ncurses4/terminfo/h/h19-bs +/usr/share/ncurses4/terminfo/h/h19-g +/usr/share/ncurses4/terminfo/h/h19-smul +/usr/share/ncurses4/terminfo/h/h19-u +/usr/share/ncurses4/terminfo/h/h19-us +/usr/share/ncurses4/terminfo/h/h19a +/usr/share/ncurses4/terminfo/h/h19g +/usr/share/ncurses4/terminfo/h/h19k +/usr/share/ncurses4/terminfo/h/h19kermit +/usr/share/ncurses4/terminfo/h/h19us +/usr/share/ncurses4/terminfo/h/h29a-kc-bc +/usr/share/ncurses4/terminfo/h/h29a-kc-uc +/usr/share/ncurses4/terminfo/h/h29a-nkc-bc +/usr/share/ncurses4/terminfo/h/h29a-nkc-uc +/usr/share/ncurses4/terminfo/h/h80 +/usr/share/ncurses4/terminfo/h/ha8675 +/usr/share/ncurses4/terminfo/h/ha8686 +/usr/share/ncurses4/terminfo/h/hazel +/usr/share/ncurses4/terminfo/h/hds200 +/usr/share/ncurses4/terminfo/h/he80 +/usr/share/ncurses4/terminfo/h/heath +/usr/share/ncurses4/terminfo/h/heath-19 +/usr/share/ncurses4/terminfo/h/heath-ansi +/usr/share/ncurses4/terminfo/h/heathkit +/usr/share/ncurses4/terminfo/h/heathkit-a +/usr/share/ncurses4/terminfo/h/hft +/usr/share/ncurses4/terminfo/h/hft-c +/usr/share/ncurses4/terminfo/h/hirez100 +/usr/share/ncurses4/terminfo/h/hirez100-w +/usr/share/ncurses4/terminfo/h/hmod1 +/usr/share/ncurses4/terminfo/h/hp +/usr/share/ncurses4/terminfo/h/hp+arrows +/usr/share/ncurses4/terminfo/h/hp+color +/usr/share/ncurses4/terminfo/h/hp+labels +/usr/share/ncurses4/terminfo/h/hp+pfk+arrows +/usr/share/ncurses4/terminfo/h/hp+pfk+cr +/usr/share/ncurses4/terminfo/h/hp+pfk-cr +/usr/share/ncurses4/terminfo/h/hp+printer +/usr/share/ncurses4/terminfo/h/hp110 +/usr/share/ncurses4/terminfo/h/hp150 +/usr/share/ncurses4/terminfo/h/hp2 +/usr/share/ncurses4/terminfo/h/hp236 +/usr/share/ncurses4/terminfo/h/hp2382 +/usr/share/ncurses4/terminfo/h/hp2382a +/usr/share/ncurses4/terminfo/h/hp2392 +/usr/share/ncurses4/terminfo/h/hp2397 +/usr/share/ncurses4/terminfo/h/hp2397a +/usr/share/ncurses4/terminfo/h/hp2621 +/usr/share/ncurses4/terminfo/h/hp2621-48 +/usr/share/ncurses4/terminfo/h/hp2621-a +/usr/share/ncurses4/terminfo/h/hp2621-ba +/usr/share/ncurses4/terminfo/h/hp2621-fl +/usr/share/ncurses4/terminfo/h/hp2621-k45 +/usr/share/ncurses4/terminfo/h/hp2621-nl +/usr/share/ncurses4/terminfo/h/hp2621-nt +/usr/share/ncurses4/terminfo/h/hp2621-wl +/usr/share/ncurses4/terminfo/h/hp2621A +/usr/share/ncurses4/terminfo/h/hp2621a +/usr/share/ncurses4/terminfo/h/hp2621a-a +/usr/share/ncurses4/terminfo/h/hp2621b +/usr/share/ncurses4/terminfo/h/hp2621b-kx +/usr/share/ncurses4/terminfo/h/hp2621b-kx-p +/usr/share/ncurses4/terminfo/h/hp2621b-p +/usr/share/ncurses4/terminfo/h/hp2621k45 +/usr/share/ncurses4/terminfo/h/hp2621p +/usr/share/ncurses4/terminfo/h/hp2621p-a +/usr/share/ncurses4/terminfo/h/hp2622 +/usr/share/ncurses4/terminfo/h/hp2622a +/usr/share/ncurses4/terminfo/h/hp2623 +/usr/share/ncurses4/terminfo/h/hp2623a +/usr/share/ncurses4/terminfo/h/hp2624 +/usr/share/ncurses4/terminfo/h/hp2624-10p +/usr/share/ncurses4/terminfo/h/hp2624a +/usr/share/ncurses4/terminfo/h/hp2624a-10p +/usr/share/ncurses4/terminfo/h/hp2624b +/usr/share/ncurses4/terminfo/h/hp2624b-10p +/usr/share/ncurses4/terminfo/h/hp2624b-10p-p +/usr/share/ncurses4/terminfo/h/hp2624b-4p +/usr/share/ncurses4/terminfo/h/hp2624b-4p-p +/usr/share/ncurses4/terminfo/h/hp2624b-p +/usr/share/ncurses4/terminfo/h/hp2626 +/usr/share/ncurses4/terminfo/h/hp2626-12 +/usr/share/ncurses4/terminfo/h/hp2626-12-s +/usr/share/ncurses4/terminfo/h/hp2626-12x40 +/usr/share/ncurses4/terminfo/h/hp2626-ns +/usr/share/ncurses4/terminfo/h/hp2626-s +/usr/share/ncurses4/terminfo/h/hp2626-x40 +/usr/share/ncurses4/terminfo/h/hp2626a +/usr/share/ncurses4/terminfo/h/hp2626p +/usr/share/ncurses4/terminfo/h/hp2627a +/usr/share/ncurses4/terminfo/h/hp2627a-rev +/usr/share/ncurses4/terminfo/h/hp2627c +/usr/share/ncurses4/terminfo/h/hp262x +/usr/share/ncurses4/terminfo/h/hp2640a +/usr/share/ncurses4/terminfo/h/hp2640b +/usr/share/ncurses4/terminfo/h/hp2641a +/usr/share/ncurses4/terminfo/h/hp2644a +/usr/share/ncurses4/terminfo/h/hp2645 +/usr/share/ncurses4/terminfo/h/hp2645a +/usr/share/ncurses4/terminfo/h/hp2647a +/usr/share/ncurses4/terminfo/h/hp2648 +/usr/share/ncurses4/terminfo/h/hp2648a +/usr/share/ncurses4/terminfo/h/hp300h +/usr/share/ncurses4/terminfo/h/hp45 +/usr/share/ncurses4/terminfo/h/hp700 +/usr/share/ncurses4/terminfo/h/hp700-wy +/usr/share/ncurses4/terminfo/h/hp70092 +/usr/share/ncurses4/terminfo/h/hp70092A +/usr/share/ncurses4/terminfo/h/hp70092a +/usr/share/ncurses4/terminfo/h/hp9837 +/usr/share/ncurses4/terminfo/h/hp9845 +/usr/share/ncurses4/terminfo/h/hp98550 +/usr/share/ncurses4/terminfo/h/hp98550a +/usr/share/ncurses4/terminfo/h/hp98720 +/usr/share/ncurses4/terminfo/h/hp98721 +/usr/share/ncurses4/terminfo/h/hpansi +/usr/share/ncurses4/terminfo/h/hpex +/usr/share/ncurses4/terminfo/h/hpex2 +/usr/share/ncurses4/terminfo/h/hpgeneric +/usr/share/ncurses4/terminfo/h/hpsub +/usr/share/ncurses4/terminfo/h/hpterm +/usr/share/ncurses4/terminfo/h/htx11 +/usr/share/ncurses4/terminfo/h/hz1000 +/usr/share/ncurses4/terminfo/h/hz1420 +/usr/share/ncurses4/terminfo/h/hz1500 +/usr/share/ncurses4/terminfo/h/hz1510 +/usr/share/ncurses4/terminfo/h/hz1520 +/usr/share/ncurses4/terminfo/h/hz1520-noesc +/usr/share/ncurses4/terminfo/h/hz1552 +/usr/share/ncurses4/terminfo/h/hz1552-rv +/usr/share/ncurses4/terminfo/h/hz2000 +/usr/share/ncurses4/terminfo/i +/usr/share/ncurses4/terminfo/i/i100 +/usr/share/ncurses4/terminfo/i/i3101 +/usr/share/ncurses4/terminfo/i/i3151 +/usr/share/ncurses4/terminfo/i/i3164 +/usr/share/ncurses4/terminfo/i/i400 +/usr/share/ncurses4/terminfo/i/ibcs2 +/usr/share/ncurses4/terminfo/i/ibm-apl +/usr/share/ncurses4/terminfo/i/ibm-pc +/usr/share/ncurses4/terminfo/i/ibm-system1 +/usr/share/ncurses4/terminfo/i/ibm3101 +/usr/share/ncurses4/terminfo/i/ibm3151 +/usr/share/ncurses4/terminfo/i/ibm3161 +/usr/share/ncurses4/terminfo/i/ibm3163 +/usr/share/ncurses4/terminfo/i/ibm3164 +/usr/share/ncurses4/terminfo/i/ibm327x +/usr/share/ncurses4/terminfo/i/ibm5051 +/usr/share/ncurses4/terminfo/i/ibm5081 +/usr/share/ncurses4/terminfo/i/ibm5081-c +/usr/share/ncurses4/terminfo/i/ibm5151 +/usr/share/ncurses4/terminfo/i/ibm5154 +/usr/share/ncurses4/terminfo/i/ibm5154-c +/usr/share/ncurses4/terminfo/i/ibm6153 +/usr/share/ncurses4/terminfo/i/ibm6154 +/usr/share/ncurses4/terminfo/i/ibm6154-c +/usr/share/ncurses4/terminfo/i/ibm6155 +/usr/share/ncurses4/terminfo/i/ibm8512 +/usr/share/ncurses4/terminfo/i/ibm8513 +/usr/share/ncurses4/terminfo/i/ibm8514 +/usr/share/ncurses4/terminfo/i/ibm8514-c +/usr/share/ncurses4/terminfo/i/ibmaed +/usr/share/ncurses4/terminfo/i/ibmapa16 +/usr/share/ncurses4/terminfo/i/ibmapa8 +/usr/share/ncurses4/terminfo/i/ibmapa8c +/usr/share/ncurses4/terminfo/i/ibmapa8c-c +/usr/share/ncurses4/terminfo/i/ibmega +/usr/share/ncurses4/terminfo/i/ibmega-c +/usr/share/ncurses4/terminfo/i/ibmmono +/usr/share/ncurses4/terminfo/i/ibmmpel +/usr/share/ncurses4/terminfo/i/ibmmpel-c +/usr/share/ncurses4/terminfo/i/ibmpc +/usr/share/ncurses4/terminfo/i/ibmpc3 +/usr/share/ncurses4/terminfo/i/ibmpc3r +/usr/share/ncurses4/terminfo/i/ibmpc3r-mono +/usr/share/ncurses4/terminfo/i/ibmpcx +/usr/share/ncurses4/terminfo/i/ibmvga +/usr/share/ncurses4/terminfo/i/ibmvga-c +/usr/share/ncurses4/terminfo/i/ibmx +/usr/share/ncurses4/terminfo/i/ifmr +/usr/share/ncurses4/terminfo/i/ims-ansi +/usr/share/ncurses4/terminfo/i/ims950 +/usr/share/ncurses4/terminfo/i/ims950-b +/usr/share/ncurses4/terminfo/i/ims950-rv +/usr/share/ncurses4/terminfo/i/infoton +/usr/share/ncurses4/terminfo/i/intertec +/usr/share/ncurses4/terminfo/i/intertube +/usr/share/ncurses4/terminfo/i/intertube2 +/usr/share/ncurses4/terminfo/i/intext +/usr/share/ncurses4/terminfo/i/intext2 +/usr/share/ncurses4/terminfo/i/intextii +/usr/share/ncurses4/terminfo/i/ips +/usr/share/ncurses4/terminfo/i/ipsi +/usr/share/ncurses4/terminfo/i/iq120 +/usr/share/ncurses4/terminfo/i/iq140 +/usr/share/ncurses4/terminfo/i/iris-ansi +/usr/share/ncurses4/terminfo/i/iris-ansi-ap +/usr/share/ncurses4/terminfo/i/iris-color +/usr/share/ncurses4/terminfo/i/iris40 +/usr/share/ncurses4/terminfo/j +/usr/share/ncurses4/terminfo/j/jaixterm-m +/usr/share/ncurses4/terminfo/j/jerq +/usr/share/ncurses4/terminfo/k +/usr/share/ncurses4/terminfo/k/k45 +/usr/share/ncurses4/terminfo/k/kaypro +/usr/share/ncurses4/terminfo/k/kaypro2 +/usr/share/ncurses4/terminfo/k/kermit +/usr/share/ncurses4/terminfo/k/kermit-am +/usr/share/ncurses4/terminfo/k/klone+acs +/usr/share/ncurses4/terminfo/k/klone+color +/usr/share/ncurses4/terminfo/k/klone+koi8acs +/usr/share/ncurses4/terminfo/k/klone+sgr +/usr/share/ncurses4/terminfo/k/klone+sgr-dumb +/usr/share/ncurses4/terminfo/k/kt7 +/usr/share/ncurses4/terminfo/k/kt7ix +/usr/share/ncurses4/terminfo/k/kterm +/usr/share/ncurses4/terminfo/k/ktm +/usr/share/ncurses4/terminfo/l +/usr/share/ncurses4/terminfo/l/la120 +/usr/share/ncurses4/terminfo/l/layer +/usr/share/ncurses4/terminfo/l/linux +/usr/share/ncurses4/terminfo/l/linux-c +/usr/share/ncurses4/terminfo/l/linux-c-nc +/usr/share/ncurses4/terminfo/l/linux-koi8 +/usr/share/ncurses4/terminfo/l/linux-koi8r +/usr/share/ncurses4/terminfo/l/linux-m +/usr/share/ncurses4/terminfo/l/linux-nic +/usr/share/ncurses4/terminfo/l/lisa +/usr/share/ncurses4/terminfo/l/lisaterm +/usr/share/ncurses4/terminfo/l/lisaterm-w +/usr/share/ncurses4/terminfo/l/liswb +/usr/share/ncurses4/terminfo/l/ln03 +/usr/share/ncurses4/terminfo/l/ln03-w +/usr/share/ncurses4/terminfo/l/lpr +/usr/share/ncurses4/terminfo/l/luna +/usr/share/ncurses4/terminfo/l/luna68k +/usr/share/ncurses4/terminfo/m +/usr/share/ncurses4/terminfo/m/m2-nam +/usr/share/ncurses4/terminfo/m/mac +/usr/share/ncurses4/terminfo/m/mac-w +/usr/share/ncurses4/terminfo/m/macintosh +/usr/share/ncurses4/terminfo/m/macterminal-w +/usr/share/ncurses4/terminfo/m/mai +/usr/share/ncurses4/terminfo/m/masscomp +/usr/share/ncurses4/terminfo/m/masscomp1 +/usr/share/ncurses4/terminfo/m/masscomp2 +/usr/share/ncurses4/terminfo/m/mdl110 +/usr/share/ncurses4/terminfo/m/megatek +/usr/share/ncurses4/terminfo/m/memhp +/usr/share/ncurses4/terminfo/m/mgr +/usr/share/ncurses4/terminfo/m/mgr-linux +/usr/share/ncurses4/terminfo/m/mgr-sun +/usr/share/ncurses4/terminfo/m/microb +/usr/share/ncurses4/terminfo/m/microbee +/usr/share/ncurses4/terminfo/m/microterm +/usr/share/ncurses4/terminfo/m/microterm5 +/usr/share/ncurses4/terminfo/m/mime +/usr/share/ncurses4/terminfo/m/mime-3ax +/usr/share/ncurses4/terminfo/m/mime-fb +/usr/share/ncurses4/terminfo/m/mime-hb +/usr/share/ncurses4/terminfo/m/mime1 +/usr/share/ncurses4/terminfo/m/mime2 +/usr/share/ncurses4/terminfo/m/mime2a +/usr/share/ncurses4/terminfo/m/mime2a-s +/usr/share/ncurses4/terminfo/m/mime2a-v +/usr/share/ncurses4/terminfo/m/mime314 +/usr/share/ncurses4/terminfo/m/mime340 +/usr/share/ncurses4/terminfo/m/mime3a +/usr/share/ncurses4/terminfo/m/mime3ax +/usr/share/ncurses4/terminfo/m/mimei +/usr/share/ncurses4/terminfo/m/mimeii +/usr/share/ncurses4/terminfo/m/minitel +/usr/share/ncurses4/terminfo/m/minitel-2 +/usr/share/ncurses4/terminfo/m/minitel-2-nam +/usr/share/ncurses4/terminfo/m/minix +/usr/share/ncurses4/terminfo/m/minix-old +/usr/share/ncurses4/terminfo/m/minix-old-am +/usr/share/ncurses4/terminfo/m/mm314 +/usr/share/ncurses4/terminfo/m/mm340 +/usr/share/ncurses4/terminfo/m/mod +/usr/share/ncurses4/terminfo/m/mod24 +/usr/share/ncurses4/terminfo/m/modgraph +/usr/share/ncurses4/terminfo/m/modgraph2 +/usr/share/ncurses4/terminfo/m/modgraph48 +/usr/share/ncurses4/terminfo/m/mono-emx +/usr/share/ncurses4/terminfo/m/msk227 +/usr/share/ncurses4/terminfo/m/msk22714 +/usr/share/ncurses4/terminfo/m/msk227am +/usr/share/ncurses4/terminfo/m/mskermit227 +/usr/share/ncurses4/terminfo/m/mskermit22714 +/usr/share/ncurses4/terminfo/m/mskermit227am +/usr/share/ncurses4/terminfo/m/mt-70 +/usr/share/ncurses4/terminfo/m/mt4520-rv +/usr/share/ncurses4/terminfo/m/mt70 +/usr/share/ncurses4/terminfo/n +/usr/share/ncurses4/terminfo/n/nansi.sys +/usr/share/ncurses4/terminfo/n/nansi.sysk +/usr/share/ncurses4/terminfo/n/nansisys +/usr/share/ncurses4/terminfo/n/nansisysk +/usr/share/ncurses4/terminfo/n/ncr7900 +/usr/share/ncurses4/terminfo/n/ncr7900i +/usr/share/ncurses4/terminfo/n/ncr7900iv +/usr/share/ncurses4/terminfo/n/ncr7901 +/usr/share/ncurses4/terminfo/n/nec +/usr/share/ncurses4/terminfo/n/nec5520 +/usr/share/ncurses4/terminfo/n/newhp +/usr/share/ncurses4/terminfo/n/newhpkeyboard +/usr/share/ncurses4/terminfo/n/news +/usr/share/ncurses4/terminfo/n/news-29 +/usr/share/ncurses4/terminfo/n/news-29-euc +/usr/share/ncurses4/terminfo/n/news-29-sjis +/usr/share/ncurses4/terminfo/n/news-33 +/usr/share/ncurses4/terminfo/n/news-33-euc +/usr/share/ncurses4/terminfo/n/news-33-sjis +/usr/share/ncurses4/terminfo/n/news-42 +/usr/share/ncurses4/terminfo/n/news-42-euc +/usr/share/ncurses4/terminfo/n/news-42-sjis +/usr/share/ncurses4/terminfo/n/news-a +/usr/share/ncurses4/terminfo/n/news-o +/usr/share/ncurses4/terminfo/n/news-old-unk +/usr/share/ncurses4/terminfo/n/news-unk +/usr/share/ncurses4/terminfo/n/news28 +/usr/share/ncurses4/terminfo/n/news28-a +/usr/share/ncurses4/terminfo/n/news29 +/usr/share/ncurses4/terminfo/n/news31 +/usr/share/ncurses4/terminfo/n/news31-a +/usr/share/ncurses4/terminfo/n/news31-o +/usr/share/ncurses4/terminfo/n/news33 +/usr/share/ncurses4/terminfo/n/news40 +/usr/share/ncurses4/terminfo/n/news40-a +/usr/share/ncurses4/terminfo/n/news40-o +/usr/share/ncurses4/terminfo/n/news42 +/usr/share/ncurses4/terminfo/n/newscbm +/usr/share/ncurses4/terminfo/n/newscbm-a +/usr/share/ncurses4/terminfo/n/newscbm-o +/usr/share/ncurses4/terminfo/n/newscbm33 +/usr/share/ncurses4/terminfo/n/next +/usr/share/ncurses4/terminfo/n/nextshell +/usr/share/ncurses4/terminfo/n/northstar +/usr/share/ncurses4/terminfo/n/nwe501 +/usr/share/ncurses4/terminfo/n/nwe501-a +/usr/share/ncurses4/terminfo/n/nwe501-o +/usr/share/ncurses4/terminfo/n/nwp-511 +/usr/share/ncurses4/terminfo/n/nwp-517 +/usr/share/ncurses4/terminfo/n/nwp-517-w +/usr/share/ncurses4/terminfo/n/nwp251-a +/usr/share/ncurses4/terminfo/n/nwp251-o +/usr/share/ncurses4/terminfo/n/nwp511 +/usr/share/ncurses4/terminfo/n/nwp512 +/usr/share/ncurses4/terminfo/n/nwp512-a +/usr/share/ncurses4/terminfo/n/nwp512-o +/usr/share/ncurses4/terminfo/n/nwp513 +/usr/share/ncurses4/terminfo/n/nwp513-a +/usr/share/ncurses4/terminfo/n/nwp513-o +/usr/share/ncurses4/terminfo/n/nwp514 +/usr/share/ncurses4/terminfo/n/nwp514-a +/usr/share/ncurses4/terminfo/n/nwp514-o +/usr/share/ncurses4/terminfo/n/nwp517 +/usr/share/ncurses4/terminfo/n/nwp517-w +/usr/share/ncurses4/terminfo/n/nwp518 +/usr/share/ncurses4/terminfo/n/nwp518-a +/usr/share/ncurses4/terminfo/n/nwp518-o +/usr/share/ncurses4/terminfo/o +/usr/share/ncurses4/terminfo/o/o31 +/usr/share/ncurses4/terminfo/o/o4112-nd +/usr/share/ncurses4/terminfo/o/o85h +/usr/share/ncurses4/terminfo/o/oabm85h +/usr/share/ncurses4/terminfo/o/oblit +/usr/share/ncurses4/terminfo/o/oc100 +/usr/share/ncurses4/terminfo/o/oconcept +/usr/share/ncurses4/terminfo/o/ojerq +/usr/share/ncurses4/terminfo/o/oldibmpc3 +/usr/share/ncurses4/terminfo/o/oldpc3 +/usr/share/ncurses4/terminfo/o/oldsun +/usr/share/ncurses4/terminfo/o/omron +/usr/share/ncurses4/terminfo/o/opus3n1+ +/usr/share/ncurses4/terminfo/o/origibmpc3 +/usr/share/ncurses4/terminfo/o/origpc3 +/usr/share/ncurses4/terminfo/o/os9LII +/usr/share/ncurses4/terminfo/o/osborne +/usr/share/ncurses4/terminfo/o/osborne-w +/usr/share/ncurses4/terminfo/o/osborne1 +/usr/share/ncurses4/terminfo/o/osborne1-w +/usr/share/ncurses4/terminfo/o/osexec +/usr/share/ncurses4/terminfo/o/otek4112 +/usr/share/ncurses4/terminfo/o/otek4113 +/usr/share/ncurses4/terminfo/o/otek4114 +/usr/share/ncurses4/terminfo/o/otek4115 +/usr/share/ncurses4/terminfo/o/owl +/usr/share/ncurses4/terminfo/p +/usr/share/ncurses4/terminfo/p/p12 +/usr/share/ncurses4/terminfo/p/p12-m +/usr/share/ncurses4/terminfo/p/p12-m-w +/usr/share/ncurses4/terminfo/p/p12-w +/usr/share/ncurses4/terminfo/p/p14 +/usr/share/ncurses4/terminfo/p/p14-m +/usr/share/ncurses4/terminfo/p/p14-m-w +/usr/share/ncurses4/terminfo/p/p14-w +/usr/share/ncurses4/terminfo/p/p19 +/usr/share/ncurses4/terminfo/p/p4 +/usr/share/ncurses4/terminfo/p/p5 +/usr/share/ncurses4/terminfo/p/p7 +/usr/share/ncurses4/terminfo/p/p8 +/usr/share/ncurses4/terminfo/p/p8-w +/usr/share/ncurses4/terminfo/p/p8gl +/usr/share/ncurses4/terminfo/p/p9 +/usr/share/ncurses4/terminfo/p/p9-8 +/usr/share/ncurses4/terminfo/p/p9-8-w +/usr/share/ncurses4/terminfo/p/p9-w +/usr/share/ncurses4/terminfo/p/pc-coherent +/usr/share/ncurses4/terminfo/p/pc-minix +/usr/share/ncurses4/terminfo/p/pc-venix +/usr/share/ncurses4/terminfo/p/pc3 +/usr/share/ncurses4/terminfo/p/pc3-bold +/usr/share/ncurses4/terminfo/p/pc3r +/usr/share/ncurses4/terminfo/p/pc3r-m +/usr/share/ncurses4/terminfo/p/pc6300plus +/usr/share/ncurses4/terminfo/p/pc7300 +/usr/share/ncurses4/terminfo/p/pcansi +/usr/share/ncurses4/terminfo/p/pcansi-25 +/usr/share/ncurses4/terminfo/p/pcansi-25-m +/usr/share/ncurses4/terminfo/p/pcansi-33 +/usr/share/ncurses4/terminfo/p/pcansi-33-m +/usr/share/ncurses4/terminfo/p/pcansi-43 +/usr/share/ncurses4/terminfo/p/pcansi-43-m +/usr/share/ncurses4/terminfo/p/pcansi-m +/usr/share/ncurses4/terminfo/p/pcansi-mono +/usr/share/ncurses4/terminfo/p/pcansi25 +/usr/share/ncurses4/terminfo/p/pcansi25m +/usr/share/ncurses4/terminfo/p/pcansi33 +/usr/share/ncurses4/terminfo/p/pcansi33m +/usr/share/ncurses4/terminfo/p/pcansi43 +/usr/share/ncurses4/terminfo/p/pccons +/usr/share/ncurses4/terminfo/p/pcconsole +/usr/share/ncurses4/terminfo/p/pcix +/usr/share/ncurses4/terminfo/p/pckermit +/usr/share/ncurses4/terminfo/p/pckermit12 +/usr/share/ncurses4/terminfo/p/pckermit120 +/usr/share/ncurses4/terminfo/p/pcplot +/usr/share/ncurses4/terminfo/p/pcvt25 +/usr/share/ncurses4/terminfo/p/pcvt25w +/usr/share/ncurses4/terminfo/p/pcvt28 +/usr/share/ncurses4/terminfo/p/pcvt28w +/usr/share/ncurses4/terminfo/p/pcvt35 +/usr/share/ncurses4/terminfo/p/pcvt35w +/usr/share/ncurses4/terminfo/p/pcvt40 +/usr/share/ncurses4/terminfo/p/pcvt40w +/usr/share/ncurses4/terminfo/p/pcvt43 +/usr/share/ncurses4/terminfo/p/pcvt43w +/usr/share/ncurses4/terminfo/p/pcvt50 +/usr/share/ncurses4/terminfo/p/pcvt50w +/usr/share/ncurses4/terminfo/p/pcvtXX +/usr/share/ncurses4/terminfo/p/pcz19 +/usr/share/ncurses4/terminfo/p/pe1100 +/usr/share/ncurses4/terminfo/p/pe1200 +/usr/share/ncurses4/terminfo/p/pe1251 +/usr/share/ncurses4/terminfo/p/pe550 +/usr/share/ncurses4/terminfo/p/pe6100 +/usr/share/ncurses4/terminfo/p/pe6300 +/usr/share/ncurses4/terminfo/p/pe6312 +/usr/share/ncurses4/terminfo/p/pe7000c +/usr/share/ncurses4/terminfo/p/pe7000m +/usr/share/ncurses4/terminfo/p/pilot +/usr/share/ncurses4/terminfo/p/printer +/usr/share/ncurses4/terminfo/p/prism12 +/usr/share/ncurses4/terminfo/p/prism12-m +/usr/share/ncurses4/terminfo/p/prism12-m-w +/usr/share/ncurses4/terminfo/p/prism12-w +/usr/share/ncurses4/terminfo/p/prism14 +/usr/share/ncurses4/terminfo/p/prism14-m +/usr/share/ncurses4/terminfo/p/prism14-m-w +/usr/share/ncurses4/terminfo/p/prism14-w +/usr/share/ncurses4/terminfo/p/prism2 +/usr/share/ncurses4/terminfo/p/prism4 +/usr/share/ncurses4/terminfo/p/prism5 +/usr/share/ncurses4/terminfo/p/prism7 +/usr/share/ncurses4/terminfo/p/prism8 +/usr/share/ncurses4/terminfo/p/prism8-w +/usr/share/ncurses4/terminfo/p/prism8gl +/usr/share/ncurses4/terminfo/p/prism9 +/usr/share/ncurses4/terminfo/p/prism9-8 +/usr/share/ncurses4/terminfo/p/prism9-8-w +/usr/share/ncurses4/terminfo/p/prism9-w +/usr/share/ncurses4/terminfo/p/pro350 +/usr/share/ncurses4/terminfo/p/ps300 +/usr/share/ncurses4/terminfo/p/psterm +/usr/share/ncurses4/terminfo/p/psterm-80x24 +/usr/share/ncurses4/terminfo/p/psterm-90x28 +/usr/share/ncurses4/terminfo/p/psterm-96x48 +/usr/share/ncurses4/terminfo/p/psterm-basic +/usr/share/ncurses4/terminfo/p/psterm-fast +/usr/share/ncurses4/terminfo/p/psx_ansi +/usr/share/ncurses4/terminfo/p/pt100 +/usr/share/ncurses4/terminfo/p/pt100w +/usr/share/ncurses4/terminfo/p/pt200 +/usr/share/ncurses4/terminfo/p/pt200w +/usr/share/ncurses4/terminfo/p/pt210 +/usr/share/ncurses4/terminfo/p/pt250 +/usr/share/ncurses4/terminfo/p/pt250w +/usr/share/ncurses4/terminfo/p/pt505 +/usr/share/ncurses4/terminfo/p/pt505-22 +/usr/share/ncurses4/terminfo/p/pt505-24 +/usr/share/ncurses4/terminfo/p/pty +/usr/share/ncurses4/terminfo/q +/usr/share/ncurses4/terminfo/q/qdcons +/usr/share/ncurses4/terminfo/q/qdss +/usr/share/ncurses4/terminfo/q/qnx +/usr/share/ncurses4/terminfo/q/qnx4 +/usr/share/ncurses4/terminfo/q/qume +/usr/share/ncurses4/terminfo/q/qume5 +/usr/share/ncurses4/terminfo/q/qvt101 +/usr/share/ncurses4/terminfo/q/qvt101+ +/usr/share/ncurses4/terminfo/q/qvt101p +/usr/share/ncurses4/terminfo/q/qvt102 +/usr/share/ncurses4/terminfo/q/qvt103 +/usr/share/ncurses4/terminfo/q/qvt103-w +/usr/share/ncurses4/terminfo/q/qvt108 +/usr/share/ncurses4/terminfo/q/qvt119 +/usr/share/ncurses4/terminfo/q/qvt119+ +/usr/share/ncurses4/terminfo/q/qvt119+-25 +/usr/share/ncurses4/terminfo/q/qvt119+-25-w +/usr/share/ncurses4/terminfo/q/qvt119+-w +/usr/share/ncurses4/terminfo/q/qvt119-25-w +/usr/share/ncurses4/terminfo/q/qvt119-w +/usr/share/ncurses4/terminfo/q/qvt119p +/usr/share/ncurses4/terminfo/q/qvt119p-25 +/usr/share/ncurses4/terminfo/q/qvt119p-25-w +/usr/share/ncurses4/terminfo/q/qvt119p-w +/usr/share/ncurses4/terminfo/q/qvt203 +/usr/share/ncurses4/terminfo/q/qvt203+ +/usr/share/ncurses4/terminfo/q/qvt203-25 +/usr/share/ncurses4/terminfo/q/qvt203-25-w +/usr/share/ncurses4/terminfo/q/qvt203-w +/usr/share/ncurses4/terminfo/q/qvt203-w-am +/usr/share/ncurses4/terminfo/r +/usr/share/ncurses4/terminfo/r/rbcomm +/usr/share/ncurses4/terminfo/r/rbcomm-nam +/usr/share/ncurses4/terminfo/r/rbcomm-w +/usr/share/ncurses4/terminfo/r/rca +/usr/share/ncurses4/terminfo/r/rebus3180 +/usr/share/ncurses4/terminfo/r/regent +/usr/share/ncurses4/terminfo/r/regent100 +/usr/share/ncurses4/terminfo/r/regent20 +/usr/share/ncurses4/terminfo/r/regent200 +/usr/share/ncurses4/terminfo/r/regent25 +/usr/share/ncurses4/terminfo/r/regent40 +/usr/share/ncurses4/terminfo/r/regent40+ +/usr/share/ncurses4/terminfo/r/regent60 +/usr/share/ncurses4/terminfo/r/rt6221 +/usr/share/ncurses4/terminfo/r/rt6221-w +/usr/share/ncurses4/terminfo/r/rtpc +/usr/share/ncurses4/terminfo/r/rxvt +/usr/share/ncurses4/terminfo/r/rxvt-basic +/usr/share/ncurses4/terminfo/s +/usr/share/ncurses4/terminfo/s/s +/usr/share/ncurses4/terminfo/s/s4 +/usr/share/ncurses4/terminfo/s/sb1 +/usr/share/ncurses4/terminfo/s/sb2 +/usr/share/ncurses4/terminfo/s/sb3 +/usr/share/ncurses4/terminfo/s/sbi +/usr/share/ncurses4/terminfo/s/sbobcat +/usr/share/ncurses4/terminfo/s/sc410 +/usr/share/ncurses4/terminfo/s/sc415 +/usr/share/ncurses4/terminfo/s/scanset +/usr/share/ncurses4/terminfo/s/scoansi +/usr/share/ncurses4/terminfo/s/screen +/usr/share/ncurses4/terminfo/s/screen-w +/usr/share/ncurses4/terminfo/s/screen2 +/usr/share/ncurses4/terminfo/s/screen3 +/usr/share/ncurses4/terminfo/s/screwpoint +/usr/share/ncurses4/terminfo/s/scrhp +/usr/share/ncurses4/terminfo/s/simterm +/usr/share/ncurses4/terminfo/s/soroc +/usr/share/ncurses4/terminfo/s/soroc120 +/usr/share/ncurses4/terminfo/s/soroc140 +/usr/share/ncurses4/terminfo/s/spinwriter +/usr/share/ncurses4/terminfo/s/st52 +/usr/share/ncurses4/terminfo/s/sun +/usr/share/ncurses4/terminfo/s/sun-1 +/usr/share/ncurses4/terminfo/s/sun-12 +/usr/share/ncurses4/terminfo/s/sun-17 +/usr/share/ncurses4/terminfo/s/sun-24 +/usr/share/ncurses4/terminfo/s/sun-34 +/usr/share/ncurses4/terminfo/s/sun-48 +/usr/share/ncurses4/terminfo/s/sun-c +/usr/share/ncurses4/terminfo/s/sun-cmd +/usr/share/ncurses4/terminfo/s/sun-e +/usr/share/ncurses4/terminfo/s/sun-e-s +/usr/share/ncurses4/terminfo/s/sun-il +/usr/share/ncurses4/terminfo/s/sun-nic +/usr/share/ncurses4/terminfo/s/sun-s +/usr/share/ncurses4/terminfo/s/sun-s-e +/usr/share/ncurses4/terminfo/s/sun-ss5 +/usr/share/ncurses4/terminfo/s/sun1 +/usr/share/ncurses4/terminfo/s/sun2 +/usr/share/ncurses4/terminfo/s/sune +/usr/share/ncurses4/terminfo/s/superbee +/usr/share/ncurses4/terminfo/s/superbee-xsb +/usr/share/ncurses4/terminfo/s/superbeeic +/usr/share/ncurses4/terminfo/s/superbrain +/usr/share/ncurses4/terminfo/s/sv80 +/usr/share/ncurses4/terminfo/s/swtp +/usr/share/ncurses4/terminfo/s/synertek +/usr/share/ncurses4/terminfo/s/synertek380 +/usr/share/ncurses4/terminfo/s/system1 +/usr/share/ncurses4/terminfo/t +/usr/share/ncurses4/terminfo/t/t10 +/usr/share/ncurses4/terminfo/t/t1061 +/usr/share/ncurses4/terminfo/t/t1061f +/usr/share/ncurses4/terminfo/t/t16 +/usr/share/ncurses4/terminfo/t/t3700 +/usr/share/ncurses4/terminfo/t/t3800 +/usr/share/ncurses4/terminfo/t/t653x +/usr/share/ncurses4/terminfo/t/tab +/usr/share/ncurses4/terminfo/t/tab132 +/usr/share/ncurses4/terminfo/t/tab132-15 +/usr/share/ncurses4/terminfo/t/tab132-rv +/usr/share/ncurses4/terminfo/t/tab132-w +/usr/share/ncurses4/terminfo/t/tab132-w-rv +/usr/share/ncurses4/terminfo/t/tandem6510 +/usr/share/ncurses4/terminfo/t/tandem653 +/usr/share/ncurses4/terminfo/t/tek +/usr/share/ncurses4/terminfo/t/tek4012 +/usr/share/ncurses4/terminfo/t/tek4013 +/usr/share/ncurses4/terminfo/t/tek4014 +/usr/share/ncurses4/terminfo/t/tek4014-sm +/usr/share/ncurses4/terminfo/t/tek4015 +/usr/share/ncurses4/terminfo/t/tek4015-sm +/usr/share/ncurses4/terminfo/t/tek4023 +/usr/share/ncurses4/terminfo/t/tek4024 +/usr/share/ncurses4/terminfo/t/tek4025 +/usr/share/ncurses4/terminfo/t/tek4025-17 +/usr/share/ncurses4/terminfo/t/tek4025-17-ws +/usr/share/ncurses4/terminfo/t/tek4025-cr +/usr/share/ncurses4/terminfo/t/tek4025-ex +/usr/share/ncurses4/terminfo/t/tek4025a +/usr/share/ncurses4/terminfo/t/tek4025ex +/usr/share/ncurses4/terminfo/t/tek4027 +/usr/share/ncurses4/terminfo/t/tek4027-ex +/usr/share/ncurses4/terminfo/t/tek4105 +/usr/share/ncurses4/terminfo/t/tek4105-30 +/usr/share/ncurses4/terminfo/t/tek4105a +/usr/share/ncurses4/terminfo/t/tek4106brl +/usr/share/ncurses4/terminfo/t/tek4107 +/usr/share/ncurses4/terminfo/t/tek4107brl +/usr/share/ncurses4/terminfo/t/tek4109 +/usr/share/ncurses4/terminfo/t/tek4109brl +/usr/share/ncurses4/terminfo/t/tek4112 +/usr/share/ncurses4/terminfo/t/tek4112-5 +/usr/share/ncurses4/terminfo/t/tek4112-nd +/usr/share/ncurses4/terminfo/t/tek4113 +/usr/share/ncurses4/terminfo/t/tek4113-34 +/usr/share/ncurses4/terminfo/t/tek4113-nd +/usr/share/ncurses4/terminfo/t/tek4114 +/usr/share/ncurses4/terminfo/t/tek4115 +/usr/share/ncurses4/terminfo/t/tek4125 +/usr/share/ncurses4/terminfo/t/tek4205 +/usr/share/ncurses4/terminfo/t/tek4207 +/usr/share/ncurses4/terminfo/t/tek4207-s +/usr/share/ncurses4/terminfo/t/tek4404 +/usr/share/ncurses4/terminfo/t/teleray +/usr/share/ncurses4/terminfo/t/teletec +/usr/share/ncurses4/terminfo/t/terminet +/usr/share/ncurses4/terminfo/t/terminet1200 +/usr/share/ncurses4/terminfo/t/terminet300 +/usr/share/ncurses4/terminfo/t/tgtelnet +/usr/share/ncurses4/terminfo/t/ti700 +/usr/share/ncurses4/terminfo/t/ti733 +/usr/share/ncurses4/terminfo/t/ti735 +/usr/share/ncurses4/terminfo/t/ti745 +/usr/share/ncurses4/terminfo/t/ti800 +/usr/share/ncurses4/terminfo/t/ti916 +/usr/share/ncurses4/terminfo/t/ti916-132 +/usr/share/ncurses4/terminfo/t/ti916-220-7 +/usr/share/ncurses4/terminfo/t/ti916-220-8 +/usr/share/ncurses4/terminfo/t/ti916-8 +/usr/share/ncurses4/terminfo/t/ti916-8-132 +/usr/share/ncurses4/terminfo/t/ti924 +/usr/share/ncurses4/terminfo/t/ti924-8 +/usr/share/ncurses4/terminfo/t/ti924-8w +/usr/share/ncurses4/terminfo/t/ti924w +/usr/share/ncurses4/terminfo/t/ti926 +/usr/share/ncurses4/terminfo/t/ti926-8 +/usr/share/ncurses4/terminfo/t/ti928 +/usr/share/ncurses4/terminfo/t/ti928-8 +/usr/share/ncurses4/terminfo/t/ti931 +/usr/share/ncurses4/terminfo/t/ti_ansi +/usr/share/ncurses4/terminfo/t/tn1200 +/usr/share/ncurses4/terminfo/t/tn300 +/usr/share/ncurses4/terminfo/t/trs16 +/usr/share/ncurses4/terminfo/t/trs2 +/usr/share/ncurses4/terminfo/t/trs80II +/usr/share/ncurses4/terminfo/t/trsII +/usr/share/ncurses4/terminfo/t/ts-1 +/usr/share/ncurses4/terminfo/t/ts-1p +/usr/share/ncurses4/terminfo/t/ts1 +/usr/share/ncurses4/terminfo/t/ts100 +/usr/share/ncurses4/terminfo/t/ts100-ctxt +/usr/share/ncurses4/terminfo/t/ts100-sp +/usr/share/ncurses4/terminfo/t/ts1p +/usr/share/ncurses4/terminfo/t/tt505-22 +/usr/share/ncurses4/terminfo/t/tty33 +/usr/share/ncurses4/terminfo/t/tty35 +/usr/share/ncurses4/terminfo/t/tty37 +/usr/share/ncurses4/terminfo/t/tty40 +/usr/share/ncurses4/terminfo/t/tty43 +/usr/share/ncurses4/terminfo/t/tty4420 +/usr/share/ncurses4/terminfo/t/tty4424 +/usr/share/ncurses4/terminfo/t/tty4424-1 +/usr/share/ncurses4/terminfo/t/tty4424m +/usr/share/ncurses4/terminfo/t/tty4426 +/usr/share/ncurses4/terminfo/t/tty5410 +/usr/share/ncurses4/terminfo/t/tty5410-w +/usr/share/ncurses4/terminfo/t/tty5410v1 +/usr/share/ncurses4/terminfo/t/tty5410v1-w +/usr/share/ncurses4/terminfo/t/tty5420 +/usr/share/ncurses4/terminfo/t/tty5420+nl +/usr/share/ncurses4/terminfo/t/tty5420-nl +/usr/share/ncurses4/terminfo/t/tty5420-rv +/usr/share/ncurses4/terminfo/t/tty5420-rv-nl +/usr/share/ncurses4/terminfo/t/tty5420-w +/usr/share/ncurses4/terminfo/t/tty5420-w-nl +/usr/share/ncurses4/terminfo/t/tty5420-w-rv +/usr/share/ncurses4/terminfo/t/tty5420-w-rv-n +/usr/share/ncurses4/terminfo/t/tty5425 +/usr/share/ncurses4/terminfo/t/tty5425-nl +/usr/share/ncurses4/terminfo/t/tty5425-w +/usr/share/ncurses4/terminfo/t/tty5620 +/usr/share/ncurses4/terminfo/t/tty5620-1 +/usr/share/ncurses4/terminfo/t/tty5620-24 +/usr/share/ncurses4/terminfo/t/tty5620-34 +/usr/share/ncurses4/terminfo/t/tty5620-s +/usr/share/ncurses4/terminfo/t/ttydmd +/usr/share/ncurses4/terminfo/t/tvi-2p +/usr/share/ncurses4/terminfo/t/tvi803 +/usr/share/ncurses4/terminfo/t/tvi9065 +/usr/share/ncurses4/terminfo/t/tvi910 +/usr/share/ncurses4/terminfo/t/tvi910+ +/usr/share/ncurses4/terminfo/t/tvi912 +/usr/share/ncurses4/terminfo/t/tvi912-2p +/usr/share/ncurses4/terminfo/t/tvi912b +/usr/share/ncurses4/terminfo/t/tvi912c +/usr/share/ncurses4/terminfo/t/tvi912cc +/usr/share/ncurses4/terminfo/t/tvi914 +/usr/share/ncurses4/terminfo/t/tvi920 +/usr/share/ncurses4/terminfo/t/tvi920-2p +/usr/share/ncurses4/terminfo/t/tvi920b +/usr/share/ncurses4/terminfo/t/tvi920c +/usr/share/ncurses4/terminfo/t/tvi921 +/usr/share/ncurses4/terminfo/t/tvi924 +/usr/share/ncurses4/terminfo/t/tvi925 +/usr/share/ncurses4/terminfo/t/tvi925-hi +/usr/share/ncurses4/terminfo/t/tvi92B +/usr/share/ncurses4/terminfo/t/tvi92D +/usr/share/ncurses4/terminfo/t/tvi950 +/usr/share/ncurses4/terminfo/t/tvi950-2p +/usr/share/ncurses4/terminfo/t/tvi950-4p +/usr/share/ncurses4/terminfo/t/tvi950-rv +/usr/share/ncurses4/terminfo/t/tvi950-rv-2p +/usr/share/ncurses4/terminfo/t/tvi950-rv-4p +/usr/share/ncurses4/terminfo/t/tvi955 +/usr/share/ncurses4/terminfo/t/tvi955-hb +/usr/share/ncurses4/terminfo/t/tvi955-w +/usr/share/ncurses4/terminfo/t/tvi970 +/usr/share/ncurses4/terminfo/t/tvi970-2p +/usr/share/ncurses4/terminfo/t/tvi970-vb +/usr/share/ncurses4/terminfo/t/tvipt +/usr/share/ncurses4/terminfo/u +/usr/share/ncurses4/terminfo/u/ultima2 +/usr/share/ncurses4/terminfo/u/ultimaII +/usr/share/ncurses4/terminfo/u/uniterm +/usr/share/ncurses4/terminfo/u/uniterm49 +/usr/share/ncurses4/terminfo/u/unixpc +/usr/share/ncurses4/terminfo/u/unknown +/usr/share/ncurses4/terminfo/u/uts30 +/usr/share/ncurses4/terminfo/v +/usr/share/ncurses4/terminfo/v/v200-nam +/usr/share/ncurses4/terminfo/v/v320n +/usr/share/ncurses4/terminfo/v/v3220 +/usr/share/ncurses4/terminfo/v/v5410 +/usr/share/ncurses4/terminfo/v/vapple +/usr/share/ncurses4/terminfo/v/vc103 +/usr/share/ncurses4/terminfo/v/vc203 +/usr/share/ncurses4/terminfo/v/vc303 +/usr/share/ncurses4/terminfo/v/vc303a +/usr/share/ncurses4/terminfo/v/vc403a +/usr/share/ncurses4/terminfo/v/vc404 +/usr/share/ncurses4/terminfo/v/vc404-s +/usr/share/ncurses4/terminfo/v/vc414 +/usr/share/ncurses4/terminfo/v/vc414h +/usr/share/ncurses4/terminfo/v/vc415 +/usr/share/ncurses4/terminfo/v/venix +/usr/share/ncurses4/terminfo/v/versaterm +/usr/share/ncurses4/terminfo/v/vi200 +/usr/share/ncurses4/terminfo/v/vi200-f +/usr/share/ncurses4/terminfo/v/vi200-rv +/usr/share/ncurses4/terminfo/v/vi300 +/usr/share/ncurses4/terminfo/v/vi300-old +/usr/share/ncurses4/terminfo/v/vi50 +/usr/share/ncurses4/terminfo/v/vi500 +/usr/share/ncurses4/terminfo/v/vi50adm +/usr/share/ncurses4/terminfo/v/vi55 +/usr/share/ncurses4/terminfo/v/vi550 +/usr/share/ncurses4/terminfo/v/vi603 +/usr/share/ncurses4/terminfo/v/viewpoint +/usr/share/ncurses4/terminfo/v/viewpoint3a+ +/usr/share/ncurses4/terminfo/v/viewpoint60 +/usr/share/ncurses4/terminfo/v/viewpoint90 +/usr/share/ncurses4/terminfo/v/visa50 +/usr/share/ncurses4/terminfo/v/visual603 +/usr/share/ncurses4/terminfo/v/vitty +/usr/share/ncurses4/terminfo/v/vk100 +/usr/share/ncurses4/terminfo/v/vp3a+ +/usr/share/ncurses4/terminfo/v/vp60 +/usr/share/ncurses4/terminfo/v/vp90 +/usr/share/ncurses4/terminfo/v/vremote +/usr/share/ncurses4/terminfo/v/vs100 +/usr/share/ncurses4/terminfo/v/vs100-x10 +/usr/share/ncurses4/terminfo/v/vsc +/usr/share/ncurses4/terminfo/v/vt-61 +/usr/share/ncurses4/terminfo/v/vt100 +/usr/share/ncurses4/terminfo/v/vt100-am +/usr/share/ncurses4/terminfo/v/vt100-bm +/usr/share/ncurses4/terminfo/v/vt100-bm-o +/usr/share/ncurses4/terminfo/v/vt100-bot-s +/usr/share/ncurses4/terminfo/v/vt100-nam +/usr/share/ncurses4/terminfo/v/vt100-nam-w +/usr/share/ncurses4/terminfo/v/vt100-nav +/usr/share/ncurses4/terminfo/v/vt100-nav-w +/usr/share/ncurses4/terminfo/v/vt100-s +/usr/share/ncurses4/terminfo/v/vt100-s-bot +/usr/share/ncurses4/terminfo/v/vt100-s-top +/usr/share/ncurses4/terminfo/v/vt100-top-s +/usr/share/ncurses4/terminfo/v/vt100-vb +/usr/share/ncurses4/terminfo/v/vt100-w +/usr/share/ncurses4/terminfo/v/vt100-w-am +/usr/share/ncurses4/terminfo/v/vt100-w-nam +/usr/share/ncurses4/terminfo/v/vt100-w-nav +/usr/share/ncurses4/terminfo/v/vt100nam +/usr/share/ncurses4/terminfo/v/vt102 +/usr/share/ncurses4/terminfo/v/vt102-nsgr +/usr/share/ncurses4/terminfo/v/vt102-w +/usr/share/ncurses4/terminfo/v/vt125 +/usr/share/ncurses4/terminfo/v/vt131 +/usr/share/ncurses4/terminfo/v/vt132 +/usr/share/ncurses4/terminfo/v/vt200 +/usr/share/ncurses4/terminfo/v/vt200-js +/usr/share/ncurses4/terminfo/v/vt200-w +/usr/share/ncurses4/terminfo/v/vt220 +/usr/share/ncurses4/terminfo/v/vt220-8 +/usr/share/ncurses4/terminfo/v/vt220-js +/usr/share/ncurses4/terminfo/v/vt220-nam +/usr/share/ncurses4/terminfo/v/vt220-w +/usr/share/ncurses4/terminfo/v/vt220d +/usr/share/ncurses4/terminfo/v/vt300 +/usr/share/ncurses4/terminfo/v/vt300-nam +/usr/share/ncurses4/terminfo/v/vt300-w +/usr/share/ncurses4/terminfo/v/vt300-w-nam +/usr/share/ncurses4/terminfo/v/vt320 +/usr/share/ncurses4/terminfo/v/vt320-k3 +/usr/share/ncurses4/terminfo/v/vt320-k311 +/usr/share/ncurses4/terminfo/v/vt320-nam +/usr/share/ncurses4/terminfo/v/vt320-w +/usr/share/ncurses4/terminfo/v/vt320-w-nam +/usr/share/ncurses4/terminfo/v/vt320nam +/usr/share/ncurses4/terminfo/v/vt330 +/usr/share/ncurses4/terminfo/v/vt340 +/usr/share/ncurses4/terminfo/v/vt400 +/usr/share/ncurses4/terminfo/v/vt400-24 +/usr/share/ncurses4/terminfo/v/vt420 +/usr/share/ncurses4/terminfo/v/vt420f +/usr/share/ncurses4/terminfo/v/vt420pc +/usr/share/ncurses4/terminfo/v/vt420pcdos +/usr/share/ncurses4/terminfo/v/vt50 +/usr/share/ncurses4/terminfo/v/vt50h +/usr/share/ncurses4/terminfo/v/vt510 +/usr/share/ncurses4/terminfo/v/vt510pc +/usr/share/ncurses4/terminfo/v/vt510pcdos +/usr/share/ncurses4/terminfo/v/vt52 +/usr/share/ncurses4/terminfo/v/vt520 +/usr/share/ncurses4/terminfo/v/vt525 +/usr/share/ncurses4/terminfo/v/vt61 +/usr/share/ncurses4/terminfo/v/vt61.5 +/usr/share/ncurses4/terminfo/w +/usr/share/ncurses4/terminfo/w/wren +/usr/share/ncurses4/terminfo/w/wrenw +/usr/share/ncurses4/terminfo/w/wsiris +/usr/share/ncurses4/terminfo/w/wy-75ap +/usr/share/ncurses4/terminfo/w/wy100 +/usr/share/ncurses4/terminfo/w/wy100q +/usr/share/ncurses4/terminfo/w/wy120 +/usr/share/ncurses4/terminfo/w/wy120-25 +/usr/share/ncurses4/terminfo/w/wy120-25-w +/usr/share/ncurses4/terminfo/w/wy120-vb +/usr/share/ncurses4/terminfo/w/wy120-w +/usr/share/ncurses4/terminfo/w/wy120-w-vb +/usr/share/ncurses4/terminfo/w/wy120-wvb +/usr/share/ncurses4/terminfo/w/wy150 +/usr/share/ncurses4/terminfo/w/wy150-25 +/usr/share/ncurses4/terminfo/w/wy150-25-w +/usr/share/ncurses4/terminfo/w/wy150-vb +/usr/share/ncurses4/terminfo/w/wy150-w +/usr/share/ncurses4/terminfo/w/wy150-w-vb +/usr/share/ncurses4/terminfo/w/wy160 +/usr/share/ncurses4/terminfo/w/wy160-25 +/usr/share/ncurses4/terminfo/w/wy160-25-w +/usr/share/ncurses4/terminfo/w/wy160-42 +/usr/share/ncurses4/terminfo/w/wy160-42-w +/usr/share/ncurses4/terminfo/w/wy160-43 +/usr/share/ncurses4/terminfo/w/wy160-43-w +/usr/share/ncurses4/terminfo/w/wy160-tek +/usr/share/ncurses4/terminfo/w/wy160-vb +/usr/share/ncurses4/terminfo/w/wy160-w +/usr/share/ncurses4/terminfo/w/wy160-w-vb +/usr/share/ncurses4/terminfo/w/wy160-wvb +/usr/share/ncurses4/terminfo/w/wy185 +/usr/share/ncurses4/terminfo/w/wy185-24 +/usr/share/ncurses4/terminfo/w/wy185-vb +/usr/share/ncurses4/terminfo/w/wy185-w +/usr/share/ncurses4/terminfo/w/wy185-wvb +/usr/share/ncurses4/terminfo/w/wy30 +/usr/share/ncurses4/terminfo/w/wy30-mc +/usr/share/ncurses4/terminfo/w/wy30-vb +/usr/share/ncurses4/terminfo/w/wy325 +/usr/share/ncurses4/terminfo/w/wy325-25 +/usr/share/ncurses4/terminfo/w/wy325-25w +/usr/share/ncurses4/terminfo/w/wy325-42 +/usr/share/ncurses4/terminfo/w/wy325-42w +/usr/share/ncurses4/terminfo/w/wy325-42w-vb +/usr/share/ncurses4/terminfo/w/wy325-42wvb +/usr/share/ncurses4/terminfo/w/wy325-43 +/usr/share/ncurses4/terminfo/w/wy325-43w +/usr/share/ncurses4/terminfo/w/wy325-43w-vb +/usr/share/ncurses4/terminfo/w/wy325-43wvb +/usr/share/ncurses4/terminfo/w/wy325-80 +/usr/share/ncurses4/terminfo/w/wy325-vb +/usr/share/ncurses4/terminfo/w/wy325-w +/usr/share/ncurses4/terminfo/w/wy325-w-vb +/usr/share/ncurses4/terminfo/w/wy325-wvb +/usr/share/ncurses4/terminfo/w/wy325w-24 +/usr/share/ncurses4/terminfo/w/wy350 +/usr/share/ncurses4/terminfo/w/wy350-vb +/usr/shar \ No newline at end of file diff --git a/fuzz/seed_corpus/07e10835dd988dbe50d5b6fd31764d861be92472 b/fuzz/seed_corpus/07e10835dd988dbe50d5b6fd31764d861be92472 new file mode 100644 index 000000000000..78d67362f322 --- /dev/null +++ b/fuzz/seed_corpus/07e10835dd988dbe50d5b6fd31764d861be92472 @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/084e64a61efd93c01013fd8e4d5c85c06b06ed30 b/fuzz/seed_corpus/084e64a61efd93c01013fd8e4d5c85c06b06ed30 new file mode 100644 index 000000000000..dad8fb710081 --- /dev/null +++ b/fuzz/seed_corpus/084e64a61efd93c01013fd8e4d5c85c06b06ed30 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/08c7c9747d2d903aa36313b9411946c71662f377 b/fuzz/seed_corpus/08c7c9747d2d903aa36313b9411946c71662f377 new file mode 100644 index 000000000000..113ffa8ce03c --- /dev/null +++ b/fuzz/seed_corpus/08c7c9747d2d903aa36313b9411946c71662f377 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/090413ef009359b0c1306316fc170553544f2b61 b/fuzz/seed_corpus/090413ef009359b0c1306316fc170553544f2b61 new file mode 100644 index 000000000000..d325ac2320b6 --- /dev/null +++ b/fuzz/seed_corpus/090413ef009359b0c1306316fc170553544f2b61 @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/0a204a26abfc429052d195a53e54e59546cbea8e b/fuzz/seed_corpus/0a204a26abfc429052d195a53e54e59546cbea8e new file mode 100644 index 000000000000..1e5a059387e3 --- /dev/null +++ b/fuzz/seed_corpus/0a204a26abfc429052d195a53e54e59546cbea8e @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/0a20515ebc673a7189a9c85df27537ce1facde25 b/fuzz/seed_corpus/0a20515ebc673a7189a9c85df27537ce1facde25 new file mode 100644 index 000000000000..693df185cfd0 --- /dev/null +++ b/fuzz/seed_corpus/0a20515ebc673a7189a9c85df27537ce1facde25 @@ -0,0 +1,3 @@ + + foobar + diff --git a/fuzz/seed_corpus/0a6fe19b30ff4214e9c0ba8de22ddfb62bab749d b/fuzz/seed_corpus/0a6fe19b30ff4214e9c0ba8de22ddfb62bab749d new file mode 100644 index 000000000000..24c2e6b0f4f0 --- /dev/null +++ b/fuzz/seed_corpus/0a6fe19b30ff4214e9c0ba8de22ddfb62bab749d @@ -0,0 +1,36 @@ + + meta + meta + + link + + + link + + base + foo + meta + + link + + meta + meta + meta + meta + meta + + link + + + link + + + link + + + link + + + link + + diff --git a/fuzz/seed_corpus/0a8ae185eb95921dda7c1904eaf2e8eb6d86cb1b b/fuzz/seed_corpus/0a8ae185eb95921dda7c1904eaf2e8eb6d86cb1b new file mode 100644 index 000000000000..bd8c4747f4cc --- /dev/null +++ b/fuzz/seed_corpus/0a8ae185eb95921dda7c1904eaf2e8eb6d86cb1b @@ -0,0 +1,3 @@ + +Hello, world!]]> + diff --git a/fuzz/seed_corpus/0a993ba3d08d0a13561b372c1b8a5d3e699cd869 b/fuzz/seed_corpus/0a993ba3d08d0a13561b372c1b8a5d3e699cd869 new file mode 100644 index 000000000000..b620ab8a3c28 --- /dev/null +++ b/fuzz/seed_corpus/0a993ba3d08d0a13561b372c1b8a5d3e699cd869 @@ -0,0 +1,5 @@ + + + 127 + + diff --git a/fuzz/seed_corpus/0ad8a19515bb609baceb2b3945e86ef0b2e5a5fb b/fuzz/seed_corpus/0ad8a19515bb609baceb2b3945e86ef0b2e5a5fb new file mode 100644 index 000000000000..c1335231bbec --- /dev/null +++ b/fuzz/seed_corpus/0ad8a19515bb609baceb2b3945e86ef0b2e5a5fb @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/0b4909764c156be5c065dcc16c1e567b31017e9e b/fuzz/seed_corpus/0b4909764c156be5c065dcc16c1e567b31017e9e new file mode 100644 index 000000000000..c954a91f47ab --- /dev/null +++ b/fuzz/seed_corpus/0b4909764c156be5c065dcc16c1e567b31017e9e @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0b654d50c2764ecf5d674bca11f08afeaf54fae4 b/fuzz/seed_corpus/0b654d50c2764ecf5d674bca11f08afeaf54fae4 new file mode 100644 index 000000000000..83ef1426a5b4 --- /dev/null +++ b/fuzz/seed_corpus/0b654d50c2764ecf5d674bca11f08afeaf54fae4 @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/0b7091f77ebe7860c8c8554eebb6765252d6e592 b/fuzz/seed_corpus/0b7091f77ebe7860c8c8554eebb6765252d6e592 new file mode 100644 index 000000000000..caeffec5557c --- /dev/null +++ b/fuzz/seed_corpus/0b7091f77ebe7860c8c8554eebb6765252d6e592 @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/0b9629a73f555d8289186e30d742aabbc50bcd5a b/fuzz/seed_corpus/0b9629a73f555d8289186e30d742aabbc50bcd5a new file mode 100644 index 000000000000..94d818c420f3 --- /dev/null +++ b/fuzz/seed_corpus/0b9629a73f555d8289186e30d742aabbc50bcd5a @@ -0,0 +1,21 @@ + + + + + I shouldn't do this here... + + weeelll + + + hmmmmmm + + ...and here as well - more than ever + + + + diff --git a/fuzz/seed_corpus/0badf8f46e8416ed41f758e79210a509dfb2d922 b/fuzz/seed_corpus/0badf8f46e8416ed41f758e79210a509dfb2d922 new file mode 100644 index 000000000000..d7c3da2f5a79 --- /dev/null +++ b/fuzz/seed_corpus/0badf8f46e8416ed41f758e79210a509dfb2d922 @@ -0,0 +1,986 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0c156d7e289aa9daed03ee5219c1087f304e0ff5 b/fuzz/seed_corpus/0c156d7e289aa9daed03ee5219c1087f304e0ff5 new file mode 100644 index 000000000000..cc2a0fdc30b1 --- /dev/null +++ b/fuzz/seed_corpus/0c156d7e289aa9daed03ee5219c1087f304e0ff5 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0c81f2be59d6e8d407560df61f70fea33f628619 b/fuzz/seed_corpus/0c81f2be59d6e8d407560df61f70fea33f628619 new file mode 100644 index 000000000000..6a728e6771fb --- /dev/null +++ b/fuzz/seed_corpus/0c81f2be59d6e8d407560df61f70fea33f628619 @@ -0,0 +1,14 @@ +=>a|b(d|e(g|h|i)|f)|c +a +c +bd +bf +beg +beh +bei +b +be +bi +f +ab +ac diff --git a/fuzz/seed_corpus/0c9f98eb422a59137fcf6e8368b2d91b00a5cfb0 b/fuzz/seed_corpus/0c9f98eb422a59137fcf6e8368b2d91b00a5cfb0 new file mode 100644 index 000000000000..22d8ed88e852 --- /dev/null +++ b/fuzz/seed_corpus/0c9f98eb422a59137fcf6e8368b2d91b00a5cfb0 @@ -0,0 +1,16 @@ + + + + + + + +]> + + Some text. + + Some text. + + Some text. + diff --git a/fuzz/seed_corpus/0cca701ea25dab8e47ffee1d41ae5b2fa80d75ce b/fuzz/seed_corpus/0cca701ea25dab8e47ffee1d41ae5b2fa80d75ce new file mode 100644 index 000000000000..5c1c1bf02799 --- /dev/null +++ b/fuzz/seed_corpus/0cca701ea25dab8e47ffee1d41ae5b2fa80d75ce @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/0d187520e9f41b00153249383f24c77fd5d4cd99 b/fuzz/seed_corpus/0d187520e9f41b00153249383f24c77fd5d4cd99 new file mode 100644 index 000000000000..a6b4d6027083 --- /dev/null +++ b/fuzz/seed_corpus/0d187520e9f41b00153249383f24c77fd5d4cd99 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/0d3a2bdc316b17dfbd0b7ccd44737d8caa63792c b/fuzz/seed_corpus/0d3a2bdc316b17dfbd0b7ccd44737d8caa63792c new file mode 100644 index 000000000000..861c90ae3d62 --- /dev/null +++ b/fuzz/seed_corpus/0d3a2bdc316b17dfbd0b7ccd44737d8caa63792c @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/0d3d85ffa5363ae5691afddfb0a630d45739179a b/fuzz/seed_corpus/0d3d85ffa5363ae5691afddfb0a630d45739179a new file mode 100644 index 000000000000..23886d0b11e9 --- /dev/null +++ b/fuzz/seed_corpus/0d3d85ffa5363ae5691afddfb0a630d45739179a @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0d553bbcd73a23a541c68ffdf8cf60d386a67d92 b/fuzz/seed_corpus/0d553bbcd73a23a541c68ffdf8cf60d386a67d92 new file mode 100644 index 000000000000..2246f1770e21 --- /dev/null +++ b/fuzz/seed_corpus/0d553bbcd73a23a541c68ffdf8cf60d386a67d92 @@ -0,0 +1,7 @@ + + + + +]> + violates [ VC: Unique Element Type Declaration ] diff --git a/fuzz/seed_corpus/0d75321585730f6bc551f43ba86cb3aaec49d14d b/fuzz/seed_corpus/0d75321585730f6bc551f43ba86cb3aaec49d14d new file mode 100644 index 000000000000..c768e97e0ba8 --- /dev/null +++ b/fuzz/seed_corpus/0d75321585730f6bc551f43ba86cb3aaec49d14d @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0dd6288030245d6321791f5d145d5c465912945c b/fuzz/seed_corpus/0dd6288030245d6321791f5d145d5c465912945c new file mode 100644 index 000000000000..dcd06942301f --- /dev/null +++ b/fuzz/seed_corpus/0dd6288030245d6321791f5d145d5c465912945c @@ -0,0 +1 @@ +foo diff --git a/fuzz/seed_corpus/0e6f212f04c1659140cc135cc8ebb1313254c219 b/fuzz/seed_corpus/0e6f212f04c1659140cc135cc8ebb1313254c219 new file mode 100644 index 000000000000..d3ac3884b6a2 --- /dev/null +++ b/fuzz/seed_corpus/0e6f212f04c1659140cc135cc8ebb1313254c219 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/0e7113fb5f90187c68454342ff4b918fd89df95b b/fuzz/seed_corpus/0e7113fb5f90187c68454342ff4b918fd89df95b new file mode 100644 index 000000000000..7248a5bf932c --- /dev/null +++ b/fuzz/seed_corpus/0e7113fb5f90187c68454342ff4b918fd89df95b @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/0e75e6935de80d924277e5328d68a23d8de6ba3f b/fuzz/seed_corpus/0e75e6935de80d924277e5328d68a23d8de6ba3f new file mode 100644 index 000000000000..769a5bb7c8f1 --- /dev/null +++ b/fuzz/seed_corpus/0e75e6935de80d924277e5328d68a23d8de6ba3f @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0ea5bd004cf7e082db96ec3773cc1d3020ea0678 b/fuzz/seed_corpus/0ea5bd004cf7e082db96ec3773cc1d3020ea0678 new file mode 100644 index 000000000000..d5f28d5300e0 --- /dev/null +++ b/fuzz/seed_corpus/0ea5bd004cf7e082db96ec3773cc1d3020ea0678 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/0ed173519dbf72a643ebac81117507a13fc33701 b/fuzz/seed_corpus/0ed173519dbf72a643ebac81117507a13fc33701 new file mode 100644 index 000000000000..24a899b707e9 --- /dev/null +++ b/fuzz/seed_corpus/0ed173519dbf72a643ebac81117507a13fc33701 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/0f4b109b7485f97b414203e5c8fcbe9d79ad44ed b/fuzz/seed_corpus/0f4b109b7485f97b414203e5c8fcbe9d79ad44ed new file mode 100644 index 000000000000..6f67877f1714 --- /dev/null +++ b/fuzz/seed_corpus/0f4b109b7485f97b414203e5c8fcbe9d79ad44ed @@ -0,0 +1,9 @@ + + + + Attribute id is missing + Attribute id is used in wrong context + + + + diff --git a/fuzz/seed_corpus/0f5106937b68ba39686ca3bdb64695d2457451ca b/fuzz/seed_corpus/0f5106937b68ba39686ca3bdb64695d2457451ca new file mode 100644 index 000000000000..fd05da78f0a8 --- /dev/null +++ b/fuzz/seed_corpus/0f5106937b68ba39686ca3bdb64695d2457451ca @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/0f84ad0758d9add8fab470f16befdfaae099ddda b/fuzz/seed_corpus/0f84ad0758d9add8fab470f16befdfaae099ddda new file mode 100644 index 000000000000..5b4a77a4019d --- /dev/null +++ b/fuzz/seed_corpus/0f84ad0758d9add8fab470f16befdfaae099ddda @@ -0,0 +1,14 @@ + + + + + +"> +]> + + + &dest; + + + diff --git a/fuzz/seed_corpus/0fd7bee6fde35437645194d8c45aaee9cac11b6a b/fuzz/seed_corpus/0fd7bee6fde35437645194d8c45aaee9cac11b6a new file mode 100644 index 000000000000..f17c8080fb96 --- /dev/null +++ b/fuzz/seed_corpus/0fd7bee6fde35437645194d8c45aaee9cac11b6a @@ -0,0 +1,2 @@ + diff --git a/fuzz/seed_corpus/0ffd3e46edeb253b94d35fcc9c65fb353b49c486 b/fuzz/seed_corpus/0ffd3e46edeb253b94d35fcc9c65fb353b49c486 new file mode 100644 index 000000000000..ff6f285c662e --- /dev/null +++ b/fuzz/seed_corpus/0ffd3e46edeb253b94d35fcc9c65fb353b49c486 @@ -0,0 +1,30 @@ + + +Welcome to Copernic.com + + + + + + + + <body bgcolor="#FFFFFF" text="#000000" link="#000080" vlink="#000080" alink="#000080" + topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> + <p>This page uses frames, but your browser doesn't support them.</p> + </body> + diff --git a/fuzz/seed_corpus/10252b88a86e33e88effc97d948ac80c6416aa8f b/fuzz/seed_corpus/10252b88a86e33e88effc97d948ac80c6416aa8f new file mode 100644 index 000000000000..aa1adac0ee7b --- /dev/null +++ b/fuzz/seed_corpus/10252b88a86e33e88effc97d948ac80c6416aa8f @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + Java Font definition:Dialog 0 + + + Java Font definition:Helvetica 0 + + + + this is text + + + + Java Font definition:Dialog 0 + + + Java Font definition:Helvetica 700 + + + + sadfsadfsad + + + + + + + + + + + Java Font definition:Dialog 700 + + + Java Font definition:Dialog 700 + + + diff --git a/fuzz/seed_corpus/10427462d18f60de0727ae71f8b30e67bae5e300 b/fuzz/seed_corpus/10427462d18f60de0727ae71f8b30e67bae5e300 new file mode 100644 index 000000000000..624c71207245 --- /dev/null +++ b/fuzz/seed_corpus/10427462d18f60de0727ae71f8b30e67bae5e300 @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/11151c1f8a1da7fc9510eb6ac06e6b9c5efe6d89 b/fuzz/seed_corpus/11151c1f8a1da7fc9510eb6ac06e6b9c5efe6d89 new file mode 100644 index 000000000000..9fc5ead082af --- /dev/null +++ b/fuzz/seed_corpus/11151c1f8a1da7fc9510eb6ac06e6b9c5efe6d89 @@ -0,0 +1,15 @@ + + + + + + + a + b + + c + + + + + diff --git a/fuzz/seed_corpus/11272849809f3bdf65ceb37ac7aa447459334b46 b/fuzz/seed_corpus/11272849809f3bdf65ceb37ac7aa447459334b46 new file mode 100644 index 000000000000..d31c8ff95e62 --- /dev/null +++ b/fuzz/seed_corpus/11272849809f3bdf65ceb37ac7aa447459334b46 @@ -0,0 +1 @@ +&jÙ \ No newline at end of file diff --git a/fuzz/seed_corpus/115b37a602de376022be7161cb23d8200aee712b b/fuzz/seed_corpus/115b37a602de376022be7161cb23d8200aee712b new file mode 100644 index 000000000000..36179ddd649b --- /dev/null +++ b/fuzz/seed_corpus/115b37a602de376022be7161cb23d8200aee712b @@ -0,0 +1,23 @@ + + + + BBB element is missing. + BBB element is present. + AAA misses attribute name. + AAA contains attribute name. + + + + + BBB element is present. + AAA contains attribute name. + + + + + BBB element is missing. + AAA misses attribute name. + + + + diff --git a/fuzz/seed_corpus/11635af037a796739b803b1d67e59aee152fb35e b/fuzz/seed_corpus/11635af037a796739b803b1d67e59aee152fb35e new file mode 100644 index 000000000000..b2e70e3fff26 --- /dev/null +++ b/fuzz/seed_corpus/11635af037a796739b803b1d67e59aee152fb35e @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/11c3681bb5b2ea9cfdecb79f3a3124cb4c8858f9 b/fuzz/seed_corpus/11c3681bb5b2ea9cfdecb79f3a3124cb4c8858f9 new file mode 100644 index 000000000000..7d37ab83c596 --- /dev/null +++ b/fuzz/seed_corpus/11c3681bb5b2ea9cfdecb79f3a3124cb4c8858f9 @@ -0,0 +1,10 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:c14n11XmlBaseDoc1 and not(ancestor-or-self::ietf:e1 or ancestor-or-self::ietf:e2)] + diff --git a/fuzz/seed_corpus/11dab67b78d459826ae4cfcdc05cf91c1fc9fd7a b/fuzz/seed_corpus/11dab67b78d459826ae4cfcdc05cf91c1fc9fd7a new file mode 100644 index 000000000000..f065eed234cd --- /dev/null +++ b/fuzz/seed_corpus/11dab67b78d459826ae4cfcdc05cf91c1fc9fd7a @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/120a2fbfabf37ad14df7ed82c2d89088dfe15d19 b/fuzz/seed_corpus/120a2fbfabf37ad14df7ed82c2d89088dfe15d19 new file mode 100644 index 000000000000..dc5573c05701 --- /dev/null +++ b/fuzz/seed_corpus/120a2fbfabf37ad14df7ed82c2d89088dfe15d19 @@ -0,0 +1,10 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:e1] + diff --git a/fuzz/seed_corpus/12e7780fd2e88bce7460167ee15bcd8f84be0fbf b/fuzz/seed_corpus/12e7780fd2e88bce7460167ee15bcd8f84be0fbf new file mode 100644 index 000000000000..7046521343ca --- /dev/null +++ b/fuzz/seed_corpus/12e7780fd2e88bce7460167ee15bcd8f84be0fbf @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/1370fc03d0009a05614a134847afd8188fd76cc1 b/fuzz/seed_corpus/1370fc03d0009a05614a134847afd8188fd76cc1 new file mode 100644 index 000000000000..714c9d1846a6 --- /dev/null +++ b/fuzz/seed_corpus/1370fc03d0009a05614a134847afd8188fd76cc1 @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/13799b7fe169c8de8889234e7b33e0cdde0cc47e b/fuzz/seed_corpus/13799b7fe169c8de8889234e7b33e0cdde0cc47e new file mode 100644 index 000000000000..275753bad8fc --- /dev/null +++ b/fuzz/seed_corpus/13799b7fe169c8de8889234e7b33e0cdde0cc47e @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/13b919c1f1c19522473beaba623afed955e65f92 b/fuzz/seed_corpus/13b919c1f1c19522473beaba623afed955e65f92 new file mode 100644 index 000000000000..f6355700ffea --- /dev/null +++ b/fuzz/seed_corpus/13b919c1f1c19522473beaba623afed955e65f92 @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/13fb4d418998bdb16f027dfc2842d46ede5129b0 b/fuzz/seed_corpus/13fb4d418998bdb16f027dfc2842d46ede5129b0 new file mode 100644 index 000000000000..7d7abb136b5e --- /dev/null +++ b/fuzz/seed_corpus/13fb4d418998bdb16f027dfc2842d46ede5129b0 @@ -0,0 +1,2 @@ + +lalala diff --git a/fuzz/seed_corpus/1437e5e33198fa59e55fe2a8dcd3edac07102e64 b/fuzz/seed_corpus/1437e5e33198fa59e55fe2a8dcd3edac07102e64 new file mode 100644 index 000000000000..a93c8ee33508 --- /dev/null +++ b/fuzz/seed_corpus/1437e5e33198fa59e55fe2a8dcd3edac07102e64 @@ -0,0 +1,7 @@ + + + PEhlbGxvIHdvcmxkIT4= + PEhlbGxvIHdvcmxkIT4= + \ No newline at end of file diff --git a/fuzz/seed_corpus/143eddcb3c1e41ca0e773b91ba0bfa3b0888b085 b/fuzz/seed_corpus/143eddcb3c1e41ca0e773b91ba0bfa3b0888b085 new file mode 100644 index 000000000000..6922becc4737 --- /dev/null +++ b/fuzz/seed_corpus/143eddcb3c1e41ca0e773b91ba0bfa3b0888b085 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/156207e9ec9a86691595dd77cb0490a247fe175e b/fuzz/seed_corpus/156207e9ec9a86691595dd77cb0490a247fe175e new file mode 100644 index 000000000000..e2567f532d1b --- /dev/null +++ b/fuzz/seed_corpus/156207e9ec9a86691595dd77cb0490a247fe175e @@ -0,0 +1,6 @@ + + + +]> + diff --git a/fuzz/seed_corpus/15970946eb9a2ed52ad09fc78e61e1cf4e741018 b/fuzz/seed_corpus/15970946eb9a2ed52ad09fc78e61e1cf4e741018 new file mode 100644 index 000000000000..a7a1950afdf2 --- /dev/null +++ b/fuzz/seed_corpus/15970946eb9a2ed52ad09fc78e61e1cf4e741018 @@ -0,0 +1,18 @@ +]> + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/15d3ac6444c917fd769d0ce83bfc31dc4466980b b/fuzz/seed_corpus/15d3ac6444c917fd769d0ce83bfc31dc4466980b new file mode 100644 index 000000000000..19ce7387f6d5 --- /dev/null +++ b/fuzz/seed_corpus/15d3ac6444c917fd769d0ce83bfc31dc4466980b @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/15de524d7bfcddd2b2ffc89f02230740b71fe042 b/fuzz/seed_corpus/15de524d7bfcddd2b2ffc89f02230740b71fe042 new file mode 100644 index 000000000000..5eeccf2a0c87 --- /dev/null +++ b/fuzz/seed_corpus/15de524d7bfcddd2b2ffc89f02230740b71fe042 @@ -0,0 +1,9 @@ + + +]> + + Retenção + <> + &test1;&test2; + diff --git a/fuzz/seed_corpus/15ff9e809d0bfa67e482541391d3ec5fc9844a96 b/fuzz/seed_corpus/15ff9e809d0bfa67e482541391d3ec5fc9844a96 new file mode 100644 index 000000000000..a3efb7014bbd --- /dev/null +++ b/fuzz/seed_corpus/15ff9e809d0bfa67e482541391d3ec5fc9844a96 @@ -0,0 +1,3 @@ + +aaa + diff --git a/fuzz/seed_corpus/1600d482d58bc75d288aedadef3a11135788dc5c b/fuzz/seed_corpus/1600d482d58bc75d288aedadef3a11135788dc5c new file mode 100644 index 000000000000..7c3249cccab2 --- /dev/null +++ b/fuzz/seed_corpus/1600d482d58bc75d288aedadef3a11135788dc5c @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/16783e74638cfe8030490b0180fd7fbc765780d7 b/fuzz/seed_corpus/16783e74638cfe8030490b0180fd7fbc765780d7 new file mode 100644 index 000000000000..986b3fec6f8c --- /dev/null +++ b/fuzz/seed_corpus/16783e74638cfe8030490b0180fd7fbc765780d7 @@ -0,0 +1,18 @@ + + + + http://www.foo.bar/container/ + + + + + HTTP 1.1 200 OK + + + http://www.foo.bar/container/index.html + + + + HTTP 1.1 200 OK + + diff --git a/fuzz/seed_corpus/16f348235a0080206b00be3f9231e418aa5d67da b/fuzz/seed_corpus/16f348235a0080206b00be3f9231e418aa5d67da new file mode 100644 index 000000000000..cbfd4c428d61 --- /dev/null +++ b/fuzz/seed_corpus/16f348235a0080206b00be3f9231e418aa5d67da @@ -0,0 +1,25 @@ + + + + + + Box type A + + + J.J. Dingleheimerschmidt + + + HTTP/1.1 200 OK + + + + + + + HTTP/1.1 403 Forbidden + The user does not have access to the DingALing property. + + + There has been an access violation error. + + diff --git a/fuzz/seed_corpus/179b0cb5a01db1510b23f5cc531ea0ac3bfe4d98 b/fuzz/seed_corpus/179b0cb5a01db1510b23f5cc531ea0ac3bfe4d98 new file mode 100644 index 000000000000..84ff576b462f --- /dev/null +++ b/fuzz/seed_corpus/179b0cb5a01db1510b23f5cc531ea0ac3bfe4d98 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/17b31bb2ef7f3a15434478f422276fcd736f0ff7 b/fuzz/seed_corpus/17b31bb2ef7f3a15434478f422276fcd736f0ff7 new file mode 100644 index 000000000000..9513445b88d6 --- /dev/null +++ b/fuzz/seed_corpus/17b31bb2ef7f3a15434478f422276fcd736f0ff7 @@ -0,0 +1,20 @@ + + + 00 + 0123456789ABCDEF + abcdef0123456789 + 0123456789abcdef + 0123456789ABCDEF + 0123456789abcdef0123456789ABCDEF + 0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF + 01234567899876543210 + 00112233445566778899aAbBcCdDeEfF + A0B1C2D3E4F5 + + 00 + 0000000000000000 + 1122334455667788 + + abcd + 0ed0 + diff --git a/fuzz/seed_corpus/18093e2a54c73c34b3160fb1bccafeed58db0bd5 b/fuzz/seed_corpus/18093e2a54c73c34b3160fb1bccafeed58db0bd5 new file mode 100644 index 000000000000..16ac6c2795fc --- /dev/null +++ b/fuzz/seed_corpus/18093e2a54c73c34b3160fb1bccafeed58db0bd5 @@ -0,0 +1,5 @@ + + + text + + diff --git a/fuzz/seed_corpus/1818ac1aa7f2fb815428dd95acf8fe0691455e16 b/fuzz/seed_corpus/1818ac1aa7f2fb815428dd95acf8fe0691455e16 new file mode 100644 index 000000000000..4478c602ba32 --- /dev/null +++ b/fuzz/seed_corpus/1818ac1aa7f2fb815428dd95acf8fe0691455e16 @@ -0,0 +1,2 @@ + diff --git a/fuzz/seed_corpus/18455d3de982d262231a468c0c47e783805cc1fd b/fuzz/seed_corpus/18455d3de982d262231a468c0c47e783805cc1fd new file mode 100644 index 000000000000..bbb654a8b35f --- /dev/null +++ b/fuzz/seed_corpus/18455d3de982d262231a468c0c47e783805cc1fd @@ -0,0 +1,7 @@ + + + + + diff --git a/fuzz/seed_corpus/185d7bb0d1416c764345bac8dc713f3fe296dff7 b/fuzz/seed_corpus/185d7bb0d1416c764345bac8dc713f3fe296dff7 new file mode 100644 index 000000000000..ce93df774f64 --- /dev/null +++ b/fuzz/seed_corpus/185d7bb0d1416c764345bac8dc713f3fe296dff7 @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/191750348d3607f07c1ac636303daa558bc31697 b/fuzz/seed_corpus/191750348d3607f07c1ac636303daa558bc31697 new file mode 100644 index 000000000000..b9f62ca5f1b3 --- /dev/null +++ b/fuzz/seed_corpus/191750348d3607f07c1ac636303daa558bc31697 @@ -0,0 +1,3 @@ + + +&abc; diff --git a/fuzz/seed_corpus/19204df7ab4eae999ecc6ea0bded083cb946dc85 b/fuzz/seed_corpus/19204df7ab4eae999ecc6ea0bded083cb946dc85 new file mode 100644 index 000000000000..906a220b16d2 --- /dev/null +++ b/fuzz/seed_corpus/19204df7ab4eae999ecc6ea0bded083cb946dc85 @@ -0,0 +1,15 @@ + + + + Two groups, each of two rectangles + + + + + + + + + + diff --git a/fuzz/seed_corpus/19384a4d87395788c83ac27934cd3cf71d0e5406 b/fuzz/seed_corpus/19384a4d87395788c83ac27934cd3cf71d0e5406 new file mode 100644 index 000000000000..36cb8bb1f92b --- /dev/null +++ b/fuzz/seed_corpus/19384a4d87395788c83ac27934cd3cf71d0e5406 @@ -0,0 +1,12 @@ + + + + Source contains an empty element CCC + [1]An element CCC does not contain any text + [2]An element CCC does not contain any text + [1]An element CCC does not contain any child element + [2]An element CCC does not contain any child element + + + + diff --git a/fuzz/seed_corpus/195c9d4c518ea0b2717c281feb289b6553326abd b/fuzz/seed_corpus/195c9d4c518ea0b2717c281feb289b6553326abd new file mode 100644 index 000000000000..8b047cea462a --- /dev/null +++ b/fuzz/seed_corpus/195c9d4c518ea0b2717c281feb289b6553326abd @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/198eb5d4de042d0b430acfedb5f08b70a9bc4267 b/fuzz/seed_corpus/198eb5d4de042d0b430acfedb5f08b70a9bc4267 new file mode 100644 index 000000000000..ce7a2915b0ef --- /dev/null +++ b/fuzz/seed_corpus/198eb5d4de042d0b430acfedb5f08b70a9bc4267 @@ -0,0 +1,8 @@ + + + + + +]> +This is a valid document diff --git a/fuzz/seed_corpus/19a80b448405a19fbb41592734b6d4af617d0459 b/fuzz/seed_corpus/19a80b448405a19fbb41592734b6d4af617d0459 new file mode 100644 index 000000000000..b6739bb43078 --- /dev/null +++ b/fuzz/seed_corpus/19a80b448405a19fbb41592734b6d4af617d0459 @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/1a0798fcc3d279d54727b8531527edcda35079d8 b/fuzz/seed_corpus/1a0798fcc3d279d54727b8531527edcda35079d8 new file mode 100644 index 000000000000..7145c194ce0c --- /dev/null +++ b/fuzz/seed_corpus/1a0798fcc3d279d54727b8531527edcda35079d8 @@ -0,0 +1,12 @@ + + +Regression test 2 + + +

Regression test 2

+

+Autoclose of tag P +

+Ok file no problem + + diff --git a/fuzz/seed_corpus/1a69f9c493e3409a297ef54cd2709c6c8b155cd7 b/fuzz/seed_corpus/1a69f9c493e3409a297ef54cd2709c6c8b155cd7 new file mode 100644 index 000000000000..0ad64dd5cf2e --- /dev/null +++ b/fuzz/seed_corpus/1a69f9c493e3409a297ef54cd2709c6c8b155cd7 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/1afdab953f153ad082284ab6579dfa97e9db25e3 b/fuzz/seed_corpus/1afdab953f153ad082284ab6579dfa97e9db25e3 new file mode 100644 index 000000000000..63d6efc5e2b7 --- /dev/null +++ b/fuzz/seed_corpus/1afdab953f153ad082284ab6579dfa97e9db25e3 @@ -0,0 +1,7 @@ + + + Let's use a DTD defined entity &bent; + Let's use predefined entites & < > + + + diff --git a/fuzz/seed_corpus/1b03d02961926db0a5b2867291d30951c39d148b b/fuzz/seed_corpus/1b03d02961926db0a5b2867291d30951c39d148b new file mode 100644 index 000000000000..a468702d93de --- /dev/null +++ b/fuzz/seed_corpus/1b03d02961926db0a5b2867291d30951c39d148b @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/1b6b1588fd94a28c0184b532083d2d4aaa4125aa b/fuzz/seed_corpus/1b6b1588fd94a28c0184b532083d2d4aaa4125aa new file mode 100644 index 000000000000..8ffee0e17503 --- /dev/null +++ b/fuzz/seed_corpus/1b6b1588fd94a28c0184b532083d2d4aaa4125aa @@ -0,0 +1,8 @@ + + + anyURI + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/1c325aae428d9e024730d89afdfbcfd9dfd05755 b/fuzz/seed_corpus/1c325aae428d9e024730d89afdfbcfd9dfd05755 new file mode 100644 index 000000000000..b151c21c30eb --- /dev/null +++ b/fuzz/seed_corpus/1c325aae428d9e024730d89afdfbcfd9dfd05755 @@ -0,0 +1,6 @@ + + + +]> +This is a valid document diff --git a/fuzz/seed_corpus/1c967d0cbfb53d1c1184b8d27f2c0b1f9cb4326c b/fuzz/seed_corpus/1c967d0cbfb53d1c1184b8d27f2c0b1f9cb4326c new file mode 100644 index 000000000000..031a967caed3 --- /dev/null +++ b/fuzz/seed_corpus/1c967d0cbfb53d1c1184b8d27f2c0b1f9cb4326c @@ -0,0 +1,13 @@ + + +Text with EUC-JP chars at position 214 (0xd6) +___ +_______________ +_______________ +_______________ +_______________ +_______________ +_______________ +_______________ +_______é®Äé___ +_ diff --git a/fuzz/seed_corpus/1d2e7871a709b88c0f4e07b959c103070768a5b5 b/fuzz/seed_corpus/1d2e7871a709b88c0f4e07b959c103070768a5b5 new file mode 100644 index 000000000000..6c303e476d19 --- /dev/null +++ b/fuzz/seed_corpus/1d2e7871a709b88c0f4e07b959c103070768a5b5 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/1e791b3905ff171de1c06a26fdff4d262d5d4be2 b/fuzz/seed_corpus/1e791b3905ff171de1c06a26fdff4d262d5d4be2 new file mode 100644 index 000000000000..a0b8a592b241 --- /dev/null +++ b/fuzz/seed_corpus/1e791b3905ff171de1c06a26fdff4d262d5d4be2 @@ -0,0 +1,9 @@ + + + + + + diff --git a/fuzz/seed_corpus/1e82fff4b132ce695652529980f1c904d28b7791 b/fuzz/seed_corpus/1e82fff4b132ce695652529980f1c904d28b7791 new file mode 100644 index 000000000000..9d3fabff2136 --- /dev/null +++ b/fuzz/seed_corpus/1e82fff4b132ce695652529980f1c904d28b7791 @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/1ed76a4de1c73b3f5883f0ca110a96be8aa12c1e b/fuzz/seed_corpus/1ed76a4de1c73b3f5883f0ca110a96be8aa12c1e new file mode 100644 index 000000000000..abfe1d6b8d6a --- /dev/null +++ b/fuzz/seed_corpus/1ed76a4de1c73b3f5883f0ca110a96be8aa12c1e @@ -0,0 +1,13 @@ + + 1 + + en + 3 + + 4 + +

+ + + + diff --git a/fuzz/seed_corpus/1ee55697ce9055cfe227685daca3c57b4318cfa0 b/fuzz/seed_corpus/1ee55697ce9055cfe227685daca3c57b4318cfa0 new file mode 100644 index 000000000000..adb9ea7afc57 --- /dev/null +++ b/fuzz/seed_corpus/1ee55697ce9055cfe227685daca3c57b4318cfa0 @@ -0,0 +1,5 @@ + + + This is an inverted exclamation sign ¡ + This is a space + diff --git a/fuzz/seed_corpus/1f50fd9aa3a95df4a16b2ff4ce266ca83a4ff1fc b/fuzz/seed_corpus/1f50fd9aa3a95df4a16b2ff4ce266ca83a4ff1fc new file mode 100644 index 000000000000..b02bb1757782 --- /dev/null +++ b/fuzz/seed_corpus/1f50fd9aa3a95df4a16b2ff4ce266ca83a4ff1fc @@ -0,0 +1,6 @@ + +]> + + diff --git a/fuzz/seed_corpus/1f61817349b114163accd91d7718ccd8a22fbfa2 b/fuzz/seed_corpus/1f61817349b114163accd91d7718ccd8a22fbfa2 new file mode 100644 index 000000000000..27955093dc0b --- /dev/null +++ b/fuzz/seed_corpus/1f61817349b114163accd91d7718ccd8a22fbfa2 @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + +

If automatic testing failed, select Failed + + + + + .

+
+ +
diff --git a/fuzz/seed_corpus/1f954acde14869cc13df666d262a96000bbfb5dc b/fuzz/seed_corpus/1f954acde14869cc13df666d262a96000bbfb5dc new file mode 100644 index 000000000000..5f63102166da --- /dev/null +++ b/fuzz/seed_corpus/1f954acde14869cc13df666d262a96000bbfb5dc @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/1fd59752baa6bc81f102ba96945a8026d8715adc b/fuzz/seed_corpus/1fd59752baa6bc81f102ba96945a8026d8715adc new file mode 100644 index 000000000000..0ea1a41bebb1 --- /dev/null +++ b/fuzz/seed_corpus/1fd59752baa6bc81f102ba96945a8026d8715adc @@ -0,0 +1,5 @@ + + first page + second page + third page + diff --git a/fuzz/seed_corpus/200d267a8bfc425839e40d407199ea7ff82fe346 b/fuzz/seed_corpus/200d267a8bfc425839e40d407199ea7ff82fe346 new file mode 100644 index 000000000000..0cf871ec5dc6 --- /dev/null +++ b/fuzz/seed_corpus/200d267a8bfc425839e40d407199ea7ff82fe346 @@ -0,0 +1,9 @@ + + + + + + diff --git a/fuzz/seed_corpus/200d6d0432577c34fc801d4fee24b3393d7c05b4 b/fuzz/seed_corpus/200d6d0432577c34fc801d4fee24b3393d7c05b4 new file mode 100644 index 000000000000..8f2bc09c420f --- /dev/null +++ b/fuzz/seed_corpus/200d6d0432577c34fc801d4fee24b3393d7c05b4 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/210a5f90b6ae0cd6cb95edbde77d52d450eeb1fc b/fuzz/seed_corpus/210a5f90b6ae0cd6cb95edbde77d52d450eeb1fc new file mode 100644 index 000000000000..58990cbbab66 --- /dev/null +++ b/fuzz/seed_corpus/210a5f90b6ae0cd6cb95edbde77d52d450eeb1fc @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/fuzz/seed_corpus/210cab277f69b056d63542bc6940ea2cca8a558a b/fuzz/seed_corpus/210cab277f69b056d63542bc6940ea2cca8a558a new file mode 100644 index 000000000000..b959a1278d51 --- /dev/null +++ b/fuzz/seed_corpus/210cab277f69b056d63542bc6940ea2cca8a558a @@ -0,0 +1,7 @@ + + + +

+

+

+
diff --git a/fuzz/seed_corpus/211cf9d35b1d4679671b4ac3d4e89fc075613ab3 b/fuzz/seed_corpus/211cf9d35b1d4679671b4ac3d4e89fc075613ab3 new file mode 100644 index 000000000000..56df55a2fe61 --- /dev/null +++ b/fuzz/seed_corpus/211cf9d35b1d4679671b4ac3d4e89fc075613ab3 @@ -0,0 +1,7 @@ + + + + +]> + This seems Ok but this was not declared diff --git a/fuzz/seed_corpus/21f4384140618ecb5caadcfeb123bd6f7d1bcbfe b/fuzz/seed_corpus/21f4384140618ecb5caadcfeb123bd6f7d1bcbfe new file mode 100644 index 000000000000..912327551ce4 --- /dev/null +++ b/fuzz/seed_corpus/21f4384140618ecb5caadcfeb123bd6f7d1bcbfe @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/21f9abf973c92ec0a51656f3a76dbdad0bad769c b/fuzz/seed_corpus/21f9abf973c92ec0a51656f3a76dbdad0bad769c new file mode 100644 index 000000000000..6c6396801014 --- /dev/null +++ b/fuzz/seed_corpus/21f9abf973c92ec0a51656f3a76dbdad0bad769c @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/22421149badaedff85e55e4cab3b08502a92c36f b/fuzz/seed_corpus/22421149badaedff85e55e4cab3b08502a92c36f new file mode 100644 index 000000000000..cc1580b53ff6 --- /dev/null +++ b/fuzz/seed_corpus/22421149badaedff85e55e4cab3b08502a92c36f @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/22d1271153c5b90a31a6a3924787b98a750344eb b/fuzz/seed_corpus/22d1271153c5b90a31a6a3924787b98a750344eb new file mode 100644 index 000000000000..a8907cc62926 --- /dev/null +++ b/fuzz/seed_corpus/22d1271153c5b90a31a6a3924787b98a750344eb @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/23343eefaf46c5fbfe5a5ed489b125cf38741d14 b/fuzz/seed_corpus/23343eefaf46c5fbfe5a5ed489b125cf38741d14 new file mode 100644 index 000000000000..7395edd17492 --- /dev/null +++ b/fuzz/seed_corpus/23343eefaf46c5fbfe5a5ed489b125cf38741d14 @@ -0,0 +1,1558 @@ + + + + + + + + + + + + +]> + + + +
+ + + + + + David + Mason + + Red Hat, Inc. +
+ dcm@redhat.com +
+
+
+ + + Daniel + Mueth + +
+ d-mueth@uchicago.edu +
+
+
+ + + Alexander + Kirillov + +
+ kirillov@math.sunysb.edu +
+
+
+ +
+ + + This is a pre-release! + + + + + + 0.99 + + + 04.10.2000 + + + + + + 2000 + Red Hat, Inc., Daniel Mueth, and Alexander Kirillov + + + + + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU Free Documentation + License, Version 1.1 or any later version published + by the Free Software Foundation with no Invariant Sections, no + Front-Cover Texts, and no Back-Cover Texts. You may obtain a copy + of the GNU Free Documentation License from + the Free Software Foundation by visiting their Web site or by writing to: + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + + Many of the names used by companies to distinguish their products and + services are claimed as trademarks. Where those names appear in any + GNOME documentation, and those trademarks are made aware to the members + of the GNOME Documentation Project, the names have been printed in caps + or initial caps. + + + + The GNOME Handbook of Writing Software Documentation + +
+ + + + + Introduction + + + + + The GNOME Documentation Project + + + Goals + + The GNOME Documentation Project (GDP) aims to provide GNOME + and GNOME applications with a complete, intuitive, and clear + documentation system. At the center of the GDP is the + GNOME Help Browser, which + presents a unified interface to GNOME-specific documentation + as well as other Linux documentation such as man pages and + texinfo documents. The GNOME Help System provides a + comprehensive view of documentation on a machine by + dynamically assembling the documentation of GNOME + applications and components which are installed. The GDP is + responsible for writing numerous GNOME-related documents, + both for developers and for users. Developer documentation + includes APIs for the GNOME libraries, GNOME White + Papers, GNOME developer tutorials, the GNOME Developer + FAQ, the GNOME + Developer's Website, and GNOME + Handbook's, such as the one you are reading. + User documentation include the GNOME User's + Guide, the GNOME FAQ, and + GNOME application documentation. Most GNOME applications + have their own manual in addition to context sensitive help. + + + + + Joining the GDP + + Documenting GNOME and all the numerous GNOME applications is + a very large project. The GDP is always looking for people + to help write, update, and edit documentation. If you are + interested in joining the GDP team, you should join the + + gnome-doc-list mailing list . + Read , for help selecting a + project to work on. Feel free to introduce yourself on the + gnome-doc-list mailing list and indicate which project you + intend to work on, or else ask for suggestions of important + documents which need work done. You may also want to join the + #docs IRC channel on irc.gnome.org to meet other GDP members + and discuss any questions you may have. For a list of GDP + projects and members, see the + + GDP Website. + + + + + Collaborating with the GDP + + GNOME developers, packagers, and translators may not be + writing GNOME documentation but will want to understand how + the GNOME documentation system works and will need to + collaborate with GDP members. This document should help to + outline the structure of how the GNOME documentation system + works. Developers who do not write the documentation for + their applications are encouraged to find a GDP member to + write the documentation. This is best done by sending an + email to the + gnome-doc-list mailing list + describing the application, where it can be downloaded from, + and that the developer(s) would like a GDP member to write + documentation for the application. The #docs IRC channel on + irc.gnome.org is another option for contacting GDP members. + + + + + + + + Notation and Conventions + + This Handbook uses the following notation: + + + + + + /usr/bin + + + Directory + + + + + foo.sgml + + + Filename + + + + + command + + + Command or text that would be typed. + + + + + replaceable + + + "Variable" text that can be replaced. + + + + + Program or Doc Code + + Program or document code + + + + + + + + + + + About This Handbook + + This Handbook is a guide for both writing documentation for + GNOME components and applications and for properly binding and + packaging documentation into GNOME applications. + + + This Handbook, like all GNOME documentation, was written in + DocBook(SGML) and is available in several formats including + SGML, HTML, PostScript, and PDF. For the latest version, see + + Getting The GNOME Handbook of Writing Software + Documentation . Alternately, one may + download it anonymously from GNOME CVS under gnome-docu/gdp. + + + + + + + + Getting Started Writing GNOME Documentation + + + + + Selecting A Document + + + Document Something You Know + + The most frequently asked question of new contributors who + join the GDP is "which document should I start + with?". Because most people involved are volunteers, we do + not assign projects and applications to + write documents for. The first step is all yours - you must + decide what about GNOME interests you most and find out if + it has complete documents or not. + + + It is also important to spend some time with GNOME to make + sure you are familiar enough with it to be + authoritative in your writing. The + best way to do this is to just sit down and play with GNOME + as much as possible before starting to write. + + + The easiest way to get started is to improve existing + documentation. If you notice some inaccuracies or omissions + in the documentation, or you think that you can explain the + material more clearly, just send your suggestions to the + author of the original documentation or to the GNOME + documentation project at docs@gnome.org. + + + + + The GNOME Documentation Status Table + + The GDP Documentation Status Table + (DocTable) (http://www.gnome.org/gdp/doctable/) is a + web page which tracks the status of all the various + documentation components of GNOME. These components include + application documentation, internal GNOME component + documentation, user documentation, and developer + documentation. For each documentation item, it tracks the + current status of the documentation, who is working on the + particular document, where the documentation can be found, + and provides a forum for the discussion of each item. + + + You should use the DocTable to help + you select a documentation item which needs work done. Once + you have selected an item to work on, please register + yourself as an author so that other authors do not duplicate + your work and may contact you to help or offer suggestions. + Also be sure to keep the status icons up-to-date so that + the GDP team can easily identify which items need additional + help. The DocTable also allows + people to make announcements and suggestions and to discuss + issues in the comments section. + + + Note + + Note that the information in the + DocTable may not always be up-to-date + or accurate. When you assign yourself to documenting an + application, make sure you find out the latest status of + documentation by contacting the application author. + + + + + + + + + Installing and Using DocBook + + All documentation for the GNOME project is written in SGML + using the DocBook DTD. There are many advantages to using + this for documentation, not least of which is the single + source nature of SGML. To contribute to the GDP you should + learn to use DocBook. + + + NOTE + + To get started writing for the GDP you do not need to rush + out and learn DocBook - if you feel it is too much to handle + for now, you can submit plain ASCII text to the + gnome-doc-list mailing list + and a volunteer will mark it up for you. Seeing your + document marked up will also be a great way for you to start + learning DocBook. + + + + Installing DocBook + + Download and install the following DocBook Tools packages: jade, docbook, + jadetex, sgml-common, and stylesheets. (RPM users should note + that jade is platform dependent (eg. i386), while the other packages + are in the noarch + directory.) You can find more + information on DocBook Tools here. + + + If you are an Emacs user you may + want to grab the psgml package as well. This is a major mode + for editing sgml files in Emacs. + + + + + GDP Stylesheets + + The GDP uses its own DocBook stylesheets. To use the GDP + stylesheets, you should download the file + gdp-both.dsl from the gnome-docu/gdp/dsssl module in + CVS (or from + GDP Custom DSSSL Stylesheet)and copy it + + over the file + /usr/lib/sgml/stylesheets/cygnus-both.dsl. + Alternately, you can download and install the + gnome-doc-tools package which will set + up the stylesheets as well as the DTD discussed below. + + + + + + + GDP DTD (PNG Image Support) + + Due to some license issues involved with the creation of + gifs, the GNOME Documentation Project has decided to use the + PNG image format for all images in GNOME documentation. You + can read more about the issues involved with gifs at http://www.gnu.org/philosophy/gif.html. + + + The current DocBook DTD(3.1) does not include support for + embedding PNG images in your documents. Since the GDP uses + many screenshots in its documentation, we use our own + variation on the DocBook DTD which has PNG image support. + We encourage everybody to use this DTD instead of the + default DocBook DTD since your source document header and + your output document appearance subtly vary between the two + DTD's. To install the GDP custom DTD with PNG image support + by hand: + + + + + Download the + GDP DocBook DTD for PNG support and install it + where you keep your DTD's. (On Red Hat use /usr/lib/sgml/.) Note that + the 3.0 DTD is missing support for the + <legalnotice> tag, so it is + recommended that you use version 3.1 + + + + + Add the new DTD to your SGML CATALOG file. The location + of your SGML CATALOG file may vary depending upon your + distribution. (On Red Hat it is usually in + /usr/lib/sgml/CATALOG.) Add the following line to this + file: + +PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN" "png-support-3.0.dtd" + + If you are using the 3.1 DTD, use: + +PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN" "png-support-3.1.dtd" + + + + + + Alternately, you can download and install the + gnome-doc-tools package which will set + up the custom stylesheets and DTD for you. + + + To include PNG files in your documents, you will need to + indicate that you are using this special DTD. To do + this, use the following headers: + + + Articles: + +]]> + + + + Books: + +]]> + + + + + + + Editors + + There are many editors on Linux and UNIX systems available + to you. Which editor you use to work on the sgml documents + is completely up to you, as long as the editor is able to + preserve sgml and produce the source in a format that is + readable by everyone. + + + Probably the two most popular editors available are + Emacs and + vi. These and other editors are + used regularly by members of the GDP. Emacs has a major + mode, psgml, for editing sgml files which can save you time + and effort in adding and closing tags. You will find the + psgml package in DocBook Tools, which is the standard set of + tools for the GDP. You may find out more about DocBook Tools + in . + + + + + Creating Something Useful with your Docs + + The tools available in DocBook Tools allow you to convert + your sgml document to many different formats including html + and Postscript. The primary tool used to do the conversion + is an application called Jade. In + most cases you will not have to work directly with + Jade; Instead, you will use the + scripts provided by DocBook Tools. + + + To preview your DocBook document, it is easiest to convert + it to html. If you have installed the + DocBook tools described above, all you have to do is to run + the command $db2html + mydocument.sgml. If there are no sgml syntax + errors, this will create a directory mydocument and place the + resulting html files in it. The title page of the document + will typically be + mydocument/index.html. If you have + screenshots in your document, you will have to copy these + files into the mydocument directory by + hand. You can use any web browser to view your document. + Note that every time you run db2html, it + creates the mydocument directory over, so + you will have to copy the screenshots over each time. + + + You can also convert your document to PostScript by running + the command $db2ps + mydocument.sgml, after which you can print out or + view the resulting .ps file. + + + NOTE + + The html files you get will not look quite the same as the + documentation distributed with GNOME unless you have the + custom stylesheets installed on your machine. DocBook + Tools' default stylesheets will produce a different look + to your docs. You can read more about the GDP stylesheets + in . + + + + + + Images in DocBook Tools + + If your document uses images you will need to take note of a + few things that should take place in order for you to make + use of those images in your output. + + + The DocBook Tools scripts and applications are smart enough + to know that when you are creating html you will be using + PNG files and when you are creating Postscript you will be + using EPS files (you must use EPS with Postscript). + + + Thus, you should never explicitly + include the extension of the image file, since DocBook + Tools will automatically insert it for you. For example: + + + + My Image + + Sample GNOME Display + + + + +]]> + + You will notice in this example that the file + myfile.png was referred to as simply + myfile. Now when you run + db2html to create an html file, it will + automatically look for myfile.png in + the directory. + + + If you want to create PostScript ouput, you will need to create an + EPS version of your image file to be displayed in the + PostScript file. There is a simple script available which + allows you to change a PNG image into an EPS file + easily. You can download this file - img2eps - from http://people.redhat.com/dcm/sgml.html + (look for the img2eps section). Note that this script is + included in the gnome-doc-tools package, so if you are using + this package, you should already have + img2eps on you system. + + + + + Learning DocBook + + There are many resources available to help you learn DocBook. + The following resources on the web are useful for learning + DocBook: + + + + + http://www.docbook.org - Norman + Walsh's DocBook: The Definitive + Guide. Online O'Reilly book on using + DocBook. Contains an excellent element reference. May be + too formal for a beginner. + + + + + A Practical Introduction to DocBook + - The Open Source Writers Group's introduction to using + DocBook. This is an excellent HOW-TO type article on + getting started. + + + + + Getting Going with DocBook: Notes for + Hackers - Mark Galassi's introduction to DocBook + for hackers. This has to be one of the first + introductions to DocBook ever - still as good as it ever + was. + + + + + + FreeBSD Documentation Project Primer for New + Contributors - FreeBSD documentation project + primer. Chapter 4.2 provides a very good introduction to + writing documentation using DocBook. Note that it also + describes some custom extensions of DocBook; + fortunately, they are clearly marked as such. + + + + + Norman Walsh's book is also available in print. + + + The following sections of this document are designed to help + documentation authors write correct and consistent DocBook: + + + + + - Descriptions of + commonly used DocBook tags. + + + + + You may also discuss specific DocBook questions with GDP + members on the #docs IRC channel at irc.gnome.org and on the + gnome-doc-list mailing list. + + + + + + + + + + GDP Document Templates + + Templates for various types of GNOME documents are found in + . They are kept in CVS in + gnome-docu/gdp/templates. The easiest source to get them from + is probably the GDP + Document Templates web page, which is typically kept + completely up-to-date with CVS and has a basic description of + each file from CVS. + + + + + + + Screenshots + + Most GNOME documents will have screenshots of the particular + applet, application, GNOME component, or widget being + discussed. As discussed above in you + will need to install the special GDP DocBook DTD which + supports PNG images, the format used for all images in GNOME + documentation. For the basic DocBook structure used to insert + images in a document, see above. + + + Screenshot Appearance + + For all screenshots of windows that typically have border + decorations (e.g. applications and dialogs, but not applets + in a panel), GDP standards dictate + the appearance of the window. (This is to minimize possible + confusion to the reader, improve the appearance of GNOME + documents, and guarantee the screenshot is readable when + printed.) All screenshots should be taken with the SawFish + (formerly known as Sawmill) window manager using the + MicroGui theme and Helvetica 12pt font. (A different window + manager can be used provided the MicroGui theme is available + for this window manager and the appearance is identical to + that when using the SawFish window manager.) The default + GTK+ theme(gtk) and font (Helvetica 12 pt) should be used + for all screenshots. If you are unable to provide + screenshots in this form, you should create screenshots as + you wish them to appear and send them to the + + gnome-doc-list mailing list + requesting a GDP member reproduce these screenshots in the + correct format and email them to you. + + + + Screenshot Tools + + There are many tools for taking screenshots in + GNOME/Linux. Perhaps the most convenient is the + Screen-Shooter Applet. Just click + on the window icon in the applet and then on the window you + would like to take a screenshot of. (Note that + at the time of this writing, PNG images taken by + screenshooter do not appear properly in + Netscape or the + GNOME Help Browser. You + should save your screenshot as a GIF and + then use convert filename.gif + filename.png.) For applets + in a Panel, + xv can be used to crop the + screenshot to only include the relevant portion of the + Panel. Note that + xv and + gimp can both be used for taking + screenshots, cropping screenshots, and converting image + formats. + + + + Screenshot Files + + Screenshots should be kept in the main documentation + directory with your SGML file for applets, or should be + kept in a directory called "figs" for application and other + documentation. After you use db2html to + convert your SGML file to HTML (see ), you will need to copy your + screenshots (either the individual PNG files for applet + documentation, or the whole "figs" directory for other + documentation) into the newly created HTML directory. Note + that every time you use db2html the HTML + directory is erased and rewritten, so do not store your only + copy of the screenshots in that directory. If you wish to + create PostScript or PDF output, you will need to manually + convert the PNG images to EPS as described in , but will not need to copy these + images from their default location, as they are included + directly into the output(PostScript of PDF) file. + + + + + + + + + Application Bugs + + Documentation authors tend to investigate and test applets and + applications more thoroughly than most + users. Often documentation authors will discover one or + more bugs in the software. These bugs vary from small ones, + such as mis-spelled words or missing + About dialogs in the menu, to large + ones which cause the applet to crash. As all users, you + should be sure to report these bugs so that application + developers know of them and can fix them. The easiest way to + submit a bug report is by using the Bug + Buddy applet which is part of the gnome-applets + package. + + + + + + + + Using CVS + + CVS (Concurrent Versions System) is a tool that allows + multiple developers to concurrently work on a set of + documents, keeping track of the modifications made by each + person. The files are stored on a server and each developer + checks files out, modifies them, and then checks in their + modified version of the files. Many GNOME programs and + documents are stored in CVS. The GNOME CVS server allows + users to anonymously check out CVS files. Most GDP members + will need to use anonymous CVS to download the most up-to-date + version of documentation or programs. Modified documents will + typically be emailed to the the application developer. Core + GDP members may also be granted login CVS privileges so they + may commit modified files directly to CVS. + + + + Anonymous CVS + + To anonymously check out documents from CVS, you must first + log in. From the bash shell, you should set your CVSROOT + shell variable with export + CVSROOT=':pserver:anonymous@anoncvs.gnome.org:/cvs/gnome' + and then login with cvs login(there is no + password, just hit return). As an example, we will use the + "gnome-docu/gdp" module which contains this and several + other documents. To check these documents out for the first + time, type cvs -z3 checkout + gnome-docu/gdp. After you have this document + checked out and you would like to download any updates on + the CVS server, use cvs -z3 update -Pd. + + + + + Login CVS If you have been given a + login for the GNOME CVS server, you may commit your file + modifications to CVS. Be sure to read the following section + on CVS etiquette before making any commits to CVS. To log in + to the CVS server as user + username with a + password, you must first set your CVSROOT shell variable with + export + CVSROOT=':pserver:username@cvs.gnome.org:/cvs/gnome'. + Log in with cvs login and enter your + password. You may check out and update modules as described + above for anonymous CVS access. As a login CVS user, you may + also check modified versions of a file into the CVS server. + To check + filename into + the CVS server, type cvs -z3 commit + filename. You will be + given a vi editor window to type in a brief log entry, + summarizing your changes. The default editor can be changed + using the EDITOR environment variable or + with the option. You + may also check in any modifications to files in the working + directory and subdirectories using cvs -z3 + commit. To + add a new file to the CVS server, use cvs -z3 add + filename, followed by the + commit command. + + + + + CVS Etiquette + + Because files in CVS are typically used and modified by + multiple developers and documentation authors, users should + exercise a few simple practices out of courtesy towards the + other CVS users and the project leader. First, you should + not make CVS commits to a package without first discussing + your plans with the project leader. This way, the project + leader knows who is modifying the files and generally, what + sort of changes/development is being done. Also, whenever a + CVS user commits a file to CVS, they should make an entry in + the CVS log and in the ChangeLog so + that other users know who is making modifications and what + is being modified. When modifying files created by others, + you should follow the indentation scheme used by the initial + author. + + + + + + + + + The GNOME Documentation System + + + + + The GNOME Help Browser + + At the core of the GNOME help system is the GNOME + Help Browser. The Help + Browser provides a unified interface to several + distinct documentation systems on Linux/Unix systems: man + pages, texinfo pages, Linux Documentation Project(LDP) + documents, GNOME application documentation, and other GNOME + documents. + + + The GNOME Help Browser works by + searching standard directories for documents which are to be + presented. Thus, the documentation that appears in the GHB is + specific to each computer and will typically only represent + software that is installed on the computer. + + + + + + + The GNOME Help Browser (GNOME-2.0) In + GNOME 2.0, the GNOME Help Browser + will be replaced by Nautilus. + Nautilus will be the file manager/graphical shell for GNOME 2.0 + and will also implement a more sophisticated help system than + that used by the GNOME Help Browser + used in GNOME 1.0. It will read and display DocBook files + directly, avoiding the need for duplicating documents in both + DocBook and HTML formats. Its display engine for DocBook will + be much faster than running jade to + convert to HTML for rendering. Because it uses the original + DocBook source for documentation, it will be possible to do more + sophisticated searching using the meta information included in + the documents. And since Nautilus is a virtual file system + layer which is Internet-capable, it will be able to find and + display documents which are on the web as well as those on the + local file system. For more information on + Nautilus, visit the #nautilus IRC + channel on irc.gnome.org. + + + + + + Dynamic Document Synthesis(GNOME-2.0) + + GNOME uses the documentation presented by all the various + GNOME components and applications installed on the system to + present a complete and customized documentation environment + describing only components which are currently installed on a + users system. Some of this documentation, such as the manuals + for applets, will be combined in such a way that it appears to + be a single document. + + + By using such a system, you can be sure that any GNOME app you + install that has documentation will show up in the index, + table of contents, any search you do in the help browser. + + + + + + + The GNOME Documentation Components + + + Application Manuals + + Every GNOME application should have an application manual. + An application manual is a document specific to the + particular application which explains the various windows + and features of the application. Application Manuals + typically use screenshots (PNG format) for clarity. Writing + application manuals is discussed in more detail in below. + + + + + Application Help + + Applications should have a Help + button on screens on which users may need help. These + Help buttons should pull up the + default help browser, determined by the + ghelp URL Handler (configured using the + Control Center), typically the + GNOME Help Browser. The help + browser should show either the first page of the application + manual, or else the relevant page thereof. Application help + is described in more detail in below. + + + + + Application Context Sensitive Help (coming in + GNOME-2.0) + + Context sensitive help is a system which will allow the user + to query any part (button, widget, etc.) of an application + window. This is done by either entering a CS Help mode by + clicking on an icon or by right clicking on the application + part and selecting "What's This" or whatever is decided on + at the time. Context sensitive help is described in more + detail in + below. + + + + + The GNOME User Guide + + The GNOME User Guide describes the + GNOME desktop environment and core components of GNOME such + as the panel and + control center. In GNOME 1.x this + was the main and only source of documentation. In GNOME 2.0 + this will become a document for the web and for printing + that is derived from various parts chosen in the system that + are necessary for the new user to understand. + + + + + User Documents + + Aside from the GNOME User Guide, + there are several other documents to help GNOME users learn + GNOME, including the GNOME FAQ, + GNOME Installation and Configuration + Guide, and the GNOME Administrators + Guide. + + + + + Developer Documents + + There are many White Papers, Tutorials, HOWTO's and FAQ's to + make programming GNOME and GNOME applications as easy as + possible. + + + API documentation is also available for the GNOME libraries. This is + detailed documentation of the code that is used to build GNOME + apps. You can keep up with the GNOME API docs on the GNOME API + Reference page. + + + + + Project Documents + + Some GNOME projects have documentation to maintain + consistency in their product and to help new contributors + get up to speed quickly. Among these are the GDP documents, + such as the one you are reading now. + + + + + + + + + + DocBook Basics + + + + Introduction to DocBook + + To understand DocBook, a basic understanding of SGML is + helpful. SGML stands for Standard General Markup Language and + is one of the first markup languages every created. HTML is + actually derived from SGML and XML is a subset of SGML. SGML + uses what is called a Document Type Definition to specify + elements which are contained between + brackets, < and >. Text is marked by both beginning and + ending elements, for example in the DocBook DTD, one denotes a + title with <title>The + Title</title>. + + + The DTD (in the case of the GDP, DocBook) defines rules for how the + elements can be used. For example, if one element can only be used when + embedded within another, this is defined in the DTD. + + + An SGML file is just a plain ASCII file containing the text + with the markup specified above. To convert it to some easily + readable format, you need special tools. The GDP uses DocBook + Tools, a free package of utilities for working with DocBook + which includes Jade, which does the SGML/DSSL + parsing. You can read more about DocBook Tools in . + + + The final appearance of the output (e.g. PostScript or HTML) + is determined by a + stylesheet. Stylesheets are files, + written in a special language (DSSSL — Document Style + Semantics and Specification Language), which specify the + appearance of various DocBook elements, for example, + what fonts to use for titles and various inline elements, page + numbering style, and much more. DocBook tools come with a + collection of stylesheets (Norman Walsh's modular + stylesheets); GNOME Document Project uses some customized + version of this stylesheets — see . + + + The advantage of specifying the structure + of a document with SGML instead of specifying the + appearance of the document with a typical + word processor, or with html, is that the resulting document + can be processed in a variety of ways using the structural + information. Whereas formatting a document for appearance + assumes a medium (typically written text on a standard-sized + piece of paper), SGML can be processed to produce output for a + large variety of media such as text, postscript, HTML, + Braille, audio, and potentially many other formats. + + + Using 'content' as the elements to define the text of a document also + allows for search engines to make use of the actual elements to make a + "smarter search". For example, if you are searching for all documents + written by the author "Susie" your search engine could be made smart + enough to only search <author> elements, making for a faster and more + accurate search. + + + Since the overall appearance of the output is determined not by the DTD + or the SGML document, but rather by a stylesheet, the appearance of a + document can be easily changed just by changing the stylesheet. This + allows everyone in the project to create documents that all look the + same. + + + As stated before, the GDP uses the DocBook DTD. For a list of + introductory and reference resources on DocBook, see . The following sections also provide + convenient instructions on which markup tags to use in various + circumstances. Be sure to read + for GDP documentation-specific guidelines. + + + + + + XML and SGML + + In not so distant future (probably before GNOME 2.0), + DocBook itself and GNOME Documentation project will migrate from + SGML to XML. This transition should be relatively painless: + (almost) all DocBook tags will remain the same. However, XML has + stricter syntax rules than SGML; thus, some constructions which + are valid in SGML will not be valid in XML. Therefore, to be + ready for this transistion, it is strongly + advised that the documentation writers conform to XML + syntax rules. Here are most important differences: + + + + + Minimization + + + + It is possible with some implementations of SGML to use + minimizations to close elements in a document by using + </>, for example: + <title>The + Title</>. This is not + allowed in XML. You can use sgmlnorm command, + included in DocBook Tools package, to expand minimized tags; + if you are using Emacs with psgml + mode, you can also use menu command + + Modify + Normalize + . + + + + + Self-closing tags + + + + Also, in SGML some tags are allowed not to have closing + tags. For example, it is legal for + <xref> not to have a closing tag: + <xref + linkend="someid">. In + XML, it is illegal; instead, you should use + <xref + linkend="someid"/> (note the + slash!). + + + + + + Case sensitive tags + + + In XML, unlike SGML, tags are case-senstive + <title> and + <TITLE> are different tags! + Therefore, please always use lowercase tags (except for + things like DOCTYPE, CDATA and + ENTITY, which are not DocBook tags). + + + + + + + + + + + + + + + Structure Elements + + + Sections and paragraphs + + Top-level element of a book body must be + <chapter>; it may contain one or more + <sect1>, each of them may contain + <sect2> and so on up to + <sect5>. The top-level element of an + article body is always + <sect1>. Regardless of which elements + you use, give each structural element a unique id, so that + you can link to it. For usage example, see the template. + + Please try to avoid using deeply nested sections; for + most situations, <sect1> and + <sect2> should be sufficient. If not, + you probably should split your <sect1> + into several smaller ones. + + Use the tag <para> for + paragraphs, even if there is only one paragraph in a + section—see template for examples. + + + + + Notes, Warnings, And Tips + + For notes, tips, warnings, and important information, which + should be set apart from the main text (usually as a + paragraph with some warning sign on the margin), use tags + <note>, <tip>, + <warning>, + <important> respectively. For example: + + + TIP + + To speed up program compilation, use gcc + compiler with Pentium optimization. + +]]> produces + + + TIP + + To speed up program compilation, use + gcc compiler with Pentium + optimization. + + + Note that this should not be inside a + <para> but between paragraphs. + + + + Screenshots and other figures + + To include screenshots and other figures, use the following + tags: + + + + Screenshot + + Screenshot of a program + + + +]]> + + replacing example_screenshot with the + actual file name (without extension). The result will look like this: + +
+ Screenshot + + Screenshot of a program + + + +
+
+ + NOTE + + Notice in this example that the screenshot file name does + not include the file type extension — to find out + why, please read . + + +
+ + Program listings and terminal session + To show a file fragment—for example, program + listing—use <programlisting> tag: + + +[Desktop Entry] +Name=Gnumeric spreadsheet +Exec=gnumeric +Icon=gnome-gnumeric.png +Terminal=0 +Type=Application +]]> + + which produces + +[Desktop Entry] +Name=Gnumeric spreadsheet +Exec=gnumeric +Icon=gnome-gnumeric.png +Terminal=0 +Type=Application + + As a matter of fact, all examples in this document were + produced using <programlisting>. + + + To show a record of terminal session—i.e., sequence of + commands entered at the command line—use + <screen> tag: + + +bash$make love +make: *** No rule to make target `love'. Stop. +]]> + + which produces + +bash$make love +make: *** No rule to make target `love'. Stop. + + Note the use of tags <prompt> and + <userinput> for marking system prompt + and commands entered by user. + + NOTE + + Note that both <programlisting> + and <screen> preserve linebreaks, + but interpret SGML tags (unlike LaTeX + verbatim environment). Take a look at + the source of this document to see how you can have SGML + tags literally shown but not interpreted, + + + + + + Lists + + The most common list types in DocBook are + <itemizedlist>, + <orderedlist>, and + <variablelist>. + + + + <itemizedlist> + + This is the simplest unnumbered list, parallel to + <ul> in HTML. Here is an example: + + + + + Show backup files — This will + show any backup file that might be on your system. + + + + + Show hidden files — This will + show all "dot files" or files that begin with a dot. This + files typically include configuration files and directories. + + + + + Mix files and directories — This + option will display files and directories in the order you + sort them instead of + always having directories shown above files. + + + +]]> + + and output: + + + + + Show backup files — + This will show any backup file that might be on + your system. + + + + + + Show hidden files — + This will show all "dot files" or files that + begin with a dot. This files typically include + configuration files and directories. + + + + + + Mix files and directories + — This option will display files and + directories in the order you sort them instead + of always having directories shown above files. + + + + Note the use of &mdash; + for long dash (see ). Also, + please note that the result looks much nicer because the + terms being explained (Show backup + files, etc.) are set in a different font. In + this case, it was achieved by using <guilabel> + tag. In other cases, use appropriate tags such as + <guimenuitem>, + <command>, + or — if none of + this applies — use + <emphasis>. + + + + + <orderedlist> + + This list is completely analogous to + <itemizedlist> and has the same + syntax, but it produces numbered list. By default, + this list uses Arabic numerals for numbering entries; + you can override this using numeration, + for example <orderedlist + numeration="lowerroman">. Possible values of + these attribute are arabic, + upperalpha, + loweralpha, + upperroman, + lowerroman. + + + + + <variablelist> + This list is used when each entry is + rather long, so it should be formatted as a block of text + with some subtitle, like a small subsection. The + <variablelist> is more complicated + than itemizedlists, but for larger blocks of text, or when + you're explaining \ No newline at end of file diff --git a/fuzz/seed_corpus/23aefbf61990ccfb3812eb85aa16969aa9c741e5 b/fuzz/seed_corpus/23aefbf61990ccfb3812eb85aa16969aa9c741e5 new file mode 100644 index 000000000000..d1dc9c48dfc4 --- /dev/null +++ b/fuzz/seed_corpus/23aefbf61990ccfb3812eb85aa16969aa9c741e5 @@ -0,0 +1,8 @@ + + + + + + diff --git a/fuzz/seed_corpus/23e1b677b9923e2d7d3351edbfb6d6f3f900968f b/fuzz/seed_corpus/23e1b677b9923e2d7d3351edbfb6d6f3f900968f new file mode 100644 index 000000000000..5a1e6608cbbb --- /dev/null +++ b/fuzz/seed_corpus/23e1b677b9923e2d7d3351edbfb6d6f3f900968f @@ -0,0 +1,59 @@ + + + + +Purchase order schema for Example.com. + Copyright 2000 Example.com. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/24112ff255332818fa2c677b91428aebcfa2771e b/fuzz/seed_corpus/24112ff255332818fa2c677b91428aebcfa2771e new file mode 100644 index 000000000000..f81aca1ae870 --- /dev/null +++ b/fuzz/seed_corpus/24112ff255332818fa2c677b91428aebcfa2771e @@ -0,0 +1,13 @@ + + + + Example of using a mask + + + + + + + + diff --git a/fuzz/seed_corpus/243261fb3a9034eaf3108beef61b3f4acbabd2ff b/fuzz/seed_corpus/243261fb3a9034eaf3108beef61b3f4acbabd2ff new file mode 100644 index 000000000000..c889933118de --- /dev/null +++ b/fuzz/seed_corpus/243261fb3a9034eaf3108beef61b3f4acbabd2ff @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/246d63002273f1f18d853d41f1e078466918b0fa b/fuzz/seed_corpus/246d63002273f1f18d853d41f1e078466918b0fa new file mode 100644 index 000000000000..4abd17d846de --- /dev/null +++ b/fuzz/seed_corpus/246d63002273f1f18d853d41f1e078466918b0fa @@ -0,0 +1 @@ + 1.2 3.4 5 6 diff --git a/fuzz/seed_corpus/24d5c3998d909457df8a5ebda0d2f13ce97bb75a b/fuzz/seed_corpus/24d5c3998d909457df8a5ebda0d2f13ce97bb75a new file mode 100644 index 000000000000..fdab0856897a --- /dev/null +++ b/fuzz/seed_corpus/24d5c3998d909457df8a5ebda0d2f13ce97bb75a @@ -0,0 +1,10 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:e1] + diff --git a/fuzz/seed_corpus/24e96912408f5d59c13dcd310a0a0399bafc427a b/fuzz/seed_corpus/24e96912408f5d59c13dcd310a0a0399bafc427a new file mode 100644 index 000000000000..11a2df34f9bd --- /dev/null +++ b/fuzz/seed_corpus/24e96912408f5d59c13dcd310a0a0399bafc427a @@ -0,0 +1,2 @@ + +
violates [ WFC: Element Type Match ]
diff --git a/fuzz/seed_corpus/2526e9fd2e7dc170f96a1138764506f28d213770 b/fuzz/seed_corpus/2526e9fd2e7dc170f96a1138764506f28d213770 new file mode 100644 index 000000000000..b06b4e757346 --- /dev/null +++ b/fuzz/seed_corpus/2526e9fd2e7dc170f96a1138764506f28d213770 @@ -0,0 +1,5 @@ + + This should fail + diff --git a/fuzz/seed_corpus/257b66031fd4022497978b05e01f4157af963b1c b/fuzz/seed_corpus/257b66031fd4022497978b05e01f4157af963b1c new file mode 100644 index 000000000000..5864343837c2 --- /dev/null +++ b/fuzz/seed_corpus/257b66031fd4022497978b05e01f4157af963b1c @@ -0,0 +1 @@ +x diff --git a/fuzz/seed_corpus/258200972a08001ab73d3a9cc1bca434edf8ac54 b/fuzz/seed_corpus/258200972a08001ab73d3a9cc1bca434edf8ac54 new file mode 100644 index 000000000000..630b0df3cfd4 --- /dev/null +++ b/fuzz/seed_corpus/258200972a08001ab73d3a9cc1bca434edf8ac54 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/fuzz/seed_corpus/268941309b3d09b155480b78c886976d9eac0658 b/fuzz/seed_corpus/268941309b3d09b155480b78c886976d9eac0658 new file mode 100644 index 000000000000..cd40fb806c03 --- /dev/null +++ b/fuzz/seed_corpus/268941309b3d09b155480b78c886976d9eac0658 @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/26bb4c75d24f2a674163677f8af8f34c83f45b47 b/fuzz/seed_corpus/26bb4c75d24f2a674163677f8af8f34c83f45b47 new file mode 100644 index 000000000000..35c9dc7c0d4c --- /dev/null +++ b/fuzz/seed_corpus/26bb4c75d24f2a674163677f8af8f34c83f45b47 @@ -0,0 +1,5 @@ + + + + diff --git a/fuzz/seed_corpus/272d4ce45d79ec367eb0b3ba6fd637215c05cf3f b/fuzz/seed_corpus/272d4ce45d79ec367eb0b3ba6fd637215c05cf3f new file mode 100644 index 000000000000..f1cad85dde8d --- /dev/null +++ b/fuzz/seed_corpus/272d4ce45d79ec367eb0b3ba6fd637215c05cf3f @@ -0,0 +1,7 @@ + + + + + + diff --git a/fuzz/seed_corpus/279887432540854d81ed9214156f2e3a9860dd80 b/fuzz/seed_corpus/279887432540854d81ed9214156f2e3a9860dd80 new file mode 100644 index 000000000000..c6f8c542d6cd --- /dev/null +++ b/fuzz/seed_corpus/279887432540854d81ed9214156f2e3a9860dd80 @@ -0,0 +1,249 @@ + + + + + ]]> + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + + +]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + + +]]> + + + + + +

+ + + + + + +]]> + + + + + + + + + + +

+ + + + + +

+ +]]> +
+ + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + +]]> + + diff --git a/fuzz/seed_corpus/27bcdce6c0a5968b3d3b2820f22e9ab211bd1f66 b/fuzz/seed_corpus/27bcdce6c0a5968b3d3b2820f22e9ab211bd1f66 new file mode 100644 index 000000000000..e12b6204383c --- /dev/null +++ b/fuzz/seed_corpus/27bcdce6c0a5968b3d3b2820f22e9ab211bd1f66 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/27bfe8bc3ce62b01ae4b0e8073db7bb8dae1bacf b/fuzz/seed_corpus/27bfe8bc3ce62b01ae4b0e8073db7bb8dae1bacf new file mode 100644 index 000000000000..93fa4b84a0df --- /dev/null +++ b/fuzz/seed_corpus/27bfe8bc3ce62b01ae4b0e8073db7bb8dae1bacf @@ -0,0 +1,9 @@ + + + +]> + +
+ + diff --git a/fuzz/seed_corpus/27d3fdcc4901e5b6d3350fe46e495f78880b9615 b/fuzz/seed_corpus/27d3fdcc4901e5b6d3350fe46e495f78880b9615 new file mode 100644 index 000000000000..292f4f7a2435 --- /dev/null +++ b/fuzz/seed_corpus/27d3fdcc4901e5b6d3350fe46e495f78880b9615 @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/27f93269230c2cdac3686c0ef8bf494689e07148 b/fuzz/seed_corpus/27f93269230c2cdac3686c0ef8bf494689e07148 new file mode 100644 index 000000000000..6d5ffaa350e6 --- /dev/null +++ b/fuzz/seed_corpus/27f93269230c2cdac3686c0ef8bf494689e07148 @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/28c1d7135e399a43882ad2d71df0ecc354305bdf b/fuzz/seed_corpus/28c1d7135e399a43882ad2d71df0ecc354305bdf new file mode 100644 index 000000000000..67723d433360 --- /dev/null +++ b/fuzz/seed_corpus/28c1d7135e399a43882ad2d71df0ecc354305bdf @@ -0,0 +1,8 @@ + + + + + diff --git a/fuzz/seed_corpus/295eea46f015e02b3a518db800bf9fa93505773b b/fuzz/seed_corpus/295eea46f015e02b3a518db800bf9fa93505773b new file mode 100644 index 000000000000..155e2d2789fa --- /dev/null +++ b/fuzz/seed_corpus/295eea46f015e02b3a518db800bf9fa93505773b @@ -0,0 +1,11 @@ + + + + +]> + + &title; + This text is about XML, the &xml; and this is an embedded + + diff --git a/fuzz/seed_corpus/299d543a09f90c6aeeb787277cd870affd2a6645 b/fuzz/seed_corpus/299d543a09f90c6aeeb787277cd870affd2a6645 new file mode 100644 index 000000000000..e2ad0a655c67 --- /dev/null +++ b/fuzz/seed_corpus/299d543a09f90c6aeeb787277cd870affd2a6645 @@ -0,0 +1,1173 @@ + + + + + The Settings Manager in Adobe Flash Player 9.0.124.0 and earlier allows remote attackers to cause victims to unknowingly click on a link or dialog via access control dialogs disguised as normal graphical elements, as demonstrated by hijacking the camera or microphone, and related to "clickjacking." + + + + + + + + + + + + adobe-flash-click-hijacking(45721) + 1020996 + 31625 + ADV-2008-2764 + http://www.adobe.com/support/security/advisories/apsa08-08.html + 32163 + http://ha.ckers.org/blog/20081007/clickjacking-details/ + http://blog.guya.net/2008/10/07/malicious-camera-spying-using-clickjacking/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Heap-based buffer overflow in Mplayer.exe in Herosoft Inc. Hero DVD Player 3.0.8 allows user-assisted remote attackers to execute arbitrary code via an M3u file with a "long entry." NOTE: the provenance of this information is unknown; the details are obtained solely from third party information. + + + + + + + + + + + + + 31627 + 31933 + + + + + + + + + + Unspecified vulnerability in IBM Lotus Quickr 8.1 before Fix pack 1 (8.1.0.1) might allow attackers to cause a denial of service (system crash) via a "nonstandard URL argument" to the OpenDocument command. NOTE: due to lack of details from the vendor, it is not clear whether this is a vulnerability. + + + + + + + + + lotus-quickr-opendocument-dos(45692) + 31608 + ADV-2008-2753 + http://www-01.ibm.com/support/docview.wss?uid=swg27013341 + 32098 + + + + + + + + + + Unspecified vulnerability in IBM Lotus Quickr 8.1 before Fix pack 1 (8.1.0.1) allows a place manager to "demote or delete a place superuser group" via unknown vectors. + + + + + + + + + + + + lotus-quickr-placemanager-security-bypass(45694) + 31608 + ADV-2008-2753 + http://www-01.ibm.com/support/docview.wss?uid=swg27013341 + 32098 + + + + + + + + + + Unspecified vulnerability in IBM Lotus Quickr 8.1 before Fix pack 1 (8.1.0.1) allows editors to delete pages that were created by a different author via unknown vectors. + + + + + + + + + + + lotus-quickr-editor-security-bypass(45693) + 31608 + ADV-2008-2753 + http://www-01.ibm.com/support/docview.wss?uid=swg27013341 + 32098 + + + + + + + + + + Stack-based buffer overflow in the file parsing function in Tonec Internet Download Manager, possibly 5.14 and earlier, allows remote attackers to cause a denial of service (crash) and possibly execute arbitrary code via a crafted AppleDouble file containing a long string. NOTE: this is probably a different vulnerability than CVE-2005-2210. + + + + + + + + + internetdownloadmanager-file-bo(45711) + 31603 + http://downloads.securityfocus.com/vulnerabilities/exploits/31603.pl + + + + + + + + + + Unrestricted file upload vulnerability in processFiles.php in FOSS Gallery Admin and FOSS Gallery Public 1.0 beta allows remote attackers to execute arbitrary code by uploading a file with an executable extension, then accessing it via a direct request to the file in the root directory. + + + + + + + + + + + + fossgallery-multiple-file-upload(45683) + 31574 + 6680 + 6674 + 6670 + + + + + + + + + + + + Microsoft Windows Vista Home and Ultimate Edition SP1 and earlier allows local users to cause a denial of service (page fault and system crash) via multiple attempts to access a virtual address in a PAGE_NOACCESS memory page. + + + + + + + + + 31570 + 6671 + 32115 + + + + + + + + + + + + + + + + + + Todd Woolums ASP News Management, possibly 2.21, stores db/news.mdb under the web root with insufficient access control, which allows remote attackers to obtain sensitive information via a direct request. + + + + + + + + + 20080927 ASP News Remote Password Disclouse Vulnerability + + + + + + + + + + ASP/MS Access Shoutbox, probably 1.1 beta, stores db/shoutdb.mdb under the web root with insufficient access control, which allows remote attackers to obtain sensitive information via a direct request. + + + + + + + + + 20080927 shoutbox Remote Password Disclouse Vulnerability + + + + + Cross-site scripting (XSS) vulnerability in BBcode API module in Phorum 5.2.8 allows remote attackers to inject arbitrary web script or HTML via nested BBcode image tags. + + + + + + + + + + phorum-img-xss(45686) + 31589 + http://trac.phorum.org/changeset/3528 + http://nulledcore.com/?p=126 + + + + + + + + + + The HTML parser in KDE Konqueror 3.5.9 allows remote attackers to cause a denial of service (application crash) via a font tag with a long color value, which triggers an assertion error. + + + + + + + + + 31605 + 6689 + + + + + + + + + + Blue Coat K9 Web Protection 4.0.230 Beta relies on client-side JavaScript as a protection mechanism, which allows remote attackers to bypass authentication and access the (1) summary, (2) detail, (3) overrides, and (4) pwemail pages by disabling JavaScript. + + + + + + + + + + + k9webprotection-multiple-auth-bypass(45696) + 31584 + 20081004 Blue Coat K9 Web Protection V4.0.230 Beta Vulnerability + http://dicas3000.blogspot.com/2008/10/blue-coat-k9-web-protection-v40230-beta.html + + + + + + + + + + SQL injection vulnerability in galerie.php in Galerie 3.2 allows remote attackers to execute arbitrary SQL commands via the pic parameter. + + + + + + + + + + + + galerie-pic-sql-injection(45698) + 31593 + 6675 + + + + + + + + + + SQL injection vulnerability in leggi.php in geccBBlite 2.0 allows remote attackers to execute arbitrary SQL commands via the id parameter. + + + + + + + + + + + + 31585 + 6677 + + + + + + + + + + Multiple SQL injection vulnerabilities in Fastpublish CMS 1.9.9.9.9 d (1.9999 d) allow remote attackers to execute arbitrary SQL commands via the (1) sprache parameter to index2.php and the (2) artikel parameter to index.php. + + + + + + + + + + + + 31582 + 6678 + 32126 + + + + + + + + + + + Multiple directory traversal vulnerabilities in Fastpublish CMS 1.9999 d allow remote attackers to include and execute arbitrary local files via a .. (dot dot) in the target parameter to (1) index2.php and (2) index.php. + + + + + + + + + + + 31582 + 6678 + 32126 + + + + + + + + + + + Cross-site scripting (XSS) vulnerability in bulk_update.pl in AutoNessus before 1.2.2 allows remote attackers to inject arbitrary web script or HTML via the remark parameter. + + + + + + + + + + 31559 + http://sourceforge.net/project/shownotes.php?group_id=216367&release_id=630124 + autonessus-bulkupdate-xss(45634) + http://sourceforge.net/tracker/index.php?func=detail&aid=2141884&group_id=216367&atid=1037394 + 32046 + http://autonessus.cvs.sourceforge.net/viewvc/autonessus/AutoNessus/www/bulk_update.pl?r1=1.2&r2=1.3 + + + + + + + + + + + + + + SQL injection vulnerability in thisraidprogress.php in the World of Warcraft tracker infusion (raidtracker_panel) module 2.0 for PHP-Fusion allows remote attackers to execute arbitrary SQL commands via the INFO_RAID_ID parameter. + + + + + + + + + + + + 31579 + 6682 + + + + + + + + + + Multiple directory traversal vulnerabilities in JMweb MP3 Music Audio Search and Download Script allow remote attackers to include and execute arbitrary local files via a .. (dot dot) in the src parameter to (1) listen.php and (2) download.php. + + + + + + + + + + + + 31573 + 6669 + 32141 + + + + + + + + + + SQL injection vulnerability in login.php in IP Reg 0.4 and earlier allows remote attackers to execute arbitrary SQL commands via the user_name parameter. + + + + + + + + + + + + ipreg-login-sql-injection(45641) + 31561 + 6657 + + + + + + + + + + + + + SQL injection vulnerability in the "Check User" feature (includes/check_user.php) in AdaptCMS Lite and AdaptCMS Pro 1.3 allows remote attackers to execute arbitrary SQL commands via the user_name parameter. + + + + + + + + + + + + http://www.adaptcms.com/article/51/News/URGENT-AdaptCMS-13-Security-Fix-Released/ + 32171 + adaptcmslite-checkuser-sql-injection(45642) + 31557 + 6662 + + + + + + + + + + + + SQL injection vulnerability in index.php in AmpJuke 0.7.5 allows remote attackers to execute arbitrary SQL commands via the special parameter in a performerid action. + + + + + + + + + + + + 31592 + 32168 + http://packetstorm.linuxsecurity.com/0810-exploits/ampjuke-sql.txt + + + + + + + + + + Multiple directory traversal vulnerabilities in CCMS 3.1 allow remote attackers to include and execute arbitrary local files via a .. (dot dot) in the skin parameter to (1) index.php, (2) forums.php, (3) admin.php, (4) header.php, (5) pages/story.php and (6) pages/poll.php. + + + + + + + + + + + 31566 + 6663 + + + + + + + + + + SQL injection vulnerability in recept.php in the Recepies (Recept) module 1.1 for PHP-Fusion allows remote attackers to execute arbitrary SQL commands via the kat_id parameter in a kategorier action. NOTE: some of these details are obtained from third party information. + + + + + + + + + + + + 31578 + 6683 + 32004 + + + + + + + + + + Directory traversal vulnerability in notes.php in Phlatline's Personal Information Manager (pPIM) 1.01 allows remote attackers to include and execute arbitrary local files via a .. (dot dot) in the id parameter in an edit action. + + + + + + + + + + + + 31571 + 6667 + + + + + + + + + + Multiple PHP remote file inclusion vulnerabilities in asiCMS alpha 0.208 allow remote attackers to execute arbitrary PHP code via a URL in the _ENV[asicms][path] parameter to (1) Association.php, (2) BigMath.php, (3) DiffieHellman.php, (4) DumbStore.php, (5) Extension.php, (6) FileStore.php, (7) HMAC.php, (8) MemcachedStore.php, (9) Message.php, (10) Nonce.php, (11) SQLStore.php, (12) SReg.php, (13) TrustRoot.php, and (14) URINorm.php in classes/Auth/OpenID/; and (15) XRDS.php, (16) XRI.php and (17) XRIRes.php in classes/Auth/Yadis/. + + + + + + + + + + + + 31601 + 6685 + + + + + + + + + + Cross-site scripting (XSS) vulnerability in Brilliant Gallery 5.x before 5.x-4.2, a module for Drupal, allows remote authenticated users with permissions to inject arbitrary web script or HTML via unspecified vectors related to posting of answers. + + + + + + + + + + http://drupal.org/node/315919 + brilliantgallery-unspecified-xss(45636) + 31554 + 32106 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SQL injection vulnerability in Brilliant Gallery 5.x before 5.x-4.2, a module for Drupal, allows remote attackers to execute arbitrary SQL commands via unspecified vectors, related to queries. NOTE: this might be the same issue as CVE-2008-4338. + + + + + + + + + + + brilliantgallery-unspecified-sql-injection(45637) + 31554 + 32106 + http://drupal.org/node/315919 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cross-site scripting (XSS) vulnerability in index.php in MaxiScript Website Directory allows remote attackers to inject arbitrary web script or HTML via the keyword parameter in a search action. + + + + + + + + + + websitedirectory-index-xss(45657) + 31562 + 20081003 Website Directory - XSS Exploit + 32176 + + + + + + + + + + Heap-based buffer overflow in the mch_expand_wildcards function in os_unix.c in Vim 6.2 and 6.3 allows user-assisted attackers to execute arbitrary code via shell metacharacters in filenames, as demonstrated by the netrw.v3 test case. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + [oss-security] 20080731 Re: Re: More arbitrary code executions in Netrw + [oss-security] 20080715 Re: Re: More arbitrary code executions in Netrw + ftp://ftp.vim.org/pub/vim/patches/6.3/6.3.059 + ftp://ftp.vim.org/pub/vim/patches/6.2.429 + + + + + + + + + + + The Hewlett-Packard Graphics Language (HPGL) filter in CUPS before 1.3.9 allows remote attackers to execute arbitrary code via crafted pen width and pen color opcodes that overwrite arbitrary memory. + + + + + + + + + + + 31681 + http://www.cups.org/articles.php?L575 + RHSA-2008:0937 + MDVSA-2008:211 + ADV-2008-2782 + http://www.cups.org/str.php?L2911 + 32226 + 32084 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Buffer overflow in ColorSync in Mac OS X 10.4.11 and 10.5.5 allows remote attackers to cause a denial of service (application termination) and possibly execute arbitrary code via an image with a crafted ICC profile. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + + + Unspecified vulnerability in Finder in Mac OS X 10.5.5 allows user-assisted attackers to cause a denial of service (continuous termination and restart) via a crafted Desktop file that generates an error when producing its icon, related to an "error recovery issue." + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + Heap-based buffer overflow in the local IPC component in the EAPOLController plugin for configd (Networking component) in Mac OS X 10.4.11 and 10.5.5 allows local users to execute arbitrary code via unknown vectors. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + + + The Postfix configuration file in Mac OS X 10.5.5 causes Postfix to be network-accessible when mail is sent from a local command-line tool, which allows remote attackers to send mail to local Mac OS X users. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + Buffer overflow in PSNormalizer in Mac OS X 10.4.11 and 10.5.5 allows remote attackers to cause a denial of service (application termination) and execute arbitrary code via a PostScript file with a crafted bounding box comment. + + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + + + Integer signedness error in QuickLook in Mac OS X 10.5.5 allows remote attackers to cause a denial of service (application termination) and execute arbitrary code via a crafted Microsoft Excel file that triggers an out-of-bounds memory access. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + Unspecified vulnerability in rlogind in the rlogin component in Mac OS X 10.4.11 and 10.5.5 applies hosts.equiv entries to root despite what is stated in documentation, which might allow remote attackers to bypass intended access restrictions. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + + + Unspecified vulnerability in Script Editor in Mac OS X 10.4.11 and 10.5.5 allows local users to cause the scripting dictionary to be written to arbitrary locations, related to an "insecure file operation" on temporary files. + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + + + + + + Weblog in Mac OS X Server 10.4.11 does not properly check an error condition when a weblog posting access control list is specified for a user that has multiple short names, which might allow attackers to bypass intended access restrictions. + + + + + + + + + + + + 31681 + APPLE-SA-2008-10-09 + + + + + + + + + + Multiple untrusted search path vulnerabilities in Portage before 2.1.4.5 include the current working directory in the Python search path, which allows local users to execute arbitrary code via a modified Python module that is loaded by the (1) ys-apps/portage, (2) net-mail/fetchmail, (3) app-editors/leo ebuilds, and other ebuilds. + + + + + + + + + + + + + + + + + + + Destination Number Length + + + + + + + + + + + destroy flag + + + + + + diff --git a/fuzz/seed_corpus/2a0b940c5134f02d3a32cf2cee38a74d5ab1c8fa b/fuzz/seed_corpus/2a0b940c5134f02d3a32cf2cee38a74d5ab1c8fa new file mode 100644 index 000000000000..719ba5f83c26 --- /dev/null +++ b/fuzz/seed_corpus/2a0b940c5134f02d3a32cf2cee38a74d5ab1c8fa @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/2a8b610bfb16745a14e58d879a9415b70fe60c3f b/fuzz/seed_corpus/2a8b610bfb16745a14e58d879a9415b70fe60c3f new file mode 100644 index 000000000000..9653bc377a15 --- /dev/null +++ b/fuzz/seed_corpus/2a8b610bfb16745a14e58d879a9415b70fe60c3f @@ -0,0 +1,8 @@ + + + (//. | //@* | //namespace::*) + [ + ancestor-or-self::n1:elem2 + ] + + \ No newline at end of file diff --git a/fuzz/seed_corpus/2a986afeaeece3a69206754e654d83221f3d4e3f b/fuzz/seed_corpus/2a986afeaeece3a69206754e654d83221f3d4e3f new file mode 100644 index 000000000000..8a7f679fce7d --- /dev/null +++ b/fuzz/seed_corpus/2a986afeaeece3a69206754e654d83221f3d4e3f @@ -0,0 +1,4 @@ + +]> + diff --git a/fuzz/seed_corpus/2adaf0d8e75c41100623c410be3dea8dd30b4d69 b/fuzz/seed_corpus/2adaf0d8e75c41100623c410be3dea8dd30b4d69 new file mode 100644 index 000000000000..374c038a98d1 --- /dev/null +++ b/fuzz/seed_corpus/2adaf0d8e75c41100623c410be3dea8dd30b4d69 @@ -0,0 +1,72 @@ + + + + + Testing duration data types + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/2b20f5ba42cc907d756768ad36e7d90ea1ec2625 b/fuzz/seed_corpus/2b20f5ba42cc907d756768ad36e7d90ea1ec2625 new file mode 100644 index 000000000000..740d0d35940b --- /dev/null +++ b/fuzz/seed_corpus/2b20f5ba42cc907d756768ad36e7d90ea1ec2625 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/2b29f5ebce426a5bbfe986324ba833b3b4eda61e b/fuzz/seed_corpus/2b29f5ebce426a5bbfe986324ba833b3b4eda61e new file mode 100644 index 000000000000..2bf5861efd67 --- /dev/null +++ b/fuzz/seed_corpus/2b29f5ebce426a5bbfe986324ba833b3b4eda61e @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/2b9b98aa420ec906d5b6da3234174e59b545b7d7 b/fuzz/seed_corpus/2b9b98aa420ec906d5b6da3234174e59b545b7d7 new file mode 100644 index 000000000000..828c4b33e8ad --- /dev/null +++ b/fuzz/seed_corpus/2b9b98aa420ec906d5b6da3234174e59b545b7d7 @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/fuzz/seed_corpus/2bf06d0674a90839c365de7cd703f2cf371cb39c b/fuzz/seed_corpus/2bf06d0674a90839c365de7cd703f2cf371cb39c new file mode 100644 index 000000000000..1962ca1ee13e --- /dev/null +++ b/fuzz/seed_corpus/2bf06d0674a90839c365de7cd703f2cf371cb39c @@ -0,0 +1,1633 @@ + + + + + + + + + + + + + + + + +"> + +'"> + + + + + + + + + +amp, +lt, +gt, +apos, +quot"> + + + + + +]> + + + + + +
+Extensible Markup Language (XML) 1.0 + +REC-xml-&iso6.doc.date; +W3C Recommendation +&draft.day;&draft.month;&draft.year; + + + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date; + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.xml + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.html + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.pdf + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.ps + + + +http://www.w3.org/TR/REC-xml + + + +http://www.w3.org/TR/PR-xml-971208 + + + +Tim Bray +Textuality and Netscape +tbray@textuality.com +Jean Paoli +Microsoft +jeanpa@microsoft.com +C. M. Sperberg-McQueen +University of Illinois at Chicago +cmsmcq@uic.edu + + +

The Extensible Markup Language (XML) is a subset of +SGML that is completely described in this document. Its goal is to +enable generic SGML to be served, received, and processed on the Web +in the way that is now possible with HTML. XML has been designed for +ease of implementation and for interoperability with both SGML and +HTML.

+
+ +

This document has been reviewed by W3C Members and +other interested parties and has been endorsed by the +Director as a W3C Recommendation. It is a stable +document and may be used as reference material or cited +as a normative reference from another document. W3C's +role in making the Recommendation is to draw attention +to the specification and to promote its widespread +deployment. This enhances the functionality and +interoperability of the Web.

+

+This document specifies a syntax created by subsetting an existing, +widely used international text processing standard (Standard +Generalized Markup Language, ISO 8879:1986(E) as amended and +corrected) for use on the World Wide Web. It is a product of the W3C +XML Activity, details of which can be found at http://www.w3.org/XML. A list of +current W3C Recommendations and other technical documents can be found +at http://www.w3.org/TR. +

+

This specification uses the term URI, which is defined by , a work in progress expected to update and . +

+

The list of known errors in this specification is +available at +http://www.w3.org/XML/xml-19980210-errata.

+

Please report errors in this document to +xml-editor@w3.org. +

+
+ + + +

Chicago, Vancouver, Mountain View, et al.: +World-Wide Web Consortium, XML Working Group, 1996, 1997.

+
+ +

Created in electronic form.

+
+ +English +Extended Backus-Naur Form (formal grammar) + + + +1997-12-03 : CMSMcQ : yet further changes +1997-12-02 : TB : further changes (see TB to XML WG, +2 December 1997) +1997-12-02 : CMSMcQ : deal with as many corrections and +comments from the proofreaders as possible: +entify hard-coded document date in pubdate element, +change expansion of entity WebSGML, +update status description as per Dan Connolly (am not sure +about refernece to Berners-Lee et al.), +add 'The' to abstract as per WG decision, +move Relationship to Existing Standards to back matter and +combine with References, +re-order back matter so normative appendices come first, +re-tag back matter so informative appendices are tagged informdiv1, +remove XXX XXX from list of 'normative' specs in prose, +move some references from Other References to Normative References, +add RFC 1738, 1808, and 2141 to Other References (they are not +normative since we do not require the processor to enforce any +rules based on them), +add reference to 'Fielding draft' (Berners-Lee et al.), +move notation section to end of body, +drop URIchar non-terminal and use SkipLit instead, +lose stray reference to defunct nonterminal 'markupdecls', +move reference to Aho et al. into appendix (Tim's right), +add prose note saying that hash marks and fragment identifiers are +NOT part of the URI formally speaking, and are NOT legal in +system identifiers (processor 'may' signal an error). +Work through: +Tim Bray reacting to James Clark, +Tim Bray on his own, +Eve Maler, + +NOT DONE YET: +change binary / text to unparsed / parsed. +handle James's suggestion about < in attriubte values +uppercase hex characters, +namechar list, + +1997-12-01 : JB : add some column-width parameters +1997-12-01 : CMSMcQ : begin round of changes to incorporate +recent WG decisions and other corrections: +binding sources of character encoding info (27 Aug / 3 Sept), +correct wording of Faust quotation (restore dropped line), +drop SDD from EncodingDecl, +change text at version number 1.0, +drop misleading (wrong!) sentence about ignorables and extenders, +modify definition of PCData to make bar on msc grammatical, +change grammar's handling of internal subset (drop non-terminal markupdecls), +change definition of includeSect to allow conditional sections, +add integral-declaration constraint on internal subset, +drop misleading / dangerous sentence about relationship of +entities with system storage objects, +change table body tag to htbody as per EM change to DTD, +add rule about space normalization in public identifiers, +add description of how to generate our name-space rules from +Unicode character database (needs further work!). + +1997-10-08 : TB : Removed %-constructs again, new rules +for PE appearance. +1997-10-01 : TB : Case-sensitive markup; cleaned up +element-type defs, lotsa little edits for style +1997-09-25 : TB : Change to elm's new DTD, with +substantial detail cleanup as a side-effect +1997-07-24 : CMSMcQ : correct error (lost *) in definition +of ignoreSectContents (thanks to Makoto Murata) +Allow all empty elements to have end-tags, consistent with +SGML TC (as per JJC). +1997-07-23 : CMSMcQ : pre-emptive strike on pending corrections: +introduce the term 'empty-element tag', note that all empty elements +may use it, and elements declared EMPTY must use it. +Add WFC requiring encoding decl to come first in an entity. +Redefine notations to point to PIs as well as binary entities. +Change autodetection table by removing bytes 3 and 4 from +examples with Byte Order Mark. +Add content model as a term and clarify that it applies to both +mixed and element content. + +1997-06-30 : CMSMcQ : change date, some cosmetic changes, +changes to productions for choice, seq, Mixed, NotationType, +Enumeration. Follow James Clark's suggestion and prohibit +conditional sections in internal subset. TO DO: simplify +production for ignored sections as a result, since we don't +need to worry about parsers which don't expand PErefs finding +a conditional section. +1997-06-29 : TB : various edits +1997-06-29 : CMSMcQ : further changes: +Suppress old FINAL EDIT comments and some dead material. +Revise occurrences of % in grammar to exploit Henry Thompson's pun, +especially markupdecl and attdef. +Remove RMD requirement relating to element content (?). + +1997-06-28 : CMSMcQ : Various changes for 1 July draft: +Add text for draconian error handling (introduce +the term Fatal Error). +RE deleta est (changing wording from +original announcement to restrict the requirement to validating +parsers). +Tag definition of validating processor and link to it. +Add colon as name character. +Change def of %operator. +Change standard definitions of lt, gt, amp. +Strip leading zeros from #x00nn forms. +1997-04-02 : CMSMcQ : final corrections of editorial errors +found in last night's proofreading. Reverse course once more on +well-formed: Webster's Second hyphenates it, and that's enough +for me. +1997-04-01 : CMSMcQ : corrections from JJC, EM, HT, and self +1997-03-31 : Tim Bray : many changes +1997-03-29 : CMSMcQ : some Henry Thompson (on entity handling), +some Charles Goldfarb, some ERB decisions (PE handling in miscellaneous +declarations. Changed Ident element to accept def attribute. +Allow normalization of Unicode characters. move def of systemliteral +into section on literals. +1997-03-28 : CMSMcQ : make as many corrections as possible, from +Terry Allen, Norbert Mikula, James Clark, Jon Bosak, Henry Thompson, +Paul Grosso, and self. Among other things: give in on "well formed" +(Terry is right), tentatively rename QuotedCData as AttValue +and Literal as EntityValue to be more informative, since attribute +values are the only place QuotedCData was used, and +vice versa for entity text and Literal. (I'd call it Entity Text, +but 8879 uses that name for both internal and external entities.) +1997-03-26 : CMSMcQ : resynch the two forks of this draft, reapply +my changes dated 03-20 and 03-21. Normalize old 'may not' to 'must not' +except in the one case where it meant 'may or may not'. +1997-03-21 : TB : massive changes on plane flight from Chicago +to Vancouver +1997-03-21 : CMSMcQ : correct as many reported errors as possible. + +1997-03-20 : CMSMcQ : correct typos listed in CMSMcQ hand copy of spec. +1997-03-20 : CMSMcQ : cosmetic changes preparatory to revision for +WWW conference April 1997: restore some of the internal entity +references (e.g. to docdate, etc.), change character xA0 to &nbsp; +and define nbsp as &#160;, and refill a lot of paragraphs for +legibility. +1996-11-12 : CMSMcQ : revise using Tim's edits: +Add list type of NUMBERED and change most lists either to +BULLETS or to NUMBERED. +Suppress QuotedNames, Names (not used). +Correct trivial-grammar doc type decl. +Rename 'marked section' as 'CDATA section' passim. +Also edits from James Clark: +Define the set of characters from which [^abc] subtracts. +Charref should use just [0-9] not Digit. +Location info needs cleaner treatment: remove? (ERB +question). +One example of a PI has wrong pic. +Clarify discussion of encoding names. +Encoding failure should lead to unspecified results; don't +prescribe error recovery. +Don't require exposure of entity boundaries. +Ignore white space in element content. +Reserve entity names of the form u-NNNN. +Clarify relative URLs. +And some of my own: +Correct productions for content model: model cannot +consist of a name, so "elements ::= cp" is no good. + +1996-11-11 : CMSMcQ : revise for style. +Add new rhs to entity declaration, for parameter entities. +1996-11-10 : CMSMcQ : revise for style. +Fix / complete section on names, characters. +Add sections on parameter entities, conditional sections. +Still to do: Add compatibility note on deterministic content models. +Finish stylistic revision. +1996-10-31 : TB : Add Entity Handling section +1996-10-30 : TB : Clean up term & termdef. Slip in +ERB decision re EMPTY. +1996-10-28 : TB : Change DTD. Implement some of Michael's +suggestions. Change comments back to //. Introduce language for +XML namespace reservation. Add section on white-space handling. +Lots more cleanup. +1996-10-24 : CMSMcQ : quick tweaks, implement some ERB +decisions. Characters are not integers. Comments are /* */ not //. +Add bibliographic refs to 10646, HyTime, Unicode. +Rename old Cdata as MsData since it's only seen +in marked sections. Call them attribute-value pairs not +name-value pairs, except once. Internal subset is optional, needs +'?'. Implied attributes should be signaled to the app, not +have values supplied by processor. +1996-10-16 : TB : track down & excise all DSD references; +introduce some EBNF for entity declarations. +1996-10-?? : TB : consistency check, fix up scraps so +they all parse, get formatter working, correct a few productions. +1996-10-10/11 : CMSMcQ : various maintenance, stylistic, and +organizational changes: +Replace a few literals with xmlpio and +pic entities, to make them consistent and ensure we can change pic +reliably when the ERB votes. +Drop paragraph on recognizers from notation section. +Add match, exact match to terminology. +Move old 2.2 XML Processors and Apps into intro. +Mention comments, PIs, and marked sections in discussion of +delimiter escaping. +Streamline discussion of doctype decl syntax. +Drop old section of 'PI syntax' for doctype decl, and add +section on partial-DTD summary PIs to end of Logical Structures +section. +Revise DSD syntax section to use Tim's subset-in-a-PI +mechanism. +1996-10-10 : TB : eliminate name recognizers (and more?) +1996-10-09 : CMSMcQ : revise for style, consistency through 2.3 +(Characters) +1996-10-09 : CMSMcQ : re-unite everything for convenience, +at least temporarily, and revise quickly +1996-10-08 : TB : first major homogenization pass +1996-10-08 : TB : turn "current" attribute on div type into +CDATA +1996-10-02 : TB : remould into skeleton + entities +1996-09-30 : CMSMcQ : add a few more sections prior to exchange + with Tim. +1996-09-20 : CMSMcQ : finish transcribing notes. +1996-09-19 : CMSMcQ : begin transcribing notes for draft. +1996-09-13 : CMSMcQ : made outline from notes of 09-06, +do some housekeeping + + +
+ + +Introduction +

Extensible Markup Language, abbreviated XML, describes a class of +data objects called XML documents and +partially describes the behavior of +computer programs which process them. XML is an application profile or +restricted form of SGML, the Standard Generalized Markup +Language . +By construction, XML documents +are conforming SGML documents. +

+

XML documents are made up of storage units called entities, which contain either parsed +or unparsed data. +Parsed data is made up of characters, +some +of which form character data, +and some of which form markup. +Markup encodes a description of the document's storage layout and +logical structure. XML provides a mechanism to impose constraints on +the storage layout and logical structure.

+

A software module +called an XML processor is used to read XML documents +and provide access to their content and structure. It is assumed that an XML processor is +doing its work on behalf of another module, called the +application. This specification describes the +required behavior of an XML processor in terms of how it must read XML +data and the information it must provide to the application.

+ + +Origin and Goals +

XML was developed by an XML Working Group (originally known as the +SGML Editorial Review Board) formed under the auspices of the World +Wide Web Consortium (W3C) in 1996. +It was chaired by Jon Bosak of Sun +Microsystems with the active participation of an XML Special +Interest Group (previously known as the SGML Working Group) also +organized by the W3C. The membership of the XML Working Group is given +in an appendix. Dan Connolly served as the WG's contact with the W3C. +

+

The design goals for XML are: +

XML shall be straightforwardly usable over the +Internet.

+

XML shall support a wide variety of applications.

+

XML shall be compatible with SGML.

+

It shall be easy to write programs which process XML +documents.

+

The number of optional features in XML is to be kept to the +absolute minimum, ideally zero.

+

XML documents should be human-legible and reasonably +clear.

+

The XML design should be prepared quickly.

+

The design of XML shall be formal and concise.

+

XML documents shall be easy to create.

+

Terseness in XML markup is of minimal importance.

+

+

This specification, +together with associated standards +(Unicode and ISO/IEC 10646 for characters, +Internet RFC 1766 for language identification tags, +ISO 639 for language name codes, and +ISO 3166 for country name codes), +provides all the information necessary to understand +XML Version &XML.version; +and construct computer programs to process it.

+

This version of the XML specification + +&doc.distribution;.

+ +
+ + + + + +Terminology + +

The terminology used to describe XML documents is defined in the body of +this specification. +The terms defined in the following list are used in building those +definitions and in describing the actions of an XML processor: + + + +

Conforming documents and XML +processors are permitted to but need not behave as +described.

+ + + +

Conforming documents and XML processors +are required to behave as described; otherwise they are in error. + +

+
+ + +

A violation of the rules of this +specification; results are +undefined. Conforming software may detect and report an error and may +recover from it.

+
+ + +

An error +which a conforming XML processor +must detect and report to the application. +After encountering a fatal error, the +processor may continue +processing the data to search for further errors and may report such +errors to the application. In order to support correction of errors, +the processor may make unprocessed data from the document (with +intermingled character data and markup) available to the application. +Once a fatal error is detected, however, the processor must not +continue normal processing (i.e., it must not +continue to pass character data and information about the document's +logical structure to the application in the normal way). +

+
+ + +

Conforming software may or must (depending on the modal verb in the +sentence) behave as described; if it does, it must +provide users a means to enable or disable the behavior +described.

+
+ + +

A rule which applies to all +valid XML documents. +Violations of validity constraints are errors; they must, at user option, +be reported by +validating XML processors.

+
+ + +

A rule which applies to all well-formed XML documents. +Violations of well-formedness constraints are +fatal errors.

+
+ + + +

(Of strings or names:) +Two strings or names being compared must be identical. +Characters with multiple possible representations in ISO/IEC 10646 (e.g. +characters with +both precomposed and base+diacritic forms) match only if they have the +same representation in both strings. +At user option, processors may normalize such characters to +some canonical form. +No case folding is performed. +(Of strings and rules in the grammar:) +A string matches a grammatical production if it belongs to the +language generated by that production. +(Of content and content models:) +An element matches its declaration when it conforms +in the fashion described in the constraint +. + +

+
+ + +

A feature of +XML included solely to ensure that XML remains compatible with SGML. +

+
+ + +

A +non-binding recommendation included to increase the chances that XML +documents can be processed by the existing installed base of SGML +processors which predate the +&WebSGML;.

+
+ +

+
+ + +
+ + + +Documents + +

+A data object is an +XML document if it is +well-formed, as +defined in this specification. +A well-formed XML document may in addition be +valid if it meets certain further +constraints.

+ +

Each XML document has both a logical and a physical structure. +Physically, the document is composed of units called entities. An entity may refer to other entities to cause their +inclusion in the document. A document begins in a "root" or document entity. +Logically, the document is composed of declarations, elements, +comments, +character references, and +processing +instructions, all of which are indicated in the document by explicit +markup. +The logical and physical structures must nest properly, as described +in . +

+ + +Well-Formed XML Documents + +

+A textual object is +a well-formed XML document if: + +

Taken as a whole, it +matches the production labeled document.

+

It +meets all the well-formedness constraints given in this specification.

+
+

Each of the parsed entities +which is referenced directly or indirectly within the document is +well-formed.

+

+

+ +Document +document +prolog +element +Misc* + +

+

Matching the document production +implies that: + +

It contains one or more +elements.

+ + +

There is exactly +one element, called the root, or document element, no +part of which appears in the content of any other element. +For all other elements, if the start-tag is in the content of another +element, the end-tag is in the content of the same element. More +simply stated, the elements, delimited by start- and end-tags, nest +properly within each other. +

+ +

+

As a consequence +of this, +for each non-root element +C in the document, there is one other element P +in the document such that +C is in the content of P, but is not in +the content of any other element that is in the content of +P. +P is referred to as the +parent of C, and C as a +child of P.

+ + +Characters + +

A parsed entity contains +text, a sequence of +characters, +which may represent markup or character data. +A character +is an atomic unit of text as specified by +ISO/IEC 10646 . +Legal characters are tab, carriage return, line feed, and the legal +graphic characters of Unicode and ISO/IEC 10646. +The use of "compatibility characters", as defined in section 6.8 +of , is discouraged. + + +Character Range + +Char +#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] +| [#x10000-#x10FFFF] +any Unicode character, excluding the +surrogate blocks, FFFE, and FFFF. + + +

+ +

The mechanism for encoding character code points into bit patterns may +vary from entity to entity. All XML processors must accept the UTF-8 +and UTF-16 encodings of 10646; the mechanisms for signaling which of +the two is in use, or for bringing other encodings into play, are +discussed later, in . +

+ +
+ + +Common Syntactic Constructs + +

This section defines some symbols used widely in the grammar.

+

S (white space) consists of one or more space (#x20) +characters, carriage returns, line feeds, or tabs. + + +White Space + +S +(#x20 | #x9 | #xD | #xA)+ + + +

+

Characters are classified for convenience as letters, digits, or other +characters. Letters consist of an alphabetic or syllabic +base character possibly +followed by one or more combining characters, or of an ideographic +character. +Full definitions of the specific characters in each class +are given in .

+

A Name is a token +beginning with a letter or one of a few punctuation characters, and continuing +with letters, digits, hyphens, underscores, colons, or full stops, together +known as name characters. +Names beginning with the string "xml", or any string +which would match (('X'|'x') ('M'|'m') ('L'|'l')), are +reserved for standardization in this or future versions of this +specification. +

+ +

The colon character within XML names is reserved for experimentation with +name spaces. +Its meaning is expected to be +standardized at some future point, at which point those documents +using the colon for experimental purposes may need to be updated. +(There is no guarantee that any name-space mechanism +adopted for XML will in fact use the colon as a name-space delimiter.) +In practice, this means that authors should not use the colon in XML +names except as part of name-space experiments, but that XML processors +should accept the colon as a name character.

+
+

An +Nmtoken (name token) is any mixture of +name characters. + +Names and Tokens +NameChar +Letter +| Digit +| '.' | '-' | '_' | ':' +| CombiningChar +| Extender + +Name +(Letter | '_' | ':') +(NameChar)* +Names +Name +(S Name)* +Nmtoken +(NameChar)+ +Nmtokens +Nmtoken (S Nmtoken)* + +

+

Literal data is any quoted string not containing +the quotation mark used as a delimiter for that string. +Literals are used +for specifying the content of internal entities +(EntityValue), +the values of attributes (AttValue), +and external identifiers +(SystemLiteral). +Note that a SystemLiteral +can be parsed without scanning for markup. + +Literals +EntityValue +'"' +([^%&"] +| PEReference +| Reference)* +'"' + +|  +"'" +([^%&'] +| PEReference +| Reference)* +"'" + +AttValue +'"' +([^<&"] +| Reference)* +'"' + +|  +"'" +([^<&'] +| Reference)* +"'" + +SystemLiteral +('"' [^"]* '"') | ("'" [^']* "'") + + +PubidLiteral +'"' PubidChar* +'"' +| "'" (PubidChar - "'")* "'" + +PubidChar +#x20 | #xD | #xA +| [a-zA-Z0-9] +| [-'()+,./:=?;!*#@$_%] + + +

+ +
+ + +Character Data and Markup + +

Text consists of intermingled +character +data and markup. +Markup takes the form of +start-tags, +end-tags, +empty-element tags, +entity references, +character references, +comments, +CDATA section delimiters, +document type declarations, and +processing instructions. + +

+

All text that is not markup +constitutes the character data of +the document.

+

The ampersand character (&) and the left angle bracket (<) +may appear in their literal form only when used as markup +delimiters, or within a comment, a +processing instruction, +or a CDATA section. + +They are also legal within the literal entity +value of an internal entity declaration; see +. + +If they are needed elsewhere, +they must be escaped +using either numeric character references +or the strings +"&amp;" and "&lt;" respectively. +The right angle +bracket (>) may be represented using the string +"&gt;", and must, for +compatibility, +be escaped using +"&gt;" or a character reference +when it appears in the string +"]]>" +in content, +when that string is not marking the end of +a CDATA section. +

+

+In the content of elements, character data +is any string of characters which does +not contain the start-delimiter of any markup. +In a CDATA section, character data +is any string of characters not including the CDATA-section-close +delimiter, "]]>".

+

+To allow attribute values to contain both single and double quotes, the +apostrophe or single-quote character (') may be represented as +"&apos;", and the double-quote character (") as +"&quot;". + +Character Data + +CharData +[^<&]* - ([^<&]* ']]>' [^<&]*) + + +

+
+ + +Comments + +

Comments may +appear anywhere in a document outside other +markup; in addition, +they may appear within the document type declaration +at places allowed by the grammar. +They are not part of the document's character +data; an XML +processor may, but need not, make it possible for an application to +retrieve the text of comments. +For compatibility, the string +"--" (double-hyphen) must not occur within +comments. + +Comments +Comment +'<!--' +((Char - '-') +| ('-' (Char - '-')))* +'-->' + + +

+

An example of a comment: +<!&como; declarations for <head> & <body> &comc;> +

+
+ + +Processing Instructions + +

Processing +instructions (PIs) allow documents to contain instructions +for applications. + + +Processing Instructions +PI +'<?' PITarget +(S +(Char* - +(Char* &pic; Char*)))? +&pic; +PITarget +Name - +(('X' | 'x') ('M' | 'm') ('L' | 'l')) + + +PIs are not part of the document's character +data, but must be passed through to the application. The +PI begins with a target (PITarget) used +to identify the application to which the instruction is directed. +The target names "XML", "xml", and so on are +reserved for standardization in this or future versions of this +specification. +The +XML Notation mechanism +may be used for +formal declaration of PI targets. +

+
+ + +CDATA Sections + +

CDATA sections +may occur +anywhere character data may occur; they are +used to escape blocks of text containing characters which would +otherwise be recognized as markup. CDATA sections begin with the +string "<![CDATA[" and end with the string +"]]>": + +CDATA Sections +CDSect +CDStart +CData +CDEnd +CDStart +'<![CDATA[' + +CData +(Char* - +(Char* ']]>' Char*)) + + +CDEnd +']]>' + + + +Within a CDATA section, only the CDEnd string is +recognized as markup, so that left angle brackets and ampersands may occur in +their literal form; they need not (and cannot) be escaped using +"&lt;" and "&amp;". CDATA sections +cannot nest. +

+ +

An example of a CDATA section, in which "<greeting>" and +"</greeting>" +are recognized as character data, not +markup: +<![CDATA[<greeting>Hello, world!</greeting>]]> +

+
+ + +Prolog and Document Type Declaration + +

XML documents +may, and should, +begin with an XML declaration which specifies +the version of +XML being used. +For example, the following is a complete XML document, well-formed but not +valid: + +Hello, world! +]]> +and so is this: +Hello, world! +]]> +

+ +

The version number "1.0" should be used to indicate +conformance to this version of this specification; it is an error +for a document to use the value "1.0" +if it does not conform to this version of this specification. +It is the intent +of the XML working group to give later versions of this specification +numbers other than "1.0", but this intent does not +indicate a +commitment to produce any future versions of XML, nor if any are produced, to +use any particular numbering scheme. +Since future versions are not ruled out, this construct is provided +as a means to allow the possibility of automatic version recognition, should +it become necessary. +Processors may signal an error if they receive documents labeled with +versions they do not support. +

+

The function of the markup in an XML document is to describe its +storage and logical structure and to associate attribute-value pairs +with its logical structures. XML provides a mechanism, the document type declaration, to define +constraints on the logical structure and to support the use of +predefined storage units. + +An XML document is +valid if it has an associated document type +declaration and if the document +complies with the constraints expressed in it.

+

The document type declaration must appear before +the first element in the document. + +Prolog + +prolog +XMLDecl? +Misc* +(doctypedecl +Misc*)? +XMLDecl +&xmlpio; +VersionInfo +EncodingDecl? +SDDecl? +S? +&pic; + +VersionInfo +S 'version' Eq +(' VersionNum ' +| " VersionNum ") + +Eq +S? '=' S? + +VersionNum +([a-zA-Z0-9_.:] | '-')+ + +Misc +Comment | PI | +S + +

+ +

The XML +document type declaration +contains or points to +markup declarations +that provide a grammar for a +class of documents. +This grammar is known as a document type definition, +or DTD. +The document type declaration can point to an external subset (a +special kind of +external entity) containing markup +declarations, or can +contain the markup declarations directly in an internal subset, or can do +both. +The DTD for a document consists of both subsets taken +together. +

+

+A markup declaration is +an element type declaration, +an attribute-list declaration, +an entity declaration, or +a notation declaration. + +These declarations may be contained in whole or in part +within parameter entities, +as described in the well-formedness and validity constraints below. +For fuller information, see +.

+ +Document Type Definition + +doctypedecl +'<!DOCTYPE' S +Name (S +ExternalID)? +S? ('[' +(markupdecl +| PEReference +| S)* +']' +S?)? '>' + + +markupdecl +elementdecl +| AttlistDecl +| EntityDecl +| NotationDecl +| PI +| Comment + + + + + + + + +

The markup declarations may be made up in whole or in part of +the replacement text of +parameter entities. +The productions later in this specification for +individual nonterminals (elementdecl, +AttlistDecl, and so on) describe +the declarations after all the parameter entities have been +included.

+ + +Root Element Type +

+The Name in the document type declaration must +match the element type of the root element. +

+
+ + +Proper Declaration/PE Nesting +

Parameter-entity +replacement text must be properly nested +with markup declarations. +That is to say, if either the first character +or the last character of a markup +declaration (markupdecl above) +is contained in the replacement text for a +parameter-entity reference, +both must be contained in the same replacement text.

+
+ +PEs in Internal Subset +

In the internal DTD subset, +parameter-entity references +can occur only where markup declarations can occur, not +within markup declarations. (This does not apply to +references that occur in +external parameter entities or to the external subset.) +

+
+

+Like the internal subset, the external subset and +any external parameter entities referred to in the DTD +must consist of a series of complete markup declarations of the types +allowed by the non-terminal symbol +markupdecl, interspersed with white space +or parameter-entity references. +However, portions of the contents +of the +external subset or of external parameter entities may conditionally be ignored +by using +the conditional section +construct; this is not allowed in the internal subset. + + +External Subset + +extSubset +TextDecl? +extSubsetDecl +extSubsetDecl +( +markupdecl +| conditionalSect +| PEReference +| S +)* + + +

+

The external subset and external parameter entities also differ +from the internal subset in that in them, +parameter-entity references +are permitted within markup declarations, +not only between markup declarations.

+

An example of an XML document with a document type declaration: + + +Hello, world! +]]> +The system identifier +"hello.dtd" gives the URI of a DTD for the document.

+

The declarations can also be given locally, as in this +example: + + +]> +Hello, world! +]]> +If both the external and internal subsets are used, the +internal subset is considered to occur before the external subset. + +This has the effect that entity and attribute-list declarations in the +internal subset take precedence over those in the external subset. +

+
+ + +Standalone Document Declaration +

Markup declarations can affect the content of the document, +as passed from an XML processor +to an application; examples are attribute defaults and entity +declarations. +The standalone document declaration, +which may appear as a component of the XML declaration, signals +whether or not there are such declarations which appear external to +the document entity. + +Standalone Document Declaration + +SDDecl + +S +'standalone' Eq +(("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) + + + +

+

+In a standalone document declaration, the value "yes" indicates +that there +are no markup declarations external to the document +entity (either in the DTD external subset, or in an +external parameter entity referenced from the internal subset) +which affect the information passed from the XML processor to +the application. +The value "no" indicates that there are or may be such +external markup declarations. +Note that the standalone document declaration only +denotes the presence of external declarations; the presence, in a +document, of +references to external entities, when those entities are +internally declared, +does not change its standalone status.

+

If there are no external markup declarations, the standalone document +declaration has no meaning. +If there are external markup declarations but there is no standalone +document declaration, the value "no" is assumed.

+

Any XML document for which standalone="no" holds can +be converted algorithmically to a standalone document, +which may be desirable for some network delivery applications.

+ +Standalone Document Declaration +

The standalone document declaration must have +the value "no" if any external markup declarations +contain declarations of:

+

attributes with default values, if +elements to which +these attributes apply appear in the document without +specifications of values for these attributes, or

+

entities (other than &magicents;), +if references to those +entities appear in the document, or

+
+

attributes with values subject to +normalization, where the +attribute appears in the document with a value which will +change as a result of normalization, or

+
+ +

element types with element content, +if white space occurs +directly within any instance of those types. +

+
+ +
+

An example XML declaration with a standalone document declaration:<?xml version="&XML.version;" standalone='yes'?>

+
+ +White Space Handling + +

In editing XML documents, it is often convenient to use "white space" +(spaces, tabs, and blank lines, denoted by the nonterminal +S in this specification) to +set apart the markup for greater readability. Such white space is typically +not intended for inclusion in the delivered version of the document. +On the other hand, "significant" white space that should be preserved in the +delivered version is common, for example in poetry and +source code.

+

An XML processor +must always pass all characters in a document that are not +markup through to the application. A +validating XML processor must also inform the application +which of these characters constitute white space appearing +in element content. +

+

A special attribute +named xml:space may be attached to an element +to signal an intention that in that element, +white space should be preserved by applications. +In valid documents, this attribute, like any other, must be +declared if it is used. +When declared, it must be given as an +enumerated type whose only +possible values are "default" and "preserve". +For example:]]>

+

The value "default" signals that applications' +default white-space processing modes are acceptable for this element; the +value "preserve" indicates the intent that applications preserve +all the white space. +This declared intent is considered to apply to all elements within the content +of the element where it is specified, unless overriden with another instance +of the xml:space attribute. +

+

The root element of any document +is considered to have signaled no intentions as regards application space +handling, unless it provides a value for +this attribute or the attribute is declared with a default value. +

+ +
+ +End-of-Line Handling +

XML parsed entities are often stored in +computer files which, for editing convenience, are organized into lines. +These lines are typically separated by some combination of the characters +carriage-return (#xD) and line-feed (#xA).

+

To simplify the tasks of applications, +wherever an external parsed entity or the literal entity value +of an internal parsed entity contains either the literal +two-character sequence "#xD#xA" or a standalone literal +#xD, an XML processor must +pass to the application the single character #xA. +(This behavior can +conveniently be produced by normalizing all +line breaks to #xA on input, before parsing.) +

+
+ +Language Identification +

In document processing, it is often useful to +identify the natural or formal language +in which the content is +written. +A special attribute named +xml:lang may be inserted in +documents to specify the +language used in the contents and attribute values +of any element in an XML document. +In valid documents, this attribute, like any other, must be +declared if it is used. +The values of the attribute are language identifiers as defined +by , "Tags for the Identification of Languages": + +Language Identification +LanguageID +Langcode +('-' Subcode)* +Langcode +ISO639Code | +IanaCode | +UserCode + +ISO639Code +([a-z] | [A-Z]) ([a-z] | [A-Z]) +IanaCode +('i' | 'I') '-' ([a-z] | [A-Z])+ +UserCode +('x' | 'X') '-' ([a-z] | [A-Z])+ +Subcode +([a-z] | [A-Z])+ + +The Langcode may be any of the following: + +

a two-letter language code as defined by +, "Codes +for the representation of names of languages"

+

a language identifier registered with the Internet +Assigned Numbers Authority ; these begin with the +prefix "i-" (or "I-")

+

a language identifier assigned by the user, or agreed on +between parties in private use; these must begin with the +prefix "x-" or "X-" in order to ensure that they do not conflict +with names later standardized or registered with IANA

+

+

There may be any number of Subcode segments; if +the first +subcode segment exists and the Subcode consists of two +letters, then it must be a country code from +, "Codes +for the representation of names of countries." +If the first +subcode consists of more than two letters, it must be +a subcode for the language in question registered with IANA, +unless the Langcode begins with the prefix +"x-" or +"X-".

+

It is customary to give the language code in lower case, and +the country code (if any) in upper case. +Note that these values, unlike other names in XML documents, +are case insensitive.

+

For example: +The quick brown fox jumps over the lazy dog.

+

What colour is it?

+

What color is it?

+ + Habe nun, ach! Philosophie, + Juristerei, und Medizin + und leider auch Theologie + durchaus studiert mit heißem Bemüh'n. + ]]>

+ +

The intent declared with xml:lang is considered to apply to +all attributes and content of the element where it is specified, +unless overridden with an instance of xml:lang +on another element within that content.

+ +

A simple declaration for xml:lang might take +the form +xml:lang NMTOKEN #IMPLIED +but specific default values may also be given, if appropriate. In a +collection of French poems for English students, with glosses and +notes in English, the xml:lang attribute might be declared this way: + + + ]]> +

+ +
+
+ + + +Logical Structures + +

Each XML document contains one or more +elements, the boundaries of which are +either delimited by start-tags +and end-tags, or, for empty elements, by an empty-element tag. Each element has a type, +identified by name, sometimes called its "generic +identifier" (GI), and may have a set of +attribute specifications. Each attribute specification +has a name and a value. +

+Element +element +EmptyElemTag +| STag content +ETag + + + + +

This specification does not constrain the semantics, use, or (beyond +syntax) names of the element types and attributes, except that names +beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) +are reserved for standardization in this or future versions of this +specification. +

+ +Element Type Match +

+The Name in an element's end-tag must match +the element type in +the start-tag. +

+
+ +Element Valid +

An element is +valid if +there is a declaration matching +elementdecl where the +Name matches the element type, and +one of the following holds:

+ +

The declaration matches EMPTY and the element has no +content.

+

The declaration matches children and +the sequence of +child elements +belongs to the language generated by the regular expression in +the content model, with optional white space (characters +matching the nonterminal S) between each pair +of child elements.

+

The declaration matches Mixed and +the content consists of character +data and child elements +whose types match names in the content model.

+

The declaration matches ANY, and the types +of any child elements have +been declared.

+
+
+ + +Start-Tags, End-Tags, and Empty-Element Tags + +

The beginning of every +non-empty XML element is marked by a start-tag. + +Start-tag + +STag +'<' Name +(S Attribute)* +S? '>' + + +Attribute +Name Eq +AttValue + + + + + +The Name in +the start- and end-tags gives the +element's type. + +The Name-AttValue pairs are +referred to as +the attribute specifications of the element, +with the +Name in each pair +referred to as the attribute name and +the content of the +AttValue (the text between the +' or " delimiters) +as the attribute value. +

+ +Unique Att Spec +

+No attribute name may appear more than once in the same start-tag +or empty-element tag. +

+
+ +Attribute Value Type +

+The attribute must have been declared; the value must be of the type +declared for it. +(For attribute types, see .) +

+
+ +No External Entity References +

+Attribute values cannot contain direct or indirect entity references +to external entities. +

+
+ +No < in Attribute Values +

The replacement text of any entity +referred to directly or indirectly in an attribute +value (other than "&lt;") must not contain +a <. +

+

An example of a start-tag: +<termdef id="dt-dog" term="dog">

+

The end of every element +that begins with a start-tag must +be marked by an end-tag +containing a name that echoes the element's type as given in the +start-tag: + +End-tag + +ETag +'</' Name +S? '>' + + +

+

An example of an end-tag:</termdef>

+

Component Package diagram ProblemDomain

+


+
+
Stereotype problem domain
+
Alias Problem Domain
+
Note
The Problem Domain package is the model behind the Human +
Interface, thats stores and manipulates the Family Tree. +
+


+
+ +

Class HumanInterface.FamilyFrame

+

Class ProblemDomain.Birth

+

Class ProblemDomain.Death

+

Class ProblemDomain.Divorce

+

Class ProblemDomain.Family

+

Class ProblemDomain.Individual

+

Class ProblemDomain.LifeEvent

+

Class ProblemDomain.Marriage

+

Class ProblemDomain.Note

+
+ +

Links

+ + + + + + + diff --git a/fuzz/seed_corpus/3457d93607d3999e321617680bed3ddca1f44bf3 b/fuzz/seed_corpus/3457d93607d3999e321617680bed3ddca1f44bf3 new file mode 100644 index 000000000000..d80a5e273cc7 --- /dev/null +++ b/fuzz/seed_corpus/3457d93607d3999e321617680bed3ddca1f44bf3 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/34675d3c7f8e4a39df7ac2c6bc0a06612f5319e0 b/fuzz/seed_corpus/34675d3c7f8e4a39df7ac2c6bc0a06612f5319e0 new file mode 100644 index 000000000000..e880cc5adf30 --- /dev/null +++ b/fuzz/seed_corpus/34675d3c7f8e4a39df7ac2c6bc0a06612f5319e0 @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/34f7d2c6f3468da3f3ff5f21164a2801a0f9925a b/fuzz/seed_corpus/34f7d2c6f3468da3f3ff5f21164a2801a0f9925a new file mode 100644 index 000000000000..087ed956b53a --- /dev/null +++ b/fuzz/seed_corpus/34f7d2c6f3468da3f3ff5f21164a2801a0f9925a @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/34f892bb3c2e5d05fd6082da5ba25d932a5dea2f b/fuzz/seed_corpus/34f892bb3c2e5d05fd6082da5ba25d932a5dea2f new file mode 100644 index 000000000000..c17295af3214 --- /dev/null +++ b/fuzz/seed_corpus/34f892bb3c2e5d05fd6082da5ba25d932a5dea2f @@ -0,0 +1,3 @@ + +0 + diff --git a/fuzz/seed_corpus/35023a7259bc97894808e681da25db0a9643746c b/fuzz/seed_corpus/35023a7259bc97894808e681da25db0a9643746c new file mode 100644 index 000000000000..fbf721dc8c6f --- /dev/null +++ b/fuzz/seed_corpus/35023a7259bc97894808e681da25db0a9643746c @@ -0,0 +1,7 @@ + + + + +]> +lacks c diff --git a/fuzz/seed_corpus/35343925d7c2fe1f6246096652ac3f588f197d37 b/fuzz/seed_corpus/35343925d7c2fe1f6246096652ac3f588f197d37 new file mode 100644 index 000000000000..e9906b7017aa --- /dev/null +++ b/fuzz/seed_corpus/35343925d7c2fe1f6246096652ac3f588f197d37 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/3553d1e2ae4f4bf2dd64e22920ee093c1246375a b/fuzz/seed_corpus/3553d1e2ae4f4bf2dd64e22920ee093c1246375a new file mode 100644 index 000000000000..5064bf230478 --- /dev/null +++ b/fuzz/seed_corpus/3553d1e2ae4f4bf2dd64e22920ee093c1246375a @@ -0,0 +1,5 @@ + + John Smith + js@example.com + text + diff --git a/fuzz/seed_corpus/3573efff01f53fb99cc1f62025782687a8492389 b/fuzz/seed_corpus/3573efff01f53fb99cc1f62025782687a8492389 new file mode 100644 index 000000000000..f5ebd8912198 --- /dev/null +++ b/fuzz/seed_corpus/3573efff01f53fb99cc1f62025782687a8492389 @@ -0,0 +1,6 @@ + + +]> +a + diff --git a/fuzz/seed_corpus/359efdf116e99b035ad8a7143e0008c726f8e89a b/fuzz/seed_corpus/359efdf116e99b035ad8a7143e0008c726f8e89a new file mode 100644 index 000000000000..f25558923ec9 --- /dev/null +++ b/fuzz/seed_corpus/359efdf116e99b035ad8a7143e0008c726f8e89a @@ -0,0 +1,8 @@ + +]> + + +text + + diff --git a/fuzz/seed_corpus/35adadef5ed7f8904b95b896ceb98c0c67b7c4d9 b/fuzz/seed_corpus/35adadef5ed7f8904b95b896ceb98c0c67b7c4d9 new file mode 100644 index 000000000000..4b4961283653 --- /dev/null +++ b/fuzz/seed_corpus/35adadef5ed7f8904b95b896ceb98c0c67b7c4d9 @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/fuzz/seed_corpus/35e835321db6aadf8e91b0c5349ca32d5dcfaca0 b/fuzz/seed_corpus/35e835321db6aadf8e91b0c5349ca32d5dcfaca0 new file mode 100644 index 000000000000..dc7c36bad212 --- /dev/null +++ b/fuzz/seed_corpus/35e835321db6aadf8e91b0c5349ca32d5dcfaca0 @@ -0,0 +1,5 @@ + + + + + diff --git a/fuzz/seed_corpus/362061c13eb3be9264e4d6fd796b65e67e06d15f b/fuzz/seed_corpus/362061c13eb3be9264e4d6fd796b65e67e06d15f new file mode 100644 index 000000000000..5caccfca49b9 --- /dev/null +++ b/fuzz/seed_corpus/362061c13eb3be9264e4d6fd796b65e67e06d15f @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/367c8849eb9c664ffd8fca01ae437693e7c300f1 b/fuzz/seed_corpus/367c8849eb9c664ffd8fca01ae437693e7c300f1 new file mode 100644 index 000000000000..7f58a8b4f6a8 --- /dev/null +++ b/fuzz/seed_corpus/367c8849eb9c664ffd8fca01ae437693e7c300f1 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/369cde0f03fa526fa88cb0962ad9df3db638f974 b/fuzz/seed_corpus/369cde0f03fa526fa88cb0962ad9df3db638f974 new file mode 100644 index 000000000000..7f99baf63625 --- /dev/null +++ b/fuzz/seed_corpus/369cde0f03fa526fa88cb0962ad9df3db638f974 @@ -0,0 +1,14 @@ + + + + http://www.foo.bar/othercontainer/resource1 + http://www.foo.bar/othercontainer/resource2 + http://www.foo.bar/othercontainer/ + http://www.foo.bar/othercontainer/R2/D2 + HTTP/1.1 201 Created + + + http://www.foo.bar/othercontainer/R2/ + HTTP/1.1 412 Precondition Failed + + diff --git a/fuzz/seed_corpus/36a3a042b66d27d82b3c33ba30f12b3ace42b992 b/fuzz/seed_corpus/36a3a042b66d27d82b3c33ba30f12b3ace42b992 new file mode 100644 index 000000000000..717b66a36387 --- /dev/null +++ b/fuzz/seed_corpus/36a3a042b66d27d82b3c33ba30f12b3ace42b992 @@ -0,0 +1,8 @@ + + + (//. | //@* | //namespace::*) + [ + + ancestor-or-self::bar:Something + ] + diff --git a/fuzz/seed_corpus/3763091a5b9d668ead99e1859df607ebaa818660 b/fuzz/seed_corpus/3763091a5b9d668ead99e1859df607ebaa818660 new file mode 100644 index 000000000000..3ab3d068ca82 --- /dev/null +++ b/fuzz/seed_corpus/3763091a5b9d668ead99e1859df607ebaa818660 @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/37d81231057d12730464baf1d81ef8463d8a3ba8 b/fuzz/seed_corpus/37d81231057d12730464baf1d81ef8463d8a3ba8 new file mode 100644 index 000000000000..f495831af821 --- /dev/null +++ b/fuzz/seed_corpus/37d81231057d12730464baf1d81ef8463d8a3ba8 @@ -0,0 +1,8 @@ + + + +]> + + &bar; + diff --git a/fuzz/seed_corpus/37f690b3337edd9e89cf7b8181a612674979125e b/fuzz/seed_corpus/37f690b3337edd9e89cf7b8181a612674979125e new file mode 100644 index 000000000000..6213f1b9eeda --- /dev/null +++ b/fuzz/seed_corpus/37f690b3337edd9e89cf7b8181a612674979125e @@ -0,0 +1,19 @@ + + + + Gradients apply to leaf nodes + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/37f92f2750a7f26f9055119d80f6cd1ebbf756f2 b/fuzz/seed_corpus/37f92f2750a7f26f9055119d80f6cd1ebbf756f2 new file mode 100644 index 000000000000..d7658b0245eb --- /dev/null +++ b/fuzz/seed_corpus/37f92f2750a7f26f9055119d80f6cd1ebbf756f2 @@ -0,0 +1,6 @@ + +]> + + + This links to an external image + + + My image + + diff --git a/fuzz/seed_corpus/3ca4c964b9792ca5363239457e5c1420da58a1f3 b/fuzz/seed_corpus/3ca4c964b9792ca5363239457e5c1420da58a1f3 new file mode 100644 index 000000000000..a14e362ba7b4 --- /dev/null +++ b/fuzz/seed_corpus/3ca4c964b9792ca5363239457e5c1420da58a1f3 @@ -0,0 +1,7 @@ + + + Let's use predefined entites & < > + + Let's use a DTD defined entity &bent; + + diff --git a/fuzz/seed_corpus/3cb01cf8d387cfe9ae2e23f1bfb6d0e8e98e9b0e b/fuzz/seed_corpus/3cb01cf8d387cfe9ae2e23f1bfb6d0e8e98e9b0e new file mode 100644 index 000000000000..874435637187 --- /dev/null +++ b/fuzz/seed_corpus/3cb01cf8d387cfe9ae2e23f1bfb6d0e8e98e9b0e @@ -0,0 +1,53 @@ + + + + + + + + + + addressBook + + + + + card + + + + name + + + + + + + givenName + + + + + + + + familyName + + + + + + + + + email + + + + + + + + + + diff --git a/fuzz/seed_corpus/3cc0358ad28a8aa873572699c3dad054b9f4b36c b/fuzz/seed_corpus/3cc0358ad28a8aa873572699c3dad054b9f4b36c new file mode 100644 index 000000000000..7bf3719ce370 --- /dev/null +++ b/fuzz/seed_corpus/3cc0358ad28a8aa873572699c3dad054b9f4b36c @@ -0,0 +1,24 @@ + + + + 0. + .0 + .10 + 01. + 000 + 123456789012345678 + -123456789012345678 + 0.123456789012345678 + -0.123456789012345678 + + . + - + + + * + - 1 + + 1 + + 0 + - 0 + diff --git a/fuzz/seed_corpus/3d3aaf13fa606e4d1f9578525670886e42f24c5c b/fuzz/seed_corpus/3d3aaf13fa606e4d1f9578525670886e42f24c5c new file mode 100644 index 000000000000..b460b93d8f4e --- /dev/null +++ b/fuzz/seed_corpus/3d3aaf13fa606e4d1f9578525670886e42f24c5c @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/3d50175e6eec31cf51792765c26e1e52e7082e52 b/fuzz/seed_corpus/3d50175e6eec31cf51792765c26e1e52e7082e52 new file mode 100644 index 000000000000..bed44b7f760c --- /dev/null +++ b/fuzz/seed_corpus/3d50175e6eec31cf51792765c26e1e52e7082e52 @@ -0,0 +1,10 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:e11 or ancestor-or-self::ietf:e12] + diff --git a/fuzz/seed_corpus/3d5670df150b1ef15cd0b5a864b453df8b60c070 b/fuzz/seed_corpus/3d5670df150b1ef15cd0b5a864b453df8b60c070 new file mode 100644 index 000000000000..6ab9d80d04a8 --- /dev/null +++ b/fuzz/seed_corpus/3d5670df150b1ef15cd0b5a864b453df8b60c070 @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/3d75659fae1ba8a57edf94fcd929e838884ec628 b/fuzz/seed_corpus/3d75659fae1ba8a57edf94fcd929e838884ec628 new file mode 100644 index 000000000000..f88364889a5c --- /dev/null +++ b/fuzz/seed_corpus/3d75659fae1ba8a57edf94fcd929e838884ec628 @@ -0,0 +1,93 @@ + + + + + 1 + 2 + 3 + 4 + 5 + + dupl1 + dupl2 + dupl3 + dupl4 + dupl5 + dupl6 + dupl7 + dupl8 + dupl9 + dupl10 + dupl11 + + 6 + 7 + 8 + 9 + 10 + 11 + + 12 + 13 + 14 + 15 + + dupl1 + dupl2 + dupl3 + dupl4 + dupl5 + dupl6 + dupl7 + dupl8 + dupl9 + dupl10 + dupl11 + + 16 + 17 + 18 + 19 + 20 + 21 + + + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + + dupl1 + dupl2 + dupl3 + dupl4 + dupl5 + dupl6 + dupl7 + dupl8 + dupl9 + dupl10 + dupl11 + + + + 41 + + + diff --git a/fuzz/seed_corpus/3dc6a326d54c4ad851e746c41d4f589a2a7a81dc b/fuzz/seed_corpus/3dc6a326d54c4ad851e746c41d4f589a2a7a81dc new file mode 100644 index 000000000000..3a74d6816011 --- /dev/null +++ b/fuzz/seed_corpus/3dc6a326d54c4ad851e746c41d4f589a2a7a81dc @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/3df6ab31f8c924814d6ec41254d11b4b3734784a b/fuzz/seed_corpus/3df6ab31f8c924814d6ec41254d11b4b3734784a new file mode 100644 index 000000000000..576e8d4c162e --- /dev/null +++ b/fuzz/seed_corpus/3df6ab31f8c924814d6ec41254d11b4b3734784a @@ -0,0 +1,2413 @@ + + + + Datatype dateTime + + + + + + + + + 2001-12-01T19:45:00 + + + 2001-12-01T19:45:00Z + + + 2001-12-01T19:45:00-11:59 + + + 0001-01-12T00:00:00+12:00 + + + 2001-12-1T19:45:00+24:00 + + + 2001-12-1T19:45:00 + + + + + + 2001-12-01T19:45:00 + + + + 2001-12-01T19:45:00.00 + + + 2001-12-01T19:45:00Z + + + 2001-12-01T19:45:00.00Z + + + 2001-12-01T20:45:00+01:00 + + + + + + 2001-12-01T19:45:00Z + + + + 2001-12-01T19:45:00.00Z + + + 2001-12-01T20:45:00+01:00 + + + 2001-12-01T19:45:00 + + + 2001-12-01T19:45:00.00 + + + + + Datatype anyURI + + + + + + + + + foobar + + + http://www.example.com + + + http://ji%6d@www.example.com + + + http://www.example.co%6d + + + nosuchscheme:stuff + + + foo$bar:stuff + + + f%oobar + + + + + Datatype integer + + + + + + + + + 10 + + + 01 + + + 0123456789 + + + +10 + + + -10 + + + 1.0 + + + .1 + + + 9999999999999999999999999999999 + + + 1. + + + 0. + + + + + + 0 + + + + +0 + + + -0 + + + 00 + + + 10 + + + +10 + + + +0010 + + + 010 + + + -10 + + + -0010 + + + -010 + + + + + + 10 + + + + +10 + + + +0010 + + + 010 + + + 0 + + + +0 + + + -0 + + + 00 + + + -10 + + + -0010 + + + -010 + + + + + + -10 + + + + -0010 + + + -010 + + + 0 + + + +0 + + + -0 + + + 00 + + + 10 + + + +10 + + + +0010 + + + 010 + + + + + Datatype duration + + + + + + + + + P1Y + + + P1Y0M2DT17H5M12S + + + -P1Y + + + P60D + + + PT24H + + + PT1.2S + + + P24h + + + P24H + + + P1YT + + + P + + + -P + + + + + + -P6M + + + + P0Y + + + -P0Y + + + P1Y + + + P001Y + + + P001Y0M + + + P1Y0M0DT0H0M0.0S + + + P6M + + + PT6M + + + PT1S + + + PT1.0S + + + + + + P0Y + + + + -P0Y + + + -P6M + + + P1Y + + + P001Y + + + P001Y0M + + + P1Y0M0DT0H0M0.0S + + + P6M + + + PT6M + + + PT1S + + + PT1.0S + + + + + + P1Y + + + + P001Y + + + P001Y0M + + + P1Y0M0DT0H0M0.0S + + + -P6M + + + P0Y + + + -P0Y + + + P6M + + + PT6M + + + PT1S + + + PT1.0S + + + + + + P6M + + + + -P6M + + + P0Y + + + -P0Y + + + P1Y + + + P001Y + + + P001Y0M + + + P1Y0M0DT0H0M0.0S + + + PT6M + + + PT1S + + + PT1.0S + + + + + + PT6M + + + + -P6M + + + P0Y + + + -P0Y + + + P1Y + + + P001Y + + + P001Y0M + + + P1Y0M0DT0H0M0.0S + + + P6M + + + PT1S + + + PT1.0S + + + + + + PT1S + + + + PT1.0S + + + -P6M + + + P0Y + + + -P0Y + + + P1Y + + + P001Y + + + P001Y0M + + + P1Y0M0DT0H0M0.0S + + + P6M + + + PT6M + + + + + + + PT1M + + + + + PT61S + + + PT1M + + + + + + + PT61S + + + + + PT1M + + + PT61S + + + + + + + PT59S + + + + + PT1M + + + PT59S + + + + + + + PT1M + + + + + PT59S + + + PT1M + + + + + + + PT60S + + + + + PT1M + + + PT60S + + + + + + + PT1M + + + + + PT60S + + + PT1M + + + + + + + PT1H + + + + + PT61M + + + PT1H + + + + + + + PT61M + + + + + PT1H + + + PT61M + + + + + + + PT59M + + + + + PT1H + + + PT59M + + + + + + + PT1H + + + + + PT59M + + + PT1H + + + + + + + PT60M + + + + + PT1H + + + PT60M + + + + + + + PT1H + + + + + PT60M + + + PT1H + + + + + + + P1D + + + + + PT25H + + + P1D + + + + + + + PT25H + + + + + P1D + + + PT25H + + + + + + + PT23H + + + + + P1D + + + PT23H + + + + + + + P1D + + + + + PT23H + + + P1D + + + + + + + P1D + + + + + PT24H + + + P1D + + + + + + + PT24H + + + + + P1D + + + PT24H + + + + + + + P1Y + + + + + P13M + + + P1Y + + + + + + + P13M + + + + + P1Y + + + P13M + + + + + + + P11M + + + + + P1Y + + + P11M + + + + + + + P1Y + + + + + P11M + + + P1Y + + + + + + + P12M + + + + + P1Y + + + P12M + + + + + + + P1Y + + + + + P12M + + + P1Y + + + + + + + P364D + + + + + P1Y + + + P364D + + + + + + + P1Y + + + + + P364D + + + P1Y + + + + + + + P1Y + + + + + P365D + + + P1Y + + + + + + + P365D + + + + + P1Y + + + P365D + + + + + + + P1Y + + + + + P366D + + + P1Y + + + + + + + P366D + + + + + P1Y + + + P366D + + + + + + + P1Y + + + + + P367D + + + P1Y + + + + + + + P367D + + + + + P1Y + + + P367D + + + + + + + P149D + + + + + P5M + + + P149D + + + + + + + P5M + + + + + P149D + + + P5M + + + + + + + P150D + + + + + P5M + + + P150D + + + + + + + P5M + + + + + P150D + + + P5M + + + + + + + P151D + + + + + P5M + + + P151D + + + + + + + P5M + + + + + P151D + + + P5M + + + + + + + P152D + + + + + P5M + + + P152D + + + + + + + P5M + + + + + P152D + + + P5M + + + + + + + P153D + + + + + P5M + + + P153D + + + + + + + P5M + + + + + P153D + + + P5M + + + + + + + P5M + + + + + P154D + + + P5M + + + + + + + P154D + + + + + P5M + + + P154D + + + + + + + P27D + + + + + P1M + + + P27D + + + + + + + P1M + + + + + P27D + + + P1M + + + + + + + P28D + + + + + P1M + + + P28D + + + + + + + P1M + + + + + P28D + + + P1M + + + + + + + P29D + + + + + P1M + + + P29D + + + + + + + P1M + + + + + P29D + + + P1M + + + + + + + P30D + + + + + P1M + + + P30D + + + + + + + P1M + + + + + P30D + + + P1M + + + + + + + P31D + + + + + P1M + + + P31D + + + + + + + P1M + + + + + P31D + + + P1M + + + + + + + P1M + + + + + P32D + + + P1M + + + + + + + P32D + + + + + P1M + + + P32D + + + + + Datatype time + + + + + + + + + 12:45:00 + + + 12:45:00Z + + + + + Datatype date + + + + + + + + + 1886-12-01 + + + 1886-12-01Z + + + + + + + 1066-12-31 + + + + + 1900-01-01 + + + 1066-12-31 + + + + + + + 1900-01-01 + + + + + 1066-12-31 + + + 1900-01-01 + + + + + + + 1900-01-01 + + + + + 1900-01-02 + + + 1900-01-01 + + + + + + + 1900-01-02 + + + + + 1900-01-01 + + + 1900-01-02 + + + + + Datatype gYearMonth + + + + + + + + + 1996-12 + + + 1996-01 + + + 1996-01Z + + + 1996-00 + + + + + + 1996-01 + + + + 1996-01Z + + + 1996-01+00:00 + + + 1996-01-00:00 + + + 1996-01+01:00 + + + 1996-01-01:00 + + + + + + 1996-01Z + + + + 1996-01+00:00 + + + 1996-01-00:00 + + + 1996-01 + + + 1996-01+01:00 + + + 1996-01-01:00 + + + + + + 1996-01+01:00 + + + + 1996-01 + + + 1996-01Z + + + 1996-01+00:00 + + + 1996-01-00:00 + + + 1996-01-01:00 + + + + + + 1996-01-01:00 + + + + 1996-01 + + + 1996-01Z + + + 1996-01+00:00 + + + 1996-01-00:00 + + + 1996-01+01:00 + + + + + Datatype gYear + + + + + + + + + 2001 + + + 2001Z + + + + + + + 1999 + + + + + 2000 + + + 1999 + + + + + + + 2000 + + + + + 1999 + + + 2000 + + + + + + + 1999+07:00 + + + + + 2000+07:00 + + + 1999+07:00 + + + + + + + 2000+07:00 + + + + + 1999+07:00 + + + 2000+07:00 + + + + + Datatype gMonthDay + + + + + + + + + --12-01 + + + --12-01Z + + + + + + + --12-01 + + + + + --12-04 + + + --12-01 + + + + + + + --12-04 + + + + + --12-01 + + + --12-04 + + + + + + + --11-17 + + + + + --12-04 + + + --11-17 + + + + + + + --12-04 + + + + + --11-17 + + + --12-04 + + + + + Datatype gDay + + + + + + + + + ---20 + + + ---20Z + + + + + + + ---01 + + + + + ---31 + + + ---01 + + + + + + + ---31 + + + + + ---01 + + + ---31 + + + + + Datatype gMonth + + + + + + + + + --12 + + + --01 + + + --01Z + + + --12 + + + ---01 + + + --00 + + + --13 + + + - -13 + + + + + + + --01 + + + + + --12 + + + --01 + + + + + + + --12 + + + + + --01 + + + --12 + + + + + + + --01 + + + + + --02 + + + --01 + + + + + + + --02 + + + + + --01 + + + --02 + + + + + Datatype boolean + + + + + + + + + true + + + false + + + 0 + + + 1 + + + 00 + + + 00 + + + 01 + + + + + + true + + + + 1 + + + false + + + 0 + + + + + + false + + + + 0 + + + true + + + 1 + + + + + Datatype base64Binary + + + + + + + + + AAAA + + + abcd efgh ijkl mnop qrst uvwx yzAB CDEF GHIJ KLMN OPQR +STUV WXYZ 0123 4567 89+/ + + + BA== + + + + + + BA== + + + BQ== + + + Bg== + + + Bw== + + + BBA= + + + BBA= + + + BBE= + + + BBI= + + + BBM= + + + BBQ= + + + BBU= + + + BBY= + + + BBc= + + + BBg= + + + BBk= + + + BBo= + + + BBs= + + + BBw= + + + BB0= + + + BB4= + + + BB8= + + + ==== + + + BB== + + + BBB= + + + B=== + + + B + + + + + + deadbeef + + + + d + e a d +b eef + + + DEADBEEF + + + D + E A D +B EEF + + + + + + DEADBEEF + + + + D + E A D +B EEF + + + deadbeef + + + d + e a d +b eef + + + + + + + 0 + + + + + + + + + + + + 1 + + + + + + + + + + + + 6 + + + + + deadbeef + + + + + + + 7 + + + + + deadbeef + + + + + + + 5 + + + + + deadbeef + + + + + + + 1 + + + + + BA== + + + + + + + 2 + + + + + BA== + + + + + + + 0 + + + + + BA== + + + + + + + 2 + + + + + BBA= + + + + + + + 3 + + + + + BBA= + + + + + + + 1 + + + + + BBA= + + + + + + + 3 + + + + + dead + + + + + + + 4 + + + + + dead + + + + + + + 2 + + + + + dead + + + + + + + 4 + + + + + deadBA== + + + + + + + 5 + + + + + deadBA== + + + + + + + 3 + + + + + deadBA== + + + + + Datatype hexBinary + + + + + + + + + deadbeef + + + + + + 0123456789ABCDEFabcdef + + + 00 00 + + + 00.00 + + + 0G + + + + + + 00 + + + + + 00 + + + + 01 + + + 10 + + + 0a + + + 0A + + + + + + 01 + + + + 00 + + + + 00 + + + + 10 + + + 0a + + + 0A + + + + + + 10 + + + + 00 + + + + 00 + + + + 01 + + + 0a + + + 0A + + + + + + 0a + + + + 0A + + + 00 + + + + 00 + + + + 01 + + + 10 + + + + + + + 0 + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/3ed6e5c140bae24b255cb44442523965ab7a42f8 b/fuzz/seed_corpus/3ed6e5c140bae24b255cb44442523965ab7a42f8 new file mode 100644 index 000000000000..0a11e14daa8a --- /dev/null +++ b/fuzz/seed_corpus/3ed6e5c140bae24b255cb44442523965ab7a42f8 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/3f55d0379c0e80b6f010820df52b0cb386ed8c61 b/fuzz/seed_corpus/3f55d0379c0e80b6f010820df52b0cb386ed8c61 new file mode 100644 index 000000000000..e09d8a10b3e8 --- /dev/null +++ b/fuzz/seed_corpus/3f55d0379c0e80b6f010820df52b0cb386ed8c61 @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/401543482823f51516d893bd40e21f62a7095390 b/fuzz/seed_corpus/401543482823f51516d893bd40e21f62a7095390 new file mode 100644 index 000000000000..555f24d48dff --- /dev/null +++ b/fuzz/seed_corpus/401543482823f51516d893bd40e21f62a7095390 @@ -0,0 +1,3 @@ + + ccc + diff --git a/fuzz/seed_corpus/4082d19ec13578dcd0e426fd90f95292d0fd17ba b/fuzz/seed_corpus/4082d19ec13578dcd0e426fd90f95292d0fd17ba new file mode 100644 index 000000000000..55cfba6dccfe --- /dev/null +++ b/fuzz/seed_corpus/4082d19ec13578dcd0e426fd90f95292d0fd17ba @@ -0,0 +1,1102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/409a08aae1b84dfbd1edf7042b9668a99832f13c b/fuzz/seed_corpus/409a08aae1b84dfbd1edf7042b9668a99832f13c new file mode 100644 index 000000000000..ebf08de4a3bb --- /dev/null +++ b/fuzz/seed_corpus/409a08aae1b84dfbd1edf7042b9668a99832f13c @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/40b77e5ae2f82dfde535ad24b584755f303fc1a4 b/fuzz/seed_corpus/40b77e5ae2f82dfde535ad24b584755f303fc1a4 new file mode 100644 index 000000000000..e8434d18189e --- /dev/null +++ b/fuzz/seed_corpus/40b77e5ae2f82dfde535ad24b584755f303fc1a4 @@ -0,0 +1,8 @@ + + + + + + diff --git a/fuzz/seed_corpus/40c5aae0f98020db8a707f95d88df88bb040c9f7 b/fuzz/seed_corpus/40c5aae0f98020db8a707f95d88df88bb040c9f7 new file mode 100644 index 000000000000..b70c5bf0adc5 --- /dev/null +++ b/fuzz/seed_corpus/40c5aae0f98020db8a707f95d88df88bb040c9f7 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/40c82af59b9824a310ef8b7666f7878db41d8a86 b/fuzz/seed_corpus/40c82af59b9824a310ef8b7666f7878db41d8a86 new file mode 100644 index 000000000000..59727aaf88eb --- /dev/null +++ b/fuzz/seed_corpus/40c82af59b9824a310ef8b7666f7878db41d8a86 @@ -0,0 +1,1311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/417dba73318503bd669248490380fa6f095fd137 b/fuzz/seed_corpus/417dba73318503bd669248490380fa6f095fd137 new file mode 100644 index 000000000000..32b42bc4e411 --- /dev/null +++ b/fuzz/seed_corpus/417dba73318503bd669248490380fa6f095fd137 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/419195bd3ad69e448e63afd9355c2c6d18c6ed52 b/fuzz/seed_corpus/419195bd3ad69e448e63afd9355c2c6d18c6ed52 new file mode 100644 index 000000000000..aedcc21a2cf9 --- /dev/null +++ b/fuzz/seed_corpus/419195bd3ad69e448e63afd9355c2c6d18c6ed52 @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/41bdffcb56ac2aab0b529d18eed2d1df0fdbc2b3 b/fuzz/seed_corpus/41bdffcb56ac2aab0b529d18eed2d1df0fdbc2b3 new file mode 100644 index 000000000000..9153bc83d773 --- /dev/null +++ b/fuzz/seed_corpus/41bdffcb56ac2aab0b529d18eed2d1df0fdbc2b3 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/427cbae095793e5bfdd99d74aab07afd1c9ad3ca b/fuzz/seed_corpus/427cbae095793e5bfdd99d74aab07afd1c9ad3ca new file mode 100644 index 000000000000..bc9c8c262ee6 --- /dev/null +++ b/fuzz/seed_corpus/427cbae095793e5bfdd99d74aab07afd1c9ad3ca @@ -0,0 +1,7 @@ + + + + +]> + diff --git a/fuzz/seed_corpus/42a6a0349a82750fa6c3d4c8352309d810b52d00 b/fuzz/seed_corpus/42a6a0349a82750fa6c3d4c8352309d810b52d00 new file mode 100644 index 000000000000..e58bed21e2b4 --- /dev/null +++ b/fuzz/seed_corpus/42a6a0349a82750fa6c3d4c8352309d810b52d00 @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/42fee542d8ff480328efa55e776f7d86a7f785f7 b/fuzz/seed_corpus/42fee542d8ff480328efa55e776f7d86a7f785f7 new file mode 100644 index 000000000000..1745abeb5909 --- /dev/null +++ b/fuzz/seed_corpus/42fee542d8ff480328efa55e776f7d86a7f785f7 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/4329a86c75c6710c55fdaed2a83afa132269cbe7 b/fuzz/seed_corpus/4329a86c75c6710c55fdaed2a83afa132269cbe7 new file mode 100644 index 000000000000..4778d894cc45 --- /dev/null +++ b/fuzz/seed_corpus/4329a86c75c6710c55fdaed2a83afa132269cbe7 @@ -0,0 +1,21 @@ + + + + + + + + hello world + + " +> +]> + + + &f; + + diff --git a/fuzz/seed_corpus/43a8002ae75dc483d657b93bf90be537f51e311b b/fuzz/seed_corpus/43a8002ae75dc483d657b93bf90be537f51e311b new file mode 100644 index 000000000000..83d15a78e2e6 --- /dev/null +++ b/fuzz/seed_corpus/43a8002ae75dc483d657b93bf90be537f51e311b @@ -0,0 +1,20 @@ + + + + + + + + + + + sj1VXDB2VMCU5qmva2OtDw3kKOs= + + + ... + + + ... + + + diff --git a/fuzz/seed_corpus/43e3e620b4a80fddf9757b0654f7d88f893b45f0 b/fuzz/seed_corpus/43e3e620b4a80fddf9757b0654f7d88f893b45f0 new file mode 100644 index 000000000000..4b611e11cdba --- /dev/null +++ b/fuzz/seed_corpus/43e3e620b4a80fddf9757b0654f7d88f893b45f0 @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/43ef53483f81d8d37ef3a506e188a13432a13b18 b/fuzz/seed_corpus/43ef53483f81d8d37ef3a506e188a13432a13b18 new file mode 100644 index 000000000000..f71576336cea --- /dev/null +++ b/fuzz/seed_corpus/43ef53483f81d8d37ef3a506e188a13432a13b18 @@ -0,0 +1 @@ +

abcdefg

diff --git a/fuzz/seed_corpus/43f0facfb33120a131a205db34a3fe227b4e70c6 b/fuzz/seed_corpus/43f0facfb33120a131a205db34a3fe227b4e70c6 new file mode 100644 index 000000000000..4613d8f56d9e --- /dev/null +++ b/fuzz/seed_corpus/43f0facfb33120a131a205db34a3fe227b4e70c6 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4488cc2cc0807fb5ab9bcd16ee7c9dacadb9214c b/fuzz/seed_corpus/4488cc2cc0807fb5ab9bcd16ee7c9dacadb9214c new file mode 100644 index 000000000000..b6122be8243c --- /dev/null +++ b/fuzz/seed_corpus/4488cc2cc0807fb5ab9bcd16ee7c9dacadb9214c @@ -0,0 +1,6 @@ + + + + + diff --git a/fuzz/seed_corpus/44a4b22ac657794f39cdda1dc9008f3226dc89a0 b/fuzz/seed_corpus/44a4b22ac657794f39cdda1dc9008f3226dc89a0 new file mode 100644 index 000000000000..26e12213e219 --- /dev/null +++ b/fuzz/seed_corpus/44a4b22ac657794f39cdda1dc9008f3226dc89a0 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/44d64981fbbd355fecc095c46fcd91e1aa05abec b/fuzz/seed_corpus/44d64981fbbd355fecc095c46fcd91e1aa05abec new file mode 100644 index 000000000000..2cef3c49f089 --- /dev/null +++ b/fuzz/seed_corpus/44d64981fbbd355fecc095c46fcd91e1aa05abec @@ -0,0 +1,7 @@ + + + + +]> +
but thiswas not declaredseems diff --git a/fuzz/seed_corpus/44f4b6c5c6540ae1bed988d4487db558e0f7bbe6 b/fuzz/seed_corpus/44f4b6c5c6540ae1bed988d4487db558e0f7bbe6 new file mode 100644 index 000000000000..9d749dc33f98 --- /dev/null +++ b/fuzz/seed_corpus/44f4b6c5c6540ae1bed988d4487db558e0f7bbe6 @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/4536f5776d343fcb123edece5fc1cdf5c6ed2c50 b/fuzz/seed_corpus/4536f5776d343fcb123edece5fc1cdf5c6ed2c50 new file mode 100644 index 000000000000..0562021a75c1 --- /dev/null +++ b/fuzz/seed_corpus/4536f5776d343fcb123edece5fc1cdf5c6ed2c50 @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/fuzz/seed_corpus/45406f6ab8ec5b8e0cd3b53f1e9ddf22229164bf b/fuzz/seed_corpus/45406f6ab8ec5b8e0cd3b53f1e9ddf22229164bf new file mode 100644 index 000000000000..ac63df1ec28a --- /dev/null +++ b/fuzz/seed_corpus/45406f6ab8ec5b8e0cd3b53f1e9ddf22229164bf @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/46257dd92641aad954c2c044e970aa7ca0e2c754 b/fuzz/seed_corpus/46257dd92641aad954c2c044e970aa7ca0e2c754 new file mode 100644 index 000000000000..454e943693ba --- /dev/null +++ b/fuzz/seed_corpus/46257dd92641aad954c2c044e970aa7ca0e2c754 @@ -0,0 +1,10 @@ + + + + omg + + + +

yo

+ + diff --git a/fuzz/seed_corpus/464c8fcee563a32e7cb205f551928eb5f4dc1933 b/fuzz/seed_corpus/464c8fcee563a32e7cb205f551928eb5f4dc1933 new file mode 100644 index 000000000000..75d7d4af45cd --- /dev/null +++ b/fuzz/seed_corpus/464c8fcee563a32e7cb205f551928eb5f4dc1933 @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/4658d404a743dceff6fc22cb94a33e6402574915 b/fuzz/seed_corpus/4658d404a743dceff6fc22cb94a33e6402574915 new file mode 100644 index 000000000000..cd31c3d24dea --- /dev/null +++ b/fuzz/seed_corpus/4658d404a743dceff6fc22cb94a33e6402574915 @@ -0,0 +1,10 @@ + + + +"> +]> + + + &test.ent; + diff --git a/fuzz/seed_corpus/46683fe43cfa4089d2f77b35d19d8ef303e084d3 b/fuzz/seed_corpus/46683fe43cfa4089d2f77b35d19d8ef303e084d3 new file mode 100644 index 000000000000..67ff388aff96 --- /dev/null +++ b/fuzz/seed_corpus/46683fe43cfa4089d2f77b35d19d8ef303e084d3 @@ -0,0 +1,2 @@ + +
 violates [ WFC: Legal Character ] diff --git a/fuzz/seed_corpus/47424d8a8e83b35bedbf27bcfdb2ac189ee2bb1e b/fuzz/seed_corpus/47424d8a8e83b35bedbf27bcfdb2ac189ee2bb1e new file mode 100644 index 000000000000..4d7a55b4571d --- /dev/null +++ b/fuzz/seed_corpus/47424d8a8e83b35bedbf27bcfdb2ac189ee2bb1e @@ -0,0 +1,4 @@ +xpointer(//chapter[position() = 2]/range-to(following::chapter[1])) +xpointer(//chapter[position() <= 2]/range-to(following::chapter[1])) +xpointer(//chapter[position() = last()]/range-to(following::chapter[1])) +xpointer(//chapter[position() = 3]/range-to(/.//chapter[position() = 1])) diff --git a/fuzz/seed_corpus/4743c78e83308ea513d4f381e8d7b31d5539ea6a b/fuzz/seed_corpus/4743c78e83308ea513d4f381e8d7b31d5539ea6a new file mode 100644 index 000000000000..ffa9d1fa157c --- /dev/null +++ b/fuzz/seed_corpus/4743c78e83308ea513d4f381e8d7b31d5539ea6a @@ -0,0 +1,6 @@ + + + +]> + diff --git a/fuzz/seed_corpus/4781476c90a04890336cb413464e4395b77e4eca b/fuzz/seed_corpus/4781476c90a04890336cb413464e4395b77e4eca new file mode 100644 index 000000000000..689809314c9f --- /dev/null +++ b/fuzz/seed_corpus/4781476c90a04890336cb413464e4395b77e4eca @@ -0,0 +1,33 @@ + + + + + + + + + + + + + General graphics on a path + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/47b45388a5ac65198523036beb5ab4c2a7ba46d1 b/fuzz/seed_corpus/47b45388a5ac65198523036beb5ab4c2a7ba46d1 new file mode 100644 index 000000000000..62f6d9425cea --- /dev/null +++ b/fuzz/seed_corpus/47b45388a5ac65198523036beb5ab4c2a7ba46d1 @@ -0,0 +1,5 @@ + + + + + diff --git a/fuzz/seed_corpus/47c2a2a47068329771380ce60cdc1357e2c9a7dc b/fuzz/seed_corpus/47c2a2a47068329771380ce60cdc1357e2c9a7dc new file mode 100644 index 000000000000..8b5da69da281 --- /dev/null +++ b/fuzz/seed_corpus/47c2a2a47068329771380ce60cdc1357e2c9a7dc @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/480521dea9eca7fcb11fcb91f2f7c9c4c09d6b71 b/fuzz/seed_corpus/480521dea9eca7fcb11fcb91f2f7c9c4c09d6b71 new file mode 100644 index 000000000000..73b0d1c6a189 --- /dev/null +++ b/fuzz/seed_corpus/480521dea9eca7fcb11fcb91f2f7c9c4c09d6b71 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/480818cd511bf7fa9b81336e3328d77fa158b765 b/fuzz/seed_corpus/480818cd511bf7fa9b81336e3328d77fa158b765 new file mode 100644 index 000000000000..d32b3b4caa68 --- /dev/null +++ b/fuzz/seed_corpus/480818cd511bf7fa9b81336e3328d77fa158b765 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/483f0f90e088d334f471a93ecc7f0725943c0bef b/fuzz/seed_corpus/483f0f90e088d334f471a93ecc7f0725943c0bef new file mode 100644 index 000000000000..96be4772de44 --- /dev/null +++ b/fuzz/seed_corpus/483f0f90e088d334f471a93ecc7f0725943c0bef @@ -0,0 +1 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/48f438485efe8c9a5c34eaf6e0024268bce6ff0c b/fuzz/seed_corpus/48f438485efe8c9a5c34eaf6e0024268bce6ff0c new file mode 100644 index 000000000000..1a4776340349 --- /dev/null +++ b/fuzz/seed_corpus/48f438485efe8c9a5c34eaf6e0024268bce6ff0c @@ -0,0 +1,8 @@ + + + EMP0090 + EMP0099 + + diff --git a/fuzz/seed_corpus/49ca2a82b912ca616d9d471f3e4f5562a53b71c4 b/fuzz/seed_corpus/49ca2a82b912ca616d9d471f3e4f5562a53b71c4 new file mode 100644 index 000000000000..7a06092a91e8 --- /dev/null +++ b/fuzz/seed_corpus/49ca2a82b912ca616d9d471f3e4f5562a53b71c4 @@ -0,0 +1,10 @@ + + + + + + html + text + + + diff --git a/fuzz/seed_corpus/4a194b0925b048e8b6291dafbfa651d5c53cd283 b/fuzz/seed_corpus/4a194b0925b048e8b6291dafbfa651d5c53cd283 new file mode 100644 index 000000000000..9a0ad34a4ea7 --- /dev/null +++ b/fuzz/seed_corpus/4a194b0925b048e8b6291dafbfa651d5c53cd283 @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4a2757541d7829e1f204f6dc5b208289b5eaf980 b/fuzz/seed_corpus/4a2757541d7829e1f204f6dc5b208289b5eaf980 new file mode 100644 index 000000000000..43cd192dbd7e --- /dev/null +++ b/fuzz/seed_corpus/4a2757541d7829e1f204f6dc5b208289b5eaf980 @@ -0,0 +1,5 @@ + + +]> + violates [ WFC: No External Entity References ] diff --git a/fuzz/seed_corpus/4a43a4e1c4e9dfca40efb0fbd6f6d1a6411b1107 b/fuzz/seed_corpus/4a43a4e1c4e9dfca40efb0fbd6f6d1a6411b1107 new file mode 100644 index 000000000000..98f057cde812 --- /dev/null +++ b/fuzz/seed_corpus/4a43a4e1c4e9dfca40efb0fbd6f6d1a6411b1107 @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4acdb070b5b06a7f4be41f3bb99069aada552179 b/fuzz/seed_corpus/4acdb070b5b06a7f4be41f3bb99069aada552179 new file mode 100644 index 000000000000..48c7ff0471d1 --- /dev/null +++ b/fuzz/seed_corpus/4acdb070b5b06a7f4be41f3bb99069aada552179 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/4af3620e1994108a73f1fd5a5b4ba55b35ae02e5 b/fuzz/seed_corpus/4af3620e1994108a73f1fd5a5b4ba55b35ae02e5 new file mode 100644 index 000000000000..607982a02cdb --- /dev/null +++ b/fuzz/seed_corpus/4af3620e1994108a73f1fd5a5b4ba55b35ae02e5 @@ -0,0 +1,5 @@ + + + foobar + + diff --git a/fuzz/seed_corpus/4b5c1f8a6ceb49ff6decb04bd00b98aaf7c1b1cd b/fuzz/seed_corpus/4b5c1f8a6ceb49ff6decb04bd00b98aaf7c1b1cd new file mode 100644 index 000000000000..3f16a5020580 --- /dev/null +++ b/fuzz/seed_corpus/4b5c1f8a6ceb49ff6decb04bd00b98aaf7c1b1cd @@ -0,0 +1,6 @@ + + +]> + diff --git a/fuzz/seed_corpus/4b67b181831ff6621088e3ccf7c8d7b1c4fa5d77 b/fuzz/seed_corpus/4b67b181831ff6621088e3ccf7c8d7b1c4fa5d77 new file mode 100644 index 000000000000..5be33fa45b3a --- /dev/null +++ b/fuzz/seed_corpus/4b67b181831ff6621088e3ccf7c8d7b1c4fa5d77 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/4b703fd43074948f2c72ed24ca9e17d23e25c32a b/fuzz/seed_corpus/4b703fd43074948f2c72ed24ca9e17d23e25c32a new file mode 100644 index 000000000000..eb3bc2098469 --- /dev/null +++ b/fuzz/seed_corpus/4b703fd43074948f2c72ed24ca9e17d23e25c32a @@ -0,0 +1,20 @@ + +"> + + + + + + + + + + + + + +%laugh13; + diff --git a/fuzz/seed_corpus/4bbb4624f4d93f1a3f651608645391c84c36f4b5 b/fuzz/seed_corpus/4bbb4624f4d93f1a3f651608645391c84c36f4b5 new file mode 100644 index 000000000000..ae5e50960c2d --- /dev/null +++ b/fuzz/seed_corpus/4bbb4624f4d93f1a3f651608645391c84c36f4b5 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4bea843a4333d5e29c7abc2bb499b7d450c9842d b/fuzz/seed_corpus/4bea843a4333d5e29c7abc2bb499b7d450c9842d new file mode 100644 index 000000000000..76d73c089e69 --- /dev/null +++ b/fuzz/seed_corpus/4bea843a4333d5e29c7abc2bb499b7d450c9842d @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4bf6ebf590bf2b858824697a241340d053fee781 b/fuzz/seed_corpus/4bf6ebf590bf2b858824697a241340d053fee781 new file mode 100644 index 000000000000..edac8ba38323 --- /dev/null +++ b/fuzz/seed_corpus/4bf6ebf590bf2b858824697a241340d053fee781 @@ -0,0 +1,10 @@ + + + John Smith + js@example.com + + + Fred Bloggs + fb@example.net + + diff --git a/fuzz/seed_corpus/4c4cec9b73d30e9a3e2374b8c12688a475f9296a b/fuzz/seed_corpus/4c4cec9b73d30e9a3e2374b8c12688a475f9296a new file mode 100644 index 000000000000..796b996482fb --- /dev/null +++ b/fuzz/seed_corpus/4c4cec9b73d30e9a3e2374b8c12688a475f9296a @@ -0,0 +1,41 @@ + + + + + Kona Lavadome mountain bike + + This picture shows a mountain bike, a human-propelled, + multi-terrain vehicle. While it can be succesfully used on moorland, + forest, roads, and large hills it is not actually suitable for going + up mountains. + + + + 14/12 gauge double butted spoke + + + black anodised low torsion hub + + + twin wall, eyeletted rim + + + 8 speed, wide ratio gearing + + + double cross lacing of 32 spokes + + + + + Front wheel + The front wheel provides grip, steering and some shock absorption + + + + + + + + diff --git a/fuzz/seed_corpus/4c9427251bffa8ec07f62d5d1ed14c5e2d4a1e36 b/fuzz/seed_corpus/4c9427251bffa8ec07f62d5d1ed14c5e2d4a1e36 new file mode 100644 index 000000000000..86172c19c0a5 --- /dev/null +++ b/fuzz/seed_corpus/4c9427251bffa8ec07f62d5d1ed14c5e2d4a1e36 @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + false + + + + + + + + + + true + false + + + + + + + + + + + + + + + + + + + + + default + + optional + + + + + + + + + + + + + + default + mandatory + optional + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4cb66bc008b9d1e5b88463dcd2ac5793e54c5cb1 b/fuzz/seed_corpus/4cb66bc008b9d1e5b88463dcd2ac5793e54c5cb1 new file mode 100644 index 000000000000..6a6237ae95c5 --- /dev/null +++ b/fuzz/seed_corpus/4cb66bc008b9d1e5b88463dcd2ac5793e54c5cb1 @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4ce5ce6249ea49457dd8dfa450ff74560d6d7715 b/fuzz/seed_corpus/4ce5ce6249ea49457dd8dfa450ff74560d6d7715 new file mode 100644 index 000000000000..e94d48141226 --- /dev/null +++ b/fuzz/seed_corpus/4ce5ce6249ea49457dd8dfa450ff74560d6d7715 @@ -0,0 +1,4 @@ + + hello world + hello world + diff --git a/fuzz/seed_corpus/4ce8dbe5d8fe97177d838802c7f0abd770c49453 b/fuzz/seed_corpus/4ce8dbe5d8fe97177d838802c7f0abd770c49453 new file mode 100644 index 000000000000..cf2bcc6faab3 --- /dev/null +++ b/fuzz/seed_corpus/4ce8dbe5d8fe97177d838802c7f0abd770c49453 @@ -0,0 +1,253 @@ + + + + + + A description of an XML application which itemizes changes over the + life-span of a software project. Changes are tracked by releases, with a + granularity of individual items made up of files that were affected. + + + Randy J. Ray (rjray@blackperl.com) + 2004-11-22 + changelog,xml,schema + + An XML Schema declaration describing an XML expression of software + project change-logs. + + + + + + XML Schema for Changelogs + + An XML Schema declaration describing an XML expression of software + project change-logs. + + + + Randy J. Ray + + + + + Randy J. Ray + + + + + + + + + + + + + + + + + + + + + An open-ended container type for including version-control information + at various levels within the changelog structure. This is the only + type which explicitly permits content from foreign namespaces. + + + + + + + + + + + + + A description block is used to document everything from specific change + items to the release as a whole. + + + + + + + + + + + + + The versionString type is applied to attributes that describe simple + revision-number strings. It only supports CVS (RCS) styled version + numbers. + + + + + + + + + + + The fileType definition is used for the file element, a part of the + itemType declaration. It is defined separately so that it can be + referred to from multiple places. + + + + + + + + + + + + + + + + + + + + + + + + + + A file element contains a single block representing a fileType. + + + + + + + + + + + + These element blocks define a single change-item within the scope of a + given release. A change-item consists of one or more files that were + affected, and a description of the change itself. + + + + + + + + + + + + + + + + + + + + + + + + An item element contains a single block representing an itemType. + + + + + + + + + + + + The release is the primary piece of information that a changelog + collects and organizes. A release contains an optional description, + followed by one or more item blocks. The release element is also the + greatest user of attributes besides the file element. A release element + must have at least a "version" attribute, uniquely identifying the + release itself. Additionally, it may have "tag" to associate it with + a release-system tag and "date" to specify the date the release was + created. + + + + + + + + + + + + + + + + + + + + + + + + + + + + The changelog element is intended as the document root element. It + contains an overview element (identical in structure to the description + element, but named differently to prevent collision in XPath queries) + and one or more release blocks. + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4d19324092ee9096d1fbf4388eb615996cc18950 b/fuzz/seed_corpus/4d19324092ee9096d1fbf4388eb615996cc18950 new file mode 100644 index 000000000000..24e0b226b718 --- /dev/null +++ b/fuzz/seed_corpus/4d19324092ee9096d1fbf4388eb615996cc18950 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/4d4c13117d6e9ed6a34c2788fafb71b817303efe b/fuzz/seed_corpus/4d4c13117d6e9ed6a34c2788fafb71b817303efe new file mode 100644 index 000000000000..11423df2c1e8 --- /dev/null +++ b/fuzz/seed_corpus/4d4c13117d6e9ed6a34c2788fafb71b817303efe @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/4e4027f40b8e1c1a6ba70d29349f4bbdf8fd8ce4 b/fuzz/seed_corpus/4e4027f40b8e1c1a6ba70d29349f4bbdf8fd8ce4 new file mode 100644 index 000000000000..0f34854888c6 --- /dev/null +++ b/fuzz/seed_corpus/4e4027f40b8e1c1a6ba70d29349f4bbdf8fd8ce4 @@ -0,0 +1,15 @@ + + + + + + 0 + 0123456789ABCDEFGH + +abcdef0123456789 + -0123456789abcdef + + 112233445566778899 + + ab + 00fedc + diff --git a/fuzz/seed_corpus/4e9ded0041672e93f57529a3f4eac76346ab9bc6 b/fuzz/seed_corpus/4e9ded0041672e93f57529a3f4eac76346ab9bc6 new file mode 100644 index 000000000000..ce60d016636a --- /dev/null +++ b/fuzz/seed_corpus/4e9ded0041672e93f57529a3f4eac76346ab9bc6 @@ -0,0 +1,7 @@ + + + Let's use a DTD defined entity &bent; + + Let's use predefined entites & < > + + diff --git a/fuzz/seed_corpus/4ed56ff66d71f85b09f702026ed92a7184c4e08f b/fuzz/seed_corpus/4ed56ff66d71f85b09f702026ed92a7184c4e08f new file mode 100644 index 000000000000..207bd73ae19f --- /dev/null +++ b/fuzz/seed_corpus/4ed56ff66d71f85b09f702026ed92a7184c4e08f @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4edd7bf919d26f02cf0aa25ed518e8ff6642e066 b/fuzz/seed_corpus/4edd7bf919d26f02cf0aa25ed518e8ff6642e066 new file mode 100644 index 000000000000..709de1535ce4 --- /dev/null +++ b/fuzz/seed_corpus/4edd7bf919d26f02cf0aa25ed518e8ff6642e066 @@ -0,0 +1,6 @@ + + + +]> + diff --git a/fuzz/seed_corpus/4ee63249a9782f1c07aa0ac6765fcf805bab62ac b/fuzz/seed_corpus/4ee63249a9782f1c07aa0ac6765fcf805bab62ac new file mode 100644 index 000000000000..253e62058161 --- /dev/null +++ b/fuzz/seed_corpus/4ee63249a9782f1c07aa0ac6765fcf805bab62ac @@ -0,0 +1,1004 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4efbcc22ad3903c6da4503c806c257ecb49e8ee7 b/fuzz/seed_corpus/4efbcc22ad3903c6da4503c806c257ecb49e8ee7 new file mode 100644 index 000000000000..1a7f17c3466f --- /dev/null +++ b/fuzz/seed_corpus/4efbcc22ad3903c6da4503c806c257ecb49e8ee7 @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/4f0b4f0c0a1ab5357b685020fa52f6ca00f299b5 b/fuzz/seed_corpus/4f0b4f0c0a1ab5357b685020fa52f6ca00f299b5 new file mode 100644 index 000000000000..24d68f433503 --- /dev/null +++ b/fuzz/seed_corpus/4f0b4f0c0a1ab5357b685020fa52f6ca00f299b5 @@ -0,0 +1,1505 @@ + + + + +XHTML 1.0: The Extensible HyperText Markup +Language + + + + + +

W3C

+ +

XHTML 1.0: +The Extensible HyperText Markup Language

+ +

A Reformulation of HTML 4.0 in XML 1.0

+ +

W3C Proposed Recommendation 10 December 1999

+ +
+
This version:
+ +
+http://www.w3.org/TR/1999/PR-xhtml1-19991210
+(Postscript version, +PDF version, +ZIP archive, or +Gzip'd TAR archive) +
+ +
Latest version:
+ +
+http://www.w3.org/TR/xhtml1
+ +
Previous versions:
+ +
+http://www.w3.org/TR/1999/WD-xhtml1-19991124
+
+http://www.w3.org/TR/1999/PR-xhtml1-19990824
+ +
Authors:
+ +
See acknowledgements.
+
+ + +
+
+ +

Abstract

+ +

This specification defines XHTML 1.0, a reformulation of HTML +4.0 as an XML 1.0 application, and three DTDs corresponding to +the ones defined by HTML 4.0. The semantics of the elements and +their attributes are defined in the W3C Recommendation for HTML +4.0. These semantics provide the foundation for future +extensibility of XHTML. Compatibility with existing HTML user +agents is possible by following a small set of guidelines.

+ +

Status of this document

+ +

This section describes the status of this document at the time +of its publication. Other documents may supersede this document. The +latest status of this document series is maintained at the W3C.

+ +

This specification is a Proposed Recommendation of the HTML Working Group. It is +a revision of the Proposed Recommendation dated 24 August +1999 incorporating changes as a result of comments from the Proposed +Recommendation review, and +comments and further deliberations of the W3C HTML Working Group. A +diff-marked version from the previous +proposed recommendation is available for comparison purposes.

+ +

On 10 December 1999, this document enters a + +Proposed Recommendation review period. From that date until 8 January +2000, +W3C Advisory Committee representatives are encouraged +to review this specification and return comments in their completed +ballots to w3c-html-review@w3.org. Please send any comments of a +confidential nature in separate email to w3t-html@w3.org, which is +visible to the Team only.

+ +

No sooner than 14 days after the end of the review period, the +Director will announce the document's disposition: it may become a W3C +Recommendation (possibly with minor changes), it may revert to Working +Draft status, or it may be dropped as a W3C work item.

+ +

Publication as a Proposed Recommendation does not imply endorsement +by the W3C membership. This is still a draft document and may be +updated, replaced or obsoleted by other documents at any time. It is +inappropriate to cite W3C Proposed Recommendation as other than "work +in progress."

+ +

This document has been produced as part of the W3C HTML Activity. The goals of +the HTML Working +Group (members +only) are discussed in the HTML Working Group +charter (members +only).

+ +

A list of current W3C Recommendations and other technical documents +can be found at http://www.w3.org/TR.

+ +

Public discussion on HTML features takes place on the mailing list www-html@w3.org (archive). The W3C +staff contact for work on HTML is Dave +Raggett.

+ +

Please report errors in this document to www-html-editor@w3.org.

+ +

The list of known errors in this specification is available at http://www.w3.org/1999/12/PR-xhtml1-19991210-errata.

+ +

Contents

+ + + + +

1. What is XHTML?

+ +

XHTML is a family of current and future document types and modules that +reproduce, subset, and extend HTML 4.0 [HTML]. XHTML family document types are XML based, +and ultimately are designed to work in conjunction with XML-based user agents. +The details of this family and its evolution are +discussed in more detail in the section on Future +Directions.

+ +

XHTML 1.0 (this specification) is the first document type in the XHTML +family. It is a reformulation of the three HTML 4.0 document types as +applications of XML 1.0 [XML]. It is intended +to be used as a language for content that is both XML-conforming and, if some +simple guidelines are followed, +operates in HTML 4.0 conforming user agents. Developers who migrate +their content to XHTML 1.0 will realize the following benefits:

+ +
    +
  • XHTML documents are XML conforming. As such, they are readily viewed, +edited, and validated with standard XML tools.
  • +
  • XHTML documents can be written to +to operate as well or better than they did before in existing +HTML 4.0-conforming user agents as well as in new, XHTML 1.0 conforming user +agents.
  • +
  • XHTML documents can utilize applications (e.g. scripts and applets) that rely +upon either the HTML Document Object Model or the XML Document Object Model [DOM].
  • +
  • As the XHTML family evolves, documents conforming to XHTML 1.0 will be more +likely to interoperate within and among various XHTML environments.
  • +
+ +

The XHTML family is the next step in the evolution of the Internet. By +migrating to XHTML today, content developers can enter the XML world with all +of its attendant benefits, while still remaining confident in their +content's backward and future compatibility.

+ +

1.1 What is HTML 4.0?

+ +

HTML 4.0 [HTML] is an SGML (Standard +Generalized Markup Language) application conforming to +International Standard ISO 8879, and is widely regarded as the +standard publishing language of the World Wide Web.

+ +

SGML is a language for describing markup languages, +particularly those used in electronic document exchange, document +management, and document publishing. HTML is an example of a +language defined in SGML.

+ +

SGML has been around since the middle 1980's and has remained +quite stable. Much of this stability stems from the fact that the +language is both feature-rich and flexible. This flexibility, +however, comes at a price, and that price is a level of +complexity that has inhibited its adoption in a diversity of +environments, including the World Wide Web.

+ +

HTML, as originally conceived, was to be a language for the +exchange of scientific and other technical documents, suitable +for use by non-document specialists. HTML addressed the problem +of SGML complexity by specifying a small set of structural and +semantic tags suitable for authoring relatively simple documents. +In addition to simplifying the document structure, HTML added +support for hypertext. Multimedia capabilities were added +later.

+ +

In a remarkably short space of time, HTML became wildly +popular and rapidly outgrew its original purpose. Since HTML's +inception, there has been rapid invention of new elements for use +within HTML (as a standard) and for adapting HTML to vertical, +highly specialized, markets. This plethora of new elements has +led to compatibility problems for documents across different +platforms.

+ +

As the heterogeneity of both software and platforms rapidly +proliferate, it is clear that the suitability of 'classic' HTML +4.0 for use on these platforms is somewhat limited.

+ +

1.2 What is XML?

+ +

XML is the shorthand for Extensible Markup +Language, and is an acronym of Extensible Markup Language [XML].

+ +

XML was conceived as a means of regaining the power and +flexibility of SGML without most of its complexity. Although a +restricted form of SGML, XML nonetheless preserves most of SGML's +power and richness, and yet still retains all of SGML's commonly +used features.

+ +

While retaining these beneficial features, XML removes many of +the more complex features of SGML that make the authoring and +design of suitable software both difficult and costly.

+ +

1.3 Why the need for XHTML?

+ +

The benefits of migrating to XHTML 1.0 are described above. Some of the +benefits of migrating to XHTML in general are:

+ +
    +
  • Document developers and user agent designers are constantly +discovering new ways to express their ideas through new markup. In XML, it is +relatively easy to introduce new elements or additional element +attributes. The XHTML family is designed to accommodate these extensions +through XHTML modules and techniques for developing new XHTML-conforming +modules (described in the forthcoming XHTML Modularization specification). +These modules will permit the combination of existing and +new feature sets when developing content and when designing new user +agents.
  • + +
  • Alternate ways of accessing the Internet are constantly being +introduced. Some estimates indicate that by the year 2002, 75% of +Internet document viewing will be carried out on these alternate +platforms. The XHTML family is designed with general user agent +interoperability in mind. Through a new user agent and document profiling +mechanism, servers, proxies, and user agents will be able to perform +best effort content transformation. Ultimately, it will be possible to +develop XHTML-conforming content that is usable by any XHTML-conforming +user agent.
  • + +
+ +

2. Definitions

+ +

2.1 Terminology

+ +

The following terms are used in this specification. These +terms extend the definitions in +[RFC2119] in ways based upon similar definitions in ISO/IEC +9945-1:1990 [POSIX.1]:

+ +
+
Implementation-defined
+ +
A value or behavior is implementation-defined when it is left +to the implementation to define [and document] the corresponding +requirements for correct document construction.
+ +
May
+ +
With respect to implementations, the word "may" is to be +interpreted as an optional feature that is not required in this +specification but can be provided. With respect to Document Conformance, the word "may" means that +the optional feature must not be used. The term "optional" has +the same definition as "may".
+ +
Must
+ +
In this specification, the word "must" is to be interpreted +as a mandatory requirement on the implementation or on Strictly +Conforming XHTML Documents, depending upon the context. The term +"shall" has the same definition as "must".
+ +
Reserved
+ +
A value or behavior is unspecified, but it is not allowed to +be used by Conforming Documents nor to be supported by a +Conforming User Agents.
+ +
Should
+ +
With respect to implementations, the word "should" is to be +interpreted as an implementation recommendation, but not a +requirement. With respect to documents, the word "should" is to +be interpreted as recommended programming practice for documents +and a requirement for Strictly Conforming XHTML Documents.
+ +
Supported
+ +
Certain facilities in this specification are optional. If a +facility is supported, it behaves as specified by this +specification.
+ +
Unspecified
+ +
When a value or behavior is unspecified, the specification +defines no portability requirements for a facility on an +implementation even when faced with a document that uses the +facility. A document that requires specific behavior in such an +instance, rather than tolerating any behavior when using that +facility, is not a Strictly Conforming XHTML Document.
+
+ +

2.2 General Terms

+ +
+
Attribute
+ +
An attribute is a parameter to an element declared in the +DTD. An attribute's type and value range, including a possible +default value, are defined in the DTD.
+ +
DTD
+ +
A DTD, or document type definition, is a collection of XML +declarations that, as a collection, defines the legal structure, +elements, and +attributes that are available for use in a document that +complies to the DTD.
+ +
Document
+ +
A document is a stream of data that, after being combined +with any other streams it references, is structured such that it +holds information contained within +elements that are organized as defined in the associated +DTD. See Document +Conformance for more information.
+ +
Element
+ +
An element is a document structuring unit declared in the +DTD. The element's content model is +defined in the DTD, and additional +semantics may be defined in the prose description of the +element.
+ +
Facilities
+ +
Functionality includes elements, +attributes, and the semantics +associated with those elements and +attributes. An implementation +supporting that functionality is said to provide the necessary +facilities.
+ +
Implementation
+ +
An implementation is a system that provides collection of +facilities and services that supports +this specification. See User Agent +Conformance for more information.
+ +
Parsing
+ +
Parsing is the act whereby a +document is scanned, and the information contained within +the document is filtered into the +context of the elements in which the +information is structured.
+ +
Rendering
+ +
Rendering is the act whereby the information in a document is presented. This presentation is +done in the form most appropriate to the environment (e.g. +aurally, visually, in print).
+ +
User Agent
+ +
A user agent is an implementation +that retrieves and processes XHTML documents. See User Agent Conformance for more information.
+ +
Validation
+ +
Validation is a process whereby +documents are verified against the associated DTD, ensuring that the structure, use of elements, and use of +attributes are consistent with the definitions in the +DTD.
+ +
Well-formed
+ +
A document is well-formed when it +is structured according to the rules defined in Section 2.1 of +the XML 1.0 Recommendation [XML]. +Basically, this definition states that elements, delimited by +their start and end tags, are nested properly within one +another.
+
+ + +

3. Normative Definition of +XHTML 1.0

+ +

3.1 Document +Conformance

+ +

This version of XHTML provides a definition of strictly +conforming XHTML documents, which are restricted to tags and +attributes from the XHTML namespace. See Section 3.1.2 for information on using XHTML +with other namespaces, for instance, to include metadata +expressed in RDF within XHTML documents.

+ +

3.1.1 Strictly Conforming +Documents

+ +

A Strictly Conforming XHTML Document is a document that +requires only the facilities described as mandatory in this +specification. Such a document must meet all of the following +criteria:

+ +
    +
  1. +

    It must validate against one of the three DTDs found in Appendix A.

    +
  2. + +
  3. +

    The root element of the document must be +<html>.

    +
  4. + +
  5. +

    The root element of the document must designate the XHTML +namespace using the xmlns attribute [XMLNAMES]. The namespace for XHTML is +defined to be +http://www.w3.org/1999/xhtml.

    +
  6. + +
  7. +

    There must be a DOCTYPE declaration in the document prior to +the root element. The public identifier included in +the DOCTYPE declaration must reference one of the three DTDs +found in Appendix A using the respective +Formal Public Identifier. The system identifier may be changed to reflect +local system conventions.

    + +
    +<!DOCTYPE html 
    +     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    +     "http://www.w3.org/TR/1999/PR-xhtml1-19991210/DTD/xhtml1-strict.dtd>
    +
    +<!DOCTYPE html 
    +     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    +     "http://www.w3.org/TR/1999/PR-xhtml1-19991210/DTD/xhtml1-transitional.dtd>
    +
    +<!DOCTYPE html 
    +     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
    +     "http://www.w3.org/TR/1999/PR-xhtml1-19991210/DTD/xhtml1-frameset.dtd>
    +
    +
  8. +
+ +

Here is an example of a minimal XHTML document.

+ +
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html 
+     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/1999/PR-xhtml1-19991210/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <title>Virtual Library</title>
+  </head>
+  <body>
+    <p>Moved to <a href="http://vlib.org/">vlib.org</a>.</p>
+  </body>
+</html>
+
+ +

Note that in this example, the XML declaration is included. An XML +declaration like the one above is +not required in all XML documents. XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required +when the character encoding of the document is other than the default UTF-8 or +UTF-16.

+ +

3.1.2 Using XHTML with +other namespaces

+ +

The XHTML namespace may be used with other XML namespaces +as per [XMLNAMES], although such +documents are not strictly conforming XHTML 1.0 documents as +defined above. Future work by W3C will address ways to specify +conformance for documents involving multiple namespaces.

+ +

The following example shows the way in which XHTML 1.0 could +be used in conjunction with the MathML Recommendation:

+ +
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <title>A Math Example</title>
+  </head>
+  <body>
+    <p>The following is MathML markup:</p>
+    <math xmlns="http://www.w3.org/1998/Math/MathML">
+      <apply> <log/>
+        <logbase>
+          <cn> 3 </cn>
+        </logbase>
+        <ci> x </ci>
+      </apply>
+    </math>
+  </body>
+</html>
+
+
+ +

The following example shows the way in which XHTML 1.0 markup +could be incorporated into another XML namespace:

+ +
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- initially, the default namespace is "books" -->
+<book xmlns='urn:loc.gov:books'
+    xmlns:isbn='urn:ISBN:0-395-36341-6' xml:lang="en" lang="en">
+  <title>Cheaper by the Dozen</title>
+  <isbn:number>1568491379</isbn:number>
+  <notes>
+    <!-- make HTML the default namespace for a hypertext commentary -->
+    <p xmlns='http://www.w3.org/1999/xhtml'>
+        This is also available <a href="http://www.w3.org/">online</a>.
+    </p>
+  </notes>
+</book>
+
+
+ +

3.2 User Agent +Conformance

+ +

A conforming user agent must meet all of the following +criteria:

+ +
    +
  1. In order to be consistent with the XML 1.0 Recommendation [XML], the user agent must parse and evaluate +an XHTML document for well-formedness. If the user agent claims +to be a validating user agent, it must also validate documents +against their referenced DTDs according to +[XML].
  2. + +
  3. When the user agent claims to support +facilities defined within this specification or required by +this specification through normative reference, it must do so in +ways consistent with the facilities' definition.
  4. + +
  5. When a user agent processes an XHTML document as generic XML, +it shall only recognize attributes of type +ID (e.g. the id attribute on most XHTML elements) +as fragment identifiers.
  6. + +
  7. If a user agent encounters an element it does not recognize, +it must render the element's content.
  8. + +
  9. If a user agent encounters an attribute it does not +recognize, it must ignore the entire attribute specification +(i.e., the attribute and its value).
  10. + +
  11. If a user agent encounters an attribute value it doesn't +recognize, it must use the default attribute value.
  12. + +
  13. If it encounters an entity reference (other than one +of the predefined entities) for which the User Agent has +processed no declaration (which could happen if the declaration +is in the external subset which the User Agent hasn't read), the entity +reference should be rendered as the characters (starting +with the ampersand and ending with the semi-colon) that +make up the entity reference.
  14. + +
  15. When rendering content, User Agents that encounter +characters or character entity references that are recognized but not renderable should display the document in such a way that it is obvious to the user that normal rendering has not taken place.
  16. + +
  17. +The following characters are defined in [XML] as whitespace characters: + +
      +
    • Space (&#x0020;)
    • +
    • Tab (&#x0009;)
    • +
    • Carriage return (&#x000D;)
    • +
    • Line feed (&#x000A;)
    • +
    + +

    +The XML processor normalizes different system's line end codes into one +single line-feed character, that is passed up to the application. The XHTML +user agent in addition, must treat the following characters as whitespace: +

    + +
      +
    • Form feed (&#x000C;)
    • +
    • Zero-width space (&#x200B;)
    • +
    + +

    +In elements where the 'xml:space' attribute is set to 'preserve', the user +agent must leave all whitespace characters intact (with the exception of +leading and trailing whitespace characters, which should be removed). +Otherwise, whitespace +is handled according to the following rules: +

    + +
      +
    • +All whitespace surrounding block elements should be removed. +
    • +
    • +Comments are removed entirely and do not affect whitespace handling. One +whitespace character on either side of a comment is treated as two white +space characters. +
    • +
    • +Leading and trailing whitespace inside a block element must be removed. +
    • +
    • Line feed characters within a block element must be converted into a +space (except when the 'xml:space' attribute is set to 'preserve'). +
    • +
    • +A sequence of white space characters must be reduced to a single space +character (except when the 'xml:space' attribute is set to 'preserve'). +
    • +
    • +With regard to rendition, +the User Agent should render the content in a +manner appropriate to the language in which the content is written. +In languages whose primary script is Latinate, the ASCII space +character is typically used to encode both grammatical word boundaries and +typographic whitespace; in languages whose script is related to Nagari +(e.g., Sanskrit, Thai, etc.), grammatical boundaries may be encoded using +the ZW 'space' character, but will not typically be represented by +typographic whitespace in rendered output; languages using Arabiform scripts +may encode typographic whitespace using a space character, but may also use +the ZW space character to delimit 'internal' grammatical boundaries (what +look like words in Arabic to an English eye frequently encode several words, +e.g. 'kitAbuhum' = 'kitAbu-hum' = 'book them' == their book); and languages +in the Chinese script tradition typically neither encode such delimiters nor +use typographic whitespace in this way. +
    • +
    + +

    Whitespace in attribute values is processed according to [XML].

    +
  18. +
+ + +

4. Differences with HTML +4.0

+ +

Due to the fact that XHTML is an XML application, certain +practices that were perfectly legal in SGML-based HTML 4.0 [HTML] must be changed.

+ +

4.1 Documents must be +well-formed

+ +

Well-formedness is a new concept +introduced by [XML]. Essentially this +means that all elements must either have closing tags or be +written in a special form (as described below), and that all the +elements must nest.

+ +

Although overlapping is illegal in SGML, it was widely +tolerated in existing browsers.

+ +
+

CORRECT: nested elements.

+ +

<p>here is an emphasized +<em>paragraph</em>.</p>

+
+ +
+

INCORRECT: overlapping elements

+ +

<p>here is an emphasized +<em>paragraph.</p></em>

+
+ +

4.2 Element and attribute +names must be in lower case

+ +

XHTML documents must use lower case for all HTML element and +attribute names. This difference is necessary because XML is +case-sensitive e.g. <li> and <LI> are different +tags.

+ +

4.3 For non-empty elements, +end tags are required

+ +

In SGML-based HTML 4.0 certain elements were permitted to omit +the end tag; with the elements that followed implying closure. +This omission is not permitted in XML-based XHTML. All elements +other than those declared in the DTD as EMPTY must +have an end tag.

+ +
+

CORRECT: terminated elements

+ +

<p>here is a paragraph.</p><p>here is +another paragraph.</p>

+
+ +
+

INCORRECT: unterminated elements

+ +

<p>here is a paragraph.<p>here is another +paragraph.

+
+ +

4.4 Attribute values must +always be quoted

+ +

All attribute values must be quoted, even those which appear +to be numeric.

+ +
+

CORRECT: quoted attribute values

+ +

<table rows="3">

+
+ +
+

INCORRECT: unquoted attribute values

+ +

<table rows=3>

+
+ +

4.5 Attribute +Minimization

+ +

XML does not support attribute minimization. Attribute-value +pairs must be written in full. Attribute names such as +compact and checked cannot occur in elements +without their value being specified.

+ +
+

CORRECT: unminimized attributes

+ +

<dl compact="compact">

+
+ +
+

INCORRECT: minimized attributes

+ +

<dl compact>

+
+ +

4.6 Empty Elements

+ +

Empty elements must either have an end tag or the start tag must end with />. For instance, +<br/> or <hr></hr>. See HTML Compatibility Guidelines for information on ways to +ensure this is backward compatible with HTML 4.0 user agents.

+ +
+

CORRECT: terminated empty tags

+ +

<br/><hr/>

+
+ +
+

INCORRECT: unterminated empty tags

+ +

<br><hr>

+
+ +

4.7 Whitespace handling in +attribute values

+ +

In attribute values, user agents will strip leading and +trailing whitespace from attribute values and map sequences +of one or more whitespace characters (including line breaks) to +a single inter-word space (an ASCII space character for western +scripts). See +Section 3.3.3 of [XML].

+ +

4.8 Script and Style +elements

+ +

In XHTML, the script and style elements are declared as having +#PCDATA content. As a result, < and +& will be treated as the start of markup, and +entities such as &lt; and &amp; +will be recognized as entity references by the XML processor to +< and & respectively. Wrapping +the content of the script or style element within a +CDATA marked section avoids the expansion of these +entities.

+ +
+
+<script>
+ <![CDATA[
+ ... unescaped script content ...
+ ]]>
+ </script>
+
+
+ +

CDATA sections are recognized by the XML +processor and appear as nodes in the Document Object Model, see + +Section 1.3 of the DOM Level 1 Recommendation [DOM].

+ +

An alternative is to use external script and style +documents.

+ +

4.9 SGML exclusions

+ +

SGML gives the writer of a DTD the ability to exclude specific +elements from being contained within an element. Such +prohibitions (called "exclusions") are not possible in XML.

+ +

For example, the HTML 4.0 Strict DTD forbids the nesting of an +'a' element within another 'a' element +to any descendant depth. It is not possible to spell out such +prohibitions in XML. Even though these prohibitions cannot be +defined in the DTD, certain elements should not be nested. A +summary of such elements and the elements that should not be +nested in them is found in the normative +Appendix B.

+ +

4.10 The elements with 'id' and 'name' +attributes

+ +

HTML 4.0 defined the name attribute for the elements +a, +applet, frame, +iframe, img, and map. +HTML 4.0 also introduced +the id attribute. Both of these attributes are designed to be +used as fragment identifiers.

+

In XML, fragment identifiers are of type ID, and +there can only be a single attribute of type ID per element. +Therefore, in XHTML 1.0 the id +attribute is defined to be of type ID. In order to +ensure that XHTML 1.0 documents are well-structured XML documents, XHTML 1.0 +documents MUST use the id attribute when defining fragment +identifiers, even on elements that historically have also had a +name attribute. +See the HTML Compatibility +Guidelines for information on ensuring such anchors are backwards +compatible when serving XHTML documents as media type text/html. +

+

Note that in XHTML 1.0, the name attribute of these +elements is formally deprecated, and will be removed in a +subsequent version of XHTML.

+ + +

5. Compatibility Issues

+ +

Although there is no requirement for XHTML 1.0 documents to be +compatible with existing user agents, in practice this is easy to +accomplish. Guidelines for creating compatible documents can be +found in Appendix C.

+ +

5.1 Internet Media Type

+

As of the publication of this recommendation, the general +recommended MIME labeling for XML-based applications +has yet to be resolved.

+ +

However, XHTML Documents which follow the guidelines set forth +in Appendix C, "HTML Compatibility Guidelines" may be +labeled with the Internet Media Type "text/html", as they +are compatible with most HTML browsers. This document +makes no recommendation about MIME labeling of other +XHTML documents.

+ + +

6. Future Directions

+ +

XHTML 1.0 provides the basis for a family of document types +that will extend and subset XHTML, in order to support a wide +range of new devices and applications, by defining modules and +specifying a mechanism for combining these modules. This +mechanism will enable the extension and sub-setting of XHTML 1.0 +in a uniform way through the definition of new modules.

+ +

6.1 Modularizing HTML

+ +

As the use of XHTML moves from the traditional desktop user +agents to other platforms, it is clear that not all of the XHTML +elements will be required on all platforms. For example a hand +held device or a cell-phone may only support a subset of XHTML +elements.

+ +

The process of modularization breaks XHTML up into a series of +smaller element sets. These elements can then be recombined to +meet the needs of different communities.

+ +

These modules will be defined in a later W3C document.

+ +

6.2 Subsets and +Extensibility

+ +

Modularization brings with it several advantages:

+ +
    +
  • +

    It provides a formal mechanism for sub-setting XHTML.

    +
  • + +
  • +

    It provides a formal mechanism for extending XHTML.

    +
  • + +
  • +

    It simplifies the transformation between document types.

    +
  • + +
  • +

    It promotes the reuse of modules in new document types.

    +
  • +
+ +

6.3 Document +Profiles

+ +

A document profile specifies the syntax and semantics of a set +of documents. Conformance to a document profile provides a basis +for interoperability guarantees. The document profile specifies +the facilities required to process documents of that type, e.g. +which image formats can be used, levels of scripting, style sheet +support, and so on.

+ +

For product designers this enables various groups to define +their own standard profile.

+ +

For authors this will obviate the need to write several +different versions of documents for different clients.

+ +

For special groups such as chemists, medical doctors, or +mathematicians this allows a special profile to be built using +standard HTML elements plus a group of elements geared to the +specialist's needs.

+ + +

+Appendix A. DTDs

+ +

This appendix is normative.

+ +

These DTDs and entity sets form a normative part of this +specification. The complete set of DTD files together with an XML +declaration and SGML Open Catalog is included in the zip file for this specification.

+ +

A.1 Document Type +Definitions

+ +

These DTDs approximate the HTML 4.0 DTDs. It is likely that +when the DTDs are modularized, a method of DTD construction will +be employed that corresponds more closely to HTML 4.0.

+ + + +

A.2 Entity Sets

+ +

The XHTML entity sets are the same as for HTML 4.0, but have +been modified to be valid XML 1.0 entity declarations. Note the +entity for the Euro currency sign (&euro; or +&#8364; or &#x20AC;) is defined +as part of the special characters.

+ + + + +

Appendix B. Element +Prohibitions

+ +

This appendix is normative.

+ +

The following elements have prohibitions on which elements +they can contain (see Section 4.9). This +prohibition applies to all depths of nesting, i.e. it contains +all the descendant elements.

+ +
a
+
+cannot contain other a elements.
+
pre
+
cannot contain the img, object, +big, small, sub, or +sup elements.
+ +
button
+
cannot contain the input, select, +textarea, label, button, +form, fieldset, iframe or +isindex elements.
+
label
+
cannot contain other label elements.
+
form
+
cannot contain other form elements.
+
+ + +

Appendix C. +HTML Compatibility Guidelines

+ +

This appendix is informative.

+ +

This appendix summarizes design guidelines for authors who +wish their XHTML documents to render on existing HTML user +agents.

+ +

C.1 Processing Instructions

+

Be aware that processing instructions are rendered on some +user agents. However, also note that when the XML declaration is not included +in a document, the document can only use the default character encodings UTF-8 +or UTF-16.

+ +

C.2 Empty Elements

+

Include a space before the trailing / and +> of empty elements, e.g. +<br />, +<hr /> and <img +src="karen.jpg" alt="Karen" />. Also, use the +minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML +gives uncertain results in many existing user agents.

+ +

C.3 Element Minimization and Empty Element Content

+

Given an empty instance of an element whose content model is +not EMPTY (for example, an empty title or paragraph) +do not use the minimized form (e.g. use +<p> </p> and not +<p />).

+ +

C.4 Embedded Style Sheets and Scripts

+

Use external style sheets if your style sheet uses +< or & or ]]> or --. Use +external scripts if your script uses < or +& or ]]> or --. Note that XML parsers +are permitted to silently remove the contents of comments. Therefore, the historical +practice of "hiding" scripts and style sheets within comments to make the +documents backward compatible is likely to not work as expected in XML-based +implementations.

+ +

C.5 Line Breaks within Attribute Values

+

Avoid line breaks and multiple whitespace characters within +attribute values. These are handled inconsistently by user +agents.

+ +

C.6 Isindex

+

Don't include more than one isindex element in +the document head. The isindex element +is deprecated in favor of the input element.

+ +

C.7 The lang and xml:lang Attributes

+

Use both the lang and xml:lang +attributes when specifying the language of an element. The value +of the xml:lang attribute takes precedence.

+ +

C.8 Fragment Identifiers

+

In XML, URIs [RFC2396] that end with fragment identifiers of the form +"#foo" do not refer to elements with an attribute +name="foo"; rather, they refer to elements with an +attribute defined to be of type ID, e.g., the +id attribute in HTML 4.0. Many existing HTML clients don't +support the use of ID-type attributes in this way, +so identical values may be supplied for both of these attributes to ensure +maximum forward and backward compatibility (e.g., <a id="foo" name="foo">...</a>).

+ +

Further, since the set of +legal values for attributes of type ID is much smaller than +for those of type CDATA, the type of the name +attribute has been changed to NMTOKEN. This attribute is +constrained such that it can only have the same values as type +ID, or as the Name production in XML 1.0 Section +2.5, production 5. Unfortunately, this constraint cannot be expressed in the +XHTML 1.0 DTDs. Because of this change, care must be taken when +converting existing HTML documents. The values of these attributes +must be unique within the document, valid, and any references to these +fragment identifiers (both +internal and external) must be updated should the values be changed during +conversion.

+

Finally, note that XHTML 1.0 has deprecated the +name attribute of the a, applet, frame, iframe, img, and map +elements, and it will be +removed from XHTML in subsequent versions.

+ +

C.9 Character Encoding

+

To specify a character encoding in the document, use both the +encoding attribute specification on the xml declaration (e.g. +<?xml version="1.0" +encoding="EUC-JP"?>) and a meta http-equiv statement +(e.g. <meta http-equiv="Content-type" +content='text/html; charset="EUC-JP"' />). The +value of the encoding attribute of the xml processing instruction +takes precedence.

+ +

C.10 Boolean Attributes

+

Some HTML user agents are unable to interpret boolean +attributes when these appear in their full (non-minimized) form, +as required by XML 1.0. Note this problem doesn't effect user +agents compliant with HTML 4.0. The following attributes are +involved: compact, nowrap, +ismap, declare, noshade, +checked, disabled, readonly, +multiple, selected, +noresize, defer.

+ +

C.11 Document Object Model and XHTML

+

+The Document Object Model level 1 Recommendation [DOM] +defines document object model interfaces for XML and HTML 4.0. The HTML 4.0 +document object model specifies that HTML element and attribute names are +returned in upper-case. The XML document object model specifies that +element and attribute names are returned in the case they are specified. In +XHTML 1.0, elements and attributes are specified in lower-case. This apparent difference can be +addressed in two ways: +

+
    +
  1. Applications that access XHTML documents served as Internet media type +text/html +via the DOM can use the HTML DOM, +and can rely upon element and attribute names being returned in +upper-case from those interfaces.
  2. +
  3. Applications that access XHTML documents served as Internet media types +text/xml or application/xml +can also use the XML DOM. Elements and attributes will be returned in lower-case. +Also, some XHTML elements may or may +not appear +in the object tree because they are optional in the content model +(e.g. the tbody element within +table). This occurs because in HTML 4.0 some elements were +permitted to be minimized such that their start and end tags are both omitted +(an SGML feature). +This is not possible in XML. Rather than require document authors to insert +extraneous elements, XHTML has made the elements optional. +Applications need to adapt to this +accordingly.
  4. +
+ +

C.12 Using Ampersands in Attribute Values

+

+When an attribute value contains an ampersand, it must be expressed as a character +entity reference +(e.g. "&amp;"). For example, when the +href attribute +of the a element refers to a +CGI script that takes parameters, it must be expressed as +http://my.site.dom/cgi-bin/myscript.pl?class=guest&amp;name=user +rather than as +http://my.site.dom/cgi-bin/myscript.pl?class=guest&name=user. +

+ +

C.13 Cascading Style Sheets (CSS) and XHTML

+ +

The Cascading Style Sheets level 2 Recommendation [CSS2] defines style +properties which are applied to the parse tree of the HTML or XML +document. Differences in parsing will produce different visual or +aural results, depending on the selectors used. The following hints +will reduce this effect for documents which are served without +modification as both media types:

+ +
    +
  1. +CSS style sheets for XHTML should use lower case element and +attribute names.
  2. + + +
  3. In tables, the tbody element will be inferred by the parser of an +HTML user agent, but not by the parser of an XML user agent. Therefore +you should always explicitely add a tbody element if it is referred to +in a CSS selector.
  4. + +
  5. Within the XHTML name space, user agents are expected to +recognize the "id" attribute as an attribute of type ID. +Therefore, style sheets should be able to continue using the +shorthand "#" selector syntax even if the user agent does not read +the DTD.
  6. + +
  7. Within the XHTML name space, user agents are expected to +recognize the "class" attribute. Therefore, style sheets should be +able to continue using the shorthand "." selector syntax.
  8. + +
  9. +CSS defines different conformance rules for HTML and XML documents; +be aware that the HTML rules apply to XHTML documents delivered as +HTML and the XML rules apply to XHTML documents delivered as XML.
  10. +
+ +

Appendix D. +Acknowledgements

+ +

This appendix is informative.

+ +

This specification was written with the participation of the +members of the W3C HTML working group:

+ +
+
Steven Pemberton, CWI (HTML Working Group Chair)
+Murray Altheim, Sun Microsystems
+Daniel Austin, CNET: The Computer Network
+Frank Boumphrey, HTML Writers Guild
+John Burger, Mitre
+Andrew W. Donoho, IBM
+Sam Dooley, IBM
+Klaus Hofrichter, GMD
+Philipp Hoschka, W3C
+Masayasu Ishikawa, W3C
+Warner ten Kate, Philips Electronics
+Peter King, Phone.com
+Paula Klante, JetForm
+Shin'ichi Matsui, W3C/Panasonic
+Shane McCarron, Applied Testing and Technology (The Open Group through August +1999)
+Ann Navarro, HTML Writers Guild
+Zach Nies, Quark
+Dave Raggett, W3C/HP (W3C lead for HTML)
+Patrick Schmitz, Microsoft
+Sebastian Schnitzenbaumer, Stack Overflow
+Chris Wilson, Microsoft
+Ted Wugofski, Gateway 2000
+Dan Zigmond, WebTV Networks
+
+ + +

Appendix E. References

+ +

This appendix is informative.

+ +
+ +
[CSS2]
+ +
"Cascading Style Sheets, level 2 (CSS2) Specification", B. +Bos, H. W. Lie, C. Lilley, I. Jacobs, 12 May 1998.
+Available at: +http://www.w3.org/TR/REC-CSS2
+ +
[DOM]
+ +
"Document Object Model (DOM) Level 1 Specification", Lauren +Wood et al., 1 October 1998.
+Available at: +http://www.w3.org/TR/REC-DOM-Level-1
+ +
[HTML]
+ +
"HTML 4.01 Specification", D. Raggett, A. Le Hors, I. +Jacobs, 24 August 1999.
+Available at: +http://www.w3.org/TR/1999/PR-html40-19990824
+ +
[POSIX.1]
+ +
"ISO/IEC 9945-1:1990 Information Technology - Portable +Operating System Interface (POSIX) - Part 1: System Application +Program Interface (API) [C Language]", Institute of Electrical +and Electronics Engineers, Inc, 1990.
+ +
+[RFC2046]
+ +
"RFC2046: Multipurpose Internet Mail Extensions (MIME) Part +Two: Media Types", N. Freed and N. Borenstein, November +1996.
+Available at +http://www.ietf.org/rfc/rfc2046.txt. Note that this RFC +obsoletes RFC1521, RFC1522, and RFC1590.
+ +
+[RFC2119]
+ +
"RFC2119: Key words for use in RFCs to Indicate Requirement +Levels", S. Bradner, March 1997.
+Available at: +http://www.ietf.org/rfc/rfc2119.txt
+ +
+[RFC2376]
+ +
"RFC2376: XML Media Types", E. Whitehead, M. Murata, July +1998.
+Available at: +http://www.ietf.org/rfc/rfc2376.txt
+ +
+[RFC2396]
+ +
"RFC2396: Uniform Resource Identifiers (URI): Generic +Syntax", T. Berners-Lee, R. Fielding, L. Masinter, August +1998.
+This document updates RFC1738 and RFC1808.
+Available at: +http://www.ietf.org/rfc/rfc2396.txt
+ +
[XML]
+ +
"Extensible Markup Language (XML) 1.0 Specification", T. +Bray, J. Paoli, C. M. Sperberg-McQueen, 10 February 1998.
+Available at: +http://www.w3.org/TR/REC-xml
+ +
[XMLNAMES]
+ +
"Namespaces in XML", T. Bray, D. Hollander, A. Layman, 14 +January 1999.
+XML namespaces provide a simple method for qualifying names used +in XML documents by associating them with namespaces identified +by URI.
+Available at: +http://www.w3.org/TR/REC-xml-names
+ +
+

+

+ + + + diff --git a/fuzz/seed_corpus/4f0e428b168f9e0c0097c13f4d27df23b3cb9e87 b/fuzz/seed_corpus/4f0e428b168f9e0c0097c13f4d27df23b3cb9e87 new file mode 100644 index 000000000000..756c73f27738 --- /dev/null +++ b/fuzz/seed_corpus/4f0e428b168f9e0c0097c13f4d27df23b3cb9e87 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/4f1cf7603c13087f1ca2c6f7871366a830282e1e b/fuzz/seed_corpus/4f1cf7603c13087f1ca2c6f7871366a830282e1e new file mode 100644 index 000000000000..7e09fab861cd --- /dev/null +++ b/fuzz/seed_corpus/4f1cf7603c13087f1ca2c6f7871366a830282e1e @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/4f2e0e0472d181cc8f28a17c2bc7caf508b70442 b/fuzz/seed_corpus/4f2e0e0472d181cc8f28a17c2bc7caf508b70442 new file mode 100644 index 000000000000..45dceff4f4ed --- /dev/null +++ b/fuzz/seed_corpus/4f2e0e0472d181cc8f28a17c2bc7caf508b70442 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/4f303abba6d7b9e8480ff0b62e21c0185c1b024f b/fuzz/seed_corpus/4f303abba6d7b9e8480ff0b62e21c0185c1b024f new file mode 100644 index 000000000000..c0436e82f98f --- /dev/null +++ b/fuzz/seed_corpus/4f303abba6d7b9e8480ff0b62e21c0185c1b024f @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/4fdd1e32ed7a2bfc01c5e84e2c0850efd184a7d2 b/fuzz/seed_corpus/4fdd1e32ed7a2bfc01c5e84e2c0850efd184a7d2 new file mode 100644 index 000000000000..f53b0ca9faf4 --- /dev/null +++ b/fuzz/seed_corpus/4fdd1e32ed7a2bfc01c5e84e2c0850efd184a7d2 @@ -0,0 +1,9 @@ + + + +]> + diff --git a/fuzz/seed_corpus/4ff17ce8da70de5a7c8da2509618d12b57f30156 b/fuzz/seed_corpus/4ff17ce8da70de5a7c8da2509618d12b57f30156 new file mode 100644 index 000000000000..4d28f332ee99 --- /dev/null +++ b/fuzz/seed_corpus/4ff17ce8da70de5a7c8da2509618d12b57f30156 @@ -0,0 +1,32 @@ + + + This example uses the switch element to provide a + fallback graphical representation of an equation, if + MathML is not supported. + + + + + + + + + + + + + + Formula goes here + + + + diff --git a/fuzz/seed_corpus/4ff2cfdf87cd976aa9c447de5dd84afd3bb5407a b/fuzz/seed_corpus/4ff2cfdf87cd976aa9c447de5dd84afd3bb5407a new file mode 100644 index 000000000000..76e5f45d8476 --- /dev/null +++ b/fuzz/seed_corpus/4ff2cfdf87cd976aa9c447de5dd84afd3bb5407a @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/5013d9f2aa7285f8e044bdf18606dceb8c4d298a b/fuzz/seed_corpus/5013d9f2aa7285f8e044bdf18606dceb8c4d298a new file mode 100644 index 000000000000..d021a831227a --- /dev/null +++ b/fuzz/seed_corpus/5013d9f2aa7285f8e044bdf18606dceb8c4d298a @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/fuzz/seed_corpus/503fbe110e1acb177aa715e87571864419348239 b/fuzz/seed_corpus/503fbe110e1acb177aa715e87571864419348239 new file mode 100644 index 000000000000..1ba44016e101 --- /dev/null +++ b/fuzz/seed_corpus/503fbe110e1acb177aa715e87571864419348239 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/50784dd9ece4c9fe863d7e6d1f19dfd56b74cb21 b/fuzz/seed_corpus/50784dd9ece4c9fe863d7e6d1f19dfd56b74cb21 new file mode 100644 index 000000000000..812d44a829a0 --- /dev/null +++ b/fuzz/seed_corpus/50784dd9ece4c9fe863d7e6d1f19dfd56b74cb21 @@ -0,0 +1,5 @@ + + bbbb + cccc + aaa@aaa.net + diff --git a/fuzz/seed_corpus/507c20ff48de0ee77b9edfd5468a7dd7d10c2988 b/fuzz/seed_corpus/507c20ff48de0ee77b9edfd5468a7dd7d10c2988 new file mode 100644 index 000000000000..b714a0d3d14c --- /dev/null +++ b/fuzz/seed_corpus/507c20ff48de0ee77b9edfd5468a7dd7d10c2988 @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/507f785de339557ac967f7c224f5c0bcb62c6c6d b/fuzz/seed_corpus/507f785de339557ac967f7c224f5c0bcb62c6c6d new file mode 100644 index 000000000000..a0122f4b930c --- /dev/null +++ b/fuzz/seed_corpus/507f785de339557ac967f7c224f5c0bcb62c6c6d @@ -0,0 +1,11 @@ + + + + + + diff --git a/fuzz/seed_corpus/50d9b549a915f5064a2c42f3c7300b8dc960e801 b/fuzz/seed_corpus/50d9b549a915f5064a2c42f3c7300b8dc960e801 new file mode 100644 index 000000000000..f85de825c4bf --- /dev/null +++ b/fuzz/seed_corpus/50d9b549a915f5064a2c42f3c7300b8dc960e801 @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/50e38c6f79608773138f87f2a2c57fb0478848fe b/fuzz/seed_corpus/50e38c6f79608773138f87f2a2c57fb0478848fe new file mode 100644 index 000000000000..8da0ae593b54 --- /dev/null +++ b/fuzz/seed_corpus/50e38c6f79608773138f87f2a2c57fb0478848fe @@ -0,0 +1,3 @@ + + 12.234 + diff --git a/fuzz/seed_corpus/513e1171b324de6a4ef006d844a51c23ad653416 b/fuzz/seed_corpus/513e1171b324de6a4ef006d844a51c23ad653416 new file mode 100644 index 000000000000..64982f531062 --- /dev/null +++ b/fuzz/seed_corpus/513e1171b324de6a4ef006d844a51c23ad653416 @@ -0,0 +1,2079 @@ + + + + +

+
Search news


News + archive
+ + + +
+ + +
+
+

PC Price + Search

+





BP6.com Special - Enter CODE: BP6-hd in the order (notes) to receive a discount
BP6.COM + Special
Code:BP6-hd

+ + + +
 

+
  + + + +
+

Copyright + ©1999-2000 BP6.com, All rights reserved.
Got news? Send it to
Tim

+ + diff --git a/fuzz/seed_corpus/616f8ed5c640e2a0df8f17d1a8a3d3e2f3cfe093 b/fuzz/seed_corpus/616f8ed5c640e2a0df8f17d1a8a3d3e2f3cfe093 new file mode 100644 index 000000000000..161be66ed2a4 --- /dev/null +++ b/fuzz/seed_corpus/616f8ed5c640e2a0df8f17d1a8a3d3e2f3cfe093 @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + document + chapter + page + + + + + + + + + text + page + section + document + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + i + I + + + + + + + + a + A + + + + + + + + + + + + + + + + + + footnote + endnote + + + + + + + + + + + + + + + true + false + + + + + + diff --git a/fuzz/seed_corpus/61c137a2d172157a9636a814c7b2e88a3cc16f27 b/fuzz/seed_corpus/61c137a2d172157a9636a814c7b2e88a3cc16f27 new file mode 100644 index 000000000000..0fdfb863347a --- /dev/null +++ b/fuzz/seed_corpus/61c137a2d172157a9636a814c7b2e88a3cc16f27 @@ -0,0 +1,972 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/61daa071fecd91e30c36bf5ff9f09676f54e477d b/fuzz/seed_corpus/61daa071fecd91e30c36bf5ff9f09676f54e477d new file mode 100644 index 0000000000000000000000000000000000000000..52c7e2d18cf2aa52b5c0b99612809d5696c6afaa GIT binary patch literal 98 zcmW-ZI}SiV07PHy6x*r%8Wpy40#1O4gxzF`I6a1HGV@;MeyFfqY^)egCIUMP9!E_~ hK}xPPB91}(DC(Gh+SAdJ$SUPn8Y2A#S)POJ>o29X5Pbju literal 0 HcmV?d00001 diff --git a/fuzz/seed_corpus/627ec43b7388a228fcdc30ebcd9b3bd5b14bc84d b/fuzz/seed_corpus/627ec43b7388a228fcdc30ebcd9b3bd5b14bc84d new file mode 100644 index 000000000000..158c7a5a2b94 --- /dev/null +++ b/fuzz/seed_corpus/627ec43b7388a228fcdc30ebcd9b3bd5b14bc84d @@ -0,0 +1,19 @@ + + + + + + xml:space + + + + + + + + default + preserve + + + + diff --git a/fuzz/seed_corpus/628cc9031030cbb14613eb0e821e5032c87bfca2 b/fuzz/seed_corpus/628cc9031030cbb14613eb0e821e5032c87bfca2 new file mode 100644 index 000000000000..1ebb50fa86ab --- /dev/null +++ b/fuzz/seed_corpus/628cc9031030cbb14613eb0e821e5032c87bfca2 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/62aa12471846f560d51fac5ee1b83c15dec6bb2a b/fuzz/seed_corpus/62aa12471846f560d51fac5ee1b83c15dec6bb2a new file mode 100644 index 000000000000..b6270436ec09 --- /dev/null +++ b/fuzz/seed_corpus/62aa12471846f560d51fac5ee1b83c15dec6bb2a @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/639a043a6fd2802e99bc12a93475c143479cf1c7 b/fuzz/seed_corpus/639a043a6fd2802e99bc12a93475c143479cf1c7 new file mode 100644 index 000000000000..ffd8d5797af7 --- /dev/null +++ b/fuzz/seed_corpus/639a043a6fd2802e99bc12a93475c143479cf1c7 @@ -0,0 +1,9 @@ + + + + + + + diff --git a/fuzz/seed_corpus/639c88003025596bfab25bcb5890f8be11ad7c80 b/fuzz/seed_corpus/639c88003025596bfab25bcb5890f8be11ad7c80 new file mode 100644 index 000000000000..288b1e7f6760 --- /dev/null +++ b/fuzz/seed_corpus/639c88003025596bfab25bcb5890f8be11ad7c80 @@ -0,0 +1,19 @@ + + + + + + diff --git a/fuzz/seed_corpus/64d101bddef3caa00b9c816400de68db34e5c69a b/fuzz/seed_corpus/64d101bddef3caa00b9c816400de68db34e5c69a new file mode 100644 index 000000000000..25367c4255fc --- /dev/null +++ b/fuzz/seed_corpus/64d101bddef3caa00b9c816400de68db34e5c69a @@ -0,0 +1,16 @@ + + + + + + + + + + + +]> + + + diff --git a/fuzz/seed_corpus/656cdb2768a229123d7ceccd4d70d4a07e3a8e8e b/fuzz/seed_corpus/656cdb2768a229123d7ceccd4d70d4a07e3a8e8e new file mode 100644 index 000000000000..106d02ae6f3f --- /dev/null +++ b/fuzz/seed_corpus/656cdb2768a229123d7ceccd4d70d4a07e3a8e8e @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/656e7de87d66733aca5e29a05713ae9414377dbd b/fuzz/seed_corpus/656e7de87d66733aca5e29a05713ae9414377dbd new file mode 100644 index 000000000000..1c639ec43784 --- /dev/null +++ b/fuzz/seed_corpus/656e7de87d66733aca5e29a05713ae9414377dbd @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/6570af3254bdeb56c2604569dd7e6299dafc3e44 b/fuzz/seed_corpus/6570af3254bdeb56c2604569dd7e6299dafc3e44 new file mode 100644 index 000000000000..2e9d55efee8f --- /dev/null +++ b/fuzz/seed_corpus/6570af3254bdeb56c2604569dd7e6299dafc3e44 @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + +]> +text + diff --git a/fuzz/seed_corpus/658df221c6641622c83b0440879a58a53ed7eb73 b/fuzz/seed_corpus/658df221c6641622c83b0440879a58a53ed7eb73 new file mode 100644 index 000000000000..dd6d9eb84c82 --- /dev/null +++ b/fuzz/seed_corpus/658df221c6641622c83b0440879a58a53ed7eb73 @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> +text diff --git a/fuzz/seed_corpus/6592fc5e65ce07cc6f1d860231ca614255d2eb82 b/fuzz/seed_corpus/6592fc5e65ce07cc6f1d860231ca614255d2eb82 new file mode 100644 index 000000000000..2a114004aa0c --- /dev/null +++ b/fuzz/seed_corpus/6592fc5e65ce07cc6f1d860231ca614255d2eb82 @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/66397361ea0cd879565fce9fd5091ab38b0b5c4d b/fuzz/seed_corpus/66397361ea0cd879565fce9fd5091ab38b0b5c4d new file mode 100644 index 000000000000..c3b8c378571c --- /dev/null +++ b/fuzz/seed_corpus/66397361ea0cd879565fce9fd5091ab38b0b5c4d @@ -0,0 +1,7 @@ + + + + diff --git a/fuzz/seed_corpus/671a654d51aa9e2dc3006e715af08668c8998682 b/fuzz/seed_corpus/671a654d51aa9e2dc3006e715af08668c8998682 new file mode 100644 index 000000000000..70e3a343eaf1 --- /dev/null +++ b/fuzz/seed_corpus/671a654d51aa9e2dc3006e715af08668c8998682 @@ -0,0 +1,34 @@ + + + + + + Virtual Library + + + + +

Moved to example.org.

+ + + foo + +

+ +

coucou

+

salut

+ +

test

+ +
+
Internet Engineering Task Force
+
An organization which establishes technical standards for the Internet
+
+ + + + diff --git a/fuzz/seed_corpus/672a6c9387c4b738c650e03058bd4af4cbd112ff b/fuzz/seed_corpus/672a6c9387c4b738c650e03058bd4af4cbd112ff new file mode 100644 index 000000000000..cf63b02b83a4 --- /dev/null +++ b/fuzz/seed_corpus/672a6c9387c4b738c650e03058bd4af4cbd112ff @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/6735bb0236484acdaf1fb09097d8461ce25f7ff3 b/fuzz/seed_corpus/6735bb0236484acdaf1fb09097d8461ce25f7ff3 new file mode 100644 index 000000000000..40df24a974ea --- /dev/null +++ b/fuzz/seed_corpus/6735bb0236484acdaf1fb09097d8461ce25f7ff3 @@ -0,0 +1,7 @@ + +An ampersand (&#38;) may be escaped + numerically (&#38;#38;) or with a general entity + (&amp;).

" > +]> +&example; diff --git a/fuzz/seed_corpus/677b126fac521c3333e2964692f55eb9991a3f14 b/fuzz/seed_corpus/677b126fac521c3333e2964692f55eb9991a3f14 new file mode 100644 index 000000000000..f06b531a98e7 --- /dev/null +++ b/fuzz/seed_corpus/677b126fac521c3333e2964692f55eb9991a3f14 @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/67b597d5c85d0f80d6354a253a1fbdd83931066b b/fuzz/seed_corpus/67b597d5c85d0f80d6354a253a1fbdd83931066b new file mode 100644 index 000000000000..598a4d53ff2b --- /dev/null +++ b/fuzz/seed_corpus/67b597d5c85d0f80d6354a253a1fbdd83931066b @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/6837c85f0d43aaefa7a2cf240118cf25b082ca91 b/fuzz/seed_corpus/6837c85f0d43aaefa7a2cf240118cf25b082ca91 new file mode 100644 index 000000000000..27b0cca2c77f --- /dev/null +++ b/fuzz/seed_corpus/6837c85f0d43aaefa7a2cf240118cf25b082ca91 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/683f55a4b2e3d5d79de93da904a6f9b5ffca90bc b/fuzz/seed_corpus/683f55a4b2e3d5d79de93da904a6f9b5ffca90bc new file mode 100644 index 000000000000..be8494377aba --- /dev/null +++ b/fuzz/seed_corpus/683f55a4b2e3d5d79de93da904a6f9b5ffca90bc @@ -0,0 +1,13 @@ + + + PT0.9S + PT0.1S + PT0.999999S + P0Y27D + P27DT23H59M59S + P0Y + P367DT23H59M59S + P13M + P12M + PT86399S + diff --git a/fuzz/seed_corpus/68924ed2f6378dba57b8d7ece7595d8837fa3763 b/fuzz/seed_corpus/68924ed2f6378dba57b8d7ece7595d8837fa3763 new file mode 100644 index 000000000000..bdd512be5a50 --- /dev/null +++ b/fuzz/seed_corpus/68924ed2f6378dba57b8d7ece7595d8837fa3763 @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/68a952113a08cd3fc90f7cfd53a651efc5042cbd b/fuzz/seed_corpus/68a952113a08cd3fc90f7cfd53a651efc5042cbd new file mode 100644 index 000000000000..7d4e662ccfce --- /dev/null +++ b/fuzz/seed_corpus/68a952113a08cd3fc90f7cfd53a651efc5042cbd @@ -0,0 +1,33 @@ + + + + + 0836217462 + Being a Dog Is a Full-Time Job + + Charles M Schulz + 1922-11-26 + 2000-02-12 + + + Peppermint Patty + 1966-08-22 + bold, brash and tomboyish + + + Snoopy + 1950-10-04 + extroverted beagle + + + Schroeder + 1951-05-30 + brought classical music to the Peanuts strip + + + Lucy + 1952-03-03 + bossy, crabby and selfish + + + diff --git a/fuzz/seed_corpus/68c51ab273511385a5d511c6840063e745e68aca b/fuzz/seed_corpus/68c51ab273511385a5d511c6840063e745e68aca new file mode 100644 index 000000000000..ee1391679b1f --- /dev/null +++ b/fuzz/seed_corpus/68c51ab273511385a5d511c6840063e745e68aca @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/697e6f3800afb5879e0128864027efd2794353eb b/fuzz/seed_corpus/697e6f3800afb5879e0128864027efd2794353eb new file mode 100644 index 000000000000..99010a7c932c --- /dev/null +++ b/fuzz/seed_corpus/697e6f3800afb5879e0128864027efd2794353eb @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/6a09daa4480137ab69dfbfc1aaca44b5b73577f5 b/fuzz/seed_corpus/6a09daa4480137ab69dfbfc1aaca44b5b73577f5 new file mode 100644 index 000000000000..b8b0a846eb7d --- /dev/null +++ b/fuzz/seed_corpus/6a09daa4480137ab69dfbfc1aaca44b5b73577f5 @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/6a1b89be3f3b76f3d1186b1901831959a642276e b/fuzz/seed_corpus/6a1b89be3f3b76f3d1186b1901831959a642276e new file mode 100644 index 000000000000..b47df6122fc6 --- /dev/null +++ b/fuzz/seed_corpus/6a1b89be3f3b76f3d1186b1901831959a642276e @@ -0,0 +1,4 @@ + +tiny + diff --git a/fuzz/seed_corpus/6a3bf591f45d93c6c89edbb804e2148dcd911e1f b/fuzz/seed_corpus/6a3bf591f45d93c6c89edbb804e2148dcd911e1f new file mode 100644 index 000000000000..3384e7c61c19 --- /dev/null +++ b/fuzz/seed_corpus/6a3bf591f45d93c6c89edbb804e2148dcd911e1f @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/6aa57746a1aad289d984e7580b7160b0b371fcf7 b/fuzz/seed_corpus/6aa57746a1aad289d984e7580b7160b0b371fcf7 new file mode 100644 index 000000000000..d6d6f978bdc7 --- /dev/null +++ b/fuzz/seed_corpus/6aa57746a1aad289d984e7580b7160b0b371fcf7 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/6aaa42de07dd5b363f7ededbfbae922c8fa2490e b/fuzz/seed_corpus/6aaa42de07dd5b363f7ededbfbae922c8fa2490e new file mode 100644 index 000000000000..90c55e1c5f17 --- /dev/null +++ b/fuzz/seed_corpus/6aaa42de07dd5b363f7ededbfbae922c8fa2490e @@ -0,0 +1,111 @@ + + + + + /all/turbine/r.turbshaft + + 1.375 + 30.250 + + -13.125 0.000 0.000 + -0.000 90.000 0.000 + + /all/turbine/r.turbshaft/s.turbshaft + + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + + + /all/turbine/r.turbshaft + + 1.375 + 0 0 0 + 1.1 1.1 1.1 + /all/turbine/r.turbshaft/s.turbshaft + + + + diff --git a/fuzz/seed_corpus/6abd8fb5d1ab4d116daf4429678ca9bb0947e51b b/fuzz/seed_corpus/6abd8fb5d1ab4d116daf4429678ca9bb0947e51b new file mode 100644 index 000000000000..f9eeb5cfceae --- /dev/null +++ b/fuzz/seed_corpus/6abd8fb5d1ab4d116daf4429678ca9bb0947e51b @@ -0,0 +1 @@ +1.2 3.4 5.6 diff --git a/fuzz/seed_corpus/6ae10aeb6fd0f9346db450029b0c1a06738a77a3 b/fuzz/seed_corpus/6ae10aeb6fd0f9346db450029b0c1a06738a77a3 new file mode 100644 index 000000000000..144b8c55ad89 --- /dev/null +++ b/fuzz/seed_corpus/6ae10aeb6fd0f9346db450029b0c1a06738a77a3 @@ -0,0 +1,8 @@ + + + + + +]> +This is a valid document diff --git a/fuzz/seed_corpus/6b3f3b53af613de99f9d50a42fb28b6c98ff7f9e b/fuzz/seed_corpus/6b3f3b53af613de99f9d50a42fb28b6c98ff7f9e new file mode 100644 index 000000000000..a7a624c17161 --- /dev/null +++ b/fuzz/seed_corpus/6b3f3b53af613de99f9d50a42fb28b6c98ff7f9e @@ -0,0 +1,66 @@ + + + + Slashdot:News for Nerds. Stuff that Matters. + http://slashdot.org/ + News for Nerds. Stuff that Matters + + + + Slashdot + http://slashdot.org/images/slashdotlg.gif + http://slashdot.org + + + + 100 Mbit/s on Fibre to the home + http://slashdot.org/articles/99/06/06/1440211.shtml + + + + Gimp 1.2 Preview + http://slashdot.org/articles/99/06/06/1438246.shtml + + + + Sony's AIBO robot Sold Out + http://slashdot.org/articles/99/06/06/1432256.shtml + + + + Ask Slashdot: Another Word for "Hacker"? + http://slashdot.org/askslashdot/99/06/05/1815225.shtml + + + + Corel Linux FAQ + http://slashdot.org/articles/99/06/05/1842218.shtml + + + + Upside downsides MP3.COM. + http://slashdot.org/articles/99/06/05/1558210.shtml + + + + 2 Terabits of Bandwidth + http://slashdot.org/articles/99/06/05/1554258.shtml + + + + Suppression of cold fusion research? + http://slashdot.org/articles/99/06/04/2313200.shtml + + + + California Gov. Halts Wage Info Sale + http://slashdot.org/articles/99/06/04/235256.shtml + + + + Red Hat Announces IPO + http://slashdot.org/articles/99/06/04/0849207.shtml + + \ No newline at end of file diff --git a/fuzz/seed_corpus/6bb5f98c0532382370c94c29910d06ce65ed2e36 b/fuzz/seed_corpus/6bb5f98c0532382370c94c29910d06ce65ed2e36 new file mode 100644 index 000000000000..7fe6bd362a1a --- /dev/null +++ b/fuzz/seed_corpus/6bb5f98c0532382370c94c29910d06ce65ed2e36 @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/6c78a975633639ff2e3214dc4cfd8b280405a276 b/fuzz/seed_corpus/6c78a975633639ff2e3214dc4cfd8b280405a276 new file mode 100644 index 000000000000..28fee0eb9b9c --- /dev/null +++ b/fuzz/seed_corpus/6c78a975633639ff2e3214dc4cfd8b280405a276 @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/6c9ca209c620ccc5b6feb7aeb546a20afd7d80d6 b/fuzz/seed_corpus/6c9ca209c620ccc5b6feb7aeb546a20afd7d80d6 new file mode 100644 index 000000000000..1b780e66c35b --- /dev/null +++ b/fuzz/seed_corpus/6c9ca209c620ccc5b6feb7aeb546a20afd7d80d6 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/6d1a623334c2a5a928192d4edfb971be0f584b42 b/fuzz/seed_corpus/6d1a623334c2a5a928192d4edfb971be0f584b42 new file mode 100644 index 000000000000..dbe4f5e3f30d --- /dev/null +++ b/fuzz/seed_corpus/6d1a623334c2a5a928192d4edfb971be0f584b42 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/6d93d9820e7b8f16da82c94a4bb2386b4abaa1f8 b/fuzz/seed_corpus/6d93d9820e7b8f16da82c94a4bb2386b4abaa1f8 new file mode 100644 index 000000000000..e4511f1131c9 --- /dev/null +++ b/fuzz/seed_corpus/6d93d9820e7b8f16da82c94a4bb2386b4abaa1f8 @@ -0,0 +1,2 @@ + + violates [ WFC: Unique Att Spec ] diff --git a/fuzz/seed_corpus/6da35dbfced7087910ad73348df7ff8a395a3c32 b/fuzz/seed_corpus/6da35dbfced7087910ad73348df7ff8a395a3c32 new file mode 100644 index 000000000000..421a1dfdfa9a --- /dev/null +++ b/fuzz/seed_corpus/6da35dbfced7087910ad73348df7ff8a395a3c32 @@ -0,0 +1,5 @@ + + +]> + diff --git a/fuzz/seed_corpus/6ea1d8bab04f9cef7f5704850f74a21b0bf55230 b/fuzz/seed_corpus/6ea1d8bab04f9cef7f5704850f74a21b0bf55230 new file mode 100644 index 000000000000..2ca54ee020fd --- /dev/null +++ b/fuzz/seed_corpus/6ea1d8bab04f9cef7f5704850f74a21b0bf55230 @@ -0,0 +1,4 @@ + + a + a + diff --git a/fuzz/seed_corpus/6eaf066f91ef68a2668e2ac83ede7d1bed8a899d b/fuzz/seed_corpus/6eaf066f91ef68a2668e2ac83ede7d1bed8a899d new file mode 100644 index 000000000000..b4b1350b73e3 --- /dev/null +++ b/fuzz/seed_corpus/6eaf066f91ef68a2668e2ac83ede7d1bed8a899d @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/6ebd108c726bd5379ebd60e9e85b58f1fa1e6289 b/fuzz/seed_corpus/6ebd108c726bd5379ebd60e9e85b58f1fa1e6289 new file mode 100644 index 000000000000..60aa1b6b4da7 --- /dev/null +++ b/fuzz/seed_corpus/6ebd108c726bd5379ebd60e9e85b58f1fa1e6289 @@ -0,0 +1,343 @@ + + + +]> +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; +&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d; diff --git a/fuzz/seed_corpus/6ee4a7f863fe05823a2640a3c040fab72abce298 b/fuzz/seed_corpus/6ee4a7f863fe05823a2640a3c040fab72abce298 new file mode 100644 index 000000000000..70440e23dac7 --- /dev/null +++ b/fuzz/seed_corpus/6ee4a7f863fe05823a2640a3c040fab72abce298 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/6f60864db263a826653e36f59579336df447313d b/fuzz/seed_corpus/6f60864db263a826653e36f59579336df447313d new file mode 100644 index 000000000000..75f4352e144e --- /dev/null +++ b/fuzz/seed_corpus/6f60864db263a826653e36f59579336df447313d @@ -0,0 +1,7 @@ + + +]> + + + diff --git a/fuzz/seed_corpus/6fbe3a751d4a6e5c82c26fabda5c41ca9b097833 b/fuzz/seed_corpus/6fbe3a751d4a6e5c82c26fabda5c41ca9b097833 new file mode 100644 index 000000000000..2b84ebbee4cb --- /dev/null +++ b/fuzz/seed_corpus/6fbe3a751d4a6e5c82c26fabda5c41ca9b097833 @@ -0,0 +1,5 @@ + + This should work + diff --git a/fuzz/seed_corpus/6fd3150c77c1067333f444472c8a9d74cbc39116 b/fuzz/seed_corpus/6fd3150c77c1067333f444472c8a9d74cbc39116 new file mode 100644 index 000000000000..b81832537960 --- /dev/null +++ b/fuzz/seed_corpus/6fd3150c77c1067333f444472c8a9d74cbc39116 @@ -0,0 +1 @@ +//p[.='abc'] diff --git a/fuzz/seed_corpus/701b2b9e1218eb518a7ec30ec71b474c8c9dcadd b/fuzz/seed_corpus/701b2b9e1218eb518a7ec30ec71b474c8c9dcadd new file mode 100644 index 000000000000..36013657032c --- /dev/null +++ b/fuzz/seed_corpus/701b2b9e1218eb518a7ec30ec71b474c8c9dcadd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + This chart includes private data in another namespace + + + diff --git a/fuzz/seed_corpus/705a3c3778f48975bed31e1e9bd72b3de2426e02 b/fuzz/seed_corpus/705a3c3778f48975bed31e1e9bd72b3de2426e02 new file mode 100644 index 000000000000..388b6a9cf3c5 --- /dev/null +++ b/fuzz/seed_corpus/705a3c3778f48975bed31e1e9bd72b3de2426e02 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/fuzz/seed_corpus/71375f731776dcad926888e614d139763da17b9f b/fuzz/seed_corpus/71375f731776dcad926888e614d139763da17b9f new file mode 100644 index 000000000000..33eaba88c6cd --- /dev/null +++ b/fuzz/seed_corpus/71375f731776dcad926888e614d139763da17b9f @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/71511f010813ef7a90ce1eaf18d4f6f6aae88f9a b/fuzz/seed_corpus/71511f010813ef7a90ce1eaf18d4f6f6aae88f9a new file mode 100644 index 000000000000..d87151926984 --- /dev/null +++ b/fuzz/seed_corpus/71511f010813ef7a90ce1eaf18d4f6f6aae88f9a @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/716a187708f9fde686d26d56d5639fbf916f64e2 b/fuzz/seed_corpus/716a187708f9fde686d26d56d5639fbf916f64e2 new file mode 100644 index 000000000000..b80802e0fac5 --- /dev/null +++ b/fuzz/seed_corpus/716a187708f9fde686d26d56d5639fbf916f64e2 @@ -0,0 +1,20 @@ + + + + + Source + http://foo.bar/program + http://foo.bar/src/main.c + + + Library + http://foo.bar/program + http://foo.bar/src/main.lib + + + Makefile + http://foo.bar/program + http://foo.bar/src/makefile + + + diff --git a/fuzz/seed_corpus/71dbd4ef4bda3e726cc9ce3daca1e56fe33a02fd b/fuzz/seed_corpus/71dbd4ef4bda3e726cc9ce3daca1e56fe33a02fd new file mode 100644 index 000000000000..13470ebefc7f --- /dev/null +++ b/fuzz/seed_corpus/71dbd4ef4bda3e726cc9ce3daca1e56fe33a02fd @@ -0,0 +1,8 @@ + +' > +' > +' > +%defroot;%defmiddle;%deftest; +]> +sample diff --git a/fuzz/seed_corpus/720fea1a8439bb20b10fd64a3e84fc8d3efde291 b/fuzz/seed_corpus/720fea1a8439bb20b10fd64a3e84fc8d3efde291 new file mode 100644 index 000000000000..6aedcfb4b015 --- /dev/null +++ b/fuzz/seed_corpus/720fea1a8439bb20b10fd64a3e84fc8d3efde291 @@ -0,0 +1,10 @@ + + + + + +]> + + + diff --git a/fuzz/seed_corpus/7236669e099aaa4dac168e5ffb2abb0804016506 b/fuzz/seed_corpus/7236669e099aaa4dac168e5ffb2abb0804016506 new file mode 100644 index 000000000000..21566158365e --- /dev/null +++ b/fuzz/seed_corpus/7236669e099aaa4dac168e5ffb2abb0804016506 @@ -0,0 +1,43 @@ + + + + + + +]> + + + + + CN=Merlin Hughes,O=Baltimore Technologies\, Ltd.,ST=Dublin,C=IE + + + + CN=Test DSA CA,O=Baltimore Technologies\, Ltd.,ST=Dublin,C=IE + + 970849936 + + + MIIDNzCCAvWgAwIBAgIEOd3+kDAJBgcqhkjOOAQDMFsxCzAJBgNVBAYTAklFMQ8w + DQYDVQQIEwZEdWJsaW4xJTAjBgNVBAoTHEJhbHRpbW9yZSBUZWNobm9sb2dpZXMs + IEx0ZC4xFDASBgNVBAMTC1Rlc3QgRFNBIENBMB4XDTAwMTAwNjE2MzIxNVoXDTAx + MTAwNjE2MzIxNFowXTELMAkGA1UEBhMCSUUxDzANBgNVBAgTBkR1YmxpbjElMCMG + A1UEChMcQmFsdGltb3JlIFRlY2hub2xvZ2llcywgTHRkLjEWMBQGA1UEAxMNTWVy + bGluIEh1Z2hlczCCAbYwggErBgcqhkjOOAQBMIIBHgKBgQDaJjfDTrawMHf8MiUt + Y54b37hSmYNnR3KpGT10uU1Dqppcju06uN0iGbqf947DjkBC25hKnqykK31xBw0E + CPbYq/KC98kghdf2xJCu6B8aqJ95K9jdVflJ3WP7PQxJn+fmM23zy6HYLXVICpfq + etdNj/VHCShZE3bdJiE6VobSFQIVAPQecqS2PaTDprcQnkwx4MHTRXhrAoGAMuGA + lqeB1ax+vyO2+Osubjhl7pHxLu47RIH+/M52DjESA9KMSrwzsYx8yNR2WooByrE0 + t6fu0VncK7UK8olO4t7wpv2z4AFQPRVCKFwo0qgn5aKIkICGMlrRy81avb27wGcW + othx3iPPMtFXtoDqK0JItaI9R8zc1msFhM1GKMYDgYQAAoGActA8YGxrtngg/zKV + vqEOefnwmViFztcnPBYPlJsvh6yKI4iDm68fnp4Mi3RrJ6bZAygFrUIQLxLjV+OJ + tgJAEto0xAs+Mehuq1DkSFEpP3oDzCTOsrOiS1DwQe4oIb7zVk/9l7aPtJMHW0LV + lMdwZNFNNJoqMcT2ZfCPrfvYvQ2jRzBFMB4GA1UdEQQXMBWBE21lcmxpbkBiYWx0 + aW1vcmUuaWUwDgYDVR0PAQH/BAQDAgeAMBMGA1UdIwQMMAqACEJZQG0KwRbPMAkG + ByqGSM44BAMDMQAwLgIVAK4skWEFYgrggaJA8vYAwSjg12+KAhUAwHTo7wd4tENw + 9LAKPklQ/74fH18= + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/72b3c8f8967f260de2a05e0e9978ec0136dc2cd0 b/fuzz/seed_corpus/72b3c8f8967f260de2a05e0e9978ec0136dc2cd0 new file mode 100644 index 000000000000..e716cb1ff930 --- /dev/null +++ b/fuzz/seed_corpus/72b3c8f8967f260de2a05e0e9978ec0136dc2cd0 @@ -0,0 +1,7 @@ + + + + + diff --git a/fuzz/seed_corpus/7306ab382f44b9481eb079c245bba6d2c412018c b/fuzz/seed_corpus/7306ab382f44b9481eb079c245bba6d2c412018c new file mode 100644 index 000000000000..cf709d1d46c6 --- /dev/null +++ b/fuzz/seed_corpus/7306ab382f44b9481eb079c245bba6d2c412018c @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7326dc66f20c41c41aaaebbcf12f02a716b9bff9 b/fuzz/seed_corpus/7326dc66f20c41c41aaaebbcf12f02a716b9bff9 new file mode 100644 index 000000000000..39026874d4e3 --- /dev/null +++ b/fuzz/seed_corpus/7326dc66f20c41c41aaaebbcf12f02a716b9bff9 @@ -0,0 +1,13 @@ + + + + Information about a single email address. + + + + + + + + + diff --git a/fuzz/seed_corpus/733825ed3f72e15c43e243ec4c5e91e4719bb486 b/fuzz/seed_corpus/733825ed3f72e15c43e243ec4c5e91e4719bb486 new file mode 100644 index 000000000000..0fc34b40aae5 --- /dev/null +++ b/fuzz/seed_corpus/733825ed3f72e15c43e243ec4c5e91e4719bb486 @@ -0,0 +1 @@ + +http://www.ics.uci.edu/~ejw/contact.html diff --git a/fuzz/seed_corpus/737300f263749bbb1e349d2b79daa8055c2e4511 b/fuzz/seed_corpus/737300f263749bbb1e349d2b79daa8055c2e4511 new file mode 100644 index 000000000000..8cdda239e30b --- /dev/null +++ b/fuzz/seed_corpus/737300f263749bbb1e349d2b79daa8055c2e4511 @@ -0,0 +1,12 @@ + + + + Name1 + 20 + + + Name1 + Name2 + 20 + + diff --git a/fuzz/seed_corpus/7395743f1738a28d98df08deb700f18eb9669867 b/fuzz/seed_corpus/7395743f1738a28d98df08deb700f18eb9669867 new file mode 100644 index 000000000000..9650f71171b1 --- /dev/null +++ b/fuzz/seed_corpus/7395743f1738a28d98df08deb700f18eb9669867 @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/73b1ef9f2bd6a869854af4befb12b3485e3c621d b/fuzz/seed_corpus/73b1ef9f2bd6a869854af4befb12b3485e3c621d new file mode 100644 index 000000000000..80aaf9452ad4 --- /dev/null +++ b/fuzz/seed_corpus/73b1ef9f2bd6a869854af4befb12b3485e3c621d @@ -0,0 +1,3 @@ + + diff --git a/fuzz/seed_corpus/73fe3cf2705d803262c7d7903e24fd0c89686bbc b/fuzz/seed_corpus/73fe3cf2705d803262c7d7903e24fd0c89686bbc new file mode 100644 index 000000000000..23b2f5dc4201 --- /dev/null +++ b/fuzz/seed_corpus/73fe3cf2705d803262c7d7903e24fd0c89686bbc @@ -0,0 +1,36 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/741bc7f1a0bcc05c05328c39ddc541c41fa86082 b/fuzz/seed_corpus/741bc7f1a0bcc05c05328c39ddc541c41fa86082 new file mode 100644 index 000000000000..057c92627c60 --- /dev/null +++ b/fuzz/seed_corpus/741bc7f1a0bcc05c05328c39ddc541c41fa86082 @@ -0,0 +1,5 @@ + + + + &entity; + diff --git a/fuzz/seed_corpus/742928dec5d193cd93774db31ae0eb9b9c412b4d b/fuzz/seed_corpus/742928dec5d193cd93774db31ae0eb9b9c412b4d new file mode 100644 index 000000000000..c86c50aa2dd7 --- /dev/null +++ b/fuzz/seed_corpus/742928dec5d193cd93774db31ae0eb9b9c412b4d @@ -0,0 +1,9 @@ + + + + + + diff --git a/fuzz/seed_corpus/74b47ceb2af543ec62b2c3925d76ef7c86383bf6 b/fuzz/seed_corpus/74b47ceb2af543ec62b2c3925d76ef7c86383bf6 new file mode 100644 index 000000000000..398f974cd874 --- /dev/null +++ b/fuzz/seed_corpus/74b47ceb2af543ec62b2c3925d76ef7c86383bf6 @@ -0,0 +1,9 @@ + + + diff --git a/fuzz/seed_corpus/74c22ea74f3df081095861f7a8e7db2a73d6b928 b/fuzz/seed_corpus/74c22ea74f3df081095861f7a8e7db2a73d6b928 new file mode 100644 index 000000000000..449de015cdd3 --- /dev/null +++ b/fuzz/seed_corpus/74c22ea74f3df081095861f7a8e7db2a73d6b928 @@ -0,0 +1,11 @@ + + +

a simple test

+

multiple tests

+

a difficult one

+

a span

n

ing one

+

and an unbal

anced test

+

for empty string 123

+

abc

+

abc

+
diff --git a/fuzz/seed_corpus/74e57dd82b745f81379d53fe84f0d89dd668bc3d b/fuzz/seed_corpus/74e57dd82b745f81379d53fe84f0d89dd668bc3d new file mode 100644 index 000000000000..8bb29ac150f5 --- /dev/null +++ b/fuzz/seed_corpus/74e57dd82b745f81379d53fe84f0d89dd668bc3d @@ -0,0 +1,8 @@ + + + + +]> + + &utf16b; &utf16l; diff --git a/fuzz/seed_corpus/74fa7a7901379ffe690ba9b471bc74995bb5302c b/fuzz/seed_corpus/74fa7a7901379ffe690ba9b471bc74995bb5302c new file mode 100644 index 000000000000..f24b5743d402 --- /dev/null +++ b/fuzz/seed_corpus/74fa7a7901379ffe690ba9b471bc74995bb5302c @@ -0,0 +1,498 @@ + + + + This schema defines the structure of the National + Vulnerability Database XML feed files version: 1.2. The elements and + attribute in this document are described by xs:annotation tags. This + file is kept at http://nvd.nist.gov/schema/nvdcve.xsd. The NVD XML + feeds are available at http://nvd.nist.gov/download.cfm. + + Release Notes: + + Version 1.2: + * CVSS version 2 scores and vectors have been added. Please see + http://nvd.nist.gov/cvss.cfm?vectorinfo and + http://www.first.org/cvss/cvss-guide.html for more information on + how to interpret this data. + + + + The root element of the NVD CVE feed. Multiple "entry" child elements describe specific NVD CVE entries. + + + + + + + + The schema version number supported by the feed. + + + + + The date the feed was generated. + + + + + + + + A CVE entry. + + + + + + + + + Documents one CVE entry. The child elements should always + appear in the sequence defined below. These elements are compatible with + entry elements from the CVE XML feeds. + + + + + Description wrapper tag, parent to any + documented descriptions of this CVE entry. While the "desc" + tag will always be present, there may be no "descript" child + tags. Only one "descript" tag will exist for each + description source (i.e. CVE, NVD, ...). + + + + + + A description of a CVE entry + from the source indicated by the "source" + attribute. + + + + + + + + Impact wrapper tag (may or may not be + present). Only one "impact" tag will exist for each impact + explanation source. + + + + + + Contains a specific impact + explanation of this CVE entry from source + indicated by the "source" attribute. + + + + + + + + + Solution wrapper tag (may or may not be + present). Only one "sol" tag will exist for each solution + explanation source. + + + + + Loss type tag (may or may not be present). + Contains one loss type child for each loss type of this CVE + entry. Potential loss types are: "avail" => availability + "conf" => confidentiality "int" => integrity "sec_prot" => + security protection + + + + + Vulnerability type tag (may or may not be + present). Contains one vulnerability type child for each + vulnerability type of this CVE entry. Potential + vulnerability types are: "access" => Access validation error + "input" => Input validation error "design" => Design error + "exception" => Exceptional condition error "env" => + Environmental error "config" => Configuration error "race" + => Race condition error "other" => other + + + + + Vulnerability range tag (may or may not be + present). Contains one vulnerability range child for each + vulnerability range of this CVE entry. Potential + vulnerability ranges are: "local" => Locally exploitable + "local_network" => Local network exploitable "network" => + Network exploitable "user_init" => User accesses attacker + + + + + + Reference wrapper tag (always present). + External references to this CVE entry are contained within + this tag. + + + + + + Individual reference to this CVE + entry. Text is the name of this vulnerability at + this particular reference. Attributes: "source" + (required) => Name of reference source "url" + (required) => hyperlink to reference "sig" => + indicates this reference includes a tool + signature "adv" => indicates this reference is a + Security Advisory "patch" => indicates this + reference includes a patch for this + vulnerability + + + + + + + + Vulnerable software wrapper tag (may or may + not be present). Software affected by this CVE entry are + listed within this tag. + + + + + + CVE or CAN + + + + + + + + + + + the full CVE name + + + + + + + + + + the sequence number from CVE name + + + + + + + + + + the NVD name (if it exists) + + + + + the date this entry was discovered + + + + + the date this entry was published + + + + + the date this entry was last modified + + + + + the entry's severity as determined by the NVD analysts: High, Medium, or Low + + + + + + + + + + + + indicates that this CVE entry has been rejected by CVE or NVD + + + + + the CVSS Version Indicator + + + + + Same as the CVSS_base_score to provide backwards compatability with the previous CVE XML feed format. This field is deprecated an may be removed at a future date. + + + + + CVSS version 2 Base Score + + + + + CVSS version 2 Impact Score + + + + + CVSS version 2 Exploit Score + + + + + the CVSS version 2 Vector string + + + + + + + + + + The source of the CVE description. + + + + + + + + + + + + + + + + + + + + + Input validation error tag with + one attribute for each input validation error + type. Potential input validation error types + are: "bound" => Boundary condition error + "buffer" => Buffer overflow + + + + + + + + + + + + + + + + + + + + Contains a specific solution + explanation of this CVE entry from source + indicated by the "source" attribute. + + + + + + + + + + + + + + + + + + + + + + Security Protection tag with one + attribute for each security protection type. + Potential security protection types are: "admin" + => gain administrative access "user" => gain + user access "other" => other + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Product wrapper tag. Versions of + this product that are affected by this + vulnerability are listed within this tag. + Attributes: "name" => Product name "vendor" => + Vendor of this product + + + + + + Represents a version + of this product that is affected by + this vulnerability. Attributes: + "num" => This version number "prev" + => Indicates that versions previous + to this version number are also + affected by this vulnerability + "edition" => Indicates the edition + associated with the version number + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines date format for NVD. Dates follow the mask "yyyy-mm-dd" + + + + + + + + + Restricts urls in NVD beyond the xs:anyURI restrictions. + + + + + + + + + + simpleType used for attributes that are only present when they are + true. Such attributes appear only in the form attribute_name="1". + + + + + + + + + simpleType used when scoring on a scale of 0-10, inclusive + + + + + + + + + + simpleType to describe the CVSS Base Vector + + + + + + diff --git a/fuzz/seed_corpus/750c15ca3c858f9880c1127450118b4d94598c96 b/fuzz/seed_corpus/750c15ca3c858f9880c1127450118b4d94598c96 new file mode 100644 index 000000000000..ac37b7b7fed7 --- /dev/null +++ b/fuzz/seed_corpus/750c15ca3c858f9880c1127450118b4d94598c96 @@ -0,0 +1,7 @@ + + + + + diff --git a/fuzz/seed_corpus/75188bed69917fd60549ec46a8dfded0364af9f5 b/fuzz/seed_corpus/75188bed69917fd60549ec46a8dfded0364af9f5 new file mode 100644 index 000000000000..d5c0dd1fdf8e --- /dev/null +++ b/fuzz/seed_corpus/75188bed69917fd60549ec46a8dfded0364af9f5 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/754e7a4d805c02735bb3ea29acacda16e79d7367 b/fuzz/seed_corpus/754e7a4d805c02735bb3ea29acacda16e79d7367 new file mode 100644 index 000000000000..678ae5805dbd --- /dev/null +++ b/fuzz/seed_corpus/754e7a4d805c02735bb3ea29acacda16e79d7367 @@ -0,0 +1,8 @@ + + + + O.K. + The AAA value is not permitted. + + + diff --git a/fuzz/seed_corpus/75976256975be166dbd17c861bd59cf3af76ee23 b/fuzz/seed_corpus/75976256975be166dbd17c861bd59cf3af76ee23 new file mode 100644 index 000000000000..7d92e1ce598c --- /dev/null +++ b/fuzz/seed_corpus/75976256975be166dbd17c861bd59cf3af76ee23 @@ -0,0 +1,119 @@ + + + + + + DCMES 1.1 XML Schema + XML Schema for http://purl.org/dc/elements/1.1/ namespace + + Created 2003-04-02 + + Created by + + Tim Cole (t-cole3@uiuc.edu) + Tom Habing (thabing@uiuc.edu) + Jane Hunter (jane@dstc.edu.au) + Pete Johnston (p.johnston@ukoln.ac.uk), + Carl Lagoze (lagoze@cs.cornell.edu) + + This schema declares XML elements for the 15 DC elements from the + http://purl.org/dc/elements/1.1/ namespace. + + It defines a complexType SimpleLiteral which permits mixed content + and makes the xml:lang attribute available. It disallows child elements by + use of minOcccurs/maxOccurs. + + However, this complexType does permit the derivation of other complexTypes + which would permit child elements. + + All elements are declared as substitutable for the abstract element any, + which means that the default type for all elements is dc:SimpleLiteral. + + + + + + + + + + + + + This is the default type for all of the DC elements. + It permits text content only with optional + xml:lang attribute. + Text is allowed because mixed="true", but sub-elements + are disallowed because minOccurs="0" and maxOccurs="0" + are on the xs:any tag. + + This complexType allows for restriction or extension permitting + child elements. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This group is included as a convenience for schema authors + who need to refer to all the elements in the + http://purl.org/dc/elements/1.1/ namespace. + + + + + + + + + + + + + + This complexType is included as a convenience for schema authors who need to define a root + or container element for all of the DC elements. + + + + + + + + + + + diff --git a/fuzz/seed_corpus/75a7a83756947e988df92e4c449c01bbca9bd18d b/fuzz/seed_corpus/75a7a83756947e988df92e4c449c01bbca9bd18d new file mode 100644 index 000000000000..b85cdcb87ef3 --- /dev/null +++ b/fuzz/seed_corpus/75a7a83756947e988df92e4c449c01bbca9bd18d @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/75e0e6e7449e64982bfa5dda52ad9a239ae89cf8 b/fuzz/seed_corpus/75e0e6e7449e64982bfa5dda52ad9a239ae89cf8 new file mode 100644 index 000000000000..981a7accbdbf --- /dev/null +++ b/fuzz/seed_corpus/75e0e6e7449e64982bfa5dda52ad9a239ae89cf8 @@ -0,0 +1,13 @@ + + + + This SVG drawing embeds another one, + thus establishing a new viewport + + + + + + diff --git a/fuzz/seed_corpus/75e496951d439ff1c85071904e5a83a01e5a9555 b/fuzz/seed_corpus/75e496951d439ff1c85071904e5a83a01e5a9555 new file mode 100644 index 000000000000..c7400ac96737 --- /dev/null +++ b/fuzz/seed_corpus/75e496951d439ff1c85071904e5a83a01e5a9555 @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/75ead4ce617162e5eb3e2ffc33c4f2f8826614c4 b/fuzz/seed_corpus/75ead4ce617162e5eb3e2ffc33c4f2f8826614c4 new file mode 100644 index 000000000000..79b55841d52a --- /dev/null +++ b/fuzz/seed_corpus/75ead4ce617162e5eb3e2ffc33c4f2f8826614c4 @@ -0,0 +1,11 @@ + + + John + Smith + js@example.com + + + Fred Bloggs + fb@example.net + + diff --git a/fuzz/seed_corpus/7640bed796785a43dbabce33e359ec6cb777275e b/fuzz/seed_corpus/7640bed796785a43dbabce33e359ec6cb777275e new file mode 100644 index 000000000000..31c288fe3376 --- /dev/null +++ b/fuzz/seed_corpus/7640bed796785a43dbabce33e359ec6cb777275e @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/765b92b183650022c8828e2249e9f0161712f123 b/fuzz/seed_corpus/765b92b183650022c8828e2249e9f0161712f123 new file mode 100644 index 000000000000..920f99d3ceb2 --- /dev/null +++ b/fuzz/seed_corpus/765b92b183650022c8828e2249e9f0161712f123 @@ -0,0 +1,3 @@ + + title + diff --git a/fuzz/seed_corpus/7692c5aefdd5a1e43595e3d61b1afd0e025104dd b/fuzz/seed_corpus/7692c5aefdd5a1e43595e3d61b1afd0e025104dd new file mode 100644 index 000000000000..8ea279545681 --- /dev/null +++ b/fuzz/seed_corpus/7692c5aefdd5a1e43595e3d61b1afd0e025104dd @@ -0,0 +1,12 @@ + + + (//. | //@* | //namespace::*) + [ + + ancestor-or-self::bar:Something and + ((name() != "bar") or parent::bar:Something) and + ((name() != "foo") or parent::foo:Something) and + ((name() != "baz") or parent::baz:Something) and + ((name() != "") or self::text()) + ] + diff --git a/fuzz/seed_corpus/76a7c7ba72492e944863c9067fe6bb6b4323d006 b/fuzz/seed_corpus/76a7c7ba72492e944863c9067fe6bb6b4323d006 new file mode 100644 index 000000000000..24fdd3f4f0a0 --- /dev/null +++ b/fuzz/seed_corpus/76a7c7ba72492e944863c9067fe6bb6b4323d006 @@ -0,0 +1,12 @@ + + + (//. | //@* | //namespace::*) + [ + + ancestor-or-self::bar:Something and + (self::text() or + (namespace-uri() != "") or + ((name() = "") and + ((count(ancestor-or-self::node()) mod 2) = 1))) + ] + diff --git a/fuzz/seed_corpus/774d96e7e04c32f0b5e4b9ae545421d0f550b25d b/fuzz/seed_corpus/774d96e7e04c32f0b5e4b9ae545421d0f550b25d new file mode 100644 index 000000000000..471eb2015d84 --- /dev/null +++ b/fuzz/seed_corpus/774d96e7e04c32f0b5e4b9ae545421d0f550b25d @@ -0,0 +1,12 @@ + + + + + + + + +]> + + diff --git a/fuzz/seed_corpus/776150e93fd52b4eed4c713ff033886cd051f12a b/fuzz/seed_corpus/776150e93fd52b4eed4c713ff033886cd051f12a new file mode 100644 index 000000000000..93282d8622af --- /dev/null +++ b/fuzz/seed_corpus/776150e93fd52b4eed4c713ff033886cd051f12a @@ -0,0 +1,5 @@ + + + + + diff --git a/fuzz/seed_corpus/77ebf6c9faa3011ffe21fd373bcf24c9930caea4 b/fuzz/seed_corpus/77ebf6c9faa3011ffe21fd373bcf24c9930caea4 new file mode 100644 index 000000000000..de89f45f2110 --- /dev/null +++ b/fuzz/seed_corpus/77ebf6c9faa3011ffe21fd373bcf24c9930caea4 @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/780ff3212a9dfc11ec0ade964d36066289df20b2 b/fuzz/seed_corpus/780ff3212a9dfc11ec0ade964d36066289df20b2 new file mode 100644 index 000000000000..4a041aaa11c8 --- /dev/null +++ b/fuzz/seed_corpus/780ff3212a9dfc11ec0ade964d36066289df20b2 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/7872b3c54d64a73f1ba61e95d3058f21d21c00f6 b/fuzz/seed_corpus/7872b3c54d64a73f1ba61e95d3058f21d21c00f6 new file mode 100644 index 000000000000..81f71cb39826 --- /dev/null +++ b/fuzz/seed_corpus/7872b3c54d64a73f1ba61e95d3058f21d21c00f6 @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/78a7e6c6c82b095036be729e3240939f8d05141b b/fuzz/seed_corpus/78a7e6c6c82b095036be729e3240939f8d05141b new file mode 100644 index 000000000000..e123ba7e3e62 --- /dev/null +++ b/fuzz/seed_corpus/78a7e6c6c82b095036be729e3240939f8d05141b @@ -0,0 +1 @@ +
diff --git a/fuzz/seed_corpus/790b51f10d107a5d311973297211d6e7d4be4ea1 b/fuzz/seed_corpus/790b51f10d107a5d311973297211d6e7d4be4ea1 new file mode 100644 index 000000000000..fb08e36d5fb4 --- /dev/null +++ b/fuzz/seed_corpus/790b51f10d107a5d311973297211d6e7d4be4ea1 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/79453c6b9b66e27860684227f2bf18f628122cf4 b/fuzz/seed_corpus/79453c6b9b66e27860684227f2bf18f628122cf4 new file mode 100644 index 000000000000..1dd44e510ce4 --- /dev/null +++ b/fuzz/seed_corpus/79453c6b9b66e27860684227f2bf18f628122cf4 @@ -0,0 +1,1223 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/79691b43957989a7ac01dbaf765109f53b0c2f6c b/fuzz/seed_corpus/79691b43957989a7ac01dbaf765109f53b0c2f6c new file mode 100644 index 000000000000..b4db29832308 --- /dev/null +++ b/fuzz/seed_corpus/79691b43957989a7ac01dbaf765109f53b0c2f6c @@ -0,0 +1,35 @@ + + + + + firstValue + + + + + + + + + + + + + + + secondValue + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7989e60b91f860c4e7e59060d2eda94038b91a5c b/fuzz/seed_corpus/7989e60b91f860c4e7e59060d2eda94038b91a5c new file mode 100644 index 000000000000..17332ae88c0f --- /dev/null +++ b/fuzz/seed_corpus/7989e60b91f860c4e7e59060d2eda94038b91a5c @@ -0,0 +1,2 @@ + "> + + + + +
\ No newline at end of file diff --git a/fuzz/seed_corpus/7a060dde82e3692da7fc95108145a86ce85b9f3d b/fuzz/seed_corpus/7a060dde82e3692da7fc95108145a86ce85b9f3d new file mode 100644 index 000000000000..1fcf898ad0bf --- /dev/null +++ b/fuzz/seed_corpus/7a060dde82e3692da7fc95108145a86ce85b9f3d @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7a35b45a813cdb47f0c8dfff5afd0caa3eb9a19e b/fuzz/seed_corpus/7a35b45a813cdb47f0c8dfff5afd0caa3eb9a19e new file mode 100644 index 000000000000..5e6d8371b725 --- /dev/null +++ b/fuzz/seed_corpus/7a35b45a813cdb47f0c8dfff5afd0caa3eb9a19e @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/7a59f97c7e838d967f0222b77ad65a4c9e9c3eb3 b/fuzz/seed_corpus/7a59f97c7e838d967f0222b77ad65a4c9e9c3eb3 new file mode 100644 index 000000000000..3ebf491fcb6e --- /dev/null +++ b/fuzz/seed_corpus/7a59f97c7e838d967f0222b77ad65a4c9e9c3eb3 @@ -0,0 +1,8 @@ + + + + + +

très

+ + diff --git a/fuzz/seed_corpus/7a629aa047f6cecaf17ec48d79d58c535277ca0e b/fuzz/seed_corpus/7a629aa047f6cecaf17ec48d79d58c535277ca0e new file mode 100644 index 000000000000..6c611c155a20 --- /dev/null +++ b/fuzz/seed_corpus/7a629aa047f6cecaf17ec48d79d58c535277ca0e @@ -0,0 +1,6 @@ + + +]> + +&newl; diff --git a/fuzz/seed_corpus/7aa5de3e001eff1ecaa37566fd45342bf6ffcb98 b/fuzz/seed_corpus/7aa5de3e001eff1ecaa37566fd45342bf6ffcb98 new file mode 100644 index 000000000000..b7fd2ec2cb31 --- /dev/null +++ b/fuzz/seed_corpus/7aa5de3e001eff1ecaa37566fd45342bf6ffcb98 @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/7af10d0ae984ef19d8db1268df1eec2d420f1374 b/fuzz/seed_corpus/7af10d0ae984ef19d8db1268df1eec2d420f1374 new file mode 100644 index 000000000000..cc3fb31510c9 --- /dev/null +++ b/fuzz/seed_corpus/7af10d0ae984ef19d8db1268df1eec2d420f1374 @@ -0,0 +1,2 @@ + +&peInCdata; diff --git a/fuzz/seed_corpus/7b07c8e1083c71288120e57950f95b0f28cc0eff b/fuzz/seed_corpus/7b07c8e1083c71288120e57950f95b0f28cc0eff new file mode 100644 index 000000000000..6b0cac122505 --- /dev/null +++ b/fuzz/seed_corpus/7b07c8e1083c71288120e57950f95b0f28cc0eff @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/fuzz/seed_corpus/7b46ce0b61f4bc2b7fa72c2921c85caf34a910d7 b/fuzz/seed_corpus/7b46ce0b61f4bc2b7fa72c2921c85caf34a910d7 new file mode 100644 index 000000000000..be10b85a1ca9 --- /dev/null +++ b/fuzz/seed_corpus/7b46ce0b61f4bc2b7fa72c2921c85caf34a910d7 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7b60a73d9e8ebc85bd25531ee58238f3650a31ef b/fuzz/seed_corpus/7b60a73d9e8ebc85bd25531ee58238f3650a31ef new file mode 100644 index 000000000000..d8cf63379308 --- /dev/null +++ b/fuzz/seed_corpus/7b60a73d9e8ebc85bd25531ee58238f3650a31ef @@ -0,0 +1 @@ +x diff --git a/fuzz/seed_corpus/7b8c31b8c3dad1ff9b943cd0ad0b6db25a4f20b0 b/fuzz/seed_corpus/7b8c31b8c3dad1ff9b943cd0ad0b6db25a4f20b0 new file mode 100644 index 000000000000..298e6b1a4aef --- /dev/null +++ b/fuzz/seed_corpus/7b8c31b8c3dad1ff9b943cd0ad0b6db25a4f20b0 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7b917fc10629b19c40df0eb76cc82e64deb137db b/fuzz/seed_corpus/7b917fc10629b19c40df0eb76cc82e64deb137db new file mode 100644 index 000000000000..e0d81afa1db8 --- /dev/null +++ b/fuzz/seed_corpus/7b917fc10629b19c40df0eb76cc82e64deb137db @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/7baca30e020070ddde4b2fcae7c72c5caa7cf178 b/fuzz/seed_corpus/7baca30e020070ddde4b2fcae7c72c5caa7cf178 new file mode 100644 index 000000000000..e649a2c5d5d8 --- /dev/null +++ b/fuzz/seed_corpus/7baca30e020070ddde4b2fcae7c72c5caa7cf178 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7bb0f3f2a9714927663d90b40580969592f5989b b/fuzz/seed_corpus/7bb0f3f2a9714927663d90b40580969592f5989b new file mode 100644 index 000000000000..9393beb2e638 --- /dev/null +++ b/fuzz/seed_corpus/7bb0f3f2a9714927663d90b40580969592f5989b @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7bc19bc980a07fec3523ee9ada0b3ddee1fa774b b/fuzz/seed_corpus/7bc19bc980a07fec3523ee9ada0b3ddee1fa774b new file mode 100644 index 000000000000..c7c2b0a7d50b --- /dev/null +++ b/fuzz/seed_corpus/7bc19bc980a07fec3523ee9ada0b3ddee1fa774b @@ -0,0 +1,8 @@ + +' > +' > +' > +%defroot; %defmiddle; %deftest; +]> +sample diff --git a/fuzz/seed_corpus/7c0fcbbc3a9add6cbe45167c553f2f26433d0c5f b/fuzz/seed_corpus/7c0fcbbc3a9add6cbe45167c553f2f26433d0c5f new file mode 100644 index 000000000000..636923c5e386 --- /dev/null +++ b/fuzz/seed_corpus/7c0fcbbc3a9add6cbe45167c553f2f26433d0c5f @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/7c211433f02071597741e6ff5a8ea34789abbf43 b/fuzz/seed_corpus/7c211433f02071597741e6ff5a8ea34789abbf43 new file mode 100644 index 000000000000..04fea06420ca --- /dev/null +++ b/fuzz/seed_corpus/7c211433f02071597741e6ff5a8ea34789abbf43 @@ -0,0 +1 @@ +world \ No newline at end of file diff --git a/fuzz/seed_corpus/7c2e5e524d126fb3df8144599b3b6f05b81570ac b/fuzz/seed_corpus/7c2e5e524d126fb3df8144599b3b6f05b81570ac new file mode 100644 index 000000000000..89be58120023 --- /dev/null +++ b/fuzz/seed_corpus/7c2e5e524d126fb3df8144599b3b6f05b81570ac @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7c85c028ae7d172131b6f464bde9f32826e94ef5 b/fuzz/seed_corpus/7c85c028ae7d172131b6f464bde9f32826e94ef5 new file mode 100644 index 000000000000..ea057a30a4fb --- /dev/null +++ b/fuzz/seed_corpus/7c85c028ae7d172131b6f464bde9f32826e94ef5 @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/7cb1dc4d1a66084e136cec80191db79004f7d881 b/fuzz/seed_corpus/7cb1dc4d1a66084e136cec80191db79004f7d881 new file mode 100644 index 000000000000..de875083e6bf --- /dev/null +++ b/fuzz/seed_corpus/7cb1dc4d1a66084e136cec80191db79004f7d881 @@ -0,0 +1,11 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:e11] + diff --git a/fuzz/seed_corpus/7cd16a6770cbde1158be465442a8d2f6d3ee6151 b/fuzz/seed_corpus/7cd16a6770cbde1158be465442a8d2f6d3ee6151 new file mode 100644 index 000000000000..7d0170bcb34b --- /dev/null +++ b/fuzz/seed_corpus/7cd16a6770cbde1158be465442a8d2f6d3ee6151 @@ -0,0 +1,10 @@ + + + (//. | //@* | //namespace::*) + [ + + ancestor-or-self::bar:Something and + (count(parent::node()/namespace::*) != + count(parent::node()/namespace::* | self::node())) + ] + diff --git a/fuzz/seed_corpus/7ce0cb194006f3f9446b13257e532181ccb4d690 b/fuzz/seed_corpus/7ce0cb194006f3f9446b13257e532181ccb4d690 new file mode 100644 index 000000000000..049b125e2316 --- /dev/null +++ b/fuzz/seed_corpus/7ce0cb194006f3f9446b13257e532181ccb4d690 @@ -0,0 +1,8 @@ + + + + There is not enough letters in the abbreviation + There is too much letters in the abbreviation + + + diff --git a/fuzz/seed_corpus/7d0e97685b4f2b497b8afc5be617b6725f042f5d b/fuzz/seed_corpus/7d0e97685b4f2b497b8afc5be617b6725f042f5d new file mode 100644 index 000000000000..990136fdae85 --- /dev/null +++ b/fuzz/seed_corpus/7d0e97685b4f2b497b8afc5be617b6725f042f5d @@ -0,0 +1,3193 @@ +"> +]> + +James Clark +jjc@jclark.com +For October 26 version of the spec. + +
3
+ +Various possible syntax errors. + +
3
+ + + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + + + + +
+ +
3
+ + + foo + + + +
+ +
3
+ + + + bar + + + +
+ +
3
+ + + + + foo + + + bar + + + + + +
+ +
3
+ + + + + foo + + + bar + + + + + +
+ +
3
+ + + + + foo + + + bar + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + + + + + + + +
+
+ +Tests for obsolete syntax + +
3
+ + + + + + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + foo + + + + +
+ +
3
+ + + + + foo + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + + + + +
+
+ +Tests for missing attributes and child elements + +
3
+ + + + +
+ +
3
+ + + foo + + +
+ +
3
+ + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + + +
+ +
3
+ + + + + + + + +
+ +
3
+ + + + + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + + + + +
+ +
3
+ + + + + + + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + + + + + +
+
+ +Checking of ns attribute + +
3
+ + + + + + + + +
+ +
3
+No checking of ns attribute is performed + + + + + + + + +
+ +
3
+No checking of ns attribute is performed + + + + + +
+ +
3
+No checking of ns attribute is performed + + + + + +
+
+ +Checking of datatypeLibrary attribute + +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + +
+ +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + + + + +
+ +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + + + + +
+ +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + +
+ +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + +
+ +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + +
+ +
3
+Value of datatypeLibrary attribute must conform to RFC 2396 + + + + + + + + +
+ +
3
+Value of datatypeLibrary attribute must not be relative + + + + + +
+ +
3
+Value of datatypeLibrary attribute must not be relative + + + + + +
+ +
3
+Value of datatypeLibrary attribute must not be relative + + + + + +
+ +
3
+Value of datatypeLibrary attribute must not be relative + + + + + +
+ +
3
+ + + + + + + + +
+ +
3
+ + + + + + + + +
+ +
3
+ + + + + + +x + +
+ +
3
+Value of datatypeLibrary attribute must not contain fragment identifier + + + + + +
+ +
3
+Value of datatypeLibrary attribute must not contain fragment identifier + + + + + +
+
+ +Tests for QName and NCNames in schemas + +
3
+ + + + + + + + +&dii; + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + + +
+ +
3
+ + + + + + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+ +
3
+ + + + + +
+
+ +Tests for elements that allow only a single pattern child. + +
3
+ + + + + + + + + + +
+ +
3
+ + + + + + + + +
+ +
3
+ + + + bar + + + + + +
+
+ +Tests for foreign element and attribute handling. + +
3
+ + + + + +
+ +
3
+ + + foo + + + +
+ +
3
+ + + foo + + +
+ +
3
+ + + + + + +X + +
+ +
3
+ + + + + + + + + + + + +
+ +
3
+ + + + + + + + + + foo + + + + + + + + + + + + + + + + +X + +
+ +
3
+ + + + + foo + + + + + + + +X + +
+ +
3
+ + + + + + + + + + foo + + + + + + + + + + +X + +
+ +
3
+ + + + + + + + + + foo + + + + + + + + + + +X + +
+
+
+ +
4
+ +
4.2
+ +
4.2
+ + + + + + + + +
+ +
4.2
+ + + bar + + + +bar + + +bar + +
+ +
4.2
+ + + + + + +X + +
+ +
4.2
+ + + foo + bar + + + + + +
+ +
4.2
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
4.4
+ + + bar + + + +bar + + + + bar + + + + bar + + +baz + + +ba r + +
+ +
4.5
+ +
4.5
+ + + + + + + + + + + + + + + + +
+ +
4.5
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.5
+ + + + + + + + +
+
+ +
4.6
+ +
4.6
+ + + + + + + + + + + + + + +
+ +
4.6
+ + + + + + + + + + + + + + +
+ +
4.6
+ + + + + + +
+ +
4.6
+ + + + + + + + + + +
+ +
4.6
+ + + + + + + + + +
+ +
4.6
+Same value of href before resolution, but not a loop. + + + + + + + + + + + + + + + + + + + + + +
+
+ +
4.7
+ +
4.7
+ + + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.7
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
4.8
+ +
4.8
+ + + + + + + + + + + +
+ +
4.8
+ + + + + + + + + + + +
+
+ +
4.9
+ +
4.9
+ + + + bar + + + + + + + + + +
+ +
4.6
+
4.9
+ + + + + + + + + + + + + + + + +
+ + + + + foo + + + + + + + + + + + foo + + + + + + + + + + + bar + + + + + + + +
+ +
4.10
+ +
4.10
+ + + + + +
+ +
4.10
+ + + + + + + + + + + +
+ +
4.10
+ + + + + + + + + + + +
+ +
4.10
+ + + + + + + + + + + +
+
+ +
4.11
+ +
4.11
+ + +
+
+ + + +
+ + + + + +
+
+ + + + + + + + + + + + +
4.12
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+
4.15
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+
4.14
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+ + + + x + y + z + + + + +x y z + + +x + +
+ +
4.12
+
4.13
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+ + + foo + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+ + + + + foo + bar + baz + + + + + + + + + +
+ +
4.12
+ + + + + x + y + z + + + + + +xyz +x +y +y +
+ +
4.12
+ + + + + + + + + + + + + + +
+ +
4.12
+ + + + bar + + + + + + + + + + + + +
+ +
4.12
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +X + + +X + + + + +
+ +
4.12
+ + + + + + + + + + + + + + + + + + + +
+ +
4.12
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.12
+ + + + + + + + + + + +
+ +
4.12
+ + + + + + + + + + + +
+ +
4.12
+ + + + + + + + + + + +
+
+ +
4.13
+ +
4.13
+ + + + + + + + + +x + +x +xy + + +
+
+ +
4.14
+ +
4.14
+ + + + + + + + + + + +x + +
+
+ +
4.15
+ +
4.15
+ + + + + + + + + + + +x + + +
+
+ +
4.16
+ +
4.16
+ + + + + + + + + + + + + + +
+ +
4.16
+ + + + + + + + + foo + + + + + + + + +
+ +
4.16
+ + + + + + + + + + + + + + +
+ +
4.16
+ + + + + + + + + foo + + + + + + + + +
+ +
4.16
+ + + + + + + + + + + + + + +
+ +
4.16
+ + + + + + + + + foo + + + + + + + + +
+ +
4.16
+Tests that 4.16 is before 4.20. + + + + + + + + + + + + + + + + + + + +
+ +
4.16
+Tests that 4.16 is before removal of unreachable definitions. + + + + + + + + + + + + + + + + + + + +
+ +
4.16
+ + + + + + + +
+ +
4.16
+ + + + + + +
+ +
4.16
+ + + + + + + +
+ +
4.16
+ + + + + + + + + + +
+ +
4.16
+ + + + + + + + + + + + + + +
+ +
4.16
+ + + + + + + +
+ +
4.16
+ + + + + xmlns + foo + + + + + +
+ +
4.16
+ + + + xmlns + + + + +
+ +
4.16
+ + + + xmlns + + + + +
+ +
4.16
+ + + + + xmlns + + + + + +
+ +
4.16
+ + + + + foo + xmlns + + + + + +
+ +
4.16
+ + + + + + + xmlns + + + + + + + +
+ +
4.16
+ + + + + + + xmlns + + + + + + + +
+ +
4.16
+ + + + + + + +
+ +
4.16
+ + + + + + +
+ +
4.16
+ + + + 2 + + + +
+ +
4.16
+ + + + + +
+ +
4.16
+ + + + + +
+ +
4.16
+ + + + + + 2 + + + + +
+ +
4.16
+ + + + + + + + +
+ +
4.16
+ + + + + + + + +
+ +
4.16
+ + + + + + + + + + 2 + + + + +
+ +
4.16
+ + + + + + + + + + + + +
+ +
4.16
+ + + + + + + + + + + + +
+
+ +
4.17
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
4.17
+ + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7d7b180aa02ec5614ede7215ee71a2da5ada9c8f b/fuzz/seed_corpus/7d7b180aa02ec5614ede7215ee71a2da5ada9c8f new file mode 100644 index 000000000000..a964a07b58fe --- /dev/null +++ b/fuzz/seed_corpus/7d7b180aa02ec5614ede7215ee71a2da5ada9c8f @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/7d8a71f28307f5fde233975b156ce0c7753d6e80 b/fuzz/seed_corpus/7d8a71f28307f5fde233975b156ce0c7753d6e80 new file mode 100644 index 000000000000..c4602397d24b --- /dev/null +++ b/fuzz/seed_corpus/7d8a71f28307f5fde233975b156ce0c7753d6e80 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/fuzz/seed_corpus/7da9aadc61efbf87721a356af3254d37eb2c0f20 b/fuzz/seed_corpus/7da9aadc61efbf87721a356af3254d37eb2c0f20 new file mode 100644 index 000000000000..50bdd3213470 --- /dev/null +++ b/fuzz/seed_corpus/7da9aadc61efbf87721a356af3254d37eb2c0f20 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/7de13be5eeb2eecaf2cdc74d0c2bd0ea6b7c6321 b/fuzz/seed_corpus/7de13be5eeb2eecaf2cdc74d0c2bd0ea6b7c6321 new file mode 100644 index 000000000000..e49f6eca710c --- /dev/null +++ b/fuzz/seed_corpus/7de13be5eeb2eecaf2cdc74d0c2bd0ea6b7c6321 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/7e4e69c985366bf1858406110a39892313a7c493 b/fuzz/seed_corpus/7e4e69c985366bf1858406110a39892313a7c493 new file mode 100644 index 000000000000..f8210893d868 --- /dev/null +++ b/fuzz/seed_corpus/7e4e69c985366bf1858406110a39892313a7c493 @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/7e641e43a098f4fab7665342745c10c28e89939a b/fuzz/seed_corpus/7e641e43a098f4fab7665342745c10c28e89939a new file mode 100644 index 000000000000..23d3c0646e30 --- /dev/null +++ b/fuzz/seed_corpus/7e641e43a098f4fab7665342745c10c28e89939a @@ -0,0 +1,8 @@ + +' > +' > +' > +%defroot;%defmiddle;%deftest; +]> +sample diff --git a/fuzz/seed_corpus/7ebc3a901368f17eb0b187ffc0491400e12fe9b9 b/fuzz/seed_corpus/7ebc3a901368f17eb0b187ffc0491400e12fe9b9 new file mode 100644 index 000000000000..1cbaf1fb1e20 --- /dev/null +++ b/fuzz/seed_corpus/7ebc3a901368f17eb0b187ffc0491400e12fe9b9 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/7ed60fa7c3717de45b17ee68ec1783c7480d58a1 b/fuzz/seed_corpus/7ed60fa7c3717de45b17ee68ec1783c7480d58a1 new file mode 100644 index 000000000000..cdb7437f0b4d --- /dev/null +++ b/fuzz/seed_corpus/7ed60fa7c3717de45b17ee68ec1783c7480d58a1 @@ -0,0 +1,43 @@ + + + + + + + + + + + +]> + + + + Welcome to Gnome + + + The Linux adventure +

bla bla bla ...

+ +

...

+

third p

+

fourth p

+
+ + Chapter 2 +

this is chapter 2 ...

+
+ + Chapter 3 +

this is chapter 3 ...

+
+ + Chapter 4 +

this is chapter 4 ...

+
+ + Chapter 5 +

this is chapter 5 ...

+
+
diff --git a/fuzz/seed_corpus/7f0abc1c206fe282b9c426ac221c78bbb0814173 b/fuzz/seed_corpus/7f0abc1c206fe282b9c426ac221c78bbb0814173 new file mode 100644 index 000000000000..54f1973fac9b --- /dev/null +++ b/fuzz/seed_corpus/7f0abc1c206fe282b9c426ac221c78bbb0814173 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/7f47e1db739cfe08b61962939dbd91a764e26b0e b/fuzz/seed_corpus/7f47e1db739cfe08b61962939dbd91a764e26b0e new file mode 100644 index 000000000000..1c644d18401a --- /dev/null +++ b/fuzz/seed_corpus/7f47e1db739cfe08b61962939dbd91a764e26b0e @@ -0,0 +1,4 @@ +public "-//OASIS//DTD DocBook XML CALS Table Model V4.1//EN" +public "-//Davenport//DTD DocBook V3.0//EN" +public "-//OASIS//DTD XML Exchange Table Model 19990315//EN" +public "-//Davenport//ENTITIES DocBook Additional General Entities V3.0//EN" diff --git a/fuzz/seed_corpus/7f621cd731ad008c88ebb4f78ffe9e1cc3a5b15f b/fuzz/seed_corpus/7f621cd731ad008c88ebb4f78ffe9e1cc3a5b15f new file mode 100644 index 000000000000..3c11e29ba6b2 --- /dev/null +++ b/fuzz/seed_corpus/7f621cd731ad008c88ebb4f78ffe9e1cc3a5b15f @@ -0,0 +1,14 @@ + + + + + + +]> + + (//.|//@*|//namespace::*) + [ + ancestor-or-self::dsig:X509Data + ] + diff --git a/fuzz/seed_corpus/7fde29284068ea511b9b2be6dd901afb585d8064 b/fuzz/seed_corpus/7fde29284068ea511b9b2be6dd901afb585d8064 new file mode 100644 index 000000000000..53bf38fd6bb6 --- /dev/null +++ b/fuzz/seed_corpus/7fde29284068ea511b9b2be6dd901afb585d8064 @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/8009a62e67818ddf363f49775f8b3e281e8fa04c b/fuzz/seed_corpus/8009a62e67818ddf363f49775f8b3e281e8fa04c new file mode 100644 index 000000000000..a07f6c7b3958 --- /dev/null +++ b/fuzz/seed_corpus/8009a62e67818ddf363f49775f8b3e281e8fa04c @@ -0,0 +1,11 @@ + + +]> + + + + + + + diff --git a/fuzz/seed_corpus/801d22b517df552c84c59feef532047455669503 b/fuzz/seed_corpus/801d22b517df552c84c59feef532047455669503 new file mode 100644 index 000000000000..0a9fee773284 --- /dev/null +++ b/fuzz/seed_corpus/801d22b517df552c84c59feef532047455669503 @@ -0,0 +1,9 @@ + + + This well formed svg document contains a hyperlink + + +

+ + diff --git a/fuzz/seed_corpus/8107206fa6e510fd3b3faa09c11bc54b5f3e0b53 b/fuzz/seed_corpus/8107206fa6e510fd3b3faa09c11bc54b5f3e0b53 new file mode 100644 index 0000000000000000000000000000000000000000..8c402e02c0ed3261e38b73e81838959aa4b76852 GIT binary patch literal 346 zcmZ9Iy$*sv5QM+lr$Bo|8!LsxM4td_V*q~=I0+CVFRu=ZhDdX}H#<8scds{VBAyiF zcs$6csJU^+v0=uNISW-!6GtLE)zopZ>4BI%zE~@^?2K2_a1tZcnVU{#+*S&;7!e^8 zxlXm`OE=~!#ai82H5beK-Ur7_Y8~oyjy*lo=`|~Dm-6gh(5P0l+W1E+;VnloQp?p? gu13j1rE*GL7*eWBEX@z={$pSV#t%m7y{FQA0KQ~8#sB~S literal 0 HcmV?d00001 diff --git a/fuzz/seed_corpus/810e451e6ad1f1c8680db315bb56c75941df82c7 b/fuzz/seed_corpus/810e451e6ad1f1c8680db315bb56c75941df82c7 new file mode 100644 index 000000000000..6f2b333c246a --- /dev/null +++ b/fuzz/seed_corpus/810e451e6ad1f1c8680db315bb56c75941df82c7 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/8139c334fd7029acc0185cd17ac297ba8c31f3a7 b/fuzz/seed_corpus/8139c334fd7029acc0185cd17ac297ba8c31f3a7 new file mode 100644 index 000000000000..9535ffcf280b --- /dev/null +++ b/fuzz/seed_corpus/8139c334fd7029acc0185cd17ac297ba8c31f3a7 @@ -0,0 +1,18 @@ + + + + + + + Write + Exclusive + + + Write + Shared + + + + HTTP/1.1 200 OK + + diff --git a/fuzz/seed_corpus/813ea194416cf7a07ceb9fbbadb6ad95f1681424 b/fuzz/seed_corpus/813ea194416cf7a07ceb9fbbadb6ad95f1681424 new file mode 100644 index 000000000000..6b35b9f37660 --- /dev/null +++ b/fuzz/seed_corpus/813ea194416cf7a07ceb9fbbadb6ad95f1681424 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/814696d90cc9eb8d7673dea191aa107e69f13a60 b/fuzz/seed_corpus/814696d90cc9eb8d7673dea191aa107e69f13a60 new file mode 100644 index 000000000000..f1af6a26bf5a --- /dev/null +++ b/fuzz/seed_corpus/814696d90cc9eb8d7673dea191aa107e69f13a60 @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/81900cdf0f2e39732efec7b29854ba59dee6ff2b b/fuzz/seed_corpus/81900cdf0f2e39732efec7b29854ba59dee6ff2b new file mode 100644 index 000000000000..009e322e248b --- /dev/null +++ b/fuzz/seed_corpus/81900cdf0f2e39732efec7b29854ba59dee6ff2b @@ -0,0 +1,7 @@ + +prefix is indeclared here"> +]> + + &xml; + diff --git a/fuzz/seed_corpus/819a7632e78054517b5e55a3040e35bb963936e7 b/fuzz/seed_corpus/819a7632e78054517b5e55a3040e35bb963936e7 new file mode 100644 index 000000000000..ba3919415081 --- /dev/null +++ b/fuzz/seed_corpus/819a7632e78054517b5e55a3040e35bb963936e7 @@ -0,0 +1,7 @@ + + + + + b text + + diff --git a/fuzz/seed_corpus/81aedd976c16631f3d4d4ac1a5e00fd2371d34f2 b/fuzz/seed_corpus/81aedd976c16631f3d4d4ac1a5e00fd2371d34f2 new file mode 100644 index 000000000000..94f707196aff --- /dev/null +++ b/fuzz/seed_corpus/81aedd976c16631f3d4d4ac1a5e00fd2371d34f2 @@ -0,0 +1,343 @@ + + + +]> + diff --git a/fuzz/seed_corpus/820fa5ffd74c5e842892ebfa6b7be36d63d370b4 b/fuzz/seed_corpus/820fa5ffd74c5e842892ebfa6b7be36d63d370b4 new file mode 100644 index 000000000000..a58fe8b5eb23 --- /dev/null +++ b/fuzz/seed_corpus/820fa5ffd74c5e842892ebfa6b7be36d63d370b4 @@ -0,0 +1,6 @@ + + hello world + hello world + hello world + hello world + diff --git a/fuzz/seed_corpus/82785abe0718426456457956f3a300b9e3ba2ea3 b/fuzz/seed_corpus/82785abe0718426456457956f3a300b9e3ba2ea3 new file mode 100644 index 000000000000..c1c385d025f8 --- /dev/null +++ b/fuzz/seed_corpus/82785abe0718426456457956f3a300b9e3ba2ea3 @@ -0,0 +1,8 @@ + + + + + + diff --git a/fuzz/seed_corpus/827c33d56454cd2748018ba925dcaae7b18bc54f b/fuzz/seed_corpus/827c33d56454cd2748018ba925dcaae7b18bc54f new file mode 100644 index 000000000000..ba9bdca86ceb --- /dev/null +++ b/fuzz/seed_corpus/827c33d56454cd2748018ba925dcaae7b18bc54f @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/835d34f465ab2e11016c1d47403d3883d4eacb35 b/fuzz/seed_corpus/835d34f465ab2e11016c1d47403d3883d4eacb35 new file mode 100644 index 000000000000..d57adf236472 --- /dev/null +++ b/fuzz/seed_corpus/835d34f465ab2e11016c1d47403d3883d4eacb35 @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + +Datatype + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<!DOCTYPE + + [ + + + +]> + + + + + + + + + element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/83d964194f3c6931cdf09f8c6aa572ee4f0a5d92 b/fuzz/seed_corpus/83d964194f3c6931cdf09f8c6aa572ee4f0a5d92 new file mode 100644 index 000000000000..cc459e91f08e --- /dev/null +++ b/fuzz/seed_corpus/83d964194f3c6931cdf09f8c6aa572ee4f0a5d92 @@ -0,0 +1,5 @@ + + +]> + violates [ WFC: No < in Attribute Values ] diff --git a/fuzz/seed_corpus/83ef3875de50ff739e8734af789bd0626be0ba0d b/fuzz/seed_corpus/83ef3875de50ff739e8734af789bd0626be0ba0d new file mode 100644 index 000000000000..0791e1a7dcd1 --- /dev/null +++ b/fuzz/seed_corpus/83ef3875de50ff739e8734af789bd0626be0ba0d @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/83fd01d94e4c127179e05ceab010b8c948384433 b/fuzz/seed_corpus/83fd01d94e4c127179e05ceab010b8c948384433 new file mode 100644 index 000000000000..acc2346e68bf --- /dev/null +++ b/fuzz/seed_corpus/83fd01d94e4c127179e05ceab010b8c948384433 @@ -0,0 +1,5 @@ + + + + + diff --git a/fuzz/seed_corpus/8417b375ee04fc01fb076db23961076133df89e5 b/fuzz/seed_corpus/8417b375ee04fc01fb076db23961076133df89e5 new file mode 100644 index 000000000000..32f8cfe8e2f3 --- /dev/null +++ b/fuzz/seed_corpus/8417b375ee04fc01fb076db23961076133df89e5 @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/842e36feb35a81b08ef1b5aa735f8cea615e6b88 b/fuzz/seed_corpus/842e36feb35a81b08ef1b5aa735f8cea615e6b88 new file mode 100644 index 000000000000..878e3e39d800 --- /dev/null +++ b/fuzz/seed_corpus/842e36feb35a81b08ef1b5aa735f8cea615e6b88 @@ -0,0 +1,9 @@ + + + + +]> + + + diff --git a/fuzz/seed_corpus/846b75d8201bc4be99b7f09e9afdbea164af9e5a b/fuzz/seed_corpus/846b75d8201bc4be99b7f09e9afdbea164af9e5a new file mode 100644 index 000000000000..806ac23d665e --- /dev/null +++ b/fuzz/seed_corpus/846b75d8201bc4be99b7f09e9afdbea164af9e5a @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/850d7f2be8432c8de1bbca56f707ad51d0c4abe8 b/fuzz/seed_corpus/850d7f2be8432c8de1bbca56f707ad51d0c4abe8 new file mode 100644 index 000000000000..aa6e33649a3a --- /dev/null +++ b/fuzz/seed_corpus/850d7f2be8432c8de1bbca56f707ad51d0c4abe8 @@ -0,0 +1,5 @@ + + +]> +&WhatHeSaid; diff --git a/fuzz/seed_corpus/857fca83124e5f00ec124068ce52269724f5a72b b/fuzz/seed_corpus/857fca83124e5f00ec124068ce52269724f5a72b new file mode 100644 index 000000000000..ce446d881f4d --- /dev/null +++ b/fuzz/seed_corpus/857fca83124e5f00ec124068ce52269724f5a72b @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/8588b54ec193e3458c35a268e00797b24c0cc142 b/fuzz/seed_corpus/8588b54ec193e3458c35a268e00797b24c0cc142 new file mode 100644 index 000000000000..cd433e0154a9 --- /dev/null +++ b/fuzz/seed_corpus/8588b54ec193e3458c35a268e00797b24c0cc142 @@ -0,0 +1,7 @@ + + + + The values do not sum to 100%. + + + diff --git a/fuzz/seed_corpus/859ced85aa5862070f5b29f71e3964b35313ca53 b/fuzz/seed_corpus/859ced85aa5862070f5b29f71e3964b35313ca53 new file mode 100644 index 000000000000..5943c117e6b5 --- /dev/null +++ b/fuzz/seed_corpus/859ced85aa5862070f5b29f71e3964b35313ca53 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/86734dd3530bddd9c5f9b476e92ca59e90b2afff b/fuzz/seed_corpus/86734dd3530bddd9c5f9b476e92ca59e90b2afff new file mode 100644 index 000000000000..d8643d747eb5 --- /dev/null +++ b/fuzz/seed_corpus/86734dd3530bddd9c5f9b476e92ca59e90b2afff @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 b/fuzz/seed_corpus/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 new file mode 100644 index 000000000000..2e65efe2a145 --- /dev/null +++ b/fuzz/seed_corpus/86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 @@ -0,0 +1 @@ +a \ No newline at end of file diff --git a/fuzz/seed_corpus/877409204f0de5d4ed884498ce8daaf153b8864c b/fuzz/seed_corpus/877409204f0de5d4ed884498ce8daaf153b8864c new file mode 100644 index 000000000000..e97213249b52 --- /dev/null +++ b/fuzz/seed_corpus/877409204f0de5d4ed884498ce8daaf153b8864c @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/fuzz/seed_corpus/878356f08f838142fc384df34b3a17df61b8292a b/fuzz/seed_corpus/878356f08f838142fc384df34b3a17df61b8292a new file mode 100644 index 000000000000..136bf9237cd8 --- /dev/null +++ b/fuzz/seed_corpus/878356f08f838142fc384df34b3a17df61b8292a @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/87e5bf9a5001599b7129c3e25585b27d367303aa b/fuzz/seed_corpus/87e5bf9a5001599b7129c3e25585b27d367303aa new file mode 100644 index 000000000000..41d797e4109b --- /dev/null +++ b/fuzz/seed_corpus/87e5bf9a5001599b7129c3e25585b27d367303aa @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/884afcdfc84b1f0c7ad6f50ca6b5bc93896dd0f8 b/fuzz/seed_corpus/884afcdfc84b1f0c7ad6f50ca6b5bc93896dd0f8 new file mode 100644 index 000000000000..31ee88261626 --- /dev/null +++ b/fuzz/seed_corpus/884afcdfc84b1f0c7ad6f50ca6b5bc93896dd0f8 @@ -0,0 +1 @@ +

diff --git a/fuzz/seed_corpus/8887177540290a0076f883559c2a98cffd3cc2f6 b/fuzz/seed_corpus/8887177540290a0076f883559c2a98cffd3cc2f6 new file mode 100644 index 000000000000..edc805d52e3f --- /dev/null +++ b/fuzz/seed_corpus/8887177540290a0076f883559c2a98cffd3cc2f6 @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + global ############# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/88f441da69c62e97531be947885d667dc74feb0c b/fuzz/seed_corpus/88f441da69c62e97531be947885d667dc74feb0c new file mode 100644 index 000000000000..69ebb57c0722 --- /dev/null +++ b/fuzz/seed_corpus/88f441da69c62e97531be947885d667dc74feb0c @@ -0,0 +1 @@ +%xx; \ No newline at end of file diff --git a/fuzz/seed_corpus/8917c5f3ef5e81df9afb1066c255d5026bfd60cc b/fuzz/seed_corpus/8917c5f3ef5e81df9afb1066c255d5026bfd60cc new file mode 100644 index 000000000000..7316a1325fc2 --- /dev/null +++ b/fuzz/seed_corpus/8917c5f3ef5e81df9afb1066c255d5026bfd60cc @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/89260f0b6eec54e5f08f7d84b1866c963ffe71b0 b/fuzz/seed_corpus/89260f0b6eec54e5f08f7d84b1866c963ffe71b0 new file mode 100644 index 000000000000..e62ebb8ce4c5 --- /dev/null +++ b/fuzz/seed_corpus/89260f0b6eec54e5f08f7d84b1866c963ffe71b0 @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/fuzz/seed_corpus/8963f87b9328c9d602c9995b105074c6ec825122 b/fuzz/seed_corpus/8963f87b9328c9d602c9995b105074c6ec825122 new file mode 100644 index 000000000000..a585e8536513 --- /dev/null +++ b/fuzz/seed_corpus/8963f87b9328c9d602c9995b105074c6ec825122 @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/89c0961db858d6de841f30462694d870e1de6d39 b/fuzz/seed_corpus/89c0961db858d6de841f30462694d870e1de6d39 new file mode 100644 index 000000000000..1bf56dc5d033 --- /dev/null +++ b/fuzz/seed_corpus/89c0961db858d6de841f30462694d870e1de6d39 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/89cb2e5aa7972899aa1d0095bb78b5f48ed19c4d b/fuzz/seed_corpus/89cb2e5aa7972899aa1d0095bb78b5f48ed19c4d new file mode 100644 index 000000000000..e57652fdcefa --- /dev/null +++ b/fuzz/seed_corpus/89cb2e5aa7972899aa1d0095bb78b5f48ed19c4d @@ -0,0 +1,6 @@ + +(//. | //@* | //namespace::*) +[ + ancestor-or-self::ds:SignedInfo +] + \ No newline at end of file diff --git a/fuzz/seed_corpus/89d905e5699bccb75f335191d92655986b943b80 b/fuzz/seed_corpus/89d905e5699bccb75f335191d92655986b943b80 new file mode 100644 index 000000000000..44c7529b6144 --- /dev/null +++ b/fuzz/seed_corpus/89d905e5699bccb75f335191d92655986b943b80 @@ -0,0 +1,12 @@ + + + + + + + + +N + + diff --git a/fuzz/seed_corpus/8a266e439cc8bdd31c8930fb82ad086ee98cc7e1 b/fuzz/seed_corpus/8a266e439cc8bdd31c8930fb82ad086ee98cc7e1 new file mode 100644 index 000000000000..c17d9d5ff504 --- /dev/null +++ b/fuzz/seed_corpus/8a266e439cc8bdd31c8930fb82ad086ee98cc7e1 @@ -0,0 +1,23 @@ + + pvtest + 596a5d2171f48fb2e068e2386a5c413e + + linux + /var/lib/xen/vmlinuz.2Dn2YT + /var/lib/xen/initrd.img.0u-Vhq + method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os + + 430080 + 2 + destroy + destroy + destroy + + + + + + + + + diff --git a/fuzz/seed_corpus/8a38a42e8ed434e7fd85d3031fce504a760aa24b b/fuzz/seed_corpus/8a38a42e8ed434e7fd85d3031fce504a760aa24b new file mode 100644 index 000000000000..644b06e67da7 --- /dev/null +++ b/fuzz/seed_corpus/8a38a42e8ed434e7fd85d3031fce504a760aa24b @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/8a9c98c29c12d19ea2446c319c2655ccb3df188f b/fuzz/seed_corpus/8a9c98c29c12d19ea2446c319c2655ccb3df188f new file mode 100644 index 000000000000..ad25e93f9aac --- /dev/null +++ b/fuzz/seed_corpus/8a9c98c29c12d19ea2446c319c2655ccb3df188f @@ -0,0 +1,13 @@ + + + + Groups can nest + + + + + + + + diff --git a/fuzz/seed_corpus/8abf3faaa71c4a6765901bb7abdfb339a45c360f b/fuzz/seed_corpus/8abf3faaa71c4a6765901bb7abdfb339a45c360f new file mode 100644 index 000000000000..9fd51b3d1918 --- /dev/null +++ b/fuzz/seed_corpus/8abf3faaa71c4a6765901bb7abdfb339a45c360f @@ -0,0 +1 @@ +<:/> diff --git a/fuzz/seed_corpus/8ac5645ab138ff454b8cd5410d6c43453f58d35b b/fuzz/seed_corpus/8ac5645ab138ff454b8cd5410d6c43453f58d35b new file mode 100644 index 000000000000..e91fe43fceac --- /dev/null +++ b/fuzz/seed_corpus/8ac5645ab138ff454b8cd5410d6c43453f58d35b @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/8c0cf798c2168950b2ebcdb2ca17c68731a52e64 b/fuzz/seed_corpus/8c0cf798c2168950b2ebcdb2ca17c68731a52e64 new file mode 100644 index 000000000000..fec1ed3bc5ba --- /dev/null +++ b/fuzz/seed_corpus/8c0cf798c2168950b2ebcdb2ca17c68731a52e64 @@ -0,0 +1,17 @@ + + + + 0.12 + 0.0 + 0.02 + 12 + 1.2 + + 0.123 + 0.023 + 123 + 12.3 + + diff --git a/fuzz/seed_corpus/8c917b16c6eb86a29207bc0dbf26e7121cb0f047 b/fuzz/seed_corpus/8c917b16c6eb86a29207bc0dbf26e7121cb0f047 new file mode 100644 index 000000000000..884b1065d7fd --- /dev/null +++ b/fuzz/seed_corpus/8c917b16c6eb86a29207bc0dbf26e7121cb0f047 @@ -0,0 +1,3 @@ +xpointer(id('chapter1')/p) +xpointer(id('chapter1')/p[1]/range-to(following-sibling::p[2])) +xpointer(range-to(id('chapter2'))) diff --git a/fuzz/seed_corpus/8ccef0cdd6149cda4059a91943cb00549a8ca71b b/fuzz/seed_corpus/8ccef0cdd6149cda4059a91943cb00549a8ca71b new file mode 100644 index 000000000000..c9cdef491558 --- /dev/null +++ b/fuzz/seed_corpus/8ccef0cdd6149cda4059a91943cb00549a8ca71b @@ -0,0 +1 @@ +5 diff --git a/fuzz/seed_corpus/8d1f2e6ebd62a8cae3ecdc2b3c79fae65f81628b b/fuzz/seed_corpus/8d1f2e6ebd62a8cae3ecdc2b3c79fae65f81628b new file mode 100644 index 000000000000..6021eb9f133d --- /dev/null +++ b/fuzz/seed_corpus/8d1f2e6ebd62a8cae3ecdc2b3c79fae65f81628b @@ -0,0 +1,8 @@ + + + + + + diff --git a/fuzz/seed_corpus/8d388f2d9c257a4dcad5264043d0b48a5ed97354 b/fuzz/seed_corpus/8d388f2d9c257a4dcad5264043d0b48a5ed97354 new file mode 100644 index 000000000000..832c507847a7 --- /dev/null +++ b/fuzz/seed_corpus/8d388f2d9c257a4dcad5264043d0b48a5ed97354 @@ -0,0 +1,4 @@ + + bbbb + cccc + diff --git a/fuzz/seed_corpus/8e8b74f62c484f2da007454c3f2d840d3135c34b b/fuzz/seed_corpus/8e8b74f62c484f2da007454c3f2d840d3135c34b new file mode 100644 index 000000000000..94e62f0c23ac --- /dev/null +++ b/fuzz/seed_corpus/8e8b74f62c484f2da007454c3f2d840d3135c34b @@ -0,0 +1,3 @@ + + foobar + diff --git a/fuzz/seed_corpus/8ee397e9f2535ca02779820367212d184fc5abc7 b/fuzz/seed_corpus/8ee397e9f2535ca02779820367212d184fc5abc7 new file mode 100644 index 000000000000..cc716704349d --- /dev/null +++ b/fuzz/seed_corpus/8ee397e9f2535ca02779820367212d184fc5abc7 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/8ee4ec247ee5588249dd3736e5989afa7df33d99 b/fuzz/seed_corpus/8ee4ec247ee5588249dd3736e5989afa7df33d99 new file mode 100644 index 000000000000..fee99f7b9653 --- /dev/null +++ b/fuzz/seed_corpus/8ee4ec247ee5588249dd3736e5989afa7df33d99 @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/8eead2134322a2c7ed1795ca2ac9a447017b665b b/fuzz/seed_corpus/8eead2134322a2c7ed1795ca2ac9a447017b665b new file mode 100644 index 000000000000..1aef3a924ede --- /dev/null +++ b/fuzz/seed_corpus/8eead2134322a2c7ed1795ca2ac9a447017b665b @@ -0,0 +1,3 @@ + diff --git a/fuzz/seed_corpus/8f32615410d86304e89d426982559ca7444f1c39 b/fuzz/seed_corpus/8f32615410d86304e89d426982559ca7444f1c39 new file mode 100644 index 000000000000..8656d2c4b097 --- /dev/null +++ b/fuzz/seed_corpus/8f32615410d86304e89d426982559ca7444f1c39 @@ -0,0 +1,5 @@ + + + Bill + Clinton + diff --git a/fuzz/seed_corpus/8f8ae74202ec25228b8f03c2c1dcb22b520b2b74 b/fuzz/seed_corpus/8f8ae74202ec25228b8f03c2c1dcb22b520b2b74 new file mode 100644 index 000000000000..e8e9ef2f1b5d --- /dev/null +++ b/fuzz/seed_corpus/8f8ae74202ec25228b8f03c2c1dcb22b520b2b74 @@ -0,0 +1,14 @@ + + + A foo element. + + + + + + + diff --git a/fuzz/seed_corpus/8fe1b82e17f7d261af3afa559576ac06006c5bbe b/fuzz/seed_corpus/8fe1b82e17f7d261af3afa559576ac06006c5bbe new file mode 100644 index 000000000000..3e24756fb379 --- /dev/null +++ b/fuzz/seed_corpus/8fe1b82e17f7d261af3afa559576ac06006c5bbe @@ -0,0 +1,7 @@ + + +]> + + &xml; + diff --git a/fuzz/seed_corpus/8fe51a539d8f16b217de6aa8df5aa3fa51354d4c b/fuzz/seed_corpus/8fe51a539d8f16b217de6aa8df5aa3fa51354d4c new file mode 100644 index 000000000000..014483ba698d --- /dev/null +++ b/fuzz/seed_corpus/8fe51a539d8f16b217de6aa8df5aa3fa51354d4c @@ -0,0 +1,13 @@ + + +Regression test 3 + + +

Regression test 3

+

+Autoclose of tag P +


+

+Ok file no problem + + diff --git a/fuzz/seed_corpus/903f6155689859ec4d0acf87bc2733956e2007c8 b/fuzz/seed_corpus/903f6155689859ec4d0acf87bc2733956e2007c8 new file mode 100644 index 000000000000..8321da2f9209 --- /dev/null +++ b/fuzz/seed_corpus/903f6155689859ec4d0acf87bc2733956e2007c8 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/904c61a798ae76ecaef0f6158b4ef3403b20d2e0 b/fuzz/seed_corpus/904c61a798ae76ecaef0f6158b4ef3403b20d2e0 new file mode 100644 index 000000000000..d3b7e8ef569e --- /dev/null +++ b/fuzz/seed_corpus/904c61a798ae76ecaef0f6158b4ef3403b20d2e0 @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/906c8ed21f324f22c94c108a3b2b2ab71e57a17c b/fuzz/seed_corpus/906c8ed21f324f22c94c108a3b2b2ab71e57a17c new file mode 100644 index 000000000000..86f8cd1943aa --- /dev/null +++ b/fuzz/seed_corpus/906c8ed21f324f22c94c108a3b2b2ab71e57a17c @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/90d942f05414a5e75f009b436e63b8c9aa99564b b/fuzz/seed_corpus/90d942f05414a5e75f009b436e63b8c9aa99564b new file mode 100644 index 000000000000..53cc7b01e229 --- /dev/null +++ b/fuzz/seed_corpus/90d942f05414a5e75f009b436e63b8c9aa99564b @@ -0,0 +1,7 @@ + + +

+ +
+ + \ No newline at end of file diff --git a/fuzz/seed_corpus/9175ea05ca9c358924d31558bf8c26c24a506ed4 b/fuzz/seed_corpus/9175ea05ca9c358924d31558bf8c26c24a506ed4 new file mode 100644 index 000000000000..3d65bb06dbbb --- /dev/null +++ b/fuzz/seed_corpus/9175ea05ca9c358924d31558bf8c26c24a506ed4 @@ -0,0 +1 @@ +<salut/> diff --git a/fuzz/seed_corpus/91817b85cffb36dae26eb991977743f486ec0bd4 b/fuzz/seed_corpus/91817b85cffb36dae26eb991977743f486ec0bd4 new file mode 100644 index 000000000000..97436e52e07f --- /dev/null +++ b/fuzz/seed_corpus/91817b85cffb36dae26eb991977743f486ec0bd4 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/918b86ec3933223d08a79988bf48e171a5b0cd6e b/fuzz/seed_corpus/918b86ec3933223d08a79988bf48e171a5b0cd6e new file mode 100644 index 000000000000..da8c53b2d7eb --- /dev/null +++ b/fuzz/seed_corpus/918b86ec3933223d08a79988bf48e171a5b0cd6e @@ -0,0 +1 @@ +xpointer(non-existing-fn()/range-to(id('chapter2'))) diff --git a/fuzz/seed_corpus/918ec5eb28a03b4389994c4b03448ff84244b8f3 b/fuzz/seed_corpus/918ec5eb28a03b4389994c4b03448ff84244b8f3 new file mode 100644 index 000000000000..e14aa46b2f7e --- /dev/null +++ b/fuzz/seed_corpus/918ec5eb28a03b4389994c4b03448ff84244b8f3 @@ -0,0 +1,9 @@ + + + + + + + diff --git a/fuzz/seed_corpus/91c53a0ba38caedb6aedb428044de8690e571eb2 b/fuzz/seed_corpus/91c53a0ba38caedb6aedb428044de8690e571eb2 new file mode 100644 index 000000000000..f98b6d89a46b --- /dev/null +++ b/fuzz/seed_corpus/91c53a0ba38caedb6aedb428044de8690e571eb2 @@ -0,0 +1,10 @@ + + + + Element CCC must not be a child of element + + + + + + diff --git a/fuzz/seed_corpus/9206fc32327e79d9444a95e9eab9873ea3c0cc24 b/fuzz/seed_corpus/9206fc32327e79d9444a95e9eab9873ea3c0cc24 new file mode 100644 index 000000000000..b8d1a6556544 --- /dev/null +++ b/fuzz/seed_corpus/9206fc32327e79d9444a95e9eab9873ea3c0cc24 @@ -0,0 +1,11 @@ + + + + Four separate rectangles + + + + + + diff --git a/fuzz/seed_corpus/926ef7f39a5d67671db2ef56b3ad52b4021318f5 b/fuzz/seed_corpus/926ef7f39a5d67671db2ef56b3ad52b4021318f5 new file mode 100644 index 000000000000..bf3dfc248085 --- /dev/null +++ b/fuzz/seed_corpus/926ef7f39a5d67671db2ef56b3ad52b4021318f5 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/928567fc69eae9e536c8cefa3b7654bf63ecc032 b/fuzz/seed_corpus/928567fc69eae9e536c8cefa3b7654bf63ecc032 new file mode 100644 index 000000000000..def8d6643499 --- /dev/null +++ b/fuzz/seed_corpus/928567fc69eae9e536c8cefa3b7654bf63ecc032 @@ -0,0 +1,1194 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/92c7b1ed4b5bb9fd903e941dec640be37dfeaafb b/fuzz/seed_corpus/92c7b1ed4b5bb9fd903e941dec640be37dfeaafb new file mode 100644 index 000000000000..7020803fd979 --- /dev/null +++ b/fuzz/seed_corpus/92c7b1ed4b5bb9fd903e941dec640be37dfeaafb @@ -0,0 +1,11 @@ + + +(//. | //@* | //namespace::*) +[ancestor-or-self::ietf:e21] + diff --git a/fuzz/seed_corpus/92cc73c67540ad637fd8890c5e44e49ebac8fb59 b/fuzz/seed_corpus/92cc73c67540ad637fd8890c5e44e49ebac8fb59 new file mode 100644 index 000000000000..1de1abcdbe84 --- /dev/null +++ b/fuzz/seed_corpus/92cc73c67540ad637fd8890c5e44e49ebac8fb59 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/92d264ce8685b25ce23f85cc9528833487eebdf7 b/fuzz/seed_corpus/92d264ce8685b25ce23f85cc9528833487eebdf7 new file mode 100644 index 000000000000..fed210309215 --- /dev/null +++ b/fuzz/seed_corpus/92d264ce8685b25ce23f85cc9528833487eebdf7 @@ -0,0 +1,179 @@ +" + PIC "?>" + SHORTREF NONE + + NAMES + SGMLREF + + QUANTITY NONE + + ENTITIES + "amp" 38 + "lt" 60 + "gt" 62 + "quot" 34 + "apos" 39 + + FEATURES + MINIMIZE + DATATAG NO + OMITTAG NO + RANK NO + SHORTTAG + STARTTAG + EMPTY NO + UNCLOSED NO + NETENABL IMMEDNET + ENDTAG + EMPTY NO + UNCLOSED NO + ATTRIB + DEFAULT YES + OMITNAME NO + VALUE NO + EMPTYNRM YES + IMPLYDEF + ATTLIST NO + DOCTYPE NO + ELEMENT NO + ENTITY NO + NOTATION NO + LINK + SIMPLE NO + IMPLICIT NO + EXPLICIT NO + OTHER + CONCUR NO + SUBDOC NO + FORMAL NO + URN NO + KEEPRSRE YES + VALIDITY TYPE + ENTITIES + REF ANY + INTEGRAL YES + APPINFO NONE + SEEALSO "ISO 8879:1986//NOTATION + Extensible Markup Language (XML) 1.0//EN" +> diff --git a/fuzz/seed_corpus/93f8de76de6f88df08f467f599c954c8ddc12170 b/fuzz/seed_corpus/93f8de76de6f88df08f467f599c954c8ddc12170 new file mode 100644 index 000000000000..038ac482ece2 --- /dev/null +++ b/fuzz/seed_corpus/93f8de76de6f88df08f467f599c954c8ddc12170 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/940863cdaeac10969e9dd60aa5dcf6ba6df4ad03 b/fuzz/seed_corpus/940863cdaeac10969e9dd60aa5dcf6ba6df4ad03 new file mode 100644 index 000000000000..cbedaf9644d2 --- /dev/null +++ b/fuzz/seed_corpus/940863cdaeac10969e9dd60aa5dcf6ba6df4ad03 @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/943fff6ebe05ba44475aa82880008862ffaa68da b/fuzz/seed_corpus/943fff6ebe05ba44475aa82880008862ffaa68da new file mode 100644 index 000000000000..86ea447f6ea1 --- /dev/null +++ b/fuzz/seed_corpus/943fff6ebe05ba44475aa82880008862ffaa68da @@ -0,0 +1 @@ + how are you

'yau de poelle

?
diff --git a/fuzz/seed_corpus/944c3c5375b82e3274fbc765951c97c155ca810e b/fuzz/seed_corpus/944c3c5375b82e3274fbc765951c97c155ca810e new file mode 100644 index 000000000000..7655a8e09314 --- /dev/null +++ b/fuzz/seed_corpus/944c3c5375b82e3274fbc765951c97c155ca810e @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/948413ad9f30726920f53ed384ce679da6451197 b/fuzz/seed_corpus/948413ad9f30726920f53ed384ce679da6451197 new file mode 100644 index 000000000000..a1631d0c5a0b --- /dev/null +++ b/fuzz/seed_corpus/948413ad9f30726920f53ed384ce679da6451197 @@ -0,0 +1,7 @@ + + + +
Let's use predefined entites & < > + Let's use a DTD defined entity &bent; + + diff --git a/fuzz/seed_corpus/949dbbf408f355b6b930966198039573adf116b3 b/fuzz/seed_corpus/949dbbf408f355b6b930966198039573adf116b3 new file mode 100644 index 000000000000..1ab9baba0221 --- /dev/null +++ b/fuzz/seed_corpus/949dbbf408f355b6b930966198039573adf116b3 @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/94e17da53e77c29e161281f54475026bb5a11569 b/fuzz/seed_corpus/94e17da53e77c29e161281f54475026bb5a11569 new file mode 100644 index 000000000000..710d51c9d7e8 --- /dev/null +++ b/fuzz/seed_corpus/94e17da53e77c29e161281f54475026bb5a11569 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/94eff61344efe569152a192f5dd15b5576fdb3c7 b/fuzz/seed_corpus/94eff61344efe569152a192f5dd15b5576fdb3c7 new file mode 100644 index 000000000000..5641ecdb9cfe --- /dev/null +++ b/fuzz/seed_corpus/94eff61344efe569152a192f5dd15b5576fdb3c7 @@ -0,0 +1,10 @@ + + + + O.K. + Some AAA are missing + Some BBB are missing + + + + diff --git a/fuzz/seed_corpus/9524f282b0bb308fb1e9eaf213956edaf2ce0b33 b/fuzz/seed_corpus/9524f282b0bb308fb1e9eaf213956edaf2ce0b33 new file mode 100644 index 000000000000..ec8dc438b24a --- /dev/null +++ b/fuzz/seed_corpus/9524f282b0bb308fb1e9eaf213956edaf2ce0b33 @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/958a39844e0cbefb774f1971230f717a1ba3cf9a b/fuzz/seed_corpus/958a39844e0cbefb774f1971230f717a1ba3cf9a new file mode 100644 index 000000000000..783fac57320a --- /dev/null +++ b/fuzz/seed_corpus/958a39844e0cbefb774f1971230f717a1ba3cf9a @@ -0,0 +1,15 @@ + + + + BBB element is not present + CCC element is not present + + + + + BBB element is not present + CCC element is not present + There is an extra element + + + diff --git a/fuzz/seed_corpus/9592d346a3cf7521e067d8fb016300cae1d99f5e b/fuzz/seed_corpus/9592d346a3cf7521e067d8fb016300cae1d99f5e new file mode 100644 index 000000000000..4b00da4e1350 --- /dev/null +++ b/fuzz/seed_corpus/9592d346a3cf7521e067d8fb016300cae1d99f5e @@ -0,0 +1,4 @@ + + + http://www.ics.uci.edu/~ejw/contact.html + diff --git a/fuzz/seed_corpus/96b764d23faf6202f259ede9a3a3cc360a3f513d b/fuzz/seed_corpus/96b764d23faf6202f259ede9a3a3cc360a3f513d new file mode 100644 index 000000000000..546904fbbd1f --- /dev/null +++ b/fuzz/seed_corpus/96b764d23faf6202f259ede9a3a3cc360a3f513d @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/96ba2f1e1c31550146f4f395f07f6351ed78ca3c b/fuzz/seed_corpus/96ba2f1e1c31550146f4f395f07f6351ed78ca3c new file mode 100644 index 000000000000..3d0de249bae2 --- /dev/null +++ b/fuzz/seed_corpus/96ba2f1e1c31550146f4f395f07f6351ed78ca3c @@ -0,0 +1,22 @@ + + + + http://www.microsoft.com/user/yarong/dav_drafts/ + + + + + + + HTTP 1.1 200 OK + + + + http://www.microsoft.com/user/yarong/dav_drafts/base + + + + + HTTP 1.1 200 OK + + diff --git a/fuzz/seed_corpus/96d61008474b512bbd5508ea4d9e13fcb13ed4e4 b/fuzz/seed_corpus/96d61008474b512bbd5508ea4d9e13fcb13ed4e4 new file mode 100644 index 000000000000..e5ec7d75de92 --- /dev/null +++ b/fuzz/seed_corpus/96d61008474b512bbd5508ea4d9e13fcb13ed4e4 @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/9722173218adf17b18b5e55fbe9664fae1160541 b/fuzz/seed_corpus/9722173218adf17b18b5e55fbe9664fae1160541 new file mode 100644 index 000000000000..a9285acca2b2 --- /dev/null +++ b/fuzz/seed_corpus/9722173218adf17b18b5e55fbe9664fae1160541 @@ -0,0 +1,3 @@ + + diff --git a/fuzz/seed_corpus/98388026d03211bd53544270577d912c94deba19 b/fuzz/seed_corpus/98388026d03211bd53544270577d912c94deba19 new file mode 100644 index 000000000000..19194aaa3c51 --- /dev/null +++ b/fuzz/seed_corpus/98388026d03211bd53544270577d912c94deba19 @@ -0,0 +1,529 @@ + + + +]> + + + + + + + +
+ XML Linking Language (XLink) + Version 1.0 + WD-xlink-19990527 + World Wide Web Consortium Working Draft + 29May1999 + +

This draft is for public discussion.

+
+ http://www.w3.org/XML/Group/1999/05/WD-xlink-current + + + http://www.w3.org/XML/Group/1999/05/WD-xlink-19990527 + http://www.w3.org/XML/Group/1999/05/WD-xlink-19990505 + http://www.w3.org/TR/1998/WD-xlink-19980303 + http://www.w3.org/TR/WD-xml-link-970630 + + + + + + Steve DeRose + Inso Corp. and Brown University + Steven_DeRose@Brown.edu + + + David Orchard + IBM Corp. + dorchard@ca.ibm.com + + + Ben Trafford + Invited Expert + bent@exemplary.net + + + + + +

This is a W3C Working Draft for review by W3C members and other interested parties. It is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". A list of current W3C working drafts can be found at http://www.w3.org/TR.

+

Note: Since working drafts are subject to frequent change, you are advised to reference the above URI, rather than the URIs for working drafts themselves. Some of the work remaining is described in .

+

This work is part of the W3C XML Activity (for current status, see http://www.w3.org/XML/Activity ). For information about the XPointer language which is expected to be used with XLink, see http://www.w3.org/TR/WD-xptr. +

+

See http://www.w3.org/TR/NOTE-xlink-principles for additional background on the design principles informing XLink.

+

Also see http://www.w3.org/TR/NOTE-xlink-req/ for the XLink requirements that this document attempts to satisfy.

+
+ + + +

This specification defines constructs that may be inserted into XML DTDs, schemas and document instances to describe links between objects. It uses XML syntax to create structures that can describe the simple unidirectional hyperlinks of today's HTML as well as more sophisticated links.

+
+ + +

Burlington, Seekonk, et al.: World-Wide Web Consortium, XML Working Group, 1998.

+
+ + +

Created in electronic form.

+
+ + + English + Extended Backus-Naur Form (formal grammar) + + + + + 1997-01-15 : Skeleton draft by TB + 1997-01-24 : Fleshed out by sjd + 1997-04-08 : Substantive draft + 1997-06-30 : Public draft + 1997-08-01 : Public draft + 1997-08-05 : Prose/organization work by sjd + 1997-10-14: Conformance and design principles; a bit of cleanup by elm + 1997-11-07: Update for editorial issues per issues doc, by sjd. + 1997-12-01: Update for editorial issues per issues doc in preparation for F2F meeting, by sjd. + 1998-01-13: Editorial cleanup, addition of new design principles, by elm. + 1998-02-27: Splitting out of XLink and XPointer, by elm. + 1998-03-03: Moved most of the XPointer locator stuff here. elm + 1999-04-24: Editorial rewrites to represent new ideas on XLink, especially the inclusion of arcs. bent + 1999-05-05: Prose/organization work by dorchard. Moved much of the semantics section around, from: locators, link semantics, remote resource semantics, local resource semantics; to: resource semantics, locators, behavior semantics, link semantics, arc semantics + 1999-05-12: Prose/organization work. Re-organized some of the sections, removed XML constructs from the document, added descriptive prose, edited document text for clarity. Rewrote the link recognition section. bent + 1999-05-17: Further prose work. Added non-normative examples. Clarified arcs. bent + 1999-05-23: Edited for grammar and clarity. bent + 1999-05-27: Final once-over before sending to group. Fixed sjd's email address. bent + + +
+ + + + Introduction +

This specification defines constructs that may be inserted into XML DTDs, schemas, and document instances to describe links between objects. A link, as the term is used here, is an explicit relationship between two or more data objects or portions of data objects. This specification is concerned with the syntax used to assert link existence and describe link characteristics. Implicit (unasserted) relationships, for example that of one word to the next or that of a word in a text to its entry in an on-line dictionary are obviously important, but outside its scope.

+

Links are asserted by elements contained in XML document instances. The simplest case is very like an HTML A link, and has these characteristics: + +

The link is expressed at one of its ends (similar to the A element in some document)

+

Users can only initiate travel from that end to the other

+

The link's effect on windows, frames, go-back lists, stylesheets in use, and so on is mainly determined by browsers, not by the link itself. For example, traveral of A links normally replaces the current view, perhaps with a user option to open a new window.

+

The link goes to only one destination (although a server may have great freedom in finding or dynamically creating that destination).

+ +

+

While this set of characteristics is already very powerful and obviously has proven itself highly useful and effective, each of these assumptions also limits the range of hypertext functionality. The linking model defined here provides ways to create links that go beyond each of these specific characteristics, thus providing features previously available mostly in dedicated hypermedia systems. +

+ + + Origin and Goals +

Following is a summary of the design principles governing XLink: + +

XLink must be straightforwardly usable over the Internet.

+

XLink must be usable by a wide variety of link usage domains and classes of linking application software.

+

XLink must support HTML 4.0 linking constructs.

+

The XLink expression language must be XML.

+

The XLink design must be formal, concise, and illustrative.

+

XLinks must be human-readable and human-writable.

+

XLinks may reside within or outside the documents in which the + participating resources reside.

+

XLink must represent the abstract structure and significance of links.

+

XLink must be feasible to implement.

+

XLink must be informed by knowledge of established hypermedia systems and standards.

+ +

+
+ + + + Relationship to Existing Standards +

Three standards have been especially influential: + +

HTML: Defines several SGML element types that represent links.

+

HyTime: Defines inline and out-of-line link structures and some semantic features, including traversal control and presentation of objects. +

+

Text Encoding Initiative Guidelines (TEI P3): Provides structures for creating links, aggregate objects, and link collections out of them.

+ +

+

Many other linking systems have also informed this design, especially Dexter, FRESS, MicroCosm, and InterMedia.

+
+ + + Terminology +

The following basic terms apply in this document. + + + +

A symbolic representation of traversal behavior in links, especially the direction, context and timing of traversal.

+ + + +

A representation of the relevant structure specified by the tags and attributes in an XML document, based on "groves" as defined in the ISO DSSSL standard.

+
+ + +

Abstractly, a link which serves as one of its own resources. Concretely, a link where the content of the linking element serves as a participating resource. + HTML A, HyTime clink, and TEI XREF + are all inline links.

+
+ + +

An explicit relationship between two or more data objects or portions of data objects.

+
+ + +

An element that asserts the existence and describes the characteristics of a link.

+
+ + +

The content of an inlinelinking element. Note that the content of the linking element could be explicitly pointed to by means of a regular locator in the same linking element, in which case the resource is considered remote, not local.

+
+ + +

Data, provided as part of a link, which identifies a + resource.

+
+ + +

A link whose traversal can be initiated from more than one of its participating resources. Note that being able to "go back" after following a one-directional link does not make the link multidirectional.

+
+ + +

A link whose content does not serve as one of the link's participating resources . Such links presuppose a notion like extended link groups, which instruct application software where to look for links. Out-of-line links are generally required for supporting multidirectional traversal and for allowing read-only resources to have outgoing links.

+
+ +

In the context of link behavior, a parsed link is any link whose content is transcluded into the document where the link originated. The use of the term "parsed" directly refers to the concept in XML of a + parsed entity.

+
+ + +

A resource that belongs to a link. All resources are potential contributors to a link; participating resources are the actual contributors to a particular link.

+
+ + +

Any participating resource of a link that is pointed to with a locator.

+
+ + +

In the abstract sense, an addressable unit of information or service that is participating in a link. Examples include files, images, documents, programs, and query results. Concretely, anything reachable by the use of a locator in some linking element. Note that this term and its definition are taken from the basic specifications governing the World Wide Web. +

+
+ + +

A portion of a resource, pointed to as the precise destination of a link. As one example, a link might specify that an entire document be retrieved and displayed, but that some specific part(s) of it is the specific linked data, to be treated in an application-appropriate manner such as indication by highlighting, scrolling, etc.

+
+ + +

The action of using a link; that is, of accessing a resource. Traversal may be initiated by a user action (for example, clicking on the displayed content of a linking element) or occur under program control.

+
+ +

+
+ + + Notation +

The formal grammar for locators is given using a simple Extended Backus-Naur Form (EBNF) location, as described in the XML specification.

+ +
+
+ + + Locator Syntax +

The locator for a resource is typically provided by means of a Uniform Resource Identifier, or URI. XPointers can be used in conjunction with the URI structure, as fragment identifiers, to specify a more precise sub-resource.

+ +

A locator generally contains a URI, as described in IETF RFCs and . As these RFCs state, the URI may include a trailing query (marked by a leading "?"), and be followed by a "#" and a fragment identifier, with the query interpreted by the host providing the indicated resource, and the interpretation of the fragment identifier dependent on the data type of the indicated resource.

+ +

In order to locate XML documents and portions of documents, a locator value may contain either a URI or a fragment identifier, or both. Any fragment identifier for pointing into XML must be an XPointer.

+

Special syntax may be used to request the use of particular processing models in accessing the locator's resource. This is designed to reflect the realities of network operation, where it may or may not be desirable to exercise fine control over the distribution of work between local and remote processors. + + Locator + + Locator + URI + | Connector (XPointer | Name) + | URI Connector (XPointer | Name) + + + Connector'#' | '|' + + + URIURIchar* + + +

+

In this discussion, the term designated resource refers to the resource which an entire locator serves to locate. The following rules apply: + + +

The URI, if provided, locates a resource called the containing resource.

+ + +

If the URI is not provided, the containing resource is considered to be the document in which the linking element is contained. +

+ +

If an XPointer is provided, the designated resource is a sub-resource + of the containing resource; otherwise the designated resource is the + containing resource.

+
+ + +

If the Connector is followed directly by a Name, the Name is shorthand for the XPointer"id(Name)"; that is, the sub-resource is the element in the containing resource that has an XML ID attribute whose value matches the Name. This shorthand is to encourage use of the robust id addressing mode.

+
+ + +

If the connector is "#", this signals an intent that the containing resource is to be fetched as a whole from the host that provides it, and that the XPointer processing to extract the sub-resource + is to be performed on the client, that is to say on the same system where the linking element is recognized and processed.

+
+ +

If the connector is "|", no intent is signaled as to what processing model is to be used to go about accessing the designated resource.

+
+ +

+

Note that the definition of a URI includes an optional query component.

+

In the case where the URI contains a query (to be interpreted by the server), information providers and authors of server software are urged to use queries as follows: + + Query + + Query'XML-XPTR=' ( XPointer | Name) + + +

+ +
+ + + Link Recognition +

The existence of a link is asserted by a linking element. Linking elements must be recognized reliably by application software in order to provide appropriate display and behavior. There are several ways link recognition could be accomplished: for example, reserving element type names, reserving attributes names, leaving the matter of recognition entirely up to stylesheets and application software, or using the XLink namespace to specify element names and attribute names that would be recognized by namespace and XLink-aware processors. Using element and attribute names within the XLink namespace provides a balance between giving users control of their own markup language design and keeping the identification of linking elements simple and unambiguous.

+

The two approaches to identifying linking elements are relatively simple to implement. For example, here's how the HTML A element would be declared using attributes within the XLink namespace, and then how an element within the XLink namespace might do the same: + <A xlink:type="simple" xlink:href="http://www.w3.org/TR/wd-xlink/" +xlink:title="The Xlink Working Draft">The XLink Working Draft.</A> + <xlink:simple href="http://www.w3.org/TR/wd-xlink/" +title="The XLink Working Draft">The XLink Working Draft</xlink:simple> + Any arbitrary element can be made into an XLink by using the xlink:type attribute. And, of course, the explicit XLink elements may be used, as well. This document will go on to describe the linking attributes that are associated with linking elements. It may be assumed by the reader that these attributes would require the xlink namespace prefix if they existed within an arbitrary element, or that they may be used directly if they exist within an explicit Xlink element.

+ +
+ + + + Linking Attributes +

XLink has several attributes associated with the variety of links it may represent. These attributes define four main concepts: locators, arcs, behaviors, and semantics. Locators define where the actual resource is located. Arcs define the traversal of links. Where does the link come from? Where does it go to? All this information can be stored in the arc attributes. Behaviors define how the link is activated, and what the application should do with the resource being linked to. Semantics define useful information that the application may use, and enables the link for such specalized targets as constricted devices and accessibility software.

+ + + Locator Attributes +

The only locator attribute at this time is href. This attribute must contain either a string in the form of a URI that defines the remote resource being linked to, a string containing a fragment identifier that links to a local resource, or a string containing a URI with a fragment identifier concacenated onto it.

+
+ + + Arc Attributes +

Arcs contain two attributes, from and to. The from attribute may contain a string containing the content of a role attribute from the resource being linked from. The purpose of the from attribute is to define where this link is being actuated from.

+

The to attribute may contain a string containing the content of a role attribute from the resource being linked to. The purpose of the to attribute is to define where this link traverses to.

+

The application may use this information in a number of ways, especially in a complex hypertext system, but it is mainly useful in providing context for application behavior.

+ +
+ + + Behavior Attributes +

There are two attributes associated with behavior: show and actuate. The show attribute defines how the remote resource is to be revealed to the user. It has three options: new, parsed, and replace. The new option indicates that the remote resource should be shown in a new window (or other device context) without replacing the previous content. The parsed option, relating directly to the XML concept of a parsed entity, indicates that the content should be integrated into the document from which the link was actuated. The replace option is the one most commonly seen on the World Wide Web, where the document being linked from is entirely replaced by the object being linked to.

+

The actuate attribute defines how the link is initiated. It has two options: user and auto. The user option indicates that the link must be initiated by some sort of human-initiated selection, such as clicking on an HTML anchor. The auto option indicates that the link is automatically initiated when the application deems that the user has reached the link. It then follows the behavior set out in the show option.

+ +
+ + + Semantic Attributes +

There are two attributes associated with semantics, role and title. The role attribute is a generic string used to describe the function of the link's content. For example, a poem might have a link with a role="stanza". The role is also used as an identifier for the from and to attributes of arcs.

+

The title attribute is designed to provide human-readable text describing the link. It is very useful for those who have text-based applications, whether that be due to a constricted device that cannot display the link's content, or if it's being read by an application to a visually-impaired user, or if it's being used to create a table of links. The title attribute contains a simple, descriptive string.

+
+
+ + + Linking Elements +

There are several kinds of linking elements in XLink: simple links, locators, arcs, and extended links. These elements may be instantiated via element declarations from the XLink namespace, or they may be instantiated via attribute declarations from the XLink namespace. Both kinds of instantiation are described in the definition of each linking element.

+

The simple link is used to declare a link that approximates the functionality of the HTML A element. It has, however, a few added features to increase its value, including the potential declaration of semantics and behavior. The locator elements are used to define the resource being linked to. Some links may contain multiple locators, representing a choice of potential links to be traversed. The arcs are used to define the traversal semantics of the link. Finally, an extended linking element differs from a simple link in that it can connect any number of resources, not just one local resource (optionally) and one remote resource, and in that extended links are more often out-of-line than simple links.

+ + + Simple Links + +

The following are two examples of linking elements, each showing all the possible attributes that can be associated with a simple link. Here is the explicit XLink simple linking element. + <!ELEMENT xlink:simple ANY> +<!ATTLIST xlink:slink + href CDATA #REQUIRED + role CDATA #IMPLIED + title CDATA #IMPLIED + show (new|parsed|replace) "replace" + actuate (user|auto) "user" +> + And here is how to make an arbitrary element into a simple link. + <!ELEMENT xlink:simple ANY> +<!ATTLIST foo + xlink:type (simple|extended|locator|arc) #FIXED "simple" + xlink:href CDATA #REQUIRED + xlink:role CDATA #IMPLIED + xlink:title CDATA #IMPLIED + xlink:show (new|parsed|replace) "replace" + xlink:actuate (user|auto) "user" +> + Here is how the first example might look in a document: +<xlink:simple href="http://www.w3.org/TR/wd-xlink" role="working draft" + title="The XLink Working Draft" show="replace" actuate="user"> +The XLink Working Draft.</xlink:simple> +<foo xlink:href="http://www.w3.org/TR/wd-xlink" xlink:role="working draft" + xlink:title="The XLink Working Draft" xlink:show="new" xlink:actuate="user"> +The XLink Working Draft.</foo> + Alternately, a simple link could be as terse as this: +<foo xlink:href="#stanza1">The First Stanza.</foo> +

+

+ There are no constraints on the contents of a simple linking element. In + the sample declaration above, it is given a content model of ANY + to illustrate that any content model or declared content is acceptable. In + a valid document, every element that is significant to XLink must still conform + to the constraints expressed in its governing DTD.

+

Note that it is meaningful to have an out-of-line simple link, although + such links are uncommon. They are called "one-ended" and are typically used + to associate discrete semantic properties with locations. The properties might + be expressed by attributes on the link, the link's element type name, or in + some other way, and are not considered full-fledged resources of the link. + Most out-of-line links are extended links, as these have a far wider range + of uses.

+
+ + +Extended Links +

An extended link differs from a simple link in that it can connect any number of resources, not just one local resource (optionally) and one remote resource, and in that extended links are more often out-of-line than simple links.

+

These additional capabilities of extended links are required for: + + +

Enabling outgoing links in documents that cannot be modified to add an inline link

+ + +

Creating links to and from resources in formats with no native support for embedded links (such as most multimedia formats)

+
+ +

Applying and filtering sets of relevant links on demand

+
+

Enabling other advanced hypermedia capabilities

+ +

+

Application software might be expected to provide traversal among all of a link's participating resources (subject to semantic constraints outside the scope of this specification) and to signal the fact that a given resource or sub-resource participates in one or more links when it is displayed (even though there is no markup at exactly that point to signal it).

+

A linking element for an extended link contains a series of child elements that serve as locators and arcs. Because an extended link can have more than one remote resource, it separates out linking itself from the mechanisms used to locate each resource (whereas a simple link combines the two).

+

The xlink:type attribute value for an extended link must be extended, if the link is being instantiated on an arbitrary element. Note that extended links introduce variants of the show and actuate behavior attributes. These attributes, the showdefault and actuatedefault define the same behavior as their counterparts. However, in this case, they are considered to define the default behavior for all the linking elements that they contain.

+

However, when a linking element within an extended link has a show or actuate attribute of its own, that attribute overrides the defaults set on the extended linking element.

+

The extended linking element itself retains those attributes relevant to the link as a whole, and to its local resource if any. Following are two sample declaration for an extended link. The first is an example of the explicit XLink extended link: + +<!ELEMENT xlink:extended ((xlink:arc | xlink:locator)*)> +<!ATTLIST xlink:extended + role CDATA #IMPLIED + title CDATA #IMPLIED + showdefault (new|parsed|replace) #IMPLIED + actuatedefault (user|auto) #IMPLIED > + + The second is an example of an arbitrary element being used an extended link: + +<!ELEMENT foo ((xlink:arc | xlink:locator)*)> +<!ATTLIST foo + xlink:type (simple|extended|locator|arc) #FIXED "extended" + xlink:role CDATA #IMPLIED + xlink:title CDATA #IMPLIED + xlink:showdefault (new|parsed|replace) #IMPLIED + xlink:actuatedefault (user|auto) #IMPLIED > + + The following two examples demonstrate how each of the above might appear within a document instance. Note that the content of these examples would be other elements. For brevity's sake, they've been left blank. The first example shows how the link might appear, using an explicit XLink extended link: + +<xlink:extended role="address book" title="Ben's Address Book" showdefault="replace" actuatedefault="user"> ... </xlink:extended> + + And the second shows how the link might appear, using an arbitrary element: + +<foo xlink:type="extended" xlink:role="address book" xlink:title="Ben's Address Book" xlink:showdefault="replace" xlink:actuatedefault="user"> ... </foo> +

+ +
+ + + Arc Elements +

An arc is contained within an extended link for the purpose of defining traversal behavior. More than one arc may be associated with a link. Otherwise, arc elements function exactly as the arc attributes might lead on to expect.

+ +
+ +
+ +Conformance +

An element conforms to XLink if: +

The element has an xml:link attribute whose value is +one of the attribute values prescribed by this specification, and

+

the element and all of its attributes and content adhere to the +syntactic +requirements imposed by the chosen xml:link attribute value, +as prescribed in this specification.

+

+

Note that conformance is assessed at the level of individual elements, +rather than whole XML documents, because XLink and non-XLink linking mechanisms +may be used side by side in any one document.

+

An application conforms to XLink if it interprets XLink-conforming elements +according to all required semantics prescribed by this specification and, +for any optional semantics it chooses to support, supports them in the way +prescribed.

+
+ + +Unfinished Work + +Structured Titles +

The simple title mechanism described in this draft is insufficient to cope +with internationalization or the use of multimedia in link titles. A future +version will provide a mechanism for the use of structured link titles.

+
+
+ +References + +Eve Maler and Steve DeRose, editors. +XML Pointer Language (XPointer) V1.0. ArborText, Inso, and Brown +University. Burlington, Seekonk, et al.: World Wide Web Consortium, 1998. +(See http://www.w3.org/TR/WD-xptr + .) +ISO (International Organization for +Standardization). ISO/IEC 10744-1992 (E). Information technology +- Hypermedia/Time-based Structuring Language (HyTime). [Geneva]: +International Organization for Standardization, 1992. Extended +Facilities +Annex. [Geneva]: International Organization for Standardization, +1996. (See http://www.ornl.go +v/sgml/wg8/hytime/html/is10744r.html ). +IETF (Internet Engineering Task +Force). +RFC 1738: Uniform Resource Locators. 1991. (See +http://www.w3.org/Addressing/rfc1738.txt). +IETF (Internet Engineering Task +Force). +RFC 1808: Relative Uniform Resource Locators. 1995. (See http://www.w3.org/Addressing/rfc +1808.txt ). +C. M. Sperberg-McQueen and Lou Burnard, editors. + +Guidelines for Electronic Text Encoding and Interchange. Association +for Computers and the Humanities (ACH), Association for Computational +Linguistics +(ACL), and Association for Literary and Linguistic Computing (ALLC). Chicago, +Oxford: Text Encoding Initiative, 1994. +]Steven J. DeRose and David G. Durand. 1995. "The +TEI Hypertext Guidelines." In Computing and the Humanities +29(3). +Reprinted in Text Encoding Initiative: Background and +Context, +ed. Nancy Ide and Jean ronis , ISBN 0-7923-3704-2. + +
+ diff --git a/fuzz/seed_corpus/985fbaac3b6d3528467187f08fd8f18fb49aaf7b b/fuzz/seed_corpus/985fbaac3b6d3528467187f08fd8f18fb49aaf7b new file mode 100644 index 000000000000..f55ccdce45d5 --- /dev/null +++ b/fuzz/seed_corpus/985fbaac3b6d3528467187f08fd8f18fb49aaf7b @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/98a842537cd90630cb5cf8c257ad890f5d03a8fc b/fuzz/seed_corpus/98a842537cd90630cb5cf8c257ad890f5d03a8fc new file mode 100644 index 000000000000..97aeb147f263 --- /dev/null +++ b/fuzz/seed_corpus/98a842537cd90630cb5cf8c257ad890f5d03a8fc @@ -0,0 +1,5 @@ +

+a&b +a&b +a & b +

diff --git a/fuzz/seed_corpus/98f3b9397b1eaa11e72fd584c6af99cfc2283d2f b/fuzz/seed_corpus/98f3b9397b1eaa11e72fd584c6af99cfc2283d2f new file mode 100644 index 000000000000..ec4a9525d8e6 --- /dev/null +++ b/fuzz/seed_corpus/98f3b9397b1eaa11e72fd584c6af99cfc2283d2f @@ -0,0 +1,16 @@ + + + + http://www.foo.bar/container/resource1 + http://www.foo.bar/container/resource2 + HTTP/1.1 200 OK + + + http://www.foo.bar/container/ + HTTP/1.1 420 Method Failure + + + http://www.foo.bar/container/resource3 + HTTP/1.1 412 Precondition Failed + + diff --git a/fuzz/seed_corpus/98fbfa6c62c30329c879684800e4ba7a7adf6fb2 b/fuzz/seed_corpus/98fbfa6c62c30329c879684800e4ba7a7adf6fb2 new file mode 100644 index 000000000000..503a0435d917 --- /dev/null +++ b/fuzz/seed_corpus/98fbfa6c62c30329c879684800e4ba7a7adf6fb2 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/99047872cfd306a40075a79e7f142c48de9dd085 b/fuzz/seed_corpus/99047872cfd306a40075a79e7f142c48de9dd085 new file mode 100644 index 000000000000..495968e8a594 --- /dev/null +++ b/fuzz/seed_corpus/99047872cfd306a40075a79e7f142c48de9dd085 @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/9906041487a221ef5aaae6b3136079f257eaa279 b/fuzz/seed_corpus/9906041487a221ef5aaae6b3136079f257eaa279 new file mode 100644 index 000000000000..c4acce602dba --- /dev/null +++ b/fuzz/seed_corpus/9906041487a221ef5aaae6b3136079f257eaa279 @@ -0,0 +1,33 @@ + + + + + 0836217462 + Being a Dog Is a Full-Time Job + + Charles M Schulz + 1922-11-26 + 2000-02-12 + + + Peppermint Patty + 1966-08-22 + bold, brash and tomboyish + + + Snoopy + 1950-10-04 + extroverted beagle + + + Schroeder + 2000-01-20Z + brought classical music to the Peanuts strip + + + Lucy + 1952-03-03 + bossy, crabby and selfish + + + diff --git a/fuzz/seed_corpus/99461fa0587d9c1dcc9bfaecbcb50d90d0f9fc9e b/fuzz/seed_corpus/99461fa0587d9c1dcc9bfaecbcb50d90d0f9fc9e new file mode 100644 index 000000000000..ed0087b71786 --- /dev/null +++ b/fuzz/seed_corpus/99461fa0587d9c1dcc9bfaecbcb50d90d0f9fc9e @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/99e01d1fc129fb19ef635abcc6651e66a47824c0 b/fuzz/seed_corpus/99e01d1fc129fb19ef635abcc6651e66a47824c0 new file mode 100644 index 000000000000..e8edb92f5aa3 --- /dev/null +++ b/fuzz/seed_corpus/99e01d1fc129fb19ef635abcc6651e66a47824c0 @@ -0,0 +1,11 @@ + + +
+ + + + + +
+
+
diff --git a/fuzz/seed_corpus/9a084e7bdaf5ada2b6fab19bc3f39f7a00d40cd7 b/fuzz/seed_corpus/9a084e7bdaf5ada2b6fab19bc3f39f7a00d40cd7 new file mode 100644 index 000000000000..197b002ae8ff --- /dev/null +++ b/fuzz/seed_corpus/9a084e7bdaf5ada2b6fab19bc3f39f7a00d40cd7 @@ -0,0 +1,9 @@ + +Script tests + + + + + diff --git a/fuzz/seed_corpus/9a2e82d3a88590acfabb0a4b802e95e0122ed7af b/fuzz/seed_corpus/9a2e82d3a88590acfabb0a4b802e95e0122ed7af new file mode 100644 index 000000000000..9b1b3c2478c4 --- /dev/null +++ b/fuzz/seed_corpus/9a2e82d3a88590acfabb0a4b802e95e0122ed7af @@ -0,0 +1 @@ +&:ê diff --git a/fuzz/seed_corpus/9a41829154ea33050146281db0b71487f6752a89 b/fuzz/seed_corpus/9a41829154ea33050146281db0b71487f6752a89 new file mode 100644 index 000000000000..41348b137b5c --- /dev/null +++ b/fuzz/seed_corpus/9a41829154ea33050146281db0b71487f6752a89 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/9aa02917d7765db4c8f9ec2cfbc83488dad5f3d7 b/fuzz/seed_corpus/9aa02917d7765db4c8f9ec2cfbc83488dad5f3d7 new file mode 100644 index 000000000000..7b4095995587 --- /dev/null +++ b/fuzz/seed_corpus/9aa02917d7765db4c8f9ec2cfbc83488dad5f3d7 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/9aabee56f9cc56c02fe2519b37952ed00ea909d6 b/fuzz/seed_corpus/9aabee56f9cc56c02fe2519b37952ed00ea909d6 new file mode 100644 index 000000000000..f1999f80cc18 --- /dev/null +++ b/fuzz/seed_corpus/9aabee56f9cc56c02fe2519b37952ed00ea909d6 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/9b4ccde252cfe3ed8ff6b03d3f225d0541cb2211 b/fuzz/seed_corpus/9b4ccde252cfe3ed8ff6b03d3f225d0541cb2211 new file mode 100644 index 000000000000..07e4c54b63b5 --- /dev/null +++ b/fuzz/seed_corpus/9b4ccde252cfe3ed8ff6b03d3f225d0541cb2211 @@ -0,0 +1,5 @@ + + +]> +&c; diff --git a/fuzz/seed_corpus/9b6d872506e2d8e85c3cfd499375946e11c675a7 b/fuzz/seed_corpus/9b6d872506e2d8e85c3cfd499375946e11c675a7 new file mode 100644 index 000000000000..9ec70b17bc57 --- /dev/null +++ b/fuzz/seed_corpus/9b6d872506e2d8e85c3cfd499375946e11c675a7 @@ -0,0 +1,16 @@ + + + +]> + + + + + +&a; should appear after colon: &a; +&b; should appear after colon: &a; +&a; should appear after colon: &b; +&b; should appear after colon: &b; + + diff --git a/fuzz/seed_corpus/9b75744b5800f2b02356669863eb7b3bb18a5e10 b/fuzz/seed_corpus/9b75744b5800f2b02356669863eb7b3bb18a5e10 new file mode 100644 index 000000000000..a1c71d2b52b2 --- /dev/null +++ b/fuzz/seed_corpus/9b75744b5800f2b02356669863eb7b3bb18a5e10 @@ -0,0 +1,8 @@ + + + + + + + diff --git a/fuzz/seed_corpus/9bc90f962db634de77a1c130aab3dcaefe9567a6 b/fuzz/seed_corpus/9bc90f962db634de77a1c130aab3dcaefe9567a6 new file mode 100644 index 000000000000..0a8cd3f28f71 --- /dev/null +++ b/fuzz/seed_corpus/9bc90f962db634de77a1c130aab3dcaefe9567a6 @@ -0,0 +1 @@ +25 diff --git a/fuzz/seed_corpus/9c337669960abecc2c6b681f1c12cfc457030f59 b/fuzz/seed_corpus/9c337669960abecc2c6b681f1c12cfc457030f59 new file mode 100644 index 000000000000..62da9e4c5ec4 --- /dev/null +++ b/fuzz/seed_corpus/9c337669960abecc2c6b681f1c12cfc457030f59 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/9ca88b6c982c8702def62862162f877e40c71dbc b/fuzz/seed_corpus/9ca88b6c982c8702def62862162f877e40c71dbc new file mode 100644 index 000000000000..62716a2e1bfb --- /dev/null +++ b/fuzz/seed_corpus/9ca88b6c982c8702def62862162f877e40c71dbc @@ -0,0 +1,28 @@ + + + + + + + + + An double-headed arrow example using markers + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/9cd20220c5e2e9140edf30960fbfe7ce6305d445 b/fuzz/seed_corpus/9cd20220c5e2e9140edf30960fbfe7ce6305d445 new file mode 100644 index 000000000000..ddc7af20a594 --- /dev/null +++ b/fuzz/seed_corpus/9cd20220c5e2e9140edf30960fbfe7ce6305d445 @@ -0,0 +1 @@ +

abcdefg

diff --git a/fuzz/seed_corpus/9cecdfd2a3cdbd835d1542703bfea2288d71d3be b/fuzz/seed_corpus/9cecdfd2a3cdbd835d1542703bfea2288d71d3be new file mode 100644 index 000000000000..dddde68bcf01 --- /dev/null +++ b/fuzz/seed_corpus/9cecdfd2a3cdbd835d1542703bfea2288d71d3be @@ -0,0 +1,2 @@ + +%ä%ent; diff --git a/fuzz/seed_corpus/9d249724eb4ac0bdf1691e81dc64f29ec0106f82 b/fuzz/seed_corpus/9d249724eb4ac0bdf1691e81dc64f29ec0106f82 new file mode 100644 index 000000000000..9b8616aa4147 --- /dev/null +++ b/fuzz/seed_corpus/9d249724eb4ac0bdf1691e81dc64f29ec0106f82 @@ -0,0 +1,4 @@ + + John Smithjs@example.com" + John Smith2js2@example.com" + diff --git a/fuzz/seed_corpus/9d67253f7b024d0c5ed12e62fb2f54d3223fd20b b/fuzz/seed_corpus/9d67253f7b024d0c5ed12e62fb2f54d3223fd20b new file mode 100644 index 000000000000..6038d7906e0d --- /dev/null +++ b/fuzz/seed_corpus/9d67253f7b024d0c5ed12e62fb2f54d3223fd20b @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/9d69c52c2b47d5ce898720d16cd59f73dce33554 b/fuzz/seed_corpus/9d69c52c2b47d5ce898720d16cd59f73dce33554 new file mode 100644 index 000000000000..13075ee2bd21 --- /dev/null +++ b/fuzz/seed_corpus/9d69c52c2b47d5ce898720d16cd59f73dce33554 @@ -0,0 +1,26 @@ + + + + Demonstration of coordinate transforms + + + This prints 12 pixels high. + This prints 12 pixels high. + + + + + + This prints 24 pixels high. + + + This prints 12 pixels high. + + + + diff --git a/fuzz/seed_corpus/9d6f91da6de2e2b45a597c6bc4642cbebd11d37a b/fuzz/seed_corpus/9d6f91da6de2e2b45a597c6bc4642cbebd11d37a new file mode 100644 index 000000000000..9e8e23630971 --- /dev/null +++ b/fuzz/seed_corpus/9d6f91da6de2e2b45a597c6bc4642cbebd11d37a @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/9dba6059f6f285ddf3e0b25ee6bc4a43b438cee8 b/fuzz/seed_corpus/9dba6059f6f285ddf3e0b25ee6bc4a43b438cee8 new file mode 100644 index 000000000000..dba26ca1619b --- /dev/null +++ b/fuzz/seed_corpus/9dba6059f6f285ddf3e0b25ee6bc4a43b438cee8 @@ -0,0 +1,7 @@ + +hmmm + + f f ff f + \ No newline at end of file diff --git a/fuzz/seed_corpus/9de04ffa9771c61b055b3a79ab8114e36c5bc852 b/fuzz/seed_corpus/9de04ffa9771c61b055b3a79ab8114e36c5bc852 new file mode 100644 index 000000000000..0d40d3c26a14 --- /dev/null +++ b/fuzz/seed_corpus/9de04ffa9771c61b055b3a79ab8114e36c5bc852 @@ -0,0 +1,2240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + changed + added + deleted + off + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BMP + CGM-CHAR + CGM-BINARY + CGM-CLEAR + DITROFF + DVI + EPS + EQN + FAX + GIF + GIF87a + GIF89a + JPG + JPEG + IGES + PCX + PIC + PNG + PS + SGML + TBL + TEX + TIFF + WMF + WPG + linespecific + + + + + + + + + + + + + + + + + + + + + + left + right + center + + + + + + + + + + + + 0 + 1 + + + + + + + + + click + double-click + press + seq + simul + other + + + + + + + + + + + + + + + + + + + + linespecific + + + + + + numbered + unnumbered + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + refentry + none + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + qanda + number + none + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + optional + required + + + + + + + + + + + + + + + + + + + + + + optional + required + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + sect1 + sect2 + sect3 + sect4 + sect5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + normal + compact + + + + + + + + + + + + + + + + + + + + + + + + + arabic + upperalpha + loweralpha + upperroman + lowerroman + + + + + + + inherit + ignore + + + + + + + continues + restarts + + + + + + + normal + compact + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inline + vert + horiz + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/9de0bf4e8e6d38de4a71975c776f35f5249d1320 b/fuzz/seed_corpus/9de0bf4e8e6d38de4a71975c776f35f5249d1320 new file mode 100644 index 000000000000..3bcc1010030e --- /dev/null +++ b/fuzz/seed_corpus/9de0bf4e8e6d38de4a71975c776f35f5249d1320 @@ -0,0 +1,4 @@ + +]> +This is a valid document ! diff --git a/fuzz/seed_corpus/9e0957ff11807ee924bb76fdadc2b01cad441b8d b/fuzz/seed_corpus/9e0957ff11807ee924bb76fdadc2b01cad441b8d new file mode 100644 index 000000000000..672a0f52da8f --- /dev/null +++ b/fuzz/seed_corpus/9e0957ff11807ee924bb76fdadc2b01cad441b8d @@ -0,0 +1,4 @@ + +]> +

diff --git a/fuzz/seed_corpus/9e11a5d29f5a4904ff2a26bfa874efec6ffc1225 b/fuzz/seed_corpus/9e11a5d29f5a4904ff2a26bfa874efec6ffc1225 new file mode 100644 index 000000000000..dbf9bd5c1aef --- /dev/null +++ b/fuzz/seed_corpus/9e11a5d29f5a4904ff2a26bfa874efec6ffc1225 @@ -0,0 +1 @@ +

diff --git a/fuzz/seed_corpus/9e335a49fead8a4176605ff6de99c5c7c094ed50 b/fuzz/seed_corpus/9e335a49fead8a4176605ff6de99c5c7c094ed50 new file mode 100644 index 000000000000..4ba332e4faaf --- /dev/null +++ b/fuzz/seed_corpus/9e335a49fead8a4176605ff6de99c5c7c094ed50 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/9e46cac97cd53b54068f8b61000d51beb98c1251 b/fuzz/seed_corpus/9e46cac97cd53b54068f8b61000d51beb98c1251 new file mode 100644 index 000000000000..78708e4d7cba --- /dev/null +++ b/fuzz/seed_corpus/9e46cac97cd53b54068f8b61000d51beb98c1251 @@ -0,0 +1,7 @@ + + + + Let's use a DTD defined entity &bent; + Let's use predefined entites & < > + + diff --git a/fuzz/seed_corpus/9e71d646d2f96560c894bb4f69595012b081cbcb b/fuzz/seed_corpus/9e71d646d2f96560c894bb4f69595012b081cbcb new file mode 100644 index 000000000000..aa01853212b9 --- /dev/null +++ b/fuzz/seed_corpus/9e71d646d2f96560c894bb4f69595012b081cbcb @@ -0,0 +1 @@ +5 diff --git a/fuzz/seed_corpus/9ee967dbb13315de75c9f1650293741282b1b8be b/fuzz/seed_corpus/9ee967dbb13315de75c9f1650293741282b1b8be new file mode 100644 index 000000000000..6e87cff16d71 --- /dev/null +++ b/fuzz/seed_corpus/9ee967dbb13315de75c9f1650293741282b1b8be @@ -0,0 +1,9 @@ + + + + + diff --git a/fuzz/seed_corpus/a05d91cbf0902b0fe341c979e9fc18fc69813f55 b/fuzz/seed_corpus/a05d91cbf0902b0fe341c979e9fc18fc69813f55 new file mode 100644 index 000000000000..f3f286eafc9c --- /dev/null +++ b/fuzz/seed_corpus/a05d91cbf0902b0fe341c979e9fc18fc69813f55 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/a09c49e53e2f72cfc69fe1535b75e398b9e2da0a b/fuzz/seed_corpus/a09c49e53e2f72cfc69fe1535b75e398b9e2da0a new file mode 100644 index 000000000000..e230c84b70ae --- /dev/null +++ b/fuzz/seed_corpus/a09c49e53e2f72cfc69fe1535b75e398b9e2da0a @@ -0,0 +1 @@ + + violates [ WFC: Unique Att Spec ] diff --git a/fuzz/seed_corpus/a12d2d35439a7b325daeae7dda813d8d9fd8ec9a b/fuzz/seed_corpus/a12d2d35439a7b325daeae7dda813d8d9fd8ec9a new file mode 100644 index 000000000000..ed450c7341d3 --- /dev/null +++ b/fuzz/seed_corpus/a12d2d35439a7b325daeae7dda813d8d9fd8ec9a @@ -0,0 +1,14 @@ + + + + + + +Hello, world! + + + + + + diff --git a/fuzz/seed_corpus/a15a2d4bda5afc0283b7922b22f9b2f81372b52f b/fuzz/seed_corpus/a15a2d4bda5afc0283b7922b22f9b2f81372b52f new file mode 100644 index 000000000000..83ba73e99ee5 --- /dev/null +++ b/fuzz/seed_corpus/a15a2d4bda5afc0283b7922b22f9b2f81372b52f @@ -0,0 +1,6 @@ + + x + + y + + diff --git a/fuzz/seed_corpus/a1a5c9bf5b4d3ea28f7aebe6a36ef925c8684e20 b/fuzz/seed_corpus/a1a5c9bf5b4d3ea28f7aebe6a36ef925c8684e20 new file mode 100644 index 000000000000..91264e4b55dc --- /dev/null +++ b/fuzz/seed_corpus/a1a5c9bf5b4d3ea28f7aebe6a36ef925c8684e20 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/a1c61928dc8532f92366646305c9d925515f5f4f b/fuzz/seed_corpus/a1c61928dc8532f92366646305c9d925515f5f4f new file mode 100644 index 000000000000..92604c8cc74a --- /dev/null +++ b/fuzz/seed_corpus/a1c61928dc8532f92366646305c9d925515f5f4f @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/a1dcdf33e4b1c0d3dca3b36163ab1a74492dfffd b/fuzz/seed_corpus/a1dcdf33e4b1c0d3dca3b36163ab1a74492dfffd new file mode 100644 index 000000000000..c785b1a62b29 --- /dev/null +++ b/fuzz/seed_corpus/a1dcdf33e4b1c0d3dca3b36163ab1a74492dfffd @@ -0,0 +1,39 @@ + + + + + Jan Novák + BÄ›lehradská 147 + Praha 2 + 12000 + + + Petra Nováková + Anglická 15 + Praha 2 + 12000 + + DPD + dobírka + 2004-11-14 + 2004-11-19 + + + 2N7-516 + SekaÄka na trávu + 1 + 2999 + http://example.org/sekacka.html + + + Q3Y-116 + Travní semeno + 2.5 + 127.50 + + + + <Řádka>O dodávku mám zájem pouze v případÄ›, že se jedná o trávu v odrůdÄ› konopí. + <Řádka>Dále jsem se chtÄ›l zeptat, zda je doprava zdarma. + + diff --git a/fuzz/seed_corpus/a217169ba383b0b37c6459e99f42351885a9cf9a b/fuzz/seed_corpus/a217169ba383b0b37c6459e99f42351885a9cf9a new file mode 100644 index 000000000000..677b03909818 --- /dev/null +++ b/fuzz/seed_corpus/a217169ba383b0b37c6459e99f42351885a9cf9a @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/a2a94f5d52603abb1ae457737e115edd8570e800 b/fuzz/seed_corpus/a2a94f5d52603abb1ae457737e115edd8570e800 new file mode 100644 index 000000000000..f831b4bbb746 --- /dev/null +++ b/fuzz/seed_corpus/a2a94f5d52603abb1ae457737e115edd8570e800 @@ -0,0 +1,24 @@ + + + + http://www.foo.bar/container/ + + + Box type A + + + Hadrian + + + HTTP 1.1 200 OK + + + http://www.foo.bar/container/index.html + + + Box type B + + + HTTP 1.1 200 OK + + diff --git a/fuzz/seed_corpus/a2b7cc8c6f518f6e0552c467cb215aaa2cb8c789 b/fuzz/seed_corpus/a2b7cc8c6f518f6e0552c467cb215aaa2cb8c789 new file mode 100644 index 000000000000..ecdd007f23ab --- /dev/null +++ b/fuzz/seed_corpus/a2b7cc8c6f518f6e0552c467cb215aaa2cb8c789 @@ -0,0 +1,10 @@ + + +Regression test 1 + + +

Regression test 1

+

+Ok file no problem + + diff --git a/fuzz/seed_corpus/a2ffb091ea66b2c5be67d36428c637fe70bb055b b/fuzz/seed_corpus/a2ffb091ea66b2c5be67d36428c637fe70bb055b new file mode 100644 index 000000000000..48c21b7affeb --- /dev/null +++ b/fuzz/seed_corpus/a2ffb091ea66b2c5be67d36428c637fe70bb055b @@ -0,0 +1 @@ +this is some text in ASCII diff --git a/fuzz/seed_corpus/a351e39e1c2534d882df78962d3f836451656a54 b/fuzz/seed_corpus/a351e39e1c2534d882df78962d3f836451656a54 new file mode 100644 index 000000000000..27fa60384282 --- /dev/null +++ b/fuzz/seed_corpus/a351e39e1c2534d882df78962d3f836451656a54 @@ -0,0 +1,3 @@ + + +&abc; diff --git a/fuzz/seed_corpus/a35deba5506c7fa4a0a540463f56237e0862c224 b/fuzz/seed_corpus/a35deba5506c7fa4a0a540463f56237e0862c224 new file mode 100644 index 000000000000..3fba13855558 --- /dev/null +++ b/fuzz/seed_corpus/a35deba5506c7fa4a0a540463f56237e0862c224 @@ -0,0 +1,9 @@ +]> + + First line Second line + 2 + "0" && value<"10" ?"valid":"error"]]> + valid + + + diff --git a/fuzz/seed_corpus/a397c927fcbce17d573ef6e6b51efda250fb2517 b/fuzz/seed_corpus/a397c927fcbce17d573ef6e6b51efda250fb2517 new file mode 100644 index 000000000000..c22444f71c34 --- /dev/null +++ b/fuzz/seed_corpus/a397c927fcbce17d573ef6e6b51efda250fb2517 @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/a3e3ee2699da83f568819bb981addcb38092ae1f b/fuzz/seed_corpus/a3e3ee2699da83f568819bb981addcb38092ae1f new file mode 100644 index 000000000000..4d1d9a830690 --- /dev/null +++ b/fuzz/seed_corpus/a3e3ee2699da83f568819bb981addcb38092ae1f @@ -0,0 +1,8 @@ + + + +

+

+

+

+
diff --git a/fuzz/seed_corpus/a43e4f54e355294d149252cc0f0ce05f7cac63ad b/fuzz/seed_corpus/a43e4f54e355294d149252cc0f0ce05f7cac63ad new file mode 100644 index 000000000000..645d35af56ab --- /dev/null +++ b/fuzz/seed_corpus/a43e4f54e355294d149252cc0f0ce05f7cac63ad @@ -0,0 +1,8 @@ + +' > +' > +' > +%defroot; %defmiddle; %deftest; +]> +sample diff --git a/fuzz/seed_corpus/a46db0975b681d55cbc40686a0cafa4b45a9a17f b/fuzz/seed_corpus/a46db0975b681d55cbc40686a0cafa4b45a9a17f new file mode 100644 index 000000000000..0923fae24767 --- /dev/null +++ b/fuzz/seed_corpus/a46db0975b681d55cbc40686a0cafa4b45a9a17f @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/a47f943f8458185f6adce2f55037703765f232da b/fuzz/seed_corpus/a47f943f8458185f6adce2f55037703765f232da new file mode 100644 index 000000000000..c542fa64211a --- /dev/null +++ b/fuzz/seed_corpus/a47f943f8458185f6adce2f55037703765f232da @@ -0,0 +1,3 @@ + + foobar + diff --git a/fuzz/seed_corpus/a515ea2917796f92e9c96dec3b60f816cdd5b85c b/fuzz/seed_corpus/a515ea2917796f92e9c96dec3b60f816cdd5b85c new file mode 100644 index 000000000000..774e56f95f47 --- /dev/null +++ b/fuzz/seed_corpus/a515ea2917796f92e9c96dec3b60f816cdd5b85c @@ -0,0 +1,13 @@ + + + + + 15 + 127 + 15 + 127 + 15 + 127 + + diff --git a/fuzz/seed_corpus/a55ddf0e4881941b2bd3d3a3ebc251fda4cd26d3 b/fuzz/seed_corpus/a55ddf0e4881941b2bd3d3a3ebc251fda4cd26d3 new file mode 100644 index 000000000000..3de2c4533cdc --- /dev/null +++ b/fuzz/seed_corpus/a55ddf0e4881941b2bd3d3a3ebc251fda4cd26d3 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/a5adf3a4d1833b1fc94d4903eca9686a7e845442 b/fuzz/seed_corpus/a5adf3a4d1833b1fc94d4903eca9686a7e845442 new file mode 100644 index 000000000000..4f34fbea3fa7 --- /dev/null +++ b/fuzz/seed_corpus/a5adf3a4d1833b1fc94d4903eca9686a7e845442 @@ -0,0 +1,3 @@ + +-45 + diff --git a/fuzz/seed_corpus/a5f16b6b5cd78f6331ab247a3c978beaa632bede b/fuzz/seed_corpus/a5f16b6b5cd78f6331ab247a3c978beaa632bede new file mode 100644 index 000000000000..62f31a56ca82 --- /dev/null +++ b/fuzz/seed_corpus/a5f16b6b5cd78f6331ab247a3c978beaa632bede @@ -0,0 +1,5 @@ + + + + + diff --git a/fuzz/seed_corpus/a61f7009b571c49c0639e88668ee34b65a022fef b/fuzz/seed_corpus/a61f7009b571c49c0639e88668ee34b65a022fef new file mode 100644 index 000000000000..d9e9e83957e7 --- /dev/null +++ b/fuzz/seed_corpus/a61f7009b571c49c0639e88668ee34b65a022fef @@ -0,0 +1,3 @@ + + %a; diff --git a/fuzz/seed_corpus/a66f2c59b5542bed70cd9bbf640466103a086cb1 b/fuzz/seed_corpus/a66f2c59b5542bed70cd9bbf640466103a086cb1 new file mode 100644 index 000000000000..7b95292f432a --- /dev/null +++ b/fuzz/seed_corpus/a66f2c59b5542bed70cd9bbf640466103a086cb1 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + 123 + ABC + 456 + DEF diff --git a/fuzz/seed_corpus/a6a6367c0ca61341ec7c77300bee0c6648467357 b/fuzz/seed_corpus/a6a6367c0ca61341ec7c77300bee0c6648467357 new file mode 100644 index 000000000000..c3bb126990c8 --- /dev/null +++ b/fuzz/seed_corpus/a6a6367c0ca61341ec7c77300bee0c6648467357 @@ -0,0 +1 @@ +content diff --git a/fuzz/seed_corpus/a6d363497c7966d8af00f0f4fad5a578b484695b b/fuzz/seed_corpus/a6d363497c7966d8af00f0f4fad5a578b484695b new file mode 100644 index 000000000000..c157a3e67a2f --- /dev/null +++ b/fuzz/seed_corpus/a6d363497c7966d8af00f0f4fad5a578b484695b @@ -0,0 +1,5 @@ +/. +//. +/root//. +//.//./././/. +/root//././/bar//. \ No newline at end of file diff --git a/fuzz/seed_corpus/a736ece169eac1afc7b083d22d60e6650b64d3a8 b/fuzz/seed_corpus/a736ece169eac1afc7b083d22d60e6650b64d3a8 new file mode 100644 index 000000000000..69e353da53f1 --- /dev/null +++ b/fuzz/seed_corpus/a736ece169eac1afc7b083d22d60e6650b64d3a8 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/a74a6dbf569e64d1117c109356151a6edd5710b3 b/fuzz/seed_corpus/a74a6dbf569e64d1117c109356151a6edd5710b3 new file mode 100644 index 000000000000..a33889b8c226 --- /dev/null +++ b/fuzz/seed_corpus/a74a6dbf569e64d1117c109356151a6edd5710b3 @@ -0,0 +1,6 @@ + + + +]> +This is a valid document diff --git a/fuzz/seed_corpus/a76019df02dfbfeede9e2bec4c49b63751d3329a b/fuzz/seed_corpus/a76019df02dfbfeede9e2bec4c49b63751d3329a new file mode 100644 index 000000000000..922314beb936 --- /dev/null +++ b/fuzz/seed_corpus/a76019df02dfbfeede9e2bec4c49b63751d3329a @@ -0,0 +1,8 @@ + + + +' > +%xx; +]> +This sample shows a &tricky; method. diff --git a/fuzz/seed_corpus/a7c82c056aea3e1c467839b6db69f4e2015c478a b/fuzz/seed_corpus/a7c82c056aea3e1c467839b6db69f4e2015c478a new file mode 100644 index 000000000000..64a1d0bdf0ca --- /dev/null +++ b/fuzz/seed_corpus/a7c82c056aea3e1c467839b6db69f4e2015c478a @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/a7caca25f9d08d19a6acea2dd2e8acd414244e62 b/fuzz/seed_corpus/a7caca25f9d08d19a6acea2dd2e8acd414244e62 new file mode 100644 index 000000000000..16d900a455cc --- /dev/null +++ b/fuzz/seed_corpus/a7caca25f9d08d19a6acea2dd2e8acd414244e62 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/a7de32bceaa8574c10988e703a3eb79b50fea650 b/fuzz/seed_corpus/a7de32bceaa8574c10988e703a3eb79b50fea650 new file mode 100644 index 000000000000..8f4dd13968df --- /dev/null +++ b/fuzz/seed_corpus/a7de32bceaa8574c10988e703a3eb79b50fea650 @@ -0,0 +1,4 @@ +public "-//OASIS//DTD DocBook XML CALS Table Model V4.1//EN " +public "-//Davenport//DTD DocBook V3.0//EN" +public " -//OASIS//DTD XML Exchange Table Model 19990315//EN" +public "-//Davenport//ENTITIES DocBook Additional General Entities V3.0//EN" diff --git a/fuzz/seed_corpus/a825a411610ce28d84d7ea236b0891172cffd1e7 b/fuzz/seed_corpus/a825a411610ce28d84d7ea236b0891172cffd1e7 new file mode 100644 index 000000000000..ed8ae68201ff --- /dev/null +++ b/fuzz/seed_corpus/a825a411610ce28d84d7ea236b0891172cffd1e7 @@ -0,0 +1,12 @@ + + + (//. | //@* | //namespace::*) + [ + + ancestor-or-self::bar:Something and + not (self::foo:Something) and + (self::text() or + (namespace-uri() != "") or + (string(self::node()) = namespace-uri(parent::node()))) + ] + diff --git a/fuzz/seed_corpus/a9399ac14de393924993c2e2b7cef86ecb543bd1 b/fuzz/seed_corpus/a9399ac14de393924993c2e2b7cef86ecb543bd1 new file mode 100644 index 000000000000..e6aae94883c6 --- /dev/null +++ b/fuzz/seed_corpus/a9399ac14de393924993c2e2b7cef86ecb543bd1 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/a946c6f0e7e270604c5f2a3014cc6053d6f5a478 b/fuzz/seed_corpus/a946c6f0e7e270604c5f2a3014cc6053d6f5a478 new file mode 100644 index 000000000000..8f2bdba81882 --- /dev/null +++ b/fuzz/seed_corpus/a946c6f0e7e270604c5f2a3014cc6053d6f5a478 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/a986aeb1ad825a9f45a0cec25a31e4ad64659627 b/fuzz/seed_corpus/a986aeb1ad825a9f45a0cec25a31e4ad64659627 new file mode 100644 index 000000000000..9264893afada --- /dev/null +++ b/fuzz/seed_corpus/a986aeb1ad825a9f45a0cec25a31e4ad64659627 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/a9ebffabd9677a657a9ef44e5540e5ed517cf393 b/fuzz/seed_corpus/a9ebffabd9677a657a9ef44e5540e5ed517cf393 new file mode 100644 index 000000000000..1111e33b8963 --- /dev/null +++ b/fuzz/seed_corpus/a9ebffabd9677a657a9ef44e5540e5ed517cf393 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/aa02af41473cf07008dd6edcf33cd800414f4628 b/fuzz/seed_corpus/aa02af41473cf07008dd6edcf33cd800414f4628 new file mode 100644 index 000000000000..3de1c19945b5 --- /dev/null +++ b/fuzz/seed_corpus/aa02af41473cf07008dd6edcf33cd800414f4628 @@ -0,0 +1,6 @@ + + + + + + diff --git a/fuzz/seed_corpus/aa21bdc5bc23663fe7fe93bc64abdab3e1c6c969 b/fuzz/seed_corpus/aa21bdc5bc23663fe7fe93bc64abdab3e1c6c969 new file mode 100644 index 000000000000..b40a8acef801 --- /dev/null +++ b/fuzz/seed_corpus/aa21bdc5bc23663fe7fe93bc64abdab3e1c6c969 @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/fuzz/seed_corpus/aa4466264322911f4e340e82b8ede8c4d4e40de1 b/fuzz/seed_corpus/aa4466264322911f4e340e82b8ede8c4d4e40de1 new file mode 100644 index 000000000000..0fa88af8ed0f --- /dev/null +++ b/fuzz/seed_corpus/aa4466264322911f4e340e82b8ede8c4d4e40de1 @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/aa5f416a1b24637bee0ee023c58d7d82b780af38 b/fuzz/seed_corpus/aa5f416a1b24637bee0ee023c58d7d82b780af38 new file mode 100644 index 000000000000..11d27a8c21f8 --- /dev/null +++ b/fuzz/seed_corpus/aa5f416a1b24637bee0ee023c58d7d82b780af38 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/aa7a6b9666bc5abdbafeff6ad604fee839cff4cf b/fuzz/seed_corpus/aa7a6b9666bc5abdbafeff6ad604fee839cff4cf new file mode 100644 index 000000000000..2c0510596d68 --- /dev/null +++ b/fuzz/seed_corpus/aa7a6b9666bc5abdbafeff6ad604fee839cff4cf @@ -0,0 +1,73 @@ +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/aaa952e35e8e86cb684097528b1a02313ecf9d9e b/fuzz/seed_corpus/aaa952e35e8e86cb684097528b1a02313ecf9d9e new file mode 100644 index 000000000000..c3f723b28aaf --- /dev/null +++ b/fuzz/seed_corpus/aaa952e35e8e86cb684097528b1a02313ecf9d9e @@ -0,0 +1,5 @@ + + John Smith + js@example.com + error + diff --git a/fuzz/seed_corpus/aabc5ff93ae73f7eb85001270335a3fe49523298 b/fuzz/seed_corpus/aabc5ff93ae73f7eb85001270335a3fe49523298 new file mode 100644 index 000000000000..e1f3e91885ed --- /dev/null +++ b/fuzz/seed_corpus/aabc5ff93ae73f7eb85001270335a3fe49523298 @@ -0,0 +1,14 @@ +# +# tests just "a" +# +t 0 1 a +f 1 +------- +a +=> +a +a +=> +=> +b +=> diff --git a/fuzz/seed_corpus/aabce40b41089adaf52c4973989ba9a4f96ef6bc b/fuzz/seed_corpus/aabce40b41089adaf52c4973989ba9a4f96ef6bc new file mode 100644 index 000000000000..16709809d0da --- /dev/null +++ b/fuzz/seed_corpus/aabce40b41089adaf52c4973989ba9a4f96ef6bc @@ -0,0 +1,3 @@ + + + &unknown; violates [ WFC: Entity Declared ] diff --git a/fuzz/seed_corpus/aad059c552093c84159931adb386895717ff34f1 b/fuzz/seed_corpus/aad059c552093c84159931adb386895717ff34f1 new file mode 100644 index 000000000000..935e7521ddd2 --- /dev/null +++ b/fuzz/seed_corpus/aad059c552093c84159931adb386895717ff34f1 @@ -0,0 +1 @@ + +"> +]> + violates [ WFC: Entity Declared ] diff --git a/fuzz/seed_corpus/ab76f337b38a2434c70af0392982f5f0f05465ca b/fuzz/seed_corpus/ab76f337b38a2434c70af0392982f5f0f05465ca new file mode 100644 index 000000000000..5ba7e3f0cc2b --- /dev/null +++ b/fuzz/seed_corpus/ab76f337b38a2434c70af0392982f5f0f05465ca @@ -0,0 +1,8 @@ + + + + xy + + diff --git a/fuzz/seed_corpus/ab81bc3803000942f2e8ec4a95377bdba3b46b1f b/fuzz/seed_corpus/ab81bc3803000942f2e8ec4a95377bdba3b46b1f new file mode 100644 index 000000000000..86784103a54a --- /dev/null +++ b/fuzz/seed_corpus/ab81bc3803000942f2e8ec4a95377bdba3b46b1f @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/fuzz/seed_corpus/ab834372595e54c6f796953decf9ee7e498f455a b/fuzz/seed_corpus/ab834372595e54c6f796953decf9ee7e498f455a new file mode 100644 index 000000000000..873fb35b9923 --- /dev/null +++ b/fuzz/seed_corpus/ab834372595e54c6f796953decf9ee7e498f455a @@ -0,0 +1,7 @@ + + + + + diff --git a/fuzz/seed_corpus/aba1fdc077a4b189ffbffb1c0a486df597464f42 b/fuzz/seed_corpus/aba1fdc077a4b189ffbffb1c0a486df597464f42 new file mode 100644 index 000000000000..a70740a6ca8c --- /dev/null +++ b/fuzz/seed_corpus/aba1fdc077a4b189ffbffb1c0a486df597464f42 @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/acfcfe811ca61bbd0dd108e0088b9ff4e59bf546 b/fuzz/seed_corpus/acfcfe811ca61bbd0dd108e0088b9ff4e59bf546 new file mode 100644 index 000000000000..211b4e5579ea --- /dev/null +++ b/fuzz/seed_corpus/acfcfe811ca61bbd0dd108e0088b9ff4e59bf546 @@ -0,0 +1 @@ +foo diff --git a/fuzz/seed_corpus/ad5a1e8e7bb5385d01789c44ee20bb43739e0231 b/fuzz/seed_corpus/ad5a1e8e7bb5385d01789c44ee20bb43739e0231 new file mode 100644 index 000000000000..e6763476dc8a --- /dev/null +++ b/fuzz/seed_corpus/ad5a1e8e7bb5385d01789c44ee20bb43739e0231 @@ -0,0 +1,8 @@ + + + +]> + + + diff --git a/fuzz/seed_corpus/ae589c86e618d6ee0662ab077f6a56cdd2830aec b/fuzz/seed_corpus/ae589c86e618d6ee0662ab077f6a56cdd2830aec new file mode 100644 index 000000000000..9f2e5eafcad1 --- /dev/null +++ b/fuzz/seed_corpus/ae589c86e618d6ee0662ab077f6a56cdd2830aec @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/aef3356d35a1ef1c662976964bf605e463f0eddb b/fuzz/seed_corpus/aef3356d35a1ef1c662976964bf605e463f0eddb new file mode 100644 index 000000000000..d9c956084b7b --- /dev/null +++ b/fuzz/seed_corpus/aef3356d35a1ef1c662976964bf605e463f0eddb @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/af3ca51d1e20efbcb7a52077d36362c489b6fb41 b/fuzz/seed_corpus/af3ca51d1e20efbcb7a52077d36362c489b6fb41 new file mode 100644 index 000000000000..16f876b251ce --- /dev/null +++ b/fuzz/seed_corpus/af3ca51d1e20efbcb7a52077d36362c489b6fb41 @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/af87d01e96497931b9b2294ad19592dfc8fcfdc9 b/fuzz/seed_corpus/af87d01e96497931b9b2294ad19592dfc8fcfdc9 new file mode 100644 index 000000000000..e973d64e91d3 --- /dev/null +++ b/fuzz/seed_corpus/af87d01e96497931b9b2294ad19592dfc8fcfdc9 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/af92c19e28175ffedb2e4e057e525000c8957aa8 b/fuzz/seed_corpus/af92c19e28175ffedb2e4e057e525000c8957aa8 new file mode 100644 index 000000000000..a5cb437d6513 --- /dev/null +++ b/fuzz/seed_corpus/af92c19e28175ffedb2e4e057e525000c8957aa8 @@ -0,0 +1,12 @@ + +

start

+ + + + + + + +
hello !
+

end

+
diff --git a/fuzz/seed_corpus/afdd6ffe65a766b43299ec8c12d12a43bd65e770 b/fuzz/seed_corpus/afdd6ffe65a766b43299ec8c12d12a43bd65e770 new file mode 100644 index 000000000000..4e4f19c40c0a --- /dev/null +++ b/fuzz/seed_corpus/afdd6ffe65a766b43299ec8c12d12a43bd65e770 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b01cece4a6652972462aef17952e990ea33978d1 b/fuzz/seed_corpus/b01cece4a6652972462aef17952e990ea33978d1 new file mode 100644 index 000000000000..c1f586e7fe18 --- /dev/null +++ b/fuzz/seed_corpus/b01cece4a6652972462aef17952e990ea33978d1 @@ -0,0 +1,1258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dynamic + static + + + + + + + + + + + xen + kvm + kqemu + qemu + lxc + openvz + test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + i686 + x86_64 + ia64 + + + + + + + xenpv + xenner + + + + + xen + linux + + + + + + + + + + + + + + hvm + + + + + + + i686 + x86_64 + + + + + xenfv + pc + isapc + + + + + + + + mips + + + mips + + + + + + + sparc + + + sun4m + + + + + + + ppc + + + + g3beige + mac99 + prep + + + + + + + + exe + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localtime + utc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + hd + fd + cdrom + network + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + floppy + disk + cdrom + + + + + + + file + + + + + + + + + + + + + + + + block + + + + + + + + + + + + + + + + + + + + + + + + + + ide + fdc + scsi + virtio + xen + usb + uml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + none + writeback + writethrough + + + + + + + + + file + + + + + + + + + + + + + + block + + + + + + + + + + + + + + mount + + + + + + + + + + + + + + template + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bridge + + + + + + + + + + + + + + + + ethernet + + + + + + + + + + + + + + + + network + + + + + + + + + + + + + + user + + + + + + + + internal + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sdl + + + + + + + + + + + + + + + yes + no + + + + + + + vnc + + + + + + + + + + yes + no + + + + + + + + + + + + + + + + + + + + + + rdp + + + + + + + + + + yes + no + + + + + + + yes + no + + + + + + + yes + no + + + + + + + + + + + + desktop + + + + + + + + + + yes + no + + + + + + + + + + + + + + + vga + cirrus + vmvga + xen + vbox + + + + + + + + + + + + + + + + + + yes + no + + + + + + + yes + no + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + preserve + rename-restart + + + + + + + dev + file + pipe + unix + tcp + udp + null + stdio + vc + pty + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sb16 + es1370 + pcspk + ac97 + + + + + + + + + + + + + + + + + + + tablet + mouse + + + + + + ps2 + usb + xen + + + + + + + + + + + subsystem + capabilities + + + + + usb + pci + + + + + yes + no + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [0-9]+ + + + + + [0-9]+ + 1 + + + + + -1 + + + + + [0-9]+ + 4000 + + + + + [A-Za-z0-9_\.\+\-&:/]+ + + + + + [A-Za-z0-9_\.\+\-]+ + + + + + [a-zA-Z0-9_\+\-]+ + + + + + + [a-fA-F0-9]{32} + + + [a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12} + + + + + + [a-zA-Z0-9_\.\+\-&/%]+ + + + + + /[a-zA-Z0-9_\.\+\-&/%]+ + + + + + /[a-zA-Z0-9_\.\+\-&/%]* + + + + + /[a-zA-Z0-9_\+\-/%]+ + + + + + [a-zA-Z0-9_\.\-:/]+ + + + + + ([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2} + + + + + ([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9] + + + + + (0x)?[0-9a-fA-F]{1,4} + + + + + (0x)?[0-9a-fA-F]{1,3} + + + + + (0x)?[0-9a-fA-F]{1,4} + + + + + (0x)?[0-9a-fA-F]{1,2} + + + + + (0x)?[0-1]?[0-9a-fA-F] + + + + + (0x)?[0-7] + + + diff --git a/fuzz/seed_corpus/b07412ff29ba83b3e65d270d9185583a9cc549d5 b/fuzz/seed_corpus/b07412ff29ba83b3e65d270d9185583a9cc549d5 new file mode 100644 index 000000000000..68f3865f54af --- /dev/null +++ b/fuzz/seed_corpus/b07412ff29ba83b3e65d270d9185583a9cc549d5 @@ -0,0 +1,6 @@ + + meta1 + foo + meta2 + error + diff --git a/fuzz/seed_corpus/b088b9b031752adc71958aceebc53e140cc7b745 b/fuzz/seed_corpus/b088b9b031752adc71958aceebc53e140cc7b745 new file mode 100644 index 000000000000..dec91436c571 --- /dev/null +++ b/fuzz/seed_corpus/b088b9b031752adc71958aceebc53e140cc7b745 @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/fuzz/seed_corpus/b0d9f006a7407b4b19712b85948a441920e0f087 b/fuzz/seed_corpus/b0d9f006a7407b4b19712b85948a441920e0f087 new file mode 100644 index 000000000000..a3b175a95dfd --- /dev/null +++ b/fuzz/seed_corpus/b0d9f006a7407b4b19712b85948a441920e0f087 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b1cae8bc746a5f0c90e837a86644f14f1b8a61f6 b/fuzz/seed_corpus/b1cae8bc746a5f0c90e837a86644f14f1b8a61f6 new file mode 100644 index 000000000000..af3592b6ae5f --- /dev/null +++ b/fuzz/seed_corpus/b1cae8bc746a5f0c90e837a86644f14f1b8a61f6 @@ -0,0 +1 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b2cd7fc6e6ee01c4ff356cd89c8070a5654d722d b/fuzz/seed_corpus/b2cd7fc6e6ee01c4ff356cd89c8070a5654d722d new file mode 100644 index 000000000000..ca58c2b08e71 --- /dev/null +++ b/fuzz/seed_corpus/b2cd7fc6e6ee01c4ff356cd89c8070a5654d722d @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/b2debffda9a50311d654f3e56bdb22d144192b25 b/fuzz/seed_corpus/b2debffda9a50311d654f3e56bdb22d144192b25 new file mode 100644 index 000000000000..0174e9060e0b --- /dev/null +++ b/fuzz/seed_corpus/b2debffda9a50311d654f3e56bdb22d144192b25 @@ -0,0 +1,6 @@ + + + + + diff --git a/fuzz/seed_corpus/b2eb9577cac455e58141bf0eccb73e8064a45c42 b/fuzz/seed_corpus/b2eb9577cac455e58141bf0eccb73e8064a45c42 new file mode 100644 index 000000000000..9bb944c40a55 --- /dev/null +++ b/fuzz/seed_corpus/b2eb9577cac455e58141bf0eccb73e8064a45c42 @@ -0,0 +1,4 @@ +resolve toto http://www.oasis-open.org/docbook/xml/4.1.2/dbpoolx.mod +public "-//OASIS//ENTITIES DocBook XML Character Entities V4.1.2//EN" +system http://www.oasis-open.org/docbook/xml/4.1.2/dbpoolx.mod +system urn:publicid:-:OASIS:DTD+DocBook+XML+V4.1.2:EN diff --git a/fuzz/seed_corpus/b304d40c287feafe05f482628ddbde4f5f7b1336 b/fuzz/seed_corpus/b304d40c287feafe05f482628ddbde4f5f7b1336 new file mode 100644 index 000000000000..348e1db250f4 --- /dev/null +++ b/fuzz/seed_corpus/b304d40c287feafe05f482628ddbde4f5f7b1336 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/b31d7370c53d261b0fdbdfb6da2faa257967ee1d b/fuzz/seed_corpus/b31d7370c53d261b0fdbdfb6da2faa257967ee1d new file mode 100644 index 000000000000..6a74b2f3de9f --- /dev/null +++ b/fuzz/seed_corpus/b31d7370c53d261b0fdbdfb6da2faa257967ee1d @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/b3268aeb1a6072253a1f47b703f6793766f61e6d b/fuzz/seed_corpus/b3268aeb1a6072253a1f47b703f6793766f61e6d new file mode 100644 index 000000000000..54b1c1cb413d --- /dev/null +++ b/fuzz/seed_corpus/b3268aeb1a6072253a1f47b703f6793766f61e6d @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b35723dce5a5fa5cd828d57182cae241bf38bdcd b/fuzz/seed_corpus/b35723dce5a5fa5cd828d57182cae241bf38bdcd new file mode 100644 index 000000000000..d748d1a41196 --- /dev/null +++ b/fuzz/seed_corpus/b35723dce5a5fa5cd828d57182cae241bf38bdcd @@ -0,0 +1,13 @@ + + + + +]> + + + first line + second line + diff --git a/fuzz/seed_corpus/b3809062894fb329d7d6316c760f92437a7aed85 b/fuzz/seed_corpus/b3809062894fb329d7d6316c760f92437a7aed85 new file mode 100644 index 000000000000..4b288048f36c --- /dev/null +++ b/fuzz/seed_corpus/b3809062894fb329d7d6316c760f92437a7aed85 @@ -0,0 +1,5 @@ + + +]> + violates [ VC: No Duplicate Types ] diff --git a/fuzz/seed_corpus/b3a27a573559d424cdc8c229940d0755667d9e15 b/fuzz/seed_corpus/b3a27a573559d424cdc8c229940d0755667d9e15 new file mode 100644 index 000000000000..ba410e1f5d5d --- /dev/null +++ b/fuzz/seed_corpus/b3a27a573559d424cdc8c229940d0755667d9e15 @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b3b51c4f00d47f3259c2808fcf33267453afdca0 b/fuzz/seed_corpus/b3b51c4f00d47f3259c2808fcf33267453afdca0 new file mode 100644 index 000000000000..6240939071be --- /dev/null +++ b/fuzz/seed_corpus/b3b51c4f00d47f3259c2808fcf33267453afdca0 @@ -0,0 +1,3 @@ + + + &unknown; but Okay diff --git a/fuzz/seed_corpus/b4146bf40551c98dc173d1788ab0f41acb65247f b/fuzz/seed_corpus/b4146bf40551c98dc173d1788ab0f41acb65247f new file mode 100644 index 000000000000..e668b404ecad --- /dev/null +++ b/fuzz/seed_corpus/b4146bf40551c98dc173d1788ab0f41acb65247f @@ -0,0 +1,8 @@ + + +]> + + Test of &amp; behaviour a&b . + + diff --git a/fuzz/seed_corpus/b44c7604df02ba25ffa5f7223a5bf59b638ac162 b/fuzz/seed_corpus/b44c7604df02ba25ffa5f7223a5bf59b638ac162 new file mode 100644 index 000000000000..01b47fcd4693 --- /dev/null +++ b/fuzz/seed_corpus/b44c7604df02ba25ffa5f7223a5bf59b638ac162 @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/b5d70dc665888663f6099ff71791b3b919a95ba6 b/fuzz/seed_corpus/b5d70dc665888663f6099ff71791b3b919a95ba6 new file mode 100644 index 000000000000..ab507092917f --- /dev/null +++ b/fuzz/seed_corpus/b5d70dc665888663f6099ff71791b3b919a95ba6 @@ -0,0 +1,8 @@ + + +]> + diff --git a/fuzz/seed_corpus/b5e888307bdab943abd4b259d65c88dcaf7a7cb7 b/fuzz/seed_corpus/b5e888307bdab943abd4b259d65c88dcaf7a7cb7 new file mode 100644 index 000000000000..0bf5f276f54c --- /dev/null +++ b/fuzz/seed_corpus/b5e888307bdab943abd4b259d65c88dcaf7a7cb7 @@ -0,0 +1,14 @@ + + + + + + + + + + Defining things for later use + + + diff --git a/fuzz/seed_corpus/b611704b84c0dc7432f806fdc918731de39dd5d1 b/fuzz/seed_corpus/b611704b84c0dc7432f806fdc918731de39dd5d1 new file mode 100644 index 000000000000..33b8f19321be --- /dev/null +++ b/fuzz/seed_corpus/b611704b84c0dc7432f806fdc918731de39dd5d1 @@ -0,0 +1,3 @@ + + diff --git a/fuzz/seed_corpus/b64c4b370a571587ada55f2cdb4bf029190643ce b/fuzz/seed_corpus/b64c4b370a571587ada55f2cdb4bf029190643ce new file mode 100644 index 000000000000..eef70788df2d --- /dev/null +++ b/fuzz/seed_corpus/b64c4b370a571587ada55f2cdb4bf029190643ce @@ -0,0 +1,1633 @@ + + + + + + + + + + + + + + + + +"> + +'"> + + + + + + + + + +amp, +lt, +gt, +apos, +quot"> + + + + + +]> + + + + + +
+Extensible Markup Language (XML) 1.0 + +REC-xml-&iso6.doc.date; +W3C Recommendation +&draft.day;&draft.month;&draft.year; + + + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date; + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.xml + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.html + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.pdf + +http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.ps + + + +http://www.w3.org/TR/REC-xml + + + +http://www.w3.org/TR/PR-xml-971208 + + + +Tim Bray +Textuality and Netscape +tbray@textuality.com +Jean Paoli +Microsoft +jeanpa@microsoft.com +C. M. Sperberg-McQueen +University of Illinois at Chicago +cmsmcq@uic.edu + + +

The Extensible Markup Language (XML) is a subset of +SGML that is completely described in this document. Its goal is to +enable generic SGML to be served, received, and processed on the Web +in the way that is now possible with HTML. XML has been designed for +ease of implementation and for interoperability with both SGML and +HTML.

+
+ +

This document has been reviewed by W3C Members and +other interested parties and has been endorsed by the +Director as a W3C Recommendation. It is a stable +document and may be used as reference material or cited +as a normative reference from another document. W3C's +role in making the Recommendation is to draw attention +to the specification and to promote its widespread +deployment. This enhances the functionality and +interoperability of the Web.

+

+This document specifies a syntax created by subsetting an existing, +widely used international text processing standard (Standard +Generalized Markup Language, ISO 8879:1986(E) as amended and +corrected) for use on the World Wide Web. It is a product of the W3C +XML Activity, details of which can be found at http://www.w3.org/XML. A list of +current W3C Recommendations and other technical documents can be found +at http://www.w3.org/TR. +

+

This specification uses the term URI, which is defined by , a work in progress expected to update and . +

+

The list of known errors in this specification is +available at +http://www.w3.org/XML/xml-19980210-errata.

+

Please report errors in this document to +xml-editor@w3.org. +

+
+ + + +

Chicago, Vancouver, Mountain View, et al.: +World-Wide Web Consortium, XML Working Group, 1996, 1997.

+
+ +

Created in electronic form.

+
+ +English +Extended Backus-Naur Form (formal grammar) + + + +1997-12-03 : CMSMcQ : yet further changes +1997-12-02 : TB : further changes (see TB to XML WG, +2 December 1997) +1997-12-02 : CMSMcQ : deal with as many corrections and +comments from the proofreaders as possible: +entify hard-coded document date in pubdate element, +change expansion of entity WebSGML, +update status description as per Dan Connolly (am not sure +about refernece to Berners-Lee et al.), +add 'The' to abstract as per WG decision, +move Relationship to Existing Standards to back matter and +combine with References, +re-order back matter so normative appendices come first, +re-tag back matter so informative appendices are tagged informdiv1, +remove XXX XXX from list of 'normative' specs in prose, +move some references from Other References to Normative References, +add RFC 1738, 1808, and 2141 to Other References (they are not +normative since we do not require the processor to enforce any +rules based on them), +add reference to 'Fielding draft' (Berners-Lee et al.), +move notation section to end of body, +drop URIchar non-terminal and use SkipLit instead, +lose stray reference to defunct nonterminal 'markupdecls', +move reference to Aho et al. into appendix (Tim's right), +add prose note saying that hash marks and fragment identifiers are +NOT part of the URI formally speaking, and are NOT legal in +system identifiers (processor 'may' signal an error). +Work through: +Tim Bray reacting to James Clark, +Tim Bray on his own, +Eve Maler, + +NOT DONE YET: +change binary / text to unparsed / parsed. +handle James's suggestion about < in attriubte values +uppercase hex characters, +namechar list, + +1997-12-01 : JB : add some column-width parameters +1997-12-01 : CMSMcQ : begin round of changes to incorporate +recent WG decisions and other corrections: +binding sources of character encoding info (27 Aug / 3 Sept), +correct wording of Faust quotation (restore dropped line), +drop SDD from EncodingDecl, +change text at version number 1.0, +drop misleading (wrong!) sentence about ignorables and extenders, +modify definition of PCData to make bar on msc grammatical, +change grammar's handling of internal subset (drop non-terminal markupdecls), +change definition of includeSect to allow conditional sections, +add integral-declaration constraint on internal subset, +drop misleading / dangerous sentence about relationship of +entities with system storage objects, +change table body tag to htbody as per EM change to DTD, +add rule about space normalization in public identifiers, +add description of how to generate our name-space rules from +Unicode character database (needs further work!). + +1997-10-08 : TB : Removed %-constructs again, new rules +for PE appearance. +1997-10-01 : TB : Case-sensitive markup; cleaned up +element-type defs, lotsa little edits for style +1997-09-25 : TB : Change to elm's new DTD, with +substantial detail cleanup as a side-effect +1997-07-24 : CMSMcQ : correct error (lost *) in definition +of ignoreSectContents (thanks to Makoto Murata) +Allow all empty elements to have end-tags, consistent with +SGML TC (as per JJC). +1997-07-23 : CMSMcQ : pre-emptive strike on pending corrections: +introduce the term 'empty-element tag', note that all empty elements +may use it, and elements declared EMPTY must use it. +Add WFC requiring encoding decl to come first in an entity. +Redefine notations to point to PIs as well as binary entities. +Change autodetection table by removing bytes 3 and 4 from +examples with Byte Order Mark. +Add content model as a term and clarify that it applies to both +mixed and element content. + +1997-06-30 : CMSMcQ : change date, some cosmetic changes, +changes to productions for choice, seq, Mixed, NotationType, +Enumeration. Follow James Clark's suggestion and prohibit +conditional sections in internal subset. TO DO: simplify +production for ignored sections as a result, since we don't +need to worry about parsers which don't expand PErefs finding +a conditional section. +1997-06-29 : TB : various edits +1997-06-29 : CMSMcQ : further changes: +Suppress old FINAL EDIT comments and some dead material. +Revise occurrences of % in grammar to exploit Henry Thompson's pun, +especially markupdecl and attdef. +Remove RMD requirement relating to element content (?). + +1997-06-28 : CMSMcQ : Various changes for 1 July draft: +Add text for draconian error handling (introduce +the term Fatal Error). +RE deleta est (changing wording from +original announcement to restrict the requirement to validating +parsers). +Tag definition of validating processor and link to it. +Add colon as name character. +Change def of %operator. +Change standard definitions of lt, gt, amp. +Strip leading zeros from #x00nn forms. +1997-04-02 : CMSMcQ : final corrections of editorial errors +found in last night's proofreading. Reverse course once more on +well-formed: Webster's Second hyphenates it, and that's enough +for me. +1997-04-01 : CMSMcQ : corrections from JJC, EM, HT, and self +1997-03-31 : Tim Bray : many changes +1997-03-29 : CMSMcQ : some Henry Thompson (on entity handling), +some Charles Goldfarb, some ERB decisions (PE handling in miscellaneous +declarations. Changed Ident element to accept def attribute. +Allow normalization of Unicode characters. move def of systemliteral +into section on literals. +1997-03-28 : CMSMcQ : make as many corrections as possible, from +Terry Allen, Norbert Mikula, James Clark, Jon Bosak, Henry Thompson, +Paul Grosso, and self. Among other things: give in on "well formed" +(Terry is right), tentatively rename QuotedCData as AttValue +and Literal as EntityValue to be more informative, since attribute +values are the only place QuotedCData was used, and +vice versa for entity text and Literal. (I'd call it Entity Text, +but 8879 uses that name for both internal and external entities.) +1997-03-26 : CMSMcQ : resynch the two forks of this draft, reapply +my changes dated 03-20 and 03-21. Normalize old 'may not' to 'must not' +except in the one case where it meant 'may or may not'. +1997-03-21 : TB : massive changes on plane flight from Chicago +to Vancouver +1997-03-21 : CMSMcQ : correct as many reported errors as possible. + +1997-03-20 : CMSMcQ : correct typos listed in CMSMcQ hand copy of spec. +1997-03-20 : CMSMcQ : cosmetic changes preparatory to revision for +WWW conference April 1997: restore some of the internal entity +references (e.g. to docdate, etc.), change character xA0 to &nbsp; +and define nbsp as &#160;, and refill a lot of paragraphs for +legibility. +1996-11-12 : CMSMcQ : revise using Tim's edits: +Add list type of NUMBERED and change most lists either to +BULLETS or to NUMBERED. +Suppress QuotedNames, Names (not used). +Correct trivial-grammar doc type decl. +Rename 'marked section' as 'CDATA section' passim. +Also edits from James Clark: +Define the set of characters from which [^abc] subtracts. +Charref should use just [0-9] not Digit. +Location info needs cleaner treatment: remove? (ERB +question). +One example of a PI has wrong pic. +Clarify discussion of encoding names. +Encoding failure should lead to unspecified results; don't +prescribe error recovery. +Don't require exposure of entity boundaries. +Ignore white space in element content. +Reserve entity names of the form u-NNNN. +Clarify relative URLs. +And some of my own: +Correct productions for content model: model cannot +consist of a name, so "elements ::= cp" is no good. + +1996-11-11 : CMSMcQ : revise for style. +Add new rhs to entity declaration, for parameter entities. +1996-11-10 : CMSMcQ : revise for style. +Fix / complete section on names, characters. +Add sections on parameter entities, conditional sections. +Still to do: Add compatibility note on deterministic content models. +Finish stylistic revision. +1996-10-31 : TB : Add Entity Handling section +1996-10-30 : TB : Clean up term & termdef. Slip in +ERB decision re EMPTY. +1996-10-28 : TB : Change DTD. Implement some of Michael's +suggestions. Change comments back to //. Introduce language for +XML namespace reservation. Add section on white-space handling. +Lots more cleanup. +1996-10-24 : CMSMcQ : quick tweaks, implement some ERB +decisions. Characters are not integers. Comments are /* */ not //. +Add bibliographic refs to 10646, HyTime, Unicode. +Rename old Cdata as MsData since it's only seen +in marked sections. Call them attribute-value pairs not +name-value pairs, except once. Internal subset is optional, needs +'?'. Implied attributes should be signaled to the app, not +have values supplied by processor. +1996-10-16 : TB : track down & excise all DSD references; +introduce some EBNF for entity declarations. +1996-10-?? : TB : consistency check, fix up scraps so +they all parse, get formatter working, correct a few productions. +1996-10-10/11 : CMSMcQ : various maintenance, stylistic, and +organizational changes: +Replace a few literals with xmlpio and +pic entities, to make them consistent and ensure we can change pic +reliably when the ERB votes. +Drop paragraph on recognizers from notation section. +Add match, exact match to terminology. +Move old 2.2 XML Processors and Apps into intro. +Mention comments, PIs, and marked sections in discussion of +delimiter escaping. +Streamline discussion of doctype decl syntax. +Drop old section of 'PI syntax' for doctype decl, and add +section on partial-DTD summary PIs to end of Logical Structures +section. +Revise DSD syntax section to use Tim's subset-in-a-PI +mechanism. +1996-10-10 : TB : eliminate name recognizers (and more?) +1996-10-09 : CMSMcQ : revise for style, consistency through 2.3 +(Characters) +1996-10-09 : CMSMcQ : re-unite everything for convenience, +at least temporarily, and revise quickly +1996-10-08 : TB : first major homogenization pass +1996-10-08 : TB : turn "current" attribute on div type into +CDATA +1996-10-02 : TB : remould into skeleton + entities +1996-09-30 : CMSMcQ : add a few more sections prior to exchange + with Tim. +1996-09-20 : CMSMcQ : finish transcribing notes. +1996-09-19 : CMSMcQ : begin transcribing notes for draft. +1996-09-13 : CMSMcQ : made outline from notes of 09-06, +do some housekeeping + + +
+ + +Introduction +

Extensible Markup Language, abbreviated XML, describes a class of +data objects called XML documents and +partially describes the behavior of +computer programs which process them. XML is an application profile or +restricted form of SGML, the Standard Generalized Markup +Language . +By construction, XML documents +are conforming SGML documents. +

+

XML documents are made up of storage units called entities, which contain either parsed +or unparsed data. +Parsed data is made up of characters, +some +of which form character data, +and some of which form markup. +Markup encodes a description of the document's storage layout and +logical structure. XML provides a mechanism to impose constraints on +the storage layout and logical structure.

+

A software module +called an XML processor is used to read XML documents +and provide access to their content and structure. It is assumed that an XML processor is +doing its work on behalf of another module, called the +application. This specification describes the +required behavior of an XML processor in terms of how it must read XML +data and the information it must provide to the application.

+ + +Origin and Goals +

XML was developed by an XML Working Group (originally known as the +SGML Editorial Review Board) formed under the auspices of the World +Wide Web Consortium (W3C) in 1996. +It was chaired by Jon Bosak of Sun +Microsystems with the active participation of an XML Special +Interest Group (previously known as the SGML Working Group) also +organized by the W3C. The membership of the XML Working Group is given +in an appendix. Dan Connolly served as the WG's contact with the W3C. +

+

The design goals for XML are: +

XML shall be straightforwardly usable over the +Internet.

+

XML shall support a wide variety of applications.

+

XML shall be compatible with SGML.

+

It shall be easy to write programs which process XML +documents.

+

The number of optional features in XML is to be kept to the +absolute minimum, ideally zero.

+

XML documents should be human-legible and reasonably +clear.

+

The XML design should be prepared quickly.

+

The design of XML shall be formal and concise.

+

XML documents shall be easy to create.

+

Terseness in XML markup is of minimal importance.

+

+

This specification, +together with associated standards +(Unicode and ISO/IEC 10646 for characters, +Internet RFC 1766 for language identification tags, +ISO 639 for language name codes, and +ISO 3166 for country name codes), +provides all the information necessary to understand +XML Version &XML.version; +and construct computer programs to process it.

+

This version of the XML specification + +&doc.distribution;.

+ +
+ + + + + +Terminology + +

The terminology used to describe XML documents is defined in the body of +this specification. +The terms defined in the following list are used in building those +definitions and in describing the actions of an XML processor: + + + +

Conforming documents and XML +processors are permitted to but need not behave as +described.

+ + + +

Conforming documents and XML processors +are required to behave as described; otherwise they are in error. + +

+
+ + +

A violation of the rules of this +specification; results are +undefined. Conforming software may detect and report an error and may +recover from it.

+
+ + +

An error +which a conforming XML processor +must detect and report to the application. +After encountering a fatal error, the +processor may continue +processing the data to search for further errors and may report such +errors to the application. In order to support correction of errors, +the processor may make unprocessed data from the document (with +intermingled character data and markup) available to the application. +Once a fatal error is detected, however, the processor must not +continue normal processing (i.e., it must not +continue to pass character data and information about the document's +logical structure to the application in the normal way). +

+
+ + +

Conforming software may or must (depending on the modal verb in the +sentence) behave as described; if it does, it must +provide users a means to enable or disable the behavior +described.

+
+ + +

A rule which applies to all +valid XML documents. +Violations of validity constraints are errors; they must, at user option, +be reported by +validating XML processors.

+
+ + +

A rule which applies to all well-formed XML documents. +Violations of well-formedness constraints are +fatal errors.

+
+ + + +

(Of strings or names:) +Two strings or names being compared must be identical. +Characters with multiple possible representations in ISO/IEC 10646 (e.g. +characters with +both precomposed and base+diacritic forms) match only if they have the +same representation in both strings. +At user option, processors may normalize such characters to +some canonical form. +No case folding is performed. +(Of strings and rules in the grammar:) +A string matches a grammatical production if it belongs to the +language generated by that production. +(Of content and content models:) +An element matches its declaration when it conforms +in the fashion described in the constraint +. + +

+
+ + +

A feature of +XML included solely to ensure that XML remains compatible with SGML. +

+
+ + +

A +non-binding recommendation included to increase the chances that XML +documents can be processed by the existing installed base of SGML +processors which predate the +&WebSGML;.

+
+ +

+
+ + +
+ + + +Documents + +

+A data object is an +XML document if it is +well-formed, as +defined in this specification. +A well-formed XML document may in addition be +valid if it meets certain further +constraints.

+ +

Each XML document has both a logical and a physical structure. +Physically, the document is composed of units called entities. An entity may refer to other entities to cause their +inclusion in the document. A document begins in a "root" or document entity. +Logically, the document is composed of declarations, elements, +comments, +character references, and +processing +instructions, all of which are indicated in the document by explicit +markup. +The logical and physical structures must nest properly, as described +in . +

+ + +Well-Formed XML Documents + +

+A textual object is +a well-formed XML document if: + +

Taken as a whole, it +matches the production labeled document.

+

It +meets all the well-formedness constraints given in this specification.

+
+

Each of the parsed entities +which is referenced directly or indirectly within the document is +well-formed.

+

+

+ +Document +document +prolog +element +Misc* + +

+

Matching the document production +implies that: + +

It contains one or more +elements.

+ + +

There is exactly +one element, called the root, or document element, no +part of which appears in the content of any other element. +For all other elements, if the start-tag is in the content of another +element, the end-tag is in the content of the same element. More +simply stated, the elements, delimited by start- and end-tags, nest +properly within each other. +

+ +

+

As a consequence +of this, +for each non-root element +C in the document, there is one other element P +in the document such that +C is in the content of P, but is not in +the content of any other element that is in the content of +P. +P is referred to as the +parent of C, and C as a +child of P.

+ + +Characters + +

A parsed entity contains +text, a sequence of +characters, +which may represent markup or character data. +A character +is an atomic unit of text as specified by +ISO/IEC 10646 . +Legal characters are tab, carriage return, line feed, and the legal +graphic characters of Unicode and ISO/IEC 10646. +The use of "compatibility characters", as defined in section 6.8 +of , is discouraged. + + +Character Range + +Char +#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] +| [#x10000-#x10FFFF] +any Unicode character, excluding the +surrogate blocks, FFFE, and FFFF. + + +

+ +

The mechanism for encoding character code points into bit patterns may +vary from entity to entity. All XML processors must accept the UTF-8 +and UTF-16 encodings of 10646; the mechanisms for signaling which of +the two is in use, or for bringing other encodings into play, are +discussed later, in . +

+ +
+ + +Common Syntactic Constructs + +

This section defines some symbols used widely in the grammar.

+

S (white space) consists of one or more space (#x20) +characters, carriage returns, line feeds, or tabs. + + +White Space + +S +(#x20 | #x9 | #xD | #xA)+ + + +

+

Characters are classified for convenience as letters, digits, or other +characters. Letters consist of an alphabetic or syllabic +base character possibly +followed by one or more combining characters, or of an ideographic +character. +Full definitions of the specific characters in each class +are given in .

+

A Name is a token +beginning with a letter or one of a few punctuation characters, and continuing +with letters, digits, hyphens, underscores, colons, or full stops, together +known as name characters. +Names beginning with the string "xml", or any string +which would match (('X'|'x') ('M'|'m') ('L'|'l')), are +reserved for standardization in this or future versions of this +specification. +

+ +

The colon character within XML names is reserved for experimentation with +name spaces. +Its meaning is expected to be +standardized at some future point, at which point those documents +using the colon for experimental purposes may need to be updated. +(There is no guarantee that any name-space mechanism +adopted for XML will in fact use the colon as a name-space delimiter.) +In practice, this means that authors should not use the colon in XML +names except as part of name-space experiments, but that XML processors +should accept the colon as a name character.

+
+

An +Nmtoken (name token) is any mixture of +name characters. + +Names and Tokens +NameChar +Letter +| Digit +| '.' | '-' | '_' | ':' +| CombiningChar +| Extender + +Name +(Letter | '_' | ':') +(NameChar)* +Names +Name +(S Name)* +Nmtoken +(NameChar)+ +Nmtokens +Nmtoken (S Nmtoken)* + +

+

Literal data is any quoted string not containing +the quotation mark used as a delimiter for that string. +Literals are used +for specifying the content of internal entities +(EntityValue), +the values of attributes (AttValue), +and external identifiers +(SystemLiteral). +Note that a SystemLiteral +can be parsed without scanning for markup. + +Literals +EntityValue +'"' +([^%&"] +| PEReference +| Reference)* +'"' + +|  +"'" +([^%&'] +| PEReference +| Reference)* +"'" + +AttValue +'"' +([^<&"] +| Reference)* +'"' + +|  +"'" +([^<&'] +| Reference)* +"'" + +SystemLiteral +('"' [^"]* '"') | ("'" [^']* "'") + + +PubidLiteral +'"' PubidChar* +'"' +| "'" (PubidChar - "'")* "'" + +PubidChar +#x20 | #xD | #xA +| [a-zA-Z0-9] +| [-'()+,./:=?;!*#@$_%] + + +

+ +
+ + +Character Data and Markup + +

Text consists of intermingled +character +data and markup. +Markup takes the form of +start-tags, +end-tags, +empty-element tags, +entity references, +character references, +comments, +CDATA section delimiters, +document type declarations, and +processing instructions. + +

+

All text that is not markup +constitutes the character data of +the document.

+

The ampersand character (&) and the left angle bracket (<) +may appear in their literal form only when used as markup +delimiters, or within a comment, a +processing instruction, +or a CDATA section. + +They are also legal within the literal entity +value of an internal entity declaration; see +. + +If they are needed elsewhere, +they must be escaped +using either numeric character references +or the strings +"&amp;" and "&lt;" respectively. +The right angle +bracket (>) may be represented using the string +"&gt;", and must, for +compatibility, +be escaped using +"&gt;" or a character reference +when it appears in the string +"]]>" +in content, +when that string is not marking the end of +a CDATA section. +

+

+In the content of elements, character data +is any string of characters which does +not contain the start-delimiter of any markup. +In a CDATA section, character data +is any string of characters not including the CDATA-section-close +delimiter, "]]>".

+

+To allow attribute values to contain both single and double quotes, the +apostrophe or single-quote character (') may be represented as +"&apos;", and the double-quote character (") as +"&quot;". + +Character Data + +CharData +[^<&]* - ([^<&]* ']]>' [^<&]*) + + +

+
+ + +Comments + +

Comments may +appear anywhere in a document outside other +markup; in addition, +they may appear within the document type declaration +at places allowed by the grammar. +They are not part of the document's character +data; an XML +processor may, but need not, make it possible for an application to +retrieve the text of comments. +For compatibility, the string +"--" (double-hyphen) must not occur within +comments. + +Comments +Comment +'<!--' +((Char - '-') +| ('-' (Char - '-')))* +'-->' + + +

+

An example of a comment: +<!&como; declarations for <head> & <body> &comc;> +

+
+ + +Processing Instructions + +

Processing +instructions (PIs) allow documents to contain instructions +for applications. + + +Processing Instructions +PI +'<?' PITarget +(S +(Char* - +(Char* &pic; Char*)))? +&pic; +PITarget +Name - +(('X' | 'x') ('M' | 'm') ('L' | 'l')) + + +PIs are not part of the document's character +data, but must be passed through to the application. The +PI begins with a target (PITarget) used +to identify the application to which the instruction is directed. +The target names "XML", "xml", and so on are +reserved for standardization in this or future versions of this +specification. +The +XML Notation mechanism +may be used for +formal declaration of PI targets. +

+
+ + +CDATA Sections + +

CDATA sections +may occur +anywhere character data may occur; they are +used to escape blocks of text containing characters which would +otherwise be recognized as markup. CDATA sections begin with the +string "<![CDATA[" and end with the string +"]]>": + +CDATA Sections +CDSect +CDStart +CData +CDEnd +CDStart +'<![CDATA[' + +CData +(Char* - +(Char* ']]>' Char*)) + + +CDEnd +']]>' + + + +Within a CDATA section, only the CDEnd string is +recognized as markup, so that left angle brackets and ampersands may occur in +their literal form; they need not (and cannot) be escaped using +"&lt;" and "&amp;". CDATA sections +cannot nest. +

+ +

An example of a CDATA section, in which "<greeting>" and +"</greeting>" +are recognized as character data, not +markup: +<![CDATA[<greeting>Hello, world!</greeting>]]> +

+
+ + +Prolog and Document Type Declaration + +

XML documents +may, and should, +begin with an XML declaration which specifies +the version of +XML being used. +For example, the following is a complete XML document, well-formed but not +valid: + +Hello, world! +]]> +and so is this: +Hello, world! +]]> +

+ +

The version number "1.0" should be used to indicate +conformance to this version of this specification; it is an error +for a document to use the value "1.0" +if it does not conform to this version of this specification. +It is the intent +of the XML working group to give later versions of this specification +numbers other than "1.0", but this intent does not +indicate a +commitment to produce any future versions of XML, nor if any are produced, to +use any particular numbering scheme. +Since future versions are not ruled out, this construct is provided +as a means to allow the possibility of automatic version recognition, should +it become necessary. +Processors may signal an error if they receive documents labeled with +versions they do not support. +

+

The function of the markup in an XML document is to describe its +storage and logical structure and to associate attribute-value pairs +with its logical structures. XML provides a mechanism, the document type declaration, to define +constraints on the logical structure and to support the use of +predefined storage units. + +An XML document is +valid if it has an associated document type +declaration and if the document +complies with the constraints expressed in it.

+

The document type declaration must appear before +the first element in the document. + +Prolog + +prolog +XMLDecl? +Misc* +(doctypedecl +Misc*)? +XMLDecl +&xmlpio; +VersionInfo +EncodingDecl? +SDDecl? +S? +&pic; + +VersionInfo +S 'version' Eq +(' VersionNum ' +| " VersionNum ") + +Eq +S? '=' S? + +VersionNum +([a-zA-Z0-9_.:] | '-')+ + +Misc +Comment | PI | +S + +

+ +

The XML +document type declaration +contains or points to +markup declarations +that provide a grammar for a +class of documents. +This grammar is known as a document type definition, +or DTD. +The document type declaration can point to an external subset (a +special kind of +external entity) containing markup +declarations, or can +contain the markup declarations directly in an internal subset, or can do +both. +The DTD for a document consists of both subsets taken +together. +

+

+A markup declaration is +an element type declaration, +an attribute-list declaration, +an entity declaration, or +a notation declaration. + +These declarations may be contained in whole or in part +within parameter entities, +as described in the well-formedness and validity constraints below. +For fuller information, see +.

+ +Document Type Definition + +doctypedecl +'<!DOCTYPE' S +Name (S +ExternalID)? +S? ('[' +(markupdecl +| PEReference +| S)* +']' +S?)? '>' + + +markupdecl +elementdecl +| AttlistDecl +| EntityDecl +| NotationDecl +| PI +| Comment + + + + + + + + +

The markup declarations may be made up in whole or in part of +the replacement text of +parameter entities. +The productions later in this specification for +individual nonterminals (elementdecl, +AttlistDecl, and so on) describe +the declarations after all the parameter entities have been +included.

+ + +Root Element Type +

+The Name in the document type declaration must +match the element type of the root element. +

+
+ + +Proper Declaration/PE Nesting +

Parameter-entity +replacement text must be properly nested +with markup declarations. +That is to say, if either the first character +or the last character of a markup +declaration (markupdecl above) +is contained in the replacement text for a +parameter-entity reference, +both must be contained in the same replacement text.

+
+ +PEs in Internal Subset +

In the internal DTD subset, +parameter-entity references +can occur only where markup declarations can occur, not +within markup declarations. (This does not apply to +references that occur in +external parameter entities or to the external subset.) +

+
+

+Like the internal subset, the external subset and +any external parameter entities referred to in the DTD +must consist of a series of complete markup declarations of the types +allowed by the non-terminal symbol +markupdecl, interspersed with white space +or parameter-entity references. +However, portions of the contents +of the +external subset or of external parameter entities may conditionally be ignored +by using +the conditional section +construct; this is not allowed in the internal subset. + + +External Subset + +extSubset +TextDecl? +extSubsetDecl +extSubsetDecl +( +markupdecl +| conditionalSect +| PEReference +| S +)* + + +

+

The external subset and external parameter entities also differ +from the internal subset in that in them, +parameter-entity references +are permitted within markup declarations, +not only between markup declarations.

+

An example of an XML document with a document type declaration: + + +Hello, world! +]]> +The system identifier +"hello.dtd" gives the URI of a DTD for the document.

+

The declarations can also be given locally, as in this +example: + + +]> +Hello, world! +]]> +If both the external and internal subsets are used, the +internal subset is considered to occur before the external subset. + +This has the effect that entity and attribute-list declarations in the +internal subset take precedence over those in the external subset. +

+
+ + +Standalone Document Declaration +

Markup declarations can affect the content of the document, +as passed from an XML processor +to an application; examples are attribute defaults and entity +declarations. +The standalone document declaration, +which may appear as a component of the XML declaration, signals +whether or not there are such declarations which appear external to +the document entity. + +Standalone Document Declaration + +SDDecl + +S +'standalone' Eq +(("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) + + + +

+

+In a standalone document declaration, the value "yes" indicates +that there +are no markup declarations external to the document +entity (either in the DTD external subset, or in an +external parameter entity referenced from the internal subset) +which affect the information passed from the XML processor to +the application. +The value "no" indicates that there are or may be such +external markup declarations. +Note that the standalone document declaration only +denotes the presence of external declarations; the presence, in a +document, of +references to external entities, when those entities are +internally declared, +does not change its standalone status.

+

If there are no external markup declarations, the standalone document +declaration has no meaning. +If there are external markup declarations but there is no standalone +document declaration, the value "no" is assumed.

+

Any XML document for which standalone="no" holds can +be converted algorithmically to a standalone document, +which may be desirable for some network delivery applications.

+ +Standalone Document Declaration +

The standalone document declaration must have +the value "no" if any external markup declarations +contain declarations of:

+

attributes with default values, if +elements to which +these attributes apply appear in the document without +specifications of values for these attributes, or

+

entities (other than &magicents;), +if references to those +entities appear in the document, or

+
+

attributes with values subject to +normalization, where the +attribute appears in the document with a value which will +change as a result of normalization, or

+
+ +

element types with element content, +if white space occurs +directly within any instance of those types. +

+
+ +
+

An example XML declaration with a standalone document declaration:<?xml version="&XML.version;" standalone='yes'?>

+
+ +White Space Handling + +

In editing XML documents, it is often convenient to use "white space" +(spaces, tabs, and blank lines, denoted by the nonterminal +S in this specification) to +set apart the markup for greater readability. Such white space is typically +not intended for inclusion in the delivered version of the document. +On the other hand, "significant" white space that should be preserved in the +delivered version is common, for example in poetry and +source code.

+

An XML processor +must always pass all characters in a document that are not +markup through to the application. A +validating XML processor must also inform the application +which of these characters constitute white space appearing +in element content. +

+

A special attribute +named xml:space may be attached to an element +to signal an intention that in that element, +white space should be preserved by applications. +In valid documents, this attribute, like any other, must be +declared if it is used. +When declared, it must be given as an +enumerated type whose only +possible values are "default" and "preserve". +For example:]]>

+

The value "default" signals that applications' +default white-space processing modes are acceptable for this element; the +value "preserve" indicates the intent that applications preserve +all the white space. +This declared intent is considered to apply to all elements within the content +of the element where it is specified, unless overriden with another instance +of the xml:space attribute. +

+

The root element of any document +is considered to have signaled no intentions as regards application space +handling, unless it provides a value for +this attribute or the attribute is declared with a default value. +

+ +
+ +End-of-Line Handling +

XML parsed entities are often stored in +computer files which, for editing convenience, are organized into lines. +These lines are typically separated by some combination of the characters +carriage-return (#xD) and line-feed (#xA).

+

To simplify the tasks of applications, +wherever an external parsed entity or the literal entity value +of an internal parsed entity contains either the literal +two-character sequence "#xD#xA" or a standalone literal +#xD, an XML processor must +pass to the application the single character #xA. +(This behavior can +conveniently be produced by normalizing all +line breaks to #xA on input, before parsing.) +

+
+ +Language Identification +

In document processing, it is often useful to +identify the natural or formal language +in which the content is +written. +A special attribute named +xml:lang may be inserted in +documents to specify the +language used in the contents and attribute values +of any element in an XML document. +In valid documents, this attribute, like any other, must be +declared if it is used. +The values of the attribute are language identifiers as defined +by , "Tags for the Identification of Languages": + +Language Identification +LanguageID +Langcode +('-' Subcode)* +Langcode +ISO639Code | +IanaCode | +UserCode + +ISO639Code +([a-z] | [A-Z]) ([a-z] | [A-Z]) +IanaCode +('i' | 'I') '-' ([a-z] | [A-Z])+ +UserCode +('x' | 'X') '-' ([a-z] | [A-Z])+ +Subcode +([a-z] | [A-Z])+ + +The Langcode may be any of the following: + +

a two-letter language code as defined by +, "Codes +for the representation of names of languages"

+

a language identifier registered with the Internet +Assigned Numbers Authority ; these begin with the +prefix "i-" (or "I-")

+

a language identifier assigned by the user, or agreed on +between parties in private use; these must begin with the +prefix "x-" or "X-" in order to ensure that they do not conflict +with names later standardized or registered with IANA

+

+

There may be any number of Subcode segments; if +the first +subcode segment exists and the Subcode consists of two +letters, then it must be a country code from +, "Codes +for the representation of names of countries." +If the first +subcode consists of more than two letters, it must be +a subcode for the language in question registered with IANA, +unless the Langcode begins with the prefix +"x-" or +"X-".

+

It is customary to give the language code in lower case, and +the country code (if any) in upper case. +Note that these values, unlike other names in XML documents, +are case insensitive.

+

For example: +The quick brown fox jumps over the lazy dog.

+

What colour is it?

+

What color is it?

+ + Habe nun, ach! Philosophie, + Juristerei, und Medizin + und leider auch Theologie + durchaus studiert mit heißem Bemüh'n. + ]]>

+ +

The intent declared with xml:lang is considered to apply to +all attributes and content of the element where it is specified, +unless overridden with an instance of xml:lang +on another element within that content.

+ +

A simple declaration for xml:lang might take +the form +xml:lang NMTOKEN #IMPLIED +but specific default values may also be given, if appropriate. In a +collection of French poems for English students, with glosses and +notes in English, the xml:lang attribute might be declared this way: + + + ]]> +

+ +
+
+ + + +Logical Structures + +

Each XML document contains one or more +elements, the boundaries of which are +either delimited by start-tags +and end-tags, or, for empty elements, by an empty-element tag. Each element has a type, +identified by name, sometimes called its "generic +identifier" (GI), and may have a set of +attribute specifications. Each attribute specification +has a name and a value. +

+Element +element +EmptyElemTag +| STag content +ETag + + + + +

This specification does not constrain the semantics, use, or (beyond +syntax) names of the element types and attributes, except that names +beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) +are reserved for standardization in this or future versions of this +specification. +

+ +Element Type Match +

+The Name in an element's end-tag must match +the element type in +the start-tag. +

+
+ +Element Valid +

An element is +valid if +there is a declaration matching +elementdecl where the +Name matches the element type, and +one of the following holds:

+ +

The declaration matches EMPTY and the element has no +content.

+

The declaration matches children and +the sequence of +child elements +belongs to the language generated by the regular expression in +the content model, with optional white space (characters +matching the nonterminal S) between each pair +of child elements.

+

The declaration matches Mixed and +the content consists of character +data and child elements +whose types match names in the content model.

+

The declaration matches ANY, and the types +of any child elements have +been declared.

+
+
+ + +Start-Tags, End-Tags, and Empty-Element Tags + +

The beginning of every +non-empty XML element is marked by a start-tag. + +Start-tag + +STag +'<' Name +(S Attribute)* +S? '>' + + +Attribute +Name Eq +AttValue + + + + + +The Name in +the start- and end-tags gives the +element's type. + +The Name-AttValue pairs are +referred to as +the attribute specifications of the element, +with the +Name in each pair +referred to as the attribute name and +the content of the +AttValue (the text between the +' or " delimiters) +as the attribute value. +

+ +Unique Att Spec +

+No attribute name may appear more than once in the same start-tag +or empty-element tag. +

+
+ +Attribute Value Type +

+The attribute must have been declared; the value must be of the type +declared for it. +(For attribute types, see .) +

+
+ +No External Entity References +

+Attribute values cannot contain direct or indirect entity references +to external entities. +

+
+ +No < in Attribute Values +

The replacement text of any entity +referred to directly or indirectly in an attribute +value (other than "&lt;") must not contain +a <. +

+

An example of a start-tag: +<termdef id="dt-dog" term="dog">

+

The end of every element +that begins with a start-tag must +be marked by an end-tag +containing a name that echoes the element's type as given in the +start-tag: + +End-tag + +ETag +'</' Name +S? '>' + + +

+

An example of an end-tag:</termdef>

+

The +text between the start-tag and +end-tag is called the element's +content: + +Content of Elements + +(//. | //@* | //namespace::*) +[self::a or ancestor-or-self::d] + diff --git a/fuzz/seed_corpus/b6d5046653658bb25225dd94ce6c07b0cb084d04 b/fuzz/seed_corpus/b6d5046653658bb25225dd94ce6c07b0cb084d04 new file mode 100644 index 000000000000..158f91c8b82f --- /dev/null +++ b/fuzz/seed_corpus/b6d5046653658bb25225dd94ce6c07b0cb084d04 @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/b6f408a3a503e1d7c06e8ccd92dbcfd7eec654c6 b/fuzz/seed_corpus/b6f408a3a503e1d7c06e8ccd92dbcfd7eec654c6 new file mode 100644 index 000000000000..b97e688124c0 --- /dev/null +++ b/fuzz/seed_corpus/b6f408a3a503e1d7c06e8ccd92dbcfd7eec654c6 @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/fuzz/seed_corpus/b71d03df33da644d74372c7469f533392262071e b/fuzz/seed_corpus/b71d03df33da644d74372c7469f533392262071e new file mode 100644 index 000000000000..28b69d8eee23 --- /dev/null +++ b/fuzz/seed_corpus/b71d03df33da644d74372c7469f533392262071e @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b73857fa60381099a6d8627cf39f8b6c580624de b/fuzz/seed_corpus/b73857fa60381099a6d8627cf39f8b6c580624de new file mode 100644 index 000000000000..01a013c51c3d --- /dev/null +++ b/fuzz/seed_corpus/b73857fa60381099a6d8627cf39f8b6c580624de @@ -0,0 +1 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b7ede270b7df17a6d9c88b2c749d0e4ab85affc9 b/fuzz/seed_corpus/b7ede270b7df17a6d9c88b2c749d0e4ab85affc9 new file mode 100644 index 000000000000..9ad7683e0a0f --- /dev/null +++ b/fuzz/seed_corpus/b7ede270b7df17a6d9c88b2c749d0e4ab85affc9 @@ -0,0 +1,17 @@ + + + + Radial gradient example with three gradient stops + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/b82652a86c1b0352780cda33c30760eeb166a69f b/fuzz/seed_corpus/b82652a86c1b0352780cda33c30760eeb166a69f new file mode 100644 index 000000000000..600365e19558 --- /dev/null +++ b/fuzz/seed_corpus/b82652a86c1b0352780cda33c30760eeb166a69f @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/fuzz/seed_corpus/b8451678adf7bd03b74b089b62ea6e3532d6a85a b/fuzz/seed_corpus/b8451678adf7bd03b74b089b62ea6e3532d6a85a new file mode 100644 index 000000000000..67cbab48c37d --- /dev/null +++ b/fuzz/seed_corpus/b8451678adf7bd03b74b089b62ea6e3532d6a85a @@ -0,0 +1,4 @@ + +]> +Oops, this element was declared EMPTY diff --git a/fuzz/seed_corpus/b8bb2a22a06ca43ed33ec94c1df22ec57ff3fedb b/fuzz/seed_corpus/b8bb2a22a06ca43ed33ec94c1df22ec57ff3fedb new file mode 100644 index 000000000000..afa807c23f4d --- /dev/null +++ b/fuzz/seed_corpus/b8bb2a22a06ca43ed33ec94c1df22ec57ff3fedb @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/b9101ee7d5775e24163b8b5a5ae129103f5143cd b/fuzz/seed_corpus/b9101ee7d5775e24163b8b5a5ae129103f5143cd new file mode 100644 index 000000000000..8d47e2797e2b --- /dev/null +++ b/fuzz/seed_corpus/b9101ee7d5775e24163b8b5a5ae129103f5143cd @@ -0,0 +1,4 @@ + + foobar + foobar + diff --git a/fuzz/seed_corpus/b910d78be99309f293372435a4beb19c58dae1bd b/fuzz/seed_corpus/b910d78be99309f293372435a4beb19c58dae1bd new file mode 100644 index 000000000000..a1ee72bfed3c --- /dev/null +++ b/fuzz/seed_corpus/b910d78be99309f293372435a4beb19c58dae1bd @@ -0,0 +1,7 @@ + + + + + + + diff --git a/fuzz/seed_corpus/bbc8c30cff99d78697c62d67820b5b66175d909d b/fuzz/seed_corpus/bbc8c30cff99d78697c62d67820b5b66175d909d new file mode 100644 index 000000000000..e6cdeea9d262 --- /dev/null +++ b/fuzz/seed_corpus/bbc8c30cff99d78697c62d67820b5b66175d909d @@ -0,0 +1,10 @@ + + + + This is a rectangle + + + + + diff --git a/fuzz/seed_corpus/bc34ba5577cab989aa32e90b54e74e8f01fa7de0 b/fuzz/seed_corpus/bc34ba5577cab989aa32e90b54e74e8f01fa7de0 new file mode 100644 index 000000000000..9ab7ceb3974a --- /dev/null +++ b/fuzz/seed_corpus/bc34ba5577cab989aa32e90b54e74e8f01fa7de0 @@ -0,0 +1,16 @@ + + + + + + Jim Whitehead + Roy Fielding + + + + + + + + + diff --git a/fuzz/seed_corpus/bc414ce2319a4395d2256621c378534061c83102 b/fuzz/seed_corpus/bc414ce2319a4395d2256621c378534061c83102 new file mode 100644 index 000000000000..c3cfacebcbbb --- /dev/null +++ b/fuzz/seed_corpus/bc414ce2319a4395d2256621c378534061c83102 @@ -0,0 +1,182 @@ + + + + + + + + +شهير بلاگ + + + + + + + + + + + + +
+ + + + + +
+  
+
+ +
+ + +
+ + +
+ + + + + + + + + " +elem_td="" +elem_textarea="" +elem_tfoot="" +elem_th="" +elem_thead="" +elem_title="" +elem_tr="" +elem_tt="" +elem_u="" +elem_ul="
    " +elem_var="" + +attr_id=" id=\"\"" +attr_style=" style=\"\"" + +comment="" + +doctype="" +doctype_system="" +doctype_public="" + +pi="" + +ref_lt="<" +ref_gt=">" +ref_amp="&" +ref_apos="'" +ref_quot=""" +ref_dec=" " +ref_hex=" " + +cs_utf8="UTF-8" +cs_utf16="UTF-16" +cs_utf16le="UTF-16LE" +cs_utf16be="UTF-16BE" +cs_ucs2="UCS-2" +cs_ucs4="UCS-4" +cs_latin1="ISO-8859-1" +cs_ascii="ASCII" +cs_ebcdic="EBCDIC" +cs_iso2022jp="ISO-2022-JP" +cs_shift_jis="SHIFT_JIS" +cs_euc_jp="EUC-JP" diff --git a/src/fuzz/regexp.c b/src/fuzz/regexp.c new file mode 100644 index 000000000000..af1210aa17b6 --- /dev/null +++ b/src/fuzz/regexp.c @@ -0,0 +1,47 @@ +/* + * regexp.c: a libFuzzer target to test the regexp module. + * + * See Copyright for the status of this software. + */ + +#include +#include "fuzz.h" + +int +LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, + char ***argv ATTRIBUTE_UNUSED) { + xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); + + return 0; +} + +int +LLVMFuzzerTestOneInput(const char *data, size_t size) { + xmlRegexpPtr regexp; + char *str[2] = { NULL, NULL }; + size_t numStrings; + + if (size > 200) + return(0); + + numStrings = xmlFuzzExtractStrings(data, size, str, 2); + + /* CUR_SCHAR doesn't handle invalid UTF-8 and may cause infinite loops. */ + if (xmlCheckUTF8(BAD_CAST str[0]) != 0) { + regexp = xmlRegexpCompile(BAD_CAST str[0]); + /* xmlRegexpExec has pathological performance in too many cases. */ +#if 0 + if ((regexp != NULL) && (numStrings >= 2)) { + xmlRegexpExec(regexp, BAD_CAST str[1]); + } +#endif + xmlRegFreeRegexp(regexp); + } + + xmlFree(str[0]); + xmlFree(str[1]); + xmlResetLastError(); + + return 0; +} + diff --git a/src/fuzz/regexp.dict b/src/fuzz/regexp.dict new file mode 100644 index 000000000000..30d666dcf3eb --- /dev/null +++ b/src/fuzz/regexp.dict @@ -0,0 +1,155 @@ +quant_any="*" +quant_opt="?" +quant_some="+" +quant_num="{1,2}" + +dot="." +branch="|a" +parens="()" +parens_inner=")(" +pos_group="[a]" +neg_group="[^a]" +class_subtraction="[a-[b]]" + +esc_space="\\s" +esc_initial="\\i" +esc_name="\\c" +esc_digit="\\d" +esc_word="\\w" + +cat_letter="\\p{L}" +cat_mark="\\p{M}" +cat_number="\\p{N}" +cat_punct="\\p{P}" +cat_sym="\\p{S}" +cat_sep="\\p{Z}" +cat_other="\\p{C}" + +block_aegean_numbers="\\p{IsAegeanNumbers}" +block_alphabetic_presentation_forms="\\p{IsAlphabeticPresentationForms}" +block_arabic="\\p{IsArabic}" +block_arabic_presentation_forms_a="\\p{IsArabicPresentationFormsA}" +block_arabic_presentation_forms_b="\\p{IsArabicPresentationFormsB}" +block_armenian="\\p{IsArmenian}" +block_arrows="\\p{IsArrows}" +block_basic_latin="\\p{IsBasicLatin}" +block_bengali="\\p{IsBengali}" +block_block_elements="\\p{IsBlockElements}" +block_bopomofo="\\p{IsBopomofo}" +block_bopomofo_extended="\\p{IsBopomofoExtended}" +block_box_drawing="\\p{IsBoxDrawing}" +block_braille_patterns="\\p{IsBraillePatterns}" +block_buhid="\\p{IsBuhid}" +block_byzantine_musical_symbols="\\p{IsByzantineMusicalSymbols}" +block_c_j_k_compatibility="\\p{IsCJKCompatibility}" +block_c_j_k_compatibility_forms="\\p{IsCJKCompatibilityForms}" +block_c_j_k_compatibility_ideographs="\\p{IsCJKCompatibilityIdeographs}" +block_c_j_k_compatibility_ideographs_supplement="\\p{IsCJKCompatibilityIdeographsSupplement}" +block_c_j_k_radicals_supplement="\\p{IsCJKRadicalsSupplement}" +block_c_j_k_symbolsand_punctuation="\\p{IsCJKSymbolsandPunctuation}" +block_c_j_k_unified_ideographs="\\p{IsCJKUnifiedIdeographs}" +block_c_j_k_unified_ideographs_extension_a="\\p{IsCJKUnifiedIdeographsExtensionA}" +block_cjk_unified_ideographs_extension_b="\\p{IsCJKUnifiedIdeographsExtensionB}" +block_cherokee="\\p{IsCherokee}" +block_combining_diacritical_marks="\\p{IsCombiningDiacriticalMarks}" +block_combining_diacritical_marksfor_symbols="\\p{IsCombiningDiacriticalMarksforSymbols}" +block_combining_half_marks="\\p{IsCombiningHalfMarks}" +block_combining_marksfor_symbols="\\p{IsCombiningMarksforSymbols}" +block_control_pictures="\\p{IsControlPictures}" +block_currency_symbols="\\p{IsCurrencySymbols}" +block_cypriot_syllabary="\\p{IsCypriotSyllabary}" +block_cyrillic="\\p{IsCyrillic}" +block_cyrillic_supplement="\\p{IsCyrillicSupplement}" +block_deseret="\\p{IsDeseret}" +block_devanagari="\\p{IsDevanagari}" +block_dingbats="\\p{IsDingbats}" +block_enclosed_alphanumerics="\\p{IsEnclosedAlphanumerics}" +block_enclosed_cjk_lettersand_months="\\p{IsEnclosedCJKLettersandMonths}" +block_ethiopic="\\p{IsEthiopic}" +block_general_punctuation="\\p{IsGeneralPunctuation}" +block_geometric_shapes="\\p{IsGeometricShapes}" +block_georgian="\\p{IsGeorgian}" +block_gothic="\\p{IsGothic}" +block_greek="\\p{IsGreek}" +block_greek_extended="\\p{IsGreekExtended}" +block_greekand_coptic="\\p{IsGreekandCoptic}" +block_gujarati="\\p{IsGujarati}" +block_gurmukhi="\\p{IsGurmukhi}" +block_halfwidthand_fullwidth_forms="\\p{IsHalfwidthandFullwidthForms}" +block_hangul_compatibility_jamo="\\p{IsHangulCompatibilityJamo}" +block_hangul_jamo="\\p{IsHangulJamo}" +block_hangul_syllables="\\p{IsHangulSyllables}" +block_hanunoo="\\p{IsHanunoo}" +block_hebrew="\\p{IsHebrew}" +block_high_private_use_surrogates="\\p{IsHighPrivateUseSurrogates}" +block_high_surrogates="\\p{IsHighSurrogates}" +block_hiragana="\\p{IsHiragana}" +block_ipa_extensions="\\p{IsIPAExtensions}" +block_ideographic_description_characters="\\p{IsIdeographicDescriptionCharacters}" +block_kanbun="\\p{IsKanbun}" +block_kangxi_radicals="\\p{IsKangxiRadicals}" +block_kannada="\\p{IsKannada}" +block_katakana="\\p{IsKatakana}" +block_katakana_phonetic_extensions="\\p{IsKatakanaPhoneticExtensions}" +block_khmer="\\p{IsKhmer}" +block_khmer_symbols="\\p{IsKhmerSymbols}" +block_lao="\\p{IsLao}" +block_latin1Supplement="\\p{IsLatin1Supplement}" +block_latin_extended_a="\\p{IsLatinExtendedA}" +block_latin_extended_b="\\p{IsLatinExtendedB}" +block_latin_extended_additional="\\p{IsLatinExtendedAdditional}" +block_letterlike_symbols="\\p{IsLetterlikeSymbols}" +block_limbu="\\p{IsLimbu}" +block_linear_b_ideograms="\\p{IsLinearBIdeograms}" +block_linear_b_syllabary="\\p{IsLinearBSyllabary}" +block_low_surrogates="\\p{IsLowSurrogates}" +block_malayalam="\\p{IsMalayalam}" +block_mathematical_alphanumeric_symbols="\\p{IsMathematicalAlphanumericSymbols}" +block_mathematical_operators="\\p{IsMathematicalOperators}" +block_miscellaneous_mathematical_symbols_a="\\p{IsMiscellaneousMathematicalSymbolsA}" +block_miscellaneous_mathematical_symbols_b="\\p{IsMiscellaneousMathematicalSymbolsB}" +block_miscellaneous_symbols="\\p{IsMiscellaneousSymbols}" +block_miscellaneous_symbolsand_arrows="\\p{IsMiscellaneousSymbolsandArrows}" +block_miscellaneous_technical="\\p{IsMiscellaneousTechnical}" +block_mongolian="\\p{IsMongolian}" +block_musical_symbols="\\p{IsMusicalSymbols}" +block_myanmar="\\p{IsMyanmar}" +block_number_forms="\\p{IsNumberForms}" +block_ogham="\\p{IsOgham}" +block_old_italic="\\p{IsOldItalic}" +block_optical_character_recognition="\\p{IsOpticalCharacterRecognition}" +block_oriya="\\p{IsOriya}" +block_osmanya="\\p{IsOsmanya}" +block_phonetic_extensions="\\p{IsPhoneticExtensions}" +block_private_use="\\p{IsPrivateUse}" +block_private_use_area="\\p{IsPrivateUseArea}" +block_runic="\\p{IsRunic}" +block_shavian="\\p{IsShavian}" +block_sinhala="\\p{IsSinhala}" +block_small_form_variants="\\p{IsSmallFormVariants}" +block_spacing_modifier_letters="\\p{IsSpacingModifierLetters}" +block_specials="\\p{IsSpecials}" +block_superscriptsand_subscripts="\\p{IsSuperscriptsandSubscripts}" +block_supplemental_arrows_a="\\p{IsSupplementalArrowsA}" +block_supplemental_arrows_b="\\p{IsSupplementalArrowsB}" +block_supplemental_mathematical_operators="\\p{IsSupplementalMathematicalOperators}" +block_supplementary_private_use_area_a="\\p{IsSupplementaryPrivateUseAreaA}" +block_supplementary_private_use_area_b="\\p{IsSupplementaryPrivateUseAreaB}" +block_syriac="\\p{IsSyriac}" +block_tagalog="\\p{IsTagalog}" +block_tagbanwa="\\p{IsTagbanwa}" +block_tags="\\p{IsTags}" +block_tai_le="\\p{IsTaiLe}" +block_tai_xuan_jing_symbols="\\p{IsTaiXuanJingSymbols}" +block_tamil="\\p{IsTamil}" +block_telugu="\\p{IsTelugu}" +block_thaana="\\p{IsThaana}" +block_thai="\\p{IsThai}" +block_tibetan="\\p{IsTibetan}" +block_ugaritic="\\p{IsUgaritic}" +block_unified_canadian_aboriginal_syllabics="\\p{IsUnifiedCanadianAboriginalSyllabics}" +block_variation_selectors="\\p{IsVariationSelectors}" +block_variation_selectors_supplement="\\p{IsVariationSelectorsSupplement}" +block_yi_radicals="\\p{IsYiRadicals}" +block_yi_syllables="\\p{IsYiSyllables}" +block_yijing_hexagram_symbols="\\p{IsYijingHexagramSymbols}" diff --git a/src/fuzz/schema.c b/src/fuzz/schema.c new file mode 100644 index 000000000000..689bffe3df1e --- /dev/null +++ b/src/fuzz/schema.c @@ -0,0 +1,44 @@ +/* + * schema.c: a libFuzzer target to test the XML Schema processor. + * + * See Copyright for the status of this software. + */ + +#include +#include +#include "fuzz.h" + +int +LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, + char ***argv ATTRIBUTE_UNUSED) { + xmlInitParser(); +#ifdef LIBXML_CATALOG_ENABLED + xmlInitializeCatalog(); +#endif + xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + + return 0; +} + +int +LLVMFuzzerTestOneInput(const char *data, size_t size) { + xmlSchemaParserCtxtPtr pctxt; + + if (size > 50000) + return(0); + + xmlFuzzDataInit(data, size); + xmlFuzzReadEntities(); + + pctxt = xmlSchemaNewParserCtxt(xmlFuzzMainUrl()); + xmlSchemaSetParserErrors(pctxt, xmlFuzzErrorFunc, xmlFuzzErrorFunc, NULL); + xmlSchemaFree(xmlSchemaParse(pctxt)); + xmlSchemaFreeParserCtxt(pctxt); + + xmlFuzzDataCleanup(); + xmlResetLastError(); + + return(0); +} + diff --git a/src/fuzz/schema.dict b/src/fuzz/schema.dict new file mode 100644 index 000000000000..9a8fd386e554 --- /dev/null +++ b/src/fuzz/schema.dict @@ -0,0 +1,55 @@ +# TODO: Add more language elements + +xs_annotation="" + +xs_attribute="" +xs_attribute_required="" +xs_element="" + +# Primitive datatypes +type_string=" type='xs:string'" +type_boolean=" type='xs:boolean'" +type_decimal=" type='xs:decimal'" +type_float=" type='xs:float'" +type_double=" type='xs:double'" +type_date_time=" type='xs:dateTime'" +type_time=" type='xs:time'" +type_date=" type='xs:date'" +type_g_year_month=" type='xs:gYearMonth'" +type_g_year=" type='xs:gYear'" +type_g_month_day=" type='xs:gMonthDay'" +type_g_day=" type='xs:gDay'" +type_g_month=" type='xs:gMonth'" +type_hex_binary=" type='xs:hexBinary'" +type_base64_binary=" type='xs:base64Binary'" +type_any_uri=" type='xs:anyURI'" +type_qname=" type='xs:QName'" +type_notation=" type='xs:NOTATION'" + +# Occurs +occurs_min=" minOccurs='1'" +occurs_max=" maxOccurs='9'" +occurs_max_unbounded=" maxOccurs='unbounded'" + +# Simple type +xs_restriction_integer="" +xs_restriction_string="" +xs_list="" +xs_union="" + +# Restrictions +xs_min_exclusive="" +xs_min_inclusive="" +xs_max_exclusive="" +xs_max_inclusive="" +xs_total_digits="" +xs_fraction_digits="" +xs_length="" +xs_min_length="" +xs_max_length="" +xs_enumeration="" +xs_white_space_collapse="" +xs_white_space_preserve="" +xs_white_space_replace="" +xs_pattern="" + diff --git a/src/fuzz/seed/regexp/branch-1 b/src/fuzz/seed/regexp/branch-1 new file mode 100644 index 0000000000000000000000000000000000000000..ded775eaf70f5e239ff1896eceaec934f6d4680e GIT binary patch literal 21 ccmYeSNzzEEN!3WN$*9THtVz?XNoGg{09CRFc>n+a literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-10 b/src/fuzz/seed/regexp/branch-10 new file mode 100644 index 0000000000000000000000000000000000000000..6700d77519c016dcb21460494592b96fc205dc5a GIT binary patch literal 22 dcmYeSNzzEEN!3WN$*9THtVz?XNoGjO1OQ!@2jc($ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-11 b/src/fuzz/seed/regexp/branch-11 new file mode 100644 index 0000000000000000000000000000000000000000..d83f91819c609ca8a944dd4ceed5326853034f2f GIT binary patch literal 21 ccmYeSNzzEEN!3WN$*9THtVz?XNoGg`09CgKegFUf literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-12 b/src/fuzz/seed/regexp/branch-12 new file mode 100644 index 0000000000000000000000000000000000000000..b44dba5732268407ef24a8f274997aceea009e67 GIT binary patch literal 22 dcmYeSNzzEEN!3WN$*9THtVz?XNoGh)0svi&2ipJu literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-13 b/src/fuzz/seed/regexp/branch-13 new file mode 100644 index 0000000000000000000000000000000000000000..64e50a0000896df6b5a82f044754cde30ec8c73e GIT binary patch literal 22 dcmYeSNzzEEN!3WN$*9THtVz?XNoGh)1^``-2iyPv literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-2 b/src/fuzz/seed/regexp/branch-2 new file mode 100644 index 0000000000000000000000000000000000000000..8293d81dbfbabaf48c7f6062794256151aecebac GIT binary patch literal 21 ccmYeSNzzEEN!3WN$*9THtVz?XNoGg}09CXHdjJ3c literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-3 b/src/fuzz/seed/regexp/branch-3 new file mode 100644 index 0000000000000000000000000000000000000000..696af9bed4d7bae7ec063e2ade8784f4bcb509fc GIT binary patch literal 22 dcmYeSNzzEEN!3WN$*9THtVz?XNoGh&0RUZ*2i^bx literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-4 b/src/fuzz/seed/regexp/branch-4 new file mode 100644 index 0000000000000000000000000000000000000000..83179988e4d3fb34a2d59f9acb418b2a80e12a6f GIT binary patch literal 22 dcmYeSNzzEEN!3WN$*9THtVz?XNoGh&0{~r<2jBnz literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-5 b/src/fuzz/seed/regexp/branch-5 new file mode 100644 index 0000000000000000000000000000000000000000..6b6db8b981e9aa5a2cbe2cc8d1686e3c5cdc129a GIT binary patch literal 23 ecmYeSNzzEEN!3WN$*9THtVz?XNoGh&O$PvF*a$`d literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-6 b/src/fuzz/seed/regexp/branch-6 new file mode 100644 index 0000000000000000000000000000000000000000..4f477902eec648f3156e9b67e415184572972529 GIT binary patch literal 23 ecmYeSNzzEEN!3WN$*9THtVz?XNoGh&%>V#p*$77f literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-7 b/src/fuzz/seed/regexp/branch-7 new file mode 100644 index 0000000000000000000000000000000000000000..6334f7254a13f1a11379024ae43dfabab0859644 GIT binary patch literal 23 ecmYeSNzzEEN!3WN$*9THtVz?XNoGh&%>)2t+6YJh literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-8 b/src/fuzz/seed/regexp/branch-8 new file mode 100644 index 0000000000000000000000000000000000000000..f77a8f4d8ddede806ed6e4c2abc6494d86fc63a2 GIT binary patch literal 21 ccmYeSNzzEEN!3WN$*9THtVz?XNoGg_09CUGdH?_b literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/branch-9 b/src/fuzz/seed/regexp/branch-9 new file mode 100644 index 0000000000000000000000000000000000000000..acd0eeca2d9f467e4ebb7f05f10d78f998950259 GIT binary patch literal 22 dcmYeSNzzEEN!3WN$*9THtVz?XNoGh&1pr-=2j2hy literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-1 b/src/fuzz/seed/regexp/bug316338-1 new file mode 100644 index 0000000000000000000000000000000000000000..9f0a504abee16ef16152d41ed89a5eaaf34c07b1 GIT binary patch literal 71 zcmdPU&~UCv*3{65jwz1SiqW-?Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#MLCdS49j+7C! literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-10 b/src/fuzz/seed/regexp/bug316338-10 new file mode 100644 index 0000000000000000000000000000000000000000..60685bbe5a4fc97d72581cc96144f706baf04a44 GIT binary patch literal 487 zcmdPU&~UCv*3{65jwz1Sj?uM`Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#H>z@ALJ0ufKw#$p literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-11 b/src/fuzz/seed/regexp/bug316338-11 new file mode 100644 index 0000000000000000000000000000000000000000..72a7956cbafe3a5b40bfb74c67de0b79b4bd3cd3 GIT binary patch literal 85 zcmdPU&~UCv*3{65jwz1Sj?uM`Hqf<<)z*m7gD^DhK@wUzU=o|OX0>sxrZ!kwQ&XG4 JS;55E7y!by70&sxrZ!kwQ&XG4 MS;55ESi#T;00kx%QUCw| literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-13 b/src/fuzz/seed/regexp/bug316338-13 new file mode 100644 index 0000000000000000000000000000000000000000..c91d4fea9140ddac84281cdec2e89fad29ffbf93 GIT binary patch literal 89 zcmdPU&~UCv*3{65jwz1Sj?uM`Hqf<<)z*m7gD^DhK@wUzU=o|OX0>sxrZ!kwQ&XG4 NS;55ESi#W97yuiq7KH!+ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-14 b/src/fuzz/seed/regexp/bug316338-14 new file mode 100644 index 0000000000000000000000000000000000000000..a164b42368422db69d175747837a3f9c5ebad84d GIT binary patch literal 93 zcmdPU&~UCv*3{65jwz1Sj?uM`Hqf<<)z*m7gD^DhK@wUzU=o|OX0>sxrZ!kwQ&XG4 RS;55ESi#W9Si!{93;=g~7eoL6 literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-15 b/src/fuzz/seed/regexp/bug316338-15 new file mode 100644 index 0000000000000000000000000000000000000000..750c76dedc5e77cdfa5d35b5681f86075a3959e4 GIT binary patch literal 500 zcmdPU&~UCv*3{65jwz1Sj?uM`Hqf<<)z*m7gD^DhK@wUzU=o|OX0>sxrZ!kwQ&XG4 sS;5@MM9<7b$HdrJ&(KK0+|WYLzyiTD)H5}L^JuMdKrJ6wuj8{F0BIIv;Q#;t literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-16 b/src/fuzz/seed/regexp/bug316338-16 new file mode 100644 index 0000000000000000000000000000000000000000..23c5d230741bfdb247124e8aece21f3806c68649 GIT binary patch literal 1355 zcmdPU(D1Fv)zpZNDUQ{S(Y22@(6x-!)`-!AFf{EoG*W9^HQ_Rv_8^s7I$#nmich^J zSgB@>hK5f~4oxl6hTG&(lR=72nh2d?HDzS#bgoI()SzWJRvXtMIW(}QkjB;-AzK$* zQ%q0m9BUFui3U>BB=M;iq*5E07Yt+3SVX0LQr(3Vzfm<+(43>G#o()8Ze*foW};(a cY^-N!q+o7np=V%$;2G+f8o_y^DhDQ%09s~8MF0Q* literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-2 b/src/fuzz/seed/regexp/bug316338-2 new file mode 100644 index 0000000000000000000000000000000000000000..5468d06dc298a7ea31c2504efa649a3877277832 GIT binary patch literal 74 zcmdPU&~UCv*3{65jwz1SiqW-?Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#MLCdS4JhDHFyq!Kp( literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-3 b/src/fuzz/seed/regexp/bug316338-3 new file mode 100644 index 0000000000000000000000000000000000000000..76e1e0bc37130e7f2a24ab3282f939e7f9ff1f45 GIT binary patch literal 75 zcmdPU&~UCv*3{65jwz1SiqW-?Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#MLCdS4JhDOE!*A5bD literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-4 b/src/fuzz/seed/regexp/bug316338-4 new file mode 100644 index 0000000000000000000000000000000000000000..e0f65a422d5e0b7eb51bbe15e1090981efa84c5d GIT binary patch literal 79 zcmdPU&~UCv*3{65jwz1SiqW-?Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#MLCdS4JhDOE;CZ=WpB7qYr literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-5 b/src/fuzz/seed/regexp/bug316338-5 new file mode 100644 index 0000000000000000000000000000000000000000..fcfaa97a11ff15c424a223d8048a6844b0f65975 GIT binary patch literal 487 zcmdPU&~UCv*3{65jwz1SiqW-?Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#ML=0+xZW+pl&#>RSvMhfPJ7J3F22%e#ysS%tvs&ZgL2>{z>VCDb- literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug316338-6 b/src/fuzz/seed/regexp/bug316338-6 new file mode 100644 index 0000000000000000000000000000000000000000..ce00a15bb2d87cb3443371f894f380bc1cd542b5 GIT binary patch literal 71 zcmdPU&~UCv*3{65jwz1Sj?uM`Hqf<<)z*m7gD^DhH8fIdTs7e`n)aI2#9p28IAn-38D9 literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug420596-2 b/src/fuzz/seed/regexp/bug420596-2 new file mode 100644 index 0000000000000000000000000000000000000000..474d2b6e4315164f731d8f0790412e1b89404d1c GIT binary patch literal 25 ecmdOh(XP?e)G&xP(6x-MF$7YEv6>9J28IAn;|09ph6Vsn-UZMA literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/bug420596-4 b/src/fuzz/seed/regexp/bug420596-4 new file mode 100644 index 0000000000000000000000000000000000000000..65d561eaebafd154aef08b1c1b3ba641b54b23cf GIT binary patch literal 25 ecmdOh(XP?e)G&xP(6x-MF$7YEv6>9Jh6VsnPx# literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/content-2 b/src/fuzz/seed/regexp/content-2 new file mode 100644 index 0000000000000000000000000000000000000000..4e6b663ea0ceb4e554f3c34914e8b446f1ad343a GIT binary patch literal 17 WcmdPUNUTY!N!CnBP19sZ0+IkQr3HZi literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/content-3 b/src/fuzz/seed/regexp/content-3 new file mode 100644 index 0000000000000000000000000000000000000000..b13fc8dbeaa96a2b0d5d096633004002d5dfb3e2 GIT binary patch literal 18 XcmdPUNUTY!N!CnBP19sZ1d{0hHi!l1 literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/content-4 b/src/fuzz/seed/regexp/content-4 new file mode 100644 index 0000000000000000000000000000000000000000..47c5d6de6ce9f84da3e626982e3e3adfaa9fda9b GIT binary patch literal 17 YcmdPUNUTY!N!CnBP19sZOiWD!05F&ZeEk literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ncname-3 b/src/fuzz/seed/regexp/ncname-3 new file mode 100644 index 0000000000000000000000000000000000000000..07a6a0818341fed0d59dfb30c02c265f3c2bb4c6 GIT binary patch literal 23 acma!!$<&Ruij9qqNe0te42em}hA9A7dj}W* literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ncname-4 b/src/fuzz/seed/regexp/ncname-4 new file mode 100644 index 0000000000000000000000000000000000000000..87e937f409e4e9392633f53621e3562c7868c617 GIT binary patch literal 21 Ycma!!$<&Ruij9qqNe0te42Frx07)GNQUCw| literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ncname-5 b/src/fuzz/seed/regexp/ncname-5 new file mode 100644 index 0000000000000000000000000000000000000000..ad294560904266700f0867053125df0089220462 GIT binary patch literal 23 acma!!$<&Ruij9qqNe0te42gzGR>=TX#Rl#G literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-1 b/src/fuzz/seed/regexp/ranges-1 new file mode 100644 index 0000000000000000000000000000000000000000..71448f2396913a83b220368d2dd992bbbdbb9257 GIT binary patch literal 8 PcmYeSHqtS!Wk>`73mF1T literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-10 b/src/fuzz/seed/regexp/ranges-10 new file mode 100644 index 0000000000000000000000000000000000000000..91aed3cf5a584fc4ae3a22feb4ee3954f3a4dc39 GIT binary patch literal 18 ZcmYe)NUBNJtTxgyu1#S`OioTt0RT2c1`902D(5ZvX%Q literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-5 b/src/fuzz/seed/regexp/ranges-5 new file mode 100644 index 0000000000000000000000000000000000000000..83ad4a82a7175ff067a8f9fdd84d4589bd1045d2 GIT binary patch literal 12 TcmYdFtTxgyu1#i0N=ya-8B7D# literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-6 b/src/fuzz/seed/regexp/ranges-6 new file mode 100644 index 0000000000000000000000000000000000000000..3bc9758f9a88096d176afb1e625c38dea90a3dad GIT binary patch literal 13 UcmYdFtTxgyu1#i0N=!@!03Cq@Hvj+t literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-7 b/src/fuzz/seed/regexp/ranges-7 new file mode 100644 index 0000000000000000000000000000000000000000..fa8903840b38d06e7203d6dad8e7f4ad3be18323 GIT binary patch literal 14 VcmYdFtTxgyu1#i0N=!^l1^^-#1egE- literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-8 b/src/fuzz/seed/regexp/ranges-8 new file mode 100644 index 0000000000000000000000000000000000000000..96f0bb690f24e43ffbcb289a6a6ffdf508703d23 GIT binary patch literal 15 UcmYdFtTxgyu1#i0N(6#r04ELv`2YX_ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges-9 b/src/fuzz/seed/regexp/ranges-9 new file mode 100644 index 0000000000000000000000000000000000000000..8e3fc43a4eaa0aeceedcf240bd5278a5df8db550 GIT binary patch literal 17 YcmYe)NUBNJtTxgyu1#S`OiE4x05Ed}YXATM literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges2-1 b/src/fuzz/seed/regexp/ranges2-1 new file mode 100644 index 0000000000000000000000000000000000000000..044a8eb93354c61a57fac6b1ecceb6232091d6d4 GIT binary patch literal 17 WcmdN$tVyai&@ryn1d@ie42b|QYy|!Q literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges2-10 b/src/fuzz/seed/regexp/ranges2-10 new file mode 100644 index 0000000000000000000000000000000000000000..19e2aa2db073df0e7d43ff9bb5c0bd5984c4dd54 GIT binary patch literal 42 gcmdOhHqf<(^b literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges2-7 b/src/fuzz/seed/regexp/ranges2-7 new file mode 100644 index 0000000000000000000000000000000000000000..74fbafb4e2149af7b61f8e53504a583fcea9dac7 GIT binary patch literal 18 XcmdN$tVyai&@ryn1d@ie42ekqG|UBH literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges2-8 b/src/fuzz/seed/regexp/ranges2-8 new file mode 100644 index 0000000000000000000000000000000000000000..125bfa91fcaf982516b4f36f4ae9352c525a962a GIT binary patch literal 18 XcmdN$tVyai&@ryn1d@ie3`vOqG|dHI literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/ranges2-9 b/src/fuzz/seed/regexp/ranges2-9 new file mode 100644 index 0000000000000000000000000000000000000000..f2cf128831dcc02e1566de8470b33630b7615373 GIT binary patch literal 41 fcmdOhHqf<_<% literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-1 b/src/fuzz/seed/regexp/xpath-1 new file mode 100644 index 0000000000000000000000000000000000000000..3bc17926cc6a2377c5ce52a800cb9cbdaf61dd8f GIT binary patch literal 181 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r JSyPK45da#=FW~?H literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-10 b/src/fuzz/seed/regexp/xpath-10 new file mode 100644 index 0000000000000000000000000000000000000000..e4f4b0cdde3e1429cdd34be5ac70329f196937eb GIT binary patch literal 212 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r dSyPJv>e57gC?m;At0qxjOFyXw=$AyRBmj!_Ig$VX literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-11 b/src/fuzz/seed/regexp/xpath-11 new file mode 100644 index 0000000000000000000000000000000000000000..318e0ccf39b4597f6106205b1475d157a666f64b GIT binary patch literal 181 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r JSyPL_5C9sPFR=gs literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-12 b/src/fuzz/seed/regexp/xpath-12 new file mode 100644 index 0000000000000000000000000000000000000000..f204295b26def133263018c368ddb44f0cda4b73 GIT binary patch literal 183 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r LSyPL_Ffj=Ldmk`# literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-13 b/src/fuzz/seed/regexp/xpath-13 new file mode 100644 index 0000000000000000000000000000000000000000..70fccd5917530d5b7bce8c45dac6e4fb51a00f25 GIT binary patch literal 183 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r LSyPK4(aI12doVCe literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-14 b/src/fuzz/seed/regexp/xpath-14 new file mode 100644 index 0000000000000000000000000000000000000000..357ce2b5627e43a1ce516d44736b64f6b3e8d5c4 GIT binary patch literal 182 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r KSyPL_ArSyd$uJ=R literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-15 b/src/fuzz/seed/regexp/xpath-15 new file mode 100644 index 0000000000000000000000000000000000000000..2a10a837029628f05f0f3a0d79f8dc4beefc5e2d GIT binary patch literal 191 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r TSyPK4F)ul_xFo;G$|?~65A!p$ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-16 b/src/fuzz/seed/regexp/xpath-16 new file mode 100644 index 0000000000000000000000000000000000000000..1f3089fb974c72cb5b2d224084e6b74c67c37cb1 GIT binary patch literal 181 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r JSyPKa82}oKFQWhe literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-17 b/src/fuzz/seed/regexp/xpath-17 new file mode 100644 index 0000000000000000000000000000000000000000..a9d542fb6f1bac51a19340d0748d4c585b6af903 GIT binary patch literal 241 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r zSyPKaS)n8&RiU6LwJbBgv{<1iH9fVWKq0LtKNl%nmS3a*W0wQ@Nk#eD Gsd)h9QboJ~ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-18 b/src/fuzz/seed/regexp/xpath-18 new file mode 100644 index 0000000000000000000000000000000000000000..651eb9d4c3a8c7cf3768564c915df70e94b99156 GIT binary patch literal 204 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r gSyPKaSs^2}C{-b|SfL~%RUs|2A~i)JKQGk^0Kg+RkN^Mx literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-19 b/src/fuzz/seed/regexp/xpath-19 new file mode 100644 index 0000000000000000000000000000000000000000..fefea8f1e6c1427d4b5924ff276ce75f48662f33 GIT binary patch literal 262 zcmcJ~u@1r@6op|Q#l+=al5$Cn3ybO6$p^TLA`ud38=&IA!)tv47q@TtbCLrriSP^n z#`$p9dNX@AV$&Cm1tK<<2=rTr0=U6{mQm~udsoV$iGt51%X*Y^deD$Q51uyDWxWM& isMgxOV(7AQHeNe3$7rXLsaL8WmNc#tDWy)*l^EX2#7pM@ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-2 b/src/fuzz/seed/regexp/xpath-2 new file mode 100644 index 0000000000000000000000000000000000000000..81e5fba0a9f4379db64f053ef9f49f61cbf5a06c GIT binary patch literal 241 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r QSyPK4(a=ag$(T$60QZYMwEzGB literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-20 b/src/fuzz/seed/regexp/xpath-20 new file mode 100644 index 0000000000000000000000000000000000000000..1f3089fb974c72cb5b2d224084e6b74c67c37cb1 GIT binary patch literal 181 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r JSyPKa82}oKFQWhe literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-21 b/src/fuzz/seed/regexp/xpath-21 new file mode 100644 index 0000000000000000000000000000000000000000..706a702576f19a885a3ab82ae18b822fb08133b3 GIT binary patch literal 277 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ S{hC@DF*O>4!zG$p42b|27)?4!zG$p42gzD`boxQ5&+tRTO|Mh literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-23 b/src/fuzz/seed/regexp/xpath-23 new file mode 100644 index 0000000000000000000000000000000000000000..02753beb3e4259cc7e3c189dc2eedbb3b653738b GIT binary patch literal 277 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ S{hC@DF*O>4!zG$p3|asd;Y}I< literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-24 b/src/fuzz/seed/regexp/xpath-24 new file mode 100644 index 0000000000000000000000000000000000000000..331105cdce1afab68181b909f6f26d22c4d531c5 GIT binary patch literal 279 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ U{hC@DF*O>4!zG$p42d;K0J9WMF8}}l literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-25 b/src/fuzz/seed/regexp/xpath-25 new file mode 100644 index 0000000000000000000000000000000000000000..ce3da4436759c625c60c974ce793b5f80de1dd77 GIT binary patch literal 282 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ X{hC@DF*O>4!zG$p48Racv`PX1oGMOv literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-26 b/src/fuzz/seed/regexp/xpath-26 new file mode 100644 index 0000000000000000000000000000000000000000..b3bf8c23dd7c8a7a695b2766b0c4f0bd58cb2fc2 GIT binary patch literal 281 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ W{hC@DF*O>4!zG$p42k+l`pE!K4o-9c literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-27 b/src/fuzz/seed/regexp/xpath-27 new file mode 100644 index 0000000000000000000000000000000000000000..74bbe4680aec8a5e6a3db318544bd59882a0c839 GIT binary patch literal 281 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ W{hC@DF*O>4!zG$p42k+$`bhvzWllQ) literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-28 b/src/fuzz/seed/regexp/xpath-28 new file mode 100644 index 0000000000000000000000000000000000000000..b38a709e791eecb2311f909fed936fa0661e8d9c GIT binary patch literal 287 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ b{hC@DF*O>4!zG$p42f1+`bj{XY^4PNDFjcT literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-29 b/src/fuzz/seed/regexp/xpath-29 new file mode 100644 index 0000000000000000000000000000000000000000..104d4e54a151ecd4ac683c0de6e38370a41cc6b1 GIT binary patch literal 295 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ a{hC@DF*O>4!zG$p4A78B)Q2*Xth4~aw^KF% literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-3 b/src/fuzz/seed/regexp/xpath-3 new file mode 100644 index 0000000000000000000000000000000000000000..6d7be85f2d0e027b15d0de87a10654ca6bdf1e19 GIT binary patch literal 181 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r JSyPKa3ji9DFRB0l literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-30 b/src/fuzz/seed/regexp/xpath-30 new file mode 100644 index 0000000000000000000000000000000000000000..b681ff14ac565bb3738c009418adb25ceecbd41f GIT binary patch literal 308 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ n{hC@DF*O>4!zG$p4A78B)Q2*Xth8zp^|kbqYJg#tXq5y27!X$i literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-31 b/src/fuzz/seed/regexp/xpath-31 new file mode 100644 index 0000000000000000000000000000000000000000..cd87b0e8d35abc93990fd3dd08eba75d97724a9d GIT binary patch literal 277 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ S{hC@DF*O>4!zG$p42A#}=uII2 literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-32 b/src/fuzz/seed/regexp/xpath-32 new file mode 100644 index 0000000000000000000000000000000000000000..c5cac32ab94e5e23d59464f53b74523b1ba05181 GIT binary patch literal 279 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ U{hC@DF*O>4!zG$p42FqG0J2U^4!zG$p42f2T0J2|AyZ`_I literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-34 b/src/fuzz/seed/regexp/xpath-34 new file mode 100644 index 0000000000000000000000000000000000000000..b65a3d6ff3a236698f4c73c9f4333450b84390f0 GIT binary patch literal 278 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ T{hC@DF*O>4!zG$p3=W9^WQa|X literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-35 b/src/fuzz/seed/regexp/xpath-35 new file mode 100644 index 0000000000000000000000000000000000000000..252a70c2eb2d608d31aa3185b350d9cfbb176d2d GIT binary patch literal 287 zcmdOh(bL!0wAawkNY2R2NwKm5v7=)$b)&6fW20k|!L$}g6hp8kMoUvuvnEDQQ$wFJ c{hC@DF*O>4!zG$p42gNksl_GvMOIdc05Y*rBme*a literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-4 b/src/fuzz/seed/regexp/xpath-4 new file mode 100644 index 0000000000000000000000000000000000000000..30718c579cb8cc03e1da1dfdb6762a7deee00cf0 GIT binary patch literal 183 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r LSyPK4u_g%sd*v{{ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-5 b/src/fuzz/seed/regexp/xpath-5 new file mode 100644 index 0000000000000000000000000000000000000000..06ad88ef4e896e02d15deabdb294cbba7583d5d5 GIT binary patch literal 186 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r NSyPJv=;B1HBmfMnF$n+w literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-6 b/src/fuzz/seed/regexp/xpath-6 new file mode 100644 index 0000000000000000000000000000000000000000..6678772837df9df7a510f560e5805a1a538fd796 GIT binary patch literal 185 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r NSyPK4Q9nsP835eyF$4er literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-7 b/src/fuzz/seed/regexp/xpath-7 new file mode 100644 index 0000000000000000000000000000000000000000..e69ad856f1191b24c687e23aad0fa4997020088f GIT binary patch literal 185 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r NSyPK4QC~|x2>{$jFv|b{ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-8 b/src/fuzz/seed/regexp/xpath-8 new file mode 100644 index 0000000000000000000000000000000000000000..a8120ccdcc334581d0ebe369f854ab6346b9ff85 GIT binary patch literal 191 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r RSyPK4(Mn4{35b)ev;YQ1GB5xD literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/regexp/xpath-9 b/src/fuzz/seed/regexp/xpath-9 new file mode 100644 index 0000000000000000000000000000000000000000..c037ce7fbd8d0ff91401e82430b7d454f0f65aaa GIT binary patch literal 199 zcmdOh(bL!0wAawkNY2R2NwKm5v12l0lC?lAFry|$OH)&`CPq(FL!UTxnpzq$H5#-r RSyPJv>e57gC?m;A3jnlgHO2q{ literal 0 HcmV?d00001 diff --git a/src/fuzz/seed/uri/dot b/src/fuzz/seed/uri/dot new file mode 100644 index 000000000000..945c9b46d684 --- /dev/null +++ b/src/fuzz/seed/uri/dot @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/src/fuzz/seed/uri/full b/src/fuzz/seed/uri/full new file mode 100644 index 0000000000000000000000000000000000000000..808e58a1522ffbf3e6aeedf4086fc81864360f0c GIT binary patch literal 36 rcmc~ODJihh*Dtjya40v{%P&f|vM|su&@a?a(@V9_wk=amW6%Qt*aiyq literal 0 HcmV?d00001 diff --git a/src/fuzz/testFuzzer.c b/src/fuzz/testFuzzer.c new file mode 100644 index 000000000000..b0c7ffbc9b7c --- /dev/null +++ b/src/fuzz/testFuzzer.c @@ -0,0 +1,188 @@ +/* + * testFuzzer.c: Test program for the custom entity loader used to fuzz + * with multiple inputs. + * + * See Copyright for the status of this software. + */ + +#include +#include +#include +#include +#include +#include "fuzz.h" + +#ifdef HAVE_HTML_FUZZER + #define LLVMFuzzerInitialize fuzzHtmlInit + #define LLVMFuzzerTestOneInput fuzzHtml + #include "html.c" + #undef LLVMFuzzerInitialize + #undef LLVMFuzzerTestOneInput +#endif + +#ifdef HAVE_REGEXP_FUZZER + #define LLVMFuzzerInitialize fuzzRegexpInit + #define LLVMFuzzerTestOneInput fuzzRegexp + #include "regexp.c" + #undef LLVMFuzzerInitialize + #undef LLVMFuzzerTestOneInput +#endif + +#ifdef HAVE_SCHEMA_FUZZER + #define LLVMFuzzerInitialize fuzzSchemaInit + #define LLVMFuzzerTestOneInput fuzzSchema + #include "schema.c" + #undef LLVMFuzzerInitialize + #undef LLVMFuzzerTestOneInput +#endif + +#ifdef HAVE_URI_FUZZER + #define LLVMFuzzerInitialize fuzzUriInit + #define LLVMFuzzerTestOneInput fuzzUri + #include "uri.c" + #undef LLVMFuzzerInitialize + #undef LLVMFuzzerTestOneInput +#endif + +#ifdef HAVE_XML_FUZZER + #define LLVMFuzzerInitialize fuzzXmlInit + #define LLVMFuzzerTestOneInput fuzzXml + #include "xml.c" + #undef LLVMFuzzerInitialize + #undef LLVMFuzzerTestOneInput +#endif + +#ifdef HAVE_XPATH_FUZZER + #define LLVMFuzzerInitialize fuzzXPathInit + #define LLVMFuzzerTestOneInput fuzzXPath + #include "xpath.c" + #undef LLVMFuzzerInitialize + #undef LLVMFuzzerTestOneInput +#endif + +typedef int +(*initFunc)(int *argc, char ***argv); +typedef int +(*fuzzFunc)(const char *data, size_t size); + +int numInputs; + +static int +testFuzzer(initFunc init, fuzzFunc fuzz, const char *pattern) { + glob_t globbuf; + int ret = -1; + int i; + + if (glob(pattern, 0, NULL, &globbuf) != 0) { + fprintf(stderr, "pattern %s matches no files\n", pattern); + return(-1); + } + + if (init != NULL) + init(NULL, NULL); + + for (i = 0; i < globbuf.gl_pathc; i++) { + const char *path = globbuf.gl_pathv[i]; + char *data; + size_t size; + + data = xmlSlurpFile(path, &size); + if (data == NULL) { + fprintf(stderr, "couldn't read %s\n", path); + goto error; + } + fuzz(data, size); + xmlFree(data); + + numInputs++; + } + + ret = 0; +error: + globfree(&globbuf); + return(ret); +} + +#ifdef HAVE_XML_FUZZER +static int +testEntityLoader() { + static const char data[] = + "doc.xml\\\n" + "\n" + "&ent;\\\n" + "doc.dtd\\\n" + "\n" + "\\\n" + "ent.txt\\\n" + "Hello, world!\\\n"; + static xmlChar expected[] = + "\n" + "\n" + "Hello, world!\n"; + const char *docBuffer; + size_t docSize; + xmlDocPtr doc; + xmlChar *out; + int ret = 0; + + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + + xmlFuzzDataInit(data, sizeof(data) - 1); + xmlFuzzReadEntities(); + docBuffer = xmlFuzzMainEntity(&docSize); + doc = xmlReadMemory(docBuffer, docSize, NULL, NULL, + XML_PARSE_NOENT | XML_PARSE_DTDLOAD); + + xmlDocDumpMemory(doc, &out, NULL); + if (xmlStrcmp(out, expected) != 0) { + fprintf(stderr, "Expected:\n%sGot:\n%s", expected, out); + ret = 1; + } + + xmlFree(out); + xmlFreeDoc(doc); + xmlFuzzDataCleanup(); + + return(ret); +} +#endif + +int +main() { + int ret = 0; + +#ifdef HAVE_XML_FUZZER + if (testEntityLoader() != 0) + ret = 1; +#endif +#ifdef HAVE_HTML_FUZZER + if (testFuzzer(fuzzHtmlInit, fuzzHtml, "seed/html/*") != 0) + ret = 1; +#endif +#ifdef HAVE_REGEXP_FUZZER + if (testFuzzer(fuzzRegexpInit, fuzzRegexp, "seed/regexp/*") != 0) + ret = 1; +#endif +#ifdef HAVE_SCHEMA_FUZZER + if (testFuzzer(fuzzSchemaInit, fuzzSchema, "seed/schema/*") != 0) + ret = 1; +#endif +#ifdef HAVE_URI_FUZZER + if (testFuzzer(NULL, fuzzUri, "seed/uri/*") != 0) + ret = 1; +#endif +#ifdef HAVE_XML_FUZZER + if (testFuzzer(fuzzXmlInit, fuzzXml, "seed/xml/*") != 0) + ret = 1; +#endif +#ifdef HAVE_XPATH_FUZZER + if (testFuzzer(fuzzXPathInit, fuzzXPath, "seed/xpath/*") != 0) + ret = 1; +#endif + + if (ret == 0) + printf("Successfully tested %d inputs\n", numInputs); + + return(ret); +} + diff --git a/src/fuzz/uri.c b/src/fuzz/uri.c new file mode 100644 index 000000000000..5e4c099cee50 --- /dev/null +++ b/src/fuzz/uri.c @@ -0,0 +1,48 @@ +/* + * uri.c: a libFuzzer target to test the URI module. + * + * See Copyright for the status of this software. + */ + +#include +#include "fuzz.h" + +int +LLVMFuzzerTestOneInput(const char *data, size_t size) { + xmlURIPtr uri; + char *str[2] = { NULL, NULL }; + size_t numStrings; + + if (size > 10000) + return(0); + + numStrings = xmlFuzzExtractStrings(data, size, str, 2); + + uri = xmlParseURI(str[0]); + xmlFree(xmlSaveUri(uri)); + xmlFreeURI(uri); + + uri = xmlParseURIRaw(str[0], 1); + xmlFree(xmlSaveUri(uri)); + xmlFreeURI(uri); + + xmlFree(xmlURIUnescapeString(str[0], -1, NULL)); + xmlFree(xmlURIEscape(BAD_CAST str[0])); + xmlFree(xmlCanonicPath(BAD_CAST str[0])); + xmlFree(xmlPathToURI(BAD_CAST str[0])); + + if (numStrings >= 2) { + xmlFree(xmlBuildURI(BAD_CAST str[1], BAD_CAST str[0])); + xmlFree(xmlBuildRelativeURI(BAD_CAST str[1], BAD_CAST str[0])); + xmlFree(xmlURIEscapeStr(BAD_CAST str[0], BAD_CAST str[1])); + } + + /* Modifies string, so must come last. */ + xmlNormalizeURIPath(str[0]); + + xmlFree(str[0]); + xmlFree(str[1]); + + return 0; +} + diff --git a/src/fuzz/xml.c b/src/fuzz/xml.c new file mode 100644 index 000000000000..8b4c4efc53f8 --- /dev/null +++ b/src/fuzz/xml.c @@ -0,0 +1,104 @@ +/* + * xml.c: a libFuzzer target to test several XML parser interfaces. + * + * See Copyright for the status of this software. + */ + +#include +#include +#include +#include +#include +#include +#include "fuzz.h" + +int +LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, + char ***argv ATTRIBUTE_UNUSED) { + xmlInitParser(); +#ifdef LIBXML_CATALOG_ENABLED + xmlInitializeCatalog(); +#endif + xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + + return 0; +} + +int +LLVMFuzzerTestOneInput(const char *data, size_t size) { + static const size_t maxChunkSize = 128; + xmlDocPtr doc; + xmlParserCtxtPtr ctxt; + xmlTextReaderPtr reader; + xmlChar *out; + const char *docBuffer, *docUrl; + size_t maxSize, docSize, consumed, chunkSize; + int opts, outSize; + + xmlFuzzDataInit(data, size); + opts = xmlFuzzReadInt(); + + /* Lower maximum size when processing entities for now. */ + maxSize = opts & XML_PARSE_NOENT ? 50000 : 500000; + if (size > maxSize) + goto exit; + + xmlFuzzReadEntities(); + docBuffer = xmlFuzzMainEntity(&docSize); + docUrl = xmlFuzzMainUrl(); + if (docBuffer == NULL) + goto exit; + + /* Pull parser */ + + doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts); + if (opts & XML_PARSE_XINCLUDE) + xmlXIncludeProcessFlags(doc, opts); + /* Also test the serializer. */ + xmlDocDumpMemory(doc, &out, &outSize); + xmlFree(out); + xmlFreeDoc(doc); + + /* Push parser */ + + ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, docUrl); + if (ctxt == NULL) + goto exit; + xmlCtxtUseOptions(ctxt, opts); + + for (consumed = 0; consumed < docSize; consumed += chunkSize) { + chunkSize = docSize - consumed; + if (chunkSize > maxChunkSize) + chunkSize = maxChunkSize; + xmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0); + } + + xmlParseChunk(ctxt, NULL, 0, 1); + if (opts & XML_PARSE_XINCLUDE) + xmlXIncludeProcessFlags(ctxt->myDoc, opts); + xmlFreeDoc(ctxt->myDoc); + xmlFreeParserCtxt(ctxt); + + /* Reader */ + + reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts); + if (reader == NULL) + goto exit; + while (xmlTextReaderRead(reader) == 1) { + if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) { + int i, n = xmlTextReaderAttributeCount(reader); + for (i=0; i +#include +#include "fuzz.h" + +int +LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, + char ***argv ATTRIBUTE_UNUSED) { + xmlInitParser(); + xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); + + return 0; +} + +int +LLVMFuzzerTestOneInput(const char *data, size_t size) { + xmlDocPtr doc; + const char *expr, *xml; + size_t exprSize, xmlSize; + + if (size > 10000) + return(0); + + xmlFuzzDataInit(data, size); + + expr = xmlFuzzReadString(&exprSize); + xml = xmlFuzzReadString(&xmlSize); + + /* Recovery mode allows more input to be fuzzed. */ + doc = xmlReadMemory(xml, xmlSize, NULL, NULL, XML_PARSE_RECOVER); + if (doc != NULL) { + xmlXPathContextPtr xpctxt = xmlXPathNewContext(doc); + + /* Operation limit to avoid timeout */ + xpctxt->opLimit = 500000; + + xmlXPathFreeObject(xmlXPtrEval(BAD_CAST expr, xpctxt)); + xmlXPathFreeContext(xpctxt); + } + xmlFreeDoc(doc); + + xmlFuzzDataCleanup(); + xmlResetLastError(); + + return(0); +} + diff --git a/src/fuzz/xpath.dict b/src/fuzz/xpath.dict new file mode 100644 index 000000000000..4fe375fbcda6 --- /dev/null +++ b/src/fuzz/xpath.dict @@ -0,0 +1,94 @@ +# XML + +elem_a="" +elem_b="" +elem_c="" +elem_d="" +elem_empty="" +elem_ns_a="" +elem_ns_b="" + +attr_a=" a='a'" +attr_b=" b='b'" + +ns_decl=" xmlns:a='a'" +ns_default=" xmlns='a'" +ns_prefix_a="a:" +ns_prefix_b="b:" + +cdata_section="" + +comment="" + +pi="" + +# XPath + +axis_ancestor="ancestor::" +axis_ancestor_or_self="ancestor-or-self::" +axis_attribute="attribute::" +axis_attribute_abbrev="@" +axis_child="child::" +axis_descendant="descendant::" +axis_descendant_or_self="descendant-or-self::" +axis_following="following::" +axis_following_sibling="following-sibling::" +axis_namespace="namespace::" +axis_parent="parent::" +axis_preceding="preceding::" +axis_preceding_siblings="preceding-sibling::" +axis_self="self::" + +node_test_ns="a:" + +val_num="=(1.0)" +val_str_sq="=('a')" +val_str_dq="=(\"a\")" +val_node_set="=(*)" +val_elem="=(b)" + +step_root="/" +step_descendant="//" +step_any="//*" +step_any_l="*//" +step_elem="//b" +step_ns_elem="//a:a" +step_comment="//comment()" +step_node="//node()" +step_node_l="node()//" +step_pi="//processing-instruction()" +step_text="//text()" +step_parent="../" + +op_plus="+1" +op_minus=" - 1" +op_neg="-" +op_mul="*1" +op_div=" div 1" +op_mod=" mod 1" +op_and=" and 1" +op_or=" or 1" +op_ne="!=1" +op_lt="<1" +op_gt=">1" +op_le="<=1" +op_ge=">=1" +op_predicate_num="[1]" +op_predicate_last="[last()]" +op_predicate_str="['a']" +op_predicate="[1=1]" +op_arg_num=",1" +op_arg_str=",'a'" +op_arg_node=",*" +op_union="|//b" + +var_num="=$f" +var_bool="=$b" +var_str="=$s" +var_node_set="=$n" + +# Unicode + +utf8_2="\xC3\x84" +utf8_3="\xE2\x80\x9C" +utf8_4="\xF0\x9F\x98\x80" diff --git a/src/genUnicode.py b/src/genUnicode.py new file mode 100755 index 000000000000..4487eeb5cac7 --- /dev/null +++ b/src/genUnicode.py @@ -0,0 +1,478 @@ +#!/usr/bin/python -u +# +# Original script modified in November 2003 to take advantage of +# the character-validation range routines, and updated to the +# current Unicode information (Version 4.0.1) +# +# NOTE: there is an 'alias' facility for blocks which are not present in +# the current release, but are needed for ABI compatibility. This +# must be accomplished MANUALLY! Please see the comments below under +# 'blockAliases' +# +import sys +import string +import time + +webpage = "http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html" +sources = "Blocks-4.0.1.txt UnicodeData-4.0.1.txt" + +# +# blockAliases is a small hack - it is used for mapping block names which +# were were used in the 3.1 release, but are missing or changed in the current +# release. The format is "OldBlockName:NewBlockName1[,NewBlockName2[,...]]" +blockAliases = [] +blockAliases.append("CombiningMarksforSymbols:CombiningDiacriticalMarksforSymbols") +blockAliases.append("Greek:GreekandCoptic") +blockAliases.append("PrivateUse:PrivateUseArea,SupplementaryPrivateUseArea-A," + + "SupplementaryPrivateUseArea-B") + +# minTableSize gives the minimum number of ranges which must be present +# before a range table is produced. If there are less than this +# number, inline comparisons are generated +minTableSize = 8 + +(blockfile, catfile) = string.split(sources) + + +# +# Now process the "blocks" file, reducing it to a dictionary +# indexed by blockname, containing a tuple with the applicable +# block range +# +BlockNames = {} +try: + blocks = open(blockfile, "r") +except: + print "Missing %s, aborting ..." % blockfile + sys.exit(1) + +for line in blocks.readlines(): + if line[0] == '#': + continue + line = string.strip(line) + if line == '': + continue + try: + fields = string.split(line, ';') + range = string.strip(fields[0]) + (start, end) = string.split(range, "..") + name = string.strip(fields[1]) + name = string.replace(name, ' ', '') + except: + print "Failed to process line: %s" % (line) + continue + start = "0x" + start + end = "0x" + end + try: + BlockNames[name].append((start, end)) + except: + BlockNames[name] = [(start, end)] +blocks.close() +print "Parsed %d blocks descriptions" % (len(BlockNames.keys())) + +for block in blockAliases: + alias = string.split(block,':') + alist = string.split(alias[1],',') + for comp in alist: + if BlockNames.has_key(comp): + if alias[0] not in BlockNames: + BlockNames[alias[0]] = [] + for r in BlockNames[comp]: + BlockNames[alias[0]].append(r) + else: + print "Alias %s: %s not in Blocks" % (alias[0], comp) + continue + +# +# Next process the Categories file. This is more complex, since +# the file is in code sequence, and we need to invert it. We use +# a dictionary with index category-name, with each entry containing +# all the ranges (codepoints) of that category. Note that category +# names comprise two parts - the general category, and the "subclass" +# within that category. Therefore, both "general category" (which is +# the first character of the 2-character category-name) and the full +# (2-character) name are entered into this dictionary. +# +try: + data = open(catfile, "r") +except: + print "Missing %s, aborting ..." % catfile + sys.exit(1) + +nbchar = 0; +Categories = {} +for line in data.readlines(): + if line[0] == '#': + continue + line = string.strip(line) + if line == '': + continue + try: + fields = string.split(line, ';') + point = string.strip(fields[0]) + value = 0 + while point != '': + value = value * 16 + if point[0] >= '0' and point[0] <= '9': + value = value + ord(point[0]) - ord('0') + elif point[0] >= 'A' and point[0] <= 'F': + value = value + 10 + ord(point[0]) - ord('A') + elif point[0] >= 'a' and point[0] <= 'f': + value = value + 10 + ord(point[0]) - ord('a') + point = point[1:] + name = fields[2] + except: + print "Failed to process line: %s" % (line) + continue + + nbchar = nbchar + 1 + # update entry for "full name" + try: + Categories[name].append(value) + except: + try: + Categories[name] = [value] + except: + print "Failed to process line: %s" % (line) + # update "general category" name + try: + Categories[name[0]].append(value) + except: + try: + Categories[name[0]] = [value] + except: + print "Failed to process line: %s" % (line) + +blocks.close() +print "Parsed %d char generating %d categories" % (nbchar, len(Categories.keys())) + +# +# The data is now all read. Time to process it into a more useful form. +# +# reduce the number list into ranges +for cat in Categories.keys(): + list = Categories[cat] + start = -1 + prev = -1 + end = -1 + ranges = [] + for val in list: + if start == -1: + start = val + prev = val + continue + elif val == prev + 1: + prev = val + continue + elif prev == start: + ranges.append((prev, prev)) + start = val + prev = val + continue + else: + ranges.append((start, prev)) + start = val + prev = val + continue + if prev == start: + ranges.append((prev, prev)) + else: + ranges.append((start, prev)) + Categories[cat] = ranges + +# +# Assure all data is in alphabetic order, since we will be doing binary +# searches on the tables. +# +bkeys = BlockNames.keys() +bkeys.sort() + +ckeys = Categories.keys() +ckeys.sort() + +# +# Generate the resulting files +# +try: + header = open("include/libxml/xmlunicode.h", "w") +except: + print "Failed to open include/libxml/xmlunicode.h" + sys.exit(1) + +try: + output = open("xmlunicode.c", "w") +except: + print "Failed to open xmlunicode.c" + sys.exit(1) + +date = time.asctime(time.localtime(time.time())) + +header.write( +"""/* + * Summary: Unicode character APIs + * Description: API for the Unicode character APIs + * + * This file is automatically generated from the + * UCS description files of the Unicode Character Database + * %s + * using the genUnicode.py Python script. + * + * Generation date: %s + * Sources: %s + * Author: Daniel Veillard + */ + +#ifndef __XML_UNICODE_H__ +#define __XML_UNICODE_H__ + +#include + +#ifdef LIBXML_UNICODE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +""" % (webpage, date, sources)); + +output.write( +"""/* + * xmlunicode.c: this module implements the Unicode character APIs + * + * This file is automatically generated from the + * UCS description files of the Unicode Character Database + * %s + * using the genUnicode.py Python script. + * + * Generation date: %s + * Sources: %s + * Daniel Veillard + */ + +#define IN_LIBXML +#include "libxml.h" + +#ifdef LIBXML_UNICODE_ENABLED + +#include +#include +#include +#include + +typedef int (xmlIntFunc)(int); /* just to keep one's mind untwisted */ + +typedef struct { + const char *rangename; + xmlIntFunc *func; +} xmlUnicodeRange; + +typedef struct { + const xmlUnicodeRange *table; + int numentries; +} xmlUnicodeNameTable; + + +static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname); + +static const xmlUnicodeRange xmlUnicodeBlocks[] = { +""" % (webpage, date, sources)); + +flag = 0 +for block in bkeys: + name = string.replace(block, '-', '') + if flag: + output.write(',\n') + else: + flag = 1 + output.write(' {"%s", xmlUCSIs%s}' % (block, name)) +output.write('};\n\n') + +output.write('static xmlUnicodeRange xmlUnicodeCats[] = {\n') +flag = 0; +for name in ckeys: + if flag: + output.write(',\n') + else: + flag = 1 + output.write(' {"%s", xmlUCSIsCat%s}' % (name, name)) +output.write('};\n\n') + +# +# For any categories with more than minTableSize ranges we generate +# a range table suitable for xmlCharInRange +# +for name in ckeys: + if len(Categories[name]) > minTableSize: + numshort = 0 + numlong = 0 + ranges = Categories[name] + sptr = "NULL" + lptr = "NULL" + for range in ranges: + (low, high) = range + if high < 0x10000: + if numshort == 0: + pline = "static const xmlChSRange xml%sS[] = {" % name + sptr = "xml%sS" % name + else: + pline += ", " + numshort += 1 + else: + if numlong == 0: + if numshort > 0: + output.write(pline + " };\n") + pline = "static const xmlChLRange xml%sL[] = {" % name + lptr = "xml%sL" % name + else: + pline += ", " + numlong += 1 + if len(pline) > 60: + output.write(pline + "\n") + pline = " " + pline += "{%s, %s}" % (hex(low), hex(high)) + output.write(pline + " };\nstatic xmlChRangeGroup xml%sG = {%s,%s,%s,%s};\n\n" + % (name, numshort, numlong, sptr, lptr)) + + +output.write( +"""static xmlUnicodeNameTable xmlUnicodeBlockTbl = {xmlUnicodeBlocks, %s}; +static xmlUnicodeNameTable xmlUnicodeCatTbl = {xmlUnicodeCats, %s}; + +/** + * xmlUnicodeLookup: + * @tptr: pointer to the name table + * @name: name to be found + * + * binary table lookup for user-supplied name + * + * Returns pointer to range function if found, otherwise NULL + */ +static xmlIntFunc +*xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname) { + int low, high, mid, cmp; + xmlUnicodeRange *sptr; + + if ((tptr == NULL) || (tname == NULL)) return(NULL); + + low = 0; + high = tptr->numentries - 1; + sptr = tptr->table; + while (low <= high) { + mid = (low + high) / 2; + if ((cmp=strcmp(tname, sptr[mid].rangename)) == 0) + return (sptr[mid].func); + if (cmp < 0) + high = mid - 1; + else + low = mid + 1; + } + return (NULL); +} + +""" % (len(BlockNames), len(Categories)) ) + +for block in bkeys: + name = string.replace(block, '-', '') + header.write("XMLPUBFUN int XMLCALL xmlUCSIs%s\t(int code);\n" % name) + output.write("/**\n * xmlUCSIs%s:\n * @code: UCS code point\n" % (name)) + output.write(" *\n * Check whether the character is part of %s UCS Block\n"% + (block)) + output.write(" *\n * Returns 1 if true 0 otherwise\n */\n"); + output.write("int\nxmlUCSIs%s(int code) {\n return(" % name) + flag = 0 + for (start, end) in BlockNames[block]: + if flag: + output.write(" ||\n ") + else: + flag = 1 + output.write("((code >= %s) && (code <= %s))" % (start, end)) + output.write(");\n}\n\n") + +header.write("\nXMLPUBFUN int XMLCALL xmlUCSIsBlock\t(int code, const char *block);\n\n") +output.write( +"""/** + * xmlUCSIsBlock: + * @code: UCS code point + * @block: UCS block name + * + * Check whether the character is part of the UCS Block + * + * Returns 1 if true, 0 if false and -1 on unknown block + */ +int +xmlUCSIsBlock(int code, const char *block) { + xmlIntFunc *func; + + func = xmlUnicodeLookup(&xmlUnicodeBlockTbl, block); + if (func == NULL) + return (-1); + return (func(code)); +} + +""") + +for name in ckeys: + ranges = Categories[name] + header.write("XMLPUBFUN int XMLCALL xmlUCSIsCat%s\t(int code);\n" % name) + output.write("/**\n * xmlUCSIsCat%s:\n * @code: UCS code point\n" % (name)) + output.write(" *\n * Check whether the character is part of %s UCS Category\n"% + (name)) + output.write(" *\n * Returns 1 if true 0 otherwise\n */\n"); + output.write("int\nxmlUCSIsCat%s(int code) {\n" % name) + if len(Categories[name]) > minTableSize: + output.write(" return(xmlCharInRange((unsigned int)code, &xml%sG)" + % name) + else: + start = 1 + for range in ranges: + (begin, end) = range; + if start: + output.write(" return("); + start = 0 + else: + output.write(" ||\n "); + if (begin == end): + output.write("(code == %s)" % (hex(begin))) + else: + output.write("((code >= %s) && (code <= %s))" % ( + hex(begin), hex(end))) + output.write(");\n}\n\n") + +header.write("\nXMLPUBFUN int XMLCALL xmlUCSIsCat\t(int code, const char *cat);\n") +output.write( +"""/** + * xmlUCSIsCat: + * @code: UCS code point + * @cat: UCS Category name + * + * Check whether the character is part of the UCS Category + * + * Returns 1 if true, 0 if false and -1 on unknown category + */ +int +xmlUCSIsCat(int code, const char *cat) { + xmlIntFunc *func; + + func = xmlUnicodeLookup(&xmlUnicodeCatTbl, cat); + if (func == NULL) + return (-1); + return (func(code)); +} + +#define bottom_xmlunicode +#include "elfgcchack.h" +#endif /* LIBXML_UNICODE_ENABLED */ +""") + +header.write(""" +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_UNICODE_ENABLED */ + +#endif /* __XML_UNICODE_H__ */ +"""); + +header.close() +output.close() diff --git a/src/gentest.py b/src/gentest.py new file mode 100755 index 000000000000..b6cd866c1b23 --- /dev/null +++ b/src/gentest.py @@ -0,0 +1,989 @@ +#!/usr/bin/python -u +# +# generate a tester program for the API +# +import sys +import os +import string +try: + import libxml2 +except: + print "libxml2 python bindings not available, skipping testapi.c generation" + sys.exit(0) + +if len(sys.argv) > 1: + srcPref = sys.argv[1] + '/' +else: + srcPref = '' + +# +# Modules we want to skip in API test +# +skipped_modules = [ "SAX", "xlink", "threads", "globals", + "xmlmemory", "xmlversion", "xmlexports", + #deprecated + "DOCBparser", +] + +# +# defines for each module +# +modules_defines = { + "HTMLparser": "LIBXML_HTML_ENABLED", + "catalog": "LIBXML_CATALOG_ENABLED", + "xmlreader": "LIBXML_READER_ENABLED", + "relaxng": "LIBXML_SCHEMAS_ENABLED", + "schemasInternals": "LIBXML_SCHEMAS_ENABLED", + "xmlschemas": "LIBXML_SCHEMAS_ENABLED", + "xmlschemastypes": "LIBXML_SCHEMAS_ENABLED", + "xpath": "LIBXML_XPATH_ENABLED", + "xpathInternals": "LIBXML_XPATH_ENABLED", + "xinclude": "LIBXML_XINCLUDE_ENABLED", + "xpointer": "LIBXML_XPTR_ENABLED", + "xmlregexp" : "LIBXML_REGEXP_ENABLED", + "xmlautomata" : "LIBXML_AUTOMATA_ENABLED", + "xmlsave" : "LIBXML_OUTPUT_ENABLED", + "DOCBparser" : "LIBXML_DOCB_ENABLED", + "xmlmodule" : "LIBXML_MODULES_ENABLED", + "pattern" : "LIBXML_PATTERN_ENABLED", + "schematron" : "LIBXML_SCHEMATRON_ENABLED", +} + +# +# defines for specific functions +# +function_defines = { + "htmlDefaultSAXHandlerInit": "LIBXML_HTML_ENABLED", + "xmlSAX2EndElement" : "LIBXML_SAX1_ENABLED", + "xmlSAX2StartElement" : "LIBXML_SAX1_ENABLED", + "xmlSAXDefaultVersion" : "LIBXML_SAX1_ENABLED", + "UTF8Toisolat1" : "LIBXML_OUTPUT_ENABLED", + "xmlCleanupPredefinedEntities": "LIBXML_LEGACY_ENABLED", + "xmlInitializePredefinedEntities": "LIBXML_LEGACY_ENABLED", + "xmlSetFeature": "LIBXML_LEGACY_ENABLED", + "xmlGetFeature": "LIBXML_LEGACY_ENABLED", + "xmlGetFeaturesList": "LIBXML_LEGACY_ENABLED", + "xmlIOParseDTD": "LIBXML_VALID_ENABLED", + "xmlParseDTD": "LIBXML_VALID_ENABLED", + "xmlParseDoc": "LIBXML_SAX1_ENABLED", + "xmlParseMemory": "LIBXML_SAX1_ENABLED", + "xmlRecoverDoc": "LIBXML_SAX1_ENABLED", + "xmlParseFile": "LIBXML_SAX1_ENABLED", + "xmlRecoverFile": "LIBXML_SAX1_ENABLED", + "xmlRecoverMemory": "LIBXML_SAX1_ENABLED", + "xmlSAXParseFileWithData": "LIBXML_SAX1_ENABLED", + "xmlSAXParseMemory": "LIBXML_SAX1_ENABLED", + "xmlSAXUserParseMemory": "LIBXML_SAX1_ENABLED", + "xmlSAXParseDoc": "LIBXML_SAX1_ENABLED", + "xmlSAXParseDTD": "LIBXML_SAX1_ENABLED", + "xmlSAXUserParseFile": "LIBXML_SAX1_ENABLED", + "xmlParseEntity": "LIBXML_SAX1_ENABLED", + "xmlParseExternalEntity": "LIBXML_SAX1_ENABLED", + "xmlSAXParseMemoryWithData": "LIBXML_SAX1_ENABLED", + "xmlParseBalancedChunkMemory": "LIBXML_SAX1_ENABLED", + "xmlParseBalancedChunkMemoryRecover": "LIBXML_SAX1_ENABLED", + "xmlSetupParserForBuffer": "LIBXML_SAX1_ENABLED", + "xmlStopParser": "LIBXML_PUSH_ENABLED", + "xmlAttrSerializeTxtContent": "LIBXML_OUTPUT_ENABLED", + "xmlSAXParseFile": "LIBXML_SAX1_ENABLED", + "xmlSAXParseEntity": "LIBXML_SAX1_ENABLED", + "xmlNewTextChild": "LIBXML_TREE_ENABLED", + "xmlNewDocRawNode": "LIBXML_TREE_ENABLED", + "xmlNewProp": "LIBXML_TREE_ENABLED", + "xmlReconciliateNs": "LIBXML_TREE_ENABLED", + "xmlValidateNCName": "LIBXML_TREE_ENABLED", + "xmlValidateNMToken": "LIBXML_TREE_ENABLED", + "xmlValidateName": "LIBXML_TREE_ENABLED", + "xmlNewChild": "LIBXML_TREE_ENABLED", + "xmlValidateQName": "LIBXML_TREE_ENABLED", + "xmlSprintfElementContent": "LIBXML_OUTPUT_ENABLED", + "xmlValidGetPotentialChildren" : "LIBXML_VALID_ENABLED", + "xmlValidGetValidElements" : "LIBXML_VALID_ENABLED", + "docbDefaultSAXHandlerInit" : "LIBXML_DOCB_ENABLED", + "xmlTextReaderPreservePattern" : "LIBXML_PATTERN_ENABLED", +} + +# +# Some functions really need to be skipped for the tests. +# +skipped_functions = [ +# block on I/O +"xmlFdRead", "xmlReadFd", "xmlCtxtReadFd", +"htmlFdRead", "htmlReadFd", "htmlCtxtReadFd", +"xmlReaderNewFd", "xmlReaderForFd", +"xmlIORead", "xmlReadIO", "xmlCtxtReadIO", +"htmlIORead", "htmlReadIO", "htmlCtxtReadIO", +"xmlReaderNewIO", "xmlBufferDump", "xmlNanoFTPConnect", +"xmlNanoFTPConnectTo", "xmlNanoHTTPMethod", "xmlNanoHTTPMethodRedir", +# Complex I/O APIs +"xmlCreateIOParserCtxt", "xmlParserInputBufferCreateIO", +"xmlRegisterInputCallbacks", "xmlReaderForIO", +"xmlOutputBufferCreateIO", "xmlRegisterOutputCallbacks", +"xmlSaveToIO", "xmlIOHTTPOpenW", +# library state cleanup, generate false leak information and other +# troubles, heavillyb tested otherwise. +"xmlCleanupParser", "xmlRelaxNGCleanupTypes", "xmlSetListDoc", +"xmlSetTreeDoc", "xmlUnlinkNode", +# hard to avoid leaks in the tests +"xmlStrcat", "xmlStrncat", "xmlCatalogAddLocal", "xmlNewTextWriterDoc", +"xmlXPathNewValueTree", "xmlXPathWrapString", +# unimplemented +"xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml", +"xmlTextReaderReadString", +# destructor +"xmlListDelete", "xmlOutputBufferClose", "xmlNanoFTPClose", "xmlNanoHTTPClose", +# deprecated +"xmlCatalogGetPublic", "xmlCatalogGetSystem", "xmlEncodeEntities", +"xmlNewGlobalNs", "xmlHandleEntity", "xmlNamespaceParseNCName", +"xmlNamespaceParseNSDef", "xmlNamespaceParseQName", +"xmlParseNamespace", "xmlParseQuotedString", "xmlParserHandleReference", +"xmlScanName", +"xmlDecodeEntities", +# allocators +"xmlMemFree", +# verbosity +"xmlCatalogSetDebug", "xmlShellPrintXPathError", "xmlShellPrintNode", +# Internal functions, no user space should really call them +"xmlParseAttribute", "xmlParseAttributeListDecl", "xmlParseName", +"xmlParseNmtoken", "xmlParseEntityValue", "xmlParseAttValue", +"xmlParseSystemLiteral", "xmlParsePubidLiteral", "xmlParseCharData", +"xmlParseExternalID", "xmlParseComment", "xmlParsePITarget", "xmlParsePI", +"xmlParseNotationDecl", "xmlParseEntityDecl", "xmlParseDefaultDecl", +"xmlParseNotationType", "xmlParseEnumerationType", "xmlParseEnumeratedType", +"xmlParseAttributeType", "xmlParseAttributeListDecl", +"xmlParseElementMixedContentDecl", "xmlParseElementChildrenContentDecl", +"xmlParseElementContentDecl", "xmlParseElementDecl", "xmlParseMarkupDecl", +"xmlParseCharRef", "xmlParseEntityRef", "xmlParseReference", +"xmlParsePEReference", "xmlParseDocTypeDecl", "xmlParseAttribute", +"xmlParseStartTag", "xmlParseEndTag", "xmlParseCDSect", "xmlParseContent", +"xmlParseElement", "xmlParseVersionNum", "xmlParseVersionInfo", +"xmlParseEncName", "xmlParseEncodingDecl", "xmlParseSDDecl", +"xmlParseXMLDecl", "xmlParseTextDecl", "xmlParseMisc", +"xmlParseExternalSubset", "xmlParserHandlePEReference", +"xmlSkipBlankChars", +] + +# +# These functions have side effects on the global state +# and hence generate errors on memory allocation tests +# +skipped_memcheck = [ "xmlLoadCatalog", "xmlAddEncodingAlias", + "xmlSchemaInitTypes", "xmlNanoFTPProxy", "xmlNanoFTPScanProxy", + "xmlNanoHTTPScanProxy", "xmlResetLastError", "xmlCatalogConvert", + "xmlCatalogRemove", "xmlLoadCatalogs", "xmlCleanupCharEncodingHandlers", + "xmlInitCharEncodingHandlers", "xmlCatalogCleanup", + "xmlSchemaGetBuiltInType", + "htmlParseFile", "htmlCtxtReadFile", # loads the catalogs + "xmlTextReaderSchemaValidate", "xmlSchemaCleanupTypes", # initialize the schemas type system + "xmlCatalogResolve", "xmlIOParseDTD" # loads the catalogs +] + +# +# Extra code needed for some test cases +# +extra_pre_call = { + "xmlSAXUserParseFile": """ +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif +""", + "xmlSAXUserParseMemory": """ +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif +""", + "xmlParseBalancedChunkMemory": """ +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif +""", + "xmlParseBalancedChunkMemoryRecover": """ +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif +""", + "xmlParserInputBufferCreateFd": + "if (fd >= 0) fd = -1;", +} +extra_post_call = { + "xmlAddChild": + "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", + "xmlAddEntity": + "if (ret_val != NULL) { xmlFreeNode(ret_val) ; ret_val = NULL; }", + "xmlAddChildList": + "if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }", + "xmlAddSibling": + "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", + "xmlAddNextSibling": + "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", + "xmlAddPrevSibling": + "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", + "xmlDocSetRootElement": + "if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }", + "xmlReplaceNode": + """if (cur != NULL) { + xmlUnlinkNode(cur); + xmlFreeNode(cur) ; cur = NULL ; } + if (old != NULL) { + xmlUnlinkNode(old); + xmlFreeNode(old) ; old = NULL ; } + ret_val = NULL;""", + "xmlTextMerge": + """if ((first != NULL) && (first->type != XML_TEXT_NODE)) { + xmlUnlinkNode(second); + xmlFreeNode(second) ; second = NULL ; }""", + "xmlBuildQName": + """if ((ret_val != NULL) && (ret_val != ncname) && + (ret_val != prefix) && (ret_val != memory)) + xmlFree(ret_val); + ret_val = NULL;""", + "xmlNewDocElementContent": + """xmlFreeDocElementContent(doc, ret_val); ret_val = NULL;""", + "xmlDictReference": "xmlDictFree(dict);", + # Functions which deallocates one of their parameters + "xmlXPathConvertBoolean": """val = NULL;""", + "xmlXPathConvertNumber": """val = NULL;""", + "xmlXPathConvertString": """val = NULL;""", + "xmlSaveFileTo": """buf = NULL;""", + "xmlSaveFormatFileTo": """buf = NULL;""", + "xmlIOParseDTD": "input = NULL;", + "xmlRemoveProp": "cur = NULL;", + "xmlNewNs": "if ((node == NULL) && (ret_val != NULL)) xmlFreeNs(ret_val);", + "xmlCopyNamespace": "if (ret_val != NULL) xmlFreeNs(ret_val);", + "xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);", + "xmlNewTextWriter": "if (ret_val != NULL) out = NULL;", + "xmlNewTextWriterPushParser": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} if (ret_val != NULL) ctxt = NULL;", + "xmlNewIOInputStream": "if (ret_val != NULL) input = NULL;", + "htmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", + "htmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", + "xmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", + "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", + "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", + "xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}", + "xmlBufferSetAllocationScheme": "if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;}" +} + +modules = [] + +def is_skipped_module(name): + for mod in skipped_modules: + if mod == name: + return 1 + return 0 + +def is_skipped_function(name): + for fun in skipped_functions: + if fun == name: + return 1 + # Do not test destructors + if string.find(name, 'Free') != -1: + return 1 + return 0 + +def is_skipped_memcheck(name): + for fun in skipped_memcheck: + if fun == name: + return 1 + return 0 + +missing_types = {} +def add_missing_type(name, func): + try: + list = missing_types[name] + list.append(func) + except: + missing_types[name] = [func] + +generated_param_types = [] +def add_generated_param_type(name): + generated_param_types.append(name) + +generated_return_types = [] +def add_generated_return_type(name): + generated_return_types.append(name) + +missing_functions = {} +missing_functions_nr = 0 +def add_missing_functions(name, module): + global missing_functions_nr + + missing_functions_nr = missing_functions_nr + 1 + try: + list = missing_functions[module] + list.append(name) + except: + missing_functions[module] = [name] + +# +# Provide the type generators and destructors for the parameters +# + +def type_convert(str, name, info, module, function, pos): +# res = string.replace(str, " ", " ") +# res = string.replace(str, " ", " ") +# res = string.replace(str, " ", " ") + res = string.replace(str, " *", "_ptr") +# res = string.replace(str, "*", "_ptr") + res = string.replace(res, " ", "_") + if res == 'const_char_ptr': + if string.find(name, "file") != -1 or \ + string.find(name, "uri") != -1 or \ + string.find(name, "URI") != -1 or \ + string.find(info, "filename") != -1 or \ + string.find(info, "URI") != -1 or \ + string.find(info, "URL") != -1: + if string.find(function, "Save") != -1 or \ + string.find(function, "Create") != -1 or \ + string.find(function, "Write") != -1 or \ + string.find(function, "Fetch") != -1: + return('fileoutput') + return('filepath') + if res == 'void_ptr': + if module == 'nanoftp' and name == 'ctx': + return('xmlNanoFTPCtxtPtr') + if function == 'xmlNanoFTPNewCtxt' or \ + function == 'xmlNanoFTPConnectTo' or \ + function == 'xmlNanoFTPOpen': + return('xmlNanoFTPCtxtPtr') + if module == 'nanohttp' and name == 'ctx': + return('xmlNanoHTTPCtxtPtr') + if function == 'xmlNanoHTTPMethod' or \ + function == 'xmlNanoHTTPMethodRedir' or \ + function == 'xmlNanoHTTPOpen' or \ + function == 'xmlNanoHTTPOpenRedir': + return('xmlNanoHTTPCtxtPtr'); + if function == 'xmlIOHTTPOpen': + return('xmlNanoHTTPCtxtPtr') + if string.find(name, "data") != -1: + return('userdata') + if string.find(name, "user") != -1: + return('userdata') + if res == 'xmlDoc_ptr': + res = 'xmlDocPtr' + if res == 'xmlNode_ptr': + res = 'xmlNodePtr' + if res == 'xmlDict_ptr': + res = 'xmlDictPtr' + if res == 'xmlNodePtr' and pos != 0: + if (function == 'xmlAddChild' and pos == 2) or \ + (function == 'xmlAddChildList' and pos == 2) or \ + (function == 'xmlAddNextSibling' and pos == 2) or \ + (function == 'xmlAddSibling' and pos == 2) or \ + (function == 'xmlDocSetRootElement' and pos == 2) or \ + (function == 'xmlReplaceNode' and pos == 2) or \ + (function == 'xmlTextMerge') or \ + (function == 'xmlAddPrevSibling' and pos == 2): + return('xmlNodePtr_in'); + if res == 'const xmlBufferPtr': + res = 'xmlBufferPtr' + if res == 'xmlChar_ptr' and name == 'name' and \ + string.find(function, "EatName") != -1: + return('eaten_name') + if res == 'void_ptr*': + res = 'void_ptr_ptr' + if res == 'char_ptr*': + res = 'char_ptr_ptr' + if res == 'xmlChar_ptr*': + res = 'xmlChar_ptr_ptr' + if res == 'const_xmlChar_ptr*': + res = 'const_xmlChar_ptr_ptr' + if res == 'const_char_ptr*': + res = 'const_char_ptr_ptr' + if res == 'FILE_ptr' and module == 'debugXML': + res = 'debug_FILE_ptr'; + if res == 'int' and name == 'options': + if module == 'parser' or module == 'xmlreader': + res = 'parseroptions' + + return res + +known_param_types = [] + +def is_known_param_type(name): + for type in known_param_types: + if type == name: + return 1 + return name[-3:] == 'Ptr' or name[-4:] == '_ptr' + +def generate_param_type(name, rtype): + global test + for type in known_param_types: + if type == name: + return + for type in generated_param_types: + if type == name: + return + + if name[-3:] == 'Ptr' or name[-4:] == '_ptr': + if rtype[0:6] == 'const ': + crtype = rtype[6:] + else: + crtype = rtype + + define = 0 + if modules_defines.has_key(module): + test.write("#ifdef %s\n" % (modules_defines[module])) + define = 1 + test.write(""" +#define gen_nb_%s 1 +static %s gen_%s(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +""" % (name, crtype, name, name, rtype)) + if define == 1: + test.write("#endif\n\n") + add_generated_param_type(name) + +# +# Provide the type destructors for the return values +# + +known_return_types = [] + +def is_known_return_type(name): + for type in known_return_types: + if type == name: + return 1 + return 0 + +# +# Copy the beginning of the C test program result +# + +try: + input = open("testapi.c", "r") +except: + input = open(srcPref + "testapi.c", "r") +test = open('testapi.c.new', 'w') + +def compare_and_save(): + global test + + test.close() + try: + input = open("testapi.c", "r").read() + except: + input = '' + test = open('testapi.c.new', "r").read() + if input != test: + try: + os.system("rm testapi.c; mv testapi.c.new testapi.c") + except: + os.system("mv testapi.c.new testapi.c") + print("Updated testapi.c") + else: + print("Generated testapi.c is identical") + +line = input.readline() +while line != "": + if line == "/* CUT HERE: everything below that line is generated */\n": + break; + if line[0:15] == "#define gen_nb_": + type = string.split(line[15:])[0] + known_param_types.append(type) + if line[0:19] == "static void desret_": + type = string.split(line[19:], '(')[0] + known_return_types.append(type) + test.write(line) + line = input.readline() +input.close() + +if line == "": + print "Could not find the CUT marker in testapi.c skipping generation" + test.close() + sys.exit(0) + +print("Scanned testapi.c: found %d parameters types and %d return types\n" % ( + len(known_param_types), len(known_return_types))) +test.write("/* CUT HERE: everything below that line is generated */\n") + + +# +# Open the input API description +# +doc = libxml2.readFile(srcPref + 'doc/libxml2-api.xml', None, 0) +if doc == None: + print "Failed to load doc/libxml2-api.xml" + sys.exit(1) +ctxt = doc.xpathNewContext() + +# +# Generate a list of all function parameters and select only +# those used in the api tests +# +argtypes = {} +args = ctxt.xpathEval("/api/symbols/function/arg") +for arg in args: + mod = arg.xpathEval('string(../@file)') + func = arg.xpathEval('string(../@name)') + if (mod not in skipped_modules) and (func not in skipped_functions): + type = arg.xpathEval('string(@type)') + if not argtypes.has_key(type): + argtypes[type] = func + +# similarly for return types +rettypes = {} +rets = ctxt.xpathEval("/api/symbols/function/return") +for ret in rets: + mod = ret.xpathEval('string(../@file)') + func = ret.xpathEval('string(../@name)') + if (mod not in skipped_modules) and (func not in skipped_functions): + type = ret.xpathEval('string(@type)') + if not rettypes.has_key(type): + rettypes[type] = func + +# +# Generate constructors and return type handling for all enums +# which are used as function parameters +# +enums = ctxt.xpathEval("/api/symbols/typedef[@type='enum']") +for enum in enums: + module = enum.xpathEval('string(@file)') + name = enum.xpathEval('string(@name)') + # + # Skip any enums which are not in our filtered lists + # + if (name == None) or ((name not in argtypes) and (name not in rettypes)): + continue; + define = 0 + + if argtypes.has_key(name) and is_known_param_type(name) == 0: + values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name) + i = 0 + vals = [] + for value in values: + vname = value.xpathEval('string(@name)') + if vname == None: + continue; + i = i + 1 + if i >= 5: + break; + vals.append(vname) + if vals == []: + print "Didn't find any value for enum %s" % (name) + continue + if modules_defines.has_key(module): + test.write("#ifdef %s\n" % (modules_defines[module])) + define = 1 + test.write("#define gen_nb_%s %d\n" % (name, len(vals))) + test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" % + (name, name)) + i = 1 + for value in vals: + test.write(" if (no == %d) return(%s);\n" % (i, value)) + i = i + 1 + test.write(""" return(0); +} + +static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +""" % (name, name)); + known_param_types.append(name) + + if (is_known_return_type(name) == 0) and (name in rettypes): + if define == 0 and modules_defines.has_key(module): + test.write("#ifdef %s\n" % (modules_defines[module])) + define = 1 + test.write("""static void desret_%s(%s val ATTRIBUTE_UNUSED) { +} + +""" % (name, name)) + known_return_types.append(name) + if define == 1: + test.write("#endif\n\n") + +# +# Load the interfaces +# +headers = ctxt.xpathEval("/api/files/file") +for file in headers: + name = file.xpathEval('string(@name)') + if (name == None) or (name == ''): + continue + + # + # Some module may be skipped because they don't really consists + # of user callable APIs + # + if is_skipped_module(name): + continue + + # + # do not test deprecated APIs + # + desc = file.xpathEval('string(description)') + if string.find(desc, 'DEPRECATED') != -1: + print "Skipping deprecated interface %s" % name + continue; + + test.write("#include \n" % name) + modules.append(name) + +# +# Generate the callers signatures +# +for module in modules: + test.write("static int test_%s(void);\n" % module); + +# +# Generate the top caller +# + +test.write(""" +/** + * testlibxml2: + * + * Main entry point of the tester for the full libxml2 module, + * it calls all the tester entry point for each module. + * + * Returns the number of error found + */ +static int +testlibxml2(void) +{ + int test_ret = 0; + +""") + +for module in modules: + test.write(" test_ret += test_%s();\n" % module) + +test.write(""" + printf("Total: %d functions, %d tests, %d errors\\n", + function_tests, call_tests, test_ret); + return(test_ret); +} + +""") + +# +# How to handle a function +# +nb_tests = 0 + +def generate_test(module, node): + global test + global nb_tests + nb_cond = 0 + no_gen = 0 + + name = node.xpathEval('string(@name)') + if is_skipped_function(name): + return + + # + # check we know how to handle the args and return values + # and store the information for the generation + # + try: + args = node.xpathEval("arg") + except: + args = [] + t_args = [] + n = 0 + for arg in args: + n = n + 1 + rtype = arg.xpathEval("string(@type)") + if rtype == 'void': + break; + info = arg.xpathEval("string(@info)") + nam = arg.xpathEval("string(@name)") + type = type_convert(rtype, nam, info, module, name, n) + if is_known_param_type(type) == 0: + add_missing_type(type, name); + no_gen = 1 + if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \ + rtype[0:6] == 'const ': + crtype = rtype[6:] + else: + crtype = rtype + t_args.append((nam, type, rtype, crtype, info)) + + try: + rets = node.xpathEval("return") + except: + rets = [] + t_ret = None + for ret in rets: + rtype = ret.xpathEval("string(@type)") + info = ret.xpathEval("string(@info)") + type = type_convert(rtype, 'return', info, module, name, 0) + if rtype == 'void': + break + if is_known_return_type(type) == 0: + add_missing_type(type, name); + no_gen = 1 + t_ret = (type, rtype, info) + break + + if no_gen == 0: + for t_arg in t_args: + (nam, type, rtype, crtype, info) = t_arg + generate_param_type(type, rtype) + + test.write(""" +static int +test_%s(void) { + int test_ret = 0; + +""" % (name)) + + if no_gen == 1: + add_missing_functions(name, module) + test.write(""" + /* missing type support */ + return(test_ret); +} + +""") + return + + try: + conds = node.xpathEval("cond") + for cond in conds: + test.write("#if %s\n" % (cond.get_content())) + nb_cond = nb_cond + 1 + except: + pass + + define = 0 + if function_defines.has_key(name): + test.write("#ifdef %s\n" % (function_defines[name])) + define = 1 + + # Declare the memory usage counter + no_mem = is_skipped_memcheck(name) + if no_mem == 0: + test.write(" int mem_base;\n"); + + # Declare the return value + if t_ret != None: + test.write(" %s ret_val;\n" % (t_ret[1])) + + # Declare the arguments + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + # add declaration + test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) + test.write(" int n_%s;\n" % (nam)) + test.write("\n") + + # Cascade loop on of each argument list of values + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + # + test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( + nam, nam, type, nam)) + + # log the memory usage + if no_mem == 0: + test.write(" mem_base = xmlMemBlocks();\n"); + + # prepare the call + i = 0; + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + # + test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) + i = i + 1; + + # add checks to avoid out-of-bounds array access + i = 0; + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + # assume that "size", "len", and "start" parameters apply to either + # the nearest preceding or following char pointer + if type == "int" and (nam == "size" or nam == "len" or nam == "start"): + for j in range(i - 1, -1, -1) + range(i + 1, len(t_args)): + (bnam, btype) = t_args[j][:2] + if btype == "const_char_ptr" or btype == "const_xmlChar_ptr": + test.write( + " if ((%s != NULL) &&\n" + " (%s > (int) strlen((const char *) %s) + 1))\n" + " continue;\n" + % (bnam, nam, bnam)) + break + i = i + 1; + + # do the call, and clanup the result + if extra_pre_call.has_key(name): + test.write(" %s\n"% (extra_pre_call[name])) + if t_ret != None: + test.write("\n ret_val = %s(" % (name)) + need = 0 + for arg in t_args: + (nam, type, rtype, crtype, info) = arg + if need: + test.write(", ") + else: + need = 1 + if rtype != crtype: + test.write("(%s)" % rtype) + test.write("%s" % nam); + test.write(");\n") + if extra_post_call.has_key(name): + test.write(" %s\n"% (extra_post_call[name])) + test.write(" desret_%s(ret_val);\n" % t_ret[0]) + else: + test.write("\n %s(" % (name)); + need = 0; + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + if need: + test.write(", ") + else: + need = 1 + if rtype != crtype: + test.write("(%s)" % rtype) + test.write("%s" % nam) + test.write(");\n") + if extra_post_call.has_key(name): + test.write(" %s\n"% (extra_post_call[name])) + + test.write(" call_tests++;\n"); + + # Free the arguments + i = 0; + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + # This is a hack to prevent generating a destructor for the + # 'input' argument in xmlTextReaderSetup. There should be + # a better, more generic way to do this! + if string.find(info, 'destroy') == -1: + test.write(" des_%s(n_%s, " % (type, nam)) + if rtype != crtype: + test.write("(%s)" % rtype) + test.write("%s, %d);\n" % (nam, i)) + i = i + 1; + + test.write(" xmlResetLastError();\n"); + # Check the memory usage + if no_mem == 0: + test.write(""" if (mem_base != xmlMemBlocks()) { + printf("Leak of %%d blocks found in %s", + xmlMemBlocks() - mem_base); + test_ret++; +""" % (name)); + for arg in t_args: + (nam, type, rtype, crtype, info) = arg; + test.write(""" printf(" %%d", n_%s);\n""" % (nam)) + test.write(""" printf("\\n");\n""") + test.write(" }\n") + + for arg in t_args: + test.write(" }\n") + + test.write(" function_tests++;\n") + # + # end of conditional + # + while nb_cond > 0: + test.write("#endif\n") + nb_cond = nb_cond -1 + if define == 1: + test.write("#endif\n") + + nb_tests = nb_tests + 1; + + test.write(""" + return(test_ret); +} + +""") + +# +# Generate all module callers +# +for module in modules: + # gather all the functions exported by that module + try: + functions = ctxt.xpathEval("/api/symbols/function[@file='%s']" % (module)) + except: + print "Failed to gather functions from module %s" % (module) + continue; + + # iterate over all functions in the module generating the test + i = 0 + nb_tests_old = nb_tests + for function in functions: + i = i + 1 + generate_test(module, function); + + # header + test.write("""static int +test_%s(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing %s : %d of %d functions ...\\n"); +""" % (module, module, nb_tests - nb_tests_old, i)) + + # iterate over all functions in the module generating the call + for function in functions: + name = function.xpathEval('string(@name)') + if is_skipped_function(name): + continue + test.write(" test_ret += test_%s();\n" % (name)) + + # footer + test.write(""" + if (test_ret != 0) + printf("Module %s: %%d errors\\n", test_ret); + return(test_ret); +} +""" % (module)) + +# +# Generate direct module caller +# +test.write("""static int +test_module(const char *module) { +"""); +for module in modules: + test.write(""" if (!strcmp(module, "%s")) return(test_%s());\n""" % ( + module, module)) +test.write(""" return(0); +} +"""); + +print "Generated test for %d modules and %d functions" %(len(modules), nb_tests) + +compare_and_save() + +missing_list = [] +for missing in missing_types.keys(): + if missing == 'va_list' or missing == '...': + continue; + + n = len(missing_types[missing]) + missing_list.append((n, missing)) + +def compare_missing(a, b): + return b[0] - a[0] + +missing_list.sort(compare_missing) +print "Missing support for %d functions and %d types see missing.lst" % (missing_functions_nr, len(missing_list)) +lst = open("missing.lst", "w") +lst.write("Missing support for %d types" % (len(missing_list))) +lst.write("\n") +for miss in missing_list: + lst.write("%s: %d :" % (miss[1], miss[0])) + i = 0 + for n in missing_types[miss[1]]: + i = i + 1 + if i > 5: + lst.write(" ...") + break + lst.write(" %s" % (n)) + lst.write("\n") +lst.write("\n") +lst.write("\n") +lst.write("Missing support per module"); +for module in missing_functions.keys(): + lst.write("module %s:\n %s\n" % (module, missing_functions[module])) + +lst.close() + + diff --git a/src/globals.c b/src/globals.c new file mode 100644 index 000000000000..0c0bdb44a838 --- /dev/null +++ b/src/globals.c @@ -0,0 +1,1126 @@ +/* + * globals.c: definition and handling of the set of global variables + * of the library + * + * The bottom of this file is automatically generated by build_glob.py + * based on the description file global.data + * + * See Copyright for the status of this software. + * + * Gary Pennington + * daniel@veillard.com + */ + +#define IN_LIBXML +#include "libxml.h" + +#ifdef HAVE_STDLIB_H +#include +#endif +#include + +#include +#include +#include + +/* #define DEBUG_GLOBALS */ + +/* + * Helpful Macro + */ +#ifdef LIBXML_THREAD_ENABLED +#define IS_MAIN_THREAD (xmlIsMainThread()) +#else +#define IS_MAIN_THREAD 1 +#endif + +/* + * Mutex to protect "ForNewThreads" variables + */ +static xmlMutexPtr xmlThrDefMutex = NULL; + +/** + * xmlInitGlobals: + * + * Additional initialisation for multi-threading + */ +void xmlInitGlobals(void) +{ + if (xmlThrDefMutex == NULL) + xmlThrDefMutex = xmlNewMutex(); +} + +/** + * xmlCleanupGlobals: + * + * Additional cleanup for multi-threading + */ +void xmlCleanupGlobals(void) +{ + if (xmlThrDefMutex != NULL) { + xmlFreeMutex(xmlThrDefMutex); + xmlThrDefMutex = NULL; + } + __xmlGlobalInitMutexDestroy(); +} + +/************************************************************************ + * * + * All the user accessible global variables of the library * + * * + ************************************************************************/ + +/* + * Memory allocation routines + */ +#undef xmlFree +#undef xmlMalloc +#undef xmlMallocAtomic +#undef xmlMemStrdup +#undef xmlRealloc + +#if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY) +xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree; +xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc; +xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc; +xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc; +xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; +#else +/** + * xmlFree: + * @mem: an already allocated block of memory + * + * The variable holding the libxml free() implementation + */ +xmlFreeFunc xmlFree = free; +/** + * xmlMalloc: + * @size: the size requested in bytes + * + * The variable holding the libxml malloc() implementation + * + * Returns a pointer to the newly allocated block or NULL in case of error + */ +xmlMallocFunc xmlMalloc = malloc; +/** + * xmlMallocAtomic: + * @size: the size requested in bytes + * + * The variable holding the libxml malloc() implementation for atomic + * data (i.e. blocks not containing pointers), useful when using a + * garbage collecting allocator. + * + * Returns a pointer to the newly allocated block or NULL in case of error + */ +xmlMallocFunc xmlMallocAtomic = malloc; +/** + * xmlRealloc: + * @mem: an already allocated block of memory + * @size: the new size requested in bytes + * + * The variable holding the libxml realloc() implementation + * + * Returns a pointer to the newly reallocated block or NULL in case of error + */ +xmlReallocFunc xmlRealloc = realloc; +/** + * xmlPosixStrdup + * @cur: the input char * + * + * a strdup implementation with a type signature matching POSIX + * + * Returns a new xmlChar * or NULL + */ +static char * +xmlPosixStrdup(const char *cur) { + return((char*) xmlCharStrdup(cur)); +} +/** + * xmlMemStrdup: + * @str: a zero terminated string + * + * The variable holding the libxml strdup() implementation + * + * Returns the copy of the string or NULL in case of error + */ +xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup; +#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */ + +#include +#include +#include + +#undef docbDefaultSAXHandler +#undef htmlDefaultSAXHandler +#undef oldXMLWDcompatibility +#undef xmlBufferAllocScheme +#undef xmlDefaultBufferSize +#undef xmlDefaultSAXHandler +#undef xmlDefaultSAXLocator +#undef xmlDoValidityCheckingDefaultValue +#undef xmlGenericError +#undef xmlStructuredError +#undef xmlGenericErrorContext +#undef xmlStructuredErrorContext +#undef xmlGetWarningsDefaultValue +#undef xmlIndentTreeOutput +#undef xmlTreeIndentString +#undef xmlKeepBlanksDefaultValue +#undef xmlLineNumbersDefaultValue +#undef xmlLoadExtDtdDefaultValue +#undef xmlParserDebugEntities +#undef xmlParserVersion +#undef xmlPedanticParserDefaultValue +#undef xmlSaveNoEmptyTags +#undef xmlSubstituteEntitiesDefaultValue +#undef xmlRegisterNodeDefaultValue +#undef xmlDeregisterNodeDefaultValue +#undef xmlLastError + +#undef xmlParserInputBufferCreateFilenameValue +#undef xmlOutputBufferCreateFilenameValue +/** + * xmlParserVersion: + * + * Constant string describing the internal version of the library + */ +const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA; + +/** + * xmlBufferAllocScheme: + * + * Global setting, default allocation policy for buffers, default is + * XML_BUFFER_ALLOC_EXACT + */ +xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; +static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT; +/** + * xmlDefaultBufferSize: + * + * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE + */ +int xmlDefaultBufferSize = BASE_BUFFER_SIZE; +static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE; + +/* + * Parser defaults + */ + +/** + * oldXMLWDcompatibility: + * + * Global setting, DEPRECATED. + */ +int oldXMLWDcompatibility = 0; /* DEPRECATED */ +/** + * xmlParserDebugEntities: + * + * Global setting, asking the parser to print out debugging information. + * while handling entities. + * Disabled by default + */ +int xmlParserDebugEntities = 0; +static int xmlParserDebugEntitiesThrDef = 0; +/** + * xmlDoValidityCheckingDefaultValue: + * + * Global setting, indicate that the parser should work in validating mode. + * Disabled by default. + */ +int xmlDoValidityCheckingDefaultValue = 0; +static int xmlDoValidityCheckingDefaultValueThrDef = 0; +/** + * xmlGetWarningsDefaultValue: + * + * Global setting, indicate that the parser should provide warnings. + * Activated by default. + */ +int xmlGetWarningsDefaultValue = 1; +static int xmlGetWarningsDefaultValueThrDef = 1; +/** + * xmlLoadExtDtdDefaultValue: + * + * Global setting, indicate that the parser should load DTD while not + * validating. + * Disabled by default. + */ +int xmlLoadExtDtdDefaultValue = 0; +static int xmlLoadExtDtdDefaultValueThrDef = 0; +/** + * xmlPedanticParserDefaultValue: + * + * Global setting, indicate that the parser be pedantic + * Disabled by default. + */ +int xmlPedanticParserDefaultValue = 0; +static int xmlPedanticParserDefaultValueThrDef = 0; +/** + * xmlLineNumbersDefaultValue: + * + * Global setting, indicate that the parser should store the line number + * in the content field of elements in the DOM tree. + * Disabled by default since this may not be safe for old classes of + * application. + */ +int xmlLineNumbersDefaultValue = 0; +static int xmlLineNumbersDefaultValueThrDef = 0; +/** + * xmlKeepBlanksDefaultValue: + * + * Global setting, indicate that the parser should keep all blanks + * nodes found in the content + * Activated by default, this is actually needed to have the parser + * conformant to the XML Recommendation, however the option is kept + * for some applications since this was libxml1 default behaviour. + */ +int xmlKeepBlanksDefaultValue = 1; +static int xmlKeepBlanksDefaultValueThrDef = 1; +/** + * xmlSubstituteEntitiesDefaultValue: + * + * Global setting, indicate that the parser should not generate entity + * references but replace them with the actual content of the entity + * Disabled by default, this should be activated when using XPath since + * the XPath data model requires entities replacement and the XPath + * engine does not handle entities references transparently. + */ +int xmlSubstituteEntitiesDefaultValue = 0; +static int xmlSubstituteEntitiesDefaultValueThrDef = 0; + +xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL; +static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL; +xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL; +static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL; + +xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL; +static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL; + +xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL; +static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL; + +/* + * Error handling + */ + +/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */ +/* Must initialize xmlGenericError in xmlInitParser */ +void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, + const char *msg, + ...); +/** + * xmlGenericError: + * + * Global setting: function used for generic error callbacks + */ +xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; +static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc; +/** + * xmlStructuredError: + * + * Global setting: function used for structured error callbacks + */ +xmlStructuredErrorFunc xmlStructuredError = NULL; +static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL; +/** + * xmlGenericErrorContext: + * + * Global setting passed to generic error callbacks + */ +void *xmlGenericErrorContext = NULL; +static void *xmlGenericErrorContextThrDef = NULL; +/** + * xmlStructuredErrorContext: + * + * Global setting passed to structured error callbacks + */ +void *xmlStructuredErrorContext = NULL; +static void *xmlStructuredErrorContextThrDef = NULL; +xmlError xmlLastError; + +/* + * output defaults + */ +/** + * xmlIndentTreeOutput: + * + * Global setting, asking the serializer to indent the output tree by default + * Enabled by default + */ +int xmlIndentTreeOutput = 1; +static int xmlIndentTreeOutputThrDef = 1; + +/** + * xmlTreeIndentString: + * + * The string used to do one-level indent. By default is equal to " " (two spaces) + */ +const char *xmlTreeIndentString = " "; +static const char *xmlTreeIndentStringThrDef = " "; + +/** + * xmlSaveNoEmptyTags: + * + * Global setting, asking the serializer to not output empty tags + * as but . those two forms are indistinguishable + * once parsed. + * Disabled by default + */ +int xmlSaveNoEmptyTags = 0; +static int xmlSaveNoEmptyTagsThrDef = 0; + +#ifdef LIBXML_SAX1_ENABLED +/** + * xmlDefaultSAXHandler: + * + * Default SAX version1 handler for XML, builds the DOM tree + */ +xmlSAXHandlerV1 xmlDefaultSAXHandler = { + xmlSAX2InternalSubset, + xmlSAX2IsStandalone, + xmlSAX2HasInternalSubset, + xmlSAX2HasExternalSubset, + xmlSAX2ResolveEntity, + xmlSAX2GetEntity, + xmlSAX2EntityDecl, + xmlSAX2NotationDecl, + xmlSAX2AttributeDecl, + xmlSAX2ElementDecl, + xmlSAX2UnparsedEntityDecl, + xmlSAX2SetDocumentLocator, + xmlSAX2StartDocument, + xmlSAX2EndDocument, + xmlSAX2StartElement, + xmlSAX2EndElement, + xmlSAX2Reference, + xmlSAX2Characters, + xmlSAX2Characters, + xmlSAX2ProcessingInstruction, + xmlSAX2Comment, + xmlParserWarning, + xmlParserError, + xmlParserError, + xmlSAX2GetParameterEntity, + xmlSAX2CDataBlock, + xmlSAX2ExternalSubset, + 0, +}; +#endif /* LIBXML_SAX1_ENABLED */ + +/** + * xmlDefaultSAXLocator: + * + * The default SAX Locator + * { getPublicId, getSystemId, getLineNumber, getColumnNumber} + */ +xmlSAXLocator xmlDefaultSAXLocator = { + xmlSAX2GetPublicId, + xmlSAX2GetSystemId, + xmlSAX2GetLineNumber, + xmlSAX2GetColumnNumber +}; + +#ifdef LIBXML_HTML_ENABLED +/** + * htmlDefaultSAXHandler: + * + * Default old SAX v1 handler for HTML, builds the DOM tree + */ +xmlSAXHandlerV1 htmlDefaultSAXHandler = { + xmlSAX2InternalSubset, + NULL, + NULL, + NULL, + NULL, + xmlSAX2GetEntity, + NULL, + NULL, + NULL, + NULL, + NULL, + xmlSAX2SetDocumentLocator, + xmlSAX2StartDocument, + xmlSAX2EndDocument, + xmlSAX2StartElement, + xmlSAX2EndElement, + NULL, + xmlSAX2Characters, + xmlSAX2IgnorableWhitespace, + xmlSAX2ProcessingInstruction, + xmlSAX2Comment, + xmlParserWarning, + xmlParserError, + xmlParserError, + xmlSAX2GetParameterEntity, + xmlSAX2CDataBlock, + NULL, + 0, +}; +#endif /* LIBXML_HTML_ENABLED */ + +#ifdef LIBXML_DOCB_ENABLED +/** + * docbDefaultSAXHandler: + * + * Default old SAX v1 handler for SGML DocBook, builds the DOM tree + */ +xmlSAXHandlerV1 docbDefaultSAXHandler = { + xmlSAX2InternalSubset, + xmlSAX2IsStandalone, + xmlSAX2HasInternalSubset, + xmlSAX2HasExternalSubset, + xmlSAX2ResolveEntity, + xmlSAX2GetEntity, + xmlSAX2EntityDecl, + NULL, + NULL, + NULL, + NULL, + xmlSAX2SetDocumentLocator, + xmlSAX2StartDocument, + xmlSAX2EndDocument, + xmlSAX2StartElement, + xmlSAX2EndElement, + xmlSAX2Reference, + xmlSAX2Characters, + xmlSAX2IgnorableWhitespace, + NULL, + xmlSAX2Comment, + xmlParserWarning, + xmlParserError, + xmlParserError, + xmlSAX2GetParameterEntity, + NULL, + NULL, + 0, +}; +#endif /* LIBXML_DOCB_ENABLED */ + +/** + * xmlInitializeGlobalState: + * @gs: a pointer to a newly allocated global state + * + * xmlInitializeGlobalState() initialize a global state with all the + * default values of the library. + */ +void +xmlInitializeGlobalState(xmlGlobalStatePtr gs) +{ +#ifdef DEBUG_GLOBALS + fprintf(stderr, "Initializing globals at %lu for thread %d\n", + (unsigned long) gs, xmlGetThreadId()); +#endif + + /* + * Perform initialization as required by libxml + */ + if (xmlThrDefMutex == NULL) + xmlInitGlobals(); + + xmlMutexLock(xmlThrDefMutex); + +#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED) + initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); +#endif +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED) + inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); +#endif + + gs->oldXMLWDcompatibility = 0; + gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef; + gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef; +#if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED) + initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); +#endif /* LIBXML_SAX1_ENABLED */ + gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId; + gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId; + gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber; + gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber; + gs->xmlDoValidityCheckingDefaultValue = + xmlDoValidityCheckingDefaultValueThrDef; +#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY) + gs->xmlFree = (xmlFreeFunc) xmlMemFree; + gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc; + gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc; + gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc; + gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; +#else + gs->xmlFree = (xmlFreeFunc) free; + gs->xmlMalloc = (xmlMallocFunc) malloc; + gs->xmlMallocAtomic = (xmlMallocFunc) malloc; + gs->xmlRealloc = (xmlReallocFunc) realloc; + gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; +#endif + gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef; + gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef; + gs->xmlTreeIndentString = xmlTreeIndentStringThrDef; + gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef; + gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef; + gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef; + gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef; + gs->xmlParserVersion = LIBXML_VERSION_STRING; + gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef; + gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef; + gs->xmlSubstituteEntitiesDefaultValue = + xmlSubstituteEntitiesDefaultValueThrDef; + + gs->xmlGenericError = xmlGenericErrorThrDef; + gs->xmlStructuredError = xmlStructuredErrorThrDef; + gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef; + gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef; + gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef; + gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef; + + gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef; + gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef; + memset(&gs->xmlLastError, 0, sizeof(xmlError)); + + xmlMutexUnlock(xmlThrDefMutex); +} + +/** + * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions, + * those are really internal work + */ +void +xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) { + xmlMutexLock(xmlThrDefMutex); + xmlGenericErrorContextThrDef = ctx; + if (handler != NULL) + xmlGenericErrorThrDef = handler; + else + xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc; + xmlMutexUnlock(xmlThrDefMutex); +} + +void +xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) { + xmlMutexLock(xmlThrDefMutex); + xmlStructuredErrorContextThrDef = ctx; + xmlStructuredErrorThrDef = handler; + xmlMutexUnlock(xmlThrDefMutex); +} + +/** + * xmlRegisterNodeDefault: + * @func: function pointer to the new RegisterNodeFunc + * + * Registers a callback for node creation + * + * Returns the old value of the registration function + */ +xmlRegisterNodeFunc +xmlRegisterNodeDefault(xmlRegisterNodeFunc func) +{ + xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue; + + __xmlRegisterCallbacks = 1; + xmlRegisterNodeDefaultValue = func; + return(old); +} + +xmlRegisterNodeFunc +xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func) +{ + xmlRegisterNodeFunc old; + + xmlMutexLock(xmlThrDefMutex); + old = xmlRegisterNodeDefaultValueThrDef; + + __xmlRegisterCallbacks = 1; + xmlRegisterNodeDefaultValueThrDef = func; + xmlMutexUnlock(xmlThrDefMutex); + + return(old); +} + +/** + * xmlDeregisterNodeDefault: + * @func: function pointer to the new DeregisterNodeFunc + * + * Registers a callback for node destruction + * + * Returns the previous value of the deregistration function + */ +xmlDeregisterNodeFunc +xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func) +{ + xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue; + + __xmlRegisterCallbacks = 1; + xmlDeregisterNodeDefaultValue = func; + return(old); +} + +xmlDeregisterNodeFunc +xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func) +{ + xmlDeregisterNodeFunc old; + + xmlMutexLock(xmlThrDefMutex); + old = xmlDeregisterNodeDefaultValueThrDef; + + __xmlRegisterCallbacks = 1; + xmlDeregisterNodeDefaultValueThrDef = func; + xmlMutexUnlock(xmlThrDefMutex); + + return(old); +} + +xmlParserInputBufferCreateFilenameFunc +xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func) +{ + xmlParserInputBufferCreateFilenameFunc old; + + xmlMutexLock(xmlThrDefMutex); + old = xmlParserInputBufferCreateFilenameValueThrDef; + if (old == NULL) { + old = __xmlParserInputBufferCreateFilename; + } + + xmlParserInputBufferCreateFilenameValueThrDef = func; + xmlMutexUnlock(xmlThrDefMutex); + + return(old); +} + +xmlOutputBufferCreateFilenameFunc +xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func) +{ + xmlOutputBufferCreateFilenameFunc old; + + xmlMutexLock(xmlThrDefMutex); + old = xmlOutputBufferCreateFilenameValueThrDef; +#ifdef LIBXML_OUTPUT_ENABLED + if (old == NULL) { + old = __xmlOutputBufferCreateFilename; + } +#endif + xmlOutputBufferCreateFilenameValueThrDef = func; + xmlMutexUnlock(xmlThrDefMutex); + + return(old); +} + +#ifdef LIBXML_DOCB_ENABLED +#undef docbDefaultSAXHandler +xmlSAXHandlerV1 * +__docbDefaultSAXHandler(void) { + if (IS_MAIN_THREAD) + return (&docbDefaultSAXHandler); + else + return (&xmlGetGlobalState()->docbDefaultSAXHandler); +} +#endif + +#ifdef LIBXML_HTML_ENABLED +#undef htmlDefaultSAXHandler +xmlSAXHandlerV1 * +__htmlDefaultSAXHandler(void) { + if (IS_MAIN_THREAD) + return (&htmlDefaultSAXHandler); + else + return (&xmlGetGlobalState()->htmlDefaultSAXHandler); +} +#endif + +#undef xmlLastError +xmlError * +__xmlLastError(void) { + if (IS_MAIN_THREAD) + return (&xmlLastError); + else + return (&xmlGetGlobalState()->xmlLastError); +} + +/* + * The following memory routines were apparently lost at some point, + * and were re-inserted at this point on June 10, 2004. Hope it's + * the right place for them :-) + */ +#if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED) +#undef xmlMalloc +xmlMallocFunc * +__xmlMalloc(void){ + if (IS_MAIN_THREAD) + return (&xmlMalloc); + else + return (&xmlGetGlobalState()->xmlMalloc); +} + +#undef xmlMallocAtomic +xmlMallocFunc * +__xmlMallocAtomic(void){ + if (IS_MAIN_THREAD) + return (&xmlMallocAtomic); + else + return (&xmlGetGlobalState()->xmlMallocAtomic); +} + +#undef xmlRealloc +xmlReallocFunc * +__xmlRealloc(void){ + if (IS_MAIN_THREAD) + return (&xmlRealloc); + else + return (&xmlGetGlobalState()->xmlRealloc); +} + +#undef xmlFree +xmlFreeFunc * +__xmlFree(void){ + if (IS_MAIN_THREAD) + return (&xmlFree); + else + return (&xmlGetGlobalState()->xmlFree); +} + +xmlStrdupFunc * +__xmlMemStrdup(void){ + if (IS_MAIN_THREAD) + return (&xmlMemStrdup); + else + return (&xmlGetGlobalState()->xmlMemStrdup); +} + +#endif + +/* + * Everything starting from the line below is + * Automatically generated by build_glob.py. + * Do not modify the previous line. + */ + + +#undef oldXMLWDcompatibility +int * +__oldXMLWDcompatibility(void) { + if (IS_MAIN_THREAD) + return (&oldXMLWDcompatibility); + else + return (&xmlGetGlobalState()->oldXMLWDcompatibility); +} + +#undef xmlBufferAllocScheme +xmlBufferAllocationScheme * +__xmlBufferAllocScheme(void) { + if (IS_MAIN_THREAD) + return (&xmlBufferAllocScheme); + else + return (&xmlGetGlobalState()->xmlBufferAllocScheme); +} +xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) { + xmlBufferAllocationScheme ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlBufferAllocSchemeThrDef; + xmlBufferAllocSchemeThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlDefaultBufferSize +int * +__xmlDefaultBufferSize(void) { + if (IS_MAIN_THREAD) + return (&xmlDefaultBufferSize); + else + return (&xmlGetGlobalState()->xmlDefaultBufferSize); +} +int xmlThrDefDefaultBufferSize(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlDefaultBufferSizeThrDef; + xmlDefaultBufferSizeThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#ifdef LIBXML_SAX1_ENABLED +#undef xmlDefaultSAXHandler +xmlSAXHandlerV1 * +__xmlDefaultSAXHandler(void) { + if (IS_MAIN_THREAD) + return (&xmlDefaultSAXHandler); + else + return (&xmlGetGlobalState()->xmlDefaultSAXHandler); +} +#endif /* LIBXML_SAX1_ENABLED */ + +#undef xmlDefaultSAXLocator +xmlSAXLocator * +__xmlDefaultSAXLocator(void) { + if (IS_MAIN_THREAD) + return (&xmlDefaultSAXLocator); + else + return (&xmlGetGlobalState()->xmlDefaultSAXLocator); +} + +#undef xmlDoValidityCheckingDefaultValue +int * +__xmlDoValidityCheckingDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlDoValidityCheckingDefaultValue); + else + return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue); +} +int xmlThrDefDoValidityCheckingDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlDoValidityCheckingDefaultValueThrDef; + xmlDoValidityCheckingDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlGenericError +xmlGenericErrorFunc * +__xmlGenericError(void) { + if (IS_MAIN_THREAD) + return (&xmlGenericError); + else + return (&xmlGetGlobalState()->xmlGenericError); +} + +#undef xmlStructuredError +xmlStructuredErrorFunc * +__xmlStructuredError(void) { + if (IS_MAIN_THREAD) + return (&xmlStructuredError); + else + return (&xmlGetGlobalState()->xmlStructuredError); +} + +#undef xmlGenericErrorContext +void * * +__xmlGenericErrorContext(void) { + if (IS_MAIN_THREAD) + return (&xmlGenericErrorContext); + else + return (&xmlGetGlobalState()->xmlGenericErrorContext); +} + +#undef xmlStructuredErrorContext +void * * +__xmlStructuredErrorContext(void) { + if (IS_MAIN_THREAD) + return (&xmlStructuredErrorContext); + else + return (&xmlGetGlobalState()->xmlStructuredErrorContext); +} + +#undef xmlGetWarningsDefaultValue +int * +__xmlGetWarningsDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlGetWarningsDefaultValue); + else + return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue); +} +int xmlThrDefGetWarningsDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlGetWarningsDefaultValueThrDef; + xmlGetWarningsDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlIndentTreeOutput +int * +__xmlIndentTreeOutput(void) { + if (IS_MAIN_THREAD) + return (&xmlIndentTreeOutput); + else + return (&xmlGetGlobalState()->xmlIndentTreeOutput); +} +int xmlThrDefIndentTreeOutput(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlIndentTreeOutputThrDef; + xmlIndentTreeOutputThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlTreeIndentString +const char * * +__xmlTreeIndentString(void) { + if (IS_MAIN_THREAD) + return (&xmlTreeIndentString); + else + return (&xmlGetGlobalState()->xmlTreeIndentString); +} +const char * xmlThrDefTreeIndentString(const char * v) { + const char * ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlTreeIndentStringThrDef; + xmlTreeIndentStringThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlKeepBlanksDefaultValue +int * +__xmlKeepBlanksDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlKeepBlanksDefaultValue); + else + return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue); +} +int xmlThrDefKeepBlanksDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlKeepBlanksDefaultValueThrDef; + xmlKeepBlanksDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlLineNumbersDefaultValue +int * +__xmlLineNumbersDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlLineNumbersDefaultValue); + else + return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue); +} +int xmlThrDefLineNumbersDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlLineNumbersDefaultValueThrDef; + xmlLineNumbersDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlLoadExtDtdDefaultValue +int * +__xmlLoadExtDtdDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlLoadExtDtdDefaultValue); + else + return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue); +} +int xmlThrDefLoadExtDtdDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlLoadExtDtdDefaultValueThrDef; + xmlLoadExtDtdDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlParserDebugEntities +int * +__xmlParserDebugEntities(void) { + if (IS_MAIN_THREAD) + return (&xmlParserDebugEntities); + else + return (&xmlGetGlobalState()->xmlParserDebugEntities); +} +int xmlThrDefParserDebugEntities(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlParserDebugEntitiesThrDef; + xmlParserDebugEntitiesThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlParserVersion +const char * * +__xmlParserVersion(void) { + if (IS_MAIN_THREAD) + return (&xmlParserVersion); + else + return (&xmlGetGlobalState()->xmlParserVersion); +} + +#undef xmlPedanticParserDefaultValue +int * +__xmlPedanticParserDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlPedanticParserDefaultValue); + else + return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue); +} +int xmlThrDefPedanticParserDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlPedanticParserDefaultValueThrDef; + xmlPedanticParserDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlSaveNoEmptyTags +int * +__xmlSaveNoEmptyTags(void) { + if (IS_MAIN_THREAD) + return (&xmlSaveNoEmptyTags); + else + return (&xmlGetGlobalState()->xmlSaveNoEmptyTags); +} +int xmlThrDefSaveNoEmptyTags(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlSaveNoEmptyTagsThrDef; + xmlSaveNoEmptyTagsThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlSubstituteEntitiesDefaultValue +int * +__xmlSubstituteEntitiesDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlSubstituteEntitiesDefaultValue); + else + return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue); +} +int xmlThrDefSubstituteEntitiesDefaultValue(int v) { + int ret; + xmlMutexLock(xmlThrDefMutex); + ret = xmlSubstituteEntitiesDefaultValueThrDef; + xmlSubstituteEntitiesDefaultValueThrDef = v; + xmlMutexUnlock(xmlThrDefMutex); + return ret; +} + +#undef xmlRegisterNodeDefaultValue +xmlRegisterNodeFunc * +__xmlRegisterNodeDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlRegisterNodeDefaultValue); + else + return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue); +} + +#undef xmlDeregisterNodeDefaultValue +xmlDeregisterNodeFunc * +__xmlDeregisterNodeDefaultValue(void) { + if (IS_MAIN_THREAD) + return (&xmlDeregisterNodeDefaultValue); + else + return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue); +} + +#undef xmlParserInputBufferCreateFilenameValue +xmlParserInputBufferCreateFilenameFunc * +__xmlParserInputBufferCreateFilenameValue(void) { + if (IS_MAIN_THREAD) + return (&xmlParserInputBufferCreateFilenameValue); + else + return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue); +} + +#undef xmlOutputBufferCreateFilenameValue +xmlOutputBufferCreateFilenameFunc * +__xmlOutputBufferCreateFilenameValue(void) { + if (IS_MAIN_THREAD) + return (&xmlOutputBufferCreateFilenameValue); + else + return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue); +} + +#define bottom_globals +#include "elfgcchack.h" diff --git a/src/hash.c b/src/hash.c new file mode 100644 index 000000000000..afa094ef9076 --- /dev/null +++ b/src/hash.c @@ -0,0 +1,1146 @@ +/* + * hash.c: chained hash tables + * + * Reference: Your favorite introductory book on algorithms + * + * Copyright (C) 2000,2012 Bjorn Reese and Daniel Veillard. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + * + * Author: breese@users.sourceforge.net + */ + +#define IN_LIBXML +#include "libxml.h" + +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_TIME_H +#include +#endif + +/* + * Following http://www.ocert.org/advisories/ocert-2011-003.html + * it seems that having hash randomization might be a good idea + * when using XML with untrusted data + */ +#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) && \ + !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) +#define HASH_RANDOMIZATION +#endif + +#include +#include +#include +#include +#include + +#define MAX_HASH_LEN 8 + +/* #define DEBUG_GROW */ + +/* + * A single entry in the hash table + */ +typedef struct _xmlHashEntry xmlHashEntry; +typedef xmlHashEntry *xmlHashEntryPtr; +struct _xmlHashEntry { + struct _xmlHashEntry *next; + xmlChar *name; + xmlChar *name2; + xmlChar *name3; + void *payload; + int valid; +}; + +/* + * The entire hash table + */ +struct _xmlHashTable { + struct _xmlHashEntry *table; + int size; + int nbElems; + xmlDictPtr dict; +#ifdef HASH_RANDOMIZATION + int random_seed; +#endif +}; + +/* + * xmlHashComputeKey: + * Calculate the hash key + */ +#ifdef __clang__ +ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow") +#endif +static unsigned long +xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3) { + unsigned long value = 0L; + char ch; + +#ifdef HASH_RANDOMIZATION + value = table->random_seed; +#endif + if (name != NULL) { + value += 30 * (*name); + while ((ch = *name++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + } + value = value ^ ((value << 5) + (value >> 3)); + if (name2 != NULL) { + while ((ch = *name2++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + } + value = value ^ ((value << 5) + (value >> 3)); + if (name3 != NULL) { + while ((ch = *name3++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + } + return (value % table->size); +} + +#ifdef __clang__ +ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow") +#endif +static unsigned long +xmlHashComputeQKey(xmlHashTablePtr table, + const xmlChar *prefix, const xmlChar *name, + const xmlChar *prefix2, const xmlChar *name2, + const xmlChar *prefix3, const xmlChar *name3) { + unsigned long value = 0L; + char ch; + +#ifdef HASH_RANDOMIZATION + value = table->random_seed; +#endif + if (prefix != NULL) + value += 30 * (*prefix); + else + value += 30 * (*name); + + if (prefix != NULL) { + while ((ch = *prefix++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)':'); + } + if (name != NULL) { + while ((ch = *name++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + } + value = value ^ ((value << 5) + (value >> 3)); + if (prefix2 != NULL) { + while ((ch = *prefix2++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)':'); + } + if (name2 != NULL) { + while ((ch = *name2++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + } + value = value ^ ((value << 5) + (value >> 3)); + if (prefix3 != NULL) { + while ((ch = *prefix3++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)':'); + } + if (name3 != NULL) { + while ((ch = *name3++) != 0) { + value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch); + } + } + return (value % table->size); +} + +/** + * xmlHashCreate: + * @size: the size of the hash table + * + * Create a new xmlHashTablePtr. + * + * Returns the newly created object, or NULL if an error occurred. + */ +xmlHashTablePtr +xmlHashCreate(int size) { + xmlHashTablePtr table; + + if (size <= 0) + size = 256; + + table = xmlMalloc(sizeof(xmlHashTable)); + if (table) { + table->dict = NULL; + table->size = size; + table->nbElems = 0; + table->table = xmlMalloc(size * sizeof(xmlHashEntry)); + if (table->table) { + memset(table->table, 0, size * sizeof(xmlHashEntry)); +#ifdef HASH_RANDOMIZATION + table->random_seed = __xmlRandom(); +#endif + return(table); + } + xmlFree(table); + } + return(NULL); +} + +/** + * xmlHashCreateDict: + * @size: the size of the hash table + * @dict: a dictionary to use for the hash + * + * Create a new xmlHashTablePtr which will use @dict as the internal dictionary + * + * Returns the newly created object, or NULL if an error occurred. + */ +xmlHashTablePtr +xmlHashCreateDict(int size, xmlDictPtr dict) { + xmlHashTablePtr table; + + table = xmlHashCreate(size); + if (table != NULL) { + table->dict = dict; + xmlDictReference(dict); + } + return(table); +} + +/** + * xmlHashGrow: + * @table: the hash table + * @size: the new size of the hash table + * + * resize the hash table + * + * Returns 0 in case of success, -1 in case of failure + */ +static int +xmlHashGrow(xmlHashTablePtr table, int size) { + unsigned long key; + int oldsize, i; + xmlHashEntryPtr iter, next; + struct _xmlHashEntry *oldtable; +#ifdef DEBUG_GROW + unsigned long nbElem = 0; +#endif + + if (table == NULL) + return(-1); + if (size < 8) + return(-1); + if (size > 8 * 2048) + return(-1); + + oldsize = table->size; + oldtable = table->table; + if (oldtable == NULL) + return(-1); + + table->table = xmlMalloc(size * sizeof(xmlHashEntry)); + if (table->table == NULL) { + table->table = oldtable; + return(-1); + } + memset(table->table, 0, size * sizeof(xmlHashEntry)); + table->size = size; + + /* If the two loops are merged, there would be situations where + a new entry needs to allocated and data copied into it from + the main table. So instead, we run through the array twice, first + copying all the elements in the main array (where we can't get + conflicts) and then the rest, so we only free (and don't allocate) + */ + for (i = 0; i < oldsize; i++) { + if (oldtable[i].valid == 0) + continue; + key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2, + oldtable[i].name3); + memcpy(&(table->table[key]), &(oldtable[i]), sizeof(xmlHashEntry)); + table->table[key].next = NULL; + } + + for (i = 0; i < oldsize; i++) { + iter = oldtable[i].next; + while (iter) { + next = iter->next; + + /* + * put back the entry in the new table + */ + + key = xmlHashComputeKey(table, iter->name, iter->name2, + iter->name3); + if (table->table[key].valid == 0) { + memcpy(&(table->table[key]), iter, sizeof(xmlHashEntry)); + table->table[key].next = NULL; + xmlFree(iter); + } else { + iter->next = table->table[key].next; + table->table[key].next = iter; + } + +#ifdef DEBUG_GROW + nbElem++; +#endif + + iter = next; + } + } + + xmlFree(oldtable); + +#ifdef DEBUG_GROW + xmlGenericError(xmlGenericErrorContext, + "xmlHashGrow : from %d to %d, %d elems\n", oldsize, size, nbElem); +#endif + + return(0); +} + +/** + * xmlHashFree: + * @table: the hash table + * @f: the deallocator function for items in the hash + * + * Free the hash @table and its contents. The userdata is + * deallocated with @f if provided. + */ +void +xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) { + int i; + xmlHashEntryPtr iter; + xmlHashEntryPtr next; + int inside_table = 0; + int nbElems; + + if (table == NULL) + return; + if (table->table) { + nbElems = table->nbElems; + for(i = 0; (i < table->size) && (nbElems > 0); i++) { + iter = &(table->table[i]); + if (iter->valid == 0) + continue; + inside_table = 1; + while (iter) { + next = iter->next; + if ((f != NULL) && (iter->payload != NULL)) + f(iter->payload, iter->name); + if (table->dict == NULL) { + if (iter->name) + xmlFree(iter->name); + if (iter->name2) + xmlFree(iter->name2); + if (iter->name3) + xmlFree(iter->name3); + } + iter->payload = NULL; + if (!inside_table) + xmlFree(iter); + nbElems--; + inside_table = 0; + iter = next; + } + } + xmlFree(table->table); + } + if (table->dict) + xmlDictFree(table->dict); + xmlFree(table); +} + +/** + * xmlHashDefaultDeallocator: + * @entry: the hash table entry + * @name: the entry's name + * + * Free a hash table entry with xmlFree. + */ +void +xmlHashDefaultDeallocator(void *entry, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlFree(entry); +} + +/** + * xmlHashAddEntry: + * @table: the hash table + * @name: the name of the userdata + * @userdata: a pointer to the userdata + * + * Add the @userdata to the hash @table. This can later be retrieved + * by using the @name. Duplicate names generate errors. + * + * Returns 0 the addition succeeded and -1 in case of error. + */ +int +xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata) { + return(xmlHashAddEntry3(table, name, NULL, NULL, userdata)); +} + +/** + * xmlHashAddEntry2: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @userdata: a pointer to the userdata + * + * Add the @userdata to the hash @table. This can later be retrieved + * by using the (@name, @name2) tuple. Duplicate tuples generate errors. + * + * Returns 0 the addition succeeded and -1 in case of error. + */ +int +xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, void *userdata) { + return(xmlHashAddEntry3(table, name, name2, NULL, userdata)); +} + +/** + * xmlHashUpdateEntry: + * @table: the hash table + * @name: the name of the userdata + * @userdata: a pointer to the userdata + * @f: the deallocator function for replaced item (if any) + * + * Add the @userdata to the hash @table. This can later be retrieved + * by using the @name. Existing entry for this @name will be removed + * and freed with @f if found. + * + * Returns 0 the addition succeeded and -1 in case of error. + */ +int +xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name, + void *userdata, xmlHashDeallocator f) { + return(xmlHashUpdateEntry3(table, name, NULL, NULL, userdata, f)); +} + +/** + * xmlHashUpdateEntry2: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @userdata: a pointer to the userdata + * @f: the deallocator function for replaced item (if any) + * + * Add the @userdata to the hash @table. This can later be retrieved + * by using the (@name, @name2) tuple. Existing entry for this tuple will + * be removed and freed with @f if found. + * + * Returns 0 the addition succeeded and -1 in case of error. + */ +int +xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, void *userdata, + xmlHashDeallocator f) { + return(xmlHashUpdateEntry3(table, name, name2, NULL, userdata, f)); +} + +/** + * xmlHashLookup: + * @table: the hash table + * @name: the name of the userdata + * + * Find the userdata specified by the @name. + * + * Returns the pointer to the userdata + */ +void * +xmlHashLookup(xmlHashTablePtr table, const xmlChar *name) { + return(xmlHashLookup3(table, name, NULL, NULL)); +} + +/** + * xmlHashLookup2: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * + * Find the userdata specified by the (@name, @name2) tuple. + * + * Returns the pointer to the userdata + */ +void * +xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2) { + return(xmlHashLookup3(table, name, name2, NULL)); +} + +/** + * xmlHashQLookup: + * @table: the hash table + * @prefix: the prefix of the userdata + * @name: the name of the userdata + * + * Find the userdata specified by the QName @prefix:@name/@name. + * + * Returns the pointer to the userdata + */ +void * +xmlHashQLookup(xmlHashTablePtr table, const xmlChar *prefix, + const xmlChar *name) { + return(xmlHashQLookup3(table, prefix, name, NULL, NULL, NULL, NULL)); +} + +/** + * xmlHashQLookup2: + * @table: the hash table + * @prefix: the prefix of the userdata + * @name: the name of the userdata + * @prefix2: the second prefix of the userdata + * @name2: a second name of the userdata + * + * Find the userdata specified by the QNames tuple + * + * Returns the pointer to the userdata + */ +void * +xmlHashQLookup2(xmlHashTablePtr table, const xmlChar *prefix, + const xmlChar *name, const xmlChar *prefix2, + const xmlChar *name2) { + return(xmlHashQLookup3(table, prefix, name, prefix2, name2, NULL, NULL)); +} + +/** + * xmlHashAddEntry3: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @name3: a third name of the userdata + * @userdata: a pointer to the userdata + * + * Add the @userdata to the hash @table. This can later be retrieved + * by using the tuple (@name, @name2, @name3). Duplicate entries generate + * errors. + * + * Returns 0 the addition succeeded and -1 in case of error. + */ +int +xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + void *userdata) { + unsigned long key, len = 0; + xmlHashEntryPtr entry; + xmlHashEntryPtr insert; + + if ((table == NULL) || (name == NULL)) + return(-1); + + /* + * If using a dict internalize if needed + */ + if (table->dict) { + if (!xmlDictOwns(table->dict, name)) { + name = xmlDictLookup(table->dict, name, -1); + if (name == NULL) + return(-1); + } + if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) { + name2 = xmlDictLookup(table->dict, name2, -1); + if (name2 == NULL) + return(-1); + } + if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) { + name3 = xmlDictLookup(table->dict, name3, -1); + if (name3 == NULL) + return(-1); + } + } + + /* + * Check for duplicate and insertion location. + */ + key = xmlHashComputeKey(table, name, name2, name3); + if (table->table[key].valid == 0) { + insert = NULL; + } else { + if (table->dict) { + for (insert = &(table->table[key]); insert->next != NULL; + insert = insert->next) { + if ((insert->name == name) && + (insert->name2 == name2) && + (insert->name3 == name3)) + return(-1); + len++; + } + if ((insert->name == name) && + (insert->name2 == name2) && + (insert->name3 == name3)) + return(-1); + } else { + for (insert = &(table->table[key]); insert->next != NULL; + insert = insert->next) { + if ((xmlStrEqual(insert->name, name)) && + (xmlStrEqual(insert->name2, name2)) && + (xmlStrEqual(insert->name3, name3))) + return(-1); + len++; + } + if ((xmlStrEqual(insert->name, name)) && + (xmlStrEqual(insert->name2, name2)) && + (xmlStrEqual(insert->name3, name3))) + return(-1); + } + } + + if (insert == NULL) { + entry = &(table->table[key]); + } else { + entry = xmlMalloc(sizeof(xmlHashEntry)); + if (entry == NULL) + return(-1); + } + + if (table->dict != NULL) { + entry->name = (xmlChar *) name; + entry->name2 = (xmlChar *) name2; + entry->name3 = (xmlChar *) name3; + } else { + entry->name = xmlStrdup(name); + entry->name2 = xmlStrdup(name2); + entry->name3 = xmlStrdup(name3); + } + entry->payload = userdata; + entry->next = NULL; + entry->valid = 1; + + + if (insert != NULL) + insert->next = entry; + + table->nbElems++; + + if (len > MAX_HASH_LEN) + xmlHashGrow(table, MAX_HASH_LEN * table->size); + + return(0); +} + +/** + * xmlHashUpdateEntry3: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @name3: a third name of the userdata + * @userdata: a pointer to the userdata + * @f: the deallocator function for replaced item (if any) + * + * Add the @userdata to the hash @table. This can later be retrieved + * by using the tuple (@name, @name2, @name3). Existing entry for this tuple + * will be removed and freed with @f if found. + * + * Returns 0 the addition succeeded and -1 in case of error. + */ +int +xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + void *userdata, xmlHashDeallocator f) { + unsigned long key; + xmlHashEntryPtr entry; + xmlHashEntryPtr insert; + + if ((table == NULL) || name == NULL) + return(-1); + + /* + * If using a dict internalize if needed + */ + if (table->dict) { + if (!xmlDictOwns(table->dict, name)) { + name = xmlDictLookup(table->dict, name, -1); + if (name == NULL) + return(-1); + } + if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) { + name2 = xmlDictLookup(table->dict, name2, -1); + if (name2 == NULL) + return(-1); + } + if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) { + name3 = xmlDictLookup(table->dict, name3, -1); + if (name3 == NULL) + return(-1); + } + } + + /* + * Check for duplicate and insertion location. + */ + key = xmlHashComputeKey(table, name, name2, name3); + if (table->table[key].valid == 0) { + insert = NULL; + } else { + if (table ->dict) { + for (insert = &(table->table[key]); insert->next != NULL; + insert = insert->next) { + if ((insert->name == name) && + (insert->name2 == name2) && + (insert->name3 == name3)) { + if (f) + f(insert->payload, insert->name); + insert->payload = userdata; + return(0); + } + } + if ((insert->name == name) && + (insert->name2 == name2) && + (insert->name3 == name3)) { + if (f) + f(insert->payload, insert->name); + insert->payload = userdata; + return(0); + } + } else { + for (insert = &(table->table[key]); insert->next != NULL; + insert = insert->next) { + if ((xmlStrEqual(insert->name, name)) && + (xmlStrEqual(insert->name2, name2)) && + (xmlStrEqual(insert->name3, name3))) { + if (f) + f(insert->payload, insert->name); + insert->payload = userdata; + return(0); + } + } + if ((xmlStrEqual(insert->name, name)) && + (xmlStrEqual(insert->name2, name2)) && + (xmlStrEqual(insert->name3, name3))) { + if (f) + f(insert->payload, insert->name); + insert->payload = userdata; + return(0); + } + } + } + + if (insert == NULL) { + entry = &(table->table[key]); + } else { + entry = xmlMalloc(sizeof(xmlHashEntry)); + if (entry == NULL) + return(-1); + } + + if (table->dict != NULL) { + entry->name = (xmlChar *) name; + entry->name2 = (xmlChar *) name2; + entry->name3 = (xmlChar *) name3; + } else { + entry->name = xmlStrdup(name); + entry->name2 = xmlStrdup(name2); + entry->name3 = xmlStrdup(name3); + } + entry->payload = userdata; + entry->next = NULL; + entry->valid = 1; + table->nbElems++; + + + if (insert != NULL) { + insert->next = entry; + } + return(0); +} + +/** + * xmlHashLookup3: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @name3: a third name of the userdata + * + * Find the userdata specified by the (@name, @name2, @name3) tuple. + * + * Returns the a pointer to the userdata + */ +void * +xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3) { + unsigned long key; + xmlHashEntryPtr entry; + + if (table == NULL) + return(NULL); + if (name == NULL) + return(NULL); + key = xmlHashComputeKey(table, name, name2, name3); + if (table->table[key].valid == 0) + return(NULL); + if (table->dict) { + for (entry = &(table->table[key]); entry != NULL; entry = entry->next) { + if ((entry->name == name) && + (entry->name2 == name2) && + (entry->name3 == name3)) + return(entry->payload); + } + } + for (entry = &(table->table[key]); entry != NULL; entry = entry->next) { + if ((xmlStrEqual(entry->name, name)) && + (xmlStrEqual(entry->name2, name2)) && + (xmlStrEqual(entry->name3, name3))) + return(entry->payload); + } + return(NULL); +} + +/** + * xmlHashQLookup3: + * @table: the hash table + * @prefix: the prefix of the userdata + * @name: the name of the userdata + * @prefix2: the second prefix of the userdata + * @name2: a second name of the userdata + * @prefix3: the third prefix of the userdata + * @name3: a third name of the userdata + * + * Find the userdata specified by the (@name, @name2, @name3) tuple. + * + * Returns the a pointer to the userdata + */ +void * +xmlHashQLookup3(xmlHashTablePtr table, + const xmlChar *prefix, const xmlChar *name, + const xmlChar *prefix2, const xmlChar *name2, + const xmlChar *prefix3, const xmlChar *name3) { + unsigned long key; + xmlHashEntryPtr entry; + + if (table == NULL) + return(NULL); + if (name == NULL) + return(NULL); + key = xmlHashComputeQKey(table, prefix, name, prefix2, + name2, prefix3, name3); + if (table->table[key].valid == 0) + return(NULL); + for (entry = &(table->table[key]); entry != NULL; entry = entry->next) { + if ((xmlStrQEqual(prefix, name, entry->name)) && + (xmlStrQEqual(prefix2, name2, entry->name2)) && + (xmlStrQEqual(prefix3, name3, entry->name3))) + return(entry->payload); + } + return(NULL); +} + +typedef struct { + xmlHashScanner hashscanner; + void *data; +} stubData; + +static void +stubHashScannerFull (void *payload, void *data, const xmlChar *name, + const xmlChar *name2 ATTRIBUTE_UNUSED, + const xmlChar *name3 ATTRIBUTE_UNUSED) { + stubData *stubdata = (stubData *) data; + stubdata->hashscanner (payload, stubdata->data, (xmlChar *) name); +} + +/** + * xmlHashScan: + * @table: the hash table + * @f: the scanner function for items in the hash + * @data: extra data passed to f + * + * Scan the hash @table and applied @f to each value. + */ +void +xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) { + stubData stubdata; + stubdata.data = data; + stubdata.hashscanner = f; + xmlHashScanFull (table, stubHashScannerFull, &stubdata); +} + +/** + * xmlHashScanFull: + * @table: the hash table + * @f: the scanner function for items in the hash + * @data: extra data passed to f + * + * Scan the hash @table and applied @f to each value. + */ +void +xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) { + int i, nb; + xmlHashEntryPtr iter; + xmlHashEntryPtr next; + + if (table == NULL) + return; + if (f == NULL) + return; + + if (table->table) { + for(i = 0; i < table->size; i++) { + if (table->table[i].valid == 0) + continue; + iter = &(table->table[i]); + while (iter) { + next = iter->next; + nb = table->nbElems; + if ((f != NULL) && (iter->payload != NULL)) + f(iter->payload, data, iter->name, + iter->name2, iter->name3); + if (nb != table->nbElems) { + /* table was modified by the callback, be careful */ + if (iter == &(table->table[i])) { + if (table->table[i].valid == 0) + iter = NULL; + if (table->table[i].next != next) + iter = &(table->table[i]); + } else + iter = next; + } else + iter = next; + } + } + } +} + +/** + * xmlHashScan3: + * @table: the hash table + * @name: the name of the userdata or NULL + * @name2: a second name of the userdata or NULL + * @name3: a third name of the userdata or NULL + * @f: the scanner function for items in the hash + * @data: extra data passed to f + * + * Scan the hash @table and applied @f to each value matching + * (@name, @name2, @name3) tuple. If one of the names is null, + * the comparison is considered to match. + */ +void +xmlHashScan3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + xmlHashScanner f, void *data) { + stubData stubdata; + stubdata.data = data; + stubdata.hashscanner = f; + xmlHashScanFull3(table, name, name2, name3, stubHashScannerFull, + &stubdata); +} + +/** + * xmlHashScanFull3: + * @table: the hash table + * @name: the name of the userdata or NULL + * @name2: a second name of the userdata or NULL + * @name3: a third name of the userdata or NULL + * @f: the scanner function for items in the hash + * @data: extra data passed to f + * + * Scan the hash @table and applied @f to each value matching + * (@name, @name2, @name3) tuple. If one of the names is null, + * the comparison is considered to match. + */ +void +xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + xmlHashScannerFull f, void *data) { + int i; + xmlHashEntryPtr iter; + xmlHashEntryPtr next; + + if (table == NULL) + return; + if (f == NULL) + return; + + if (table->table) { + for(i = 0; i < table->size; i++) { + if (table->table[i].valid == 0) + continue; + iter = &(table->table[i]); + while (iter) { + next = iter->next; + if (((name == NULL) || (xmlStrEqual(name, iter->name))) && + ((name2 == NULL) || (xmlStrEqual(name2, iter->name2))) && + ((name3 == NULL) || (xmlStrEqual(name3, iter->name3))) && + (iter->payload != NULL)) { + f(iter->payload, data, iter->name, + iter->name2, iter->name3); + } + iter = next; + } + } + } +} + +/** + * xmlHashCopy: + * @table: the hash table + * @f: the copier function for items in the hash + * + * Scan the hash @table and applied @f to each value. + * + * Returns the new table or NULL in case of error. + */ +xmlHashTablePtr +xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) { + int i; + xmlHashEntryPtr iter; + xmlHashEntryPtr next; + xmlHashTablePtr ret; + + if (table == NULL) + return(NULL); + if (f == NULL) + return(NULL); + + ret = xmlHashCreate(table->size); + if (ret == NULL) + return(NULL); + + if (table->table) { + for(i = 0; i < table->size; i++) { + if (table->table[i].valid == 0) + continue; + iter = &(table->table[i]); + while (iter) { + next = iter->next; + xmlHashAddEntry3(ret, iter->name, iter->name2, + iter->name3, f(iter->payload, iter->name)); + iter = next; + } + } + } + ret->nbElems = table->nbElems; + return(ret); +} + +/** + * xmlHashSize: + * @table: the hash table + * + * Query the number of elements installed in the hash @table. + * + * Returns the number of elements in the hash table or + * -1 in case of error + */ +int +xmlHashSize(xmlHashTablePtr table) { + if (table == NULL) + return(-1); + return(table->nbElems); +} + +/** + * xmlHashRemoveEntry: + * @table: the hash table + * @name: the name of the userdata + * @f: the deallocator function for removed item (if any) + * + * Find the userdata specified by the @name and remove + * it from the hash @table. Existing userdata for this tuple will be removed + * and freed with @f. + * + * Returns 0 if the removal succeeded and -1 in case of error or not found. + */ +int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, + xmlHashDeallocator f) { + return(xmlHashRemoveEntry3(table, name, NULL, NULL, f)); +} + +/** + * xmlHashRemoveEntry2: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @f: the deallocator function for removed item (if any) + * + * Find the userdata specified by the (@name, @name2) tuple and remove + * it from the hash @table. Existing userdata for this tuple will be removed + * and freed with @f. + * + * Returns 0 if the removal succeeded and -1 in case of error or not found. + */ +int +xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, xmlHashDeallocator f) { + return(xmlHashRemoveEntry3(table, name, name2, NULL, f)); +} + +/** + * xmlHashRemoveEntry3: + * @table: the hash table + * @name: the name of the userdata + * @name2: a second name of the userdata + * @name3: a third name of the userdata + * @f: the deallocator function for removed item (if any) + * + * Find the userdata specified by the (@name, @name2, @name3) tuple and remove + * it from the hash @table. Existing userdata for this tuple will be removed + * and freed with @f. + * + * Returns 0 if the removal succeeded and -1 in case of error or not found. + */ +int +xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, xmlHashDeallocator f) { + unsigned long key; + xmlHashEntryPtr entry; + xmlHashEntryPtr prev = NULL; + + if (table == NULL || name == NULL) + return(-1); + + key = xmlHashComputeKey(table, name, name2, name3); + if (table->table[key].valid == 0) { + return(-1); + } else { + for (entry = &(table->table[key]); entry != NULL; entry = entry->next) { + if (xmlStrEqual(entry->name, name) && + xmlStrEqual(entry->name2, name2) && + xmlStrEqual(entry->name3, name3)) { + if ((f != NULL) && (entry->payload != NULL)) + f(entry->payload, entry->name); + entry->payload = NULL; + if (table->dict == NULL) { + if(entry->name) + xmlFree(entry->name); + if(entry->name2) + xmlFree(entry->name2); + if(entry->name3) + xmlFree(entry->name3); + } + if(prev) { + prev->next = entry->next; + xmlFree(entry); + } else { + if (entry->next == NULL) { + entry->valid = 0; + } else { + entry = entry->next; + memcpy(&(table->table[key]), entry, sizeof(xmlHashEntry)); + xmlFree(entry); + } + } + table->nbElems--; + return(0); + } + prev = entry; + } + return(-1); + } +} + +#define bottom_hash +#include "elfgcchack.h" diff --git a/src/include/Makefile.am b/src/include/Makefile.am new file mode 100644 index 000000000000..7dbfaa5bb58f --- /dev/null +++ b/src/include/Makefile.am @@ -0,0 +1,5 @@ +## Process this file with automake to produce Makefile.in +SUBDIRS=libxml + +EXTRA_DIST = win32config.h wsockcompat.h + diff --git a/src/include/libxml/DOCBparser.h b/src/include/libxml/DOCBparser.h new file mode 100644 index 000000000000..9394fa71bddc --- /dev/null +++ b/src/include/libxml/DOCBparser.h @@ -0,0 +1,96 @@ +/* + * Summary: old DocBook SGML parser + * Description: interface for a DocBook SGML non-verifying parser + * This code is DEPRECATED, and should not be used anymore. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DOCB_PARSER_H__ +#define __DOCB_PARSER_H__ +#include + +#ifdef LIBXML_DOCB_ENABLED + +#include +#include + +#ifndef IN_LIBXML +#ifdef __GNUC__ +#warning "The DOCBparser module has been deprecated in libxml2-2.6.0" +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most of the back-end structures from XML and SGML are shared. + */ +typedef xmlParserCtxt docbParserCtxt; +typedef xmlParserCtxtPtr docbParserCtxtPtr; +typedef xmlSAXHandler docbSAXHandler; +typedef xmlSAXHandlerPtr docbSAXHandlerPtr; +typedef xmlParserInput docbParserInput; +typedef xmlParserInputPtr docbParserInputPtr; +typedef xmlDocPtr docbDocPtr; + +/* + * There is only few public functions. + */ +XMLPUBFUN int XMLCALL + docbEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); + +XMLPUBFUN docbDocPtr XMLCALL + docbSAXParseDoc (xmlChar *cur, + const char *encoding, + docbSAXHandlerPtr sax, + void *userData); +XMLPUBFUN docbDocPtr XMLCALL + docbParseDoc (xmlChar *cur, + const char *encoding); +XMLPUBFUN docbDocPtr XMLCALL + docbSAXParseFile (const char *filename, + const char *encoding, + docbSAXHandlerPtr sax, + void *userData); +XMLPUBFUN docbDocPtr XMLCALL + docbParseFile (const char *filename, + const char *encoding); + +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN void XMLCALL + docbFreeParserCtxt (docbParserCtxtPtr ctxt); +XMLPUBFUN docbParserCtxtPtr XMLCALL + docbCreatePushParserCtxt(docbSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + docbParseChunk (docbParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +XMLPUBFUN docbParserCtxtPtr XMLCALL + docbCreateFileParserCtxt(const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + docbParseDocument (docbParserCtxtPtr ctxt); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DOCB_ENABLED */ + +#endif /* __DOCB_PARSER_H__ */ diff --git a/src/include/libxml/HTMLparser.h b/src/include/libxml/HTMLparser.h new file mode 100644 index 000000000000..1d4fec2f7343 --- /dev/null +++ b/src/include/libxml/HTMLparser.h @@ -0,0 +1,306 @@ +/* + * Summary: interface for an HTML 4.0 non-verifying parser + * Description: this module implements an HTML 4.0 non-verifying parser + * with API compatible with the XML parser ones. It should + * be able to parse "real world" HTML, even if severely + * broken from a specification point of view. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_PARSER_H__ +#define __HTML_PARSER_H__ +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most of the back-end structures from XML and HTML are shared. + */ +typedef xmlParserCtxt htmlParserCtxt; +typedef xmlParserCtxtPtr htmlParserCtxtPtr; +typedef xmlParserNodeInfo htmlParserNodeInfo; +typedef xmlSAXHandler htmlSAXHandler; +typedef xmlSAXHandlerPtr htmlSAXHandlerPtr; +typedef xmlParserInput htmlParserInput; +typedef xmlParserInputPtr htmlParserInputPtr; +typedef xmlDocPtr htmlDocPtr; +typedef xmlNodePtr htmlNodePtr; + +/* + * Internal description of an HTML element, representing HTML 4.01 + * and XHTML 1.0 (which share the same structure). + */ +typedef struct _htmlElemDesc htmlElemDesc; +typedef htmlElemDesc *htmlElemDescPtr; +struct _htmlElemDesc { + const char *name; /* The tag name */ + char startTag; /* Whether the start tag can be implied */ + char endTag; /* Whether the end tag can be implied */ + char saveEndTag; /* Whether the end tag should be saved */ + char empty; /* Is this an empty element ? */ + char depr; /* Is this a deprecated element ? */ + char dtd; /* 1: only in Loose DTD, 2: only Frameset one */ + char isinline; /* is this a block 0 or inline 1 element */ + const char *desc; /* the description */ + +/* NRK Jan.2003 + * New fields encapsulating HTML structure + * + * Bugs: + * This is a very limited representation. It fails to tell us when + * an element *requires* subelements (we only have whether they're + * allowed or not), and it doesn't tell us where CDATA and PCDATA + * are allowed. Some element relationships are not fully represented: + * these are flagged with the word MODIFIER + */ + const char** subelts; /* allowed sub-elements of this element */ + const char* defaultsubelt; /* subelement for suggested auto-repair + if necessary or NULL */ + const char** attrs_opt; /* Optional Attributes */ + const char** attrs_depr; /* Additional deprecated attributes */ + const char** attrs_req; /* Required attributes */ +}; + +/* + * Internal description of an HTML entity. + */ +typedef struct _htmlEntityDesc htmlEntityDesc; +typedef htmlEntityDesc *htmlEntityDescPtr; +struct _htmlEntityDesc { + unsigned int value; /* the UNICODE value for the character */ + const char *name; /* The entity name */ + const char *desc; /* the description */ +}; + +/* + * There is only few public functions. + */ +XMLPUBFUN const htmlElemDesc * XMLCALL + htmlTagLookup (const xmlChar *tag); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlEntityLookup(const xmlChar *name); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlEntityValueLookup(unsigned int value); + +XMLPUBFUN int XMLCALL + htmlIsAutoClosed(htmlDocPtr doc, + htmlNodePtr elem); +XMLPUBFUN int XMLCALL + htmlAutoCloseTag(htmlDocPtr doc, + const xmlChar *name, + htmlNodePtr elem); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlParseEntityRef(htmlParserCtxtPtr ctxt, + const xmlChar **str); +XMLPUBFUN int XMLCALL + htmlParseCharRef(htmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + htmlParseElement(htmlParserCtxtPtr ctxt); + +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlNewParserCtxt(void); + +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlCreateMemoryParserCtxt(const char *buffer, + int size); + +XMLPUBFUN int XMLCALL + htmlParseDocument(htmlParserCtxtPtr ctxt); +XMLPUBFUN htmlDocPtr XMLCALL + htmlSAXParseDoc (const xmlChar *cur, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr XMLCALL + htmlParseDoc (const xmlChar *cur, + const char *encoding); +XMLPUBFUN htmlDocPtr XMLCALL + htmlSAXParseFile(const char *filename, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr XMLCALL + htmlParseFile (const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + UTF8ToHtml (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +XMLPUBFUN int XMLCALL + htmlEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); +XMLPUBFUN int XMLCALL + htmlIsScriptAttribute(const xmlChar *name); +XMLPUBFUN int XMLCALL + htmlHandleOmittedElem(int val); + +#ifdef LIBXML_PUSH_ENABLED +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + htmlParseChunk (htmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +XMLPUBFUN void XMLCALL + htmlFreeParserCtxt (htmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + HTML_PARSE_RECOVER = 1<<0, /* Relaxed parsing */ + HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */ + HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */ + HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + HTML_PARSE_NONET = 1<<11,/* Forbid network access */ + HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */ + HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */ + HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */ +} htmlParserOption; + +XMLPUBFUN void XMLCALL + htmlCtxtReset (htmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + htmlCtxtUseOptions (htmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/* NRK/Jan2003: further knowledge of HTML structure + */ +typedef enum { + HTML_NA = 0 , /* something we don't check at all */ + HTML_INVALID = 0x1 , + HTML_DEPRECATED = 0x2 , + HTML_VALID = 0x4 , + HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */ +} htmlStatus ; + +/* Using htmlElemDesc rather than name here, to emphasise the fact + that otherwise there's a lookup overhead +*/ +XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ; +XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ; +XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ; +XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ; +/** + * htmlDefaultSubelement: + * @elt: HTML element + * + * Returns the default subelement for this element + */ +#define htmlDefaultSubelement(elt) elt->defaultsubelt +/** + * htmlElementAllowedHereDesc: + * @parent: HTML parent element + * @elt: HTML element + * + * Checks whether an HTML element description may be a + * direct child of the specified element. + * + * Returns 1 if allowed; 0 otherwise. + */ +#define htmlElementAllowedHereDesc(parent,elt) \ + htmlElementAllowedHere((parent), (elt)->name) +/** + * htmlRequiredAttrs: + * @elt: HTML element + * + * Returns the attributes required for the specified element. + */ +#define htmlRequiredAttrs(elt) (elt)->attrs_req + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ +#endif /* __HTML_PARSER_H__ */ diff --git a/src/include/libxml/HTMLtree.h b/src/include/libxml/HTMLtree.h new file mode 100644 index 000000000000..c0e110330c5b --- /dev/null +++ b/src/include/libxml/HTMLtree.h @@ -0,0 +1,147 @@ +/* + * Summary: specific APIs to process HTML tree, especially serialization + * Description: this module implements a few function needed to process + * tree in an HTML specific way. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_TREE_H__ +#define __HTML_TREE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * HTML_TEXT_NODE: + * + * Macro. A text node in a HTML document is really implemented + * the same way as a text node in an XML document. + */ +#define HTML_TEXT_NODE XML_TEXT_NODE +/** + * HTML_ENTITY_REF_NODE: + * + * Macro. An entity reference in a HTML document is really implemented + * the same way as an entity reference in an XML document. + */ +#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE +/** + * HTML_COMMENT_NODE: + * + * Macro. A comment in a HTML document is really implemented + * the same way as a comment in an XML document. + */ +#define HTML_COMMENT_NODE XML_COMMENT_NODE +/** + * HTML_PRESERVE_NODE: + * + * Macro. A preserved node in a HTML document is really implemented + * the same way as a CDATA section in an XML document. + */ +#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE +/** + * HTML_PI_NODE: + * + * Macro. A processing instruction in a HTML document is really implemented + * the same way as a processing instruction in an XML document. + */ +#define HTML_PI_NODE XML_PI_NODE + +XMLPUBFUN htmlDocPtr XMLCALL + htmlNewDoc (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN htmlDocPtr XMLCALL + htmlNewDocNoDtD (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN const xmlChar * XMLCALL + htmlGetMetaEncoding (htmlDocPtr doc); +XMLPUBFUN int XMLCALL + htmlSetMetaEncoding (htmlDocPtr doc, + const xmlChar *encoding); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + htmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void XMLCALL + htmlDocDumpMemoryFormat (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN int XMLCALL + htmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + htmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + htmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN void XMLCALL + htmlNodeDumpFile (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int XMLCALL + htmlNodeDumpFileFormat (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN int XMLCALL + htmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int XMLCALL + htmlSaveFileFormat (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN void XMLCALL + htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + htmlDocContentDumpOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN void XMLCALL + htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + htmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XMLPUBFUN int XMLCALL + htmlIsBooleanAttr (const xmlChar *name); + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ + +#endif /* __HTML_TREE_H__ */ + diff --git a/src/include/libxml/Makefile.am b/src/include/libxml/Makefile.am new file mode 100644 index 000000000000..328c1800e8d3 --- /dev/null +++ b/src/include/libxml/Makefile.am @@ -0,0 +1,54 @@ +## Process this file with automake to produce Makefile.in + +xmlincdir = $(includedir)/libxml2/libxml + +xmlinc_HEADERS = \ + SAX.h \ + entities.h \ + encoding.h \ + parser.h \ + parserInternals.h \ + xmlerror.h \ + HTMLparser.h \ + HTMLtree.h \ + debugXML.h \ + tree.h \ + list.h \ + hash.h \ + xpath.h \ + xpathInternals.h \ + xpointer.h \ + xinclude.h \ + xmlIO.h \ + xmlmemory.h \ + nanohttp.h \ + nanoftp.h \ + uri.h \ + valid.h \ + xlink.h \ + xmlversion.h \ + DOCBparser.h \ + catalog.h \ + threads.h \ + globals.h \ + c14n.h \ + xmlautomata.h \ + xmlregexp.h \ + xmlmodule.h \ + xmlschemas.h \ + schemasInternals.h \ + xmlschemastypes.h \ + xmlstring.h \ + xmlunicode.h \ + xmlreader.h \ + relaxng.h \ + dict.h \ + SAX2.h \ + xmlexports.h \ + xmlwriter.h \ + chvalid.h \ + pattern.h \ + xmlsave.h \ + schematron.h + +EXTRA_DIST = xmlversion.h.in xmlwin32version.h.in diff --git a/src/include/libxml/SAX.h b/src/include/libxml/SAX.h new file mode 100644 index 000000000000..20093ceb6853 --- /dev/null +++ b/src/include/libxml/SAX.h @@ -0,0 +1,173 @@ +/* + * Summary: Old SAX version 1 handler, deprecated + * Description: DEPRECATED set of SAX version 1 interfaces used to + * build the DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX_H__ +#define __XML_SAX_H__ + +#include +#include +#include +#include +#include + +#ifdef LIBXML_LEGACY_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * XMLCALL + getPublicId (void *ctx); +XMLPUBFUN const xmlChar * XMLCALL + getSystemId (void *ctx); +XMLPUBFUN void XMLCALL + setDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int XMLCALL + getLineNumber (void *ctx); +XMLPUBFUN int XMLCALL + getColumnNumber (void *ctx); + +XMLPUBFUN int XMLCALL + isStandalone (void *ctx); +XMLPUBFUN int XMLCALL + hasInternalSubset (void *ctx); +XMLPUBFUN int XMLCALL + hasExternalSubset (void *ctx); + +XMLPUBFUN void XMLCALL + internalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void XMLCALL + externalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr XMLCALL + getEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + getParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr XMLCALL + resolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void XMLCALL + entityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void XMLCALL + attributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void XMLCALL + elementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + notationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void XMLCALL + unparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void XMLCALL + startDocument (void *ctx); +XMLPUBFUN void XMLCALL + endDocument (void *ctx); +XMLPUBFUN void XMLCALL + attribute (void *ctx, + const xmlChar *fullname, + const xmlChar *value); +XMLPUBFUN void XMLCALL + startElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XMLPUBFUN void XMLCALL + endElement (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + ignorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + processingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void XMLCALL + globalNamespace (void *ctx, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + setNamespace (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlNsPtr XMLCALL + getNamespace (void *ctx); +XMLPUBFUN int XMLCALL + checkNamespace (void *ctx, + xmlChar *nameSpace); +XMLPUBFUN void XMLCALL + namespaceDecl (void *ctx, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void XMLCALL + cdataBlock (void *ctx, + const xmlChar *value, + int len); + +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN void XMLCALL + initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void XMLCALL + inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); +#endif +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN void XMLCALL + initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); +#endif +#endif /* LIBXML_SAX1_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_LEGACY_ENABLED */ + +#endif /* __XML_SAX_H__ */ diff --git a/src/include/libxml/SAX2.h b/src/include/libxml/SAX2.h new file mode 100644 index 000000000000..a55212eb554d --- /dev/null +++ b/src/include/libxml/SAX2.h @@ -0,0 +1,178 @@ +/* + * Summary: SAX2 parser interface used to build the DOM tree + * Description: those are the default SAX2 interfaces used by + * the library when building DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX2_H__ +#define __XML_SAX2_H__ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * XMLCALL + xmlSAX2GetPublicId (void *ctx); +XMLPUBFUN const xmlChar * XMLCALL + xmlSAX2GetSystemId (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2SetDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int XMLCALL + xmlSAX2GetLineNumber (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2GetColumnNumber (void *ctx); + +XMLPUBFUN int XMLCALL + xmlSAX2IsStandalone (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2HasInternalSubset (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2HasExternalSubset (void *ctx); + +XMLPUBFUN void XMLCALL + xmlSAX2InternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void XMLCALL + xmlSAX2ExternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlSAX2GetEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlSAX2GetParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlSAX2ResolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void XMLCALL + xmlSAX2EntityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void XMLCALL + xmlSAX2AttributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void XMLCALL + xmlSAX2ElementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlSAX2NotationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void XMLCALL + xmlSAX2UnparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void XMLCALL + xmlSAX2StartDocument (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2EndDocument (void *ctx); +#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \ + defined(LIBXML_LEGACY_ENABLED) +XMLPUBFUN void XMLCALL + xmlSAX2StartElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XMLPUBFUN void XMLCALL + xmlSAX2EndElement (void *ctx, + const xmlChar *name); +#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */ +XMLPUBFUN void XMLCALL + xmlSAX2StartElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); +XMLPUBFUN void XMLCALL + xmlSAX2EndElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); +XMLPUBFUN void XMLCALL + xmlSAX2Reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSAX2Characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + xmlSAX2IgnorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + xmlSAX2ProcessingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void XMLCALL + xmlSAX2Comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlSAX2CDataBlock (void *ctx, + const xmlChar *value, + int len); + +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlSAXDefaultVersion (int version); +#endif /* LIBXML_SAX1_ENABLED */ + +XMLPUBFUN int XMLCALL + xmlSAXVersion (xmlSAXHandler *hdlr, + int version); +XMLPUBFUN void XMLCALL + xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void XMLCALL + xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr); +XMLPUBFUN void XMLCALL + htmlDefaultSAXHandlerInit (void); +#endif +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN void XMLCALL + xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr); +XMLPUBFUN void XMLCALL + docbDefaultSAXHandlerInit (void); +#endif +XMLPUBFUN void XMLCALL + xmlDefaultSAXHandlerInit (void); +#ifdef __cplusplus +} +#endif +#endif /* __XML_SAX2_H__ */ diff --git a/src/include/libxml/c14n.h b/src/include/libxml/c14n.h new file mode 100644 index 000000000000..af93de63a4c3 --- /dev/null +++ b/src/include/libxml/c14n.h @@ -0,0 +1,128 @@ +/* + * Summary: Provide Canonical XML and Exclusive XML Canonicalization + * Description: the c14n modules provides a + * + * "Canonical XML" implementation + * http://www.w3.org/TR/xml-c14n + * + * and an + * + * "Exclusive XML Canonicalization" implementation + * http://www.w3.org/TR/xml-exc-c14n + + * Copy: See Copyright for the status of this software. + * + * Author: Aleksey Sanin + */ +#ifndef __XML_C14N_H__ +#define __XML_C14N_H__ + +#include + +#ifdef LIBXML_C14N_ENABLED +#ifdef LIBXML_OUTPUT_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * XML Canonicalization + * http://www.w3.org/TR/xml-c14n + * + * Exclusive XML Canonicalization + * http://www.w3.org/TR/xml-exc-c14n + * + * Canonical form of an XML document could be created if and only if + * a) default attributes (if any) are added to all nodes + * b) all character and parsed entity references are resolved + * In order to achieve this in libxml2 the document MUST be loaded with + * following global settings: + * + * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + * xmlSubstituteEntitiesDefault(1); + * + * or corresponding parser context setting: + * xmlParserCtxtPtr ctxt; + * + * ... + * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + * ctxt->replaceEntities = 1; + * ... + */ + +/* + * xmlC14NMode: + * + * Predefined values for C14N modes + * + */ +typedef enum { + XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */ + XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */ + XML_C14N_1_1 = 2 /* C14N 1.1 spec */ +} xmlC14NMode; + +XMLPUBFUN int XMLCALL + xmlC14NDocSaveTo (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +XMLPUBFUN int XMLCALL + xmlC14NDocDumpMemory (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlChar **doc_txt_ptr); + +XMLPUBFUN int XMLCALL + xmlC14NDocSave (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + const char* filename, + int compression); + + +/** + * This is the core C14N function + */ +/** + * xmlC14NIsVisibleCallback: + * @user_data: user data + * @node: the current node + * @parent: the parent node + * + * Signature for a C14N callback on visible nodes + * + * Returns 1 if the node should be included + */ +typedef int (*xmlC14NIsVisibleCallback) (void* user_data, + xmlNodePtr node, + xmlNodePtr parent); + +XMLPUBFUN int XMLCALL + xmlC14NExecute (xmlDocPtr doc, + xmlC14NIsVisibleCallback is_visible_callback, + void* user_data, + int mode, /* a xmlC14NMode */ + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* LIBXML_C14N_ENABLED */ +#endif /* __XML_C14N_H__ */ + diff --git a/src/include/libxml/catalog.h b/src/include/libxml/catalog.h new file mode 100644 index 000000000000..26b178dbbc9c --- /dev/null +++ b/src/include/libxml/catalog.h @@ -0,0 +1,182 @@ +/** + * Summary: interfaces to the Catalog handling system + * Description: the catalog module implements the support for + * XML Catalogs and SGML catalogs + * + * SGML Open Technical Resolution TR9401:1997. + * http://www.jclark.com/sp/catalog.htm + * + * XML Catalogs Working Draft 06 August 2001 + * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CATALOG_H__ +#define __XML_CATALOG_H__ + +#include + +#include +#include +#include + +#ifdef LIBXML_CATALOG_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_CATALOGS_NAMESPACE: + * + * The namespace for the XML Catalogs elements. + */ +#define XML_CATALOGS_NAMESPACE \ + (const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog" +/** + * XML_CATALOG_PI: + * + * The specific XML Catalog Processing Instruction name. + */ +#define XML_CATALOG_PI \ + (const xmlChar *) "oasis-xml-catalog" + +/* + * The API is voluntarily limited to general cataloging. + */ +typedef enum { + XML_CATA_PREFER_NONE = 0, + XML_CATA_PREFER_PUBLIC = 1, + XML_CATA_PREFER_SYSTEM +} xmlCatalogPrefer; + +typedef enum { + XML_CATA_ALLOW_NONE = 0, + XML_CATA_ALLOW_GLOBAL = 1, + XML_CATA_ALLOW_DOCUMENT = 2, + XML_CATA_ALLOW_ALL = 3 +} xmlCatalogAllow; + +typedef struct _xmlCatalog xmlCatalog; +typedef xmlCatalog *xmlCatalogPtr; + +/* + * Operations on a given catalog. + */ +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlNewCatalog (int sgml); +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlLoadACatalog (const char *filename); +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlLoadSGMLSuperCatalog (const char *filename); +XMLPUBFUN int XMLCALL + xmlConvertSGMLCatalog (xmlCatalogPtr catal); +XMLPUBFUN int XMLCALL + xmlACatalogAdd (xmlCatalogPtr catal, + const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int XMLCALL + xmlACatalogRemove (xmlCatalogPtr catal, + const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolve (xmlCatalogPtr catal, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolveSystem(xmlCatalogPtr catal, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolvePublic(xmlCatalogPtr catal, + const xmlChar *pubID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolveURI (xmlCatalogPtr catal, + const xmlChar *URI); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlACatalogDump (xmlCatalogPtr catal, + FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeCatalog (xmlCatalogPtr catal); +XMLPUBFUN int XMLCALL + xmlCatalogIsEmpty (xmlCatalogPtr catal); + +/* + * Global operations. + */ +XMLPUBFUN void XMLCALL + xmlInitializeCatalog (void); +XMLPUBFUN int XMLCALL + xmlLoadCatalog (const char *filename); +XMLPUBFUN void XMLCALL + xmlLoadCatalogs (const char *paths); +XMLPUBFUN void XMLCALL + xmlCatalogCleanup (void); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlCatalogDump (FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolve (const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolveSystem (const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolvePublic (const xmlChar *pubID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolveURI (const xmlChar *URI); +XMLPUBFUN int XMLCALL + xmlCatalogAdd (const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int XMLCALL + xmlCatalogRemove (const xmlChar *value); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseCatalogFile (const char *filename); +XMLPUBFUN int XMLCALL + xmlCatalogConvert (void); + +/* + * Strictly minimal interfaces for per-document catalogs used + * by the parser. + */ +XMLPUBFUN void XMLCALL + xmlCatalogFreeLocal (void *catalogs); +XMLPUBFUN void * XMLCALL + xmlCatalogAddLocal (void *catalogs, + const xmlChar *URL); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogLocalResolve (void *catalogs, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogLocalResolveURI(void *catalogs, + const xmlChar *URI); +/* + * Preference settings. + */ +XMLPUBFUN int XMLCALL + xmlCatalogSetDebug (int level); +XMLPUBFUN xmlCatalogPrefer XMLCALL + xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer); +XMLPUBFUN void XMLCALL + xmlCatalogSetDefaults (xmlCatalogAllow allow); +XMLPUBFUN xmlCatalogAllow XMLCALL + xmlCatalogGetDefaults (void); + + +/* DEPRECATED interfaces */ +XMLPUBFUN const xmlChar * XMLCALL + xmlCatalogGetSystem (const xmlChar *sysID); +XMLPUBFUN const xmlChar * XMLCALL + xmlCatalogGetPublic (const xmlChar *pubID); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_CATALOG_ENABLED */ +#endif /* __XML_CATALOG_H__ */ diff --git a/src/include/libxml/chvalid.h b/src/include/libxml/chvalid.h new file mode 100644 index 000000000000..fb43016982d3 --- /dev/null +++ b/src/include/libxml/chvalid.h @@ -0,0 +1,230 @@ +/* + * Summary: Unicode character range checking + * Description: this module exports interfaces for the character + * range validation APIs + * + * This file is automatically generated from the cvs source + * definition files using the genChRanges.py Python script + * + * Generation date: Mon Mar 27 11:09:48 2006 + * Sources: chvalid.def + * Author: William Brack + */ + +#ifndef __XML_CHVALID_H__ +#define __XML_CHVALID_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define our typedefs and structures + * + */ +typedef struct _xmlChSRange xmlChSRange; +typedef xmlChSRange *xmlChSRangePtr; +struct _xmlChSRange { + unsigned short low; + unsigned short high; +}; + +typedef struct _xmlChLRange xmlChLRange; +typedef xmlChLRange *xmlChLRangePtr; +struct _xmlChLRange { + unsigned int low; + unsigned int high; +}; + +typedef struct _xmlChRangeGroup xmlChRangeGroup; +typedef xmlChRangeGroup *xmlChRangeGroupPtr; +struct _xmlChRangeGroup { + int nbShortRange; + int nbLongRange; + const xmlChSRange *shortRange; /* points to an array of ranges */ + const xmlChLRange *longRange; +}; + +/** + * Range checking routine + */ +XMLPUBFUN int XMLCALL + xmlCharInRange(unsigned int val, const xmlChRangeGroup *group); + + +/** + * xmlIsBaseChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseChar_ch(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ + ((0x61 <= (c)) && ((c) <= 0x7a)) || \ + ((0xc0 <= (c)) && ((c) <= 0xd6)) || \ + ((0xd8 <= (c)) && ((c) <= 0xf6)) || \ + (0xf8 <= (c))) + +/** + * xmlIsBaseCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseCharQ(c) (((c) < 0x100) ? \ + xmlIsBaseChar_ch((c)) : \ + xmlCharInRange((c), &xmlIsBaseCharGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup; + +/** + * xmlIsBlank_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlank_ch(c) (((c) == 0x20) || \ + ((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd)) + +/** + * xmlIsBlankQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlankQ(c) (((c) < 0x100) ? \ + xmlIsBlank_ch((c)) : 0) + + +/** + * xmlIsChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsChar_ch(c) (((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd) || \ + (0x20 <= (c))) + +/** + * xmlIsCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCharQ(c) (((c) < 0x100) ? \ + xmlIsChar_ch((c)) :\ + (((0x100 <= (c)) && ((c) <= 0xd7ff)) || \ + ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \ + ((0x10000 <= (c)) && ((c) <= 0x10ffff)))) + +XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup; + +/** + * xmlIsCombiningQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCombiningQ(c) (((c) < 0x100) ? \ + 0 : \ + xmlCharInRange((c), &xmlIsCombiningGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup; + +/** + * xmlIsDigit_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigit_ch(c) (((0x30 <= (c)) && ((c) <= 0x39))) + +/** + * xmlIsDigitQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigitQ(c) (((c) < 0x100) ? \ + xmlIsDigit_ch((c)) : \ + xmlCharInRange((c), &xmlIsDigitGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup; + +/** + * xmlIsExtender_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtender_ch(c) (((c) == 0xb7)) + +/** + * xmlIsExtenderQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtenderQ(c) (((c) < 0x100) ? \ + xmlIsExtender_ch((c)) : \ + xmlCharInRange((c), &xmlIsExtenderGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup; + +/** + * xmlIsIdeographicQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsIdeographicQ(c) (((c) < 0x100) ? \ + 0 :\ + (((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \ + ((c) == 0x3007) || \ + ((0x3021 <= (c)) && ((c) <= 0x3029)))) + +XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup; +XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256]; + +/** + * xmlIsPubidChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)]) + +/** + * xmlIsPubidCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidCharQ(c) (((c) < 0x100) ? \ + xmlIsPubidChar_ch((c)) : 0) + +XMLPUBFUN int XMLCALL + xmlIsBaseChar(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsBlank(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsChar(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsCombining(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsDigit(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsExtender(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsIdeographic(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsPubidChar(unsigned int ch); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_CHVALID_H__ */ diff --git a/src/include/libxml/debugXML.h b/src/include/libxml/debugXML.h new file mode 100644 index 000000000000..5b3be13d8572 --- /dev/null +++ b/src/include/libxml/debugXML.h @@ -0,0 +1,217 @@ +/* + * Summary: Tree debugging APIs + * Description: Interfaces to a set of routines used for debugging the tree + * produced by the XML parser. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DEBUG_XML__ +#define __DEBUG_XML__ +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The standard Dump routines. + */ +XMLPUBFUN void XMLCALL + xmlDebugDumpString (FILE *output, + const xmlChar *str); +XMLPUBFUN void XMLCALL + xmlDebugDumpAttr (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpAttrList (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpOneNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpNodeList (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpDocumentHead(FILE *output, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlDebugDumpDocument (FILE *output, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlDebugDumpDTD (FILE *output, + xmlDtdPtr dtd); +XMLPUBFUN void XMLCALL + xmlDebugDumpEntities (FILE *output, + xmlDocPtr doc); + +/**************************************************************** + * * + * Checking routines * + * * + ****************************************************************/ + +XMLPUBFUN int XMLCALL + xmlDebugCheckDocument (FILE * output, + xmlDocPtr doc); + +/**************************************************************** + * * + * XML shell helpers * + * * + ****************************************************************/ + +XMLPUBFUN void XMLCALL + xmlLsOneNode (FILE *output, xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlLsCountNode (xmlNodePtr node); + +XMLPUBFUN const char * XMLCALL + xmlBoolToText (int boolval); + +/**************************************************************** + * * + * The XML shell related structures and functions * + * * + ****************************************************************/ + +#ifdef LIBXML_XPATH_ENABLED +/** + * xmlShellReadlineFunc: + * @prompt: a string prompt + * + * This is a generic signature for the XML shell input function. + * + * Returns a string which will be freed by the Shell. + */ +typedef char * (* xmlShellReadlineFunc)(char *prompt); + +/** + * xmlShellCtxt: + * + * A debugging shell context. + * TODO: add the defined function tables. + */ +typedef struct _xmlShellCtxt xmlShellCtxt; +typedef xmlShellCtxt *xmlShellCtxtPtr; +struct _xmlShellCtxt { + char *filename; + xmlDocPtr doc; + xmlNodePtr node; + xmlXPathContextPtr pctxt; + int loaded; + FILE *output; + xmlShellReadlineFunc input; +}; + +/** + * xmlShellCmd: + * @ctxt: a shell context + * @arg: a string argument + * @node: a first node + * @node2: a second node + * + * This is a generic signature for the XML shell functions. + * + * Returns an int, negative returns indicating errors. + */ +typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); + +XMLPUBFUN void XMLCALL + xmlShellPrintXPathError (int errorType, + const char *arg); +XMLPUBFUN void XMLCALL + xmlShellPrintXPathResult(xmlXPathObjectPtr list); +XMLPUBFUN int XMLCALL + xmlShellList (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellBase (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellDir (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellLoad (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlShellPrintNode (xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlShellCat (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellWrite (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellSave (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +#endif /* LIBXML_OUTPUT_ENABLED */ +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN int XMLCALL + xmlShellValidate (xmlShellCtxtPtr ctxt, + char *dtd, + xmlNodePtr node, + xmlNodePtr node2); +#endif /* LIBXML_VALID_ENABLED */ +XMLPUBFUN int XMLCALL + xmlShellDu (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr tree, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellPwd (xmlShellCtxtPtr ctxt, + char *buffer, + xmlNodePtr node, + xmlNodePtr node2); + +/* + * The Shell interface. + */ +XMLPUBFUN void XMLCALL + xmlShell (xmlDocPtr doc, + char *filename, + xmlShellReadlineFunc input, + FILE *output); + +#endif /* LIBXML_XPATH_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DEBUG_ENABLED */ +#endif /* __DEBUG_XML__ */ diff --git a/src/include/libxml/dict.h b/src/include/libxml/dict.h new file mode 100644 index 000000000000..cf54af1f252a --- /dev/null +++ b/src/include/libxml/dict.h @@ -0,0 +1,79 @@ +/* + * Summary: string dictionary + * Description: dictionary of reusable strings, just used to avoid allocation + * and freeing operations. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_DICT_H__ +#define __XML_DICT_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The dictionary. + */ +typedef struct _xmlDict xmlDict; +typedef xmlDict *xmlDictPtr; + +/* + * Initializer + */ +XMLPUBFUN int XMLCALL xmlInitializeDict(void); + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreate (void); +XMLPUBFUN size_t XMLCALL + xmlDictSetLimit (xmlDictPtr dict, + size_t limit); +XMLPUBFUN size_t XMLCALL + xmlDictGetUsage (xmlDictPtr dict); +XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreateSub(xmlDictPtr sub); +XMLPUBFUN int XMLCALL + xmlDictReference(xmlDictPtr dict); +XMLPUBFUN void XMLCALL + xmlDictFree (xmlDictPtr dict); + +/* + * Lookup of entry in the dictionary. + */ +XMLPUBFUN const xmlChar * XMLCALL + xmlDictLookup (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlDictExists (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlDictQLookup (xmlDictPtr dict, + const xmlChar *prefix, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlDictOwns (xmlDictPtr dict, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlDictSize (xmlDictPtr dict); + +/* + * Cleanup function + */ +XMLPUBFUN void XMLCALL + xmlDictCleanup (void); + +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_DICT_H__ */ diff --git a/src/include/libxml/encoding.h b/src/include/libxml/encoding.h new file mode 100644 index 000000000000..c875af6fb7c2 --- /dev/null +++ b/src/include/libxml/encoding.h @@ -0,0 +1,245 @@ +/* + * Summary: interface for the encoding conversion functions + * Description: interface for the encoding conversion functions needed for + * XML basic encoding and iconv() support. + * + * Related specs are + * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies + * [ISO-10646] UTF-8 and UTF-16 in Annexes + * [ISO-8859-1] ISO Latin-1 characters codes. + * [UNICODE] The Unicode Consortium, "The Unicode Standard -- + * Worldwide Character Encoding -- Version 1.0", Addison- + * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is + * described in Unicode Technical Report #4. + * [US-ASCII] Coded Character Set--7-bit American Standard Code for + * Information Interchange, ANSI X3.4-1986. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CHAR_ENCODING_H__ +#define __XML_CHAR_ENCODING_H__ + +#include + +#ifdef LIBXML_ICONV_ENABLED +#include +#endif +#ifdef LIBXML_ICU_ENABLED +#include +#endif +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlCharEncoding: + * + * Predefined values for some standard encodings. + * Libxml does not do beforehand translation on UTF8 and ISOLatinX. + * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default. + * + * Anything else would have to be translated to UTF8 before being + * given to the parser itself. The BOM for UTF16 and the encoding + * declaration are looked at and a converter is looked for at that + * point. If not found the parser stops here as asked by the XML REC. A + * converter can be registered by the user using xmlRegisterCharEncodingHandler + * but the current form doesn't allow stateful transcoding (a serious + * problem agreed !). If iconv has been found it will be used + * automatically and allow stateful transcoding, the simplest is then + * to be sure to enable iconv and to provide iconv libs for the encoding + * support needed. + * + * Note that the generic "UTF-16" is not a predefined value. Instead, only + * the specific UTF-16LE and UTF-16BE are present. + */ +typedef enum { + XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */ + XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */ + XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */ + XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */ + XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */ + XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */ + XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */ + XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */ + XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */ + XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */ + XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */ + XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */ + XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */ + XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */ + XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */ + XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */ + XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */ + XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */ + XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */ + XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */ + XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */ + XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */ +} xmlCharEncoding; + +/** + * xmlCharEncodingInputFunc: + * @out: a pointer to an array of bytes to store the UTF-8 result + * @outlen: the length of @out + * @in: a pointer to an array of chars in the original encoding + * @inlen: the length of @in + * + * Take a block of chars in the original encoding and try to convert + * it to an UTF-8 block of chars out. + * + * Returns the number of bytes written, -1 if lack of space, or -2 + * if the transcoding failed. + * The value of @inlen after return is the number of octets consumed + * if the return value is positive, else unpredictiable. + * The value of @outlen after return is the number of octets consumed. + */ +typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/** + * xmlCharEncodingOutputFunc: + * @out: a pointer to an array of bytes to store the result + * @outlen: the length of @out + * @in: a pointer to an array of UTF-8 chars + * @inlen: the length of @in + * + * Take a block of UTF-8 chars in and try to convert it to another + * encoding. + * Note: a first call designed to produce heading info is called with + * in = NULL. If stateful this should also initialize the encoder state. + * + * Returns the number of bytes written, -1 if lack of space, or -2 + * if the transcoding failed. + * The value of @inlen after return is the number of octets consumed + * if the return value is positive, else unpredictiable. + * The value of @outlen after return is the number of octets produced. + */ +typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/* + * Block defining the handlers for non UTF-8 encodings. + * If iconv is supported, there are two extra fields. + */ +#ifdef LIBXML_ICU_ENABLED +/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */ +#define ICU_PIVOT_BUF_SIZE 1024 +struct _uconv_t { + UConverter *uconv; /* for conversion between an encoding and UTF-16 */ + UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */ + UChar pivot_buf[ICU_PIVOT_BUF_SIZE]; + UChar *pivot_source; + UChar *pivot_target; +}; +typedef struct _uconv_t uconv_t; +#endif + +typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler; +typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr; +struct _xmlCharEncodingHandler { + char *name; + xmlCharEncodingInputFunc input; + xmlCharEncodingOutputFunc output; +#ifdef LIBXML_ICONV_ENABLED + iconv_t iconv_in; + iconv_t iconv_out; +#endif /* LIBXML_ICONV_ENABLED */ +#ifdef LIBXML_ICU_ENABLED + uconv_t *uconv_in; + uconv_t *uconv_out; +#endif /* LIBXML_ICU_ENABLED */ +}; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interfaces for encoding handlers. + */ +XMLPUBFUN void XMLCALL + xmlInitCharEncodingHandlers (void); +XMLPUBFUN void XMLCALL + xmlCleanupCharEncodingHandlers (void); +XMLPUBFUN void XMLCALL + xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlGetCharEncodingHandler (xmlCharEncoding enc); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlFindCharEncodingHandler (const char *name); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlNewCharEncodingHandler (const char *name, + xmlCharEncodingInputFunc input, + xmlCharEncodingOutputFunc output); + +/* + * Interfaces for encoding names and aliases. + */ +XMLPUBFUN int XMLCALL + xmlAddEncodingAlias (const char *name, + const char *alias); +XMLPUBFUN int XMLCALL + xmlDelEncodingAlias (const char *alias); +XMLPUBFUN const char * XMLCALL + xmlGetEncodingAlias (const char *alias); +XMLPUBFUN void XMLCALL + xmlCleanupEncodingAliases (void); +XMLPUBFUN xmlCharEncoding XMLCALL + xmlParseCharEncoding (const char *name); +XMLPUBFUN const char * XMLCALL + xmlGetCharEncodingName (xmlCharEncoding enc); + +/* + * Interfaces directly used by the parsers. + */ +XMLPUBFUN xmlCharEncoding XMLCALL + xmlDetectCharEncoding (const unsigned char *in, + int len); + +XMLPUBFUN int XMLCALL + xmlCharEncOutFunc (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); + +XMLPUBFUN int XMLCALL + xmlCharEncInFunc (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); +XMLPUBFUN int XMLCALL + xmlCharEncFirstLine (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); +XMLPUBFUN int XMLCALL + xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); + +/* + * Export a few useful functions + */ +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int XMLCALL + UTF8Toisolat1 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN int XMLCALL + isolat1ToUTF8 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#ifdef __cplusplus +} +#endif + +#endif /* __XML_CHAR_ENCODING_H__ */ diff --git a/src/include/libxml/entities.h b/src/include/libxml/entities.h new file mode 100644 index 000000000000..012efab294cb --- /dev/null +++ b/src/include/libxml/entities.h @@ -0,0 +1,157 @@ +/* + * Summary: interface for the XML entities handling + * Description: this module provides some of the entity API needed + * for the parser and applications. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_ENTITIES_H__ +#define __XML_ENTITIES_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The different valid entity types. + */ +typedef enum { + XML_INTERNAL_GENERAL_ENTITY = 1, + XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, + XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, + XML_INTERNAL_PARAMETER_ENTITY = 4, + XML_EXTERNAL_PARAMETER_ENTITY = 5, + XML_INTERNAL_PREDEFINED_ENTITY = 6 +} xmlEntityType; + +/* + * An unit of storage for an entity, contains the string, the value + * and the linkind data needed for the linking in the hash table. + */ + +typedef enum { + XML_ENTITY_NOT_BEING_CHECKED, + XML_ENTITY_BEING_CHECKED /* entity check is in progress */ +} xmlEntityRecursionGuard; + +struct _xmlEntity { + void *_private; /* application data */ + xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ + const xmlChar *name; /* Entity name */ + struct _xmlNode *children; /* First child link */ + struct _xmlNode *last; /* Last child link */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlChar *orig; /* content without ref substitution */ + xmlChar *content; /* content or ndata if unparsed */ + int length; /* the content length */ + xmlEntityType etype; /* The entity type */ + const xmlChar *ExternalID; /* External identifier for PUBLIC */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ + + struct _xmlEntity *nexte; /* unused */ + const xmlChar *URI; /* the full URI as computed */ + int owner; /* does the entity own the childrens */ + int checked; /* was the entity content checked and */ + /* l.o. bit: replacement contains '<' */ + /* remaining bits: one plus count of */ + /* entity references from this entity */ + xmlEntityRecursionGuard guard; +}; + +/* + * All entities are stored in an hash table. + * There is 2 separate hash tables for global and parameter entities. + */ + +typedef struct _xmlHashTable xmlEntitiesTable; +typedef xmlEntitiesTable *xmlEntitiesTablePtr; + +/* + * External functions: + */ + +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN void XMLCALL + xmlInitializePredefinedEntities (void); +#endif /* LIBXML_LEGACY_ENABLED */ + +XMLPUBFUN xmlEntityPtr XMLCALL + xmlNewEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlAddDocEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlAddDtdEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetPredefinedEntity (const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetDocEntity (const xmlDoc *doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetDtdEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetParameterEntity (xmlDocPtr doc, + const xmlChar *name); +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN const xmlChar * XMLCALL + xmlEncodeEntities (xmlDocPtr doc, + const xmlChar *input); +#endif /* LIBXML_LEGACY_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlEncodeEntitiesReentrant(xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlChar * XMLCALL + xmlEncodeSpecialChars (const xmlDoc *doc, + const xmlChar *input); +XMLPUBFUN xmlEntitiesTablePtr XMLCALL + xmlCreateEntitiesTable (void); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlEntitiesTablePtr XMLCALL + xmlCopyEntitiesTable (xmlEntitiesTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeEntitiesTable (xmlEntitiesTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpEntitiesTable (xmlBufferPtr buf, + xmlEntitiesTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpEntityDecl (xmlBufferPtr buf, + xmlEntityPtr ent); +#endif /* LIBXML_OUTPUT_ENABLED */ +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN void XMLCALL + xmlCleanupPredefinedEntities(void); +#endif /* LIBXML_LEGACY_ENABLED */ + + +#ifdef __cplusplus +} +#endif + +# endif /* __XML_ENTITIES_H__ */ diff --git a/src/include/libxml/globals.h b/src/include/libxml/globals.h new file mode 100644 index 000000000000..5e41b7bb5f82 --- /dev/null +++ b/src/include/libxml/globals.h @@ -0,0 +1,508 @@ +/* + * Summary: interface for all global variables of the library + * Description: all the global variables and thread handling for + * those variables is handled by this module. + * + * The bottom of this file is automatically generated by build_glob.py + * based on the description file global.data + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington , Daniel Veillard + */ + +#ifndef __XML_GLOBALS_H +#define __XML_GLOBALS_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL xmlInitGlobals(void); +XMLPUBFUN void XMLCALL xmlCleanupGlobals(void); + +/** + * xmlParserInputBufferCreateFilenameFunc: + * @URI: the URI to read from + * @enc: the requested source encoding + * + * Signature for the function doing the lookup for a suitable input method + * corresponding to an URI. + * + * Returns the new xmlParserInputBufferPtr in case of success or NULL if no + * method was found. + */ +typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, + xmlCharEncoding enc); + + +/** + * xmlOutputBufferCreateFilenameFunc: + * @URI: the URI to write to + * @enc: the requested target encoding + * + * Signature for the function doing the lookup for a suitable output method + * corresponding to an URI. + * + * Returns the new xmlOutputBufferPtr in case of success or NULL if no + * method was found. + */ +typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc +XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func); +XMLPUBFUN xmlOutputBufferCreateFilenameFunc +XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); + +/* + * Externally global symbols which need to be protected for backwards + * compatibility support. + */ + +#undef docbDefaultSAXHandler +#undef htmlDefaultSAXHandler +#undef oldXMLWDcompatibility +#undef xmlBufferAllocScheme +#undef xmlDefaultBufferSize +#undef xmlDefaultSAXHandler +#undef xmlDefaultSAXLocator +#undef xmlDoValidityCheckingDefaultValue +#undef xmlFree +#undef xmlGenericError +#undef xmlStructuredError +#undef xmlGenericErrorContext +#undef xmlStructuredErrorContext +#undef xmlGetWarningsDefaultValue +#undef xmlIndentTreeOutput +#undef xmlTreeIndentString +#undef xmlKeepBlanksDefaultValue +#undef xmlLineNumbersDefaultValue +#undef xmlLoadExtDtdDefaultValue +#undef xmlMalloc +#undef xmlMallocAtomic +#undef xmlMemStrdup +#undef xmlParserDebugEntities +#undef xmlParserVersion +#undef xmlPedanticParserDefaultValue +#undef xmlRealloc +#undef xmlSaveNoEmptyTags +#undef xmlSubstituteEntitiesDefaultValue +#undef xmlRegisterNodeDefaultValue +#undef xmlDeregisterNodeDefaultValue +#undef xmlLastError +#undef xmlParserInputBufferCreateFilenameValue +#undef xmlOutputBufferCreateFilenameValue + +/** + * xmlRegisterNodeFunc: + * @node: the current node + * + * Signature for the registration callback of a created node + */ +typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node); +/** + * xmlDeregisterNodeFunc: + * @node: the current node + * + * Signature for the deregistration callback of a discarded node + */ +typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); + +typedef struct _xmlGlobalState xmlGlobalState; +typedef xmlGlobalState *xmlGlobalStatePtr; +struct _xmlGlobalState +{ + const char *xmlParserVersion; + + xmlSAXLocator xmlDefaultSAXLocator; + xmlSAXHandlerV1 xmlDefaultSAXHandler; + xmlSAXHandlerV1 docbDefaultSAXHandler; + xmlSAXHandlerV1 htmlDefaultSAXHandler; + + xmlFreeFunc xmlFree; + xmlMallocFunc xmlMalloc; + xmlStrdupFunc xmlMemStrdup; + xmlReallocFunc xmlRealloc; + + xmlGenericErrorFunc xmlGenericError; + xmlStructuredErrorFunc xmlStructuredError; + void *xmlGenericErrorContext; + + int oldXMLWDcompatibility; + + xmlBufferAllocationScheme xmlBufferAllocScheme; + int xmlDefaultBufferSize; + + int xmlSubstituteEntitiesDefaultValue; + int xmlDoValidityCheckingDefaultValue; + int xmlGetWarningsDefaultValue; + int xmlKeepBlanksDefaultValue; + int xmlLineNumbersDefaultValue; + int xmlLoadExtDtdDefaultValue; + int xmlParserDebugEntities; + int xmlPedanticParserDefaultValue; + + int xmlSaveNoEmptyTags; + int xmlIndentTreeOutput; + const char *xmlTreeIndentString; + + xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; + xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; + + xmlMallocFunc xmlMallocAtomic; + xmlError xmlLastError; + + xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; + xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; + + void *xmlStructuredErrorContext; +}; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs); + +XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler); + +XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler); + +XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func); +XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func); +XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func); +XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func); + +XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL + xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func); +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL + xmlThrDefParserInputBufferCreateFilenameDefault( + xmlParserInputBufferCreateFilenameFunc func); + +/** DOC_DISABLE */ +/* + * In general the memory allocation entry points are not kept + * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED + * - xmlMalloc + * - xmlMallocAtomic + * - xmlRealloc + * - xmlMemStrdup + * - xmlFree + */ + +#ifdef LIBXML_THREAD_ALLOC_ENABLED +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void); +#define xmlMalloc \ +(*(__xmlMalloc())) +#else +XMLPUBVAR xmlMallocFunc xmlMalloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void); +#define xmlMallocAtomic \ +(*(__xmlMallocAtomic())) +#else +XMLPUBVAR xmlMallocFunc xmlMallocAtomic; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void); +#define xmlRealloc \ +(*(__xmlRealloc())) +#else +XMLPUBVAR xmlReallocFunc xmlRealloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void); +#define xmlFree \ +(*(__xmlFree())) +#else +XMLPUBVAR xmlFreeFunc xmlFree; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void); +#define xmlMemStrdup \ +(*(__xmlMemStrdup())) +#else +XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif + +#else /* !LIBXML_THREAD_ALLOC_ENABLED */ +XMLPUBVAR xmlMallocFunc xmlMalloc; +XMLPUBVAR xmlMallocFunc xmlMallocAtomic; +XMLPUBVAR xmlReallocFunc xmlRealloc; +XMLPUBVAR xmlFreeFunc xmlFree; +XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif /* LIBXML_THREAD_ALLOC_ENABLED */ + +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define docbDefaultSAXHandler \ +(*(__docbDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler; +#endif +#endif + +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define htmlDefaultSAXHandler \ +(*(__htmlDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler; +#endif +#endif + +XMLPUBFUN xmlError * XMLCALL __xmlLastError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLastError \ +(*(__xmlLastError())) +#else +XMLPUBVAR xmlError xmlLastError; +#endif + +/* + * Everything starting from the line below is + * Automatically generated by build_glob.py. + * Do not modify the previous line. + */ + + +XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void); +#ifdef LIBXML_THREAD_ENABLED +#define oldXMLWDcompatibility \ +(*(__oldXMLWDcompatibility())) +#else +XMLPUBVAR int oldXMLWDcompatibility; +#endif + +XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlBufferAllocScheme \ +(*(__xmlBufferAllocScheme())) +#else +XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme; +#endif +XMLPUBFUN xmlBufferAllocationScheme XMLCALL + xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v); + +XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultBufferSize \ +(*(__xmlDefaultBufferSize())) +#else +XMLPUBVAR int xmlDefaultBufferSize; +#endif +XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v); + +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultSAXHandler \ +(*(__xmlDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler; +#endif + +XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultSAXLocator \ +(*(__xmlDefaultSAXLocator())) +#else +XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator; +#endif + +XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDoValidityCheckingDefaultValue \ +(*(__xmlDoValidityCheckingDefaultValue())) +#else +XMLPUBVAR int xmlDoValidityCheckingDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v); + +XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGenericError \ +(*(__xmlGenericError())) +#else +XMLPUBVAR xmlGenericErrorFunc xmlGenericError; +#endif + +XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlStructuredError \ +(*(__xmlStructuredError())) +#else +XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError; +#endif + +XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGenericErrorContext \ +(*(__xmlGenericErrorContext())) +#else +XMLPUBVAR void * xmlGenericErrorContext; +#endif + +XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlStructuredErrorContext \ +(*(__xmlStructuredErrorContext())) +#else +XMLPUBVAR void * xmlStructuredErrorContext; +#endif + +XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGetWarningsDefaultValue \ +(*(__xmlGetWarningsDefaultValue())) +#else +XMLPUBVAR int xmlGetWarningsDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlIndentTreeOutput \ +(*(__xmlIndentTreeOutput())) +#else +XMLPUBVAR int xmlIndentTreeOutput; +#endif +XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v); + +XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlTreeIndentString \ +(*(__xmlTreeIndentString())) +#else +XMLPUBVAR const char * xmlTreeIndentString; +#endif +XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v); + +XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlKeepBlanksDefaultValue \ +(*(__xmlKeepBlanksDefaultValue())) +#else +XMLPUBVAR int xmlKeepBlanksDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLineNumbersDefaultValue \ +(*(__xmlLineNumbersDefaultValue())) +#else +XMLPUBVAR int xmlLineNumbersDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLoadExtDtdDefaultValue \ +(*(__xmlLoadExtDtdDefaultValue())) +#else +XMLPUBVAR int xmlLoadExtDtdDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserDebugEntities \ +(*(__xmlParserDebugEntities())) +#else +XMLPUBVAR int xmlParserDebugEntities; +#endif +XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v); + +XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserVersion \ +(*(__xmlParserVersion())) +#else +XMLPUBVAR const char * xmlParserVersion; +#endif + +XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlPedanticParserDefaultValue \ +(*(__xmlPedanticParserDefaultValue())) +#else +XMLPUBVAR int xmlPedanticParserDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlSaveNoEmptyTags \ +(*(__xmlSaveNoEmptyTags())) +#else +XMLPUBVAR int xmlSaveNoEmptyTags; +#endif +XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v); + +XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlSubstituteEntitiesDefaultValue \ +(*(__xmlSubstituteEntitiesDefaultValue())) +#else +XMLPUBVAR int xmlSubstituteEntitiesDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v); + +XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlRegisterNodeDefaultValue \ +(*(__xmlRegisterNodeDefaultValue())) +#else +XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; +#endif + +XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDeregisterNodeDefaultValue \ +(*(__xmlDeregisterNodeDefaultValue())) +#else +XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; +#endif + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \ + __xmlParserInputBufferCreateFilenameValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserInputBufferCreateFilenameValue \ +(*(__xmlParserInputBufferCreateFilenameValue())) +#else +XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; +#endif + +XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlOutputBufferCreateFilenameValue \ +(*(__xmlOutputBufferCreateFilenameValue())) +#else +XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_GLOBALS_H */ diff --git a/src/include/libxml/hash.h b/src/include/libxml/hash.h new file mode 100644 index 000000000000..b682b6b9403a --- /dev/null +++ b/src/include/libxml/hash.h @@ -0,0 +1,236 @@ +/* + * Summary: Chained hash tables + * Description: This module implements the hash table support used in + * various places in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Bjorn Reese + */ + +#ifndef __XML_HASH_H__ +#define __XML_HASH_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The hash table. + */ +typedef struct _xmlHashTable xmlHashTable; +typedef xmlHashTable *xmlHashTablePtr; + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Recent version of gcc produce a warning when a function pointer is assigned + * to an object pointer, or vice versa. The following macro is a dirty hack + * to allow suppression of the warning. If your architecture has function + * pointers which are a different size than a void pointer, there may be some + * serious trouble within the library. + */ +/** + * XML_CAST_FPTR: + * @fptr: pointer to a function + * + * Macro to do a casting from an object pointer to a + * function pointer without encountering a warning from + * gcc + * + * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr)) + * This macro violated ISO C aliasing rules (gcc4 on s390 broke) + * so it is disabled now + */ + +#define XML_CAST_FPTR(fptr) fptr + + +/* + * function types: + */ +/** + * xmlHashDeallocator: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to free data from a hash. + */ +typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name); +/** + * xmlHashCopier: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to copy data from a hash. + * + * Returns a copy of the data or NULL in case of error. + */ +typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name); +/** + * xmlHashScanner: + * @payload: the data in the hash + * @data: extra scanner data + * @name: the name associated + * + * Callback when scanning data in a hash with the simple scanner. + */ +typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name); +/** + * xmlHashScannerFull: + * @payload: the data in the hash + * @data: extra scanner data + * @name: the name associated + * @name2: the second name associated + * @name3: the third name associated + * + * Callback when scanning data in a hash with the full scanner. + */ +typedef void (*xmlHashScannerFull)(void *payload, void *data, + const xmlChar *name, const xmlChar *name2, + const xmlChar *name3); + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCreate (int size); +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCreateDict(int size, + xmlDictPtr dict); +XMLPUBFUN void XMLCALL + xmlHashFree (xmlHashTablePtr table, + xmlHashDeallocator f); +XMLPUBFUN void XMLCALL + xmlHashDefaultDeallocator(void *entry, + const xmlChar *name); + +/* + * Add a new entry to the hash table. + */ +XMLPUBFUN int XMLCALL + xmlHashAddEntry (xmlHashTablePtr table, + const xmlChar *name, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry(xmlHashTablePtr table, + const xmlChar *name, + void *userdata, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashAddEntry2(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry2(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + void *userdata, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashAddEntry3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata, + xmlHashDeallocator f); + +/* + * Remove an entry from the hash table. + */ +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + xmlHashDeallocator f); + +/* + * Retrieve the userdata. + */ +XMLPUBFUN void * XMLCALL + xmlHashLookup (xmlHashTablePtr table, + const xmlChar *name); +XMLPUBFUN void * XMLCALL + xmlHashLookup2 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2); +XMLPUBFUN void * XMLCALL + xmlHashLookup3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3); +XMLPUBFUN void * XMLCALL + xmlHashQLookup (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN void * XMLCALL + xmlHashQLookup2 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix, + const xmlChar *name2, + const xmlChar *prefix2); +XMLPUBFUN void * XMLCALL + xmlHashQLookup3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix, + const xmlChar *name2, + const xmlChar *prefix2, + const xmlChar *name3, + const xmlChar *prefix3); + +/* + * Helpers. + */ +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCopy (xmlHashTablePtr table, + xmlHashCopier f); +XMLPUBFUN int XMLCALL + xmlHashSize (xmlHashTablePtr table); +XMLPUBFUN void XMLCALL + xmlHashScan (xmlHashTablePtr table, + xmlHashScanner f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScan3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScanner f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScanFull (xmlHashTablePtr table, + xmlHashScannerFull f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScanFull3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScannerFull f, + void *data); +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_HASH_H__ */ diff --git a/src/include/libxml/list.h b/src/include/libxml/list.h new file mode 100644 index 000000000000..3211c755247b --- /dev/null +++ b/src/include/libxml/list.h @@ -0,0 +1,137 @@ +/* + * Summary: lists interfaces + * Description: this module implement the list support used in + * various place in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington + */ + +#ifndef __XML_LINK_INCLUDE__ +#define __XML_LINK_INCLUDE__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlLink xmlLink; +typedef xmlLink *xmlLinkPtr; + +typedef struct _xmlList xmlList; +typedef xmlList *xmlListPtr; + +/** + * xmlListDeallocator: + * @lk: the data to deallocate + * + * Callback function used to free data from a list. + */ +typedef void (*xmlListDeallocator) (xmlLinkPtr lk); +/** + * xmlListDataCompare: + * @data0: the first data + * @data1: the second data + * + * Callback function used to compare 2 data. + * + * Returns 0 is equality, -1 or 1 otherwise depending on the ordering. + */ +typedef int (*xmlListDataCompare) (const void *data0, const void *data1); +/** + * xmlListWalker: + * @data: the data found in the list + * @user: extra user provided data to the walker + * + * Callback function used when walking a list with xmlListWalk(). + * + * Returns 0 to stop walking the list, 1 otherwise. + */ +typedef int (*xmlListWalker) (const void *data, void *user); + +/* Creation/Deletion */ +XMLPUBFUN xmlListPtr XMLCALL + xmlListCreate (xmlListDeallocator deallocator, + xmlListDataCompare compare); +XMLPUBFUN void XMLCALL + xmlListDelete (xmlListPtr l); + +/* Basic Operators */ +XMLPUBFUN void * XMLCALL + xmlListSearch (xmlListPtr l, + void *data); +XMLPUBFUN void * XMLCALL + xmlListReverseSearch (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListInsert (xmlListPtr l, + void *data) ; +XMLPUBFUN int XMLCALL + xmlListAppend (xmlListPtr l, + void *data) ; +XMLPUBFUN int XMLCALL + xmlListRemoveFirst (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListRemoveLast (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListRemoveAll (xmlListPtr l, + void *data); +XMLPUBFUN void XMLCALL + xmlListClear (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListEmpty (xmlListPtr l); +XMLPUBFUN xmlLinkPtr XMLCALL + xmlListFront (xmlListPtr l); +XMLPUBFUN xmlLinkPtr XMLCALL + xmlListEnd (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListSize (xmlListPtr l); + +XMLPUBFUN void XMLCALL + xmlListPopFront (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListPopBack (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListPushFront (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListPushBack (xmlListPtr l, + void *data); + +/* Advanced Operators */ +XMLPUBFUN void XMLCALL + xmlListReverse (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListSort (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListWalk (xmlListPtr l, + xmlListWalker walker, + void *user); +XMLPUBFUN void XMLCALL + xmlListReverseWalk (xmlListPtr l, + xmlListWalker walker, + void *user); +XMLPUBFUN void XMLCALL + xmlListMerge (xmlListPtr l1, + xmlListPtr l2); +XMLPUBFUN xmlListPtr XMLCALL + xmlListDup (const xmlListPtr old); +XMLPUBFUN int XMLCALL + xmlListCopy (xmlListPtr cur, + const xmlListPtr old); +/* Link operators */ +XMLPUBFUN void * XMLCALL + xmlLinkGetData (xmlLinkPtr lk); + +/* xmlListUnique() */ +/* xmlListSwap */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_LINK_INCLUDE__ */ diff --git a/src/include/libxml/nanoftp.h b/src/include/libxml/nanoftp.h new file mode 100644 index 000000000000..7335faf10751 --- /dev/null +++ b/src/include/libxml/nanoftp.h @@ -0,0 +1,163 @@ +/* + * Summary: minimal FTP implementation + * Description: minimal FTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_FTP_H__ +#define __NANO_FTP_H__ + +#include + +#ifdef LIBXML_FTP_ENABLED + +/* Needed for portability to Windows 64 bits */ +#if defined(_WIN32) && !defined(__CYGWIN__) +#include +#else +/** + * SOCKET: + * + * macro used to provide portability of code to windows sockets + */ +#define SOCKET int +/** + * INVALID_SOCKET: + * + * macro used to provide portability of code to windows sockets + * the value to be used when the socket is not valid + */ +#undef INVALID_SOCKET +#define INVALID_SOCKET (-1) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * ftpListCallback: + * @userData: user provided data for the callback + * @filename: the file name (including "->" when links are shown) + * @attrib: the attribute string + * @owner: the owner string + * @group: the group string + * @size: the file size + * @links: the link count + * @year: the year + * @month: the month + * @day: the day + * @hour: the hour + * @minute: the minute + * + * A callback for the xmlNanoFTPList command. + * Note that only one of year and day:minute are specified. + */ +typedef void (*ftpListCallback) (void *userData, + const char *filename, const char *attrib, + const char *owner, const char *group, + unsigned long size, int links, int year, + const char *month, int day, int hour, + int minute); +/** + * ftpDataCallback: + * @userData: the user provided context + * @data: the data received + * @len: its size in bytes + * + * A callback for the xmlNanoFTPGet command. + */ +typedef void (*ftpDataCallback) (void *userData, + const char *data, + int len); + +/* + * Init + */ +XMLPUBFUN void XMLCALL + xmlNanoFTPInit (void); +XMLPUBFUN void XMLCALL + xmlNanoFTPCleanup (void); + +/* + * Creating/freeing contexts. + */ +XMLPUBFUN void * XMLCALL + xmlNanoFTPNewCtxt (const char *URL); +XMLPUBFUN void XMLCALL + xmlNanoFTPFreeCtxt (void * ctx); +XMLPUBFUN void * XMLCALL + xmlNanoFTPConnectTo (const char *server, + int port); +/* + * Opening/closing session connections. + */ +XMLPUBFUN void * XMLCALL + xmlNanoFTPOpen (const char *URL); +XMLPUBFUN int XMLCALL + xmlNanoFTPConnect (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPClose (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPQuit (void *ctx); +XMLPUBFUN void XMLCALL + xmlNanoFTPScanProxy (const char *URL); +XMLPUBFUN void XMLCALL + xmlNanoFTPProxy (const char *host, + int port, + const char *user, + const char *passwd, + int type); +XMLPUBFUN int XMLCALL + xmlNanoFTPUpdateURL (void *ctx, + const char *URL); + +/* + * Rather internal commands. + */ +XMLPUBFUN int XMLCALL + xmlNanoFTPGetResponse (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPCheckResponse (void *ctx); + +/* + * CD/DIR/GET handlers. + */ +XMLPUBFUN int XMLCALL + xmlNanoFTPCwd (void *ctx, + const char *directory); +XMLPUBFUN int XMLCALL + xmlNanoFTPDele (void *ctx, + const char *file); + +XMLPUBFUN SOCKET XMLCALL + xmlNanoFTPGetConnection (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPCloseConnection(void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPList (void *ctx, + ftpListCallback callback, + void *userData, + const char *filename); +XMLPUBFUN SOCKET XMLCALL + xmlNanoFTPGetSocket (void *ctx, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPGet (void *ctx, + ftpDataCallback callback, + void *userData, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPRead (void *ctx, + void *dest, + int len); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_FTP_ENABLED */ +#endif /* __NANO_FTP_H__ */ diff --git a/src/include/libxml/nanohttp.h b/src/include/libxml/nanohttp.h new file mode 100644 index 000000000000..22b8fb43381c --- /dev/null +++ b/src/include/libxml/nanohttp.h @@ -0,0 +1,81 @@ +/* + * Summary: minimal HTTP implementation + * Description: minimal HTTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_HTTP_H__ +#define __NANO_HTTP_H__ + +#include + +#ifdef LIBXML_HTTP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN void XMLCALL + xmlNanoHTTPInit (void); +XMLPUBFUN void XMLCALL + xmlNanoHTTPCleanup (void); +XMLPUBFUN void XMLCALL + xmlNanoHTTPScanProxy (const char *URL); +XMLPUBFUN int XMLCALL + xmlNanoHTTPFetch (const char *URL, + const char *filename, + char **contentType); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPMethod (const char *URL, + const char *method, + const char *input, + char **contentType, + const char *headers, + int ilen); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPMethodRedir (const char *URL, + const char *method, + const char *input, + char **contentType, + char **redir, + const char *headers, + int ilen); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPOpen (const char *URL, + char **contentType); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPOpenRedir (const char *URL, + char **contentType, + char **redir); +XMLPUBFUN int XMLCALL + xmlNanoHTTPReturnCode (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPAuthHeader (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPRedir (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoHTTPContentLength( void * ctx ); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPEncoding (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPMimeType (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoHTTPRead (void *ctx, + void *dest, + int len); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int XMLCALL + xmlNanoHTTPSave (void *ctxt, + const char *filename); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNanoHTTPClose (void *ctx); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTTP_ENABLED */ +#endif /* __NANO_HTTP_H__ */ diff --git a/src/include/libxml/parser.h b/src/include/libxml/parser.h new file mode 100644 index 000000000000..0ba1c387a97d --- /dev/null +++ b/src/include/libxml/parser.h @@ -0,0 +1,1243 @@ +/* + * Summary: the core parser module + * Description: Interfaces, constants and types related to the XML parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_H__ +#define __XML_PARSER_H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_DEFAULT_VERSION: + * + * The default version of XML used: 1.0 + */ +#define XML_DEFAULT_VERSION "1.0" + +/** + * xmlParserInput: + * + * An xmlParserInput is an input flow for the XML processor. + * Each entity parsed is associated an xmlParserInput (except the + * few predefined ones). This is the case both for internal entities + * - in which case the flow is already completely in memory - or + * external entities - in which case we use the buf structure for + * progressive reading and I18N conversions to the internal UTF-8 format. + */ + +/** + * xmlParserInputDeallocate: + * @str: the string to deallocate + * + * Callback for freeing some parser input allocations. + */ +typedef void (* xmlParserInputDeallocate)(xmlChar *str); + +struct _xmlParserInput { + /* Input buffer */ + xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ + + const char *filename; /* The file analyzed, if any */ + const char *directory; /* the directory/base of the file */ + const xmlChar *base; /* Base of the array to parse */ + const xmlChar *cur; /* Current char being parsed */ + const xmlChar *end; /* end of the array to parse */ + int length; /* length if known */ + int line; /* Current line */ + int col; /* Current column */ + /* + * NOTE: consumed is only tested for equality in the parser code, + * so even if there is an overflow this should not give troubles + * for parsing very large instances. + */ + unsigned long consumed; /* How many xmlChars already consumed */ + xmlParserInputDeallocate free; /* function to deallocate the base */ + const xmlChar *encoding; /* the encoding string for entity */ + const xmlChar *version; /* the version string for entity */ + int standalone; /* Was that entity marked standalone */ + int id; /* an unique identifier for the entity */ +}; + +/** + * xmlParserNodeInfo: + * + * The parser can be asked to collect Node information, i.e. at what + * place in the file they were detected. + * NOTE: This is off by default and not very well tested. + */ +typedef struct _xmlParserNodeInfo xmlParserNodeInfo; +typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; + +struct _xmlParserNodeInfo { + const struct _xmlNode* node; + /* Position & line # that text that created the node begins & ends on */ + unsigned long begin_pos; + unsigned long begin_line; + unsigned long end_pos; + unsigned long end_line; +}; + +typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; +typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; +struct _xmlParserNodeInfoSeq { + unsigned long maximum; + unsigned long length; + xmlParserNodeInfo* buffer; +}; + +/** + * xmlParserInputState: + * + * The parser is now working also as a state based parser. + * The recursive one use the state info for entities processing. + */ +typedef enum { + XML_PARSER_EOF = -1, /* nothing is to be parsed */ + XML_PARSER_START = 0, /* nothing has been parsed */ + XML_PARSER_MISC, /* Misc* before int subset */ + XML_PARSER_PI, /* Within a processing instruction */ + XML_PARSER_DTD, /* within some DTD content */ + XML_PARSER_PROLOG, /* Misc* after internal subset */ + XML_PARSER_COMMENT, /* within a comment */ + XML_PARSER_START_TAG, /* within a start tag */ + XML_PARSER_CONTENT, /* within the content */ + XML_PARSER_CDATA_SECTION, /* within a CDATA section */ + XML_PARSER_END_TAG, /* within a closing tag */ + XML_PARSER_ENTITY_DECL, /* within an entity declaration */ + XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ + XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ + XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ + XML_PARSER_EPILOG, /* the Misc* after the last end tag */ + XML_PARSER_IGNORE, /* within an IGNORED section */ + XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */ +} xmlParserInputState; + +/** + * XML_DETECT_IDS: + * + * Bit in the loadsubset context field to tell to do ID/REFs lookups. + * Use it to initialize xmlLoadExtDtdDefaultValue. + */ +#define XML_DETECT_IDS 2 + +/** + * XML_COMPLETE_ATTRS: + * + * Bit in the loadsubset context field to tell to do complete the + * elements attributes lists with the ones defaulted from the DTDs. + * Use it to initialize xmlLoadExtDtdDefaultValue. + */ +#define XML_COMPLETE_ATTRS 4 + +/** + * XML_SKIP_IDS: + * + * Bit in the loadsubset context field to tell to not do ID/REFs registration. + * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. + */ +#define XML_SKIP_IDS 8 + +/** + * xmlParserMode: + * + * A parser can operate in various modes + */ +typedef enum { + XML_PARSE_UNKNOWN = 0, + XML_PARSE_DOM = 1, + XML_PARSE_SAX = 2, + XML_PARSE_PUSH_DOM = 3, + XML_PARSE_PUSH_SAX = 4, + XML_PARSE_READER = 5 +} xmlParserMode; + +typedef struct _xmlStartTag xmlStartTag; + +/** + * xmlParserCtxt: + * + * The parser context. + * NOTE This doesn't completely define the parser state, the (current ?) + * design of the parser uses recursive function calls since this allow + * and easy mapping from the production rules of the specification + * to the actual code. The drawback is that the actual function call + * also reflect the parser state. However most of the parsing routines + * takes as the only argument the parser context pointer, so migrating + * to a state based parser for progressive parsing shouldn't be too hard. + */ +struct _xmlParserCtxt { + struct _xmlSAXHandler *sax; /* The SAX handler */ + void *userData; /* For SAX interface only, used by DOM build */ + xmlDocPtr myDoc; /* the document being built */ + int wellFormed; /* is the document well formed */ + int replaceEntities; /* shall we replace entities ? */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* the declared encoding, if any */ + int standalone; /* standalone document */ + int html; /* an HTML(1)/Docbook(2) document + * 3 is HTML after + * 10 is HTML after + */ + + /* Input stream stack */ + xmlParserInputPtr input; /* Current input stream */ + int inputNr; /* Number of current input streams */ + int inputMax; /* Max number of input streams */ + xmlParserInputPtr *inputTab; /* stack of inputs */ + + /* Node analysis stack only used for DOM building */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + int record_info; /* Whether node info should be kept */ + xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ + + int errNo; /* error code */ + + int hasExternalSubset; /* reference and external subset */ + int hasPErefs; /* the internal subset has PE refs */ + int external; /* are we parsing an external entity */ + + int valid; /* is the document valid */ + int validate; /* shall we try to validate ? */ + xmlValidCtxt vctxt; /* The validity context */ + + xmlParserInputState instate; /* current type of input */ + int token; /* next char look-ahead */ + + char *directory; /* the data directory */ + + /* Node name stack */ + const xmlChar *name; /* Current parsed Node */ + int nameNr; /* Depth of the parsing stack */ + int nameMax; /* Max depth of the parsing stack */ + const xmlChar * *nameTab; /* array of nodes */ + + long nbChars; /* unused */ + long checkIndex; /* used by progressive parsing lookup */ + int keepBlanks; /* ugly but ... */ + int disableSAX; /* SAX callbacks are disabled */ + int inSubset; /* Parsing is in int 1/ext 2 subset */ + const xmlChar * intSubName; /* name of subset */ + xmlChar * extSubURI; /* URI of external subset */ + xmlChar * extSubSystem; /* SYSTEM ID of external subset */ + + /* xml:space values */ + int * space; /* Should the parser preserve spaces */ + int spaceNr; /* Depth of the parsing stack */ + int spaceMax; /* Max depth of the parsing stack */ + int * spaceTab; /* array of space infos */ + + int depth; /* to prevent entity substitution loops */ + xmlParserInputPtr entity; /* used to check entities boundaries */ + int charset; /* encoding of the in-memory content + actually an xmlCharEncoding */ + int nodelen; /* Those two fields are there to */ + int nodemem; /* Speed up large node parsing */ + int pedantic; /* signal pedantic warnings */ + void *_private; /* For user data, libxml won't touch it */ + + int loadsubset; /* should the external subset be loaded */ + int linenumbers; /* set line number in element content */ + void *catalogs; /* document's own catalog */ + int recovery; /* run in recovery mode */ + int progressive; /* is this a progressive parsing */ + xmlDictPtr dict; /* dictionary for the parser */ + const xmlChar * *atts; /* array for the attributes callbacks */ + int maxatts; /* the size of the array */ + int docdict; /* use strings from dict to build tree */ + + /* + * pre-interned strings + */ + const xmlChar *str_xml; + const xmlChar *str_xmlns; + const xmlChar *str_xml_ns; + + /* + * Everything below is used only by the new SAX mode + */ + int sax2; /* operating in the new SAX mode */ + int nsNr; /* the number of inherited namespaces */ + int nsMax; /* the size of the arrays */ + const xmlChar * *nsTab; /* the array of prefix/namespace name */ + int *attallocs; /* which attribute were allocated */ + xmlStartTag *pushTab; /* array of data for push */ + xmlHashTablePtr attsDefault; /* defaulted attributes if any */ + xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ + int nsWellFormed; /* is the document XML Namespace okay */ + int options; /* Extra options */ + + /* + * Those fields are needed only for streaming parsing so far + */ + int dictNames; /* Use dictionary names for the tree */ + int freeElemsNr; /* number of freed element nodes */ + xmlNodePtr freeElems; /* List of freed element nodes */ + int freeAttrsNr; /* number of freed attributes nodes */ + xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ + + /* + * the complete error information for the last error. + */ + xmlError lastError; + xmlParserMode parseMode; /* the parser mode */ + unsigned long nbentities; /* number of entities references */ + unsigned long sizeentities; /* size of parsed entities */ + + /* for use by HTML non-recursive parser */ + xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */ + int nodeInfoNr; /* Depth of the parsing stack */ + int nodeInfoMax; /* Max depth of the parsing stack */ + xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */ + + int input_id; /* we need to label inputs */ + unsigned long sizeentcopy; /* volume of entity copy */ +}; + +/** + * xmlSAXLocator: + * + * A SAX Locator. + */ +struct _xmlSAXLocator { + const xmlChar *(*getPublicId)(void *ctx); + const xmlChar *(*getSystemId)(void *ctx); + int (*getLineNumber)(void *ctx); + int (*getColumnNumber)(void *ctx); +}; + +/** + * xmlSAXHandler: + * + * A SAX handler is bunch of callbacks called by the parser when processing + * of the input generate data or structure information. + */ + +/** + * resolveEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Callback: + * The entity loader, to control the loading of external entities, + * the application can either: + * - override this resolveEntity() callback in the SAX block + * - or better use the xmlSetExternalEntityLoader() function to + * set up it's own entity resolution routine + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * internalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on internal subset declaration. + */ +typedef void (*internalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * externalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on external subset declaration. + */ +typedef void (*externalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * getEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get an entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * getParameterEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get a parameter entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * entityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed. + */ +typedef void (*entityDeclSAXFunc) (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +/** + * notationDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +typedef void (*notationDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * attributeDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @elem: the name of the element + * @fullname: the attribute name + * @type: the attribute type + * @def: the type of default value + * @defaultValue: the attribute default value + * @tree: the tree of enumerated value set + * + * An attribute definition has been parsed. + */ +typedef void (*attributeDeclSAXFunc)(void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +/** + * elementDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the element name + * @type: the element type + * @content: the element value tree + * + * An element definition has been parsed. + */ +typedef void (*elementDeclSAXFunc)(void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +/** + * unparsedEntityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed. + */ +typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); +/** + * setDocumentLocatorSAXFunc: + * @ctx: the user data (XML parser context) + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator. + * Everything is available on the context, so this is useless in our case. + */ +typedef void (*setDocumentLocatorSAXFunc) (void *ctx, + xmlSAXLocatorPtr loc); +/** + * startDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document start being processed. + */ +typedef void (*startDocumentSAXFunc) (void *ctx); +/** + * endDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document end has been detected. + */ +typedef void (*endDocumentSAXFunc) (void *ctx); +/** + * startElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name, including namespace prefix + * @atts: An array of name/value attributes pairs, NULL terminated + * + * Called when an opening tag has been processed. + */ +typedef void (*startElementSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar **atts); +/** + * endElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name + * + * Called when the end of an element has been detected. + */ +typedef void (*endElementSAXFunc) (void *ctx, + const xmlChar *name); +/** + * attributeSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The attribute name, including namespace prefix + * @value: The attribute value + * + * Handle an attribute that has been read by the parser. + * The default handling is to convert the attribute into an + * DOM subtree and past it in a new xmlAttr element added to + * the element. + */ +typedef void (*attributeSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *value); +/** + * referenceSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Called when an entity reference is detected. + */ +typedef void (*referenceSAXFunc) (void *ctx, + const xmlChar *name); +/** + * charactersSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some chars from the parser. + */ +typedef void (*charactersSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * ignorableWhitespaceSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some ignorable whitespaces from the parser. + * UNUSED: by default the DOM building will use characters. + */ +typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * processingInstructionSAXFunc: + * @ctx: the user data (XML parser context) + * @target: the target name + * @data: the PI data's + * + * A processing instruction has been parsed. + */ +typedef void (*processingInstructionSAXFunc) (void *ctx, + const xmlChar *target, + const xmlChar *data); +/** + * commentSAXFunc: + * @ctx: the user data (XML parser context) + * @value: the comment content + * + * A comment has been parsed. + */ +typedef void (*commentSAXFunc) (void *ctx, + const xmlChar *value); +/** + * cdataBlockSAXFunc: + * @ctx: the user data (XML parser context) + * @value: The pcdata content + * @len: the block length + * + * Called when a pcdata block has been parsed. + */ +typedef void (*cdataBlockSAXFunc) ( + void *ctx, + const xmlChar *value, + int len); +/** + * warningSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a warning messages, callback. + */ +typedef void (XMLCDECL *warningSAXFunc) (void *ctx, + const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** + * errorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format an error messages, callback. + */ +typedef void (XMLCDECL *errorSAXFunc) (void *ctx, + const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** + * fatalErrorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format fatal error messages, callback. + * Note: so far fatalError() SAX callbacks are not used, error() + * get all the callbacks for errors. + */ +typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx, + const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** + * isStandaloneSAXFunc: + * @ctx: the user data (XML parser context) + * + * Is this document tagged standalone? + * + * Returns 1 if true + */ +typedef int (*isStandaloneSAXFunc) (void *ctx); +/** + * hasInternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an internal subset. + * + * Returns 1 if true + */ +typedef int (*hasInternalSubsetSAXFunc) (void *ctx); + +/** + * hasExternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an external subset? + * + * Returns 1 if true + */ +typedef int (*hasExternalSubsetSAXFunc) (void *ctx); + +/************************************************************************ + * * + * The SAX version 2 API extensions * + * * + ************************************************************************/ +/** + * XML_SAX2_MAGIC: + * + * Special constant found in SAX2 blocks initialized fields + */ +#define XML_SAX2_MAGIC 0xDEEDBEAF + +/** + * startElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * @nb_namespaces: number of namespace definitions on that node + * @namespaces: pointer to the array of prefix/URI pairs namespace definitions + * @nb_attributes: the number of attributes on that node + * @nb_defaulted: the number of defaulted attributes. The defaulted + * ones are at the end of the array + * @attributes: pointer to the array of (localname/prefix/URI/value/end) + * attribute values. + * + * SAX2 callback when an element start has been detected by the parser. + * It provides the namespace information for the element, as well as + * the new namespace declarations on the element. + */ + +typedef void (*startElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +/** + * endElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * + * SAX2 callback when an element end has been detected by the parser. + * It provides the namespace information for the element. + */ + +typedef void (*endElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + + +struct _xmlSAXHandler { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; + /* The following fields are extensions available only on version 2 */ + void *_private; + startElementNsSAX2Func startElementNs; + endElementNsSAX2Func endElementNs; + xmlStructuredErrorFunc serror; +}; + +/* + * SAX Version 1 + */ +typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; +typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; +struct _xmlSAXHandlerV1 { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; +}; + + +/** + * xmlExternalEntityLoader: + * @URL: The System ID of the resource requested + * @ID: The Public ID of the resource requested + * @context: the XML parser context + * + * External entity loaders types. + * + * Returns the entity input parser. + */ +typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, + const char *ID, + xmlParserCtxtPtr context); + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Init/Cleanup + */ +XMLPUBFUN void XMLCALL + xmlInitParser (void); +XMLPUBFUN void XMLCALL + xmlCleanupParser (void); + +/* + * Input functions + */ +XMLPUBFUN int XMLCALL + xmlParserInputRead (xmlParserInputPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputGrow (xmlParserInputPtr in, + int len); + +/* + * Basic parsing Interfaces + */ +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseDoc (const xmlChar *cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseFile (const char *filename); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseMemory (const char *buffer, + int size); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN int XMLCALL + xmlSubstituteEntitiesDefault(int val); +XMLPUBFUN int XMLCALL + xmlKeepBlanksDefault (int val); +XMLPUBFUN void XMLCALL + xmlStopParser (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlPedanticParserDefault(int val); +XMLPUBFUN int XMLCALL + xmlLineNumbersDefault (int val); + +#ifdef LIBXML_SAX1_ENABLED +/* + * Recovery mode + */ +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverDoc (const xmlChar *cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverMemory (const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverFile (const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ + +/* + * Less common routines and SAX interfaces + */ +XMLPUBFUN int XMLCALL + xmlParseDocument (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlSAXUserParseFile (xmlSAXHandlerPtr sax, + void *user_data, + const char *filename); +XMLPUBFUN int XMLCALL + xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, + void *user_data, + const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseDoc (xmlSAXHandlerPtr sax, + const xmlChar *cur, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseMemory (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery, + void *data); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseFile (xmlSAXHandlerPtr sax, + const char *filename, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, + const char *filename, + int recovery, + void *data); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseEntity (xmlSAXHandlerPtr sax, + const char *filename); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseEntity (const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ + +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN xmlDtdPtr XMLCALL + xmlSAXParseDTD (xmlSAXHandlerPtr sax, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlParseDTD (const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlIOParseDTD (xmlSAXHandlerPtr sax, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); +#endif /* LIBXML_VALID_ENABLE */ +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlParseBalancedChunkMemory(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN xmlParserErrors XMLCALL + xmlParseInNodeContext (xmlNodePtr node, + const char *data, + int datalen, + int options, + xmlNodePtr *lst); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst, + int recover); +XMLPUBFUN int XMLCALL + xmlParseExternalEntity (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN int XMLCALL + xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); + +/* + * Parser contexts handling. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlNewParserCtxt (void); +XMLPUBFUN int XMLCALL + xmlInitParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlClearParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN void XMLCALL + xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, + const xmlChar* buffer, + const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateDocParserCtxt (const xmlChar *cur); + +#ifdef LIBXML_LEGACY_ENABLED +/* + * Reading/setting optional parsing features. + */ +XMLPUBFUN int XMLCALL + xmlGetFeaturesList (int *len, + const char **result); +XMLPUBFUN int XMLCALL + xmlGetFeature (xmlParserCtxtPtr ctxt, + const char *name, + void *result); +XMLPUBFUN int XMLCALL + xmlSetFeature (xmlParserCtxtPtr ctxt, + const char *name, + void *value); +#endif /* LIBXML_LEGACY_ENABLED */ + +#ifdef LIBXML_PUSH_ENABLED +/* + * Interfaces for the Push mode. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename); +XMLPUBFUN int XMLCALL + xmlParseChunk (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +/* + * Special I/O mode. + */ + +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, + void *user_data, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewIOInputStream (xmlParserCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); + +/* + * Node infos. + */ +XMLPUBFUN const xmlParserNodeInfo* XMLCALL + xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, + const xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XMLPUBFUN void XMLCALL + xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XMLPUBFUN unsigned long XMLCALL + xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, + const xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, + const xmlParserNodeInfoPtr info); + +/* + * External entities handling actually implemented in xmlIO. + */ + +XMLPUBFUN void XMLCALL + xmlSetExternalEntityLoader(xmlExternalEntityLoader f); +XMLPUBFUN xmlExternalEntityLoader XMLCALL + xmlGetExternalEntityLoader(void); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlLoadExternalEntity (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +/* + * Index lookup, actually implemented in the encoding module + */ +XMLPUBFUN long XMLCALL + xmlByteConsumed (xmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + XML_PARSE_RECOVER = 1<<0, /* recover on errors */ + XML_PARSE_NOENT = 1<<1, /* substitute entities */ + XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ + XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ + XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ + XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ + XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ + XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */ + XML_PARSE_NONET = 1<<11,/* Forbid network access */ + XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */ + XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ + XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ + XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ + XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of + the tree allowed afterwards (will possibly + crash if you try to modify the tree) */ + XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */ + XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */ + XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */ + XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */ + XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */ + XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */ +} xmlParserOption; + +XMLPUBFUN void XMLCALL + xmlCtxtReset (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlCtxtResetPush (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/* + * Library wide options + */ +/** + * xmlFeature: + * + * Used to examine the existence of features that can be enabled + * or disabled at compile-time. + * They used to be called XML_FEATURE_xxx but this clashed with Expat + */ +typedef enum { + XML_WITH_THREAD = 1, + XML_WITH_TREE = 2, + XML_WITH_OUTPUT = 3, + XML_WITH_PUSH = 4, + XML_WITH_READER = 5, + XML_WITH_PATTERN = 6, + XML_WITH_WRITER = 7, + XML_WITH_SAX1 = 8, + XML_WITH_FTP = 9, + XML_WITH_HTTP = 10, + XML_WITH_VALID = 11, + XML_WITH_HTML = 12, + XML_WITH_LEGACY = 13, + XML_WITH_C14N = 14, + XML_WITH_CATALOG = 15, + XML_WITH_XPATH = 16, + XML_WITH_XPTR = 17, + XML_WITH_XINCLUDE = 18, + XML_WITH_ICONV = 19, + XML_WITH_ISO8859X = 20, + XML_WITH_UNICODE = 21, + XML_WITH_REGEXP = 22, + XML_WITH_AUTOMATA = 23, + XML_WITH_EXPR = 24, + XML_WITH_SCHEMAS = 25, + XML_WITH_SCHEMATRON = 26, + XML_WITH_MODULES = 27, + XML_WITH_DEBUG = 28, + XML_WITH_DEBUG_MEM = 29, + XML_WITH_DEBUG_RUN = 30, + XML_WITH_ZLIB = 31, + XML_WITH_ICU = 32, + XML_WITH_LZMA = 33, + XML_WITH_NONE = 99999 /* just to be sure of allocation size */ +} xmlFeature; + +XMLPUBFUN int XMLCALL + xmlHasFeature (xmlFeature feature); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_H__ */ diff --git a/src/include/libxml/parserInternals.h b/src/include/libxml/parserInternals.h new file mode 100644 index 000000000000..1f26ce208100 --- /dev/null +++ b/src/include/libxml/parserInternals.h @@ -0,0 +1,644 @@ +/* + * Summary: internals routines and limits exported by the parser. + * Description: this module exports a number of internal parsing routines + * they are not really all intended for applications but + * can prove useful doing low level processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_INTERNALS_H__ +#define __XML_PARSER_INTERNALS_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlParserMaxDepth: + * + * arbitrary depth limit for the XML documents that we allow to + * process. This is not a limitation of the parser but a safety + * boundary feature, use XML_PARSE_HUGE option to override it. + */ +XMLPUBVAR unsigned int xmlParserMaxDepth; + +/** + * XML_MAX_TEXT_LENGTH: + * + * Maximum size allowed for a single text node when building a tree. + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + * Introduced in 2.9.0 + */ +#define XML_MAX_TEXT_LENGTH 10000000 + +/** + * XML_MAX_NAME_LENGTH: + * + * Maximum size allowed for a markup identifier. + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + * Note that with the use of parsing dictionaries overriding the limit + * may result in more runtime memory usage in face of "unfriendly' content + * Introduced in 2.9.0 + */ +#define XML_MAX_NAME_LENGTH 50000 + +/** + * XML_MAX_DICTIONARY_LIMIT: + * + * Maximum size allowed by the parser for a dictionary by default + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + * Introduced in 2.9.0 + */ +#define XML_MAX_DICTIONARY_LIMIT 10000000 + +/** + * XML_MAX_LOOKUP_LIMIT: + * + * Maximum size allowed by the parser for ahead lookup + * This is an upper boundary enforced by the parser to avoid bad + * behaviour on "unfriendly' content + * Introduced in 2.9.0 + */ +#define XML_MAX_LOOKUP_LIMIT 10000000 + +/** + * XML_MAX_NAMELEN: + * + * Identifiers can be longer, but this will be more costly + * at runtime. + */ +#define XML_MAX_NAMELEN 100 + +/** + * INPUT_CHUNK: + * + * The parser tries to always have that amount of input ready. + * One of the point is providing context when reporting errors. + */ +#define INPUT_CHUNK 250 + +/************************************************************************ + * * + * UNICODE version of the macros. * + * * + ************************************************************************/ +/** + * IS_BYTE_CHAR: + * @c: an byte value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20...] + * any byte character in the accepted range + */ +#define IS_BYTE_CHAR(c) xmlIsChar_ch(c) + +/** + * IS_CHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + * | [#x10000-#x10FFFF] + * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. + */ +#define IS_CHAR(c) xmlIsCharQ(c) + +/** + * IS_CHAR_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Behaves like IS_CHAR on single-byte value + */ +#define IS_CHAR_CH(c) xmlIsChar_ch(c) + +/** + * IS_BLANK: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [3] S ::= (#x20 | #x9 | #xD | #xA)+ + */ +#define IS_BLANK(c) xmlIsBlankQ(c) + +/** + * IS_BLANK_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Behaviour same as IS_BLANK + */ +#define IS_BLANK_CH(c) xmlIsBlank_ch(c) + +/** + * IS_BASECHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [85] BaseChar ::= ... long list see REC ... + */ +#define IS_BASECHAR(c) xmlIsBaseCharQ(c) + +/** + * IS_DIGIT: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [88] Digit ::= ... long list see REC ... + */ +#define IS_DIGIT(c) xmlIsDigitQ(c) + +/** + * IS_DIGIT_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_DIGIT but with a single byte argument + */ +#define IS_DIGIT_CH(c) xmlIsDigit_ch(c) + +/** + * IS_COMBINING: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [87] CombiningChar ::= ... long list see REC ... + */ +#define IS_COMBINING(c) xmlIsCombiningQ(c) + +/** + * IS_COMBINING_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Always false (all combining chars > 0xff) + */ +#define IS_COMBINING_CH(c) 0 + +/** + * IS_EXTENDER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | + * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | + * [#x309D-#x309E] | [#x30FC-#x30FE] + */ +#define IS_EXTENDER(c) xmlIsExtenderQ(c) + +/** + * IS_EXTENDER_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_EXTENDER but with a single-byte argument + */ +#define IS_EXTENDER_CH(c) xmlIsExtender_ch(c) + +/** + * IS_IDEOGRAPHIC: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029] + */ +#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c) + +/** + * IS_LETTER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [84] Letter ::= BaseChar | Ideographic + */ +#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c)) + +/** + * IS_LETTER_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Macro behaves like IS_LETTER, but only check base chars + * + */ +#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c) + +/** + * IS_ASCII_LETTER: + * @c: an xmlChar value + * + * Macro to check [a-zA-Z] + * + */ +#define IS_ASCII_LETTER(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ + ((0x61 <= (c)) && ((c) <= 0x7a))) + +/** + * IS_ASCII_DIGIT: + * @c: an xmlChar value + * + * Macro to check [0-9] + * + */ +#define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39)) + +/** + * IS_PUBIDCHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] + */ +#define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c) + +/** + * IS_PUBIDCHAR_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Same as IS_PUBIDCHAR but for single-byte value + */ +#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c) + +/** + * SKIP_EOL: + * @p: and UTF8 string pointer + * + * Skips the end of line chars. + */ +#define SKIP_EOL(p) \ + if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \ + if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; } + +/** + * MOVETO_ENDTAG: + * @p: and UTF8 string pointer + * + * Skips to the next '>' char. + */ +#define MOVETO_ENDTAG(p) \ + while ((*p) && (*(p) != '>')) (p)++ + +/** + * MOVETO_STARTTAG: + * @p: and UTF8 string pointer + * + * Skips to the next '<' char. + */ +#define MOVETO_STARTTAG(p) \ + while ((*p) && (*(p) != '<')) (p)++ + +/** + * Global variables used for predefined strings. + */ +XMLPUBVAR const xmlChar xmlStringText[]; +XMLPUBVAR const xmlChar xmlStringTextNoenc[]; +XMLPUBVAR const xmlChar xmlStringComment[]; + +/* + * Function to finish the work of the macros where needed. + */ +XMLPUBFUN int XMLCALL xmlIsLetter (int c); + +/** + * Parser context. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateFileParserCtxt (const char *filename); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateURLParserCtxt (const char *filename, + int options); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateMemoryParserCtxt(const char *buffer, + int size); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateEntityParserCtxt(const xmlChar *URL, + const xmlChar *ID, + const xmlChar *base); +XMLPUBFUN int XMLCALL + xmlSwitchEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncodingHandlerPtr handler); +XMLPUBFUN int XMLCALL + xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input, + xmlCharEncodingHandlerPtr handler); + +#ifdef IN_LIBXML +/* internal error reporting */ +XMLPUBFUN void XMLCALL + __xmlErrEncoding (xmlParserCtxtPtr ctxt, + xmlParserErrors xmlerr, + const char *msg, + const xmlChar * str1, + const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0); +#endif + +/** + * Input Streams. + */ +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewStringInputStream (xmlParserCtxtPtr ctxt, + const xmlChar *buffer); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); +XMLPUBFUN int XMLCALL + xmlPushInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XMLPUBFUN xmlChar XMLCALL + xmlPopInput (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlFreeInputStream (xmlParserInputPtr input); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewInputFromFile (xmlParserCtxtPtr ctxt, + const char *filename); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewInputStream (xmlParserCtxtPtr ctxt); + +/** + * Namespaces. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlSplitQName (xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlChar **prefix); + +/** + * Generic production rules. + */ +XMLPUBFUN const xmlChar * XMLCALL + xmlParseName (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseNmtoken (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseEntityValue (xmlParserCtxtPtr ctxt, + xmlChar **orig); +XMLPUBFUN xmlChar * XMLCALL + xmlParseAttValue (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseSystemLiteral (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParsePubidLiteral (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseCharData (xmlParserCtxtPtr ctxt, + int cdata); +XMLPUBFUN xmlChar * XMLCALL + xmlParseExternalID (xmlParserCtxtPtr ctxt, + xmlChar **publicID, + int strict); +XMLPUBFUN void XMLCALL + xmlParseComment (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParsePITarget (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParsePI (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseNotationDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseEntityDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, + xmlChar **value); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlParseNotationType (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlParseEnumerationType (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XMLPUBFUN int XMLCALL + xmlParseAttributeType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XMLPUBFUN void XMLCALL + xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlParseElementMixedContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlParseElementChildrenContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XMLPUBFUN int XMLCALL + xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlElementContentPtr *result); +XMLPUBFUN int XMLCALL + xmlParseElementDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseMarkupDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseCharRef (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlParseEntityRef (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseReference (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParsePEReference (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN const xmlChar * XMLCALL + xmlParseAttribute (xmlParserCtxtPtr ctxt, + xmlChar **value); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseStartTag (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseEndTag (xmlParserCtxtPtr ctxt); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN void XMLCALL + xmlParseCDSect (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseContent (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseElement (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseVersionNum (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseVersionInfo (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseEncName (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseEncodingDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseSDDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseXMLDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseTextDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseMisc (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseExternalSubset (xmlParserCtxtPtr ctxt, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * XML_SUBSTITUTE_NONE: + * + * If no entities need to be substituted. + */ +#define XML_SUBSTITUTE_NONE 0 +/** + * XML_SUBSTITUTE_REF: + * + * Whether general entities need to be substituted. + */ +#define XML_SUBSTITUTE_REF 1 +/** + * XML_SUBSTITUTE_PEREF: + * + * Whether parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_PEREF 2 +/** + * XML_SUBSTITUTE_BOTH: + * + * Both general and parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_BOTH 3 + +XMLPUBFUN xmlChar * XMLCALL + xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XMLPUBFUN xmlChar * XMLCALL + xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); + +/* + * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP. + */ +XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, + xmlNodePtr value); +XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, + xmlParserInputPtr value); +XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL namePop (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, + const xmlChar *value); + +/* + * other commodities shared between parser.c and parserInternals. + */ +XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + int *len); +XMLPUBFUN void XMLCALL xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang); + +/* + * Really core function shared with HTML parser. + */ +XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, + int *len); +XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, + int val); +XMLPUBFUN int XMLCALL xmlCopyChar (int len, + xmlChar *out, + int val); +XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in); + +#ifdef LIBXML_HTML_ENABLED +/* + * Actually comes from the HTML parser but launched from the init stuff. + */ +XMLPUBFUN void XMLCALL htmlInitAutoClose (void); +XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename, + const char *encoding); +#endif + +/* + * Specific function to keep track of entities references + * and used by the XSLT debugger. + */ +#ifdef LIBXML_LEGACY_ENABLED +/** + * xmlEntityReferenceFunc: + * @ent: the entity + * @firstNode: the fist node in the chunk + * @lastNode: the last nod in the chunk + * + * Callback function used when one needs to be able to track back the + * provenance of a chunk of nodes inherited from an entity replacement. + */ +typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent, + xmlNodePtr firstNode, + xmlNodePtr lastNode); + +XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func); + +XMLPUBFUN xmlChar * XMLCALL + xmlParseQuotedString (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseNamespace (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlScanName (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseQName (xmlParserCtxtPtr ctxt, + xmlChar **prefix); +/** + * Entities + */ +XMLPUBFUN xmlChar * XMLCALL + xmlDecodeEntities (xmlParserCtxtPtr ctxt, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XMLPUBFUN void XMLCALL + xmlHandleEntity (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); + +#endif /* LIBXML_LEGACY_ENABLED */ + +#ifdef IN_LIBXML +/* + * internal only + */ +XMLPUBFUN void XMLCALL + xmlErrMemory (xmlParserCtxtPtr ctxt, + const char *extra); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_INTERNALS_H__ */ diff --git a/src/include/libxml/pattern.h b/src/include/libxml/pattern.h new file mode 100644 index 000000000000..97d2cd2bc085 --- /dev/null +++ b/src/include/libxml/pattern.h @@ -0,0 +1,100 @@ +/* + * Summary: pattern expression handling + * Description: allows to compile and test pattern expressions for nodes + * either in a tree or based on a parser state. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PATTERN_H__ +#define __XML_PATTERN_H__ + +#include +#include +#include + +#ifdef LIBXML_PATTERN_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlPattern: + * + * A compiled (XPath based) pattern to select nodes + */ +typedef struct _xmlPattern xmlPattern; +typedef xmlPattern *xmlPatternPtr; + +/** + * xmlPatternFlags: + * + * This is the set of options affecting the behaviour of pattern + * matching with this module + * + */ +typedef enum { + XML_PATTERN_DEFAULT = 0, /* simple pattern match */ + XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */ + XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */ + XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */ +} xmlPatternFlags; + +XMLPUBFUN void XMLCALL + xmlFreePattern (xmlPatternPtr comp); + +XMLPUBFUN void XMLCALL + xmlFreePatternList (xmlPatternPtr comp); + +XMLPUBFUN xmlPatternPtr XMLCALL + xmlPatterncompile (const xmlChar *pattern, + xmlDict *dict, + int flags, + const xmlChar **namespaces); +XMLPUBFUN int XMLCALL + xmlPatternMatch (xmlPatternPtr comp, + xmlNodePtr node); + +/* streaming interfaces */ +typedef struct _xmlStreamCtxt xmlStreamCtxt; +typedef xmlStreamCtxt *xmlStreamCtxtPtr; + +XMLPUBFUN int XMLCALL + xmlPatternStreamable (xmlPatternPtr comp); +XMLPUBFUN int XMLCALL + xmlPatternMaxDepth (xmlPatternPtr comp); +XMLPUBFUN int XMLCALL + xmlPatternMinDepth (xmlPatternPtr comp); +XMLPUBFUN int XMLCALL + xmlPatternFromRoot (xmlPatternPtr comp); +XMLPUBFUN xmlStreamCtxtPtr XMLCALL + xmlPatternGetStreamCtxt (xmlPatternPtr comp); +XMLPUBFUN void XMLCALL + xmlFreeStreamCtxt (xmlStreamCtxtPtr stream); +XMLPUBFUN int XMLCALL + xmlStreamPushNode (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns, + int nodeType); +XMLPUBFUN int XMLCALL + xmlStreamPush (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlStreamPushAttr (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlStreamPop (xmlStreamCtxtPtr stream); +XMLPUBFUN int XMLCALL + xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_PATTERN_ENABLED */ + +#endif /* __XML_PATTERN_H__ */ diff --git a/src/include/libxml/relaxng.h b/src/include/libxml/relaxng.h new file mode 100644 index 000000000000..f269c9ec0db2 --- /dev/null +++ b/src/include/libxml/relaxng.h @@ -0,0 +1,217 @@ +/* + * Summary: implementation of the Relax-NG validation + * Description: implementation of the Relax-NG validation + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_RELAX_NG__ +#define __XML_RELAX_NG__ + +#include +#include +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlRelaxNG xmlRelaxNG; +typedef xmlRelaxNG *xmlRelaxNGPtr; + + +/** + * xmlRelaxNGValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from a Relax-NG validation + */ +typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * xmlRelaxNGValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from a Relax-NG validation + */ +typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * A schemas validation context + */ +typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; +typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; + +typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; +typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; + +/* + * xmlRelaxNGValidErr: + * + * List of possible Relax NG validation errors + */ +typedef enum { + XML_RELAXNG_OK = 0, + XML_RELAXNG_ERR_MEMORY, + XML_RELAXNG_ERR_TYPE, + XML_RELAXNG_ERR_TYPEVAL, + XML_RELAXNG_ERR_DUPID, + XML_RELAXNG_ERR_TYPECMP, + XML_RELAXNG_ERR_NOSTATE, + XML_RELAXNG_ERR_NODEFINE, + XML_RELAXNG_ERR_LISTEXTRA, + XML_RELAXNG_ERR_LISTEMPTY, + XML_RELAXNG_ERR_INTERNODATA, + XML_RELAXNG_ERR_INTERSEQ, + XML_RELAXNG_ERR_INTEREXTRA, + XML_RELAXNG_ERR_ELEMNAME, + XML_RELAXNG_ERR_ATTRNAME, + XML_RELAXNG_ERR_ELEMNONS, + XML_RELAXNG_ERR_ATTRNONS, + XML_RELAXNG_ERR_ELEMWRONGNS, + XML_RELAXNG_ERR_ATTRWRONGNS, + XML_RELAXNG_ERR_ELEMEXTRANS, + XML_RELAXNG_ERR_ATTREXTRANS, + XML_RELAXNG_ERR_ELEMNOTEMPTY, + XML_RELAXNG_ERR_NOELEM, + XML_RELAXNG_ERR_NOTELEM, + XML_RELAXNG_ERR_ATTRVALID, + XML_RELAXNG_ERR_CONTENTVALID, + XML_RELAXNG_ERR_EXTRACONTENT, + XML_RELAXNG_ERR_INVALIDATTR, + XML_RELAXNG_ERR_DATAELEM, + XML_RELAXNG_ERR_VALELEM, + XML_RELAXNG_ERR_LISTELEM, + XML_RELAXNG_ERR_DATATYPE, + XML_RELAXNG_ERR_VALUE, + XML_RELAXNG_ERR_LIST, + XML_RELAXNG_ERR_NOGRAMMAR, + XML_RELAXNG_ERR_EXTRADATA, + XML_RELAXNG_ERR_LACKDATA, + XML_RELAXNG_ERR_INTERNAL, + XML_RELAXNG_ERR_ELEMWRONG, + XML_RELAXNG_ERR_TEXTWRONG +} xmlRelaxNGValidErr; + +/* + * xmlRelaxNGParserFlags: + * + * List of possible Relax NG Parser flags + */ +typedef enum { + XML_RELAXNGP_NONE = 0, + XML_RELAXNGP_FREE_DOC = 1, + XML_RELAXNGP_CRNG = 2 +} xmlRelaxNGParserFlag; + +XMLPUBFUN int XMLCALL + xmlRelaxNGInitTypes (void); +XMLPUBFUN void XMLCALL + xmlRelaxNGCleanupTypes (void); + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewParserCtxt (const char *URL); +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); + +XMLPUBFUN int XMLCALL + xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, + int flag); + +XMLPUBFUN void XMLCALL + xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetParserStructuredErrors( + xmlRelaxNGParserCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN xmlRelaxNGPtr XMLCALL + xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlRelaxNGFree (xmlRelaxNGPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlRelaxNGDump (FILE *output, + xmlRelaxNGPtr schema); +XMLPUBFUN void XMLCALL + xmlRelaxNGDumpTree (FILE * output, + xmlRelaxNGPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, void *ctx); +XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL + xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); +XMLPUBFUN void XMLCALL + xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc); +/* + * Interfaces for progressive validation when possible + */ +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ + +#endif /* __XML_RELAX_NG__ */ diff --git a/src/include/libxml/schemasInternals.h b/src/include/libxml/schemasInternals.h new file mode 100644 index 000000000000..c521d1c184cc --- /dev/null +++ b/src/include/libxml/schemasInternals.h @@ -0,0 +1,958 @@ +/* + * Summary: internal interfaces for XML Schemas + * Description: internal interfaces for the XML Schemas handling + * and schema validity checking + * The Schemas development is a Work In Progress. + * Some of those interfaces are not guaranteed to be API or ABI stable ! + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_INTERNALS_H__ +#define __XML_SCHEMA_INTERNALS_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMAS_UNKNOWN = 0, + XML_SCHEMAS_STRING = 1, + XML_SCHEMAS_NORMSTRING = 2, + XML_SCHEMAS_DECIMAL = 3, + XML_SCHEMAS_TIME = 4, + XML_SCHEMAS_GDAY = 5, + XML_SCHEMAS_GMONTH = 6, + XML_SCHEMAS_GMONTHDAY = 7, + XML_SCHEMAS_GYEAR = 8, + XML_SCHEMAS_GYEARMONTH = 9, + XML_SCHEMAS_DATE = 10, + XML_SCHEMAS_DATETIME = 11, + XML_SCHEMAS_DURATION = 12, + XML_SCHEMAS_FLOAT = 13, + XML_SCHEMAS_DOUBLE = 14, + XML_SCHEMAS_BOOLEAN = 15, + XML_SCHEMAS_TOKEN = 16, + XML_SCHEMAS_LANGUAGE = 17, + XML_SCHEMAS_NMTOKEN = 18, + XML_SCHEMAS_NMTOKENS = 19, + XML_SCHEMAS_NAME = 20, + XML_SCHEMAS_QNAME = 21, + XML_SCHEMAS_NCNAME = 22, + XML_SCHEMAS_ID = 23, + XML_SCHEMAS_IDREF = 24, + XML_SCHEMAS_IDREFS = 25, + XML_SCHEMAS_ENTITY = 26, + XML_SCHEMAS_ENTITIES = 27, + XML_SCHEMAS_NOTATION = 28, + XML_SCHEMAS_ANYURI = 29, + XML_SCHEMAS_INTEGER = 30, + XML_SCHEMAS_NPINTEGER = 31, + XML_SCHEMAS_NINTEGER = 32, + XML_SCHEMAS_NNINTEGER = 33, + XML_SCHEMAS_PINTEGER = 34, + XML_SCHEMAS_INT = 35, + XML_SCHEMAS_UINT = 36, + XML_SCHEMAS_LONG = 37, + XML_SCHEMAS_ULONG = 38, + XML_SCHEMAS_SHORT = 39, + XML_SCHEMAS_USHORT = 40, + XML_SCHEMAS_BYTE = 41, + XML_SCHEMAS_UBYTE = 42, + XML_SCHEMAS_HEXBINARY = 43, + XML_SCHEMAS_BASE64BINARY = 44, + XML_SCHEMAS_ANYTYPE = 45, + XML_SCHEMAS_ANYSIMPLETYPE = 46 +} xmlSchemaValType; + +/* + * XML Schemas defines multiple type of types. + */ +typedef enum { + XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */ + XML_SCHEMA_TYPE_ANY, + XML_SCHEMA_TYPE_FACET, + XML_SCHEMA_TYPE_SIMPLE, + XML_SCHEMA_TYPE_COMPLEX, + XML_SCHEMA_TYPE_SEQUENCE = 6, + XML_SCHEMA_TYPE_CHOICE, + XML_SCHEMA_TYPE_ALL, + XML_SCHEMA_TYPE_SIMPLE_CONTENT, + XML_SCHEMA_TYPE_COMPLEX_CONTENT, + XML_SCHEMA_TYPE_UR, + XML_SCHEMA_TYPE_RESTRICTION, + XML_SCHEMA_TYPE_EXTENSION, + XML_SCHEMA_TYPE_ELEMENT, + XML_SCHEMA_TYPE_ATTRIBUTE, + XML_SCHEMA_TYPE_ATTRIBUTEGROUP, + XML_SCHEMA_TYPE_GROUP, + XML_SCHEMA_TYPE_NOTATION, + XML_SCHEMA_TYPE_LIST, + XML_SCHEMA_TYPE_UNION, + XML_SCHEMA_TYPE_ANY_ATTRIBUTE, + XML_SCHEMA_TYPE_IDC_UNIQUE, + XML_SCHEMA_TYPE_IDC_KEY, + XML_SCHEMA_TYPE_IDC_KEYREF, + XML_SCHEMA_TYPE_PARTICLE = 25, + XML_SCHEMA_TYPE_ATTRIBUTE_USE, + XML_SCHEMA_FACET_MININCLUSIVE = 1000, + XML_SCHEMA_FACET_MINEXCLUSIVE, + XML_SCHEMA_FACET_MAXINCLUSIVE, + XML_SCHEMA_FACET_MAXEXCLUSIVE, + XML_SCHEMA_FACET_TOTALDIGITS, + XML_SCHEMA_FACET_FRACTIONDIGITS, + XML_SCHEMA_FACET_PATTERN, + XML_SCHEMA_FACET_ENUMERATION, + XML_SCHEMA_FACET_WHITESPACE, + XML_SCHEMA_FACET_LENGTH, + XML_SCHEMA_FACET_MAXLENGTH, + XML_SCHEMA_FACET_MINLENGTH, + XML_SCHEMA_EXTRA_QNAMEREF = 2000, + XML_SCHEMA_EXTRA_ATTR_USE_PROHIB +} xmlSchemaTypeType; + +typedef enum { + XML_SCHEMA_CONTENT_UNKNOWN = 0, + XML_SCHEMA_CONTENT_EMPTY = 1, + XML_SCHEMA_CONTENT_ELEMENTS, + XML_SCHEMA_CONTENT_MIXED, + XML_SCHEMA_CONTENT_SIMPLE, + XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */ + XML_SCHEMA_CONTENT_BASIC, + XML_SCHEMA_CONTENT_ANY +} xmlSchemaContentType; + +typedef struct _xmlSchemaVal xmlSchemaVal; +typedef xmlSchemaVal *xmlSchemaValPtr; + +typedef struct _xmlSchemaType xmlSchemaType; +typedef xmlSchemaType *xmlSchemaTypePtr; + +typedef struct _xmlSchemaFacet xmlSchemaFacet; +typedef xmlSchemaFacet *xmlSchemaFacetPtr; + +/** + * Annotation + */ +typedef struct _xmlSchemaAnnot xmlSchemaAnnot; +typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; +struct _xmlSchemaAnnot { + struct _xmlSchemaAnnot *next; + xmlNodePtr content; /* the annotation */ +}; + +/** + * XML_SCHEMAS_ANYATTR_SKIP: + * + * Skip unknown attribute from validation + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_SKIP 1 +/** + * XML_SCHEMAS_ANYATTR_LAX: + * + * Ignore validation non definition on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_LAX 2 +/** + * XML_SCHEMAS_ANYATTR_STRICT: + * + * Apply strict validation rules on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_STRICT 3 +/** + * XML_SCHEMAS_ANY_SKIP: + * + * Skip unknown attribute from validation + */ +#define XML_SCHEMAS_ANY_SKIP 1 +/** + * XML_SCHEMAS_ANY_LAX: + * + * Used by wildcards. + * Validate if type found, don't worry if not found + */ +#define XML_SCHEMAS_ANY_LAX 2 +/** + * XML_SCHEMAS_ANY_STRICT: + * + * Used by wildcards. + * Apply strict validation rules + */ +#define XML_SCHEMAS_ANY_STRICT 3 +/** + * XML_SCHEMAS_ATTR_USE_PROHIBITED: + * + * Used by wildcards. + * The attribute is prohibited. + */ +#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0 +/** + * XML_SCHEMAS_ATTR_USE_REQUIRED: + * + * The attribute is required. + */ +#define XML_SCHEMAS_ATTR_USE_REQUIRED 1 +/** + * XML_SCHEMAS_ATTR_USE_OPTIONAL: + * + * The attribute is optional. + */ +#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2 +/** + * XML_SCHEMAS_ATTR_GLOBAL: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0 +/** + * XML_SCHEMAS_ATTR_NSDEFAULT: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED: + * + * this is set when the "type" and "ref" references + * have been resolved. + */ +#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8 +/** + * XML_SCHEMAS_ATTR_FIXED: + * + * the attribute has a fixed value + */ +#define XML_SCHEMAS_ATTR_FIXED 1 << 9 + +/** + * xmlSchemaAttribute: + * An attribute definition. + */ + +typedef struct _xmlSchemaAttribute xmlSchemaAttribute; +typedef xmlSchemaAttribute *xmlSchemaAttributePtr; +struct _xmlSchemaAttribute { + xmlSchemaTypeType type; + struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */ + const xmlChar *name; /* the name of the declaration */ + const xmlChar *id; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + const xmlChar *typeName; /* the local name of the type definition */ + const xmlChar *typeNs; /* the ns URI of the type definition */ + xmlSchemaAnnotPtr annot; + + xmlSchemaTypePtr base; /* Deprecated; not used */ + int occurs; /* Deprecated; not used */ + const xmlChar *defValue; /* The initial value of the value constraint */ + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlNodePtr node; + const xmlChar *targetNamespace; + int flags; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaValPtr defVal; /* The compiled value constraint */ + xmlSchemaAttributePtr refDecl; /* Deprecated; not used */ +}; + +/** + * xmlSchemaAttributeLink: + * Used to build a list of attribute uses on complexType definitions. + * WARNING: Deprecated; not used. + */ +typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink; +typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr; +struct _xmlSchemaAttributeLink { + struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */ + struct _xmlSchemaAttribute *attr;/* the linked attribute */ +}; + +/** + * XML_SCHEMAS_WILDCARD_COMPLETE: + * + * If the wildcard is complete. + */ +#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0 + +/** + * xmlSchemaCharValueLink: + * Used to build a list of namespaces on wildcards. + */ +typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs; +typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr; +struct _xmlSchemaWildcardNs { + struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */ + const xmlChar *value;/* the value */ +}; + +/** + * xmlSchemaWildcard. + * A wildcard. + */ +typedef struct _xmlSchemaWildcard xmlSchemaWildcard; +typedef xmlSchemaWildcard *xmlSchemaWildcardPtr; +struct _xmlSchemaWildcard { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *id; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + int processContents; + int any; /* Indicates if the ns constraint is of ##any */ + xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */ + xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */ + int flags; +}; + +/** + * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED: + * + * The attribute wildcard has been built. + */ +#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0 +/** + * XML_SCHEMAS_ATTRGROUP_GLOBAL: + * + * The attribute group has been defined. + */ +#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ATTRGROUP_MARKED: + * + * Marks the attr group as marked; used for circular checks. + */ +#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2 + +/** + * XML_SCHEMAS_ATTRGROUP_REDEFINED: + * + * The attr group was redefined. + */ +#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3 +/** + * XML_SCHEMAS_ATTRGROUP_HAS_REFS: + * + * Whether this attr. group contains attr. group references. + */ +#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4 + +/** + * An attribute group definition. + * + * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures + * must be kept similar + */ +typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; +typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; +struct _xmlSchemaAttributeGroup { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ + const xmlChar *name; + const xmlChar *id; + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + + xmlSchemaAttributePtr attributes; /* Deprecated; not used */ + xmlNodePtr node; + int flags; + xmlSchemaWildcardPtr attributeWildcard; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */ + const xmlChar *targetNamespace; + void *attrUses; +}; + +/** + * xmlSchemaTypeLink: + * Used to build a list of types (e.g. member types of + * simpleType with variety "union"). + */ +typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink; +typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr; +struct _xmlSchemaTypeLink { + struct _xmlSchemaTypeLink *next;/* the next type link ... */ + xmlSchemaTypePtr type;/* the linked type */ +}; + +/** + * xmlSchemaFacetLink: + * Used to build a list of facets. + */ +typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink; +typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr; +struct _xmlSchemaFacetLink { + struct _xmlSchemaFacetLink *next;/* the next facet link ... */ + xmlSchemaFacetPtr facet;/* the linked facet */ +}; + +/** + * XML_SCHEMAS_TYPE_MIXED: + * + * the element content type is mixed + */ +#define XML_SCHEMAS_TYPE_MIXED 1 << 0 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION: + * + * the simple or complex type has a derivation method of "extension". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION: + * + * the simple or complex type has a derivation method of "restriction". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2 +/** + * XML_SCHEMAS_TYPE_GLOBAL: + * + * the type is global + */ +#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3 +/** + * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD: + * + * the complexType owns an attribute wildcard, i.e. + * it can be freed by the complexType + */ +#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */ +/** + * XML_SCHEMAS_TYPE_VARIETY_ABSENT: + * + * the simpleType has a variety of "absent". + * TODO: Actually not necessary :-/, since if + * none of the variety flags occur then it's + * automatically absent. + */ +#define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5 +/** + * XML_SCHEMAS_TYPE_VARIETY_LIST: + * + * the simpleType has a variety of "list". + */ +#define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6 +/** + * XML_SCHEMAS_TYPE_VARIETY_UNION: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7 +/** + * XML_SCHEMAS_TYPE_VARIETY_ATOMIC: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8 +/** + * XML_SCHEMAS_TYPE_FINAL_EXTENSION: + * + * the complexType has a final of "extension". + */ +#define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9 +/** + * XML_SCHEMAS_TYPE_FINAL_RESTRICTION: + * + * the simpleType/complexType has a final of "restriction". + */ +#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10 +/** + * XML_SCHEMAS_TYPE_FINAL_LIST: + * + * the simpleType has a final of "list". + */ +#define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11 +/** + * XML_SCHEMAS_TYPE_FINAL_UNION: + * + * the simpleType has a final of "union". + */ +#define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12 +/** + * XML_SCHEMAS_TYPE_FINAL_DEFAULT: + * + * the simpleType has a final of "default". + */ +#define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13 +/** + * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE: + * + * Marks the item as a builtin primitive. + */ +#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14 +/** + * XML_SCHEMAS_TYPE_MARKED: + * + * Marks the item as marked; used for circular checks. + */ +#define XML_SCHEMAS_TYPE_MARKED 1 << 16 +/** + * XML_SCHEMAS_TYPE_BLOCK_DEFAULT: + * + * the complexType did not specify 'block' so use the default of the + * item. + */ +#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17 +/** + * XML_SCHEMAS_TYPE_BLOCK_EXTENSION: + * + * the complexType has a 'block' of "extension". + */ +#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18 +/** + * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION: + * + * the complexType has a 'block' of "restriction". + */ +#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19 +/** + * XML_SCHEMAS_TYPE_ABSTRACT: + * + * the simple/complexType is abstract. + */ +#define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20 +/** + * XML_SCHEMAS_TYPE_FACETSNEEDVALUE: + * + * indicates if the facets need a computed value + */ +#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21 +/** + * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED: + * + * indicates that the type was typefixed + */ +#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22 +/** + * XML_SCHEMAS_TYPE_INTERNAL_INVALID: + * + * indicates that the type is invalid + */ +#define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE: + * + * a whitespace-facet value of "preserve" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE: + * + * a whitespace-facet value of "replace" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE: + * + * a whitespace-facet value of "collapse" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26 +/** + * XML_SCHEMAS_TYPE_HAS_FACETS: + * + * has facets + */ +#define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27 +/** + * XML_SCHEMAS_TYPE_NORMVALUENEEDED: + * + * indicates if the facets (pattern) need a normalized value + */ +#define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28 + +/** + * XML_SCHEMAS_TYPE_FIXUP_1: + * + * First stage of fixup was done. + */ +#define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29 + +/** + * XML_SCHEMAS_TYPE_REDEFINED: + * + * The type was redefined. + */ +#define XML_SCHEMAS_TYPE_REDEFINED 1 << 30 +/** + * XML_SCHEMAS_TYPE_REDEFINING: + * + * The type redefines an other type. + */ +/* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */ + +/** + * _xmlSchemaType: + * + * Schemas type definition. + */ +struct _xmlSchemaType { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next; /* the next type if in a sequence ... */ + const xmlChar *name; + const xmlChar *id ; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; + xmlSchemaAttributePtr attributes; /* Deprecated; not used */ + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + + int flags; + xmlSchemaContentType contentType; + const xmlChar *base; /* Base type's local name */ + const xmlChar *baseNs; /* Base type's target namespace */ + xmlSchemaTypePtr baseType; /* The base type component */ + xmlSchemaFacetPtr facets; /* Local facets */ + struct _xmlSchemaType *redef; /* Deprecated; not used */ + int recurse; /* Obsolete */ + xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */ + xmlSchemaWildcardPtr attributeWildcard; + int builtInType; /* Type of built-in types. */ + xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */ + xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */ + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types. + Could we use @subtypes for this? */ + xmlRegexpPtr contModel; /* Holds the automaton of the content model */ + const xmlChar *targetNamespace; + void *attrUses; +}; + +/* + * xmlSchemaElement: + * An element definition. + * + * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of + * structures must be kept similar + */ +/** + * XML_SCHEMAS_ELEM_NILLABLE: + * + * the element is nillable + */ +#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 +/** + * XML_SCHEMAS_ELEM_GLOBAL: + * + * the element is global + */ +#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ELEM_DEFAULT: + * + * the element has a default value + */ +#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 +/** + * XML_SCHEMAS_ELEM_FIXED: + * + * the element has a fixed value + */ +#define XML_SCHEMAS_ELEM_FIXED 1 << 3 +/** + * XML_SCHEMAS_ELEM_ABSTRACT: + * + * the element is abstract + */ +#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 +/** + * XML_SCHEMAS_ELEM_TOPLEVEL: + * + * the element is top level + * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead + */ +#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 +/** + * XML_SCHEMAS_ELEM_REF: + * + * the element is a reference to a type + */ +#define XML_SCHEMAS_ELEM_REF 1 << 6 +/** + * XML_SCHEMAS_ELEM_NSDEFAULT: + * + * allow elements in no namespace + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED: + * + * this is set when "type", "ref", "substitutionGroup" + * references have been resolved. + */ +#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8 + /** + * XML_SCHEMAS_ELEM_CIRCULAR: + * + * a helper flag for the search of circular references. + */ +#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9 +/** + * XML_SCHEMAS_ELEM_BLOCK_ABSENT: + * + * the "block" attribute is absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10 +/** + * XML_SCHEMAS_ELEM_BLOCK_EXTENSION: + * + * disallowed substitutions are absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11 +/** + * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: + * + * disallowed substitutions: "restriction" + */ +#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12 +/** + * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION: + * + * disallowed substitutions: "substitution" + */ +#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13 +/** + * XML_SCHEMAS_ELEM_FINAL_ABSENT: + * + * substitution group exclusions are absent + */ +#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14 +/** + * XML_SCHEMAS_ELEM_FINAL_EXTENSION: + * + * substitution group exclusions: "extension" + */ +#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15 +/** + * XML_SCHEMAS_ELEM_FINAL_RESTRICTION: + * + * substitution group exclusions: "restriction" + */ +#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16 +/** + * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD: + * + * the declaration is a substitution group head + */ +#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17 +/** + * XML_SCHEMAS_ELEM_INTERNAL_CHECKED: + * + * this is set when the elem decl has been checked against + * all constraints + */ +#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18 + +typedef struct _xmlSchemaElement xmlSchemaElement; +typedef xmlSchemaElement *xmlSchemaElementPtr; +struct _xmlSchemaElement { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next; /* Not used? */ + const xmlChar *name; + const xmlChar *id; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlSchemaAttributePtr attributes; + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + + int flags; + const xmlChar *targetNamespace; + const xmlChar *namedType; + const xmlChar *namedTypeNs; + const xmlChar *substGroup; + const xmlChar *substGroupNs; + const xmlChar *scope; + const xmlChar *value; /* The original value of the value constraint. */ + struct _xmlSchemaElement *refDecl; /* This will now be used for the + substitution group affiliation */ + xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */ + xmlSchemaContentType contentType; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaValPtr defVal; /* The compiled value constraint. */ + void *idcs; /* The identity-constraint defs */ +}; + +/* + * XML_SCHEMAS_FACET_UNKNOWN: + * + * unknown facet handling + */ +#define XML_SCHEMAS_FACET_UNKNOWN 0 +/* + * XML_SCHEMAS_FACET_PRESERVE: + * + * preserve the type of the facet + */ +#define XML_SCHEMAS_FACET_PRESERVE 1 +/* + * XML_SCHEMAS_FACET_REPLACE: + * + * replace the type of the facet + */ +#define XML_SCHEMAS_FACET_REPLACE 2 +/* + * XML_SCHEMAS_FACET_COLLAPSE: + * + * collapse the types of the facet + */ +#define XML_SCHEMAS_FACET_COLLAPSE 3 +/** + * A facet definition. + */ +struct _xmlSchemaFacet { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */ + const xmlChar *value; /* The original value */ + const xmlChar *id; /* Obsolete */ + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */ + int whitespace; + xmlSchemaValPtr val; /* The compiled value */ + xmlRegexpPtr regexp; /* The regex for patterns */ +}; + +/** + * A notation definition. + */ +typedef struct _xmlSchemaNotation xmlSchemaNotation; +typedef xmlSchemaNotation *xmlSchemaNotationPtr; +struct _xmlSchemaNotation { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *name; + xmlSchemaAnnotPtr annot; + const xmlChar *identifier; + const xmlChar *targetNamespace; +}; + +/* +* TODO: Actually all those flags used for the schema should sit +* on the schema parser context, since they are used only +* during parsing an XML schema document, and not available +* on the component level as per spec. +*/ +/** + * XML_SCHEMAS_QUALIF_ELEM: + * + * Reflects elementFormDefault == qualified in + * an XML schema document. + */ +#define XML_SCHEMAS_QUALIF_ELEM 1 << 0 +/** + * XML_SCHEMAS_QUALIF_ATTR: + * + * Reflects attributeFormDefault == qualified in + * an XML schema document. + */ +#define XML_SCHEMAS_QUALIF_ATTR 1 << 1 +/** + * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2 +/** + * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3 +/** + * XML_SCHEMAS_FINAL_DEFAULT_LIST: + * + * the schema has "list" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4 +/** + * XML_SCHEMAS_FINAL_DEFAULT_UNION: + * + * the schema has "union" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION: + * + * the schema has "substitution" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8 +/** + * XML_SCHEMAS_INCLUDING_CONVERT_NS: + * + * the schema is currently including an other schema with + * no target namespace. + */ +#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9 +/** + * _xmlSchema: + * + * A Schemas definition + */ +struct _xmlSchema { + const xmlChar *name; /* schema name */ + const xmlChar *targetNamespace; /* the target namespace */ + const xmlChar *version; + const xmlChar *id; /* Obsolete */ + xmlDocPtr doc; + xmlSchemaAnnotPtr annot; + int flags; + + xmlHashTablePtr typeDecl; + xmlHashTablePtr attrDecl; + xmlHashTablePtr attrgrpDecl; + xmlHashTablePtr elemDecl; + xmlHashTablePtr notaDecl; + + xmlHashTablePtr schemasImports; + + void *_private; /* unused by the library for users or bindings */ + xmlHashTablePtr groupDecl; + xmlDictPtr dict; + void *includes; /* the includes, this is opaque for now */ + int preserve; /* whether to free the document */ + int counter; /* used to give anonymous components unique names */ + xmlHashTablePtr idcDef; /* All identity-constraint defs. */ + void *volatiles; /* Obsolete */ +}; + +XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type); +XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_INTERNALS_H__ */ diff --git a/src/include/libxml/schematron.h b/src/include/libxml/schematron.h new file mode 100644 index 000000000000..364eaecde6b1 --- /dev/null +++ b/src/include/libxml/schematron.h @@ -0,0 +1,142 @@ +/* + * Summary: XML Schemastron implementation + * Description: interface to the XML Schematron validity checking. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMATRON_H__ +#define __XML_SCHEMATRON_H__ + +#include + +#ifdef LIBXML_SCHEMATRON_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ + XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ + XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ + XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */ + XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */ + XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */ + XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */ +} xmlSchematronValidOptions; + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchematron xmlSchematron; +typedef xmlSchematron *xmlSchematronPtr; + +/** + * xmlSchematronValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from a Schematron validation + */ +typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); + +/** + * xmlSchematronValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from a Schematron validation + */ +typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); + +/** + * A schemas validation context + */ +typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; +typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; + +typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; +typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL + xmlSchematronNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL + xmlSchematronNewMemParserCtxt(const char *buffer, + int size); +XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL + xmlSchematronNewDocParserCtxt(xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); +/***** +XMLPUBFUN void XMLCALL + xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, + xmlSchematronValidityErrorFunc err, + xmlSchematronValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, + xmlSchematronValidityErrorFunc * err, + xmlSchematronValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); + *****/ +XMLPUBFUN xmlSchematronPtr XMLCALL + xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchematronFree (xmlSchematronPtr schema); +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlSchematronSetValidStructuredErrors( + xmlSchematronValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +/****** +XMLPUBFUN void XMLCALL + xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, + xmlSchematronValidityErrorFunc err, + xmlSchematronValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, + xmlSchematronValidityErrorFunc *err, + xmlSchematronValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, + int options); +XMLPUBFUN int XMLCALL + xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, + xmlNodePtr elem); + *******/ + +XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL + xmlSchematronNewValidCtxt (xmlSchematronPtr schema, + int options); +XMLPUBFUN void XMLCALL + xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, + xmlDocPtr instance); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMATRON_ENABLED */ +#endif /* __XML_SCHEMATRON_H__ */ diff --git a/src/include/libxml/threads.h b/src/include/libxml/threads.h new file mode 100644 index 000000000000..9969ae7cfd0d --- /dev/null +++ b/src/include/libxml/threads.h @@ -0,0 +1,89 @@ +/** + * Summary: interfaces for thread handling + * Description: set of generic threading related routines + * should work with pthreads, Windows native or TLS threads + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_THREADS_H__ +#define __XML_THREADS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlMutex are a simple mutual exception locks. + */ +typedef struct _xmlMutex xmlMutex; +typedef xmlMutex *xmlMutexPtr; + +/* + * xmlRMutex are reentrant mutual exception locks. + */ +typedef struct _xmlRMutex xmlRMutex; +typedef xmlRMutex *xmlRMutexPtr; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN xmlMutexPtr XMLCALL + xmlNewMutex (void); +XMLPUBFUN void XMLCALL + xmlMutexLock (xmlMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlMutexUnlock (xmlMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlFreeMutex (xmlMutexPtr tok); + +XMLPUBFUN xmlRMutexPtr XMLCALL + xmlNewRMutex (void); +XMLPUBFUN void XMLCALL + xmlRMutexLock (xmlRMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlRMutexUnlock (xmlRMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlFreeRMutex (xmlRMutexPtr tok); + +/* + * Library wide APIs. + */ +XMLPUBFUN void XMLCALL + xmlInitThreads (void); +XMLPUBFUN void XMLCALL + xmlLockLibrary (void); +XMLPUBFUN void XMLCALL + xmlUnlockLibrary(void); +XMLPUBFUN int XMLCALL + xmlGetThreadId (void); +XMLPUBFUN int XMLCALL + xmlIsMainThread (void); +XMLPUBFUN void XMLCALL + xmlCleanupThreads(void); +XMLPUBFUN xmlGlobalStatePtr XMLCALL + xmlGetGlobalState(void); + +#ifdef HAVE_PTHREAD_H +#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) +#if defined(LIBXML_STATIC_FOR_DLL) +int XMLCALL +xmlDllMain(void *hinstDLL, unsigned long fdwReason, + void *lpvReserved); +#endif +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* __XML_THREADS_H__ */ diff --git a/src/include/libxml/tree.h b/src/include/libxml/tree.h new file mode 100644 index 000000000000..1e79be92ea9a --- /dev/null +++ b/src/include/libxml/tree.h @@ -0,0 +1,1311 @@ +/* + * Summary: interfaces for tree manipulation + * Description: this module describes the structures found in an tree resulting + * from an XML or HTML parsing, as well as the API provided for + * various processing on that tree + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_TREE_H__ +#define __XML_TREE_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Some of the basic types pointer to structures: + */ +/* xmlIO.h */ +typedef struct _xmlParserInputBuffer xmlParserInputBuffer; +typedef xmlParserInputBuffer *xmlParserInputBufferPtr; + +typedef struct _xmlOutputBuffer xmlOutputBuffer; +typedef xmlOutputBuffer *xmlOutputBufferPtr; + +/* parser.h */ +typedef struct _xmlParserInput xmlParserInput; +typedef xmlParserInput *xmlParserInputPtr; + +typedef struct _xmlParserCtxt xmlParserCtxt; +typedef xmlParserCtxt *xmlParserCtxtPtr; + +typedef struct _xmlSAXLocator xmlSAXLocator; +typedef xmlSAXLocator *xmlSAXLocatorPtr; + +typedef struct _xmlSAXHandler xmlSAXHandler; +typedef xmlSAXHandler *xmlSAXHandlerPtr; + +/* entities.h */ +typedef struct _xmlEntity xmlEntity; +typedef xmlEntity *xmlEntityPtr; + +/** + * BASE_BUFFER_SIZE: + * + * default buffer size 4000. + */ +#define BASE_BUFFER_SIZE 4096 + +/** + * LIBXML_NAMESPACE_DICT: + * + * Defines experimental behaviour: + * 1) xmlNs gets an additional field @context (a xmlDoc) + * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc. + */ +/* #define LIBXML_NAMESPACE_DICT */ + +/** + * xmlBufferAllocationScheme: + * + * A buffer allocation scheme can be defined to either match exactly the + * need or double it's allocated size each time it is found too small. + */ + +typedef enum { + XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */ + XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */ + XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */ + XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */ + XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */ + XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */ +} xmlBufferAllocationScheme; + +/** + * xmlBuffer: + * + * A buffer structure, this old construct is limited to 2GB and + * is being deprecated, use API with xmlBuf instead + */ +typedef struct _xmlBuffer xmlBuffer; +typedef xmlBuffer *xmlBufferPtr; +struct _xmlBuffer { + xmlChar *content; /* The buffer content UTF8 */ + unsigned int use; /* The buffer size used */ + unsigned int size; /* The buffer size */ + xmlBufferAllocationScheme alloc; /* The realloc method */ + xmlChar *contentIO; /* in IO mode we may have a different base */ +}; + +/** + * xmlBuf: + * + * A buffer structure, new one, the actual structure internals are not public + */ + +typedef struct _xmlBuf xmlBuf; + +/** + * xmlBufPtr: + * + * A pointer to a buffer structure, the actual structure internals are not + * public + */ + +typedef xmlBuf *xmlBufPtr; + +/* + * A few public routines for xmlBuf. As those are expected to be used + * mostly internally the bulk of the routines are internal in buf.h + */ +XMLPUBFUN xmlChar* XMLCALL xmlBufContent (const xmlBuf* buf); +XMLPUBFUN xmlChar* XMLCALL xmlBufEnd (xmlBufPtr buf); +XMLPUBFUN size_t XMLCALL xmlBufUse (const xmlBufPtr buf); +XMLPUBFUN size_t XMLCALL xmlBufShrink (xmlBufPtr buf, size_t len); + +/* + * LIBXML2_NEW_BUFFER: + * + * Macro used to express that the API use the new buffers for + * xmlParserInputBuffer and xmlOutputBuffer. The change was + * introduced in 2.9.0. + */ +#define LIBXML2_NEW_BUFFER + +/** + * XML_XML_NAMESPACE: + * + * This is the namespace for the special xml: prefix predefined in the + * XML Namespace specification. + */ +#define XML_XML_NAMESPACE \ + (const xmlChar *) "http://www.w3.org/XML/1998/namespace" + +/** + * XML_XML_ID: + * + * This is the name for the special xml:id attribute + */ +#define XML_XML_ID (const xmlChar *) "xml:id" + +/* + * The different element types carried by an XML tree. + * + * NOTE: This is synchronized with DOM Level1 values + * See http://www.w3.org/TR/REC-DOM-Level-1/ + * + * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should + * be deprecated to use an XML_DTD_NODE. + */ +typedef enum { + XML_ELEMENT_NODE= 1, + XML_ATTRIBUTE_NODE= 2, + XML_TEXT_NODE= 3, + XML_CDATA_SECTION_NODE= 4, + XML_ENTITY_REF_NODE= 5, + XML_ENTITY_NODE= 6, + XML_PI_NODE= 7, + XML_COMMENT_NODE= 8, + XML_DOCUMENT_NODE= 9, + XML_DOCUMENT_TYPE_NODE= 10, + XML_DOCUMENT_FRAG_NODE= 11, + XML_NOTATION_NODE= 12, + XML_HTML_DOCUMENT_NODE= 13, + XML_DTD_NODE= 14, + XML_ELEMENT_DECL= 15, + XML_ATTRIBUTE_DECL= 16, + XML_ENTITY_DECL= 17, + XML_NAMESPACE_DECL= 18, + XML_XINCLUDE_START= 19, + XML_XINCLUDE_END= 20 +#ifdef LIBXML_DOCB_ENABLED + ,XML_DOCB_DOCUMENT_NODE= 21 +#endif +} xmlElementType; + + +/** + * xmlNotation: + * + * A DTD Notation definition. + */ + +typedef struct _xmlNotation xmlNotation; +typedef xmlNotation *xmlNotationPtr; +struct _xmlNotation { + const xmlChar *name; /* Notation name */ + const xmlChar *PublicID; /* Public identifier, if any */ + const xmlChar *SystemID; /* System identifier, if any */ +}; + +/** + * xmlAttributeType: + * + * A DTD Attribute type definition. + */ + +typedef enum { + XML_ATTRIBUTE_CDATA = 1, + XML_ATTRIBUTE_ID, + XML_ATTRIBUTE_IDREF , + XML_ATTRIBUTE_IDREFS, + XML_ATTRIBUTE_ENTITY, + XML_ATTRIBUTE_ENTITIES, + XML_ATTRIBUTE_NMTOKEN, + XML_ATTRIBUTE_NMTOKENS, + XML_ATTRIBUTE_ENUMERATION, + XML_ATTRIBUTE_NOTATION +} xmlAttributeType; + +/** + * xmlAttributeDefault: + * + * A DTD Attribute default definition. + */ + +typedef enum { + XML_ATTRIBUTE_NONE = 1, + XML_ATTRIBUTE_REQUIRED, + XML_ATTRIBUTE_IMPLIED, + XML_ATTRIBUTE_FIXED +} xmlAttributeDefault; + +/** + * xmlEnumeration: + * + * List structure used when there is an enumeration in DTDs. + */ + +typedef struct _xmlEnumeration xmlEnumeration; +typedef xmlEnumeration *xmlEnumerationPtr; +struct _xmlEnumeration { + struct _xmlEnumeration *next; /* next one */ + const xmlChar *name; /* Enumeration name */ +}; + +/** + * xmlAttribute: + * + * An Attribute declaration in a DTD. + */ + +typedef struct _xmlAttribute xmlAttribute; +typedef xmlAttribute *xmlAttributePtr; +struct _xmlAttribute { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ + const xmlChar *name; /* Attribute name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + struct _xmlAttribute *nexth; /* next in hash table */ + xmlAttributeType atype; /* The attribute type */ + xmlAttributeDefault def; /* the default */ + const xmlChar *defaultValue; /* or the default value */ + xmlEnumerationPtr tree; /* or the enumeration tree if any */ + const xmlChar *prefix; /* the namespace prefix if any */ + const xmlChar *elem; /* Element holding the attribute */ +}; + +/** + * xmlElementContentType: + * + * Possible definitions of element content types. + */ +typedef enum { + XML_ELEMENT_CONTENT_PCDATA = 1, + XML_ELEMENT_CONTENT_ELEMENT, + XML_ELEMENT_CONTENT_SEQ, + XML_ELEMENT_CONTENT_OR +} xmlElementContentType; + +/** + * xmlElementContentOccur: + * + * Possible definitions of element content occurrences. + */ +typedef enum { + XML_ELEMENT_CONTENT_ONCE = 1, + XML_ELEMENT_CONTENT_OPT, + XML_ELEMENT_CONTENT_MULT, + XML_ELEMENT_CONTENT_PLUS +} xmlElementContentOccur; + +/** + * xmlElementContent: + * + * An XML Element content as stored after parsing an element definition + * in a DTD. + */ + +typedef struct _xmlElementContent xmlElementContent; +typedef xmlElementContent *xmlElementContentPtr; +struct _xmlElementContent { + xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ + xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ + const xmlChar *name; /* Element name */ + struct _xmlElementContent *c1; /* first child */ + struct _xmlElementContent *c2; /* second child */ + struct _xmlElementContent *parent; /* parent */ + const xmlChar *prefix; /* Namespace prefix */ +}; + +/** + * xmlElementTypeVal: + * + * The different possibilities for an element content type. + */ + +typedef enum { + XML_ELEMENT_TYPE_UNDEFINED = 0, + XML_ELEMENT_TYPE_EMPTY = 1, + XML_ELEMENT_TYPE_ANY, + XML_ELEMENT_TYPE_MIXED, + XML_ELEMENT_TYPE_ELEMENT +} xmlElementTypeVal; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlElement: + * + * An XML Element declaration from a DTD. + */ + +typedef struct _xmlElement xmlElement; +typedef xmlElement *xmlElementPtr; +struct _xmlElement { + void *_private; /* application data */ + xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ + const xmlChar *name; /* Element name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlElementTypeVal etype; /* The type */ + xmlElementContentPtr content; /* the allowed element content */ + xmlAttributePtr attributes; /* List of the declared attributes */ + const xmlChar *prefix; /* the namespace prefix if any */ +#ifdef LIBXML_REGEXP_ENABLED + xmlRegexpPtr contModel; /* the validating regexp */ +#else + void *contModel; +#endif +}; + + +/** + * XML_LOCAL_NAMESPACE: + * + * A namespace declaration node. + */ +#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL +typedef xmlElementType xmlNsType; + +/** + * xmlNs: + * + * An XML namespace. + * Note that prefix == NULL is valid, it defines the default namespace + * within the subtree (until overridden). + * + * xmlNsType is unified with xmlElementType. + */ + +typedef struct _xmlNs xmlNs; +typedef xmlNs *xmlNsPtr; +struct _xmlNs { + struct _xmlNs *next; /* next Ns link for this node */ + xmlNsType type; /* global or local */ + const xmlChar *href; /* URL for the namespace */ + const xmlChar *prefix; /* prefix for the namespace */ + void *_private; /* application data */ + struct _xmlDoc *context; /* normally an xmlDoc */ +}; + +/** + * xmlDtd: + * + * An XML DTD, as defined by parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + void *notations; /* Hash table for notations if any */ + void *elements; /* Hash table for elements if any */ + void *attributes; /* Hash table for attributes if any */ + void *entities; /* Hash table for entities if any */ + const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ + void *pentities; /* Hash table for param entities if any */ +}; + +/** + * xmlAttr: + * + * An attribute on an XML node. + */ +typedef struct _xmlAttr xmlAttr; +typedef xmlAttr *xmlAttrPtr; +struct _xmlAttr { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ + const xmlChar *name; /* the name of the property */ + struct _xmlNode *children; /* the value of the property */ + struct _xmlNode *last; /* NULL */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlAttr *next; /* next sibling link */ + struct _xmlAttr *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlAttributeType atype; /* the attribute type if validating */ + void *psvi; /* for type/PSVI information */ +}; + +/** + * xmlID: + * + * An XML ID instance. + */ + +typedef struct _xmlID xmlID; +typedef xmlID *xmlIDPtr; +struct _xmlID { + struct _xmlID *next; /* next ID */ + const xmlChar *value; /* The ID name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ + struct _xmlDoc *doc; /* The document holding the ID */ +}; + +/** + * xmlRef: + * + * An XML IDREF instance. + */ + +typedef struct _xmlRef xmlRef; +typedef xmlRef *xmlRefPtr; +struct _xmlRef { + struct _xmlRef *next; /* next Ref */ + const xmlChar *value; /* The Ref name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ +}; + +/** + * xmlNode: + * + * A node in an XML tree. + */ +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; +struct _xmlNode { + void *_private; /* application data */ + xmlElementType type; /* type number, must be second ! */ + const xmlChar *name; /* the name of the node, or the entity */ + struct _xmlNode *children; /* parent->childs link */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlChar *content; /* the content */ + struct _xmlAttr *properties;/* properties list */ + xmlNs *nsDef; /* namespace definitions on this node */ + void *psvi; /* for type/PSVI information */ + unsigned short line; /* line number */ + unsigned short extra; /* extra data for XPath/XSLT */ +}; + +/** + * XML_GET_CONTENT: + * + * Macro to extract the content pointer of a node. + */ +#define XML_GET_CONTENT(n) \ + ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content) + +/** + * XML_GET_LINE: + * + * Macro to extract the line number of an element node. + */ +#define XML_GET_LINE(n) \ + (xmlGetLineNo(n)) + +/** + * xmlDocProperty + * + * Set of properties of the document as found by the parser + * Some of them are linked to similarly named xmlParserOption + */ +typedef enum { + XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */ + XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */ + XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */ + XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */ + XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */ + XML_DOC_USERBUILT = 1<<5, /* Document was built using the API + and not by parsing an instance */ + XML_DOC_INTERNAL = 1<<6, /* built for internal processing */ + XML_DOC_HTML = 1<<7 /* parsed or built HTML document */ +} xmlDocProperties; + +/** + * xmlDoc: + * + * An XML document. + */ +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; +struct _xmlDoc { + void *_private; /* application data */ + xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ + char *name; /* name/filename/URI of the document */ + struct _xmlNode *children; /* the document tree */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* autoreference to itself */ + + /* End of common part */ + int compression;/* level of zlib compression */ + int standalone; /* standalone document (no external refs) + 1 if standalone="yes" + 0 if standalone="no" + -1 if there is no XML declaration + -2 if there is an XML declaration, but no + standalone attribute was specified */ + struct _xmlDtd *intSubset; /* the document internal subset */ + struct _xmlDtd *extSubset; /* the document external subset */ + struct _xmlNs *oldNs; /* Global namespace, the old way */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* external initial encoding, if any */ + void *ids; /* Hash table for ID attributes if any */ + void *refs; /* Hash table for IDREFs attributes if any */ + const xmlChar *URL; /* The URI for that document */ + int charset; /* Internal flag for charset handling, + actually an xmlCharEncoding */ + struct _xmlDict *dict; /* dict used to allocate names or NULL */ + void *psvi; /* for type/PSVI information */ + int parseFlags; /* set of xmlParserOption used to parse the + document */ + int properties; /* set of xmlDocProperties for this document + set at the end of parsing */ +}; + + +typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt; +typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr; + +/** + * xmlDOMWrapAcquireNsFunction: + * @ctxt: a DOM wrapper context + * @node: the context node (element or attribute) + * @nsName: the requested namespace name + * @nsPrefix: the requested namespace prefix + * + * A function called to acquire namespaces (xmlNs) from the wrapper. + * + * Returns an xmlNsPtr or NULL in case of an error. + */ +typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr node, + const xmlChar *nsName, + const xmlChar *nsPrefix); + +/** + * xmlDOMWrapCtxt: + * + * Context for DOM wrapper-operations. + */ +struct _xmlDOMWrapCtxt { + void * _private; + /* + * The type of this context, just in case we need specialized + * contexts in the future. + */ + int type; + /* + * Internal namespace map used for various operations. + */ + void * namespaceMap; + /* + * Use this one to acquire an xmlNsPtr intended for node->ns. + * (Note that this is not intended for elem->nsDef). + */ + xmlDOMWrapAcquireNsFunction getNsForNodeFunc; +}; + +/** + * xmlChildrenNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children." + */ +#ifndef xmlChildrenNode +#define xmlChildrenNode children +#endif + +/** + * xmlRootNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children". + */ +#ifndef xmlRootNode +#define xmlRootNode children +#endif + +/* + * Variables. + */ + +/* + * Some helper functions + */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \ + defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \ + defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \ + defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED) +XMLPUBFUN int XMLCALL + xmlValidateNCName (const xmlChar *value, + int space); +#endif + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN int XMLCALL + xmlValidateQName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateNMToken (const xmlChar *value, + int space); +#endif + +XMLPUBFUN xmlChar * XMLCALL + xmlBuildQName (const xmlChar *ncname, + const xmlChar *prefix, + xmlChar *memory, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlSplitQName2 (const xmlChar *name, + xmlChar **prefix); +XMLPUBFUN const xmlChar * XMLCALL + xmlSplitQName3 (const xmlChar *name, + int *len); + +/* + * Handling Buffers, the old ones see @xmlBuf for the new ones. + */ + +XMLPUBFUN void XMLCALL + xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); +XMLPUBFUN xmlBufferAllocationScheme XMLCALL + xmlGetBufferAllocationScheme(void); + +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreate (void); +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreateSize (size_t size); +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreateStatic (void *mem, + size_t size); +XMLPUBFUN int XMLCALL + xmlBufferResize (xmlBufferPtr buf, + unsigned int size); +XMLPUBFUN void XMLCALL + xmlBufferFree (xmlBufferPtr buf); +XMLPUBFUN int XMLCALL + xmlBufferDump (FILE *file, + xmlBufferPtr buf); +XMLPUBFUN int XMLCALL + xmlBufferAdd (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int XMLCALL + xmlBufferAddHead (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int XMLCALL + xmlBufferCat (xmlBufferPtr buf, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlBufferCCat (xmlBufferPtr buf, + const char *str); +XMLPUBFUN int XMLCALL + xmlBufferShrink (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN int XMLCALL + xmlBufferGrow (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN void XMLCALL + xmlBufferEmpty (xmlBufferPtr buf); +XMLPUBFUN const xmlChar* XMLCALL + xmlBufferContent (const xmlBuffer *buf); +XMLPUBFUN xmlChar* XMLCALL + xmlBufferDetach (xmlBufferPtr buf); +XMLPUBFUN void XMLCALL + xmlBufferSetAllocationScheme(xmlBufferPtr buf, + xmlBufferAllocationScheme scheme); +XMLPUBFUN int XMLCALL + xmlBufferLength (const xmlBuffer *buf); + +/* + * Creating/freeing new structures. + */ +XMLPUBFUN xmlDtdPtr XMLCALL + xmlCreateIntSubset (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlNewDtd (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlGetIntSubset (const xmlDoc *doc); +XMLPUBFUN void XMLCALL + xmlFreeDtd (xmlDtdPtr cur); +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN xmlNsPtr XMLCALL + xmlNewGlobalNs (xmlDocPtr doc, + const xmlChar *href, + const xmlChar *prefix); +#endif /* LIBXML_LEGACY_ENABLED */ +XMLPUBFUN xmlNsPtr XMLCALL + xmlNewNs (xmlNodePtr node, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + xmlFreeNs (xmlNsPtr cur); +XMLPUBFUN void XMLCALL + xmlFreeNsList (xmlNsPtr cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlNewDoc (const xmlChar *version); +XMLPUBFUN void XMLCALL + xmlFreeDoc (xmlDocPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewDocProp (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *value); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +#endif +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewNsPropEatName (xmlNodePtr node, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlFreePropList (xmlAttrPtr cur); +XMLPUBFUN void XMLCALL + xmlFreeProp (xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlCopyProp (xmlNodePtr target, + xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlCopyPropList (xmlNodePtr target, + xmlAttrPtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlDtdPtr XMLCALL + xmlCopyDtd (xmlDtdPtr dtd); +#endif /* LIBXML_TREE_ENABLED */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlDocPtr XMLCALL + xmlCopyDoc (xmlDocPtr doc, + int recursive); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ +/* + * Creating new nodes. + */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocNodeEatName (xmlDocPtr doc, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewNode (xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewNodeEatName (xmlNsPtr ns, + xmlChar *name); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +#endif +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocText (const xmlDoc *doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewText (const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocPI (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewPI (const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocTextLen (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewTextLen (const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocComment (xmlDocPtr doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewComment (const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewCDataBlock (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewCharRef (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewReference (const xmlDoc *doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlCopyNode (xmlNodePtr node, + int recursive); +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocCopyNode (xmlNodePtr node, + xmlDocPtr doc, + int recursive); +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocCopyNodeList (xmlDocPtr doc, + xmlNodePtr node); +XMLPUBFUN xmlNodePtr XMLCALL + xmlCopyNodeList (xmlNodePtr node); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewTextChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocRawNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocFragment (xmlDocPtr doc); +#endif /* LIBXML_TREE_ENABLED */ + +/* + * Navigating. + */ +XMLPUBFUN long XMLCALL + xmlGetLineNo (const xmlNode *node); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) +XMLPUBFUN xmlChar * XMLCALL + xmlGetNodePath (const xmlNode *node); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocGetRootElement (const xmlDoc *doc); +XMLPUBFUN xmlNodePtr XMLCALL + xmlGetLastChild (const xmlNode *parent); +XMLPUBFUN int XMLCALL + xmlNodeIsText (const xmlNode *node); +XMLPUBFUN int XMLCALL + xmlIsBlankNode (const xmlNode *node); + +/* + * Changing the structure. + */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddChild (xmlNodePtr parent, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddChildList (xmlNodePtr parent, + xmlNodePtr cur); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN void XMLCALL + xmlUnlinkNode (xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextMerge (xmlNodePtr first, + xmlNodePtr second); +XMLPUBFUN int XMLCALL + xmlTextConcat (xmlNodePtr node, + const xmlChar *content, + int len); +XMLPUBFUN void XMLCALL + xmlFreeNodeList (xmlNodePtr cur); +XMLPUBFUN void XMLCALL + xmlFreeNode (xmlNodePtr cur); +XMLPUBFUN void XMLCALL + xmlSetTreeDoc (xmlNodePtr tree, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSetListDoc (xmlNodePtr list, + xmlDocPtr doc); +/* + * Namespaces. + */ +XMLPUBFUN xmlNsPtr XMLCALL + xmlSearchNs (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *nameSpace); +XMLPUBFUN xmlNsPtr XMLCALL + xmlSearchNsByHref (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *href); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlNsPtr * XMLCALL + xmlGetNsList (const xmlDoc *doc, + const xmlNode *node); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */ + +XMLPUBFUN void XMLCALL + xmlSetNs (xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN xmlNsPtr XMLCALL + xmlCopyNamespace (xmlNsPtr cur); +XMLPUBFUN xmlNsPtr XMLCALL + xmlCopyNamespaceList (xmlNsPtr cur); + +/* + * Changing the content. + */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) +XMLPUBFUN xmlAttrPtr XMLCALL + xmlSetProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */ +XMLPUBFUN xmlChar * XMLCALL + xmlGetNoNsProp (const xmlNode *node, + const xmlChar *name); +XMLPUBFUN xmlChar * XMLCALL + xmlGetProp (const xmlNode *node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlHasProp (const xmlNode *node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlHasNsProp (const xmlNode *node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlChar * XMLCALL + xmlGetNsProp (const xmlNode *node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlNodePtr XMLCALL + xmlStringGetNodeList (const xmlDoc *doc, + const xmlChar *value); +XMLPUBFUN xmlNodePtr XMLCALL + xmlStringLenGetNodeList (const xmlDoc *doc, + const xmlChar *value, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeListGetString (xmlDocPtr doc, + const xmlNode *list, + int inLine); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlChar * XMLCALL + xmlNodeListGetRawString (const xmlDoc *doc, + const xmlNode *list, + int inLine); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNodeSetContent (xmlNodePtr cur, + const xmlChar *content); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNodeAddContent (xmlNodePtr cur, + const xmlChar *content); +XMLPUBFUN void XMLCALL + xmlNodeAddContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetContent (const xmlNode *cur); + +XMLPUBFUN int XMLCALL + xmlNodeBufGetContent (xmlBufferPtr buffer, + const xmlNode *cur); +XMLPUBFUN int XMLCALL + xmlBufGetNodeContent (xmlBufPtr buf, + const xmlNode *cur); + +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetLang (const xmlNode *cur); +XMLPUBFUN int XMLCALL + xmlNodeGetSpacePreserve (const xmlNode *cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetLang (xmlNodePtr cur, + const xmlChar *lang); +XMLPUBFUN void XMLCALL + xmlNodeSetSpacePreserve (xmlNodePtr cur, + int val); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetBase (const xmlDoc *doc, + const xmlNode *cur); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) +XMLPUBFUN void XMLCALL + xmlNodeSetBase (xmlNodePtr cur, + const xmlChar *uri); +#endif + +/* + * Removing content. + */ +XMLPUBFUN int XMLCALL + xmlRemoveProp (xmlAttrPtr cur); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN int XMLCALL + xmlUnsetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlUnsetProp (xmlNodePtr node, + const xmlChar *name); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ + +/* + * Internal, don't use. + */ +XMLPUBFUN void XMLCALL + xmlBufferWriteCHAR (xmlBufferPtr buf, + const xmlChar *string); +XMLPUBFUN void XMLCALL + xmlBufferWriteChar (xmlBufferPtr buf, + const char *string); +XMLPUBFUN void XMLCALL + xmlBufferWriteQuotedString(xmlBufferPtr buf, + const xmlChar *string); + +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf, + xmlDocPtr doc, + xmlAttrPtr attr, + const xmlChar *string); +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef LIBXML_TREE_ENABLED +/* + * Namespace handling. + */ +XMLPUBFUN int XMLCALL + xmlReconciliateNs (xmlDocPtr doc, + xmlNodePtr tree); +#endif + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Saving. + */ +XMLPUBFUN void XMLCALL + xmlDocDumpFormatMemory (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN void XMLCALL + xmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void XMLCALL + xmlDocDumpMemoryEnc (xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding); +XMLPUBFUN void XMLCALL + xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding, + int format); +XMLPUBFUN int XMLCALL + xmlDocFormatDump (FILE *f, + xmlDocPtr cur, + int format); +XMLPUBFUN int XMLCALL + xmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN void XMLCALL + xmlElemDump (FILE *f, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + xmlSaveFormatFile (const char *filename, + xmlDocPtr cur, + int format); +XMLPUBFUN size_t XMLCALL + xmlBufNodeDump (xmlBufPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format); +XMLPUBFUN int XMLCALL + xmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format); + +XMLPUBFUN int XMLCALL + xmlSaveFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int XMLCALL + xmlSaveFormatFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + xmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format, + const char *encoding); + +XMLPUBFUN int XMLCALL + xmlSaveFormatFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN int XMLCALL + xmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * XHTML + */ +XMLPUBFUN int XMLCALL + xmlIsXHTML (const xmlChar *systemID, + const xmlChar *publicID); + +/* + * Compression. + */ +XMLPUBFUN int XMLCALL + xmlGetDocCompressMode (const xmlDoc *doc); +XMLPUBFUN void XMLCALL + xmlSetDocCompressMode (xmlDocPtr doc, + int mode); +XMLPUBFUN int XMLCALL + xmlGetCompressMode (void); +XMLPUBFUN void XMLCALL + xmlSetCompressMode (int mode); + +/* +* DOM-wrapper helper functions. +*/ +XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL + xmlDOMWrapNewCtxt (void); +XMLPUBFUN void XMLCALL + xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr elem, + int options); +XMLPUBFUN int XMLCALL + xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int options); +XMLPUBFUN int XMLCALL + xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr node, + int options); +XMLPUBFUN int XMLCALL + xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlNodePtr *clonedNode, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int deep, + int options); + +#ifdef LIBXML_TREE_ENABLED +/* + * 5 interfaces from DOM ElementTraversal, but different in entities + * traversal. + */ +XMLPUBFUN unsigned long XMLCALL + xmlChildElementCount (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNextElementSibling (xmlNodePtr node); +XMLPUBFUN xmlNodePtr XMLCALL + xmlFirstElementChild (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr XMLCALL + xmlLastElementChild (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr XMLCALL + xmlPreviousElementSibling (xmlNodePtr node); +#endif +#ifdef __cplusplus +} +#endif +#ifndef __XML_PARSER_H__ +#include +#endif + +#endif /* __XML_TREE_H__ */ + diff --git a/src/include/libxml/uri.h b/src/include/libxml/uri.h new file mode 100644 index 000000000000..db48262b136f --- /dev/null +++ b/src/include/libxml/uri.h @@ -0,0 +1,94 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_URI_H__ +#define __XML_URI_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlURI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + * + * Note: query is a deprecated field which is incorrectly unescaped. + * query_raw takes precedence over query if the former is set. + * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127 + */ +typedef struct _xmlURI xmlURI; +typedef xmlURI *xmlURIPtr; +struct _xmlURI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *query; /* the query string (deprecated - use with caution) */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ + char *query_raw; /* the query string (as it appears in the URI) */ +}; + +/* + * This function is in tree.h: + * xmlChar * xmlNodeGetBase (xmlDocPtr doc, + * xmlNodePtr cur); + */ +XMLPUBFUN xmlURIPtr XMLCALL + xmlCreateURI (void); +XMLPUBFUN xmlChar * XMLCALL + xmlBuildURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlChar * XMLCALL + xmlBuildRelativeURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlURIPtr XMLCALL + xmlParseURI (const char *str); +XMLPUBFUN xmlURIPtr XMLCALL + xmlParseURIRaw (const char *str, + int raw); +XMLPUBFUN int XMLCALL + xmlParseURIReference (xmlURIPtr uri, + const char *str); +XMLPUBFUN xmlChar * XMLCALL + xmlSaveUri (xmlURIPtr uri); +XMLPUBFUN void XMLCALL + xmlPrintURI (FILE *stream, + xmlURIPtr uri); +XMLPUBFUN xmlChar * XMLCALL + xmlURIEscapeStr (const xmlChar *str, + const xmlChar *list); +XMLPUBFUN char * XMLCALL + xmlURIUnescapeString (const char *str, + int len, + char *target); +XMLPUBFUN int XMLCALL + xmlNormalizeURIPath (char *path); +XMLPUBFUN xmlChar * XMLCALL + xmlURIEscape (const xmlChar *str); +XMLPUBFUN void XMLCALL + xmlFreeURI (xmlURIPtr uri); +XMLPUBFUN xmlChar* XMLCALL + xmlCanonicPath (const xmlChar *path); +XMLPUBFUN xmlChar* XMLCALL + xmlPathToURI (const xmlChar *path); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_URI_H__ */ diff --git a/src/include/libxml/valid.h b/src/include/libxml/valid.h new file mode 100644 index 000000000000..2bc7b380c1ed --- /dev/null +++ b/src/include/libxml/valid.h @@ -0,0 +1,458 @@ +/* + * Summary: The DTD validation + * Description: API for the DTD handling and the validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_VALID_H__ +#define __XML_VALID_H__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Validation state added for non-determinist content model. + */ +typedef struct _xmlValidState xmlValidState; +typedef xmlValidState *xmlValidStatePtr; + +/** + * xmlValidityErrorFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity error is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * xmlValidityWarningFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity warning is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); + +#ifdef IN_LIBXML +/** + * XML_CTXT_FINISH_DTD_0: + * + * Special value for finishDtd field when embedded in an xmlParserCtxt + */ +#define XML_CTXT_FINISH_DTD_0 0xabcd1234 +/** + * XML_CTXT_FINISH_DTD_1: + * + * Special value for finishDtd field when embedded in an xmlParserCtxt + */ +#define XML_CTXT_FINISH_DTD_1 0xabcd1235 +#endif + +/* + * xmlValidCtxt: + * An xmlValidCtxt is used for error reporting when validating. + */ +typedef struct _xmlValidCtxt xmlValidCtxt; +typedef xmlValidCtxt *xmlValidCtxtPtr; +struct _xmlValidCtxt { + void *userData; /* user specific data block */ + xmlValidityErrorFunc error; /* the callback in case of errors */ + xmlValidityWarningFunc warning; /* the callback in case of warning */ + + /* Node analysis stack used when validating within entities */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + unsigned int finishDtd; /* finished validating the Dtd ? */ + xmlDocPtr doc; /* the document */ + int valid; /* temporary validity check result */ + + /* state state used for non-determinist content validation */ + xmlValidState *vstate; /* current state */ + int vstateNr; /* Depth of the validation stack */ + int vstateMax; /* Max depth of the validation stack */ + xmlValidState *vstateTab; /* array of validation states */ + +#ifdef LIBXML_REGEXP_ENABLED + xmlAutomataPtr am; /* the automata */ + xmlAutomataStatePtr state; /* used to build the automata */ +#else + void *am; + void *state; +#endif +}; + +/* + * ALL notation declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlNotationTable; +typedef xmlNotationTable *xmlNotationTablePtr; + +/* + * ALL element declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlElementTable; +typedef xmlElementTable *xmlElementTablePtr; + +/* + * ALL attribute declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlAttributeTable; +typedef xmlAttributeTable *xmlAttributeTablePtr; + +/* + * ALL IDs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlIDTable; +typedef xmlIDTable *xmlIDTablePtr; + +/* + * ALL Refs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlRefTable; +typedef xmlRefTable *xmlRefTablePtr; + +/* Notation */ +XMLPUBFUN xmlNotationPtr XMLCALL + xmlAddNotationDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *PublicID, + const xmlChar *SystemID); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNotationTablePtr XMLCALL + xmlCopyNotationTable (xmlNotationTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeNotationTable (xmlNotationTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpNotationDecl (xmlBufferPtr buf, + xmlNotationPtr nota); +XMLPUBFUN void XMLCALL + xmlDumpNotationTable (xmlBufferPtr buf, + xmlNotationTablePtr table); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Element Content */ +/* the non Doc version are being deprecated */ +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlNewElementContent (const xmlChar *name, + xmlElementContentType type); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlCopyElementContent (xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlFreeElementContent (xmlElementContentPtr cur); +/* the new versions with doc argument */ +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlNewDocElementContent (xmlDocPtr doc, + const xmlChar *name, + xmlElementContentType type); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlCopyDocElementContent(xmlDocPtr doc, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlFreeDocElementContent(xmlDocPtr doc, + xmlElementContentPtr cur); +XMLPUBFUN void XMLCALL + xmlSnprintfElementContent(char *buf, + int size, + xmlElementContentPtr content, + int englob); +#ifdef LIBXML_OUTPUT_ENABLED +/* DEPRECATED */ +XMLPUBFUN void XMLCALL + xmlSprintfElementContent(char *buf, + xmlElementContentPtr content, + int englob); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* DEPRECATED */ + +/* Element */ +XMLPUBFUN xmlElementPtr XMLCALL + xmlAddElementDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + xmlElementTypeVal type, + xmlElementContentPtr content); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlElementTablePtr XMLCALL + xmlCopyElementTable (xmlElementTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeElementTable (xmlElementTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpElementTable (xmlBufferPtr buf, + xmlElementTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpElementDecl (xmlBufferPtr buf, + xmlElementPtr elem); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Enumeration */ +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlCreateEnumeration (const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlFreeEnumeration (xmlEnumerationPtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlCopyEnumeration (xmlEnumerationPtr cur); +#endif /* LIBXML_TREE_ENABLED */ + +/* Attribute */ +XMLPUBFUN xmlAttributePtr XMLCALL + xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *ns, + xmlAttributeType type, + xmlAttributeDefault def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlAttributeTablePtr XMLCALL + xmlCopyAttributeTable (xmlAttributeTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeAttributeTable (xmlAttributeTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpAttributeTable (xmlBufferPtr buf, + xmlAttributeTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpAttributeDecl (xmlBufferPtr buf, + xmlAttributePtr attr); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* IDs */ +XMLPUBFUN xmlIDPtr XMLCALL + xmlAddID (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void XMLCALL + xmlFreeIDTable (xmlIDTablePtr table); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlGetID (xmlDocPtr doc, + const xmlChar *ID); +XMLPUBFUN int XMLCALL + xmlIsID (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int XMLCALL + xmlRemoveID (xmlDocPtr doc, + xmlAttrPtr attr); + +/* IDREFs */ +XMLPUBFUN xmlRefPtr XMLCALL + xmlAddRef (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void XMLCALL + xmlFreeRefTable (xmlRefTablePtr table); +XMLPUBFUN int XMLCALL + xmlIsRef (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int XMLCALL + xmlRemoveRef (xmlDocPtr doc, + xmlAttrPtr attr); +XMLPUBFUN xmlListPtr XMLCALL + xmlGetRefs (xmlDocPtr doc, + const xmlChar *ID); + +/** + * The public function calls related to validity checking. + */ +#ifdef LIBXML_VALID_ENABLED +/* Allocate/Release Validation Contexts */ +XMLPUBFUN xmlValidCtxtPtr XMLCALL + xmlNewValidCtxt(void); +XMLPUBFUN void XMLCALL + xmlFreeValidCtxt(xmlValidCtxtPtr); + +XMLPUBFUN int XMLCALL + xmlValidateRoot (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateElementDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlElementPtr elem); +XMLPUBFUN xmlChar * XMLCALL + xmlValidNormalizeAttributeValue(xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlAttributePtr attr); +XMLPUBFUN int XMLCALL + xmlValidateAttributeValue(xmlAttributeType type, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNotationPtr nota); +XMLPUBFUN int XMLCALL + xmlValidateDtd (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlDtdPtr dtd); +XMLPUBFUN int XMLCALL + xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateDocument (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlValidateOneElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *prefix, + xmlNsPtr ns, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +#endif /* LIBXML_VALID_ENABLED */ + +#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN int XMLCALL + xmlValidateNotationUse (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *notationName); +#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */ + +XMLPUBFUN int XMLCALL + xmlIsMixedElement (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr XMLCALL + xmlGetDtdAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr XMLCALL + xmlGetDtdQAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlNotationPtr XMLCALL + xmlGetDtdNotationDesc (xmlDtdPtr dtd, + const xmlChar *name); +XMLPUBFUN xmlElementPtr XMLCALL + xmlGetDtdQElementDesc (xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlElementPtr XMLCALL + xmlGetDtdElementDesc (xmlDtdPtr dtd, + const xmlChar *name); + +#ifdef LIBXML_VALID_ENABLED + +XMLPUBFUN int XMLCALL + xmlValidGetPotentialChildren(xmlElementContent *ctree, + const xmlChar **names, + int *len, + int max); + +XMLPUBFUN int XMLCALL + xmlValidGetValidElements(xmlNode *prev, + xmlNode *next, + const xmlChar **names, + int max); +XMLPUBFUN int XMLCALL + xmlValidateNameValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNamesValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNmtokenValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNmtokensValue(const xmlChar *value); + +#ifdef LIBXML_REGEXP_ENABLED +/* + * Validation based on the regexp support + */ +XMLPUBFUN int XMLCALL + xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, + xmlElementPtr elem); + +XMLPUBFUN int XMLCALL + xmlValidatePushElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +XMLPUBFUN int XMLCALL + xmlValidatePushCData (xmlValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int XMLCALL + xmlValidatePopElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +#endif /* LIBXML_REGEXP_ENABLED */ +#endif /* LIBXML_VALID_ENABLED */ +#ifdef __cplusplus +} +#endif +#endif /* __XML_VALID_H__ */ diff --git a/src/include/libxml/xinclude.h b/src/include/libxml/xinclude.h new file mode 100644 index 000000000000..863ab25ad9fe --- /dev/null +++ b/src/include/libxml/xinclude.h @@ -0,0 +1,129 @@ +/* + * Summary: implementation of XInclude + * Description: API to handle XInclude processing, + * implements the + * World Wide Web Consortium Last Call Working Draft 10 November 2003 + * http://www.w3.org/TR/2003/WD-xinclude-20031110 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XINCLUDE_H__ +#define __XML_XINCLUDE_H__ + +#include +#include + +#ifdef LIBXML_XINCLUDE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XINCLUDE_NS: + * + * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude + */ +#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2003/XInclude" +/** + * XINCLUDE_OLD_NS: + * + * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude + */ +#define XINCLUDE_OLD_NS (const xmlChar *) "http://www.w3.org/2001/XInclude" +/** + * XINCLUDE_NODE: + * + * Macro defining "include" + */ +#define XINCLUDE_NODE (const xmlChar *) "include" +/** + * XINCLUDE_FALLBACK: + * + * Macro defining "fallback" + */ +#define XINCLUDE_FALLBACK (const xmlChar *) "fallback" +/** + * XINCLUDE_HREF: + * + * Macro defining "href" + */ +#define XINCLUDE_HREF (const xmlChar *) "href" +/** + * XINCLUDE_PARSE: + * + * Macro defining "parse" + */ +#define XINCLUDE_PARSE (const xmlChar *) "parse" +/** + * XINCLUDE_PARSE_XML: + * + * Macro defining "xml" + */ +#define XINCLUDE_PARSE_XML (const xmlChar *) "xml" +/** + * XINCLUDE_PARSE_TEXT: + * + * Macro defining "text" + */ +#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" +/** + * XINCLUDE_PARSE_ENCODING: + * + * Macro defining "encoding" + */ +#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding" +/** + * XINCLUDE_PARSE_XPOINTER: + * + * Macro defining "xpointer" + */ +#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) "xpointer" + +typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt; +typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr; + +/* + * standalone processing + */ +XMLPUBFUN int XMLCALL + xmlXIncludeProcess (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessFlags (xmlDocPtr doc, + int flags); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessFlagsData(xmlDocPtr doc, + int flags, + void *data); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, + int flags, + void *data); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTree (xmlNodePtr tree); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTreeFlags(xmlNodePtr tree, + int flags); +/* + * contextual processing + */ +XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL + xmlXIncludeNewContext (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt, + int flags); +XMLPUBFUN void XMLCALL + xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt, + xmlNodePtr tree); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XINCLUDE_ENABLED */ + +#endif /* __XML_XINCLUDE_H__ */ diff --git a/src/include/libxml/xlink.h b/src/include/libxml/xlink.h new file mode 100644 index 000000000000..04e4b32c015f --- /dev/null +++ b/src/include/libxml/xlink.h @@ -0,0 +1,189 @@ +/* + * Summary: unfinished XLink detection module + * Description: unfinished XLink detection module + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XLINK_H__ +#define __XML_XLINK_H__ + +#include +#include + +#ifdef LIBXML_XPTR_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Various defines for the various Link properties. + * + * NOTE: the link detection layer will try to resolve QName expansion + * of namespaces. If "foo" is the prefix for "http://foo.com/" + * then the link detection layer will expand role="foo:myrole" + * to "http://foo.com/:myrole". + * NOTE: the link detection layer will expand URI-References found on + * href attributes by using the base mechanism if found. + */ +typedef xmlChar *xlinkHRef; +typedef xmlChar *xlinkRole; +typedef xmlChar *xlinkTitle; + +typedef enum { + XLINK_TYPE_NONE = 0, + XLINK_TYPE_SIMPLE, + XLINK_TYPE_EXTENDED, + XLINK_TYPE_EXTENDED_SET +} xlinkType; + +typedef enum { + XLINK_SHOW_NONE = 0, + XLINK_SHOW_NEW, + XLINK_SHOW_EMBED, + XLINK_SHOW_REPLACE +} xlinkShow; + +typedef enum { + XLINK_ACTUATE_NONE = 0, + XLINK_ACTUATE_AUTO, + XLINK_ACTUATE_ONREQUEST +} xlinkActuate; + +/** + * xlinkNodeDetectFunc: + * @ctx: user data pointer + * @node: the node to check + * + * This is the prototype for the link detection routine. + * It calls the default link detection callbacks upon link detection. + */ +typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node); + +/* + * The link detection module interact with the upper layers using + * a set of callback registered at parsing time. + */ + +/** + * xlinkSimpleLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @href: the target of the link + * @role: the role string + * @title: the link title + * + * This is the prototype for a simple link detection callback. + */ +typedef void +(*xlinkSimpleLinkFunk) (void *ctx, + xmlNodePtr node, + const xlinkHRef href, + const xlinkRole role, + const xlinkTitle title); + +/** + * xlinkExtendedLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbArcs: the number of arcs detected on the link + * @from: pointer to the array of source roles found on the arcs + * @to: pointer to the array of target roles found on the arcs + * @show: array of values for the show attributes found on the arcs + * @actuate: array of values for the actuate attributes found on the arcs + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link detection callback. + */ +typedef void +(*xlinkExtendedLinkFunk)(void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbArcs, + const xlinkRole *from, + const xlinkRole *to, + xlinkShow *show, + xlinkActuate *actuate, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * xlinkExtendedLinkSetFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link set detection callback. + */ +typedef void +(*xlinkExtendedLinkSetFunk) (void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * This is the structure containing a set of Links detection callbacks. + * + * There is no default xlink callbacks, if one want to get link + * recognition activated, those call backs must be provided before parsing. + */ +typedef struct _xlinkHandler xlinkHandler; +typedef xlinkHandler *xlinkHandlerPtr; +struct _xlinkHandler { + xlinkSimpleLinkFunk simple; + xlinkExtendedLinkFunk extended; + xlinkExtendedLinkSetFunk set; +}; + +/* + * The default detection routine, can be overridden, they call the default + * detection callbacks. + */ + +XMLPUBFUN xlinkNodeDetectFunc XMLCALL + xlinkGetDefaultDetect (void); +XMLPUBFUN void XMLCALL + xlinkSetDefaultDetect (xlinkNodeDetectFunc func); + +/* + * Routines to set/get the default handlers. + */ +XMLPUBFUN xlinkHandlerPtr XMLCALL + xlinkGetDefaultHandler (void); +XMLPUBFUN void XMLCALL + xlinkSetDefaultHandler (xlinkHandlerPtr handler); + +/* + * Link detection module itself. + */ +XMLPUBFUN xlinkType XMLCALL + xlinkIsLink (xmlDocPtr doc, + xmlNodePtr node); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ + +#endif /* __XML_XLINK_H__ */ diff --git a/src/include/libxml/xmlIO.h b/src/include/libxml/xmlIO.h new file mode 100644 index 000000000000..095b2f56d96c --- /dev/null +++ b/src/include/libxml/xmlIO.h @@ -0,0 +1,368 @@ +/* + * Summary: interface for the I/O interfaces used by the parser + * Description: interface for the I/O interfaces used by the parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_IO_H__ +#define __XML_IO_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Those are the functions and datatypes for the parser input + * I/O structures. + */ + +/** + * xmlInputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to detect if the current handler + * can provide input functionality for this resource. + * + * Returns 1 if yes and 0 if another Input module should be used + */ +typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename); +/** + * xmlInputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to open the resource + * + * Returns an Input context or NULL in case or error + */ +typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename); +/** + * xmlInputReadCallback: + * @context: an Input context + * @buffer: the buffer to store data read + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Input API to read the resource + * + * Returns the number of bytes read or -1 in case of error + */ +typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len); +/** + * xmlInputCloseCallback: + * @context: an Input context + * + * Callback used in the I/O Input API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (XMLCALL *xmlInputCloseCallback) (void * context); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Those are the functions and datatypes for the library output + * I/O structures. + */ + +/** + * xmlOutputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to detect if the current handler + * can provide output functionality for this resource. + * + * Returns 1 if yes and 0 if another Output module should be used + */ +typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename); +/** + * xmlOutputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to open the resource + * + * Returns an Output context or NULL in case or error + */ +typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename); +/** + * xmlOutputWriteCallback: + * @context: an Output context + * @buffer: the buffer of data to write + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Output API to write to the resource + * + * Returns the number of bytes written or -1 in case of error + */ +typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer, + int len); +/** + * xmlOutputCloseCallback: + * @context: an Output context + * + * Callback used in the I/O Output API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (XMLCALL *xmlOutputCloseCallback) (void * context); +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +struct _xmlParserInputBuffer { + void* context; + xmlInputReadCallback readcallback; + xmlInputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */ + xmlBufPtr raw; /* if encoder != NULL buffer for raw input */ + int compressed; /* -1=unknown, 0=not compressed, 1=compressed */ + int error; + unsigned long rawconsumed;/* amount consumed from raw */ +}; + + +#ifdef LIBXML_OUTPUT_ENABLED +struct _xmlOutputBuffer { + void* context; + xmlOutputWriteCallback writecallback; + xmlOutputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ + xmlBufPtr conv; /* if encoder != NULL buffer for output */ + int written; /* total number of byte written */ + int error; +}; +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* + * Interfaces for input + */ +XMLPUBFUN void XMLCALL + xmlCleanupInputCallbacks (void); + +XMLPUBFUN int XMLCALL + xmlPopInputCallbacks (void); + +XMLPUBFUN void XMLCALL + xmlRegisterDefaultInputCallbacks (void); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlAllocParserInputBuffer (xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFilename (const char *URI, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFile (FILE *file, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFd (int fd, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateMem (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateStatic (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlParserInputBufferRead (xmlParserInputBufferPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputBufferGrow (xmlParserInputBufferPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputBufferPush (xmlParserInputBufferPtr in, + int len, + const char *buf); +XMLPUBFUN void XMLCALL + xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); +XMLPUBFUN char * XMLCALL + xmlParserGetDirectory (const char *filename); + +XMLPUBFUN int XMLCALL + xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, + xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc); + +xmlParserInputBufferPtr + __xmlParserInputBufferCreateFilename(const char *URI, + xmlCharEncoding enc); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Interfaces for output + */ +XMLPUBFUN void XMLCALL + xmlCleanupOutputCallbacks (void); +XMLPUBFUN int XMLCALL + xmlPopOutputCallbacks (void); +XMLPUBFUN void XMLCALL + xmlRegisterDefaultOutputCallbacks(void); +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFilename (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFile (FILE *file, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateBuffer (xmlBufferPtr buffer, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFd (int fd, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + xmlCharEncodingHandlerPtr encoder); + +/* Couple of APIs to get the output without digging into the buffers */ +XMLPUBFUN const xmlChar * XMLCALL + xmlOutputBufferGetContent (xmlOutputBufferPtr out); +XMLPUBFUN size_t XMLCALL + xmlOutputBufferGetSize (xmlOutputBufferPtr out); + +XMLPUBFUN int XMLCALL + xmlOutputBufferWrite (xmlOutputBufferPtr out, + int len, + const char *buf); +XMLPUBFUN int XMLCALL + xmlOutputBufferWriteString (xmlOutputBufferPtr out, + const char *str); +XMLPUBFUN int XMLCALL + xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, + const xmlChar *str, + xmlCharEncodingOutputFunc escaping); + +XMLPUBFUN int XMLCALL + xmlOutputBufferFlush (xmlOutputBufferPtr out); +XMLPUBFUN int XMLCALL + xmlOutputBufferClose (xmlOutputBufferPtr out); + +XMLPUBFUN int XMLCALL + xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, + xmlOutputOpenCallback openFunc, + xmlOutputWriteCallback writeFunc, + xmlOutputCloseCallback closeFunc); + +xmlOutputBufferPtr + __xmlOutputBufferCreateFilename(const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +#ifdef LIBXML_HTTP_ENABLED +/* This function only exists if HTTP support built into the library */ +XMLPUBFUN void XMLCALL + xmlRegisterHTTPPostCallbacks (void ); +#endif /* LIBXML_HTTP_ENABLED */ + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr ret); + +/* + * A predefined entity loader disabling network accesses + */ +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNoNetExternalEntityLoader (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +/* + * xmlNormalizeWindowsPath is obsolete, don't use it. + * Check xmlCanonicPath in uri.h for a better alternative. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlNormalizeWindowsPath (const xmlChar *path); + +XMLPUBFUN int XMLCALL + xmlCheckFilename (const char *path); +/** + * Default 'file://' protocol callbacks + */ +XMLPUBFUN int XMLCALL + xmlFileMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlFileOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlFileRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlFileClose (void * context); + +/** + * Default 'http://' protocol callbacks + */ +#ifdef LIBXML_HTTP_ENABLED +XMLPUBFUN int XMLCALL + xmlIOHTTPMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlIOHTTPOpen (const char *filename); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void * XMLCALL + xmlIOHTTPOpenW (const char * post_uri, + int compression ); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN int XMLCALL + xmlIOHTTPRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlIOHTTPClose (void * context); +#endif /* LIBXML_HTTP_ENABLED */ + +/** + * Default 'ftp://' protocol callbacks + */ +#ifdef LIBXML_FTP_ENABLED +XMLPUBFUN int XMLCALL + xmlIOFTPMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlIOFTPOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlIOFTPRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlIOFTPClose (void * context); +#endif /* LIBXML_FTP_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_IO_H__ */ diff --git a/src/include/libxml/xmlautomata.h b/src/include/libxml/xmlautomata.h new file mode 100644 index 000000000000..bf1b131c6534 --- /dev/null +++ b/src/include/libxml/xmlautomata.h @@ -0,0 +1,146 @@ +/* + * Summary: API to build regexp automata + * Description: the API to build regexp automata + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_AUTOMATA_H__ +#define __XML_AUTOMATA_H__ + +#include +#include + +#ifdef LIBXML_REGEXP_ENABLED +#ifdef LIBXML_AUTOMATA_ENABLED +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlAutomataPtr: + * + * A libxml automata description, It can be compiled into a regexp + */ +typedef struct _xmlAutomata xmlAutomata; +typedef xmlAutomata *xmlAutomataPtr; + +/** + * xmlAutomataStatePtr: + * + * A state int the automata description, + */ +typedef struct _xmlAutomataState xmlAutomataState; +typedef xmlAutomataState *xmlAutomataStatePtr; + +/* + * Building API + */ +XMLPUBFUN xmlAutomataPtr XMLCALL + xmlNewAutomata (void); +XMLPUBFUN void XMLCALL + xmlFreeAutomata (xmlAutomataPtr am); + +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataGetInitState (xmlAutomataPtr am); +XMLPUBFUN int XMLCALL + xmlAutomataSetFinalState (xmlAutomataPtr am, + xmlAutomataStatePtr state); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewState (xmlAutomataPtr am); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewTransition (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewTransition2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewNegTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); + +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewOnceTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewOnceTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewAllTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int lax); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewEpsilon (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountedTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCounterTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XMLPUBFUN int XMLCALL + xmlAutomataNewCounter (xmlAutomataPtr am, + int min, + int max); + +XMLPUBFUN xmlRegexpPtr XMLCALL + xmlAutomataCompile (xmlAutomataPtr am); +XMLPUBFUN int XMLCALL + xmlAutomataIsDeterminist (xmlAutomataPtr am); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_AUTOMATA_ENABLED */ +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /* __XML_AUTOMATA_H__ */ diff --git a/src/include/libxml/xmlerror.h b/src/include/libxml/xmlerror.h new file mode 100644 index 000000000000..c1019971f247 --- /dev/null +++ b/src/include/libxml/xmlerror.h @@ -0,0 +1,945 @@ +/* + * Summary: error handling + * Description: the API used to report errors + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#include + +#ifndef __XML_ERROR_H__ +#define __XML_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlErrorLevel: + * + * Indicates the level of an error + */ +typedef enum { + XML_ERR_NONE = 0, + XML_ERR_WARNING = 1, /* A simple warning */ + XML_ERR_ERROR = 2, /* A recoverable error */ + XML_ERR_FATAL = 3 /* A fatal error */ +} xmlErrorLevel; + +/** + * xmlErrorDomain: + * + * Indicates where an error may have come from + */ +typedef enum { + XML_FROM_NONE = 0, + XML_FROM_PARSER, /* The XML parser */ + XML_FROM_TREE, /* The tree module */ + XML_FROM_NAMESPACE, /* The XML Namespace module */ + XML_FROM_DTD, /* The XML DTD validation with parser context*/ + XML_FROM_HTML, /* The HTML parser */ + XML_FROM_MEMORY, /* The memory allocator */ + XML_FROM_OUTPUT, /* The serialization code */ + XML_FROM_IO, /* The Input/Output stack */ + XML_FROM_FTP, /* The FTP module */ + XML_FROM_HTTP, /* The HTTP module */ + XML_FROM_XINCLUDE, /* The XInclude processing */ + XML_FROM_XPATH, /* The XPath module */ + XML_FROM_XPOINTER, /* The XPointer module */ + XML_FROM_REGEXP, /* The regular expressions module */ + XML_FROM_DATATYPE, /* The W3C XML Schemas Datatype module */ + XML_FROM_SCHEMASP, /* The W3C XML Schemas parser module */ + XML_FROM_SCHEMASV, /* The W3C XML Schemas validation module */ + XML_FROM_RELAXNGP, /* The Relax-NG parser module */ + XML_FROM_RELAXNGV, /* The Relax-NG validator module */ + XML_FROM_CATALOG, /* The Catalog module */ + XML_FROM_C14N, /* The Canonicalization module */ + XML_FROM_XSLT, /* The XSLT engine from libxslt */ + XML_FROM_VALID, /* The XML DTD validation with valid context */ + XML_FROM_CHECK, /* The error checking module */ + XML_FROM_WRITER, /* The xmlwriter module */ + XML_FROM_MODULE, /* The dynamically loaded module module*/ + XML_FROM_I18N, /* The module handling character conversion */ + XML_FROM_SCHEMATRONV,/* The Schematron validator module */ + XML_FROM_BUFFER, /* The buffers module */ + XML_FROM_URI /* The URI module */ +} xmlErrorDomain; + +/** + * xmlError: + * + * An XML Error instance. + */ + +typedef struct _xmlError xmlError; +typedef xmlError *xmlErrorPtr; +struct _xmlError { + int domain; /* What part of the library raised this error */ + int code; /* The error code, e.g. an xmlParserError */ + char *message;/* human-readable informative error message */ + xmlErrorLevel level;/* how consequent is the error */ + char *file; /* the filename */ + int line; /* the line number if available */ + char *str1; /* extra string information */ + char *str2; /* extra string information */ + char *str3; /* extra string information */ + int int1; /* extra number information */ + int int2; /* error column # or 0 if N/A (todo: rename field when we would brk ABI) */ + void *ctxt; /* the parser context if available */ + void *node; /* the node in the tree */ +}; + +/** + * xmlParserError: + * + * This is an error that the XML (or HTML) parser can generate + */ +typedef enum { + XML_ERR_OK = 0, + XML_ERR_INTERNAL_ERROR, /* 1 */ + XML_ERR_NO_MEMORY, /* 2 */ + XML_ERR_DOCUMENT_START, /* 3 */ + XML_ERR_DOCUMENT_EMPTY, /* 4 */ + XML_ERR_DOCUMENT_END, /* 5 */ + XML_ERR_INVALID_HEX_CHARREF, /* 6 */ + XML_ERR_INVALID_DEC_CHARREF, /* 7 */ + XML_ERR_INVALID_CHARREF, /* 8 */ + XML_ERR_INVALID_CHAR, /* 9 */ + XML_ERR_CHARREF_AT_EOF, /* 10 */ + XML_ERR_CHARREF_IN_PROLOG, /* 11 */ + XML_ERR_CHARREF_IN_EPILOG, /* 12 */ + XML_ERR_CHARREF_IN_DTD, /* 13 */ + XML_ERR_ENTITYREF_AT_EOF, /* 14 */ + XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */ + XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */ + XML_ERR_ENTITYREF_IN_DTD, /* 17 */ + XML_ERR_PEREF_AT_EOF, /* 18 */ + XML_ERR_PEREF_IN_PROLOG, /* 19 */ + XML_ERR_PEREF_IN_EPILOG, /* 20 */ + XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */ + XML_ERR_ENTITYREF_NO_NAME, /* 22 */ + XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */ + XML_ERR_PEREF_NO_NAME, /* 24 */ + XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */ + XML_ERR_UNDECLARED_ENTITY, /* 26 */ + XML_WAR_UNDECLARED_ENTITY, /* 27 */ + XML_ERR_UNPARSED_ENTITY, /* 28 */ + XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */ + XML_ERR_ENTITY_IS_PARAMETER, /* 30 */ + XML_ERR_UNKNOWN_ENCODING, /* 31 */ + XML_ERR_UNSUPPORTED_ENCODING, /* 32 */ + XML_ERR_STRING_NOT_STARTED, /* 33 */ + XML_ERR_STRING_NOT_CLOSED, /* 34 */ + XML_ERR_NS_DECL_ERROR, /* 35 */ + XML_ERR_ENTITY_NOT_STARTED, /* 36 */ + XML_ERR_ENTITY_NOT_FINISHED, /* 37 */ + XML_ERR_LT_IN_ATTRIBUTE, /* 38 */ + XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */ + XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */ + XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */ + XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */ + XML_ERR_LITERAL_NOT_STARTED, /* 43 */ + XML_ERR_LITERAL_NOT_FINISHED, /* 44 */ + XML_ERR_COMMENT_NOT_FINISHED, /* 45 */ + XML_ERR_PI_NOT_STARTED, /* 46 */ + XML_ERR_PI_NOT_FINISHED, /* 47 */ + XML_ERR_NOTATION_NOT_STARTED, /* 48 */ + XML_ERR_NOTATION_NOT_FINISHED, /* 49 */ + XML_ERR_ATTLIST_NOT_STARTED, /* 50 */ + XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */ + XML_ERR_MIXED_NOT_STARTED, /* 52 */ + XML_ERR_MIXED_NOT_FINISHED, /* 53 */ + XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */ + XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */ + XML_ERR_XMLDECL_NOT_STARTED, /* 56 */ + XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */ + XML_ERR_CONDSEC_NOT_STARTED, /* 58 */ + XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */ + XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */ + XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */ + XML_ERR_MISPLACED_CDATA_END, /* 62 */ + XML_ERR_CDATA_NOT_FINISHED, /* 63 */ + XML_ERR_RESERVED_XML_NAME, /* 64 */ + XML_ERR_SPACE_REQUIRED, /* 65 */ + XML_ERR_SEPARATOR_REQUIRED, /* 66 */ + XML_ERR_NMTOKEN_REQUIRED, /* 67 */ + XML_ERR_NAME_REQUIRED, /* 68 */ + XML_ERR_PCDATA_REQUIRED, /* 69 */ + XML_ERR_URI_REQUIRED, /* 70 */ + XML_ERR_PUBID_REQUIRED, /* 71 */ + XML_ERR_LT_REQUIRED, /* 72 */ + XML_ERR_GT_REQUIRED, /* 73 */ + XML_ERR_LTSLASH_REQUIRED, /* 74 */ + XML_ERR_EQUAL_REQUIRED, /* 75 */ + XML_ERR_TAG_NAME_MISMATCH, /* 76 */ + XML_ERR_TAG_NOT_FINISHED, /* 77 */ + XML_ERR_STANDALONE_VALUE, /* 78 */ + XML_ERR_ENCODING_NAME, /* 79 */ + XML_ERR_HYPHEN_IN_COMMENT, /* 80 */ + XML_ERR_INVALID_ENCODING, /* 81 */ + XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */ + XML_ERR_CONDSEC_INVALID, /* 83 */ + XML_ERR_VALUE_REQUIRED, /* 84 */ + XML_ERR_NOT_WELL_BALANCED, /* 85 */ + XML_ERR_EXTRA_CONTENT, /* 86 */ + XML_ERR_ENTITY_CHAR_ERROR, /* 87 */ + XML_ERR_ENTITY_PE_INTERNAL, /* 88 */ + XML_ERR_ENTITY_LOOP, /* 89 */ + XML_ERR_ENTITY_BOUNDARY, /* 90 */ + XML_ERR_INVALID_URI, /* 91 */ + XML_ERR_URI_FRAGMENT, /* 92 */ + XML_WAR_CATALOG_PI, /* 93 */ + XML_ERR_NO_DTD, /* 94 */ + XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */ + XML_ERR_VERSION_MISSING, /* 96 */ + XML_WAR_UNKNOWN_VERSION, /* 97 */ + XML_WAR_LANG_VALUE, /* 98 */ + XML_WAR_NS_URI, /* 99 */ + XML_WAR_NS_URI_RELATIVE, /* 100 */ + XML_ERR_MISSING_ENCODING, /* 101 */ + XML_WAR_SPACE_VALUE, /* 102 */ + XML_ERR_NOT_STANDALONE, /* 103 */ + XML_ERR_ENTITY_PROCESSING, /* 104 */ + XML_ERR_NOTATION_PROCESSING, /* 105 */ + XML_WAR_NS_COLUMN, /* 106 */ + XML_WAR_ENTITY_REDEFINED, /* 107 */ + XML_ERR_UNKNOWN_VERSION, /* 108 */ + XML_ERR_VERSION_MISMATCH, /* 109 */ + XML_ERR_NAME_TOO_LONG, /* 110 */ + XML_ERR_USER_STOP, /* 111 */ + XML_NS_ERR_XML_NAMESPACE = 200, + XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */ + XML_NS_ERR_QNAME, /* 202 */ + XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */ + XML_NS_ERR_EMPTY, /* 204 */ + XML_NS_ERR_COLON, /* 205 */ + XML_DTD_ATTRIBUTE_DEFAULT = 500, + XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */ + XML_DTD_ATTRIBUTE_VALUE, /* 502 */ + XML_DTD_CONTENT_ERROR, /* 503 */ + XML_DTD_CONTENT_MODEL, /* 504 */ + XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */ + XML_DTD_DIFFERENT_PREFIX, /* 506 */ + XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */ + XML_DTD_ELEM_NAMESPACE, /* 508 */ + XML_DTD_ELEM_REDEFINED, /* 509 */ + XML_DTD_EMPTY_NOTATION, /* 510 */ + XML_DTD_ENTITY_TYPE, /* 511 */ + XML_DTD_ID_FIXED, /* 512 */ + XML_DTD_ID_REDEFINED, /* 513 */ + XML_DTD_ID_SUBSET, /* 514 */ + XML_DTD_INVALID_CHILD, /* 515 */ + XML_DTD_INVALID_DEFAULT, /* 516 */ + XML_DTD_LOAD_ERROR, /* 517 */ + XML_DTD_MISSING_ATTRIBUTE, /* 518 */ + XML_DTD_MIXED_CORRUPT, /* 519 */ + XML_DTD_MULTIPLE_ID, /* 520 */ + XML_DTD_NO_DOC, /* 521 */ + XML_DTD_NO_DTD, /* 522 */ + XML_DTD_NO_ELEM_NAME, /* 523 */ + XML_DTD_NO_PREFIX, /* 524 */ + XML_DTD_NO_ROOT, /* 525 */ + XML_DTD_NOTATION_REDEFINED, /* 526 */ + XML_DTD_NOTATION_VALUE, /* 527 */ + XML_DTD_NOT_EMPTY, /* 528 */ + XML_DTD_NOT_PCDATA, /* 529 */ + XML_DTD_NOT_STANDALONE, /* 530 */ + XML_DTD_ROOT_NAME, /* 531 */ + XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */ + XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */ + XML_DTD_UNKNOWN_ELEM, /* 534 */ + XML_DTD_UNKNOWN_ENTITY, /* 535 */ + XML_DTD_UNKNOWN_ID, /* 536 */ + XML_DTD_UNKNOWN_NOTATION, /* 537 */ + XML_DTD_STANDALONE_DEFAULTED, /* 538 */ + XML_DTD_XMLID_VALUE, /* 539 */ + XML_DTD_XMLID_TYPE, /* 540 */ + XML_DTD_DUP_TOKEN, /* 541 */ + XML_HTML_STRUCURE_ERROR = 800, + XML_HTML_UNKNOWN_TAG, /* 801 */ + XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000, + XML_RNGP_ATTR_CONFLICT, /* 1001 */ + XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */ + XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */ + XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */ + XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */ + XML_RNGP_CHOICE_CONTENT, /* 1006 */ + XML_RNGP_CHOICE_EMPTY, /* 1007 */ + XML_RNGP_CREATE_FAILURE, /* 1008 */ + XML_RNGP_DATA_CONTENT, /* 1009 */ + XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */ + XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */ + XML_RNGP_DEFINE_EMPTY, /* 1012 */ + XML_RNGP_DEFINE_MISSING, /* 1013 */ + XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */ + XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */ + XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */ + XML_RNGP_ELEMENT_EMPTY, /* 1017 */ + XML_RNGP_ELEMENT_CONTENT, /* 1018 */ + XML_RNGP_ELEMENT_NAME, /* 1019 */ + XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */ + XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */ + XML_RNGP_EMPTY, /* 1022 */ + XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */ + XML_RNGP_EMPTY_CONTENT, /* 1024 */ + XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */ + XML_RNGP_ERROR_TYPE_LIB, /* 1026 */ + XML_RNGP_EXCEPT_EMPTY, /* 1027 */ + XML_RNGP_EXCEPT_MISSING, /* 1028 */ + XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */ + XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */ + XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */ + XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */ + XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */ + XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */ + XML_RNGP_FOREIGN_ELEMENT, /* 1035 */ + XML_RNGP_GRAMMAR_CONTENT, /* 1036 */ + XML_RNGP_GRAMMAR_EMPTY, /* 1037 */ + XML_RNGP_GRAMMAR_MISSING, /* 1038 */ + XML_RNGP_GRAMMAR_NO_START, /* 1039 */ + XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */ + XML_RNGP_HREF_ERROR, /* 1041 */ + XML_RNGP_INCLUDE_EMPTY, /* 1042 */ + XML_RNGP_INCLUDE_FAILURE, /* 1043 */ + XML_RNGP_INCLUDE_RECURSE, /* 1044 */ + XML_RNGP_INTERLEAVE_ADD, /* 1045 */ + XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */ + XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */ + XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */ + XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */ + XML_RNGP_INVALID_URI, /* 1050 */ + XML_RNGP_INVALID_VALUE, /* 1051 */ + XML_RNGP_MISSING_HREF, /* 1052 */ + XML_RNGP_NAME_MISSING, /* 1053 */ + XML_RNGP_NEED_COMBINE, /* 1054 */ + XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */ + XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */ + XML_RNGP_NSNAME_NO_NS, /* 1057 */ + XML_RNGP_PARAM_FORBIDDEN, /* 1058 */ + XML_RNGP_PARAM_NAME_MISSING, /* 1059 */ + XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */ + XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */ + XML_RNGP_PARENTREF_NO_NAME, /* 1062 */ + XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */ + XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */ + XML_RNGP_PARSE_ERROR, /* 1065 */ + XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */ + XML_RNGP_PAT_ATTR_ATTR, /* 1067 */ + XML_RNGP_PAT_ATTR_ELEM, /* 1068 */ + XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */ + XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */ + XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */ + XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */ + XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */ + XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */ + XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */ + XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */ + XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */ + XML_RNGP_PAT_LIST_ATTR, /* 1078 */ + XML_RNGP_PAT_LIST_ELEM, /* 1079 */ + XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */ + XML_RNGP_PAT_LIST_LIST, /* 1081 */ + XML_RNGP_PAT_LIST_REF, /* 1082 */ + XML_RNGP_PAT_LIST_TEXT, /* 1083 */ + XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */ + XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */ + XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */ + XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */ + XML_RNGP_PAT_START_ATTR, /* 1088 */ + XML_RNGP_PAT_START_DATA, /* 1089 */ + XML_RNGP_PAT_START_EMPTY, /* 1090 */ + XML_RNGP_PAT_START_GROUP, /* 1091 */ + XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */ + XML_RNGP_PAT_START_LIST, /* 1093 */ + XML_RNGP_PAT_START_ONEMORE, /* 1094 */ + XML_RNGP_PAT_START_TEXT, /* 1095 */ + XML_RNGP_PAT_START_VALUE, /* 1096 */ + XML_RNGP_PREFIX_UNDEFINED, /* 1097 */ + XML_RNGP_REF_CREATE_FAILED, /* 1098 */ + XML_RNGP_REF_CYCLE, /* 1099 */ + XML_RNGP_REF_NAME_INVALID, /* 1100 */ + XML_RNGP_REF_NO_DEF, /* 1101 */ + XML_RNGP_REF_NO_NAME, /* 1102 */ + XML_RNGP_REF_NOT_EMPTY, /* 1103 */ + XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */ + XML_RNGP_START_CONTENT, /* 1105 */ + XML_RNGP_START_EMPTY, /* 1106 */ + XML_RNGP_START_MISSING, /* 1107 */ + XML_RNGP_TEXT_EXPECTED, /* 1108 */ + XML_RNGP_TEXT_HAS_CHILD, /* 1109 */ + XML_RNGP_TYPE_MISSING, /* 1110 */ + XML_RNGP_TYPE_NOT_FOUND, /* 1111 */ + XML_RNGP_TYPE_VALUE, /* 1112 */ + XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */ + XML_RNGP_UNKNOWN_COMBINE, /* 1114 */ + XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */ + XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */ + XML_RNGP_URI_FRAGMENT, /* 1117 */ + XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */ + XML_RNGP_VALUE_EMPTY, /* 1119 */ + XML_RNGP_VALUE_NO_CONTENT, /* 1120 */ + XML_RNGP_XMLNS_NAME, /* 1121 */ + XML_RNGP_XML_NS, /* 1122 */ + XML_XPATH_EXPRESSION_OK = 1200, + XML_XPATH_NUMBER_ERROR, /* 1201 */ + XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */ + XML_XPATH_START_LITERAL_ERROR, /* 1203 */ + XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */ + XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */ + XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */ + XML_XPATH_EXPR_ERROR, /* 1207 */ + XML_XPATH_UNCLOSED_ERROR, /* 1208 */ + XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */ + XML_XPATH_INVALID_OPERAND, /* 1210 */ + XML_XPATH_INVALID_TYPE, /* 1211 */ + XML_XPATH_INVALID_ARITY, /* 1212 */ + XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */ + XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */ + XML_XPATH_MEMORY_ERROR, /* 1215 */ + XML_XPTR_SYNTAX_ERROR, /* 1216 */ + XML_XPTR_RESOURCE_ERROR, /* 1217 */ + XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */ + XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */ + XML_XPATH_ENCODING_ERROR, /* 1220 */ + XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */ + XML_TREE_INVALID_HEX = 1300, + XML_TREE_INVALID_DEC, /* 1301 */ + XML_TREE_UNTERMINATED_ENTITY, /* 1302 */ + XML_TREE_NOT_UTF8, /* 1303 */ + XML_SAVE_NOT_UTF8 = 1400, + XML_SAVE_CHAR_INVALID, /* 1401 */ + XML_SAVE_NO_DOCTYPE, /* 1402 */ + XML_SAVE_UNKNOWN_ENCODING, /* 1403 */ + XML_REGEXP_COMPILE_ERROR = 1450, + XML_IO_UNKNOWN = 1500, + XML_IO_EACCES, /* 1501 */ + XML_IO_EAGAIN, /* 1502 */ + XML_IO_EBADF, /* 1503 */ + XML_IO_EBADMSG, /* 1504 */ + XML_IO_EBUSY, /* 1505 */ + XML_IO_ECANCELED, /* 1506 */ + XML_IO_ECHILD, /* 1507 */ + XML_IO_EDEADLK, /* 1508 */ + XML_IO_EDOM, /* 1509 */ + XML_IO_EEXIST, /* 1510 */ + XML_IO_EFAULT, /* 1511 */ + XML_IO_EFBIG, /* 1512 */ + XML_IO_EINPROGRESS, /* 1513 */ + XML_IO_EINTR, /* 1514 */ + XML_IO_EINVAL, /* 1515 */ + XML_IO_EIO, /* 1516 */ + XML_IO_EISDIR, /* 1517 */ + XML_IO_EMFILE, /* 1518 */ + XML_IO_EMLINK, /* 1519 */ + XML_IO_EMSGSIZE, /* 1520 */ + XML_IO_ENAMETOOLONG, /* 1521 */ + XML_IO_ENFILE, /* 1522 */ + XML_IO_ENODEV, /* 1523 */ + XML_IO_ENOENT, /* 1524 */ + XML_IO_ENOEXEC, /* 1525 */ + XML_IO_ENOLCK, /* 1526 */ + XML_IO_ENOMEM, /* 1527 */ + XML_IO_ENOSPC, /* 1528 */ + XML_IO_ENOSYS, /* 1529 */ + XML_IO_ENOTDIR, /* 1530 */ + XML_IO_ENOTEMPTY, /* 1531 */ + XML_IO_ENOTSUP, /* 1532 */ + XML_IO_ENOTTY, /* 1533 */ + XML_IO_ENXIO, /* 1534 */ + XML_IO_EPERM, /* 1535 */ + XML_IO_EPIPE, /* 1536 */ + XML_IO_ERANGE, /* 1537 */ + XML_IO_EROFS, /* 1538 */ + XML_IO_ESPIPE, /* 1539 */ + XML_IO_ESRCH, /* 1540 */ + XML_IO_ETIMEDOUT, /* 1541 */ + XML_IO_EXDEV, /* 1542 */ + XML_IO_NETWORK_ATTEMPT, /* 1543 */ + XML_IO_ENCODER, /* 1544 */ + XML_IO_FLUSH, /* 1545 */ + XML_IO_WRITE, /* 1546 */ + XML_IO_NO_INPUT, /* 1547 */ + XML_IO_BUFFER_FULL, /* 1548 */ + XML_IO_LOAD_ERROR, /* 1549 */ + XML_IO_ENOTSOCK, /* 1550 */ + XML_IO_EISCONN, /* 1551 */ + XML_IO_ECONNREFUSED, /* 1552 */ + XML_IO_ENETUNREACH, /* 1553 */ + XML_IO_EADDRINUSE, /* 1554 */ + XML_IO_EALREADY, /* 1555 */ + XML_IO_EAFNOSUPPORT, /* 1556 */ + XML_XINCLUDE_RECURSION=1600, + XML_XINCLUDE_PARSE_VALUE, /* 1601 */ + XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */ + XML_XINCLUDE_NO_HREF, /* 1603 */ + XML_XINCLUDE_NO_FALLBACK, /* 1604 */ + XML_XINCLUDE_HREF_URI, /* 1605 */ + XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */ + XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */ + XML_XINCLUDE_INVALID_CHAR, /* 1608 */ + XML_XINCLUDE_BUILD_FAILED, /* 1609 */ + XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */ + XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */ + XML_XINCLUDE_XPTR_FAILED, /* 1612 */ + XML_XINCLUDE_XPTR_RESULT, /* 1613 */ + XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */ + XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */ + XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */ + XML_XINCLUDE_DEPRECATED_NS, /* 1617 */ + XML_XINCLUDE_FRAGMENT_ID, /* 1618 */ + XML_CATALOG_MISSING_ATTR = 1650, + XML_CATALOG_ENTRY_BROKEN, /* 1651 */ + XML_CATALOG_PREFER_VALUE, /* 1652 */ + XML_CATALOG_NOT_CATALOG, /* 1653 */ + XML_CATALOG_RECURSION, /* 1654 */ + XML_SCHEMAP_PREFIX_UNDEFINED = 1700, + XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */ + XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */ + XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */ + XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */ + XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */ + XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */ + XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */ + XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */ + XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */ + XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */ + XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */ + XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */ + XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */ + XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */ + XML_SCHEMAP_INVALID_ENUM, /* 1715 */ + XML_SCHEMAP_INVALID_FACET, /* 1716 */ + XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */ + XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */ + XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */ + XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */ + XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */ + XML_SCHEMAP_NOATTR_NOREF, /* 1722 */ + XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */ + XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */ + XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */ + XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */ + XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */ + XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */ + XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */ + XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */ + XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */ + XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */ + XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */ + XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */ + XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */ + XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */ + XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */ + XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */ + XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */ + XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */ + XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */ + XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */ + XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */ + XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */ + XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */ + XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */ + XML_SCHEMAP_UNKNOWN_REF, /* 1747 */ + XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */ + XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */ + XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */ + XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */ + XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */ + XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */ + XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */ + XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */ + XML_SCHEMAP_REGEXP_INVALID, /* 1756 */ + XML_SCHEMAP_FAILED_LOAD, /* 1757 */ + XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */ + XML_SCHEMAP_NOROOT, /* 1759 */ + XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */ + XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */ + XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */ + XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */ + XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */ + XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */ + XML_SCHEMAP_FAILED_PARSE, /* 1766 */ + XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */ + XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */ + XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */ + XML_SCHEMAP_NOT_SCHEMA, /* 1772 */ + XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */ + XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */ + XML_SCHEMAP_RECURSIVE, /* 1775 */ + XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */ + XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */ + XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */ + XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */ + XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */ + XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */ + XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */ + XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */ + XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */ + XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */ + XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */ + XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */ + XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */ + XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */ + XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */ + XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */ + XML_SCHEMAV_NOROOT = 1801, + XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */ + XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */ + XML_SCHEMAV_MISSING, /* 1804 */ + XML_SCHEMAV_WRONGELEM, /* 1805 */ + XML_SCHEMAV_NOTYPE, /* 1806 */ + XML_SCHEMAV_NOROLLBACK, /* 1807 */ + XML_SCHEMAV_ISABSTRACT, /* 1808 */ + XML_SCHEMAV_NOTEMPTY, /* 1809 */ + XML_SCHEMAV_ELEMCONT, /* 1810 */ + XML_SCHEMAV_HAVEDEFAULT, /* 1811 */ + XML_SCHEMAV_NOTNILLABLE, /* 1812 */ + XML_SCHEMAV_EXTRACONTENT, /* 1813 */ + XML_SCHEMAV_INVALIDATTR, /* 1814 */ + XML_SCHEMAV_INVALIDELEM, /* 1815 */ + XML_SCHEMAV_NOTDETERMINIST, /* 1816 */ + XML_SCHEMAV_CONSTRUCT, /* 1817 */ + XML_SCHEMAV_INTERNAL, /* 1818 */ + XML_SCHEMAV_NOTSIMPLE, /* 1819 */ + XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */ + XML_SCHEMAV_ATTRINVALID, /* 1821 */ + XML_SCHEMAV_VALUE, /* 1822 */ + XML_SCHEMAV_FACET, /* 1823 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */ + XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */ + XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */ + XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */ + XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */ + XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */ + XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */ + XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */ + XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */ + XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */ + XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */ + XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */ + XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */ + XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */ + XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */ + XML_SCHEMAV_CVC_ELT_1, /* 1845 */ + XML_SCHEMAV_CVC_ELT_2, /* 1846 */ + XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */ + XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */ + XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */ + XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */ + XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */ + XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */ + XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */ + XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */ + XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */ + XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */ + XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */ + XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */ + XML_SCHEMAV_CVC_ELT_6, /* 1859 */ + XML_SCHEMAV_CVC_ELT_7, /* 1860 */ + XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */ + XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */ + XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */ + XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */ + XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */ + XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */ + XML_SCHEMAV_CVC_AU, /* 1874 */ + XML_SCHEMAV_CVC_TYPE_1, /* 1875 */ + XML_SCHEMAV_CVC_TYPE_2, /* 1876 */ + XML_SCHEMAV_CVC_IDC, /* 1877 */ + XML_SCHEMAV_CVC_WILDCARD, /* 1878 */ + XML_SCHEMAV_MISC, /* 1879 */ + XML_XPTR_UNKNOWN_SCHEME = 1900, + XML_XPTR_CHILDSEQ_START, /* 1901 */ + XML_XPTR_EVAL_FAILED, /* 1902 */ + XML_XPTR_EXTRA_OBJECTS, /* 1903 */ + XML_C14N_CREATE_CTXT = 1950, + XML_C14N_REQUIRES_UTF8, /* 1951 */ + XML_C14N_CREATE_STACK, /* 1952 */ + XML_C14N_INVALID_NODE, /* 1953 */ + XML_C14N_UNKNOW_NODE, /* 1954 */ + XML_C14N_RELATIVE_NAMESPACE, /* 1955 */ + XML_FTP_PASV_ANSWER = 2000, + XML_FTP_EPSV_ANSWER, /* 2001 */ + XML_FTP_ACCNT, /* 2002 */ + XML_FTP_URL_SYNTAX, /* 2003 */ + XML_HTTP_URL_SYNTAX = 2020, + XML_HTTP_USE_IP, /* 2021 */ + XML_HTTP_UNKNOWN_HOST, /* 2022 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000, + XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */ + XML_SCHEMAP_SRC_RESOLVE, /* 3004 */ + XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */ + XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */ + XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */ + XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */ + XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */ + XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */ + XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */ + XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */ + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */ + XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */ + XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */ + XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */ + XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */ + XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */ + XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */ + XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */ + XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */ + XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */ + XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */ + XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */ + XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */ + XML_SCHEMAP_SRC_INCLUDE, /* 3050 */ + XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */ + XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */ + XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */ + XML_SCHEMAP_NO_XMLNS, /* 3056 */ + XML_SCHEMAP_NO_XSI, /* 3057 */ + XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */ + XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */ + XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */ + XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */ + XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */ + XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */ + XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */ + XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */ + XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */ + XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */ + XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */ + XML_SCHEMAP_SRC_CT_1, /* 3076 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */ + XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */ + XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */ + XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */ + XML_SCHEMAP_SRC_REDEFINE, /* 3081 */ + XML_SCHEMAP_SRC_IMPORT, /* 3082 */ + XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */ + XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */ + XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */ + XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */ + XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */ + XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */ + XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */ + XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */ + XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */ + XML_SCHEMATRONV_REPORT, + XML_MODULE_OPEN = 4900, /* 4900 */ + XML_MODULE_CLOSE, /* 4901 */ + XML_CHECK_FOUND_ELEMENT = 5000, + XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */ + XML_CHECK_FOUND_TEXT, /* 5002 */ + XML_CHECK_FOUND_CDATA, /* 5003 */ + XML_CHECK_FOUND_ENTITYREF, /* 5004 */ + XML_CHECK_FOUND_ENTITY, /* 5005 */ + XML_CHECK_FOUND_PI, /* 5006 */ + XML_CHECK_FOUND_COMMENT, /* 5007 */ + XML_CHECK_FOUND_DOCTYPE, /* 5008 */ + XML_CHECK_FOUND_FRAGMENT, /* 5009 */ + XML_CHECK_FOUND_NOTATION, /* 5010 */ + XML_CHECK_UNKNOWN_NODE, /* 5011 */ + XML_CHECK_ENTITY_TYPE, /* 5012 */ + XML_CHECK_NO_PARENT, /* 5013 */ + XML_CHECK_NO_DOC, /* 5014 */ + XML_CHECK_NO_NAME, /* 5015 */ + XML_CHECK_NO_ELEM, /* 5016 */ + XML_CHECK_WRONG_DOC, /* 5017 */ + XML_CHECK_NO_PREV, /* 5018 */ + XML_CHECK_WRONG_PREV, /* 5019 */ + XML_CHECK_NO_NEXT, /* 5020 */ + XML_CHECK_WRONG_NEXT, /* 5021 */ + XML_CHECK_NOT_DTD, /* 5022 */ + XML_CHECK_NOT_ATTR, /* 5023 */ + XML_CHECK_NOT_ATTR_DECL, /* 5024 */ + XML_CHECK_NOT_ELEM_DECL, /* 5025 */ + XML_CHECK_NOT_ENTITY_DECL, /* 5026 */ + XML_CHECK_NOT_NS_DECL, /* 5027 */ + XML_CHECK_NO_HREF, /* 5028 */ + XML_CHECK_WRONG_PARENT,/* 5029 */ + XML_CHECK_NS_SCOPE, /* 5030 */ + XML_CHECK_NS_ANCESTOR, /* 5031 */ + XML_CHECK_NOT_UTF8, /* 5032 */ + XML_CHECK_NO_DICT, /* 5033 */ + XML_CHECK_NOT_NCNAME, /* 5034 */ + XML_CHECK_OUTSIDE_DICT, /* 5035 */ + XML_CHECK_WRONG_NAME, /* 5036 */ + XML_CHECK_NAME_NOT_NULL, /* 5037 */ + XML_I18N_NO_NAME = 6000, + XML_I18N_NO_HANDLER, /* 6001 */ + XML_I18N_EXCESS_HANDLER, /* 6002 */ + XML_I18N_CONV_FAILED, /* 6003 */ + XML_I18N_NO_OUTPUT, /* 6004 */ + XML_BUF_OVERFLOW = 7000 +} xmlParserErrors; + +/** + * xmlGenericErrorFunc: + * @ctx: a parsing context + * @msg: the message + * @...: the extra arguments of the varargs to format the message + * + * Signature of the function to use when there is an error and + * no parsing or validity context available . + */ +typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +/** + * xmlStructuredErrorFunc: + * @userData: user provided data for the error callback + * @error: the error being raised. + * + * Signature of the function to use when there is an error and + * the module handles the new error reporting mechanism. + */ +typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error); + +/* + * Use the following function to reset the two global variables + * xmlGenericError and xmlGenericErrorContext. + */ +XMLPUBFUN void XMLCALL + xmlSetGenericErrorFunc (void *ctx, + xmlGenericErrorFunc handler); +XMLPUBFUN void XMLCALL + initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler); + +XMLPUBFUN void XMLCALL + xmlSetStructuredErrorFunc (void *ctx, + xmlStructuredErrorFunc handler); +/* + * Default message routines used by SAX and Valid context for error + * and warning reporting. + */ +XMLPUBFUN void XMLCDECL + xmlParserError (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void XMLCDECL + xmlParserWarning (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void XMLCDECL + xmlParserValidityError (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void XMLCDECL + xmlParserValidityWarning (void *ctx, + const char *msg, + ...) LIBXML_ATTR_FORMAT(2,3); +XMLPUBFUN void XMLCALL + xmlParserPrintFileInfo (xmlParserInputPtr input); +XMLPUBFUN void XMLCALL + xmlParserPrintFileContext (xmlParserInputPtr input); + +/* + * Extended error information routines + */ +XMLPUBFUN xmlErrorPtr XMLCALL + xmlGetLastError (void); +XMLPUBFUN void XMLCALL + xmlResetLastError (void); +XMLPUBFUN xmlErrorPtr XMLCALL + xmlCtxtGetLastError (void *ctx); +XMLPUBFUN void XMLCALL + xmlCtxtResetLastError (void *ctx); +XMLPUBFUN void XMLCALL + xmlResetError (xmlErrorPtr err); +XMLPUBFUN int XMLCALL + xmlCopyError (xmlErrorPtr from, + xmlErrorPtr to); + +#ifdef IN_LIBXML +/* + * Internal callback reporting routine + */ +XMLPUBFUN void XMLCALL + __xmlRaiseError (xmlStructuredErrorFunc schannel, + xmlGenericErrorFunc channel, + void *data, + void *ctx, + void *node, + int domain, + int code, + xmlErrorLevel level, + const char *file, + int line, + const char *str1, + const char *str2, + const char *str3, + int int1, + int col, + const char *msg, + ...) LIBXML_ATTR_FORMAT(16,17); +XMLPUBFUN void XMLCALL + __xmlSimpleError (int domain, + int code, + xmlNodePtr node, + const char *msg, + const char *extra) LIBXML_ATTR_FORMAT(4,0); +#endif +#ifdef __cplusplus +} +#endif +#endif /* __XML_ERROR_H__ */ diff --git a/src/include/libxml/xmlexports.h b/src/include/libxml/xmlexports.h new file mode 100644 index 000000000000..aceede5ec050 --- /dev/null +++ b/src/include/libxml/xmlexports.h @@ -0,0 +1,77 @@ +/* + * Summary: macros for marking symbols as exportable/importable. + * Description: macros for marking symbols as exportable/importable. + * + * Copy: See Copyright for the status of this software. + */ + +#ifndef __XML_EXPORTS_H__ +#define __XML_EXPORTS_H__ + +#if defined(_WIN32) || defined(__CYGWIN__) +/** DOC_DISABLE */ + +#ifdef LIBXML_STATIC + #define XMLPUBLIC +#elif defined(IN_LIBXML) + #define XMLPUBLIC __declspec(dllexport) +#else + #define XMLPUBLIC __declspec(dllimport) +#endif + +#if defined(LIBXML_FASTCALL) + #define XMLCALL __fastcall +#else + #define XMLCALL __cdecl +#endif +#define XMLCDECL __cdecl + +/** DOC_ENABLE */ +#else /* not Windows */ + +/** + * XMLPUBLIC: + * + * Macro which declares a public symbol + */ +#define XMLPUBLIC + +/** + * XMLCALL: + * + * Macro which declares the calling convention for exported functions + */ +#define XMLCALL + +/** + * XMLCDECL: + * + * Macro which declares the calling convention for exported functions that + * use '...'. + */ +#define XMLCDECL + +#endif /* platform switch */ + +/* + * XMLPUBFUN: + * + * Macro which declares an exportable function + */ +#define XMLPUBFUN XMLPUBLIC + +/** + * XMLPUBVAR: + * + * Macro which declares an exportable variable + */ +#define XMLPUBVAR XMLPUBLIC extern + +/* Compatibility */ +#if !defined(LIBXML_DLL_IMPORT) +#define LIBXML_DLL_IMPORT XMLPUBVAR +#endif + +#endif /* __XML_EXPORTS_H__ */ + + diff --git a/src/include/libxml/xmlmemory.h b/src/include/libxml/xmlmemory.h new file mode 100644 index 000000000000..17e375a3c9ad --- /dev/null +++ b/src/include/libxml/xmlmemory.h @@ -0,0 +1,224 @@ +/* + * Summary: interface for the memory allocator + * Description: provides interfaces for the memory allocator, + * including debugging capabilities. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __DEBUG_MEMORY_ALLOC__ +#define __DEBUG_MEMORY_ALLOC__ + +#include +#include + +/** + * DEBUG_MEMORY: + * + * DEBUG_MEMORY replaces the allocator with a collect and debug + * shell to the libc allocator. + * DEBUG_MEMORY should only be activated when debugging + * libxml i.e. if libxml has been configured with --with-debug-mem too. + */ +/* #define DEBUG_MEMORY_FREED */ +/* #define DEBUG_MEMORY_LOCATION */ + +#ifdef DEBUG +#ifndef DEBUG_MEMORY +#define DEBUG_MEMORY +#endif +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * DEBUG_MEMORY_LOCATION should be activated only when debugging + * libxml i.e. if libxml has been configured with --with-debug-mem too. + */ +#ifdef DEBUG_MEMORY_LOCATION +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The XML memory wrapper support 4 basic overloadable functions. + */ +/** + * xmlFreeFunc: + * @mem: an already allocated block of memory + * + * Signature for a free() implementation. + */ +typedef void (XMLCALL *xmlFreeFunc)(void *mem); +/** + * xmlMallocFunc: + * @size: the size requested in bytes + * + * Signature for a malloc() implementation. + * + * Returns a pointer to the newly allocated block or NULL in case of error. + */ +typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size); + +/** + * xmlReallocFunc: + * @mem: an already allocated block of memory + * @size: the new size requested in bytes + * + * Signature for a realloc() implementation. + * + * Returns a pointer to the newly reallocated block or NULL in case of error. + */ +typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size); + +/** + * xmlStrdupFunc: + * @str: a zero terminated string + * + * Signature for an strdup() implementation. + * + * Returns the copy of the string or NULL in case of error. + */ +typedef char *(XMLCALL *xmlStrdupFunc)(const char *str); + +/* + * The 4 interfaces used for all memory handling within libxml. +LIBXML_DLL_IMPORT xmlFreeFunc xmlFree; +LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc; +LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic; +LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc; +LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup; + */ + +/* + * The way to overload the existing functions. + * The xmlGc function have an extra entry for atomic block + * allocations useful for garbage collected memory allocators + */ +XMLPUBFUN int XMLCALL + xmlMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int XMLCALL + xmlMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); +XMLPUBFUN int XMLCALL + xmlGcMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlMallocFunc mallocAtomicFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int XMLCALL + xmlGcMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlMallocFunc *mallocAtomicFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); + +/* + * Initialization of the memory layer. + */ +XMLPUBFUN int XMLCALL + xmlInitMemory (void); + +/* + * Cleanup of the memory layer. + */ +XMLPUBFUN void XMLCALL + xmlCleanupMemory (void); +/* + * These are specific to the XML debug memory wrapper. + */ +XMLPUBFUN int XMLCALL + xmlMemUsed (void); +XMLPUBFUN int XMLCALL + xmlMemBlocks (void); +XMLPUBFUN void XMLCALL + xmlMemDisplay (FILE *fp); +XMLPUBFUN void XMLCALL + xmlMemDisplayLast(FILE *fp, long nbBytes); +XMLPUBFUN void XMLCALL + xmlMemShow (FILE *fp, int nr); +XMLPUBFUN void XMLCALL + xmlMemoryDump (void); +XMLPUBFUN void * XMLCALL + xmlMemMalloc (size_t size) LIBXML_ATTR_ALLOC_SIZE(1); +XMLPUBFUN void * XMLCALL + xmlMemRealloc (void *ptr,size_t size); +XMLPUBFUN void XMLCALL + xmlMemFree (void *ptr); +XMLPUBFUN char * XMLCALL + xmlMemoryStrdup (const char *str); +XMLPUBFUN void * XMLCALL + xmlMallocLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1); +XMLPUBFUN void * XMLCALL + xmlReallocLoc (void *ptr, size_t size, const char *file, int line); +XMLPUBFUN void * XMLCALL + xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1); +XMLPUBFUN char * XMLCALL + xmlMemStrdupLoc (const char *str, const char *file, int line); + + +#ifdef DEBUG_MEMORY_LOCATION +/** + * xmlMalloc: + * @size: number of bytes to allocate + * + * Wrapper for the malloc() function used in the XML library. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__) +/** + * xmlMallocAtomic: + * @size: number of bytes to allocate + * + * Wrapper for the malloc() function used in the XML library for allocation + * of block not containing pointers to other areas. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__) +/** + * xmlRealloc: + * @ptr: pointer to the existing allocated area + * @size: number of bytes to allocate + * + * Wrapper for the realloc() function used in the XML library. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__) +/** + * xmlMemStrdup: + * @str: pointer to the existing string + * + * Wrapper for the strdup() function, xmlStrdup() is usually preferred. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__) + +#endif /* DEBUG_MEMORY_LOCATION */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#ifndef __XML_GLOBALS_H +#ifndef __XML_THREADS_H__ +#include +#include +#endif +#endif + +#endif /* __DEBUG_MEMORY_ALLOC__ */ + diff --git a/src/include/libxml/xmlmodule.h b/src/include/libxml/xmlmodule.h new file mode 100644 index 000000000000..9667820070af --- /dev/null +++ b/src/include/libxml/xmlmodule.h @@ -0,0 +1,57 @@ +/* + * Summary: dynamic module loading + * Description: basic API for dynamic module loading, used by + * libexslt added in 2.6.17 + * + * Copy: See Copyright for the status of this software. + * + * Author: Joel W. Reed + */ + +#ifndef __XML_MODULE_H__ +#define __XML_MODULE_H__ + +#include + +#ifdef LIBXML_MODULES_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlModulePtr: + * + * A handle to a dynamically loaded module + */ +typedef struct _xmlModule xmlModule; +typedef xmlModule *xmlModulePtr; + +/** + * xmlModuleOption: + * + * enumeration of options that can be passed down to xmlModuleOpen() + */ +typedef enum { + XML_MODULE_LAZY = 1, /* lazy binding */ + XML_MODULE_LOCAL= 2 /* local binding */ +} xmlModuleOption; + +XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen (const char *filename, + int options); + +XMLPUBFUN int XMLCALL xmlModuleSymbol (xmlModulePtr module, + const char* name, + void **result); + +XMLPUBFUN int XMLCALL xmlModuleClose (xmlModulePtr module); + +XMLPUBFUN int XMLCALL xmlModuleFree (xmlModulePtr module); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_MODULES_ENABLED */ + +#endif /*__XML_MODULE_H__ */ diff --git a/src/include/libxml/xmlreader.h b/src/include/libxml/xmlreader.h new file mode 100644 index 000000000000..e8a8bcc9aab0 --- /dev/null +++ b/src/include/libxml/xmlreader.h @@ -0,0 +1,428 @@ +/* + * Summary: the XMLReader implementation + * Description: API of the XML streaming API based on C# interfaces. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLREADER_H__ +#define __XML_XMLREADER_H__ + +#include +#include +#include +#ifdef LIBXML_SCHEMAS_ENABLED +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlParserSeverities: + * + * How severe an error callback is when the per-reader error callback API + * is used. + */ +typedef enum { + XML_PARSER_SEVERITY_VALIDITY_WARNING = 1, + XML_PARSER_SEVERITY_VALIDITY_ERROR = 2, + XML_PARSER_SEVERITY_WARNING = 3, + XML_PARSER_SEVERITY_ERROR = 4 +} xmlParserSeverities; + +#ifdef LIBXML_READER_ENABLED + +/** + * xmlTextReaderMode: + * + * Internal state values for the reader. + */ +typedef enum { + XML_TEXTREADER_MODE_INITIAL = 0, + XML_TEXTREADER_MODE_INTERACTIVE = 1, + XML_TEXTREADER_MODE_ERROR = 2, + XML_TEXTREADER_MODE_EOF =3, + XML_TEXTREADER_MODE_CLOSED = 4, + XML_TEXTREADER_MODE_READING = 5 +} xmlTextReaderMode; + +/** + * xmlParserProperties: + * + * Some common options to use with xmlTextReaderSetParserProp, but it + * is better to use xmlParserOption and the xmlReaderNewxxx and + * xmlReaderForxxx APIs now. + */ +typedef enum { + XML_PARSER_LOADDTD = 1, + XML_PARSER_DEFAULTATTRS = 2, + XML_PARSER_VALIDATE = 3, + XML_PARSER_SUBST_ENTITIES = 4 +} xmlParserProperties; + +/** + * xmlReaderTypes: + * + * Predefined constants for the different types of nodes. + */ +typedef enum { + XML_READER_TYPE_NONE = 0, + XML_READER_TYPE_ELEMENT = 1, + XML_READER_TYPE_ATTRIBUTE = 2, + XML_READER_TYPE_TEXT = 3, + XML_READER_TYPE_CDATA = 4, + XML_READER_TYPE_ENTITY_REFERENCE = 5, + XML_READER_TYPE_ENTITY = 6, + XML_READER_TYPE_PROCESSING_INSTRUCTION = 7, + XML_READER_TYPE_COMMENT = 8, + XML_READER_TYPE_DOCUMENT = 9, + XML_READER_TYPE_DOCUMENT_TYPE = 10, + XML_READER_TYPE_DOCUMENT_FRAGMENT = 11, + XML_READER_TYPE_NOTATION = 12, + XML_READER_TYPE_WHITESPACE = 13, + XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14, + XML_READER_TYPE_END_ELEMENT = 15, + XML_READER_TYPE_END_ENTITY = 16, + XML_READER_TYPE_XML_DECLARATION = 17 +} xmlReaderTypes; + +/** + * xmlTextReader: + * + * Structure for an xmlReader context. + */ +typedef struct _xmlTextReader xmlTextReader; + +/** + * xmlTextReaderPtr: + * + * Pointer to an xmlReader context. + */ +typedef xmlTextReader *xmlTextReaderPtr; + +/* + * Constructors & Destructor + */ +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlNewTextReader (xmlParserInputBufferPtr input, + const char *URI); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlNewTextReaderFilename(const char *URI); + +XMLPUBFUN void XMLCALL + xmlFreeTextReader (xmlTextReaderPtr reader); + +XMLPUBFUN int XMLCALL + xmlTextReaderSetup(xmlTextReaderPtr reader, + xmlParserInputBufferPtr input, const char *URL, + const char *encoding, int options); + +/* + * Iterators + */ +XMLPUBFUN int XMLCALL + xmlTextReaderRead (xmlTextReaderPtr reader); + +#ifdef LIBXML_WRITER_ENABLED +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadInnerXml(xmlTextReaderPtr reader); + +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadOuterXml(xmlTextReaderPtr reader); +#endif + +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadString (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader); + +/* + * Attributes of the node + */ +XMLPUBFUN int XMLCALL + xmlTextReaderAttributeCount(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderDepth (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderHasAttributes(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderHasValue(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsDefault (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNodeType (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderQuoteChar (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderReadState (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); + +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstLocalName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstPrefix (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstString (xmlTextReaderPtr reader, + const xmlChar *str); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstValue (xmlTextReaderPtr reader); + +/* + * use the Const version of the routine for + * better performance and simpler code + */ +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLocalName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderPrefix (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderValue (xmlTextReaderPtr reader); + +/* + * Methods of the XmlTextReader + */ +XMLPUBFUN int XMLCALL + xmlTextReaderClose (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, + int no); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttribute (xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlTextReaderGetRemainder (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, + const xmlChar *prefix); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, + int no); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToElement (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNormalization (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstEncoding (xmlTextReaderPtr reader); + +/* + * Extensions + */ +XMLPUBFUN int XMLCALL + xmlTextReaderSetParserProp (xmlTextReaderPtr reader, + int prop, + int value); +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserProp (xmlTextReaderPtr reader, + int prop); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderCurrentNode (xmlTextReaderPtr reader); + +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader); + +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader); + +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderPreserve (xmlTextReaderPtr reader); +#ifdef LIBXML_PATTERN_ENABLED +XMLPUBFUN int XMLCALL + xmlTextReaderPreservePattern(xmlTextReaderPtr reader, + const xmlChar *pattern, + const xmlChar **namespaces); +#endif /* LIBXML_PATTERN_ENABLED */ +XMLPUBFUN xmlDocPtr XMLCALL + xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderExpand (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNext (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNextSibling (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsValid (xmlTextReaderPtr reader); +#ifdef LIBXML_SCHEMAS_ENABLED +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, + const char *rng); +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader, + xmlRelaxNGValidCtxtPtr ctxt, + int options); + +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, + xmlRelaxNGPtr schema); +XMLPUBFUN int XMLCALL + xmlTextReaderSchemaValidate (xmlTextReaderPtr reader, + const char *xsd); +XMLPUBFUN int XMLCALL + xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader, + xmlSchemaValidCtxtPtr ctxt, + int options); +XMLPUBFUN int XMLCALL + xmlTextReaderSetSchema (xmlTextReaderPtr reader, + xmlSchemaPtr schema); +#endif +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderStandalone (xmlTextReaderPtr reader); + + +/* + * Index lookup + */ +XMLPUBFUN long XMLCALL + xmlTextReaderByteConsumed (xmlTextReaderPtr reader); + +/* + * New more complete APIs for simpler creation and reuse of readers + */ +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderWalker (xmlDocPtr doc); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForDoc (const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForFile (const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +XMLPUBFUN int XMLCALL + xmlReaderNewWalker (xmlTextReaderPtr reader, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlReaderNewDoc (xmlTextReaderPtr reader, + const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewFile (xmlTextReaderPtr reader, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewMemory (xmlTextReaderPtr reader, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewFd (xmlTextReaderPtr reader, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewIO (xmlTextReaderPtr reader, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +/* + * Error handling extensions + */ +typedef void * xmlTextReaderLocatorPtr; + +/** + * xmlTextReaderErrorFunc: + * @arg: the user argument + * @msg: the message + * @severity: the severity of the error + * @locator: a locator indicating where the error occurred + * + * Signature of an error callback from a reader parser + */ +typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg, + const char *msg, + xmlParserSeverities severity, + xmlTextReaderLocatorPtr locator); +XMLPUBFUN int XMLCALL + xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); +XMLPUBFUN void XMLCALL + xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc f, + void *arg); +XMLPUBFUN void XMLCALL + xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, + xmlStructuredErrorFunc f, + void *arg); +XMLPUBFUN void XMLCALL + xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc *f, + void **arg); + +#endif /* LIBXML_READER_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_XMLREADER_H__ */ + diff --git a/src/include/libxml/xmlregexp.h b/src/include/libxml/xmlregexp.h new file mode 100644 index 000000000000..7009645a9252 --- /dev/null +++ b/src/include/libxml/xmlregexp.h @@ -0,0 +1,222 @@ +/* + * Summary: regular expressions handling + * Description: basic API for libxml regular expressions handling used + * for XML Schemas and validation. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_REGEXP_H__ +#define __XML_REGEXP_H__ + +#include + +#ifdef LIBXML_REGEXP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlRegexpPtr: + * + * A libxml regular expression, they can actually be far more complex + * thank the POSIX regex expressions. + */ +typedef struct _xmlRegexp xmlRegexp; +typedef xmlRegexp *xmlRegexpPtr; + +/** + * xmlRegExecCtxtPtr: + * + * A libxml progressive regular expression evaluation context + */ +typedef struct _xmlRegExecCtxt xmlRegExecCtxt; +typedef xmlRegExecCtxt *xmlRegExecCtxtPtr; + +#ifdef __cplusplus +} +#endif +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The POSIX like API + */ +XMLPUBFUN xmlRegexpPtr XMLCALL + xmlRegexpCompile (const xmlChar *regexp); +XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp); +XMLPUBFUN int XMLCALL + xmlRegexpExec (xmlRegexpPtr comp, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlRegexpPrint (FILE *output, + xmlRegexpPtr regexp); +XMLPUBFUN int XMLCALL + xmlRegexpIsDeterminist(xmlRegexpPtr comp); + +/** + * xmlRegExecCallbacks: + * @exec: the regular expression context + * @token: the current token string + * @transdata: transition data + * @inputdata: input data + * + * Callback function when doing a transition in the automata + */ +typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec, + const xmlChar *token, + void *transdata, + void *inputdata); + +/* + * The progressive API + */ +XMLPUBFUN xmlRegExecCtxtPtr XMLCALL + xmlRegNewExecCtxt (xmlRegexpPtr comp, + xmlRegExecCallbacks callback, + void *data); +XMLPUBFUN void XMLCALL + xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); +XMLPUBFUN int XMLCALL + xmlRegExecPushString(xmlRegExecCtxtPtr exec, + const xmlChar *value, + void *data); +XMLPUBFUN int XMLCALL + xmlRegExecPushString2(xmlRegExecCtxtPtr exec, + const xmlChar *value, + const xmlChar *value2, + void *data); + +XMLPUBFUN int XMLCALL + xmlRegExecNextValues(xmlRegExecCtxtPtr exec, + int *nbval, + int *nbneg, + xmlChar **values, + int *terminal); +XMLPUBFUN int XMLCALL + xmlRegExecErrInfo (xmlRegExecCtxtPtr exec, + const xmlChar **string, + int *nbval, + int *nbneg, + xmlChar **values, + int *terminal); +#ifdef LIBXML_EXPR_ENABLED +/* + * Formal regular expression handling + * Its goal is to do some formal work on content models + */ + +/* expressions are used within a context */ +typedef struct _xmlExpCtxt xmlExpCtxt; +typedef xmlExpCtxt *xmlExpCtxtPtr; + +XMLPUBFUN void XMLCALL + xmlExpFreeCtxt (xmlExpCtxtPtr ctxt); +XMLPUBFUN xmlExpCtxtPtr XMLCALL + xmlExpNewCtxt (int maxNodes, + xmlDictPtr dict); + +XMLPUBFUN int XMLCALL + xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt); + +/* Expressions are trees but the tree is opaque */ +typedef struct _xmlExpNode xmlExpNode; +typedef xmlExpNode *xmlExpNodePtr; + +typedef enum { + XML_EXP_EMPTY = 0, + XML_EXP_FORBID = 1, + XML_EXP_ATOM = 2, + XML_EXP_SEQ = 3, + XML_EXP_OR = 4, + XML_EXP_COUNT = 5 +} xmlExpNodeType; + +/* + * 2 core expressions shared by all for the empty language set + * and for the set with just the empty token + */ +XMLPUBVAR xmlExpNodePtr forbiddenExp; +XMLPUBVAR xmlExpNodePtr emptyExp; + +/* + * Expressions are reference counted internally + */ +XMLPUBFUN void XMLCALL + xmlExpFree (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr); +XMLPUBFUN void XMLCALL + xmlExpRef (xmlExpNodePtr expr); + +/* + * constructors can be either manual or from a string + */ +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpParse (xmlExpCtxtPtr ctxt, + const char *expr); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewAtom (xmlExpCtxtPtr ctxt, + const xmlChar *name, + int len); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewOr (xmlExpCtxtPtr ctxt, + xmlExpNodePtr left, + xmlExpNodePtr right); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewSeq (xmlExpCtxtPtr ctxt, + xmlExpNodePtr left, + xmlExpNodePtr right); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewRange (xmlExpCtxtPtr ctxt, + xmlExpNodePtr subset, + int min, + int max); +/* + * The really interesting APIs + */ +XMLPUBFUN int XMLCALL + xmlExpIsNillable(xmlExpNodePtr expr); +XMLPUBFUN int XMLCALL + xmlExpMaxToken (xmlExpNodePtr expr); +XMLPUBFUN int XMLCALL + xmlExpGetLanguage(xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + const xmlChar**langList, + int len); +XMLPUBFUN int XMLCALL + xmlExpGetStart (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + const xmlChar**tokList, + int len); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpStringDerive(xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + const xmlChar *str, + int len); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpExpDerive (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + xmlExpNodePtr sub); +XMLPUBFUN int XMLCALL + xmlExpSubsume (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + xmlExpNodePtr sub); +XMLPUBFUN void XMLCALL + xmlExpDump (xmlBufferPtr buf, + xmlExpNodePtr expr); +#endif /* LIBXML_EXPR_ENABLED */ +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /*__XML_REGEXP_H__ */ diff --git a/src/include/libxml/xmlsave.h b/src/include/libxml/xmlsave.h new file mode 100644 index 000000000000..fb329b22dbc2 --- /dev/null +++ b/src/include/libxml/xmlsave.h @@ -0,0 +1,88 @@ +/* + * Summary: the XML document serializer + * Description: API to save document or subtree of document + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLSAVE_H__ +#define __XML_XMLSAVE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlSaveOption: + * + * This is the set of XML save options that can be passed down + * to the xmlSaveToFd() and similar calls. + */ +typedef enum { + XML_SAVE_FORMAT = 1<<0, /* format save output */ + XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */ + XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */ + XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */ + XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */ + XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */ + XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */ + XML_SAVE_WSNONSIG = 1<<7 /* format with non-significant whitespace */ +} xmlSaveOption; + + +typedef struct _xmlSaveCtxt xmlSaveCtxt; +typedef xmlSaveCtxt *xmlSaveCtxtPtr; + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToFd (int fd, + const char *encoding, + int options); +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToFilename (const char *filename, + const char *encoding, + int options); + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToBuffer (xmlBufferPtr buffer, + const char *encoding, + int options); + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + const char *encoding, + int options); + +XMLPUBFUN long XMLCALL + xmlSaveDoc (xmlSaveCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN long XMLCALL + xmlSaveTree (xmlSaveCtxtPtr ctxt, + xmlNodePtr node); + +XMLPUBFUN int XMLCALL + xmlSaveFlush (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSaveClose (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSaveSetEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +XMLPUBFUN int XMLCALL + xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* __XML_XMLSAVE_H__ */ + + diff --git a/src/include/libxml/xmlschemas.h b/src/include/libxml/xmlschemas.h new file mode 100644 index 000000000000..b90e9d18c6e6 --- /dev/null +++ b/src/include/libxml/xmlschemas.h @@ -0,0 +1,246 @@ +/* + * Summary: incomplete XML Schemas structure implementation + * Description: interface to the XML Schemas handling and schema validity + * checking, it is incomplete right now. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_H__ +#define __XML_SCHEMA_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This error codes are obsolete; not used any more. + */ +typedef enum { + XML_SCHEMAS_ERR_OK = 0, + XML_SCHEMAS_ERR_NOROOT = 1, + XML_SCHEMAS_ERR_UNDECLAREDELEM, + XML_SCHEMAS_ERR_NOTTOPLEVEL, + XML_SCHEMAS_ERR_MISSING, + XML_SCHEMAS_ERR_WRONGELEM, + XML_SCHEMAS_ERR_NOTYPE, + XML_SCHEMAS_ERR_NOROLLBACK, + XML_SCHEMAS_ERR_ISABSTRACT, + XML_SCHEMAS_ERR_NOTEMPTY, + XML_SCHEMAS_ERR_ELEMCONT, + XML_SCHEMAS_ERR_HAVEDEFAULT, + XML_SCHEMAS_ERR_NOTNILLABLE, + XML_SCHEMAS_ERR_EXTRACONTENT, + XML_SCHEMAS_ERR_INVALIDATTR, + XML_SCHEMAS_ERR_INVALIDELEM, + XML_SCHEMAS_ERR_NOTDETERMINIST, + XML_SCHEMAS_ERR_CONSTRUCT, + XML_SCHEMAS_ERR_INTERNAL, + XML_SCHEMAS_ERR_NOTSIMPLE, + XML_SCHEMAS_ERR_ATTRUNKNOWN, + XML_SCHEMAS_ERR_ATTRINVALID, + XML_SCHEMAS_ERR_VALUE, + XML_SCHEMAS_ERR_FACET, + XML_SCHEMAS_ERR_, + XML_SCHEMAS_ERR_XXX +} xmlSchemaValidError; + +/* +* ATTENTION: Change xmlSchemaSetValidOptions's check +* for invalid values, if adding to the validation +* options below. +*/ +/** + * xmlSchemaValidOption: + * + * This is the set of XML Schema validation options. + */ +typedef enum { + XML_SCHEMA_VAL_VC_I_CREATE = 1<<0 + /* Default/fixed: create an attribute node + * or an element's text node on the instance. + */ +} xmlSchemaValidOption; + +/* + XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1, + * assemble schemata using + * xsi:schemaLocation and + * xsi:noNamespaceSchemaLocation +*/ + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchema xmlSchema; +typedef xmlSchema *xmlSchemaPtr; + +/** + * xmlSchemaValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from an XSD validation + */ +typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) + (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * xmlSchemaValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from an XSD validation + */ +typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) + (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); + +/** + * A schemas validation context + */ +typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt; +typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr; + +typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt; +typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr; + +/** + * xmlSchemaValidityLocatorFunc: + * @ctx: user provided context + * @file: returned file information + * @line: returned line information + * + * A schemas validation locator, a callback called by the validator. + * This is used when file or node information are not available + * to find out what file and line number are affected + * + * Returns: 0 in case of success and -1 in case of error + */ + +typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx, + const char **file, unsigned long *line); + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewDocParserCtxt (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN void XMLCALL + xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc * err, + xmlSchemaValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt); + +XMLPUBFUN xmlSchemaPtr XMLCALL + xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchemaFree (xmlSchemaPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlSchemaDump (FILE *output, + xmlSchemaPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN void XMLCALL + xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc *err, + xmlSchemaValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt, + int options); +XMLPUBFUN void XMLCALL + xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt, + const char *filename); +XMLPUBFUN int XMLCALL + xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt); + +XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL + xmlSchemaNewValidCtxt (xmlSchemaPtr schema); +XMLPUBFUN void XMLCALL + xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt, + xmlDocPtr instance); +XMLPUBFUN int XMLCALL + xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc, + xmlSAXHandlerPtr sax, + void *user_data); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt, + const char * filename, + int options); + +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt); + +/* + * Interface to insert Schemas SAX validation in a SAX stream + */ +typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct; +typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr; + +XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL + xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt, + xmlSAXHandlerPtr *sax, + void **user_data); +XMLPUBFUN int XMLCALL + xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug); + + +XMLPUBFUN void XMLCALL + xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt, + xmlSchemaValidityLocatorFunc f, + void *ctxt); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_H__ */ diff --git a/src/include/libxml/xmlschemastypes.h b/src/include/libxml/xmlschemastypes.h new file mode 100644 index 000000000000..35d48d414bea --- /dev/null +++ b/src/include/libxml/xmlschemastypes.h @@ -0,0 +1,151 @@ +/* + * Summary: implementation of XML Schema Datatypes + * Description: module providing the XML Schema Datatypes implementation + * both definition and validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_TYPES_H__ +#define __XML_SCHEMA_TYPES_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMA_WHITESPACE_UNKNOWN = 0, + XML_SCHEMA_WHITESPACE_PRESERVE = 1, + XML_SCHEMA_WHITESPACE_REPLACE = 2, + XML_SCHEMA_WHITESPACE_COLLAPSE = 3 +} xmlSchemaWhitespaceValueType; + +XMLPUBFUN void XMLCALL + xmlSchemaInitTypes (void); +XMLPUBFUN void XMLCALL + xmlSchemaCleanupTypes (void); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetPredefinedType (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val); +XMLPUBFUN int XMLCALL + xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFacet (xmlSchemaTypePtr base, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFacetWhtsp (xmlSchemaFacetPtr facet, + xmlSchemaWhitespaceValueType fws, + xmlSchemaValType valType, + const xmlChar *value, + xmlSchemaValPtr val, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN void XMLCALL + xmlSchemaFreeValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaFacetPtr XMLCALL + xmlSchemaNewFacet (void); +XMLPUBFUN int XMLCALL + xmlSchemaCheckFacet (xmlSchemaFacetPtr facet, + xmlSchemaTypePtr typeDecl, + xmlSchemaParserCtxtPtr ctxt, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSchemaFreeFacet (xmlSchemaFacetPtr facet); +XMLPUBFUN int XMLCALL + xmlSchemaCompareValues (xmlSchemaValPtr x, + xmlSchemaValPtr y); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaTypePtr type); +XMLPUBFUN int XMLCALL + xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacetPtr facet, + const xmlChar *value, + unsigned long actualLen, + unsigned long *expectedLen); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetBuiltInType (xmlSchemaValType type); +XMLPUBFUN int XMLCALL + xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type, + int facetType); +XMLPUBFUN xmlChar * XMLCALL + xmlSchemaCollapseString (const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlSchemaWhiteSpaceReplace (const xmlChar *value); +XMLPUBFUN unsigned long XMLCALL + xmlSchemaGetFacetValueAsULong (xmlSchemaFacetPtr facet); +XMLPUBFUN int XMLCALL + xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length); +XMLPUBFUN int XMLCALL + xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, + xmlSchemaValType valType, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN int XMLCALL + xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlSchemaGetCanonValue (xmlSchemaValPtr val, + const xmlChar **retValue); +XMLPUBFUN int XMLCALL + xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val, + const xmlChar **retValue, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN int XMLCALL + xmlSchemaValueAppend (xmlSchemaValPtr prev, + xmlSchemaValPtr cur); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaValueGetNext (xmlSchemaValPtr cur); +XMLPUBFUN const xmlChar * XMLCALL + xmlSchemaValueGetAsString (xmlSchemaValPtr val); +XMLPUBFUN int XMLCALL + xmlSchemaValueGetAsBoolean (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaNewStringValue (xmlSchemaValType type, + const xmlChar *value); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaNewNOTATIONValue (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaNewQNameValue (const xmlChar *namespaceName, + const xmlChar *localName); +XMLPUBFUN int XMLCALL + xmlSchemaCompareValuesWhtsp (xmlSchemaValPtr x, + xmlSchemaWhitespaceValueType xws, + xmlSchemaValPtr y, + xmlSchemaWhitespaceValueType yws); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaCopyValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaValType XMLCALL + xmlSchemaGetValType (xmlSchemaValPtr val); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_TYPES_H__ */ diff --git a/src/include/libxml/xmlstring.h b/src/include/libxml/xmlstring.h new file mode 100644 index 000000000000..2d0b2d1668eb --- /dev/null +++ b/src/include/libxml/xmlstring.h @@ -0,0 +1,140 @@ +/* + * Summary: set of routines to process strings + * Description: type and interfaces needed for the internal string handling + * of the library, especially UTF8 processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_STRING_H__ +#define __XML_STRING_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlChar: + * + * This is a basic byte in an UTF-8 encoded string. + * It's unsigned allowing to pinpoint case where char * are assigned + * to xmlChar * (possibly making serialization back impossible). + */ +typedef unsigned char xmlChar; + +/** + * BAD_CAST: + * + * Macro to cast a string to an xmlChar * when one know its safe. + */ +#define BAD_CAST (xmlChar *) + +/* + * xmlChar handling + */ +XMLPUBFUN xmlChar * XMLCALL + xmlStrdup (const xmlChar *cur); +XMLPUBFUN xmlChar * XMLCALL + xmlStrndup (const xmlChar *cur, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlCharStrndup (const char *cur, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlCharStrdup (const char *cur); +XMLPUBFUN xmlChar * XMLCALL + xmlStrsub (const xmlChar *str, + int start, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrchr (const xmlChar *str, + xmlChar val); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrstr (const xmlChar *str, + const xmlChar *val); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrcasestr (const xmlChar *str, + const xmlChar *val); +XMLPUBFUN int XMLCALL + xmlStrcmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrncmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrcasecmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrncasecmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrEqual (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrQEqual (const xmlChar *pref, + const xmlChar *name, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlStrlen (const xmlChar *str); +XMLPUBFUN xmlChar * XMLCALL + xmlStrcat (xmlChar *cur, + const xmlChar *add); +XMLPUBFUN xmlChar * XMLCALL + xmlStrncat (xmlChar *cur, + const xmlChar *add, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlStrncatNew (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrPrintf (xmlChar *buf, + int len, + const char *msg, + ...) LIBXML_ATTR_FORMAT(3,4); +XMLPUBFUN int XMLCALL + xmlStrVPrintf (xmlChar *buf, + int len, + const char *msg, + va_list ap) LIBXML_ATTR_FORMAT(3,0); + +XMLPUBFUN int XMLCALL + xmlGetUTF8Char (const unsigned char *utf, + int *len); +XMLPUBFUN int XMLCALL + xmlCheckUTF8 (const unsigned char *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Strsize (const xmlChar *utf, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strndup (const xmlChar *utf, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlUTF8Strpos (const xmlChar *utf, + int pos); +XMLPUBFUN int XMLCALL + xmlUTF8Strloc (const xmlChar *utf, + const xmlChar *utfchar); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strsub (const xmlChar *utf, + int start, + int len); +XMLPUBFUN int XMLCALL + xmlUTF8Strlen (const xmlChar *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Size (const xmlChar *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Charcmp (const xmlChar *utf1, + const xmlChar *utf2); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_STRING_H__ */ diff --git a/src/include/libxml/xmlunicode.h b/src/include/libxml/xmlunicode.h new file mode 100644 index 000000000000..01ac8b61f56a --- /dev/null +++ b/src/include/libxml/xmlunicode.h @@ -0,0 +1,202 @@ +/* + * Summary: Unicode character APIs + * Description: API for the Unicode character APIs + * + * This file is automatically generated from the + * UCS description files of the Unicode Character Database + * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html + * using the genUnicode.py Python script. + * + * Generation date: Mon Mar 27 11:09:52 2006 + * Sources: Blocks-4.0.1.txt UnicodeData-4.0.1.txt + * Author: Daniel Veillard + */ + +#ifndef __XML_UNICODE_H__ +#define __XML_UNICODE_H__ + +#include + +#ifdef LIBXML_UNICODE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN int XMLCALL xmlUCSIsAegeanNumbers (int code); +XMLPUBFUN int XMLCALL xmlUCSIsAlphabeticPresentationForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArmenian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArrows (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBasicLatin (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBengali (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBlockElements (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBopomofo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBopomofoExtended (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBoxDrawing (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBraillePatterns (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBuhid (int code); +XMLPUBFUN int XMLCALL xmlUCSIsByzantineMusicalSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibility (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKRadicalsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKSymbolsandPunctuation (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCherokee (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarks (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarksforSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningHalfMarks (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningMarksforSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsControlPictures (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCurrencySymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCypriotSyllabary (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCyrillic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCyrillicSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDeseret (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDevanagari (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDingbats (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEnclosedAlphanumerics (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEnclosedCJKLettersandMonths (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEthiopic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeneralPunctuation (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeometricShapes (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeorgian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGothic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreek (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreekExtended (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreekandCoptic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGujarati (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGurmukhi (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHalfwidthandFullwidthForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulCompatibilityJamo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulJamo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulSyllables (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHanunoo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHebrew (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHighPrivateUseSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHighSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHiragana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsIPAExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsIdeographicDescriptionCharacters (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKanbun (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKangxiRadicals (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKannada (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKatakana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKatakanaPhoneticExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKhmer (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKhmerSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLao (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatin1Supplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedAdditional (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLetterlikeSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLimbu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLinearBIdeograms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLinearBSyllabary (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLowSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMalayalam (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMathematicalAlphanumericSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMathematicalOperators (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbolsandArrows (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousTechnical (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMongolian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMusicalSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMyanmar (int code); +XMLPUBFUN int XMLCALL xmlUCSIsNumberForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOgham (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOldItalic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOpticalCharacterRecognition (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOriya (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOsmanya (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPhoneticExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPrivateUse (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPrivateUseArea (int code); +XMLPUBFUN int XMLCALL xmlUCSIsRunic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsShavian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSinhala (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSmallFormVariants (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSpacingModifierLetters (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSpecials (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSuperscriptsandSubscripts (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalMathematicalOperators (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSyriac (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTagalog (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTagbanwa (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTags (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTaiLe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTaiXuanJingSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTamil (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTelugu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsThaana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsThai (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTibetan (int code); +XMLPUBFUN int XMLCALL xmlUCSIsUgaritic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsUnifiedCanadianAboriginalSyllabics (int code); +XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectors (int code); +XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectorsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYiRadicals (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYiSyllables (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYijingHexagramSymbols (int code); + +XMLPUBFUN int XMLCALL xmlUCSIsBlock (int code, const char *block); + +XMLPUBFUN int XMLCALL xmlUCSIsCatC (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCf (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatL (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLm (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLt (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatM (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMn (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatN (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNd (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatP (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPd (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPf (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPi (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatS (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSk (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSm (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZ (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZp (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZs (int code); + +XMLPUBFUN int XMLCALL xmlUCSIsCat (int code, const char *cat); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_UNICODE_ENABLED */ + +#endif /* __XML_UNICODE_H__ */ diff --git a/src/include/libxml/xmlversion.h.in b/src/include/libxml/xmlversion.h.in new file mode 100644 index 000000000000..c995fe512bdc --- /dev/null +++ b/src/include/libxml/xmlversion.h.in @@ -0,0 +1,485 @@ +/* + * Summary: compile-time version information + * Description: compile-time version information for the XML library + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_VERSION_H__ +#define __XML_VERSION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * use those to be sure nothing nasty will happen if + * your library and includes mismatch + */ +#ifndef LIBXML2_COMPILING_MSCCDEF +XMLPUBFUN void XMLCALL xmlCheckVersion(int version); +#endif /* LIBXML2_COMPILING_MSCCDEF */ + +/** + * LIBXML_DOTTED_VERSION: + * + * the version string like "1.2.3" + */ +#define LIBXML_DOTTED_VERSION "@VERSION@" + +/** + * LIBXML_VERSION: + * + * the version number: 1.2.3 value is 10203 + */ +#define LIBXML_VERSION @LIBXML_VERSION_NUMBER@ + +/** + * LIBXML_VERSION_STRING: + * + * the version number string, 1.2.3 value is "10203" + */ +#define LIBXML_VERSION_STRING "@LIBXML_VERSION_NUMBER@" + +/** + * LIBXML_VERSION_EXTRA: + * + * extra version information, used to show a CVS compilation + */ +#define LIBXML_VERSION_EXTRA "@LIBXML_VERSION_EXTRA@" + +/** + * LIBXML_TEST_VERSION: + * + * Macro to check that the libxml version in use is compatible with + * the version the software has been compiled against + */ +#define LIBXML_TEST_VERSION xmlCheckVersion(@LIBXML_VERSION_NUMBER@); + +#ifndef VMS +#if @WITH_TRIO@ +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO +#else +/** + * WITHOUT_TRIO: + * + * defined if the trio support should not be configured in + */ +#define WITHOUT_TRIO +#endif +#else /* VMS */ +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO 1 +#endif /* VMS */ + +/** + * LIBXML_THREAD_ENABLED: + * + * Whether the thread support is configured in + */ +#if @WITH_THREADS@ +#define LIBXML_THREAD_ENABLED +#endif + +/** + * LIBXML_THREAD_ALLOC_ENABLED: + * + * Whether the allocation hooks are per-thread + */ +#if @WITH_THREAD_ALLOC@ +#define LIBXML_THREAD_ALLOC_ENABLED +#endif + +/** + * LIBXML_TREE_ENABLED: + * + * Whether the DOM like tree manipulation API support is configured in + */ +#if @WITH_TREE@ +#define LIBXML_TREE_ENABLED +#endif + +/** + * LIBXML_OUTPUT_ENABLED: + * + * Whether the serialization/saving support is configured in + */ +#if @WITH_OUTPUT@ +#define LIBXML_OUTPUT_ENABLED +#endif + +/** + * LIBXML_PUSH_ENABLED: + * + * Whether the push parsing interfaces are configured in + */ +#if @WITH_PUSH@ +#define LIBXML_PUSH_ENABLED +#endif + +/** + * LIBXML_READER_ENABLED: + * + * Whether the xmlReader parsing interface is configured in + */ +#if @WITH_READER@ +#define LIBXML_READER_ENABLED +#endif + +/** + * LIBXML_PATTERN_ENABLED: + * + * Whether the xmlPattern node selection interface is configured in + */ +#if @WITH_PATTERN@ +#define LIBXML_PATTERN_ENABLED +#endif + +/** + * LIBXML_WRITER_ENABLED: + * + * Whether the xmlWriter saving interface is configured in + */ +#if @WITH_WRITER@ +#define LIBXML_WRITER_ENABLED +#endif + +/** + * LIBXML_SAX1_ENABLED: + * + * Whether the older SAX1 interface is configured in + */ +#if @WITH_SAX1@ +#define LIBXML_SAX1_ENABLED +#endif + +/** + * LIBXML_FTP_ENABLED: + * + * Whether the FTP support is configured in + */ +#if @WITH_FTP@ +#define LIBXML_FTP_ENABLED +#endif + +/** + * LIBXML_HTTP_ENABLED: + * + * Whether the HTTP support is configured in + */ +#if @WITH_HTTP@ +#define LIBXML_HTTP_ENABLED +#endif + +/** + * LIBXML_VALID_ENABLED: + * + * Whether the DTD validation support is configured in + */ +#if @WITH_VALID@ +#define LIBXML_VALID_ENABLED +#endif + +/** + * LIBXML_HTML_ENABLED: + * + * Whether the HTML support is configured in + */ +#if @WITH_HTML@ +#define LIBXML_HTML_ENABLED +#endif + +/** + * LIBXML_LEGACY_ENABLED: + * + * Whether the deprecated APIs are compiled in for compatibility + */ +#if @WITH_LEGACY@ +#define LIBXML_LEGACY_ENABLED +#endif + +/** + * LIBXML_C14N_ENABLED: + * + * Whether the Canonicalization support is configured in + */ +#if @WITH_C14N@ +#define LIBXML_C14N_ENABLED +#endif + +/** + * LIBXML_CATALOG_ENABLED: + * + * Whether the Catalog support is configured in + */ +#if @WITH_CATALOG@ +#define LIBXML_CATALOG_ENABLED +#endif + +/** + * LIBXML_DOCB_ENABLED: + * + * Whether the SGML Docbook support is configured in + */ +#if @WITH_DOCB@ +#define LIBXML_DOCB_ENABLED +#endif + +/** + * LIBXML_XPATH_ENABLED: + * + * Whether XPath is configured in + */ +#if @WITH_XPATH@ +#define LIBXML_XPATH_ENABLED +#endif + +/** + * LIBXML_XPTR_ENABLED: + * + * Whether XPointer is configured in + */ +#if @WITH_XPTR@ +#define LIBXML_XPTR_ENABLED +#endif + +/** + * LIBXML_XINCLUDE_ENABLED: + * + * Whether XInclude is configured in + */ +#if @WITH_XINCLUDE@ +#define LIBXML_XINCLUDE_ENABLED +#endif + +/** + * LIBXML_ICONV_ENABLED: + * + * Whether iconv support is available + */ +#if @WITH_ICONV@ +#define LIBXML_ICONV_ENABLED +#endif + +/** + * LIBXML_ICU_ENABLED: + * + * Whether icu support is available + */ +#if @WITH_ICU@ +#define LIBXML_ICU_ENABLED +#endif + +/** + * LIBXML_ISO8859X_ENABLED: + * + * Whether ISO-8859-* support is made available in case iconv is not + */ +#if @WITH_ISO8859X@ +#define LIBXML_ISO8859X_ENABLED +#endif + +/** + * LIBXML_DEBUG_ENABLED: + * + * Whether Debugging module is configured in + */ +#if @WITH_DEBUG@ +#define LIBXML_DEBUG_ENABLED +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * Whether the memory debugging is configured in + */ +#if @WITH_MEM_DEBUG@ +#define DEBUG_MEMORY_LOCATION +#endif + +/** + * LIBXML_DEBUG_RUNTIME: + * + * Whether the runtime debugging is configured in + */ +#if @WITH_RUN_DEBUG@ +#define LIBXML_DEBUG_RUNTIME +#endif + +/** + * LIBXML_UNICODE_ENABLED: + * + * Whether the Unicode related interfaces are compiled in + */ +#if @WITH_REGEXPS@ +#define LIBXML_UNICODE_ENABLED +#endif + +/** + * LIBXML_REGEXP_ENABLED: + * + * Whether the regular expressions interfaces are compiled in + */ +#if @WITH_REGEXPS@ +#define LIBXML_REGEXP_ENABLED +#endif + +/** + * LIBXML_AUTOMATA_ENABLED: + * + * Whether the automata interfaces are compiled in + */ +#if @WITH_REGEXPS@ +#define LIBXML_AUTOMATA_ENABLED +#endif + +/** + * LIBXML_EXPR_ENABLED: + * + * Whether the formal expressions interfaces are compiled in + * + * This code is unused and disabled unconditionally for now. + */ +#if 0 +#define LIBXML_EXPR_ENABLED +#endif + +/** + * LIBXML_SCHEMAS_ENABLED: + * + * Whether the Schemas validation interfaces are compiled in + */ +#if @WITH_SCHEMAS@ +#define LIBXML_SCHEMAS_ENABLED +#endif + +/** + * LIBXML_SCHEMATRON_ENABLED: + * + * Whether the Schematron validation interfaces are compiled in + */ +#if @WITH_SCHEMATRON@ +#define LIBXML_SCHEMATRON_ENABLED +#endif + +/** + * LIBXML_MODULES_ENABLED: + * + * Whether the module interfaces are compiled in + */ +#if @WITH_MODULES@ +#define LIBXML_MODULES_ENABLED +/** + * LIBXML_MODULE_EXTENSION: + * + * the string suffix used by dynamic modules (usually shared libraries) + */ +#define LIBXML_MODULE_EXTENSION "@MODULE_EXTENSION@" +#endif + +/** + * LIBXML_ZLIB_ENABLED: + * + * Whether the Zlib support is compiled in + */ +#if @WITH_ZLIB@ +#define LIBXML_ZLIB_ENABLED +#endif + +/** + * LIBXML_LZMA_ENABLED: + * + * Whether the Lzma support is compiled in + */ +#if @WITH_LZMA@ +#define LIBXML_LZMA_ENABLED +#endif + +#ifdef __GNUC__ + +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ + +#ifndef ATTRIBUTE_UNUSED +# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) +# define ATTRIBUTE_UNUSED __attribute__((unused)) +# else +# define ATTRIBUTE_UNUSED +# endif +#endif + +/** + * LIBXML_ATTR_ALLOC_SIZE: + * + * Macro used to indicate to GCC this is an allocator function + */ + +#ifndef LIBXML_ATTR_ALLOC_SIZE +# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) +# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) +# else +# define LIBXML_ATTR_ALLOC_SIZE(x) +# endif +#else +# define LIBXML_ATTR_ALLOC_SIZE(x) +#endif + +/** + * LIBXML_ATTR_FORMAT: + * + * Macro used to indicate to GCC the parameter are printf like + */ + +#ifndef LIBXML_ATTR_FORMAT +# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) +# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args))) +# else +# define LIBXML_ATTR_FORMAT(fmt,args) +# endif +#else +# define LIBXML_ATTR_FORMAT(fmt,args) +#endif + +#else /* ! __GNUC__ */ +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ +#define ATTRIBUTE_UNUSED +/** + * LIBXML_ATTR_ALLOC_SIZE: + * + * Macro used to indicate to GCC this is an allocator function + */ +#define LIBXML_ATTR_ALLOC_SIZE(x) +/** + * LIBXML_ATTR_FORMAT: + * + * Macro used to indicate to GCC the parameter are printf like + */ +#define LIBXML_ATTR_FORMAT(fmt,args) +#endif /* __GNUC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif + + diff --git a/src/include/libxml/xmlwriter.h b/src/include/libxml/xmlwriter.h new file mode 100644 index 000000000000..dd5add341668 --- /dev/null +++ b/src/include/libxml/xmlwriter.h @@ -0,0 +1,488 @@ +/* + * Summary: text writing API for XML + * Description: text writing API for XML + * + * Copy: See Copyright for the status of this software. + * + * Author: Alfred Mickautsch + */ + +#ifndef __XML_XMLWRITER_H__ +#define __XML_XMLWRITER_H__ + +#include + +#ifdef LIBXML_WRITER_ENABLED + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _xmlTextWriter xmlTextWriter; + typedef xmlTextWriter *xmlTextWriterPtr; + +/* + * Constructors & Destructor + */ + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriter(xmlOutputBufferPtr out); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterFilename(const char *uri, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterMemory(xmlBufferPtr buf, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterDoc(xmlDocPtr * doc, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, + int compression); + XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer); + +/* + * Functions + */ + + +/* + * Document + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDocument(xmlTextWriterPtr writer, + const char *version, + const char *encoding, + const char *standalone); + XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr + writer); + +/* + * Comments + */ + XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr + writer); + XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, + const char *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr + writer, + const xmlChar * + content); + +/* + * Elements + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI); + XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr + writer); + +/* + * Elements conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...) + LIBXML_ATTR_FORMAT(5,6); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(5,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * Text + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, + const char *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, + const xmlChar * content, int len); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteRaw(xmlTextWriterPtr writer, + const xmlChar * content); + XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr + writer, + const char + *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr + writer, + const char + *format, + va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer, + const xmlChar * + content); + XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer, + const char *data, + int start, int len); + XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, + const char *data, + int start, int len); + +/* + * Attributes + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartAttribute(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI); + XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr + writer); + +/* + * Attributes conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...) + LIBXML_ATTR_FORMAT(5,6); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(5,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * PI's + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartPI(xmlTextWriterPtr writer, + const xmlChar * target); + XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer); + +/* + * PI conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWritePI(xmlTextWriterPtr writer, + const xmlChar * target, + const xmlChar * content); + +/** + * xmlTextWriterWriteProcessingInstruction: + * + * This macro maps to xmlTextWriterWritePI + */ +#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI + +/* + * CDATA + */ + XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer); + +/* + * CDATA conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, + const char *format, ...) + LIBXML_ATTR_FORMAT(2,3); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(2,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, + const xmlChar * content); + +/* + * DTD + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer); + +/* + * DTD conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, ...) + LIBXML_ATTR_FORMAT(5,6); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, va_list argptr) + LIBXML_ATTR_FORMAT(5,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * subset); + +/** + * xmlTextWriterWriteDocType: + * + * this macro maps to xmlTextWriterWriteDTD + */ +#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD + +/* + * DTD element definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr + writer); + +/* + * DTD element definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD attribute list definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr + writer); + +/* + * DTD attribute list definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD entity definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, + int pe, const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr + writer); + +/* + * DTD entity definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, ...) + LIBXML_ATTR_FORMAT(4,5); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, + va_list argptr) + LIBXML_ATTR_FORMAT(4,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * ndataid); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr + writer, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * + ndataid); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr + writer, int pe, + const xmlChar * name, + const xmlChar * + pubid, + const xmlChar * + sysid, + const xmlChar * + ndataid, + const xmlChar * + content); + +/* + * DTD notation definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + +/* + * Indentation + */ + XMLPUBFUN int XMLCALL + xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent); + XMLPUBFUN int XMLCALL + xmlTextWriterSetIndentString(xmlTextWriterPtr writer, + const xmlChar * str); + + XMLPUBFUN int XMLCALL + xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar); + + +/* + * misc + */ + XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_WRITER_ENABLED */ + +#endif /* __XML_XMLWRITER_H__ */ diff --git a/src/include/libxml/xpath.h b/src/include/libxml/xpath.h new file mode 100644 index 000000000000..539593fa506b --- /dev/null +++ b/src/include/libxml/xpath.h @@ -0,0 +1,564 @@ +/* + * Summary: XML Path Language implementation + * Description: API for the XML Path Language implementation + * + * XML Path Language implementation + * XPath is a language for addressing parts of an XML document, + * designed to be used by both XSLT and XPointer + * http://www.w3.org/TR/xpath + * + * Implements + * W3C Recommendation 16 November 1999 + * http://www.w3.org/TR/1999/REC-xpath-19991116 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_H__ +#define __XML_XPATH_H__ + +#include + +#ifdef LIBXML_XPATH_ENABLED + +#include +#include +#include +#endif /* LIBXML_XPATH_ENABLED */ + +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef __cplusplus +extern "C" { +#endif +#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */ + +#ifdef LIBXML_XPATH_ENABLED + +typedef struct _xmlXPathContext xmlXPathContext; +typedef xmlXPathContext *xmlXPathContextPtr; +typedef struct _xmlXPathParserContext xmlXPathParserContext; +typedef xmlXPathParserContext *xmlXPathParserContextPtr; + +/** + * The set of XPath error codes. + */ + +typedef enum { + XPATH_EXPRESSION_OK = 0, + XPATH_NUMBER_ERROR, + XPATH_UNFINISHED_LITERAL_ERROR, + XPATH_START_LITERAL_ERROR, + XPATH_VARIABLE_REF_ERROR, + XPATH_UNDEF_VARIABLE_ERROR, + XPATH_INVALID_PREDICATE_ERROR, + XPATH_EXPR_ERROR, + XPATH_UNCLOSED_ERROR, + XPATH_UNKNOWN_FUNC_ERROR, + XPATH_INVALID_OPERAND, + XPATH_INVALID_TYPE, + XPATH_INVALID_ARITY, + XPATH_INVALID_CTXT_SIZE, + XPATH_INVALID_CTXT_POSITION, + XPATH_MEMORY_ERROR, + XPTR_SYNTAX_ERROR, + XPTR_RESOURCE_ERROR, + XPTR_SUB_RESOURCE_ERROR, + XPATH_UNDEF_PREFIX_ERROR, + XPATH_ENCODING_ERROR, + XPATH_INVALID_CHAR_ERROR, + XPATH_INVALID_CTXT, + XPATH_STACK_ERROR, + XPATH_FORBID_VARIABLE_ERROR, + XPATH_OP_LIMIT_EXCEEDED, + XPATH_RECURSION_LIMIT_EXCEEDED +} xmlXPathError; + +/* + * A node-set (an unordered collection of nodes without duplicates). + */ +typedef struct _xmlNodeSet xmlNodeSet; +typedef xmlNodeSet *xmlNodeSetPtr; +struct _xmlNodeSet { + int nodeNr; /* number of nodes in the set */ + int nodeMax; /* size of the array as allocated */ + xmlNodePtr *nodeTab; /* array of nodes in no particular order */ + /* @@ with_ns to check whether namespace nodes should be looked at @@ */ +}; + +/* + * An expression is evaluated to yield an object, which + * has one of the following four basic types: + * - node-set + * - boolean + * - number + * - string + * + * @@ XPointer will add more types ! + */ + +typedef enum { + XPATH_UNDEFINED = 0, + XPATH_NODESET = 1, + XPATH_BOOLEAN = 2, + XPATH_NUMBER = 3, + XPATH_STRING = 4, + XPATH_POINT = 5, + XPATH_RANGE = 6, + XPATH_LOCATIONSET = 7, + XPATH_USERS = 8, + XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */ +} xmlXPathObjectType; + +typedef struct _xmlXPathObject xmlXPathObject; +typedef xmlXPathObject *xmlXPathObjectPtr; +struct _xmlXPathObject { + xmlXPathObjectType type; + xmlNodeSetPtr nodesetval; + int boolval; + double floatval; + xmlChar *stringval; + void *user; + int index; + void *user2; + int index2; +}; + +/** + * xmlXPathConvertFunc: + * @obj: an XPath object + * @type: the number of the target type + * + * A conversion function is associated to a type and used to cast + * the new type to primitive values. + * + * Returns -1 in case of error, 0 otherwise + */ +typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type); + +/* + * Extra type: a name and a conversion function. + */ + +typedef struct _xmlXPathType xmlXPathType; +typedef xmlXPathType *xmlXPathTypePtr; +struct _xmlXPathType { + const xmlChar *name; /* the type name */ + xmlXPathConvertFunc func; /* the conversion function */ +}; + +/* + * Extra variable: a name and a value. + */ + +typedef struct _xmlXPathVariable xmlXPathVariable; +typedef xmlXPathVariable *xmlXPathVariablePtr; +struct _xmlXPathVariable { + const xmlChar *name; /* the variable name */ + xmlXPathObjectPtr value; /* the value */ +}; + +/** + * xmlXPathEvalFunc: + * @ctxt: an XPath parser context + * @nargs: the number of arguments passed to the function + * + * An XPath evaluation function, the parameters are on the XPath context stack. + */ + +typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, + int nargs); + +/* + * Extra function: a name and a evaluation function. + */ + +typedef struct _xmlXPathFunct xmlXPathFunct; +typedef xmlXPathFunct *xmlXPathFuncPtr; +struct _xmlXPathFunct { + const xmlChar *name; /* the function name */ + xmlXPathEvalFunc func; /* the evaluation function */ +}; + +/** + * xmlXPathAxisFunc: + * @ctxt: the XPath interpreter context + * @cur: the previous node being explored on that axis + * + * An axis traversal function. To traverse an axis, the engine calls + * the first time with cur == NULL and repeat until the function returns + * NULL indicating the end of the axis traversal. + * + * Returns the next node in that axis or NULL if at the end of the axis. + */ + +typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr cur); + +/* + * Extra axis: a name and an axis function. + */ + +typedef struct _xmlXPathAxis xmlXPathAxis; +typedef xmlXPathAxis *xmlXPathAxisPtr; +struct _xmlXPathAxis { + const xmlChar *name; /* the axis name */ + xmlXPathAxisFunc func; /* the search function */ +}; + +/** + * xmlXPathFunction: + * @ctxt: the XPath interprestation context + * @nargs: the number of arguments + * + * An XPath function. + * The arguments (if any) are popped out from the context stack + * and the result is pushed on the stack. + */ + +typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs); + +/* + * Function and Variable Lookup. + */ + +/** + * xmlXPathVariableLookupFunc: + * @ctxt: an XPath context + * @name: name of the variable + * @ns_uri: the namespace name hosting this variable + * + * Prototype for callbacks used to plug variable lookup in the XPath + * engine. + * + * Returns the XPath object value or NULL if not found. + */ +typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFuncLookupFunc: + * @ctxt: an XPath context + * @name: name of the function + * @ns_uri: the namespace name hosting this function + * + * Prototype for callbacks used to plug function lookup in the XPath + * engine. + * + * Returns the XPath function or NULL if not found. + */ +typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFlags: + * Flags for XPath engine compilation and runtime + */ +/** + * XML_XPATH_CHECKNS: + * + * check namespaces at compilation + */ +#define XML_XPATH_CHECKNS (1<<0) +/** + * XML_XPATH_NOVAR: + * + * forbid variables in expression + */ +#define XML_XPATH_NOVAR (1<<1) + +/** + * xmlXPathContext: + * + * Expression evaluation occurs with respect to a context. + * he context consists of: + * - a node (the context node) + * - a node list (the context node list) + * - a set of variable bindings + * - a function library + * - the set of namespace declarations in scope for the expression + * Following the switch to hash tables, this need to be trimmed up at + * the next binary incompatible release. + * The node may be modified when the context is passed to libxml2 + * for an XPath evaluation so you may need to initialize it again + * before the next call. + */ + +struct _xmlXPathContext { + xmlDocPtr doc; /* The current document */ + xmlNodePtr node; /* The current node */ + + int nb_variables_unused; /* unused (hash table) */ + int max_variables_unused; /* unused (hash table) */ + xmlHashTablePtr varHash; /* Hash table of defined variables */ + + int nb_types; /* number of defined types */ + int max_types; /* max number of types */ + xmlXPathTypePtr types; /* Array of defined types */ + + int nb_funcs_unused; /* unused (hash table) */ + int max_funcs_unused; /* unused (hash table) */ + xmlHashTablePtr funcHash; /* Hash table of defined funcs */ + + int nb_axis; /* number of defined axis */ + int max_axis; /* max number of axis */ + xmlXPathAxisPtr axis; /* Array of defined axis */ + + /* the namespace nodes of the context node */ + xmlNsPtr *namespaces; /* Array of namespaces */ + int nsNr; /* number of namespace in scope */ + void *user; /* function to free */ + + /* extra variables */ + int contextSize; /* the context size */ + int proximityPosition; /* the proximity position */ + + /* extra stuff for XPointer */ + int xptr; /* is this an XPointer context? */ + xmlNodePtr here; /* for here() */ + xmlNodePtr origin; /* for origin() */ + + /* the set of namespace declarations in scope for the expression */ + xmlHashTablePtr nsHash; /* The namespaces hash table */ + xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */ + void *varLookupData; /* variable lookup data */ + + /* Possibility to link in an extra item */ + void *extra; /* needed for XSLT */ + + /* The function name and URI when calling a function */ + const xmlChar *function; + const xmlChar *functionURI; + + /* function lookup function and data */ + xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */ + void *funcLookupData; /* function lookup data */ + + /* temporary namespace lists kept for walking the namespace axis */ + xmlNsPtr *tmpNsList; /* Array of namespaces */ + int tmpNsNr; /* number of namespaces in scope */ + + /* error reporting mechanism */ + void *userData; /* user specific data block */ + xmlStructuredErrorFunc error; /* the callback in case of errors */ + xmlError lastError; /* the last error */ + xmlNodePtr debugNode; /* the source node XSLT */ + + /* dictionary */ + xmlDictPtr dict; /* dictionary if any */ + + int flags; /* flags to control compilation */ + + /* Cache for reusal of XPath objects */ + void *cache; + + /* Resource limits */ + unsigned long opLimit; + unsigned long opCount; + int depth; +}; + +/* + * The structure of a compiled expression form is not public. + */ + +typedef struct _xmlXPathCompExpr xmlXPathCompExpr; +typedef xmlXPathCompExpr *xmlXPathCompExprPtr; + +/** + * xmlXPathParserContext: + * + * An XPath parser context. It contains pure parsing information, + * an xmlXPathContext, and the stack of objects. + */ +struct _xmlXPathParserContext { + const xmlChar *cur; /* the current char being parsed */ + const xmlChar *base; /* the full expression */ + + int error; /* error code */ + + xmlXPathContextPtr context; /* the evaluation context */ + xmlXPathObjectPtr value; /* the current value */ + int valueNr; /* number of values stacked */ + int valueMax; /* max number of values stacked */ + xmlXPathObjectPtr *valueTab; /* stack of values */ + + xmlXPathCompExprPtr comp; /* the precompiled expression */ + int xptr; /* it this an XPointer expression */ + xmlNodePtr ancestor; /* used for walking preceding axis */ + + int valueFrame; /* used to limit Pop on the stack */ +}; + +/************************************************************************ + * * + * Public API * + * * + ************************************************************************/ + +/** + * Objects and Nodesets handling + */ + +XMLPUBVAR double xmlXPathNAN; +XMLPUBVAR double xmlXPathPINF; +XMLPUBVAR double xmlXPathNINF; + +/* These macros may later turn into functions */ +/** + * xmlXPathNodeSetGetLength: + * @ns: a node-set + * + * Implement a functionality similar to the DOM NodeList.length. + * + * Returns the number of nodes in the node-set. + */ +#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0) +/** + * xmlXPathNodeSetItem: + * @ns: a node-set + * @index: index of a node in the set + * + * Implements a functionality similar to the DOM NodeList.item(). + * + * Returns the xmlNodePtr at the given @index in @ns or NULL if + * @index is out of range (0 to length-1) + */ +#define xmlXPathNodeSetItem(ns, index) \ + ((((ns) != NULL) && \ + ((index) >= 0) && ((index) < (ns)->nodeNr)) ? \ + (ns)->nodeTab[(index)] \ + : NULL) +/** + * xmlXPathNodeSetIsEmpty: + * @ns: a node-set + * + * Checks whether @ns is empty or not. + * + * Returns %TRUE if @ns is an empty node-set. + */ +#define xmlXPathNodeSetIsEmpty(ns) \ + (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL)) + + +XMLPUBFUN void XMLCALL + xmlXPathFreeObject (xmlXPathObjectPtr obj); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeSetCreate (xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj); +XMLPUBFUN void XMLCALL + xmlXPathFreeNodeSet (xmlNodeSetPtr obj); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathObjectCopy (xmlXPathObjectPtr val); +XMLPUBFUN int XMLCALL + xmlXPathCmpNodes (xmlNodePtr node1, + xmlNodePtr node2); +/** + * Conversion functions to basic types. + */ +XMLPUBFUN int XMLCALL + xmlXPathCastNumberToBoolean (double val); +XMLPUBFUN int XMLCALL + xmlXPathCastStringToBoolean (const xmlChar * val); +XMLPUBFUN int XMLCALL + xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns); +XMLPUBFUN int XMLCALL + xmlXPathCastToBoolean (xmlXPathObjectPtr val); + +XMLPUBFUN double XMLCALL + xmlXPathCastBooleanToNumber (int val); +XMLPUBFUN double XMLCALL + xmlXPathCastStringToNumber (const xmlChar * val); +XMLPUBFUN double XMLCALL + xmlXPathCastNodeToNumber (xmlNodePtr node); +XMLPUBFUN double XMLCALL + xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns); +XMLPUBFUN double XMLCALL + xmlXPathCastToNumber (xmlXPathObjectPtr val); + +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastBooleanToString (int val); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNumberToString (double val); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNodeToString (xmlNodePtr node); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNodeSetToString (xmlNodeSetPtr ns); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastToString (xmlXPathObjectPtr val); + +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertBoolean (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertNumber (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertString (xmlXPathObjectPtr val); + +/** + * Context handling. + */ +XMLPUBFUN xmlXPathContextPtr XMLCALL + xmlXPathNewContext (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlXPathFreeContext (xmlXPathContextPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXPathContextSetCache(xmlXPathContextPtr ctxt, + int active, + int value, + int options); +/** + * Evaluation functions. + */ +XMLPUBFUN long XMLCALL + xmlXPathOrderDocElems (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXPathSetContextNode (xmlNodePtr node, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNodeEval (xmlNodePtr node, + const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathEvalExpression (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXPathEvalPredicate (xmlXPathContextPtr ctxt, + xmlXPathObjectPtr res); +/** + * Separate compilation/evaluation entry points. + */ +XMLPUBFUN xmlXPathCompExprPtr XMLCALL + xmlXPathCompile (const xmlChar *str); +XMLPUBFUN xmlXPathCompExprPtr XMLCALL + xmlXPathCtxtCompile (xmlXPathContextPtr ctxt, + const xmlChar *str); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathCompiledEval (xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctx); +XMLPUBFUN int XMLCALL + xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp); +#endif /* LIBXML_XPATH_ENABLED */ +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN void XMLCALL + xmlXPathInit (void); +XMLPUBFUN int XMLCALL + xmlXPathIsNaN (double val); +XMLPUBFUN int XMLCALL + xmlXPathIsInf (double val); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*/ +#endif /* ! __XML_XPATH_H__ */ diff --git a/src/include/libxml/xpathInternals.h b/src/include/libxml/xpathInternals.h new file mode 100644 index 000000000000..76a6b481572d --- /dev/null +++ b/src/include/libxml/xpathInternals.h @@ -0,0 +1,632 @@ +/* + * Summary: internal interfaces for XML Path Language implementation + * Description: internal interfaces for XML Path Language implementation + * used to build new modules on top of XPath like XPointer and + * XSLT + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_INTERNALS_H__ +#define __XML_XPATH_INTERNALS_H__ + +#include +#include + +#ifdef LIBXML_XPATH_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************ + * * + * Helpers * + * * + ************************************************************************/ + +/* + * Many of these macros may later turn into functions. They + * shouldn't be used in #ifdef's preprocessor instructions. + */ +/** + * xmlXPathSetError: + * @ctxt: an XPath parser context + * @err: an xmlXPathError code + * + * Raises an error. + */ +#define xmlXPathSetError(ctxt, err) \ + { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \ + if ((ctxt) != NULL) (ctxt)->error = (err); } + +/** + * xmlXPathSetArityError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_ARITY error. + */ +#define xmlXPathSetArityError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_ARITY) + +/** + * xmlXPathSetTypeError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_TYPE error. + */ +#define xmlXPathSetTypeError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_TYPE) + +/** + * xmlXPathGetError: + * @ctxt: an XPath parser context + * + * Get the error code of an XPath context. + * + * Returns the context error. + */ +#define xmlXPathGetError(ctxt) ((ctxt)->error) + +/** + * xmlXPathCheckError: + * @ctxt: an XPath parser context + * + * Check if an XPath error was raised. + * + * Returns true if an error has been raised, false otherwise. + */ +#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK) + +/** + * xmlXPathGetDocument: + * @ctxt: an XPath parser context + * + * Get the document of an XPath context. + * + * Returns the context document. + */ +#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc) + +/** + * xmlXPathGetContextNode: + * @ctxt: an XPath parser context + * + * Get the context node of an XPath context. + * + * Returns the context node. + */ +#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node) + +XMLPUBFUN int XMLCALL + xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt); +XMLPUBFUN double XMLCALL + xmlXPathPopNumber (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathPopString (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void * XMLCALL + xmlXPathPopExternal (xmlXPathParserContextPtr ctxt); + +/** + * xmlXPathReturnBoolean: + * @ctxt: an XPath parser context + * @val: a boolean + * + * Pushes the boolean @val on the context stack. + */ +#define xmlXPathReturnBoolean(ctxt, val) \ + valuePush((ctxt), xmlXPathNewBoolean(val)) + +/** + * xmlXPathReturnTrue: + * @ctxt: an XPath parser context + * + * Pushes true on the context stack. + */ +#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1) + +/** + * xmlXPathReturnFalse: + * @ctxt: an XPath parser context + * + * Pushes false on the context stack. + */ +#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0) + +/** + * xmlXPathReturnNumber: + * @ctxt: an XPath parser context + * @val: a double + * + * Pushes the double @val on the context stack. + */ +#define xmlXPathReturnNumber(ctxt, val) \ + valuePush((ctxt), xmlXPathNewFloat(val)) + +/** + * xmlXPathReturnString: + * @ctxt: an XPath parser context + * @str: a string + * + * Pushes the string @str on the context stack. + */ +#define xmlXPathReturnString(ctxt, str) \ + valuePush((ctxt), xmlXPathWrapString(str)) + +/** + * xmlXPathReturnEmptyString: + * @ctxt: an XPath parser context + * + * Pushes an empty string on the stack. + */ +#define xmlXPathReturnEmptyString(ctxt) \ + valuePush((ctxt), xmlXPathNewCString("")) + +/** + * xmlXPathReturnNodeSet: + * @ctxt: an XPath parser context + * @ns: a node-set + * + * Pushes the node-set @ns on the context stack. + */ +#define xmlXPathReturnNodeSet(ctxt, ns) \ + valuePush((ctxt), xmlXPathWrapNodeSet(ns)) + +/** + * xmlXPathReturnEmptyNodeSet: + * @ctxt: an XPath parser context + * + * Pushes an empty node-set on the context stack. + */ +#define xmlXPathReturnEmptyNodeSet(ctxt) \ + valuePush((ctxt), xmlXPathNewNodeSet(NULL)) + +/** + * xmlXPathReturnExternal: + * @ctxt: an XPath parser context + * @val: user data + * + * Pushes user data on the context stack. + */ +#define xmlXPathReturnExternal(ctxt, val) \ + valuePush((ctxt), xmlXPathWrapExternal(val)) + +/** + * xmlXPathStackIsNodeSet: + * @ctxt: an XPath parser context + * + * Check if the current value on the XPath stack is a node set or + * an XSLT value tree. + * + * Returns true if the current object on the stack is a node-set. + */ +#define xmlXPathStackIsNodeSet(ctxt) \ + (((ctxt)->value != NULL) \ + && (((ctxt)->value->type == XPATH_NODESET) \ + || ((ctxt)->value->type == XPATH_XSLT_TREE))) + +/** + * xmlXPathStackIsExternal: + * @ctxt: an XPath parser context + * + * Checks if the current value on the XPath stack is an external + * object. + * + * Returns true if the current object on the stack is an external + * object. + */ +#define xmlXPathStackIsExternal(ctxt) \ + ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS)) + +/** + * xmlXPathEmptyNodeSet: + * @ns: a node-set + * + * Empties a node-set. + */ +#define xmlXPathEmptyNodeSet(ns) \ + { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; } + +/** + * CHECK_ERROR: + * + * Macro to return from the function if an XPath error was detected. + */ +#define CHECK_ERROR \ + if (ctxt->error != XPATH_EXPRESSION_OK) return + +/** + * CHECK_ERROR0: + * + * Macro to return 0 from the function if an XPath error was detected. + */ +#define CHECK_ERROR0 \ + if (ctxt->error != XPATH_EXPRESSION_OK) return(0) + +/** + * XP_ERROR: + * @X: the error code + * + * Macro to raise an XPath error and return. + */ +#define XP_ERROR(X) \ + { xmlXPathErr(ctxt, X); return; } + +/** + * XP_ERROR0: + * @X: the error code + * + * Macro to raise an XPath error and return 0. + */ +#define XP_ERROR0(X) \ + { xmlXPathErr(ctxt, X); return(0); } + +/** + * CHECK_TYPE: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. + */ +#define CHECK_TYPE(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR(XPATH_INVALID_TYPE) + +/** + * CHECK_TYPE0: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. Return(0) in case of failure + */ +#define CHECK_TYPE0(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR0(XPATH_INVALID_TYPE) + +/** + * CHECK_ARITY: + * @x: the number of expected args + * + * Macro to check that the number of args passed to an XPath function matches. + */ +#define CHECK_ARITY(x) \ + if (ctxt == NULL) return; \ + if (nargs != (x)) \ + XP_ERROR(XPATH_INVALID_ARITY); \ + if (ctxt->valueNr < ctxt->valueFrame + (x)) \ + XP_ERROR(XPATH_STACK_ERROR); + +/** + * CAST_TO_STRING: + * + * Macro to try to cast the value on the top of the XPath stack to a string. + */ +#define CAST_TO_STRING \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \ + xmlXPathStringFunction(ctxt, 1); + +/** + * CAST_TO_NUMBER: + * + * Macro to try to cast the value on the top of the XPath stack to a number. + */ +#define CAST_TO_NUMBER \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \ + xmlXPathNumberFunction(ctxt, 1); + +/** + * CAST_TO_BOOLEAN: + * + * Macro to try to cast the value on the top of the XPath stack to a boolean. + */ +#define CAST_TO_BOOLEAN \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \ + xmlXPathBooleanFunction(ctxt, 1); + +/* + * Variable Lookup forwarding. + */ + +XMLPUBFUN void XMLCALL + xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt, + xmlXPathVariableLookupFunc f, + void *data); + +/* + * Function Lookup forwarding. + */ + +XMLPUBFUN void XMLCALL + xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt, + xmlXPathFuncLookupFunc f, + void *funcCtxt); + +/* + * Error reporting. + */ +XMLPUBFUN void XMLCALL + xmlXPatherror (xmlXPathParserContextPtr ctxt, + const char *file, + int line, + int no); + +XMLPUBFUN void XMLCALL + xmlXPathErr (xmlXPathParserContextPtr ctxt, + int error); + +#ifdef LIBXML_DEBUG_ENABLED +XMLPUBFUN void XMLCALL + xmlXPathDebugDumpObject (FILE *output, + xmlXPathObjectPtr cur, + int depth); +XMLPUBFUN void XMLCALL + xmlXPathDebugDumpCompExpr(FILE *output, + xmlXPathCompExprPtr comp, + int depth); +#endif +/** + * NodeSet handling. + */ +XMLPUBFUN int XMLCALL + xmlXPathNodeSetContains (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDifference (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathIntersection (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDistinctSorted (xmlNodeSetPtr nodes); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDistinct (xmlNodeSetPtr nodes); + +XMLPUBFUN int XMLCALL + xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeLeading (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathLeading (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeTrailing (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathTrailing (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + + +/** + * Extending a context. + */ + +XMLPUBFUN int XMLCALL + xmlXPathRegisterNs (xmlXPathContextPtr ctxt, + const xmlChar *prefix, + const xmlChar *ns_uri); +XMLPUBFUN const xmlChar * XMLCALL + xmlXPathNsLookup (xmlXPathContextPtr ctxt, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt); + +XMLPUBFUN int XMLCALL + xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathFunction f); +XMLPUBFUN int XMLCALL + xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathFunction f); +XMLPUBFUN int XMLCALL + xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathObjectPtr value); +XMLPUBFUN int XMLCALL + xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathObjectPtr value); +XMLPUBFUN xmlXPathFunction XMLCALL + xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathFunction XMLCALL + xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathVariableLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); + +/** + * Utilities to extend XPath. + */ +XMLPUBFUN xmlXPathParserContextPtr XMLCALL + xmlXPathNewParserContext (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); + +/* TODO: remap to xmlXPathValuePop and Push. */ +XMLPUBFUN xmlXPathObjectPtr XMLCALL + valuePop (xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL + valuePush (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr value); + +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewString (const xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewCString (const char *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapString (xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapCString (char * val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewFloat (double val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewBoolean (int val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewNodeSet (xmlNodePtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewValueTree (xmlNodePtr val); +XMLPUBFUN int XMLCALL + xmlXPathNodeSetAdd (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN int XMLCALL + xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN int XMLCALL + xmlXPathNodeSetAddNs (xmlNodeSetPtr cur, + xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetSort (xmlNodeSetPtr set); + +XMLPUBFUN void XMLCALL + xmlXPathRoot (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathParseName (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathParseNCName (xmlXPathParserContextPtr ctxt); + +/* + * Existing functions. + */ +XMLPUBFUN double XMLCALL + xmlXPathStringEvalNumber (const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr res); +XMLPUBFUN void XMLCALL + xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeSetMerge (xmlNodeSetPtr val1, + xmlNodeSetPtr val2); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetDel (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetRemove (xmlNodeSetPtr cur, + int val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewNodeSetList (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapNodeSet (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapExternal (void *val); + +XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); +XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt); + +XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name); + +/* + * Some of the axis navigation routines. + */ +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +/* + * The official core of XPath functions. + */ +XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs); + +/** + * Really internal functions + */ +XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED */ +#endif /* ! __XML_XPATH_INTERNALS_H__ */ diff --git a/src/include/libxml/xpointer.h b/src/include/libxml/xpointer.h new file mode 100644 index 000000000000..b99112b87a10 --- /dev/null +++ b/src/include/libxml/xpointer.h @@ -0,0 +1,114 @@ +/* + * Summary: API to handle XML Pointers + * Description: API to handle XML Pointers + * Base implementation was made accordingly to + * W3C Candidate Recommendation 7 June 2000 + * http://www.w3.org/TR/2000/CR-xptr-20000607 + * + * Added support for the element() scheme described in: + * W3C Proposed Recommendation 13 November 2002 + * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPTR_H__ +#define __XML_XPTR_H__ + +#include + +#ifdef LIBXML_XPTR_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A Location Set + */ +typedef struct _xmlLocationSet xmlLocationSet; +typedef xmlLocationSet *xmlLocationSetPtr; +struct _xmlLocationSet { + int locNr; /* number of locations in the set */ + int locMax; /* size of the array as allocated */ + xmlXPathObjectPtr *locTab;/* array of locations */ +}; + +/* + * Handling of location sets. + */ + +XMLPUBFUN xmlLocationSetPtr XMLCALL + xmlXPtrLocationSetCreate (xmlXPathObjectPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); +XMLPUBFUN xmlLocationSetPtr XMLCALL + xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, + xmlLocationSetPtr val2); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRange (xmlNodePtr start, + int startindex, + xmlNodePtr end, + int endindex); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangePoints (xmlXPathObjectPtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodePoint (xmlNodePtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangePointNode (xmlXPathObjectPtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodes (xmlNodePtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewLocationSetNodes (xmlNodePtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodeObject (xmlNodePtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewCollapsedRange (xmlNodePtr start); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, + xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrWrapLocationSet (xmlLocationSetPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetDel (xmlLocationSetPtr cur, + xmlXPathObjectPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetRemove (xmlLocationSetPtr cur, + int val); + +/* + * Functions. + */ +XMLPUBFUN xmlXPathContextPtr XMLCALL + xmlXPtrNewContext (xmlDocPtr doc, + xmlNodePtr here, + xmlNodePtr origin); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN void XMLCALL + xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt, + int nargs); +XMLPUBFUN xmlNodePtr XMLCALL + xmlXPtrBuildNodeList (xmlXPathObjectPtr obj); +XMLPUBFUN void XMLCALL + xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ +#endif /* __XML_XPTR_H__ */ diff --git a/src/include/win32config.h b/src/include/win32config.h new file mode 100644 index 000000000000..54392f4961e7 --- /dev/null +++ b/src/include/win32config.h @@ -0,0 +1,122 @@ +#ifndef __LIBXML_WIN32_CONFIG__ +#define __LIBXML_WIN32_CONFIG__ + +#define HAVE_CTYPE_H +#define HAVE_STDARG_H +#define HAVE_MALLOC_H +#define HAVE_ERRNO_H +#define SEND_ARG2_CAST +#define GETHOSTBYNAME_ARG_CAST + +#if defined(_WIN32_WCE) +#undef HAVE_ERRNO_H +#include "wincecompat.h" +#else +#define HAVE_SYS_STAT_H +#define HAVE_STAT +#define HAVE_STDLIB_H +#define HAVE_TIME_H +#define HAVE_FCNTL_H +#include +#include +#endif + +#include + +#ifndef ICONV_CONST +#define ICONV_CONST const +#endif + +/* + * Windows platforms may define except + */ +#undef except + +#define HAVE_ISINF +#define HAVE_ISNAN +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) +/* MS C-runtime has functions which can be used in order to determine if + a given floating-point variable contains NaN, (+-)INF. These are + preferred, because floating-point technology is considered proprietary + by MS and we can assume that their functions know more about their + oddities than we do. */ +#include +/* Bjorn Reese figured a quite nice construct for isinf() using the _fpclass + function. */ +#ifndef isinf +#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \ + : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0)) +#endif +/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */ +#ifndef isnan +#define isnan(d) (_isnan(d)) +#endif +#else /* _MSC_VER */ +#ifndef isinf +static int isinf (double d) { + int expon = 0; + double val = frexp (d, &expon); + if (expon == 1025) { + if (val == 0.5) { + return 1; + } else if (val == -0.5) { + return -1; + } else { + return 0; + } + } else { + return 0; + } +} +#endif +#ifndef isnan +static int isnan (double d) { + int expon = 0; + double val = frexp (d, &expon); + if (expon == 1025) { + if (val == 0.5) { + return 0; + } else if (val == -0.5) { + return 0; + } else { + return 1; + } + } else { + return 0; + } +} +#endif +#endif /* _MSC_VER */ + +#if defined(_MSC_VER) +#define mkdir(p,m) _mkdir(p) +#if _MSC_VER < 1900 +#define snprintf _snprintf +#endif +#if _MSC_VER < 1500 +#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a) +#endif +#elif defined(__MINGW32__) +#define mkdir(p,m) _mkdir(p) +#endif + +/* Threading API to use should be specified here for compatibility reasons. + This is however best specified on the compiler's command-line. */ +#if defined(LIBXML_THREAD_ENABLED) +#if !defined(HAVE_PTHREAD_H) && !defined(HAVE_WIN32_THREADS) && !defined(_WIN32_WCE) +#define HAVE_WIN32_THREADS +#endif +#endif + +/* Some third-party libraries far from our control assume the following + is defined, which it is not if we don't include windows.h. */ +#if !defined(FALSE) +#define FALSE 0 +#endif +#if !defined(TRUE) +#define TRUE (!(FALSE)) +#endif + +#endif /* __LIBXML_WIN32_CONFIG__ */ + diff --git a/src/include/wsockcompat.h b/src/include/wsockcompat.h new file mode 100644 index 000000000000..e57ca8ec56ea --- /dev/null +++ b/src/include/wsockcompat.h @@ -0,0 +1,54 @@ +/* include/wsockcompat.h + * Windows -> Berkeley Sockets compatibility things. + */ + +#if !defined __XML_WSOCKCOMPAT_H__ +#define __XML_WSOCKCOMPAT_H__ + +#ifdef _WIN32_WCE +#include +#else +#include +#include + +/* Fix for old MinGW. */ +#ifndef _WINSOCKAPI_ +#define _WINSOCKAPI_ +#endif + +/* the following is a workaround a problem for 'inline' keyword in said + header when compiled with Borland C++ 6 */ +#if defined(__BORLANDC__) && !defined(__cplusplus) +#define inline __inline +#define _inline __inline +#endif + +#include + +/* Check if ws2tcpip.h is a recent version which provides getaddrinfo() */ +#if defined(GetAddrInfo) +#include +#define HAVE_GETADDRINFO +#endif +#endif + +#undef XML_SOCKLEN_T +#define XML_SOCKLEN_T int + +#ifndef ECONNRESET +#define ECONNRESET WSAECONNRESET +#endif +#ifndef EINPROGRESS +#define EINPROGRESS WSAEINPROGRESS +#endif +#ifndef EINTR +#define EINTR WSAEINTR +#endif +#ifndef ESHUTDOWN +#define ESHUTDOWN WSAESHUTDOWN +#endif +#ifndef EWOULDBLOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#endif + +#endif /* __XML_WSOCKCOMPAT_H__ */ diff --git a/src/libxml-2.0-uninstalled.pc.in b/src/libxml-2.0-uninstalled.pc.in new file mode 100644 index 000000000000..60b886b304a8 --- /dev/null +++ b/src/libxml-2.0-uninstalled.pc.in @@ -0,0 +1,12 @@ +prefix= +exec_prefix= +libdir=${pcfiledir} +includedir=${pcfiledir}/include + + +Name: libXML +Version: @VERSION@ +Description: libXML library version2. +Requires: +Libs: -L${libdir} -lxml2 @ICU_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@ +Cflags: -I${includedir} @XML_INCLUDEDIR@ @XML_CFLAGS@ diff --git a/src/libxml-2.0.pc.in b/src/libxml-2.0.pc.in new file mode 100644 index 000000000000..2653a7c56857 --- /dev/null +++ b/src/libxml-2.0.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +modules=@WITH_MODULES@ + +Name: libXML +Version: @VERSION@ +Description: libXML library version2. +Requires: +Libs: -L${libdir} -lxml2 +Libs.private: @ICU_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@ +Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@ diff --git a/src/libxml.3 b/src/libxml.3 new file mode 100644 index 000000000000..b3e9fef0617c --- /dev/null +++ b/src/libxml.3 @@ -0,0 +1,71 @@ +.TH libxml 3 "12 April 2000" +.SH NAME +libxml \- library used to parse XML files +.SH DESCRIPTION +The +.I libxml +library is used to parse XML files. +Its internal document representation is as close as possible to the +.I DOM +(Document Object Model) interface, +an API for accessing XML or HTML structured documents. +.LP +The +.I libxml +library also has a +.IR SAX -like +interface, +which is designed to be compatible with +.IR expat (1). +NOTE: +.IR SAX , +the Simple API for XML, +is a standard interface for event-based XML parsing, +developed collaboratively by the members of the XML-DEV mailing list, +currently hosted by OASIS. +The +.I expat +library is a XML 1.0 parser written in C, +which aims to be fully conforming. +It is currently not a validating XML processor. +.LP +The +.I libxml +library now includes a nearly complete +.I XPath +implementation. +The +.I XPath +(XML Path Language) is a language for addressing parts of an +XML document, +designed to be used by both +.I XSLT +and +.IR XPointer . +.LP +The +.I libxml +library exports Push and Pull type parser interfaces for both XML and +.IR html . +.SH FILES +.TP 2.2i +.B /depot/lib/libxml_2.0.0/libxml.a +static library +.TP +.B /depot/lib/libxml_2.0.0/libxml.so +shared library +.TP +.B /depot/package/libxml_2.0.0/bin/xmllint +binary application for parsing XML files +.SH AUTHORS +Daniel Veillard (daniel@veillard.com). +Red Hat Inc. +Manual page by Ziying Sherwin (sherwin@nlm.nih.gov), +Lister Hill National Center for Biomedical Communications, +U.S. National Library of Medicine. +.SH SEE ALSO +.IR xmllint (1), +.IR libxslt (3), +.IR libexslt (3), +.IR xsltproc (1) +.\" end of manual page diff --git a/src/libxml.h b/src/libxml.h new file mode 100644 index 000000000000..1090729c65eb --- /dev/null +++ b/src/libxml.h @@ -0,0 +1,134 @@ +/* + * libxml.h: internal header only used during the compilation of libxml + * + * See COPYRIGHT for the status of this software + * + * Author: breese@users.sourceforge.net + */ + +#ifndef __XML_LIBXML_H__ +#define __XML_LIBXML_H__ + +#include + +#ifndef NO_LARGEFILE_SOURCE +#ifndef _LARGEFILE_SOURCE +#define _LARGEFILE_SOURCE +#endif +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 +#endif +#endif + +#if defined(macintosh) +#include "config-mac.h" +#elif defined(_WIN32_WCE) +/* + * Windows CE compatibility definitions and functions + * This is needed to compile libxml2 for Windows CE. + * At least I tested it with WinCE 5.0 for Emulator and WinCE 4.2/SH4 target + */ +#include +#include +#else +/* + * Currently supported platforms use either autoconf or + * copy to config.h own "preset" configuration file. + * As result ifdef HAVE_CONFIG_H is omitted here. + */ +#include "config.h" +#include +#endif + +#if defined(__Lynx__) +#include /* pull definition of size_t */ +#include +int snprintf(char *, size_t, const char *, ...); +int vfprintf(FILE *, const char *, va_list); +#endif + +#ifndef WITH_TRIO +#include +#else +/** + * TRIO_REPLACE_STDIO: + * + * This macro is defined if the trio string formatting functions are to + * be used instead of the default stdio ones. + */ +#define TRIO_REPLACE_STDIO +#include "trio.h" +#endif + +#if defined(__clang__) || \ + (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) +#define XML_IGNORE_PEDANTIC_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wpedantic\"") +#define XML_POP_WARNINGS \ + _Pragma("GCC diagnostic pop") +#else +#define XML_IGNORE_PEDANTIC_WARNINGS +#define XML_POP_WARNINGS +#endif + +#if defined(__clang__) || \ + (defined(__GNUC__) && (__GNUC__ >= 8)) +#define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg))) +#else +#define ATTRIBUTE_NO_SANITIZE(arg) +#endif + +/* + * Internal variable indicating if a callback has been registered for + * node creation/destruction. It avoids spending a lot of time in locking + * function while checking if the callback exists. + */ +extern int __xmlRegisterCallbacks; +/* + * internal error reporting routines, shared but not part of the API. + */ +void __xmlIOErr(int domain, int code, const char *extra); +void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2,0); +#ifdef LIBXML_HTML_ENABLED +/* + * internal function of HTML parser needed for xmlParseInNodeContext + * but not part of the API + */ +void __htmlParseContent(void *ctx); +#endif + +/* + * internal global initialization critical section routines. + */ +void __xmlGlobalInitMutexLock(void); +void __xmlGlobalInitMutexUnlock(void); +void __xmlGlobalInitMutexDestroy(void); + +int __xmlInitializeDict(void); + +#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) +/* + * internal thread safe random function + */ +int __xmlRandom(void); +#endif + +XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg); +int xmlInputReadCallbackNop(void *context, char *buffer, int len); + +#ifdef IN_LIBXML +#ifdef __GNUC__ +#ifdef PIC +#ifdef __linux__ +#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3) +#include "elfgcchack.h" +#endif +#endif +#endif +#endif +#endif +#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC) +# define LIBXML_STATIC +#endif +#endif /* ! __XML_LIBXML_H__ */ diff --git a/src/libxml.m4 b/src/libxml.m4 new file mode 100644 index 000000000000..09de9fe2defa --- /dev/null +++ b/src/libxml.m4 @@ -0,0 +1,192 @@ +# Configure paths for LIBXML2 +# Simon Josefsson 2020-02-12 +# Fix autoconf 2.70+ warnings +# Mike Hommey 2004-06-19 +# use CPPFLAGS instead of CFLAGS +# Toshio Kuratomi 2001-04-21 +# Adapted from: +# Configure paths for GLIB +# Owen Taylor 97-11-3 + +dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS +dnl +AC_DEFUN([AM_PATH_XML2],[ +AC_ARG_WITH(xml-prefix, + [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)], + xml_config_prefix="$withval", xml_config_prefix="") +AC_ARG_WITH(xml-exec-prefix, + [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)], + xml_config_exec_prefix="$withval", xml_config_exec_prefix="") +AC_ARG_ENABLE(xmltest, + [ --disable-xmltest Do not try to compile and run a test LIBXML program],, + enable_xmltest=yes) + + if test x$xml_config_exec_prefix != x ; then + xml_config_args="$xml_config_args" + if test x${XML2_CONFIG+set} != xset ; then + XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config + fi + fi + if test x$xml_config_prefix != x ; then + xml_config_args="$xml_config_args --prefix=$xml_config_prefix" + if test x${XML2_CONFIG+set} != xset ; then + XML2_CONFIG=$xml_config_prefix/bin/xml2-config + fi + fi + + AC_PATH_PROG(XML2_CONFIG, xml2-config, no) + min_xml_version=ifelse([$1], ,2.0.0,[$1]) + AC_MSG_CHECKING(for libxml - version >= $min_xml_version) + no_xml="" + if test "$XML2_CONFIG" = "no" ; then + no_xml=yes + else + XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags` + XML_LIBS=`$XML2_CONFIG $xml_config_args --libs` + xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_xmltest" = "xyes" ; then + ac_save_CPPFLAGS="$CPPFLAGS" + ac_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" + LIBS="$XML_LIBS $LIBS" +dnl +dnl Now check if the installed libxml is sufficiently new. +dnl (Also sanity checks the results of xml2-config to some extent) +dnl + rm -f conf.xmltest + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include + +int +main() +{ + int xml_major_version, xml_minor_version, xml_micro_version; + int major, minor, micro; + char *tmp_version; + + system("touch conf.xmltest"); + + /* Capture xml2-config output via autoconf/configure variables */ + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = (char *)strdup("$min_xml_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string from xml2-config\n", "$min_xml_version"); + exit(1); + } + free(tmp_version); + + /* Capture the version information from the header files */ + tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION); + if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) { + printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION"); + exit(1); + } + free(tmp_version); + + /* Compare xml2-config output to the libxml headers */ + if ((xml_major_version != $xml_config_major_version) || + (xml_minor_version != $xml_config_minor_version) || + (xml_micro_version != $xml_config_micro_version)) + { + printf("*** libxml header files (version %d.%d.%d) do not match\n", + xml_major_version, xml_minor_version, xml_micro_version); + printf("*** xml2-config (version %d.%d.%d)\n", + $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version); + return 1; + } +/* Compare the headers to the library to make sure we match */ + /* Less than ideal -- doesn't provide us with return value feedback, + * only exits if there's a serious mismatch between header and library. + */ + LIBXML_TEST_VERSION; + + /* Test that the library is greater than our minimum version */ + if ((xml_major_version > major) || + ((xml_major_version == major) && (xml_minor_version > minor)) || + ((xml_major_version == major) && (xml_minor_version == minor) && + (xml_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of libxml (%d.%d.%d) was found.\n", + xml_major_version, xml_minor_version, xml_micro_version); + printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the xml2-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n"); + printf("*** correct copy of xml2-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + return 1; +} +]])],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + + if test "x$no_xml" = x ; then + AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$XML2_CONFIG" = "no" ; then + echo "*** The xml2-config script installed by LIBXML could not be found" + echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the XML2_CONFIG environment variable to the" + echo "*** full path to xml2-config." + else + if test -f conf.xmltest ; then + : + else + echo "*** Could not run libxml test program, checking why..." + CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" + LIBS="$LIBS $XML_LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ +#include +#include +]], [[ LIBXML_TEST_VERSION; return 0;]])], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding LIBXML or finding the wrong" + echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occurred. This usually means LIBXML was incorrectly installed" + echo "*** or that you have moved LIBXML since it was installed. In the latter case, you" + echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ]) + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + + XML_CPPFLAGS="" + XML_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(XML_CPPFLAGS) + AC_SUBST(XML_LIBS) + rm -f conf.xmltest +]) diff --git a/src/libxml.spec.in b/src/libxml.spec.in new file mode 100644 index 000000000000..11c29ea4c97b --- /dev/null +++ b/src/libxml.spec.in @@ -0,0 +1,209 @@ +%global with_python3 1 + +Summary: Library providing XML and HTML support +Name: libxml2 +Version: @VERSION@ +Release: 1%{?dist}%{?extra_release} +License: MIT +Group: Development/Libraries +Source: ftp://xmlsoft.org/libxml2/libxml2-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-root +BuildRequires: python-devel +%if 0%{?with_python3} +BuildRequires: python3-devel +%endif # with_python3 +BuildRequires: zlib-devel +BuildRequires: pkgconfig +BuildRequires: xz-devel +URL: http://xmlsoft.org/ + +%description +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DtDs, either +at parse time or later once the document has been modified. The output +can be a simple SAX stream or and in-memory DOM like representations. +In this case one can use the built-in XPath and XPointer implementation +to select sub nodes or ranges. A flexible Input/Output mechanism is +available, with existing HTTP and FTP modules and combined to an +URI library. + +%package devel +Summary: Libraries, includes, etc. to develop XML and HTML applications +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} +Requires: zlib-devel +Requires: xz-devel +Requires: pkgconfig + +%description devel +Libraries, include files, etc you can use to develop XML applications. +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DtDs, either +at parse time or later once the document has been modified. The output +can be a simple SAX stream or and in-memory DOM like representations. +In this case one can use the built-in XPath and XPointer implementation +to select sub nodes or ranges. A flexible Input/Output mechanism is +available, with existing HTTP and FTP modules and combined to an +URI library. + +%package static +Summary: Static library for libxml2 +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} + +%description static +Static library for libxml2 provided for specific uses or shaving a few +microseconds when parsing, do not link to them for generic purpose packages. + +%package -n python-%{name} +%{?python_provide:%python_provide python-%{name}} +Summary: Python bindings for the libxml2 library +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} +Obsoletes: %{name}-python < %{version}-%{release} +Provides: %{name}-python = %{version}-%{release} + +%description -n python-%{name} +The libxml2-python package contains a Python 2 module that permits applications +written in the Python programming language, version 2, to use the interface +supplied by the libxml2 library to manipulate XML files. + +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DTDs, either +at parse time or later once the document has been modified. + +%if 0%{?with_python3} +%package -n python3-%{name} +Summary: Python 3 bindings for the libxml2 library +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} +Obsoletes: %{name}-python3 < %{version}-%{release} +Provides: %{name}-python3 = %{version}-%{release} + +%description -n python3-%{name} +The libxml2-python3 package contains a Python 3 module that permits +applications written in the Python programming language, version 3, to use the +interface supplied by the libxml2 library to manipulate XML files. + +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DTDs, either +at parse time or later once the document has been modified. +%endif # with_python3 + +%prep +%setup -q + +mkdir py3doc +cp doc/*.py py3doc +sed -i 's|#!/usr/bin/python |#!%{__python3} |' py3doc/*.py + +%build +%configure +make %{_smp_mflags} + +find doc -type f -exec chmod 0644 \{\} \; + +%install +rm -fr %{buildroot} + +make install DESTDIR=%{buildroot} + +%if 0%{?with_python3} +make clean +%configure --with-python=%{__python3} +make install DESTDIR=%{buildroot} +%endif # with_python3 + + +rm -f $RPM_BUILD_ROOT%{_libdir}/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la +rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libxml2-%{version}/* +rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libxml2-python-%{version}/* +(cd doc/examples ; make clean ; rm -rf .deps Makefile) +gzip -9 -c doc/libxml2-api.xml > doc/libxml2-api.xml.gz + +%check +#disabling python tests from rpm build as broken in Fedora 30 +make PYTHON_SUBDIR="" runtests + +%clean +rm -fr %{buildroot} + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%defattr(-, root, root) + +%doc AUTHORS NEWS README Copyright TODO +%doc %{_mandir}/man1/xmllint.1* +%doc %{_mandir}/man1/xmlcatalog.1* +%doc %{_mandir}/man3/libxml.3* + +%{_libdir}/lib*.so.* +%{_bindir}/xmllint +%{_bindir}/xmlcatalog + +%files devel +%defattr(-, root, root) + +%doc %{_mandir}/man1/xml2-config.1* +%doc AUTHORS NEWS README Copyright +%doc doc/*.html doc/html doc/*.gif doc/*.png +%doc doc/tutorial doc/libxml2-api.xml.gz +%doc doc/examples +%doc %dir %{_datadir}/gtk-doc/html/libxml2 +%doc %{_datadir}/gtk-doc/html/libxml2/*.devhelp +%doc %{_datadir}/gtk-doc/html/libxml2/*.html +%doc %{_datadir}/gtk-doc/html/libxml2/*.png +%doc %{_datadir}/gtk-doc/html/libxml2/*.css + +%{_libdir}/lib*.so +%{_libdir}/*.sh +%{_includedir}/* +%{_bindir}/xml2-config +%{_datadir}/aclocal/libxml.m4 +%{_libdir}/pkgconfig/libxml-2.0.pc +%{_libdir}/cmake/libxml2/libxml2-config.cmake + +%files static +%defattr(-, root, root) + +%{_libdir}/*a + +%files -n python-%{name} +%defattr(-, root, root) + +%{_libdir}/python2*/site-packages/libxml2.py* +%{_libdir}/python2*/site-packages/drv_libxml2.py* +%{_libdir}/python2*/site-packages/libxml2mod* +%doc python/TODO +%doc python/libxml2class.txt +%doc python/tests/*.py +%doc doc/*.py +%doc doc/python.html + +%if 0%{?with_python3} +%files -n python3-%{name} +%defattr(-, root, root) + +%{_libdir}/python3*/site-packages/libxml2.py* +%{_libdir}/python3*/site-packages/drv_libxml2.py* +%{_libdir}/python3*/site-packages/__pycache__/*py* +%{_libdir}/python3*/site-packages/libxml2mod* +%doc python/TODO +%doc python/libxml2class.txt +%doc py3doc/*.py +%doc doc/python.html +%endif # with_python3 + +%changelog +* @RELDATE@ Daniel Veillard +- upstream release @VERSION@ see http://xmlsoft.org/news.html + diff --git a/src/libxml2-config.cmake.cmake.in b/src/libxml2-config.cmake.cmake.in new file mode 100644 index 000000000000..27586aab1539 --- /dev/null +++ b/src/libxml2-config.cmake.cmake.in @@ -0,0 +1,136 @@ +# libxml2-config.cmake +# -------------------- +# +# Libxml2 cmake module. +# This module sets the following variables: +# +# :: +# +# LIBXML2_INCLUDE_DIR - Directory where LibXml2 headers are located. +# LIBXML2_INCLUDE_DIRS - list of the include directories needed to use LibXml2. +# LIBXML2_LIBRARY - path to the LibXml2 library. +# LIBXML2_LIBRARIES - xml2 libraries to link against. +# LIBXML2_DEFINITIONS - the compiler switches required for using LibXml2. +# LIBXML2_VERSION_MAJOR - The major version of libxml2. +# LIBXML2_VERSION_MINOR - The minor version of libxml2. +# LIBXML2_VERSION_PATCH - The patch version of libxml2. +# LIBXML2_VERSION_STRING - version number as a string (ex: "2.3.4") +# LIBXML2_MODULES - whether libxml2 has dso support +# LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2 + +include("${CMAKE_CURRENT_LIST_DIR}/libxml2-export.cmake") + +@PACKAGE_INIT@ + +set(LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@) +set(LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@) +set(LIBXML2_VERSION_PATCH @LIBXML_MICRO_VERSION@) +set(LIBXML2_VERSION_STRING "@VERSION@") +set(LIBXML2_INSTALL_PREFIX ${PACKAGE_PREFIX_DIR}) +set(LIBXML2_INCLUDE_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@/libxml2) +set(LIBXML2_LIBRARY_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@) + +macro(select_library_location target basename) + if(TARGET ${target}) + foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB) + get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG) + get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL) + get_target_property(${basename}_${property}_RELEASE ${target} ${property}_RELEASE) + get_target_property(${basename}_${property}_RELWITHDEBINFO ${target} ${property}_RELWITHDEBINFO) + + if(${basename}_${property}_DEBUG AND ${basename}_${property}_RELEASE) + set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELEASE}) + elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_RELWITHDEBINFO) + set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELWITHDEBINFO}) + elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_MINSIZEREL) + set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_MINSIZEREL}) + elseif(${basename}_${property}_RELEASE) + set(${basename}_LIBRARY ${${basename}_${property}_RELEASE}) + elseif(${basename}_${property}_RELWITHDEBINFO) + set(${basename}_LIBRARY ${${basename}_${property}_RELWITHDEBINFO}) + elseif(${basename}_${property}_MINSIZEREL) + set(${basename}_LIBRARY ${${basename}_${property}_MINSIZEREL}) + elseif(${basename}_${property}_DEBUG) + set(${basename}_LIBRARY ${${basename}_${property}_DEBUG}) + endif() + endforeach() + endif() +endmacro() + +macro(select_executable_location target basename) + if(TARGET ${target}) + get_target_property(${basename}_IMPORTED_LOCATION_DEBUG ${target} IMPORTED_LOCATION_DEBUG) + get_target_property(${basename}_IMPORTED_LOCATION_MINSIZEREL ${target} IMPORTED_LOCATION_MINSIZEREL) + get_target_property(${basename}_IMPORTED_LOCATION_RELEASE ${target} IMPORTED_LOCATION_RELEASE) + get_target_property(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO ${target} IMPORTED_LOCATION_RELWITHDEBINFO) + + if(${basename}_IMPORTED_LOCATION_RELEASE) + set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELEASE}) + elseif(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO) + set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELWITHDEBINFO}) + elseif(${basename}_IMPORTED_LOCATION_MINSIZEREL) + set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_MINSIZEREL}) + elseif(${basename}_IMPORTED_LOCATION_DEBUG) + set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_DEBUG}) + endif() + endif() +endmacro() + +select_library_location(LibXml2::LibXml2 LIBXML2) +select_executable_location(LibXml2::xmlcatalog LIBXML2_XMLCATALOG) +select_executable_location(LibXml2::xmllint LIBXML2_XMLLINT) + +set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY}) +set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR}) + +include(CMakeFindDependencyMacro) + +set(LIBXML2_SHARED @BUILD_SHARED_LIBS@) +set(LIBXML2_WITH_ICONV @LIBXML2_WITH_ICONV@) +set(LIBXML2_WITH_THREADS @LIBXML2_WITH_THREADS@) +set(LIBXML2_WITH_ICU @LIBXML2_WITH_ICU@) +set(LIBXML2_WITH_LZMA @LIBXML2_WITH_LZMA@) +set(LIBXML2_WITH_ZLIB @LIBXML2_WITH_ZLIB@) + +if(LIBXML2_WITH_ICONV) + find_dependency(Iconv) + list(APPEND LIBXML2_LIBRARIES ${Iconv_LIBRARIES}) + list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS}) +endif() + +if(NOT LIBXML2_SHARED) + set(LIBXML2_DEFINITIONS -DLIBXML_STATIC) + + if(LIBXML2_WITH_THREADS) + find_dependency(Threads) + list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + endif() + + if(LIBXML2_WITH_ICU) + find_dependency(ICU COMPONENTS data i18n uc) + list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES}) + endif() + + if(LIBXML2_WITH_LZMA) + find_dependency(LibLZMA) + list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + endif() + + if(LIBXML2_WITH_ZLIB) + find_dependency(ZLIB) + list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES}) + endif() + + if(UNIX) + list(APPEND LIBXML2_LIBRARIES m) + endif() + + if(WIN32) + list(APPEND LIBXML2_LIBRARIES ws2_32) + endif() +endif() + +# whether libxml2 has dso support +set(LIBXML2_MODULES @LIBXML2_WITH_MODULES@) + +mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE) diff --git a/src/libxml2-config.cmake.in b/src/libxml2-config.cmake.in new file mode 100644 index 000000000000..49896900fdbb --- /dev/null +++ b/src/libxml2-config.cmake.in @@ -0,0 +1,115 @@ +# libxml2-config.cmake +# -------------------- +# +# Libxml2 cmake module. +# This module sets the following variables: +# +# :: +# +# LIBXML2_INCLUDE_DIR - Directory where LibXml2 headers are located. +# LIBXML2_INCLUDE_DIRS - list of the include directories needed to use LibXml2. +# LIBXML2_LIBRARY - path to the LibXml2 library. +# LIBXML2_LIBRARIES - xml2 libraries to link against. +# LIBXML2_DEFINITIONS - the compiler switches required for using LibXml2. +# LIBXML2_VERSION_MAJOR - The major version of libxml2. +# LIBXML2_VERSION_MINOR - The minor version of libxml2. +# LIBXML2_VERSION_PATCH - The patch version of libxml2. +# LIBXML2_VERSION_STRING - version number as a string (ex: "2.3.4") +# LIBXML2_MODULES - whether libxml2 has dso support +# LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2 +# +# The following targets are defined: +# +# LibXml2::LibXml2 - the LibXml2 library +# LibXml2::xmllint - the xmllint command-line executable + +get_filename_component(_libxml2_rootdir ${CMAKE_CURRENT_LIST_DIR}/../../../ ABSOLUTE) + +set(LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@) +set(LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@) +set(LIBXML2_VERSION_MICRO @LIBXML_MICRO_VERSION@) +set(LIBXML2_VERSION_STRING "@VERSION@") +set(LIBXML2_DEFINITIONS "@XML_CFLAGS@") +set(LIBXML2_INSTALL_PREFIX ${_libxml2_rootdir}) +set(LIBXML2_INCLUDE_DIR ${_libxml2_rootdir}/include/libxml2) +set(LIBXML2_LIBRARY_DIR ${_libxml2_rootdir}/lib) + +find_library(LIBXML2_LIBRARY NAMES xml2 HINTS ${LIBXML2_LIBRARY_DIR} NO_DEFAULT_PATH) +find_program(LIBXML2_XMLCATALOG_EXECUTABLE NAMES xmlcatalog HINTS ${_libxml2_rootdir}/bin NO_DEFAULT_PATH) +find_program(LIBXML2_XMLLINT_EXECUTABLE NAMES xmllint HINTS ${_libxml2_rootdir}/bin NO_DEFAULT_PATH) + +set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY}) +set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR}) +unset(LIBXML2_INTERFACE_LINK_LIBRARIES) + +include(CMakeFindDependencyMacro) + +set(LIBXML2_WITH_ICONV @WITH_ICONV@) +set(LIBXML2_WITH_THREADS @WITH_THREADS@) +set(LIBXML2_WITH_ICU @WITH_ICU@) +set(LIBXML2_WITH_LZMA @WITH_LZMA@) +set(LIBXML2_WITH_ZLIB @WITH_ZLIB@) + +if(LIBXML2_WITH_ICONV) + find_dependency(Iconv) + list(APPEND LIBXML2_LIBRARIES ${Iconv_LIBRARIES}) + list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "Iconv::Iconv") +endif() + +if(LIBXML2_WITH_THREADS) + find_dependency(Threads) + list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") +endif() + +if(LIBXML2_WITH_ICU) + find_dependency(ICU COMPONENTS data i18n uc) + list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$;\$;\$") +endif() + +if(LIBXML2_WITH_LZMA) + find_dependency(LibLZMA) + list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") +endif() + +if(LIBXML2_WITH_ZLIB) + find_dependency(ZLIB) + list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") +endif() + +if(UNIX) + list(APPEND LIBXML2_LIBRARIES m) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") +endif() + +if(WIN32) + list(APPEND LIBXML2_LIBRARIES ws2_32) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") +endif() + +# whether libxml2 has dso support +set(LIBXML2_MODULES @WITH_MODULES@) + +mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE) + +if(NOT TARGET LibXml2::LibXml2 AND DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS) + add_library(LibXml2::LibXml2 UNKNOWN IMPORTED) + set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBXML2_INTERFACE_LINK_LIBRARIES}") +endif() + +if(NOT TARGET LibXml2::xmlcatalog AND DEFINED LIBXML2_XMLCATALOG_EXECUTABLE) + add_executable(LibXml2::xmlcatalog IMPORTED) + set_target_properties(LibXml2::xmlcatalog PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLCATALOG_EXECUTABLE}") +endif() + +if(NOT TARGET LibXml2::xmllint AND DEFINED LIBXML2_XMLLINT_EXECUTABLE) + add_executable(LibXml2::xmllint IMPORTED) + set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}") +endif() diff --git a/src/libxml2.spec b/src/libxml2.spec new file mode 100644 index 000000000000..b3eca4f01d12 --- /dev/null +++ b/src/libxml2.spec @@ -0,0 +1,209 @@ +%global with_python3 1 + +Summary: Library providing XML and HTML support +Name: libxml2 +Version: 2.9.12 +Release: 1%{?dist}%{?extra_release} +License: MIT +Group: Development/Libraries +Source: ftp://xmlsoft.org/libxml2/libxml2-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-root +BuildRequires: python-devel +%if 0%{?with_python3} +BuildRequires: python3-devel +%endif # with_python3 +BuildRequires: zlib-devel +BuildRequires: pkgconfig +BuildRequires: xz-devel +URL: http://xmlsoft.org/ + +%description +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DtDs, either +at parse time or later once the document has been modified. The output +can be a simple SAX stream or and in-memory DOM like representations. +In this case one can use the built-in XPath and XPointer implementation +to select sub nodes or ranges. A flexible Input/Output mechanism is +available, with existing HTTP and FTP modules and combined to an +URI library. + +%package devel +Summary: Libraries, includes, etc. to develop XML and HTML applications +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} +Requires: zlib-devel +Requires: xz-devel +Requires: pkgconfig + +%description devel +Libraries, include files, etc you can use to develop XML applications. +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DtDs, either +at parse time or later once the document has been modified. The output +can be a simple SAX stream or and in-memory DOM like representations. +In this case one can use the built-in XPath and XPointer implementation +to select sub nodes or ranges. A flexible Input/Output mechanism is +available, with existing HTTP and FTP modules and combined to an +URI library. + +%package static +Summary: Static library for libxml2 +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} + +%description static +Static library for libxml2 provided for specific uses or shaving a few +microseconds when parsing, do not link to them for generic purpose packages. + +%package -n python-%{name} +%{?python_provide:%python_provide python-%{name}} +Summary: Python bindings for the libxml2 library +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} +Obsoletes: %{name}-python < %{version}-%{release} +Provides: %{name}-python = %{version}-%{release} + +%description -n python-%{name} +The libxml2-python package contains a Python 2 module that permits applications +written in the Python programming language, version 2, to use the interface +supplied by the libxml2 library to manipulate XML files. + +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DTDs, either +at parse time or later once the document has been modified. + +%if 0%{?with_python3} +%package -n python3-%{name} +Summary: Python 3 bindings for the libxml2 library +Group: Development/Libraries +Requires: libxml2 = %{version}-%{release} +Obsoletes: %{name}-python3 < %{version}-%{release} +Provides: %{name}-python3 = %{version}-%{release} + +%description -n python3-%{name} +The libxml2-python3 package contains a Python 3 module that permits +applications written in the Python programming language, version 3, to use the +interface supplied by the libxml2 library to manipulate XML files. + +This library allows to manipulate XML files. It includes support +to read, modify and write XML and HTML files. There is DTDs support +this includes parsing and validation even with complex DTDs, either +at parse time or later once the document has been modified. +%endif # with_python3 + +%prep +%setup -q + +mkdir py3doc +cp doc/*.py py3doc +sed -i 's|#!/usr/bin/python |#!%{__python3} |' py3doc/*.py + +%build +%configure +make %{_smp_mflags} + +find doc -type f -exec chmod 0644 \{\} \; + +%install +rm -fr %{buildroot} + +make install DESTDIR=%{buildroot} + +%if 0%{?with_python3} +make clean +%configure --with-python=%{__python3} +make install DESTDIR=%{buildroot} +%endif # with_python3 + + +rm -f $RPM_BUILD_ROOT%{_libdir}/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la +rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libxml2-%{version}/* +rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libxml2-python-%{version}/* +(cd doc/examples ; make clean ; rm -rf .deps Makefile) +gzip -9 -c doc/libxml2-api.xml > doc/libxml2-api.xml.gz + +%check +#disabling python tests from rpm build as broken in Fedora 30 +make PYTHON_SUBDIR="" runtests + +%clean +rm -fr %{buildroot} + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%defattr(-, root, root) + +%doc AUTHORS NEWS README Copyright TODO +%doc %{_mandir}/man1/xmllint.1* +%doc %{_mandir}/man1/xmlcatalog.1* +%doc %{_mandir}/man3/libxml.3* + +%{_libdir}/lib*.so.* +%{_bindir}/xmllint +%{_bindir}/xmlcatalog + +%files devel +%defattr(-, root, root) + +%doc %{_mandir}/man1/xml2-config.1* +%doc AUTHORS NEWS README Copyright +%doc doc/*.html doc/html doc/*.gif doc/*.png +%doc doc/tutorial doc/libxml2-api.xml.gz +%doc doc/examples +%doc %dir %{_datadir}/gtk-doc/html/libxml2 +%doc %{_datadir}/gtk-doc/html/libxml2/*.devhelp +%doc %{_datadir}/gtk-doc/html/libxml2/*.html +%doc %{_datadir}/gtk-doc/html/libxml2/*.png +%doc %{_datadir}/gtk-doc/html/libxml2/*.css + +%{_libdir}/lib*.so +%{_libdir}/*.sh +%{_includedir}/* +%{_bindir}/xml2-config +%{_datadir}/aclocal/libxml.m4 +%{_libdir}/pkgconfig/libxml-2.0.pc +%{_libdir}/cmake/libxml2/libxml2-config.cmake + +%files static +%defattr(-, root, root) + +%{_libdir}/*a + +%files -n python-%{name} +%defattr(-, root, root) + +%{_libdir}/python2*/site-packages/libxml2.py* +%{_libdir}/python2*/site-packages/drv_libxml2.py* +%{_libdir}/python2*/site-packages/libxml2mod* +%doc python/TODO +%doc python/libxml2class.txt +%doc python/tests/*.py +%doc doc/*.py +%doc doc/python.html + +%if 0%{?with_python3} +%files -n python3-%{name} +%defattr(-, root, root) + +%{_libdir}/python3*/site-packages/libxml2.py* +%{_libdir}/python3*/site-packages/drv_libxml2.py* +%{_libdir}/python3*/site-packages/__pycache__/*py* +%{_libdir}/python3*/site-packages/libxml2mod* +%doc python/TODO +%doc python/libxml2class.txt +%doc py3doc/*.py +%doc doc/python.html +%endif # with_python3 + +%changelog +* Tue Aug 3 2021 Daniel Veillard +- upstream release 2.9.12 see http://xmlsoft.org/news.html + diff --git a/src/libxml2.syms b/src/libxml2.syms new file mode 100644 index 000000000000..33bc112c14f0 --- /dev/null +++ b/src/libxml2.syms @@ -0,0 +1,2295 @@ +# +# Officially exported symbols, for which header +# file definitions are installed in /usr/include/libxml2 +# +# Automatically generated from symbols.xml and syms.xsl +# +# Versions here are *fixed* to match the libxml2 version +# at which the symbol was introduced. This ensures that +# a new client app requiring symbol foo() can't accidentally +# run with old libxml2.so not providing foo() - the global +# soname version info can't enforce this since we never +# change the soname +# + +LIBXML2_2.4.30 { + global: + +# debugXML + xmlBoolToText; + xmlDebugDumpAttr; + xmlDebugDumpAttrList; + xmlDebugDumpDTD; + xmlDebugDumpDocument; + xmlDebugDumpDocumentHead; + xmlDebugDumpEntities; + xmlDebugDumpNode; + xmlDebugDumpNodeList; + xmlDebugDumpOneNode; + xmlDebugDumpString; + xmlLsCountNode; + xmlLsOneNode; + xmlShell; + xmlShellBase; + xmlShellCat; + xmlShellDir; + xmlShellDu; + xmlShellList; + xmlShellLoad; + xmlShellPrintNode; + xmlShellPrintXPathError; + xmlShellPrintXPathResult; + xmlShellPwd; + xmlShellSave; + xmlShellValidate; + xmlShellWrite; + +# xpointer + xmlXPtrBuildNodeList; + xmlXPtrEval; + xmlXPtrEvalRangePredicate; + xmlXPtrFreeLocationSet; + xmlXPtrLocationSetAdd; + xmlXPtrLocationSetCreate; + xmlXPtrLocationSetDel; + xmlXPtrLocationSetMerge; + xmlXPtrLocationSetRemove; + xmlXPtrNewCollapsedRange; + xmlXPtrNewContext; + xmlXPtrNewLocationSetNodeSet; + xmlXPtrNewLocationSetNodes; + xmlXPtrNewRange; + xmlXPtrNewRangeNodeObject; + xmlXPtrNewRangeNodePoint; + xmlXPtrNewRangeNodes; + xmlXPtrNewRangePointNode; + xmlXPtrNewRangePoints; + xmlXPtrRangeToFunction; + xmlXPtrWrapLocationSet; + +# SAX + attribute; + attributeDecl; + cdataBlock; + characters; + checkNamespace; + comment; + +# SAX2 + docbDefaultSAXHandlerInit; + +# SAX + elementDecl; + endDocument; + endElement; + entityDecl; + externalSubset; + getColumnNumber; + getEntity; + getLineNumber; + getNamespace; + getParameterEntity; + getPublicId; + getSystemId; + globalNamespace; + hasExternalSubset; + hasInternalSubset; + +# SAX2 + htmlDefaultSAXHandlerInit; + +# SAX + ignorableWhitespace; + initdocbDefaultSAXHandler; + inithtmlDefaultSAXHandler; + initxmlDefaultSAXHandler; + internalSubset; + isStandalone; + namespaceDecl; + notationDecl; + processingInstruction; + reference; + resolveEntity; + setDocumentLocator; + setNamespace; + startDocument; + startElement; + unparsedEntityDecl; + +# SAX2 + xmlDefaultSAXHandlerInit; + +# parserInternals + htmlCreateFileParserCtxt; + htmlInitAutoClose; + inputPop; + inputPush; + namePop; + namePush; + nodePop; + nodePush; + xmlCheckLanguageID; + xmlCopyChar; + xmlCopyCharMultiByte; + xmlCreateEntityParserCtxt; + xmlCreateFileParserCtxt; + xmlCreateMemoryParserCtxt; + xmlCurrentChar; + xmlDecodeEntities; + xmlFreeInputStream; + xmlHandleEntity; + +# chvalid + xmlIsBaseChar; + xmlIsBlank; + xmlIsChar; + xmlIsCombining; + xmlIsDigit; + xmlIsExtender; + xmlIsIdeographic; + +# parserInternals + xmlIsLetter; + +# chvalid + xmlIsPubidChar; + +# parserInternals + xmlNamespaceParseNCName; + xmlNamespaceParseNSDef; + xmlNamespaceParseQName; + xmlNewEntityInputStream; + xmlNewInputFromFile; + xmlNewInputStream; + +# parser + xmlNewParserCtxt; + +# parserInternals + xmlNewStringInputStream; + xmlNextChar; + xmlParseAttValue; + xmlParseAttribute; + xmlParseAttributeListDecl; + xmlParseAttributeType; + xmlParseCDSect; + xmlParseCharData; + xmlParseCharRef; + xmlParseComment; + xmlParseContent; + xmlParseDefaultDecl; + xmlParseDocTypeDecl; + xmlParseElement; + xmlParseElementChildrenContentDecl; + xmlParseElementContentDecl; + xmlParseElementDecl; + xmlParseElementMixedContentDecl; + xmlParseEncName; + xmlParseEncodingDecl; + xmlParseEndTag; + xmlParseEntityDecl; + xmlParseEntityRef; + xmlParseEntityValue; + xmlParseEnumeratedType; + xmlParseEnumerationType; + xmlParseExternalID; + xmlParseExternalSubset; + xmlParseMarkupDecl; + xmlParseMisc; + xmlParseName; + xmlParseNamespace; + xmlParseNmtoken; + xmlParseNotationDecl; + xmlParseNotationType; + xmlParsePEReference; + xmlParsePI; + xmlParsePITarget; + xmlParsePubidLiteral; + xmlParseQuotedString; + xmlParseReference; + xmlParseSDDecl; + xmlParseStartTag; + xmlParseSystemLiteral; + xmlParseTextDecl; + xmlParseVersionInfo; + xmlParseVersionNum; + xmlParseXMLDecl; + xmlParserHandlePEReference; + xmlParserHandleReference; + xmlParserInputShrink; + xmlPopInput; + xmlPushInput; + xmlScanName; + xmlSetEntityReferenceFunc; + xmlSkipBlankChars; + xmlSplitQName; + xmlStringComment; # variable + xmlStringCurrentChar; + xmlStringDecodeEntities; + xmlStringText; # variable + xmlStringTextNoenc; # variable + xmlSwitchEncoding; + xmlSwitchToEncoding; + +# c14n + xmlC14NDocDumpMemory; + xmlC14NDocSave; + xmlC14NDocSaveTo; + xmlC14NExecute; + +# catalog + xmlACatalogAdd; + xmlACatalogDump; + xmlACatalogRemove; + xmlACatalogResolve; + xmlACatalogResolvePublic; + xmlACatalogResolveSystem; + xmlACatalogResolveURI; + xmlCatalogAdd; + xmlCatalogAddLocal; + xmlCatalogCleanup; + xmlCatalogConvert; + xmlCatalogDump; + xmlCatalogFreeLocal; + xmlCatalogGetDefaults; + xmlCatalogGetPublic; + xmlCatalogGetSystem; + xmlCatalogIsEmpty; + xmlCatalogLocalResolve; + xmlCatalogLocalResolveURI; + xmlCatalogRemove; + xmlCatalogResolve; + xmlCatalogResolvePublic; + xmlCatalogResolveSystem; + xmlCatalogResolveURI; + xmlCatalogSetDebug; + xmlCatalogSetDefaultPrefer; + xmlCatalogSetDefaults; + xmlConvertSGMLCatalog; + xmlFreeCatalog; + xmlInitializeCatalog; + xmlLoadACatalog; + xmlLoadCatalog; + xmlLoadCatalogs; + xmlLoadSGMLSuperCatalog; + xmlNewCatalog; + xmlParseCatalogFile; + +# xpathInternals + valuePop; + valuePush; + xmlXPathAddValues; + xmlXPathBooleanFunction; + xmlXPathCeilingFunction; + xmlXPathCompareValues; + xmlXPathConcatFunction; + xmlXPathContainsFunction; + xmlXPathCountFunction; + xmlXPathDebugDumpCompExpr; + xmlXPathDebugDumpObject; + xmlXPathDifference; + xmlXPathDistinct; + xmlXPathDistinctSorted; + xmlXPathDivValues; + xmlXPathEqualValues; + xmlXPathEvalExpr; + xmlXPathEvaluatePredicateResult; + xmlXPathFalseFunction; + xmlXPathFloorFunction; + xmlXPathFreeParserContext; + xmlXPathFunctionLookup; + xmlXPathFunctionLookupNS; + xmlXPathHasSameNodes; + xmlXPathIdFunction; + xmlXPathIntersection; + xmlXPathIsNodeType; + xmlXPathLangFunction; + xmlXPathLastFunction; + xmlXPathLeading; + xmlXPathLeadingSorted; + xmlXPathLocalNameFunction; + xmlXPathModValues; + xmlXPathMultValues; + xmlXPathNamespaceURIFunction; + xmlXPathNewBoolean; + xmlXPathNewCString; + xmlXPathNewFloat; + xmlXPathNewNodeSet; + xmlXPathNewNodeSetList; + xmlXPathNewParserContext; + xmlXPathNewString; + xmlXPathNewValueTree; + xmlXPathNextAncestor; + xmlXPathNextAncestorOrSelf; + xmlXPathNextAttribute; + xmlXPathNextChild; + xmlXPathNextDescendant; + xmlXPathNextDescendantOrSelf; + xmlXPathNextFollowing; + xmlXPathNextFollowingSibling; + xmlXPathNextNamespace; + xmlXPathNextParent; + xmlXPathNextPreceding; + xmlXPathNextPrecedingSibling; + xmlXPathNextSelf; + xmlXPathNodeLeading; + xmlXPathNodeLeadingSorted; + xmlXPathNodeSetAdd; + xmlXPathNodeSetAddNs; + xmlXPathNodeSetAddUnique; + xmlXPathNodeSetContains; + xmlXPathNodeSetDel; + xmlXPathNodeSetFreeNs; + xmlXPathNodeSetMerge; + xmlXPathNodeSetRemove; + xmlXPathNodeSetSort; + xmlXPathNodeTrailing; + xmlXPathNodeTrailingSorted; + xmlXPathNormalizeFunction; + xmlXPathNotEqualValues; + xmlXPathNotFunction; + xmlXPathNsLookup; + xmlXPathNumberFunction; + xmlXPathParseNCName; + xmlXPathParseName; + xmlXPathPopBoolean; + xmlXPathPopExternal; + xmlXPathPopNodeSet; + xmlXPathPopNumber; + xmlXPathPopString; + xmlXPathPositionFunction; + xmlXPathRegisterAllFunctions; + xmlXPathRegisterFunc; + xmlXPathRegisterFuncLookup; + xmlXPathRegisterFuncNS; + xmlXPathRegisterNs; + xmlXPathRegisterVariable; + xmlXPathRegisterVariableLookup; + xmlXPathRegisterVariableNS; + xmlXPathRegisteredFuncsCleanup; + xmlXPathRegisteredNsCleanup; + xmlXPathRegisteredVariablesCleanup; + xmlXPathRoot; + xmlXPathRoundFunction; + xmlXPathStartsWithFunction; + xmlXPathStringEvalNumber; + xmlXPathStringFunction; + xmlXPathStringLengthFunction; + xmlXPathSubValues; + xmlXPathSubstringAfterFunction; + xmlXPathSubstringBeforeFunction; + xmlXPathSubstringFunction; + xmlXPathSumFunction; + xmlXPathTrailing; + xmlXPathTrailingSorted; + xmlXPathTranslateFunction; + xmlXPathTrueFunction; + xmlXPathValueFlipSign; + xmlXPathVariableLookup; + xmlXPathVariableLookupNS; + xmlXPathWrapCString; + xmlXPathWrapExternal; + xmlXPathWrapNodeSet; + xmlXPathWrapString; + xmlXPatherror; + +# xmlautomata + xmlAutomataCompile; + xmlAutomataGetInitState; + xmlAutomataIsDeterminist; + xmlAutomataNewAllTrans; + xmlAutomataNewCountTrans; + xmlAutomataNewCountedTrans; + xmlAutomataNewCounter; + xmlAutomataNewCounterTrans; + xmlAutomataNewEpsilon; + xmlAutomataNewOnceTrans; + xmlAutomataNewState; + xmlAutomataNewTransition; + xmlAutomataSetFinalState; + xmlFreeAutomata; + xmlNewAutomata; + +# HTMLtree + htmlDocContentDumpFormatOutput; + htmlDocContentDumpOutput; + htmlDocDump; + htmlDocDumpMemory; + htmlGetMetaEncoding; + htmlIsBooleanAttr; + htmlNewDoc; + htmlNewDocNoDtD; + htmlNodeDump; + htmlNodeDumpFile; + htmlNodeDumpFileFormat; + htmlNodeDumpFormatOutput; + htmlNodeDumpOutput; + htmlSaveFile; + htmlSaveFileEnc; + htmlSaveFileFormat; + htmlSetMetaEncoding; + +# nanoftp + xmlNanoFTPCheckResponse; + xmlNanoFTPCleanup; + xmlNanoFTPClose; + xmlNanoFTPCloseConnection; + xmlNanoFTPConnect; + xmlNanoFTPConnectTo; + xmlNanoFTPCwd; + xmlNanoFTPFreeCtxt; + xmlNanoFTPGet; + xmlNanoFTPGetConnection; + xmlNanoFTPGetResponse; + xmlNanoFTPGetSocket; + xmlNanoFTPInit; + xmlNanoFTPList; + xmlNanoFTPNewCtxt; + xmlNanoFTPOpen; + xmlNanoFTPProxy; + xmlNanoFTPQuit; + xmlNanoFTPRead; + xmlNanoFTPScanProxy; + xmlNanoFTPUpdateURL; + +# DOCBparser + docbCreateFileParserCtxt; + docbCreatePushParserCtxt; + docbEncodeEntities; + docbFreeParserCtxt; + docbParseChunk; + docbParseDoc; + docbParseDocument; + docbParseFile; + docbSAXParseDoc; + docbSAXParseFile; + +# xpath + xmlXPathCastBooleanToNumber; + xmlXPathCastBooleanToString; + xmlXPathCastNodeSetToBoolean; + xmlXPathCastNodeSetToNumber; + xmlXPathCastNodeSetToString; + xmlXPathCastNodeToNumber; + xmlXPathCastNodeToString; + xmlXPathCastNumberToBoolean; + xmlXPathCastNumberToString; + xmlXPathCastStringToBoolean; + xmlXPathCastStringToNumber; + xmlXPathCastToBoolean; + xmlXPathCastToNumber; + xmlXPathCastToString; + xmlXPathCmpNodes; + xmlXPathCompile; + xmlXPathCompiledEval; + xmlXPathConvertBoolean; + xmlXPathConvertNumber; + xmlXPathConvertString; + xmlXPathEval; + xmlXPathEvalExpression; + xmlXPathEvalPredicate; + xmlXPathFreeCompExpr; + xmlXPathFreeContext; + xmlXPathFreeNodeSet; + xmlXPathFreeNodeSetList; + xmlXPathFreeObject; + xmlXPathInit; + xmlXPathIsInf; + xmlXPathIsNaN; + xmlXPathNAN; # variable + xmlXPathNINF; # variable + xmlXPathNewContext; + xmlXPathNodeSetCreate; + xmlXPathObjectCopy; + xmlXPathPINF; # variable + +# xlink + xlinkGetDefaultDetect; + xlinkGetDefaultHandler; + xlinkIsLink; + xlinkSetDefaultDetect; + xlinkSetDefaultHandler; + +# entities + xmlAddDocEntity; + xmlAddDtdEntity; + xmlCleanupPredefinedEntities; + xmlCopyEntitiesTable; + xmlCreateEntitiesTable; + xmlDumpEntitiesTable; + xmlDumpEntityDecl; + xmlEncodeEntities; + xmlEncodeEntitiesReentrant; + xmlEncodeSpecialChars; + xmlFreeEntitiesTable; + xmlGetDocEntity; + xmlGetDtdEntity; + xmlGetParameterEntity; + xmlGetPredefinedEntity; + xmlInitializePredefinedEntities; + +# xinclude + xmlXIncludeProcess; + +# list + xmlLinkGetData; + xmlListAppend; + xmlListClear; + xmlListCopy; + xmlListCreate; + xmlListDelete; + xmlListDup; + xmlListEmpty; + xmlListEnd; + xmlListFront; + xmlListInsert; + xmlListMerge; + xmlListPopBack; + xmlListPopFront; + xmlListPushBack; + xmlListPushFront; + xmlListRemoveAll; + xmlListRemoveFirst; + xmlListRemoveLast; + xmlListReverse; + xmlListReverseSearch; + xmlListReverseWalk; + xmlListSearch; + xmlListSize; + xmlListSort; + xmlListWalk; + +# xmlmemory + xmlInitMemory; + xmlMallocLoc; + xmlMemDisplay; + xmlMemFree; + xmlMemGet; + xmlMemMalloc; + xmlMemRealloc; + xmlMemSetup; + xmlMemShow; + xmlMemStrdupLoc; + xmlMemUsed; + xmlMemoryDump; + xmlMemoryStrdup; + xmlReallocLoc; + +# xmlIO + xmlAllocOutputBuffer; + xmlAllocParserInputBuffer; + xmlCheckFilename; + xmlCleanupInputCallbacks; + xmlCleanupOutputCallbacks; + xmlFileClose; + xmlFileMatch; + xmlFileOpen; + xmlFileRead; + xmlFreeParserInputBuffer; + xmlIOFTPClose; + xmlIOFTPMatch; + xmlIOFTPOpen; + xmlIOFTPRead; + xmlIOHTTPClose; + xmlIOHTTPMatch; + xmlIOHTTPOpen; + xmlIOHTTPOpenW; + xmlIOHTTPRead; + xmlNoNetExternalEntityLoader; + xmlNormalizeWindowsPath; + xmlOutputBufferClose; + xmlOutputBufferCreateFd; + xmlOutputBufferCreateFile; + xmlOutputBufferCreateFilename; + xmlOutputBufferCreateIO; + xmlOutputBufferFlush; + xmlOutputBufferWrite; + xmlOutputBufferWriteString; + xmlParserGetDirectory; + xmlParserInputBufferCreateFd; + xmlParserInputBufferCreateFile; + xmlParserInputBufferCreateFilename; + xmlParserInputBufferCreateIO; + xmlParserInputBufferCreateMem; + xmlParserInputBufferGrow; + xmlParserInputBufferPush; + xmlParserInputBufferRead; + xmlRegisterDefaultInputCallbacks; + xmlRegisterDefaultOutputCallbacks; + xmlRegisterHTTPPostCallbacks; + xmlRegisterInputCallbacks; + xmlRegisterOutputCallbacks; + +# xmlversion + xmlCheckVersion; + +# valid + xmlAddAttributeDecl; + xmlAddElementDecl; + xmlAddID; + xmlAddNotationDecl; + xmlAddRef; + xmlCopyAttributeTable; + xmlCopyElementContent; + xmlCopyElementTable; + xmlCopyEnumeration; + xmlCopyNotationTable; + xmlCreateEnumeration; + xmlDumpAttributeDecl; + xmlDumpAttributeTable; + xmlDumpElementDecl; + xmlDumpElementTable; + xmlDumpNotationDecl; + xmlDumpNotationTable; + xmlFreeAttributeTable; + xmlFreeElementContent; + xmlFreeElementTable; + xmlFreeEnumeration; + xmlFreeIDTable; + xmlFreeNotationTable; + xmlFreeRefTable; + xmlGetDtdAttrDesc; + xmlGetDtdElementDesc; + xmlGetDtdNotationDesc; + xmlGetDtdQAttrDesc; + xmlGetDtdQElementDesc; + xmlGetID; + xmlGetRefs; + xmlIsID; + xmlIsMixedElement; + xmlIsRef; + xmlNewElementContent; + xmlRemoveID; + xmlRemoveRef; + xmlSnprintfElementContent; + +# tree + xmlSplitQName2; + +# valid + xmlSprintfElementContent; + xmlValidBuildContentModel; + xmlValidCtxtNormalizeAttributeValue; + xmlValidGetPotentialChildren; + xmlValidGetValidElements; + xmlValidNormalizeAttributeValue; + xmlValidateAttributeDecl; + xmlValidateAttributeValue; + xmlValidateDocument; + xmlValidateDocumentFinal; + xmlValidateDtd; + xmlValidateDtdFinal; + xmlValidateElement; + xmlValidateElementDecl; + xmlValidateNameValue; + xmlValidateNamesValue; + xmlValidateNmtokenValue; + xmlValidateNmtokensValue; + xmlValidateNotationDecl; + xmlValidateNotationUse; + xmlValidateOneAttribute; + xmlValidateOneElement; + xmlValidateOneNamespace; + xmlValidateRoot; + +# HTMLparser + UTF8ToHtml; + htmlAutoCloseTag; + htmlCreatePushParserCtxt; + htmlEncodeEntities; + htmlEntityLookup; + htmlEntityValueLookup; + htmlFreeParserCtxt; + htmlHandleOmittedElem; + htmlIsAutoClosed; + htmlIsScriptAttribute; + htmlParseCharRef; + htmlParseChunk; + htmlParseDoc; + htmlParseDocument; + htmlParseElement; + htmlParseEntityRef; + htmlParseFile; + htmlSAXParseDoc; + htmlSAXParseFile; + htmlTagLookup; + +# xmlstring + xmlCharStrdup; + xmlCharStrndup; + +# parser + xmlCleanupParser; + xmlClearNodeInfoSeq; + xmlClearParserCtxt; + xmlCreateDocParserCtxt; + xmlCreateIOParserCtxt; + xmlCreatePushParserCtxt; + xmlFreeParserCtxt; + xmlGetExternalEntityLoader; + xmlGetFeature; + xmlGetFeaturesList; + +# globals + xmlGetWarningsDefaultValue; # variable + +# parser + xmlIOParseDTD; + xmlInitNodeInfoSeq; + xmlInitParser; + xmlInitParserCtxt; + xmlKeepBlanksDefault; + xmlLineNumbersDefault; + xmlLoadExternalEntity; + xmlNewIOInputStream; + xmlParseBalancedChunkMemory; + xmlParseBalancedChunkMemoryRecover; + xmlParseChunk; + xmlParseCtxtExternalEntity; + xmlParseDTD; + xmlParseDoc; + xmlParseDocument; + xmlParseEntity; + xmlParseExtParsedEnt; + xmlParseExternalEntity; + xmlParseFile; + xmlParseMemory; + xmlParserAddNodeInfo; + xmlParserFindNodeInfo; + xmlParserFindNodeInfoIndex; + xmlParserInputGrow; + xmlParserInputRead; + xmlPedanticParserDefault; + xmlRecoverDoc; + xmlRecoverFile; + xmlRecoverMemory; + xmlSAXParseDTD; + xmlSAXParseDoc; + xmlSAXParseEntity; + xmlSAXParseFile; + xmlSAXParseFileWithData; + xmlSAXParseMemory; + xmlSAXParseMemoryWithData; + xmlSAXUserParseFile; + xmlSAXUserParseMemory; + xmlSetExternalEntityLoader; + xmlSetFeature; + xmlSetupParserForBuffer; + xmlStopParser; + +# xmlstring + xmlStrEqual; + xmlStrcasecmp; + xmlStrcasestr; + xmlStrcat; + xmlStrchr; + xmlStrcmp; + xmlStrdup; + xmlStrlen; + xmlStrncasecmp; + xmlStrncat; + xmlStrncmp; + xmlStrndup; + xmlStrstr; + xmlStrsub; + +# parser + xmlSubstituteEntitiesDefault; + +# xmlreader + xmlFreeTextReader; + xmlNewTextReader; + xmlNewTextReaderFilename; + xmlTextReaderAttributeCount; + xmlTextReaderBaseUri; + xmlTextReaderDepth; + xmlTextReaderHasAttributes; + xmlTextReaderHasValue; + xmlTextReaderIsDefault; + xmlTextReaderIsEmptyElement; + xmlTextReaderLocalName; + xmlTextReaderName; + xmlTextReaderNamespaceUri; + xmlTextReaderNodeType; + xmlTextReaderPrefix; + xmlTextReaderQuoteChar; + xmlTextReaderRead; + xmlTextReaderValue; + xmlTextReaderXmlLang; + +# globals + docbDefaultSAXHandler; # variable + htmlDefaultSAXHandler; # variable + xmlDefaultSAXHandler; # variable + xmlDefaultSAXLocator; # variable + xmlDoValidityCheckingDefaultValue; # variable + xmlFree; # variable + xmlGenericError; # variable + xmlGenericErrorContext; # variable + xmlInitializeGlobalState; + xmlKeepBlanksDefaultValue; # variable + xmlLineNumbersDefaultValue; # variable + xmlLoadExtDtdDefaultValue; # variable + xmlMalloc; # variable + xmlMemStrdup; # variable + xmlParserDebugEntities; # variable + xmlParserVersion; # variable + xmlPedanticParserDefaultValue; # variable + xmlRealloc; # variable + xmlSaveNoEmptyTags; # variable + xmlSubstituteEntitiesDefaultValue; # variable + xmlTreeIndentString; # variable + +# threads + xmlCleanupThreads; + xmlFreeMutex; + xmlFreeRMutex; + xmlGetGlobalState; + xmlGetThreadId; + xmlInitThreads; + xmlIsMainThread; + xmlLockLibrary; + xmlMutexLock; + xmlMutexUnlock; + xmlNewMutex; + xmlNewRMutex; + xmlRMutexLock; + xmlRMutexUnlock; + xmlUnlockLibrary; + +# hash + xmlHashAddEntry; + xmlHashAddEntry2; + xmlHashAddEntry3; + xmlHashCopy; + xmlHashCreate; + xmlHashFree; + xmlHashLookup; + xmlHashLookup2; + xmlHashLookup3; + xmlHashRemoveEntry; + xmlHashRemoveEntry2; + xmlHashRemoveEntry3; + xmlHashScan; + xmlHashScan3; + xmlHashScanFull; + xmlHashScanFull3; + xmlHashSize; + xmlHashUpdateEntry; + xmlHashUpdateEntry2; + xmlHashUpdateEntry3; + +# xmlerror + initGenericErrorDefaultFunc; + xmlParserError; + xmlParserPrintFileContext; + xmlParserPrintFileInfo; + xmlParserValidityError; + xmlParserValidityWarning; + xmlParserWarning; + xmlSetGenericErrorFunc; + +# globals + oldXMLWDcompatibility; # variable + +# tree + xmlAddChild; + xmlAddChildList; + xmlAddNextSibling; + xmlAddPrevSibling; + xmlAddSibling; + xmlBufferAdd; + xmlBufferAddHead; + +# globals + xmlBufferAllocScheme; # variable + +# tree + xmlBufferCCat; + xmlBufferCat; + xmlBufferContent; + xmlBufferCreate; + xmlBufferCreateSize; + xmlBufferDump; + xmlBufferEmpty; + xmlBufferFree; + xmlBufferGrow; + xmlBufferLength; + xmlBufferResize; + xmlBufferSetAllocationScheme; + xmlBufferShrink; + xmlBufferWriteCHAR; + xmlBufferWriteChar; + xmlBufferWriteQuotedString; + xmlCopyDoc; + xmlCopyDtd; + xmlCopyNamespace; + xmlCopyNamespaceList; + xmlCopyNode; + xmlCopyNodeList; + xmlCopyProp; + xmlCopyPropList; + xmlCreateIntSubset; + +# globals + xmlDefaultBufferSize; # variable + +# tree + xmlDocCopyNode; + xmlDocDump; + xmlDocDumpFormatMemory; + xmlDocDumpFormatMemoryEnc; + xmlDocDumpMemory; + xmlDocDumpMemoryEnc; + xmlDocFormatDump; + xmlDocGetRootElement; + xmlDocSetRootElement; + xmlElemDump; + xmlFreeDoc; + xmlFreeDtd; + xmlFreeNode; + xmlFreeNodeList; + xmlFreeNs; + xmlFreeNsList; + xmlFreeProp; + xmlFreePropList; + xmlGetBufferAllocationScheme; + xmlGetCompressMode; + xmlGetDocCompressMode; + xmlGetIntSubset; + xmlGetLastChild; + xmlGetLineNo; + xmlGetNodePath; + xmlGetNsList; + xmlGetNsProp; + xmlGetProp; + xmlHasNsProp; + xmlHasProp; + +# globals + xmlIndentTreeOutput; # variable + +# tree + xmlIsBlankNode; + xmlIsXHTML; + xmlNewCDataBlock; + xmlNewCharRef; + xmlNewChild; + xmlNewComment; + xmlNewDoc; + xmlNewDocComment; + xmlNewDocFragment; + xmlNewDocNode; + xmlNewDocNodeEatName; + xmlNewDocProp; + xmlNewDocRawNode; + xmlNewDocText; + xmlNewDocTextLen; + xmlNewDtd; + xmlNewGlobalNs; + xmlNewNode; + xmlNewNodeEatName; + xmlNewNs; + xmlNewNsProp; + xmlNewNsPropEatName; + xmlNewPI; + xmlNewProp; + xmlNewReference; + xmlNewText; + xmlNewTextChild; + xmlNewTextLen; + xmlNodeAddContent; + xmlNodeAddContentLen; + xmlNodeDump; + xmlNodeDumpOutput; + xmlNodeGetBase; + xmlNodeGetContent; + xmlNodeGetLang; + xmlNodeGetSpacePreserve; + xmlNodeIsText; + xmlNodeListGetRawString; + xmlNodeListGetString; + xmlNodeSetBase; + xmlNodeSetContent; + xmlNodeSetContentLen; + xmlNodeSetLang; + xmlNodeSetName; + xmlNodeSetSpacePreserve; + xmlReconciliateNs; + xmlRemoveProp; + xmlReplaceNode; + xmlSaveFile; + xmlSaveFileEnc; + xmlSaveFileTo; + xmlSaveFormatFile; + xmlSaveFormatFileEnc; + xmlSaveFormatFileTo; + xmlSearchNs; + xmlSearchNsByHref; + xmlSetBufferAllocationScheme; + xmlSetCompressMode; + xmlSetDocCompressMode; + xmlSetListDoc; + xmlSetNs; + xmlSetNsProp; + xmlSetProp; + xmlSetTreeDoc; + xmlStringGetNodeList; + xmlStringLenGetNodeList; + xmlTextConcat; + xmlTextMerge; + xmlUnlinkNode; + xmlUnsetNsProp; + xmlUnsetProp; + +# xmlregexp + xmlRegExecPushString; + xmlRegFreeExecCtxt; + xmlRegFreeRegexp; + xmlRegNewExecCtxt; + xmlRegexpCompile; + xmlRegexpExec; + xmlRegexpIsDeterminist; + xmlRegexpPrint; + +# nanohttp + xmlNanoHTTPAuthHeader; + xmlNanoHTTPCleanup; + xmlNanoHTTPClose; + xmlNanoHTTPFetch; + xmlNanoHTTPInit; + xmlNanoHTTPMethod; + xmlNanoHTTPMethodRedir; + xmlNanoHTTPOpen; + xmlNanoHTTPOpenRedir; + xmlNanoHTTPRead; + xmlNanoHTTPReturnCode; + xmlNanoHTTPSave; + xmlNanoHTTPScanProxy; + +# xmlunicode + xmlUCSIsAlphabeticPresentationForms; + xmlUCSIsArabic; + xmlUCSIsArabicPresentationFormsA; + xmlUCSIsArabicPresentationFormsB; + xmlUCSIsArmenian; + xmlUCSIsArrows; + xmlUCSIsBasicLatin; + xmlUCSIsBengali; + xmlUCSIsBlock; + xmlUCSIsBlockElements; + xmlUCSIsBopomofo; + xmlUCSIsBopomofoExtended; + xmlUCSIsBoxDrawing; + xmlUCSIsBraillePatterns; + xmlUCSIsByzantineMusicalSymbols; + xmlUCSIsCJKCompatibility; + xmlUCSIsCJKCompatibilityForms; + xmlUCSIsCJKCompatibilityIdeographs; + xmlUCSIsCJKCompatibilityIdeographsSupplement; + xmlUCSIsCJKRadicalsSupplement; + xmlUCSIsCJKSymbolsandPunctuation; + xmlUCSIsCJKUnifiedIdeographs; + xmlUCSIsCJKUnifiedIdeographsExtensionA; + xmlUCSIsCJKUnifiedIdeographsExtensionB; + xmlUCSIsCat; + xmlUCSIsCatC; + xmlUCSIsCatCc; + xmlUCSIsCatCf; + xmlUCSIsCatCo; + xmlUCSIsCatCs; + xmlUCSIsCatL; + xmlUCSIsCatLl; + xmlUCSIsCatLm; + xmlUCSIsCatLo; + xmlUCSIsCatLt; + xmlUCSIsCatLu; + xmlUCSIsCatM; + xmlUCSIsCatMc; + xmlUCSIsCatMe; + xmlUCSIsCatMn; + xmlUCSIsCatN; + xmlUCSIsCatNd; + xmlUCSIsCatNl; + xmlUCSIsCatNo; + xmlUCSIsCatP; + xmlUCSIsCatPc; + xmlUCSIsCatPd; + xmlUCSIsCatPe; + xmlUCSIsCatPf; + xmlUCSIsCatPi; + xmlUCSIsCatPo; + xmlUCSIsCatPs; + xmlUCSIsCatS; + xmlUCSIsCatSc; + xmlUCSIsCatSk; + xmlUCSIsCatSm; + xmlUCSIsCatSo; + xmlUCSIsCatZ; + xmlUCSIsCatZl; + xmlUCSIsCatZp; + xmlUCSIsCatZs; + xmlUCSIsCherokee; + xmlUCSIsCombiningDiacriticalMarks; + xmlUCSIsCombiningHalfMarks; + xmlUCSIsCombiningMarksforSymbols; + xmlUCSIsControlPictures; + xmlUCSIsCurrencySymbols; + xmlUCSIsCyrillic; + xmlUCSIsDeseret; + xmlUCSIsDevanagari; + xmlUCSIsDingbats; + xmlUCSIsEnclosedAlphanumerics; + xmlUCSIsEnclosedCJKLettersandMonths; + xmlUCSIsEthiopic; + xmlUCSIsGeneralPunctuation; + xmlUCSIsGeometricShapes; + xmlUCSIsGeorgian; + xmlUCSIsGothic; + xmlUCSIsGreek; + xmlUCSIsGreekExtended; + xmlUCSIsGujarati; + xmlUCSIsGurmukhi; + xmlUCSIsHalfwidthandFullwidthForms; + xmlUCSIsHangulCompatibilityJamo; + xmlUCSIsHangulJamo; + xmlUCSIsHangulSyllables; + xmlUCSIsHebrew; + xmlUCSIsHighPrivateUseSurrogates; + xmlUCSIsHighSurrogates; + xmlUCSIsHiragana; + xmlUCSIsIPAExtensions; + xmlUCSIsIdeographicDescriptionCharacters; + xmlUCSIsKanbun; + xmlUCSIsKangxiRadicals; + xmlUCSIsKannada; + xmlUCSIsKatakana; + xmlUCSIsKhmer; + xmlUCSIsLao; + xmlUCSIsLatin1Supplement; + xmlUCSIsLatinExtendedA; + xmlUCSIsLatinExtendedAdditional; + xmlUCSIsLatinExtendedB; + xmlUCSIsLetterlikeSymbols; + xmlUCSIsLowSurrogates; + xmlUCSIsMalayalam; + xmlUCSIsMathematicalAlphanumericSymbols; + xmlUCSIsMathematicalOperators; + xmlUCSIsMiscellaneousSymbols; + xmlUCSIsMiscellaneousTechnical; + xmlUCSIsMongolian; + xmlUCSIsMusicalSymbols; + xmlUCSIsMyanmar; + xmlUCSIsNumberForms; + xmlUCSIsOgham; + xmlUCSIsOldItalic; + xmlUCSIsOpticalCharacterRecognition; + xmlUCSIsOriya; + xmlUCSIsPrivateUse; + xmlUCSIsRunic; + xmlUCSIsSinhala; + xmlUCSIsSmallFormVariants; + xmlUCSIsSpacingModifierLetters; + xmlUCSIsSpecials; + xmlUCSIsSuperscriptsandSubscripts; + xmlUCSIsSyriac; + xmlUCSIsTags; + xmlUCSIsTamil; + xmlUCSIsTelugu; + xmlUCSIsThaana; + xmlUCSIsThai; + xmlUCSIsTibetan; + xmlUCSIsUnifiedCanadianAboriginalSyllabics; + xmlUCSIsYiRadicals; + xmlUCSIsYiSyllables; + +# uri + xmlBuildURI; + xmlCreateURI; + xmlFreeURI; + xmlNormalizeURIPath; + xmlParseURI; + xmlParseURIReference; + xmlPrintURI; + xmlSaveUri; + xmlURIEscape; + xmlURIEscapeStr; + xmlURIUnescapeString; + +# encoding + UTF8Toisolat1; + isolat1ToUTF8; + xmlAddEncodingAlias; + xmlCharEncCloseFunc; + xmlCharEncFirstLine; + xmlCharEncInFunc; + xmlCharEncOutFunc; + +# xmlstring + xmlCheckUTF8; + +# encoding + xmlCleanupCharEncodingHandlers; + xmlCleanupEncodingAliases; + xmlDelEncodingAlias; + xmlDetectCharEncoding; + xmlFindCharEncodingHandler; + xmlGetCharEncodingHandler; + xmlGetCharEncodingName; + xmlGetEncodingAlias; + +# xmlstring + xmlGetUTF8Char; + +# encoding + xmlInitCharEncodingHandlers; + xmlNewCharEncodingHandler; + xmlParseCharEncoding; + xmlRegisterCharEncodingHandler; + +# xmlstring + xmlUTF8Strlen; + xmlUTF8Strloc; + xmlUTF8Strndup; + xmlUTF8Strpos; + xmlUTF8Strsize; + xmlUTF8Strsub; +} ; + +LIBXML2_2.5.0 { + global: + +# globals + xmlDeregisterNodeDefault; + xmlDeregisterNodeDefaultValue; # variable + xmlRegisterNodeDefault; + xmlRegisterNodeDefaultValue; # variable + +# xmlreader + xmlTextReaderClose; + xmlTextReaderCurrentDoc; + xmlTextReaderCurrentNode; + xmlTextReaderGetAttributeNo; + xmlTextReaderGetAttributeNs; + xmlTextReaderGetAttribute; + xmlTextReaderGetParserProp; + xmlTextReaderGetRemainder; + xmlTextReaderLookupNamespace; + xmlTextReaderMoveToAttributeNo; + xmlTextReaderMoveToAttributeNs; + xmlTextReaderMoveToAttribute; + xmlTextReaderMoveToElement; + xmlTextReaderMoveToFirstAttribute; + xmlTextReaderMoveToNextAttribute; + xmlTextReaderNormalization; + xmlTextReaderReadAttributeValue; + xmlTextReaderReadInnerXml; + xmlTextReaderReadOuterXml; + xmlTextReaderReadState; + xmlTextReaderReadString; + xmlTextReaderSetParserProp; + +# valid + xmlValidatePopElement; + xmlValidatePushCData; + xmlValidatePushElement; +} LIBXML2_2.4.30; + +LIBXML2_2.5.2 { + global: + +# tree + xmlGetNoNsProp; + +# HTMLparser + htmlAttrAllowed; + htmlElementAllowedHere; + htmlElementStatusHere; + htmlNodeStatus; + +# relaxng + xmlRelaxNGCleanupTypes; + xmlRelaxNGDump; + xmlRelaxNGFreeParserCtxt; + xmlRelaxNGFree; + xmlRelaxNGFreeValidCtxt; + xmlRelaxNGNewMemParserCtxt; + xmlRelaxNGNewParserCtxt; + xmlRelaxNGNewValidCtxt; + xmlRelaxNGParse; + xmlRelaxNGSetParserErrors; + xmlRelaxNGSetValidErrors; + xmlRelaxNGValidateDoc; + +# xmlreader + xmlTextReaderGetErrorHandler; + xmlTextReaderLocatorBaseURI; + xmlTextReaderLocatorLineNumber; + xmlTextReaderSetErrorHandler; + +# relaxng +# xmlRelaxNGValidateStream; removed in 2.5.5 +} LIBXML2_2.5.0; + +LIBXML2_2.5.4 { + global: + +# uri + xmlCanonicPath; + +# relaxng + xmlRelaxNGDumpTree; + +# tree + xmlValidateName; + xmlValidateNCName; + xmlValidateNMToken; + xmlValidateQName; +} LIBXML2_2.5.2; + +LIBXML2_2.5.5 { + global: + +# nanoftp + xmlNanoFTPDele; +} LIBXML2_2.5.4; + +LIBXML2_2.5.6 { + global: + +# xpath + xmlXPathOrderDocElems; +} LIBXML2_2.5.5; + +LIBXML2_2.5.7 { + global: + +# HTMLparser + htmlCreateMemoryParserCtxt; + +# xmlautomata + xmlAutomataNewTransition2; + +# tree + xmlBuildQName; + +# xmlmemory + xmlGcMemGet; + xmlGcMemSetup; + +# globals + xmlMallocAtomic; # variable + +# xmlregexp + xmlRegExecPushString2; + +# relaxng + xmlRelaxNGNewDocParserCtxt; + xmlRelaxNGValidateFullElement; + xmlRelaxNGValidatePopElement; + xmlRelaxNGValidatePushCData; + xmlRelaxNGValidatePushElement; + +# xmlreader + xmlTextReaderExpand; + xmlTextReaderIsValid; + xmlTextReaderNext; + xmlTextReaderRelaxNGSetSchema; + xmlTextReaderRelaxNGValidate; +} LIBXML2_2.5.6; + +LIBXML2_2.5.8 { + global: + +# globals + xmlCleanupGlobals; + xmlInitGlobals; + +# valid + xmlFreeValidCtxt; + xmlNewValidCtxt; + +# schemasInternals + xmlSchemaFreeType; + +# xmlschemas + xmlSchemaDump; + xmlSchemaFreeParserCtxt; + xmlSchemaFreeValidCtxt; + xmlSchemaFree; + xmlSchemaNewMemParserCtxt; + xmlSchemaNewParserCtxt; + xmlSchemaNewValidCtxt; + xmlSchemaParse; + xmlSchemaSetParserErrors; + xmlSchemaSetValidErrors; + xmlSchemaValidateDoc; + xmlSchemaValidateStream; + +# xmlschemastypes + xmlSchemaCheckFacet; + xmlSchemaCleanupTypes; + xmlSchemaCompareValues; + xmlSchemaFreeFacet; + xmlSchemaFreeValue; + xmlSchemaGetPredefinedType; + xmlSchemaInitTypes; + xmlSchemaNewFacet; + xmlSchemaValidateFacet; + xmlSchemaValidatePredefinedType; + xmlSchemaValPredefTypeNode; + +# globals + xmlThrDefBufferAllocScheme; + xmlThrDefDefaultBufferSize; + xmlThrDefDeregisterNodeDefault; + xmlThrDefDoValidityCheckingDefaultValue; + xmlThrDefGetWarningsDefaultValue; + xmlThrDefIndentTreeOutput; + xmlThrDefKeepBlanksDefaultValue; + xmlThrDefLineNumbersDefaultValue; + xmlThrDefLoadExtDtdDefaultValue; + xmlThrDefParserDebugEntities; + xmlThrDefPedanticParserDefaultValue; + xmlThrDefRegisterNodeDefault; + xmlThrDefSaveNoEmptyTags; + xmlThrDefSetGenericErrorFunc; + xmlThrDefSubstituteEntitiesDefaultValue; + xmlThrDefTreeIndentString; +} LIBXML2_2.5.7; + +LIBXML2_2.5.9 { + global: + +# xmlmemory + xmlMallocAtomicLoc; + +# relaxng + xmlRelaxNGGetParserErrors; + xmlRelaxNGGetValidErrors; + +# tree + xmlSplitQName3; + +# xmlstring + xmlUTF8Charcmp; + xmlUTF8Size; + +# xinclude + xmlXIncludeProcessTree; +} LIBXML2_2.5.8; + +LIBXML2_2.6.0 { + global: + +# SAX2 + xmlSAX2AttributeDecl; + xmlSAX2CDataBlock; + xmlSAX2Characters; + xmlSAX2Comment; + xmlSAX2ElementDecl; + xmlSAX2EndDocument; + xmlSAX2EndElementNs; + xmlSAX2EndElement; + xmlSAX2EntityDecl; + xmlSAX2ExternalSubset; + xmlSAX2GetColumnNumber; + xmlSAX2GetEntity; + xmlSAX2GetLineNumber; + xmlSAX2GetParameterEntity; + xmlSAX2GetPublicId; + xmlSAX2GetSystemId; + xmlSAX2HasExternalSubset; + xmlSAX2HasInternalSubset; + xmlSAX2IgnorableWhitespace; + xmlSAX2InitDefaultSAXHandler; + xmlSAX2InitDocbDefaultSAXHandler; + xmlSAX2InitHtmlDefaultSAXHandler; + xmlSAX2InternalSubset; + xmlSAX2IsStandalone; + xmlSAX2NotationDecl; + xmlSAX2ProcessingInstruction; + xmlSAX2Reference; + xmlSAX2ResolveEntity; + xmlSAX2SetDocumentLocator; + xmlSAX2StartDocument; + xmlSAX2StartElementNs; + xmlSAX2StartElement; + xmlSAX2UnparsedEntityDecl; + xmlSAXDefaultVersion; + xmlSAXVersion; + +# HTMLparser + htmlCtxtReadDoc; + htmlCtxtReadFd; + htmlCtxtReadFile; + htmlCtxtReadIO; + htmlCtxtReadMemory; + htmlCtxtReset; + htmlCtxtUseOptions; + htmlReadDoc; + htmlReadFd; + htmlReadFile; + htmlReadIO; + htmlReadMemory; + +# tree + xmlBufferCreateStatic; + +# chvalid + xmlCharInRange; + +# xmlIO + xmlCheckHTTPInput; + +# xmlerror + xmlCopyError; + xmlCtxtGetLastError; + xmlGetLastError; + xmlResetError; + xmlResetLastError; + xmlSetStructuredErrorFunc; + +# parser + xmlCtxtReadDoc; + xmlCtxtReadFd; + xmlCtxtReadFile; + xmlCtxtReadIO; + xmlCtxtReadMemory; + +# xmlerror + xmlCtxtResetLastError; + +# parser + xmlCtxtReset; + xmlCtxtUseOptions; + xmlReadDoc; + xmlReadFd; + xmlReadFile; + xmlReadIO; + xmlReadMemory; + +# xmlstring + xmlStrPrintf; + xmlStrQEqual; + +# dict + xmlDictCreate; + xmlDictFree; + xmlDictLookup; + xmlDictOwns; + xmlDictQLookup; + xmlDictReference; + xmlDictSize; + +# parserInternals + xmlErrMemory; + xmlParserMaxDepth; # variable + xmlStringLenDecodeEntities; + xmlSwitchInputEncoding; + +# xmlwriter + xmlFreeTextWriter; + xmlNewTextWriterFilename; + xmlNewTextWriterMemory; + xmlNewTextWriter; + xmlTextWriterEndAttribute; + xmlTextWriterEndCDATA; + xmlTextWriterEndDocument; + xmlTextWriterEndDTD; + xmlTextWriterEndElement; + xmlTextWriterEndPI; + xmlTextWriterFlush; + xmlTextWriterFullEndElement; + xmlTextWriterStartAttributeNS; + xmlTextWriterStartAttribute; + xmlTextWriterStartCDATA; + xmlTextWriterStartDocument; + xmlTextWriterStartDTDAttlist; + xmlTextWriterStartDTDElement; + xmlTextWriterStartDTDEntity; + xmlTextWriterStartDTD; + xmlTextWriterStartElementNS; + xmlTextWriterStartElement; + xmlTextWriterStartPI; + xmlTextWriterWriteAttributeNS; + xmlTextWriterWriteAttribute; + xmlTextWriterWriteBase64; + xmlTextWriterWriteBinHex; + xmlTextWriterWriteCDATA; + xmlTextWriterWriteComment; + xmlTextWriterWriteDTDAttlist; + xmlTextWriterWriteDTDElement; + xmlTextWriterWriteDTDEntity; + xmlTextWriterWriteDTDExternalEntity; + xmlTextWriterWriteDTDInternalEntity; + xmlTextWriterWriteDTDNotation; + xmlTextWriterWriteDTD; + xmlTextWriterWriteElementNS; + xmlTextWriterWriteElement; + xmlTextWriterWriteFormatAttributeNS; + xmlTextWriterWriteFormatAttribute; + xmlTextWriterWriteFormatCDATA; + xmlTextWriterWriteFormatComment; + xmlTextWriterWriteFormatDTDAttlist; + xmlTextWriterWriteFormatDTDElement; + xmlTextWriterWriteFormatDTDInternalEntity; + xmlTextWriterWriteFormatDTD; + xmlTextWriterWriteFormatElementNS; + xmlTextWriterWriteFormatElement; + xmlTextWriterWriteFormatPI; + xmlTextWriterWriteFormatRaw; + xmlTextWriterWriteFormatString; + xmlTextWriterWritePI; + xmlTextWriterWriteRawLen; + xmlTextWriterWriteRaw; + xmlTextWriterWriteString; + xmlTextWriterWriteVFormatAttributeNS; + xmlTextWriterWriteVFormatAttribute; + xmlTextWriterWriteVFormatCDATA; + xmlTextWriterWriteVFormatComment; + xmlTextWriterWriteVFormatDTDAttlist; + xmlTextWriterWriteVFormatDTDElement; + xmlTextWriterWriteVFormatDTDInternalEntity; + xmlTextWriterWriteVFormatDTD; + xmlTextWriterWriteVFormatElementNS; + xmlTextWriterWriteVFormatElement; + xmlTextWriterWriteVFormatPI; + xmlTextWriterWriteVFormatRaw; + xmlTextWriterWriteVFormatString; + +# hash + xmlHashQLookup2; + xmlHashQLookup3; + xmlHashQLookup; + +# chvalid + xmlIsBaseCharGroup; # variable + xmlIsCharGroup; # variable + xmlIsCombiningGroup; # variable + xmlIsDigitGroup; # variable + xmlIsExtenderGroup; # variable + xmlIsIdeographicGroup; # variable + xmlIsPubidChar_tab; # variable + +# globals + xmlLastError; # variable + +# nanohttp + xmlNanoHTTPEncoding; + xmlNanoHTTPMimeType; + xmlNanoHTTPRedir; + +# tree + xmlNodeBufGetContent; + +# xmlIO + xmlParserInputBufferCreateStatic; + +# xmlreader + xmlReaderForDoc; + xmlReaderForFd; + xmlReaderForFile; + xmlReaderForIO; + xmlReaderForMemory; + xmlReaderNewDoc; + xmlReaderNewFd; + xmlReaderNewFile; + xmlReaderNewIO; + xmlReaderNewMemory; + xmlReaderNewWalker; + xmlReaderWalker; + xmlTextReaderConstBaseUri; + xmlTextReaderConstLocalName; + xmlTextReaderConstNamespaceUri; + xmlTextReaderConstName; + xmlTextReaderConstPrefix; + xmlTextReaderConstString; + xmlTextReaderConstValue; + xmlTextReaderConstXmlLang; + xmlTextReaderNextSibling; + xmlTextReaderPreserve; + +# globals + xmlStructuredError; # variable + xmlThrDefSetStructuredErrorFunc; + +# xpathInternals + xmlXPathErr; + +# SAX2 +# xmlSAX2CheckNamespace; removed in 2.6.10 +# xmlSAX2GetNamespace; removed in 2.6.10 +# xmlSAX2GlobalNamespace; removed in 2.6.10 +# xmlSAX2NamespaceDecl; removed in 2.6.10 +# xmlSAX2SetNamespace; removed in 2.6.10 +} LIBXML2_2.5.9; + +LIBXML2_2.6.1 { + global: + +# parser + xmlCtxtResetPush; +} LIBXML2_2.6.0; + +LIBXML2_2.6.2 { + global: + +# parserInternals + xmlCreateURLParserCtxt; + +# xmlschemas + xmlSchemaNewDocParserCtxt; + +# xmlstring + xmlStrVPrintf; + +# xinclude + xmlXIncludeFreeContext; + xmlXIncludeNewContext; + xmlXIncludeProcessNode; +} LIBXML2_2.6.1; + +LIBXML2_2.6.3 { + global: + +# pattern + xmlFreePatternList; + xmlFreePattern; + xmlPatterncompile; + xmlPatternMatch; + +# xmlwriter + xmlNewTextWriterDoc; + xmlNewTextWriterPushParser; + xmlNewTextWriterTree; + +# xmlreader + xmlTextReaderPreservePattern; + +# xmlunicode + xmlUCSIsAegeanNumbers; + xmlUCSIsBuhid; + xmlUCSIsCombiningDiacriticalMarksforSymbols; + xmlUCSIsCypriotSyllabary; + xmlUCSIsCyrillicSupplement; + xmlUCSIsGreekandCoptic; + xmlUCSIsHanunoo; + xmlUCSIsKatakanaPhoneticExtensions; + xmlUCSIsKhmerSymbols; + xmlUCSIsLimbu; + xmlUCSIsLinearBIdeograms; + xmlUCSIsLinearBSyllabary; + xmlUCSIsMiscellaneousMathematicalSymbolsA; + xmlUCSIsMiscellaneousMathematicalSymbolsB; + xmlUCSIsMiscellaneousSymbolsandArrows; + xmlUCSIsOsmanya; + xmlUCSIsPhoneticExtensions; + xmlUCSIsPrivateUseArea; + xmlUCSIsShavian; + xmlUCSIsSupplementalArrowsA; + xmlUCSIsSupplementalArrowsB; + xmlUCSIsSupplementalMathematicalOperators; + xmlUCSIsSupplementaryPrivateUseAreaA; + xmlUCSIsSupplementaryPrivateUseAreaB; + xmlUCSIsTagalog; + xmlUCSIsTagbanwa; + xmlUCSIsTaiLe; + xmlUCSIsTaiXuanJingSymbols; + xmlUCSIsUgaritic; + xmlUCSIsVariationSelectorsSupplement; + xmlUCSIsVariationSelectors; + xmlUCSIsYijingHexagramSymbols; + +# xinclude + xmlXIncludeProcessFlags; + xmlXIncludeProcessTreeFlags; + xmlXIncludeSetFlags; +} LIBXML2_2.6.2; + +LIBXML2_2.6.5 { + global: + +# xmlmemory + xmlCleanupMemory; + +# dict + xmlDictCreateSub; + +# relaxng + xmlRelaxParserSetFlag; + +# xmlstring + xmlStrncatNew; + +# xmlwriter + xmlTextWriterSetIndentString; + xmlTextWriterSetIndent; + +# xpath + xmlXPathCtxtCompile; +} LIBXML2_2.6.3; + +LIBXML2_2.6.6 { + global: + +# tree + xmlAttrSerializeTxtContent; + +# parser + xmlByteConsumed; + +# xmlreader + xmlTextReaderSetStructuredErrorHandler; +} LIBXML2_2.6.5; + +LIBXML2_2.6.7 { + global: + +# xmlwriter + xmlTextWriterEndComment; + xmlTextWriterStartComment; +} LIBXML2_2.6.6; + +LIBXML2_2.6.8 { + global: + +# xmlsave + xmlSaveClose; + xmlSaveDoc; + xmlSaveFlush; + xmlSaveToFd; + xmlSaveToFilename; + xmlSaveToIO; + xmlSaveTree; + +# xmlwriter + xmlTextWriterEndDTDAttlist; + xmlTextWriterEndDTDElement; + xmlTextWriterEndDTDEntity; + xmlTextWriterWriteDTDExternalEntityContents; +} LIBXML2_2.6.7; + +LIBXML2_2.6.10 { + global: + +# xmlIO + xmlOutputBufferWriteEscape; + xmlPopInputCallbacks; + +# xmlsave + xmlSaveSetAttrEscape; + xmlSaveSetEscape; +} LIBXML2_2.6.8; + +LIBXML2_2.6.11 { + global: + +# uri + xmlBuildRelativeURI; + +# globals + xmlOutputBufferCreateFilenameDefault; + xmlOutputBufferCreateFilenameValue; # variable + xmlParserInputBufferCreateFilenameDefault; + xmlParserInputBufferCreateFilenameValue; # variable + xmlThrDefOutputBufferCreateFilenameDefault; + xmlThrDefParserInputBufferCreateFilenameDefault; + +# schemasInternals + xmlSchemaFreeWildcard; + +# xmlschemastypes + xmlSchemaCollapseString; + xmlSchemaGetBuiltInListSimpleTypeItemType; + xmlSchemaGetBuiltInType; + xmlSchemaIsBuiltInTypeFacet; + xmlSchemaValidateListSimpleTypeFacet; +} LIBXML2_2.6.10; + +LIBXML2_2.6.12 { + global: + +# parser + xmlParseInNodeContext; + +# xmlschemastypes + xmlSchemaGetFacetValueAsULong; + xmlSchemaValidateLengthFacet; + xmlSchemaValPredefTypeNodeNoNorm; + +# xmlschemas + xmlSchemaGetParserErrors; + xmlSchemaGetValidErrors; +} LIBXML2_2.6.11; + +LIBXML2_2.6.14 { + global: + +# xmlautomata + xmlAutomataNewCountTrans2; + xmlAutomataNewOnceTrans2; + +# nanohttp + xmlNanoHTTPContentLength; + +# xmlschemas + xmlSchemaSetValidOptions; + xmlSchemaValidateOneElement; + xmlSchemaValidCtxtGetOptions; +} LIBXML2_2.6.12; + +LIBXML2_2.6.15 { + global: + +# debugXML + xmlDebugCheckDocument; + +# tree + xmlDocCopyNodeList; + xmlNewDocPI; + +# xmlreader + xmlTextReaderConstEncoding; + xmlTextReaderConstXmlVersion; + xmlTextReaderIsNamespaceDecl; + xmlTextReaderStandalone; +} LIBXML2_2.6.14; + +LIBXML2_2.6.16 { + global: + +# xmlmemory + xmlMemBlocks; + +# relaxng + xmlRelaxNGInitTypes; +} LIBXML2_2.6.15; + +LIBXML2_2.6.17 { + global: + +# dict + xmlDictExists; + +# xmlmodule + xmlModuleClose; + xmlModuleFree; + xmlModuleOpen; + xmlModuleSymbol; + +# xmlregexp + xmlRegExecErrInfo; + xmlRegExecNextValues; + +# xmlschemastypes + xmlSchemaWhiteSpaceReplace; + +# xmlreader + xmlTextReaderGetParserColumnNumber; + xmlTextReaderGetParserLineNumber; +} LIBXML2_2.6.16; + +LIBXML2_2.6.18 { + global: + +# valid + xmlCopyDocElementContent; + xmlFreeDocElementContent; + xmlNewDocElementContent; + +# dict + xmlDictCleanup; + +# hash + xmlHashCreateDict; + +# pattern + xmlFreeStreamCtxt; + xmlPatternFromRoot; + xmlPatternGetStreamCtxt; + xmlPatternMaxDepth; + xmlPatternStreamable; + xmlStreamPop; + xmlStreamPushAttr; + xmlStreamPush; + +# xmlschemastypes + xmlSchemaCompareValuesWhtsp; + xmlSchemaCopyValue; + xmlSchemaGetCanonValue; + xmlSchemaNewNOTATIONValue; + xmlSchemaNewStringValue; + +# xmlreader + xmlTextReaderByteConsumed; +} LIBXML2_2.6.17; + +LIBXML2_2.6.19 { + global: + +# xmlschemastypes + xmlSchemaGetValType; + xmlSchemaValidateFacetWhtsp; + xmlSchemaValidateLengthFacetWhtsp; +} LIBXML2_2.6.18; + +LIBXML2_2.6.20 { + global: + +# tree + xmlDOMWrapAdoptNode; + xmlDOMWrapFreeCtxt; + xmlDOMWrapNewCtxt; + xmlDOMWrapReconcileNamespaces; + xmlDOMWrapRemoveNode; + +# xmlschemastypes + xmlSchemaGetCanonValueWhtsp; + xmlSchemaNewQNameValue; + xmlSchemaValueAppend; + xmlSchemaValueGetAsBoolean; + xmlSchemaValueGetAsString; + xmlSchemaValueGetNext; + +# xmlschemas + xmlSchemaIsValid; + xmlSchemaSAXPlug; + xmlSchemaSAXUnplug; + xmlSchemaValidateFile; + +# xmlreader + xmlTextReaderSchemaValidate; + xmlTextReaderSetSchema; +} LIBXML2_2.6.19; + +LIBXML2_2.6.21 { + global: + +# xmlautomata + xmlAutomataNewNegTrans; + +# xmlregexp +# emptyExp; removed in 2.9.10 +# forbiddenExp; removed in 2.9.10 +# xmlExpCtxtNbCons; removed in 2.9.10 +# xmlExpCtxtNbNodes; removed in 2.9.10 +# xmlExpDump; removed in 2.9.10 +# xmlExpExpDerive; removed in 2.9.10 +# xmlExpFreeCtxt; removed in 2.9.10 +# xmlExpFree; removed in 2.9.10 +# xmlExpGetLanguage; removed in 2.9.10 +# xmlExpGetStart; removed in 2.9.10 +# xmlExpIsNillable; removed in 2.9.10 +# xmlExpMaxToken; removed in 2.9.10 +# xmlExpNewAtom; removed in 2.9.10 +# xmlExpNewCtxt; removed in 2.9.10 +# xmlExpNewOr; removed in 2.9.10 +# xmlExpNewRange; removed in 2.9.10 +# xmlExpNewSeq; removed in 2.9.10 +# xmlExpParse; removed in 2.9.10 +# xmlExpRef; removed in 2.9.10 +# xmlExpStringDerive; removed in 2.9.10 +# xmlExpSubsume; removed in 2.9.10 + +# parser + xmlHasFeature; + +# uri + xmlParseURIRaw; + +# pattern + xmlPatternMinDepth; + +# relaxng + xmlRelaxNGSetValidStructuredErrors; + +# xmlschemas + xmlSchemaSetValidStructuredErrors; + +# schematron + xmlSchematronFreeParserCtxt; + xmlSchematronFree; + xmlSchematronFreeValidCtxt; + xmlSchematronNewDocParserCtxt; + xmlSchematronNewMemParserCtxt; + xmlSchematronNewParserCtxt; + xmlSchematronNewValidCtxt; + xmlSchematronParse; + xmlSchematronValidateDoc; +} LIBXML2_2.6.20; + +LIBXML2_2.6.23 { + global: + +# HTMLtree + htmlDocDumpMemoryFormat; + +# xmlIO + xmlOutputBufferCreateBuffer; + +# xmlsave + xmlSaveToBuffer;# suppressed in 2.6.11, readded in 2.6.23 + + +# xmlschemas + xmlSchemaSetParserStructuredErrors; + +# pattern + xmlStreamPushNode; + xmlStreamWantsAnyNode; + +# xmlreader + xmlTextReaderSchemaValidateCtxt; +} LIBXML2_2.6.21; + +LIBXML2_2.6.24 { + global: + +# tree + xmlDOMWrapCloneNode; + +# relaxng + xmlRelaxNGSetParserStructuredErrors; +} LIBXML2_2.6.23; + +LIBXML2_2.6.25 { + global: + +# xpath + xmlXPathContextSetCache; +} LIBXML2_2.6.24; + +LIBXML2_2.6.27 { + global: + +# HTMLparser + htmlNewParserCtxt; + +# uri + xmlPathToURI; + +# xinclude + xmlXIncludeProcessFlagsData; + +# xpath + xmlXPathCompiledEvalToBoolean; +} LIBXML2_2.6.25; + +LIBXML2_2.6.28 { + global: + +# xmlreader + xmlTextReaderSetup; +} LIBXML2_2.6.27; + +LIBXML2_2.6.29 { + global: + +# threads + xmlDllMain; +} LIBXML2_2.6.28; + +LIBXML2_2.6.32 { + global: + +# schematron + xmlSchematronSetValidStructuredErrors; +} LIBXML2_2.6.29; + +LIBXML2_2.7.0 { + global: + +# xmlmemory + xmlMemDisplayLast; + +# entities + xmlNewEntity; + +# xmlschemas + xmlSchemaValidCtxtGetParserCtxt; +} LIBXML2_2.6.32; + +LIBXML2_2.7.3 { + global: + +# tree + xmlChildElementCount; + xmlFirstElementChild; + xmlLastElementChild; + xmlNextElementSibling; + xmlPreviousElementSibling; +} LIBXML2_2.7.0; + +LIBXML2_2.7.4 { + global: + +# globals + xmlStructuredErrorContext; # variable + +# xinclude + xmlXIncludeProcessTreeFlagsData; +} LIBXML2_2.7.3; + +LIBXML2_2.8.0 { + global: + +# xmlreader + xmlTextReaderRelaxNGValidateCtxt; + +# tree + xmlBufferDetach; + +# dict + xmlInitializeDict; +} LIBXML2_2.7.4; + +LIBXML2_2.9.0 { + global: + +# tree + xmlBufContent; + xmlBufEnd; + xmlBufGetNodeContent; + xmlBufNodeDump; + xmlBufShrink; + xmlBufUse; + +# dict + xmlDictGetUsage; + xmlDictSetLimit; + +# xmlschemas + xmlSchemaValidateSetFilename; + xmlSchemaValidateSetLocator; + +# xmlIO + xmlOutputBufferGetContent; + xmlOutputBufferGetSize; + +# xmlwriter + xmlTextWriterSetQuoteChar; +} LIBXML2_2.8.0; + +LIBXML2_2.9.1 { + global: + +# xpath + xmlXPathNodeEval; + xmlXPathSetContextNode; +} LIBXML2_2.9.0; + +LIBXML2_2.9.8 { + global: + +# hash + xmlHashDefaultDeallocator; +} LIBXML2_2.9.1; + +LIBXML2_2.9.11 { + global: + +# xmlIO + xmlPopOutputCallbacks; +} LIBXML2_2.9.8; + diff --git a/src/list.c b/src/list.c new file mode 100644 index 000000000000..20207155190f --- /dev/null +++ b/src/list.c @@ -0,0 +1,779 @@ +/* + * list.c: lists handling implementation + * + * Copyright (C) 2000 Gary Pennington and Daniel Veillard. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + * + * Author: Gary.Pennington@uk.sun.com + */ + +#define IN_LIBXML +#include "libxml.h" + +#include +#include +#include +#include +#include + +/* + * Type definition are kept internal + */ + +struct _xmlLink +{ + struct _xmlLink *next; + struct _xmlLink *prev; + void *data; +}; + +struct _xmlList +{ + xmlLinkPtr sentinel; + void (*linkDeallocator)(xmlLinkPtr ); + int (*linkCompare)(const void *, const void*); +}; + +/************************************************************************ + * * + * Interfaces * + * * + ************************************************************************/ + +/** + * xmlLinkDeallocator: + * @l: a list + * @lk: a link + * + * Unlink and deallocate @lk from list @l + */ +static void +xmlLinkDeallocator(xmlListPtr l, xmlLinkPtr lk) +{ + (lk->prev)->next = lk->next; + (lk->next)->prev = lk->prev; + if(l->linkDeallocator) + l->linkDeallocator(lk); + xmlFree(lk); +} + +/** + * xmlLinkCompare: + * @data0: first data + * @data1: second data + * + * Compares two arbitrary data + * + * Returns -1, 0 or 1 depending on whether data1 is greater equal or smaller + * than data0 + */ +static int +xmlLinkCompare(const void *data0, const void *data1) +{ + if (data0 < data1) + return (-1); + else if (data0 == data1) + return (0); + return (1); +} + +/** + * xmlListLowerSearch: + * @l: a list + * @data: a data + * + * Search data in the ordered list walking from the beginning + * + * Returns the link containing the data or NULL + */ +static xmlLinkPtr +xmlListLowerSearch(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + + if (l == NULL) + return(NULL); + for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next); + return lk; +} + +/** + * xmlListHigherSearch: + * @l: a list + * @data: a data + * + * Search data in the ordered list walking backward from the end + * + * Returns the link containing the data or NULL + */ +static xmlLinkPtr +xmlListHigherSearch(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + + if (l == NULL) + return(NULL); + for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev); + return lk; +} + +/** + * xmlListSearch: + * @l: a list + * @data: a data + * + * Search data in the list + * + * Returns the link containing the data or NULL + */ +static xmlLinkPtr +xmlListLinkSearch(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + if (l == NULL) + return(NULL); + lk = xmlListLowerSearch(l, data); + if (lk == l->sentinel) + return NULL; + else { + if (l->linkCompare(lk->data, data) ==0) + return lk; + return NULL; + } +} + +/** + * xmlListLinkReverseSearch: + * @l: a list + * @data: a data + * + * Search data in the list processing backward + * + * Returns the link containing the data or NULL + */ +static xmlLinkPtr +xmlListLinkReverseSearch(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + if (l == NULL) + return(NULL); + lk = xmlListHigherSearch(l, data); + if (lk == l->sentinel) + return NULL; + else { + if (l->linkCompare(lk->data, data) ==0) + return lk; + return NULL; + } +} + +/** + * xmlListCreate: + * @deallocator: an optional deallocator function + * @compare: an optional comparison function + * + * Create a new list + * + * Returns the new list or NULL in case of error + */ +xmlListPtr +xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare) +{ + xmlListPtr l; + if (NULL == (l = (xmlListPtr )xmlMalloc( sizeof(xmlList)))) { + xmlGenericError(xmlGenericErrorContext, + "Cannot initialize memory for list"); + return (NULL); + } + /* Initialize the list to NULL */ + memset(l, 0, sizeof(xmlList)); + + /* Add the sentinel */ + if (NULL ==(l->sentinel = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { + xmlGenericError(xmlGenericErrorContext, + "Cannot initialize memory for sentinel"); + xmlFree(l); + return (NULL); + } + l->sentinel->next = l->sentinel; + l->sentinel->prev = l->sentinel; + l->sentinel->data = NULL; + + /* If there is a link deallocator, use it */ + if (deallocator != NULL) + l->linkDeallocator = deallocator; + /* If there is a link comparator, use it */ + if (compare != NULL) + l->linkCompare = compare; + else /* Use our own */ + l->linkCompare = xmlLinkCompare; + return l; +} + +/** + * xmlListSearch: + * @l: a list + * @data: a search value + * + * Search the list for an existing value of @data + * + * Returns the value associated to @data or NULL in case of error + */ +void * +xmlListSearch(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + if (l == NULL) + return(NULL); + lk = xmlListLinkSearch(l, data); + if (lk) + return (lk->data); + return NULL; +} + +/** + * xmlListReverseSearch: + * @l: a list + * @data: a search value + * + * Search the list in reverse order for an existing value of @data + * + * Returns the value associated to @data or NULL in case of error + */ +void * +xmlListReverseSearch(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + if (l == NULL) + return(NULL); + lk = xmlListLinkReverseSearch(l, data); + if (lk) + return (lk->data); + return NULL; +} + +/** + * xmlListInsert: + * @l: a list + * @data: the data + * + * Insert data in the ordered list at the beginning for this value + * + * Returns 0 in case of success, 1 in case of failure + */ +int +xmlListInsert(xmlListPtr l, void *data) +{ + xmlLinkPtr lkPlace, lkNew; + + if (l == NULL) + return(1); + lkPlace = xmlListLowerSearch(l, data); + /* Add the new link */ + lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); + if (lkNew == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot initialize memory for new link"); + return (1); + } + lkNew->data = data; + lkPlace = lkPlace->prev; + lkNew->next = lkPlace->next; + (lkPlace->next)->prev = lkNew; + lkPlace->next = lkNew; + lkNew->prev = lkPlace; + return 0; +} + +/** + * xmlListAppend: + * @l: a list + * @data: the data + * + * Insert data in the ordered list at the end for this value + * + * Returns 0 in case of success, 1 in case of failure + */ +int xmlListAppend(xmlListPtr l, void *data) +{ + xmlLinkPtr lkPlace, lkNew; + + if (l == NULL) + return(1); + lkPlace = xmlListHigherSearch(l, data); + /* Add the new link */ + lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); + if (lkNew == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot initialize memory for new link"); + return (1); + } + lkNew->data = data; + lkNew->next = lkPlace->next; + (lkPlace->next)->prev = lkNew; + lkPlace->next = lkNew; + lkNew->prev = lkPlace; + return 0; +} + +/** + * xmlListDelete: + * @l: a list + * + * Deletes the list and its associated data + */ +void xmlListDelete(xmlListPtr l) +{ + if (l == NULL) + return; + + xmlListClear(l); + xmlFree(l->sentinel); + xmlFree(l); +} + +/** + * xmlListRemoveFirst: + * @l: a list + * @data: list data + * + * Remove the first instance associated to data in the list + * + * Returns 1 if a deallocation occurred, or 0 if not found + */ +int +xmlListRemoveFirst(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + + if (l == NULL) + return(0); + /*Find the first instance of this data */ + lk = xmlListLinkSearch(l, data); + if (lk != NULL) { + xmlLinkDeallocator(l, lk); + return 1; + } + return 0; +} + +/** + * xmlListRemoveLast: + * @l: a list + * @data: list data + * + * Remove the last instance associated to data in the list + * + * Returns 1 if a deallocation occurred, or 0 if not found + */ +int +xmlListRemoveLast(xmlListPtr l, void *data) +{ + xmlLinkPtr lk; + + if (l == NULL) + return(0); + /*Find the last instance of this data */ + lk = xmlListLinkReverseSearch(l, data); + if (lk != NULL) { + xmlLinkDeallocator(l, lk); + return 1; + } + return 0; +} + +/** + * xmlListRemoveAll: + * @l: a list + * @data: list data + * + * Remove the all instance associated to data in the list + * + * Returns the number of deallocation, or 0 if not found + */ +int +xmlListRemoveAll(xmlListPtr l, void *data) +{ + int count=0; + + if (l == NULL) + return(0); + + while(xmlListRemoveFirst(l, data)) + count++; + return count; +} + +/** + * xmlListClear: + * @l: a list + * + * Remove the all data in the list + */ +void +xmlListClear(xmlListPtr l) +{ + xmlLinkPtr lk; + + if (l == NULL) + return; + lk = l->sentinel->next; + while(lk != l->sentinel) { + xmlLinkPtr next = lk->next; + + xmlLinkDeallocator(l, lk); + lk = next; + } +} + +/** + * xmlListEmpty: + * @l: a list + * + * Is the list empty ? + * + * Returns 1 if the list is empty, 0 if not empty and -1 in case of error + */ +int +xmlListEmpty(xmlListPtr l) +{ + if (l == NULL) + return(-1); + return (l->sentinel->next == l->sentinel); +} + +/** + * xmlListFront: + * @l: a list + * + * Get the first element in the list + * + * Returns the first element in the list, or NULL + */ +xmlLinkPtr +xmlListFront(xmlListPtr l) +{ + if (l == NULL) + return(NULL); + return (l->sentinel->next); +} + +/** + * xmlListEnd: + * @l: a list + * + * Get the last element in the list + * + * Returns the last element in the list, or NULL + */ +xmlLinkPtr +xmlListEnd(xmlListPtr l) +{ + if (l == NULL) + return(NULL); + return (l->sentinel->prev); +} + +/** + * xmlListSize: + * @l: a list + * + * Get the number of elements in the list + * + * Returns the number of elements in the list or -1 in case of error + */ +int +xmlListSize(xmlListPtr l) +{ + xmlLinkPtr lk; + int count=0; + + if (l == NULL) + return(-1); + /* TODO: keep a counter in xmlList instead */ + for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next, count++); + return count; +} + +/** + * xmlListPopFront: + * @l: a list + * + * Removes the first element in the list + */ +void +xmlListPopFront(xmlListPtr l) +{ + if(!xmlListEmpty(l)) + xmlLinkDeallocator(l, l->sentinel->next); +} + +/** + * xmlListPopBack: + * @l: a list + * + * Removes the last element in the list + */ +void +xmlListPopBack(xmlListPtr l) +{ + if(!xmlListEmpty(l)) + xmlLinkDeallocator(l, l->sentinel->prev); +} + +/** + * xmlListPushFront: + * @l: a list + * @data: new data + * + * add the new data at the beginning of the list + * + * Returns 1 if successful, 0 otherwise + */ +int +xmlListPushFront(xmlListPtr l, void *data) +{ + xmlLinkPtr lkPlace, lkNew; + + if (l == NULL) + return(0); + lkPlace = l->sentinel; + /* Add the new link */ + lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); + if (lkNew == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot initialize memory for new link"); + return (0); + } + lkNew->data = data; + lkNew->next = lkPlace->next; + (lkPlace->next)->prev = lkNew; + lkPlace->next = lkNew; + lkNew->prev = lkPlace; + return 1; +} + +/** + * xmlListPushBack: + * @l: a list + * @data: new data + * + * add the new data at the end of the list + * + * Returns 1 if successful, 0 otherwise + */ +int +xmlListPushBack(xmlListPtr l, void *data) +{ + xmlLinkPtr lkPlace, lkNew; + + if (l == NULL) + return(0); + lkPlace = l->sentinel->prev; + /* Add the new link */ + if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { + xmlGenericError(xmlGenericErrorContext, + "Cannot initialize memory for new link"); + return (0); + } + lkNew->data = data; + lkNew->next = lkPlace->next; + (lkPlace->next)->prev = lkNew; + lkPlace->next = lkNew; + lkNew->prev = lkPlace; + return 1; +} + +/** + * xmlLinkGetData: + * @lk: a link + * + * See Returns. + * + * Returns a pointer to the data referenced from this link + */ +void * +xmlLinkGetData(xmlLinkPtr lk) +{ + if (lk == NULL) + return(NULL); + return lk->data; +} + +/** + * xmlListReverse: + * @l: a list + * + * Reverse the order of the elements in the list + */ +void +xmlListReverse(xmlListPtr l) +{ + xmlLinkPtr lk; + xmlLinkPtr lkPrev; + + if (l == NULL) + return; + lkPrev = l->sentinel; + for (lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) { + lkPrev->next = lkPrev->prev; + lkPrev->prev = lk; + lkPrev = lk; + } + /* Fix up the last node */ + lkPrev->next = lkPrev->prev; + lkPrev->prev = lk; +} + +/** + * xmlListSort: + * @l: a list + * + * Sort all the elements in the list + */ +void +xmlListSort(xmlListPtr l) +{ + xmlListPtr lTemp; + + if (l == NULL) + return; + if(xmlListEmpty(l)) + return; + + /* I think that the real answer is to implement quicksort, the + * alternative is to implement some list copying procedure which + * would be based on a list copy followed by a clear followed by + * an insert. This is slow... + */ + + if (NULL ==(lTemp = xmlListDup(l))) + return; + xmlListClear(l); + xmlListMerge(l, lTemp); + xmlListDelete(lTemp); + return; +} + +/** + * xmlListWalk: + * @l: a list + * @walker: a processing function + * @user: a user parameter passed to the walker function + * + * Walk all the element of the first from first to last and + * apply the walker function to it + */ +void +xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user) { + xmlLinkPtr lk; + + if ((l == NULL) || (walker == NULL)) + return; + for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) { + if((walker(lk->data, user)) == 0) + break; + } +} + +/** + * xmlListReverseWalk: + * @l: a list + * @walker: a processing function + * @user: a user parameter passed to the walker function + * + * Walk all the element of the list in reverse order and + * apply the walker function to it + */ +void +xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, void *user) { + xmlLinkPtr lk; + + if ((l == NULL) || (walker == NULL)) + return; + for(lk = l->sentinel->prev; lk != l->sentinel; lk = lk->prev) { + if((walker(lk->data, user)) == 0) + break; + } +} + +/** + * xmlListMerge: + * @l1: the original list + * @l2: the new list + * + * include all the elements of the second list in the first one and + * clear the second list + */ +void +xmlListMerge(xmlListPtr l1, xmlListPtr l2) +{ + xmlListCopy(l1, l2); + xmlListClear(l2); +} + +/** + * xmlListDup: + * @old: the list + * + * Duplicate the list + * + * Returns a new copy of the list or NULL in case of error + */ +xmlListPtr +xmlListDup(const xmlListPtr old) +{ + xmlListPtr cur; + + if (old == NULL) + return(NULL); + /* Hmmm, how to best deal with allocation issues when copying + * lists. If there is a de-allocator, should responsibility lie with + * the new list or the old list. Surely not both. I'll arbitrarily + * set it to be the old list for the time being whilst I work out + * the answer + */ + if (NULL ==(cur = xmlListCreate(NULL, old->linkCompare))) + return (NULL); + if (0 != xmlListCopy(cur, old)) + return NULL; + return cur; +} + +/** + * xmlListCopy: + * @cur: the new list + * @old: the old list + * + * Move all the element from the old list in the new list + * + * Returns 0 in case of success 1 in case of error + */ +int +xmlListCopy(xmlListPtr cur, const xmlListPtr old) +{ + /* Walk the old tree and insert the data into the new one */ + xmlLinkPtr lk; + + if ((old == NULL) || (cur == NULL)) + return(1); + for(lk = old->sentinel->next; lk != old->sentinel; lk = lk->next) { + if (0 !=xmlListInsert(cur, lk->data)) { + xmlListDelete(cur); + return (1); + } + } + return (0); +} +/* xmlListUnique() */ +/* xmlListSwap */ +#define bottom_list +#include "elfgcchack.h" diff --git a/src/macos/README b/src/macos/README new file mode 100644 index 000000000000..434aece685a1 --- /dev/null +++ b/src/macos/README @@ -0,0 +1,8 @@ +This is a MacOS port contribution (not to be used for MacOS-X) +for the CodeWarrior environment. +Please contact the author directly in case of problems: + Eric + + thanks, + +Daniel diff --git a/src/macos/src/XMLTestPrefix.h b/src/macos/src/XMLTestPrefix.h new file mode 100644 index 000000000000..3e84255cb61f --- /dev/null +++ b/src/macos/src/XMLTestPrefix.h @@ -0,0 +1 @@ +int test_main(int argc, char **argv); #define main(X,Y) test_main(X,Y) \ No newline at end of file diff --git a/src/macos/src/XMLTestPrefix2.h b/src/macos/src/XMLTestPrefix2.h new file mode 100644 index 000000000000..55df51eabba4 --- /dev/null +++ b/src/macos/src/XMLTestPrefix2.h @@ -0,0 +1 @@ +int test_main(int argc, char* argv[]); #define main() test_main(int argc, char* argv[]) \ No newline at end of file diff --git a/src/macos/src/config-mac.h b/src/macos/src/config-mac.h new file mode 100644 index 000000000000..ca6f99394101 --- /dev/null +++ b/src/macos/src/config-mac.h @@ -0,0 +1,150 @@ +/* config.h generated manually for macos. */ + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS + +#define PACKAGE +#define VERSION + +#undef HAVE_LIBZ +#undef HAVE_LIBM +#undef HAVE_ISINF +#undef HAVE_ISNAN +#undef HAVE_LIBHISTORY +#undef HAVE_LIBREADLINE + +#define XML_SOCKLEN_T socklen_t +#define HAVE_LIBPTHREAD +#define HAVE_PTHREAD_H +#define LIBXML_THREAD_ENABLED + +/* Define if you have the fprintf function. */ +#define HAVE_FPRINTF + +/* Define if you have the localtime function. */ +#define HAVE_LOCALTIME + +/* Define if you have the printf function. */ +#define HAVE_PRINTF + +/* Define if you have the signal function. */ +#define HAVE_SIGNAL + +/* Define if you have the snprintf function. */ +#define HAVE_SNPRINTF + +/* Define if you have the sprintf function. */ +#define HAVE_SPRINTF + +/* Define if you have the sscanf function. */ +#define HAVE_SSCANF + +/* Define if you have the stat function. */ +#define HAVE_STAT + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME + +/* Define if you have the vfprintf function. */ +#define HAVE_VFPRINTF + +/* Define if you have the vsnprintf function. */ +#define HAVE_VSNPRINTF + +/* Define if you have the vsprintf function. */ +#define HAVE_VSPRINTF + +/* Define if you have the header file. */ +#define HAVE_ARPA_INET_H + +/* Define if you have the header file. */ +#define HAVE_CTYPE_H + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H + +/* Define if you have the header file. */ +#define HAVE_DLFCN_H + +/* Define if you have the header file. */ +#define HAVE_ERRNO_H + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H + +/* Define if you have the header file. */ +#define HAVE_FLOAT_H + +/* Define if you have the header file. */ +#undef HAVE_MALLOC_H + +/* Define if you have the header file. */ +#define HAVE_MATH_H + +/* Define if you have the header file. */ +#define HAVE_NDIR_H + +/* Define if you have the header file. */ +#define HAVE_NETDB_H + +/* Define if you have the header file. */ +#define HAVE_NETINET_IN_H + +/* Define if you have the header file. */ +#define HAVE_SIGNAL_H + +/* Define if you have the header file. */ +#define HAVE_STDARG_H + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the header file. */ +#define HAVE_STRING_H + +/* Define if you have the header file. */ +#define HAVE_SYS_DIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the header file. */ +#define HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#define HAVE_SYS_SOCKET_H + +/* Define if you have the header file. */ +#define HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#define HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#define HAVE_TIME_H + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H + +/* Name of package */ +#define PACKAGE + +/* Version number of package */ +#define VERSION + +/* Define if compiler has function prototypes */ +#define PROTOTYPES + +#include +#include +#include +#include diff --git a/src/macos/src/libxml2_GUSIConfig.cp b/src/macos/src/libxml2_GUSIConfig.cp new file mode 100644 index 000000000000..77d0c93a6465 --- /dev/null +++ b/src/macos/src/libxml2_GUSIConfig.cp @@ -0,0 +1 @@ +/**************** BEGIN GUSI CONFIGURATION **************************** * * GUSI Configuration section generated by GUSI Configurator * last modified: Wed Oct 31 17:07:45 2001 * * This section will be overwritten by the next run of Configurator. */ #define GUSI_SOURCE #include #include /* Declarations of Socket Factories */ __BEGIN_DECLS void GUSIwithInetSockets(); void GUSIwithLocalSockets(); void GUSIwithMTInetSockets(); void GUSIwithMTTcpSockets(); void GUSIwithMTUdpSockets(); void GUSIwithOTInetSockets(); void GUSIwithOTTcpSockets(); void GUSIwithOTUdpSockets(); void GUSIwithPPCSockets(); void GUSISetupFactories(); __END_DECLS /* Configure Socket Factories */ void GUSISetupFactories() { #ifdef GUSISetupFactories_BeginHook GUSISetupFactories_BeginHook #endif GUSIwithInetSockets(); #ifdef GUSISetupFactories_EndHook GUSISetupFactories_EndHook #endif } /* Declarations of File Devices */ __BEGIN_DECLS void GUSIwithNullSockets(); void GUSISetupDevices(); __END_DECLS /* Configure File Devices */ void GUSISetupDevices() { #ifdef GUSISetupDevices_BeginHook GUSISetupDevices_BeginHook #endif GUSIwithNullSockets(); #ifdef GUSISetupDevices_EndHook GUSISetupDevices_EndHook #endif } #ifndef __cplusplus #error GUSISetupConfig() needs to be written in C++ #endif GUSIConfiguration::FileSuffix sSuffices[] = { "", '????', '????' }; extern "C" void GUSISetupConfig() { GUSIConfiguration * config = GUSIConfiguration::CreateInstance(GUSIConfiguration::kNoResource); config->ConfigureDefaultTypeCreator('TEXT', 'CWIE'); config->ConfigureSuffices( sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices); } /**************** END GUSI CONFIGURATION *************************/ \ No newline at end of file diff --git a/src/macos/src/macos_main.c b/src/macos/src/macos_main.c new file mode 100644 index 000000000000..262500038fbf --- /dev/null +++ b/src/macos/src/macos_main.c @@ -0,0 +1 @@ +#include #include #undef main DECLARE_MAIN(test) REGISTER_MAIN_START REGISTER_MAIN(test) REGISTER_MAIN_END int main() { (void) exec_commands(); return 0; } \ No newline at end of file diff --git a/src/nanoftp.c b/src/nanoftp.c new file mode 100644 index 000000000000..18c1ce4377cc --- /dev/null +++ b/src/nanoftp.c @@ -0,0 +1,2118 @@ +/* + * nanoftp.c: basic FTP client support + * + * Reference: RFC 959 + */ + +#ifdef TESTING +#define STANDALONE +#define HAVE_STDLIB_H +#define HAVE_UNISTD_H +#define HAVE_SYS_SOCKET_H +#define HAVE_NETINET_IN_H +#define HAVE_NETDB_H +#define HAVE_SYS_TIME_H +#endif /* TESTING */ + +#define IN_LIBXML +#include "libxml.h" + +#ifdef LIBXML_FTP_ENABLED +#include + +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STRINGS_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +/* #define DEBUG_FTP 1 */ +#ifdef STANDALONE +#ifndef DEBUG_FTP +#define DEBUG_FTP 1 +#endif +#endif + + +#if defined(_WIN32) && !defined(__CYGWIN__) +#include +#endif + +/** + * A couple portability macros + */ +#ifndef _WINSOCKAPI_ +#if !defined(__BEOS__) || defined(__HAIKU__) +#define closesocket(s) close(s) +#endif +#endif + +#ifdef __BEOS__ +#ifndef PF_INET +#define PF_INET AF_INET +#endif +#endif + +#ifdef _AIX +#ifdef HAVE_BROKEN_SS_FAMILY +#define ss_family __ss_family +#endif +#endif + +#ifndef XML_SOCKLEN_T +#define XML_SOCKLEN_T unsigned int +#endif + +#define FTP_COMMAND_OK 200 +#define FTP_SYNTAX_ERROR 500 +#define FTP_GET_PASSWD 331 +#define FTP_BUF_SIZE 1024 + +#define XML_NANO_MAX_URLBUF 4096 + +typedef struct xmlNanoFTPCtxt { + char *protocol; /* the protocol name */ + char *hostname; /* the host name */ + int port; /* the port */ + char *path; /* the path within the URL */ + char *user; /* user string */ + char *passwd; /* passwd string */ +#ifdef SUPPORT_IP6 + struct sockaddr_storage ftpAddr; /* this is large enough to hold IPv6 address*/ +#else + struct sockaddr_in ftpAddr; /* the socket address struct */ +#endif + int passive; /* currently we support only passive !!! */ + SOCKET controlFd; /* the file descriptor for the control socket */ + SOCKET dataFd; /* the file descriptor for the data socket */ + int state; /* WRITE / READ / CLOSED */ + int returnValue; /* the protocol return value */ + /* buffer for data received from the control connection */ + char controlBuf[FTP_BUF_SIZE + 1]; + int controlBufIndex; + int controlBufUsed; + int controlBufAnswer; +} xmlNanoFTPCtxt, *xmlNanoFTPCtxtPtr; + +static int initialized = 0; +static char *proxy = NULL; /* the proxy name if any */ +static int proxyPort = 0; /* the proxy port if any */ +static char *proxyUser = NULL; /* user for proxy authentication */ +static char *proxyPasswd = NULL;/* passwd for proxy authentication */ +static int proxyType = 0; /* uses TYPE or a@b ? */ + +#ifdef SUPPORT_IP6 +static +int have_ipv6(void) { + int s; + + s = socket (AF_INET6, SOCK_STREAM, 0); + if (s != -1) { + close (s); + return (1); + } + return (0); +} +#endif + +/** + * xmlFTPErrMemory: + * @extra: extra information + * + * Handle an out of memory condition + */ +static void +xmlFTPErrMemory(const char *extra) +{ + __xmlSimpleError(XML_FROM_FTP, XML_ERR_NO_MEMORY, NULL, NULL, extra); +} + +/** + * xmlNanoFTPInit: + * + * Initialize the FTP protocol layer. + * Currently it just checks for proxy information, + * and get the hostname + */ + +void +xmlNanoFTPInit(void) { + const char *env; +#ifdef _WINSOCKAPI_ + WSADATA wsaData; +#endif + + if (initialized) + return; + +#ifdef _WINSOCKAPI_ + if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) + return; +#endif + + proxyPort = 21; + env = getenv("no_proxy"); + if (env && ((env[0] == '*' ) && (env[1] == 0))) + return; + env = getenv("ftp_proxy"); + if (env != NULL) { + xmlNanoFTPScanProxy(env); + } else { + env = getenv("FTP_PROXY"); + if (env != NULL) { + xmlNanoFTPScanProxy(env); + } + } + env = getenv("ftp_proxy_user"); + if (env != NULL) { + proxyUser = xmlMemStrdup(env); + } + env = getenv("ftp_proxy_password"); + if (env != NULL) { + proxyPasswd = xmlMemStrdup(env); + } + initialized = 1; +} + +/** + * xmlNanoFTPCleanup: + * + * Cleanup the FTP protocol layer. This cleanup proxy information. + */ + +void +xmlNanoFTPCleanup(void) { + if (proxy != NULL) { + xmlFree(proxy); + proxy = NULL; + } + if (proxyUser != NULL) { + xmlFree(proxyUser); + proxyUser = NULL; + } + if (proxyPasswd != NULL) { + xmlFree(proxyPasswd); + proxyPasswd = NULL; + } +#ifdef _WINSOCKAPI_ + if (initialized) + WSACleanup(); +#endif + initialized = 0; +} + +/** + * xmlNanoFTPProxy: + * @host: the proxy host name + * @port: the proxy port + * @user: the proxy user name + * @passwd: the proxy password + * @type: the type of proxy 1 for using SITE, 2 for USER a@b + * + * Setup the FTP proxy information. + * This can also be done by using ftp_proxy ftp_proxy_user and + * ftp_proxy_password environment variables. + */ + +void +xmlNanoFTPProxy(const char *host, int port, const char *user, + const char *passwd, int type) { + if (proxy != NULL) { + xmlFree(proxy); + proxy = NULL; + } + if (proxyUser != NULL) { + xmlFree(proxyUser); + proxyUser = NULL; + } + if (proxyPasswd != NULL) { + xmlFree(proxyPasswd); + proxyPasswd = NULL; + } + if (host) + proxy = xmlMemStrdup(host); + if (user) + proxyUser = xmlMemStrdup(user); + if (passwd) + proxyPasswd = xmlMemStrdup(passwd); + proxyPort = port; + proxyType = type; +} + +/** + * xmlNanoFTPScanURL: + * @ctx: an FTP context + * @URL: The URL used to initialize the context + * + * (Re)Initialize an FTP context by parsing the URL and finding + * the protocol host port and path it indicates. + */ + +static void +xmlNanoFTPScanURL(void *ctx, const char *URL) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + xmlURIPtr uri; + + /* + * Clear any existing data from the context + */ + if (ctxt->protocol != NULL) { + xmlFree(ctxt->protocol); + ctxt->protocol = NULL; + } + if (ctxt->hostname != NULL) { + xmlFree(ctxt->hostname); + ctxt->hostname = NULL; + } + if (ctxt->path != NULL) { + xmlFree(ctxt->path); + ctxt->path = NULL; + } + if (URL == NULL) return; + + uri = xmlParseURIRaw(URL, 1); + if (uri == NULL) + return; + + if ((uri->scheme == NULL) || (uri->server == NULL)) { + xmlFreeURI(uri); + return; + } + + ctxt->protocol = xmlMemStrdup(uri->scheme); + ctxt->hostname = xmlMemStrdup(uri->server); + if (uri->path != NULL) + ctxt->path = xmlMemStrdup(uri->path); + else + ctxt->path = xmlMemStrdup("/"); + if (uri->port != 0) + ctxt->port = uri->port; + + if (uri->user != NULL) { + char *cptr; + if ((cptr=strchr(uri->user, ':')) == NULL) + ctxt->user = xmlMemStrdup(uri->user); + else { + ctxt->user = (char *)xmlStrndup((xmlChar *)uri->user, + (cptr - uri->user)); + ctxt->passwd = xmlMemStrdup(cptr+1); + } + } + + xmlFreeURI(uri); + +} + +/** + * xmlNanoFTPUpdateURL: + * @ctx: an FTP context + * @URL: The URL used to update the context + * + * Update an FTP context by parsing the URL and finding + * new path it indicates. If there is an error in the + * protocol, hostname, port or other information, the + * error is raised. It indicates a new connection has to + * be established. + * + * Returns 0 if Ok, -1 in case of error (other host). + */ + +int +xmlNanoFTPUpdateURL(void *ctx, const char *URL) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + xmlURIPtr uri; + + if (URL == NULL) + return(-1); + if (ctxt == NULL) + return(-1); + if (ctxt->protocol == NULL) + return(-1); + if (ctxt->hostname == NULL) + return(-1); + + uri = xmlParseURIRaw(URL, 1); + if (uri == NULL) + return(-1); + + if ((uri->scheme == NULL) || (uri->server == NULL)) { + xmlFreeURI(uri); + return(-1); + } + if ((strcmp(ctxt->protocol, uri->scheme)) || + (strcmp(ctxt->hostname, uri->server)) || + ((uri->port != 0) && (ctxt->port != uri->port))) { + xmlFreeURI(uri); + return(-1); + } + + if (uri->port != 0) + ctxt->port = uri->port; + + if (ctxt->path != NULL) { + xmlFree(ctxt->path); + ctxt->path = NULL; + } + + if (uri->path == NULL) + ctxt->path = xmlMemStrdup("/"); + else + ctxt->path = xmlMemStrdup(uri->path); + + xmlFreeURI(uri); + + return(0); +} + +/** + * xmlNanoFTPScanProxy: + * @URL: The proxy URL used to initialize the proxy context + * + * (Re)Initialize the FTP Proxy context by parsing the URL and finding + * the protocol host port it indicates. + * Should be like ftp://myproxy/ or ftp://myproxy:3128/ + * A NULL URL cleans up proxy information. + */ + +void +xmlNanoFTPScanProxy(const char *URL) { + xmlURIPtr uri; + + if (proxy != NULL) { + xmlFree(proxy); + proxy = NULL; + } + proxyPort = 0; + +#ifdef DEBUG_FTP + if (URL == NULL) + xmlGenericError(xmlGenericErrorContext, + "Removing FTP proxy info\n"); + else + xmlGenericError(xmlGenericErrorContext, + "Using FTP proxy %s\n", URL); +#endif + if (URL == NULL) return; + + uri = xmlParseURIRaw(URL, 1); + if ((uri == NULL) || (uri->scheme == NULL) || + (strcmp(uri->scheme, "ftp")) || (uri->server == NULL)) { + __xmlIOErr(XML_FROM_FTP, XML_FTP_URL_SYNTAX, "Syntax Error\n"); + if (uri != NULL) + xmlFreeURI(uri); + return; + } + + proxy = xmlMemStrdup(uri->server); + if (uri->port != 0) + proxyPort = uri->port; + + xmlFreeURI(uri); +} + +/** + * xmlNanoFTPNewCtxt: + * @URL: The URL used to initialize the context + * + * Allocate and initialize a new FTP context. + * + * Returns an FTP context or NULL in case of error. + */ + +void* +xmlNanoFTPNewCtxt(const char *URL) { + xmlNanoFTPCtxtPtr ret; + char *unescaped; + + ret = (xmlNanoFTPCtxtPtr) xmlMalloc(sizeof(xmlNanoFTPCtxt)); + if (ret == NULL) { + xmlFTPErrMemory("allocating FTP context"); + return(NULL); + } + + memset(ret, 0, sizeof(xmlNanoFTPCtxt)); + ret->port = 21; + ret->passive = 1; + ret->returnValue = 0; + ret->controlBufIndex = 0; + ret->controlBufUsed = 0; + ret->controlFd = INVALID_SOCKET; + + unescaped = xmlURIUnescapeString(URL, 0, NULL); + if (unescaped != NULL) { + xmlNanoFTPScanURL(ret, unescaped); + xmlFree(unescaped); + } else if (URL != NULL) + xmlNanoFTPScanURL(ret, URL); + + return(ret); +} + +/** + * xmlNanoFTPFreeCtxt: + * @ctx: an FTP context + * + * Frees the context after closing the connection. + */ + +void +xmlNanoFTPFreeCtxt(void * ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + if (ctxt == NULL) return; + if (ctxt->hostname != NULL) xmlFree(ctxt->hostname); + if (ctxt->protocol != NULL) xmlFree(ctxt->protocol); + if (ctxt->path != NULL) xmlFree(ctxt->path); + if (ctxt->user != NULL) xmlFree(ctxt->user); + if (ctxt->passwd != NULL) xmlFree(ctxt->passwd); + ctxt->passive = 1; + if (ctxt->controlFd != INVALID_SOCKET) closesocket(ctxt->controlFd); + ctxt->controlFd = INVALID_SOCKET; + ctxt->controlBufIndex = -1; + ctxt->controlBufUsed = -1; + xmlFree(ctxt); +} + +/** + * xmlNanoFTPParseResponse: + * @buf: the buffer containing the response + * @len: the buffer length + * + * Parsing of the server answer, we just extract the code. + * + * returns 0 for errors + * +XXX for last line of response + * -XXX for response to be continued + */ +static int +xmlNanoFTPParseResponse(char *buf, int len) { + int val = 0; + + if (len < 3) return(-1); + if ((*buf >= '0') && (*buf <= '9')) + val = val * 10 + (*buf - '0'); + else + return(0); + buf++; + if ((*buf >= '0') && (*buf <= '9')) + val = val * 10 + (*buf - '0'); + else + return(0); + buf++; + if ((*buf >= '0') && (*buf <= '9')) + val = val * 10 + (*buf - '0'); + else + return(0); + buf++; + if (*buf == '-') + return(-val); + return(val); +} + +/** + * xmlNanoFTPGetMore: + * @ctx: an FTP context + * + * Read more information from the FTP control connection + * Returns the number of bytes read, < 0 indicates an error + */ +static int +xmlNanoFTPGetMore(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + int len; + int size; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1); + + if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) { +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoFTPGetMore : controlBufIndex = %d\n", + ctxt->controlBufIndex); +#endif + return(-1); + } + + if ((ctxt->controlBufUsed < 0) || (ctxt->controlBufUsed > FTP_BUF_SIZE)) { +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoFTPGetMore : controlBufUsed = %d\n", + ctxt->controlBufUsed); +#endif + return(-1); + } + if (ctxt->controlBufIndex > ctxt->controlBufUsed) { +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoFTPGetMore : controlBufIndex > controlBufUsed %d > %d\n", + ctxt->controlBufIndex, ctxt->controlBufUsed); +#endif + return(-1); + } + + /* + * First pack the control buffer + */ + if (ctxt->controlBufIndex > 0) { + memmove(&ctxt->controlBuf[0], &ctxt->controlBuf[ctxt->controlBufIndex], + ctxt->controlBufUsed - ctxt->controlBufIndex); + ctxt->controlBufUsed -= ctxt->controlBufIndex; + ctxt->controlBufIndex = 0; + } + size = FTP_BUF_SIZE - ctxt->controlBufUsed; + if (size == 0) { +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoFTPGetMore : buffer full %d \n", ctxt->controlBufUsed); +#endif + return(0); + } + + /* + * Read the amount left on the control connection + */ + if ((len = recv(ctxt->controlFd, &ctxt->controlBuf[ctxt->controlBufIndex], + size, 0)) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "recv failed"); + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoFTPGetMore : read %d [%d - %d]\n", len, + ctxt->controlBufUsed, ctxt->controlBufUsed + len); +#endif + ctxt->controlBufUsed += len; + ctxt->controlBuf[ctxt->controlBufUsed] = 0; + + return(len); +} + +/** + * xmlNanoFTPReadResponse: + * @ctx: an FTP context + * + * Read the response from the FTP server after a command. + * Returns the code number + */ +static int +xmlNanoFTPReadResponse(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char *ptr, *end; + int len; + int res = -1, cur = -1; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1); + +get_more: + /* + * Assumes everything up to controlBuf[controlBufIndex] has been read + * and analyzed. + */ + len = xmlNanoFTPGetMore(ctx); + if (len < 0) { + return(-1); + } + if ((ctxt->controlBufUsed == 0) && (len == 0)) { + return(-1); + } + ptr = &ctxt->controlBuf[ctxt->controlBufIndex]; + end = &ctxt->controlBuf[ctxt->controlBufUsed]; + +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "\n<<<\n%s\n--\n", ptr); +#endif + while (ptr < end) { + cur = xmlNanoFTPParseResponse(ptr, end - ptr); + if (cur > 0) { + /* + * Successfully scanned the control code, scratch + * till the end of the line, but keep the index to be + * able to analyze the result if needed. + */ + res = cur; + ptr += 3; + ctxt->controlBufAnswer = ptr - ctxt->controlBuf; + while ((ptr < end) && (*ptr != '\n')) ptr++; + if (*ptr == '\n') ptr++; + if (*ptr == '\r') ptr++; + break; + } + while ((ptr < end) && (*ptr != '\n')) ptr++; + if (ptr >= end) { + ctxt->controlBufIndex = ctxt->controlBufUsed; + goto get_more; + } + if (*ptr != '\r') ptr++; + } + + if (res < 0) goto get_more; + ctxt->controlBufIndex = ptr - ctxt->controlBuf; +#ifdef DEBUG_FTP + ptr = &ctxt->controlBuf[ctxt->controlBufIndex]; + xmlGenericError(xmlGenericErrorContext, "\n---\n%s\n--\n", ptr); +#endif + +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "Got %d\n", res); +#endif + return(res / 100); +} + +/** + * xmlNanoFTPGetResponse: + * @ctx: an FTP context + * + * Get the response from the FTP server after a command. + * Returns the code number + */ + +int +xmlNanoFTPGetResponse(void *ctx) { + int res; + + res = xmlNanoFTPReadResponse(ctx); + + return(res); +} + +/** + * xmlNanoFTPCheckResponse: + * @ctx: an FTP context + * + * Check if there is a response from the FTP server after a command. + * Returns the code number, or 0 + */ + +int +xmlNanoFTPCheckResponse(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + fd_set rfd; + struct timeval tv; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1); + tv.tv_sec = 0; + tv.tv_usec = 0; + FD_ZERO(&rfd); + FD_SET(ctxt->controlFd, &rfd); + switch(select(ctxt->controlFd + 1, &rfd, NULL, NULL, &tv)) { + case 0: + return(0); + case -1: + __xmlIOErr(XML_FROM_FTP, 0, "select"); + return(-1); + + } + + return(xmlNanoFTPReadResponse(ctx)); +} + +/** + * Send the user authentication + */ + +static int +xmlNanoFTPSendUser(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[200]; + int len; + int res; + + if (ctxt->user == NULL) + snprintf(buf, sizeof(buf), "USER anonymous\r\n"); + else + snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + return(res); + } + return(0); +} + +/** + * Send the password authentication + */ + +static int +xmlNanoFTPSendPasswd(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[200]; + int len; + int res; + + if (ctxt->passwd == NULL) + snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); + else + snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + return(res); + } + return(0); +} + +/** + * xmlNanoFTPQuit: + * @ctx: an FTP context + * + * Send a QUIT command to the server + * + * Returns -1 in case of error, 0 otherwise + */ + + +int +xmlNanoFTPQuit(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[200]; + int len, res; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1); + + snprintf(buf, sizeof(buf), "QUIT\r\n"); + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */ +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + return(res); + } + return(0); +} + +/** + * xmlNanoFTPConnect: + * @ctx: an FTP context + * + * Tries to open a control connection + * + * Returns -1 in case of error, 0 otherwise + */ + +int +xmlNanoFTPConnect(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + struct hostent *hp; + int port; + int res; + int addrlen = sizeof (struct sockaddr_in); + + if (ctxt == NULL) + return(-1); + if (ctxt->hostname == NULL) + return(-1); + + /* + * do the blocking DNS query. + */ + if (proxy) { + port = proxyPort; + } else { + port = ctxt->port; + } + if (port == 0) + port = 21; + + memset (&ctxt->ftpAddr, 0, sizeof(ctxt->ftpAddr)); + +#ifdef SUPPORT_IP6 + if (have_ipv6 ()) { + struct addrinfo hints, *tmp, *result; + + result = NULL; + memset (&hints, 0, sizeof(hints)); + hints.ai_socktype = SOCK_STREAM; + + if (proxy) { + if (getaddrinfo (proxy, NULL, &hints, &result) != 0) { + __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed"); + return (-1); + } + } + else + if (getaddrinfo (ctxt->hostname, NULL, &hints, &result) != 0) { + __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed"); + return (-1); + } + + for (tmp = result; tmp; tmp = tmp->ai_next) + if (tmp->ai_family == AF_INET || tmp->ai_family == AF_INET6) + break; + + if (!tmp) { + if (result) + freeaddrinfo (result); + __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed"); + return (-1); + } + if ((size_t)tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) { + if (result) + freeaddrinfo (result); + __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch"); + return (-1); + } + if (tmp->ai_family == AF_INET6) { + memcpy (&ctxt->ftpAddr, tmp->ai_addr, tmp->ai_addrlen); + ((struct sockaddr_in6 *) &ctxt->ftpAddr)->sin6_port = htons (port); + ctxt->controlFd = socket (AF_INET6, SOCK_STREAM, 0); + } + else { + memcpy (&ctxt->ftpAddr, tmp->ai_addr, tmp->ai_addrlen); + ((struct sockaddr_in *) &ctxt->ftpAddr)->sin_port = htons (port); + ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0); + } + addrlen = tmp->ai_addrlen; + freeaddrinfo (result); + } + else +#endif + { + if (proxy) + hp = gethostbyname (GETHOSTBYNAME_ARG_CAST proxy); + else + hp = gethostbyname (GETHOSTBYNAME_ARG_CAST ctxt->hostname); + if (hp == NULL) { + __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname failed"); + return (-1); + } + if ((unsigned int) hp->h_length > + sizeof(((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr)) { + __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch"); + return (-1); + } + + /* + * Prepare the socket + */ + ((struct sockaddr_in *)&ctxt->ftpAddr)->sin_family = AF_INET; + memcpy (&((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr, + hp->h_addr_list[0], hp->h_length); + ((struct sockaddr_in *)&ctxt->ftpAddr)->sin_port = + (unsigned short)htons ((unsigned short)port); + ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0); + addrlen = sizeof (struct sockaddr_in); + } + + if (ctxt->controlFd == INVALID_SOCKET) { + __xmlIOErr(XML_FROM_FTP, 0, "socket failed"); + return(-1); + } + + /* + * Do the connect. + */ + if (connect(ctxt->controlFd, (struct sockaddr *) &ctxt->ftpAddr, + addrlen) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "Failed to create a connection"); + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + + /* + * Wait for the HELLO from the server. + */ + res = xmlNanoFTPGetResponse(ctxt); + if (res != 2) { + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + + /* + * State diagram for the login operation on the FTP server + * + * Reference: RFC 959 + * + * 1 + * +---+ USER +---+------------->+---+ + * | B |---------->| W | 2 ---->| E | + * +---+ +---+------ | -->+---+ + * | | | | | + * 3 | | 4,5 | | | + * -------------- ----- | | | + * | | | | | + * | | | | | + * | --------- | + * | 1| | | | + * V | | | | + * +---+ PASS +---+ 2 | ------>+---+ + * | |---------->| W |------------->| S | + * +---+ +---+ ---------->+---+ + * | | | | | + * 3 | |4,5| | | + * -------------- -------- | + * | | | | | + * | | | | | + * | ----------- + * | 1,3| | | | + * V | 2| | | + * +---+ ACCT +---+-- | ----->+---+ + * | |---------->| W | 4,5 -------->| F | + * +---+ +---+------------->+---+ + * + * Of course in case of using a proxy this get really nasty and is not + * standardized at all :-( + */ + if (proxy) { + int len; + char buf[400]; + + if (proxyUser != NULL) { + /* + * We need proxy auth + */ + snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->controlFd); + ctxt->controlFd = INVALID_SOCKET; + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + switch (res) { + case 2: + if (proxyPasswd == NULL) + break; + /* Falls through. */ + case 3: + if (proxyPasswd != NULL) + snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd); + else + snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->controlFd); + ctxt->controlFd = INVALID_SOCKET; + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + if (res > 3) { + closesocket(ctxt->controlFd); + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + break; + case 1: + break; + case 4: + case 5: + case -1: + default: + closesocket(ctxt->controlFd); + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + } + + /* + * We assume we don't need more authentication to the proxy + * and that it succeeded :-\ + */ + switch (proxyType) { + case 0: + /* we will try in sequence */ + case 1: + /* Using SITE command */ + snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + if (res == 2) { + /* we assume it worked :-\ 1 is error for SITE command */ + proxyType = 1; + break; + } + if (proxyType == 1) { + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + /* Falls through. */ + case 2: + /* USER user@host command */ + if (ctxt->user == NULL) + snprintf(buf, sizeof(buf), "USER anonymous@%s\r\n", + ctxt->hostname); + else + snprintf(buf, sizeof(buf), "USER %s@%s\r\n", + ctxt->user, ctxt->hostname); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + if ((res == 1) || (res == 2)) { + /* we assume it worked :-\ */ + proxyType = 2; + return(0); + } + if (ctxt->passwd == NULL) + snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); + else + snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + if ((res == 1) || (res == 2)) { + /* we assume it worked :-\ */ + proxyType = 2; + return(0); + } + if (proxyType == 2) { + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + /* Falls through. */ + case 3: + /* + * If you need support for other Proxy authentication scheme + * send the code or at least the sequence in use. + */ + default: + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + } + /* + * Non-proxy handling. + */ + res = xmlNanoFTPSendUser(ctxt); + if (res < 0) { + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + res = xmlNanoFTPGetResponse(ctxt); + switch (res) { + case 2: + return(0); + case 3: + break; + case 1: + case 4: + case 5: + case -1: + default: + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + res = xmlNanoFTPSendPasswd(ctxt); + if (res < 0) { + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + res = xmlNanoFTPGetResponse(ctxt); + switch (res) { + case 2: + break; + case 3: + __xmlIOErr(XML_FROM_FTP, XML_FTP_ACCNT, + "FTP server asking for ACCNT on anonymous\n"); + /* Falls through. */ + case 1: + case 4: + case 5: + case -1: + default: + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + + return(0); +} + +/** + * xmlNanoFTPConnectTo: + * @server: an FTP server name + * @port: the port (use 21 if 0) + * + * Tries to open a control connection to the given server/port + * + * Returns an fTP context or NULL if it failed + */ + +void* +xmlNanoFTPConnectTo(const char *server, int port) { + xmlNanoFTPCtxtPtr ctxt; + int res; + + xmlNanoFTPInit(); + if (server == NULL) + return(NULL); + if (port <= 0) + return(NULL); + ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(NULL); + if (ctxt == NULL) + return(NULL); + ctxt->hostname = xmlMemStrdup(server); + if (ctxt->hostname == NULL) { + xmlNanoFTPFreeCtxt(ctxt); + return(NULL); + } + ctxt->port = port; + res = xmlNanoFTPConnect(ctxt); + if (res < 0) { + xmlNanoFTPFreeCtxt(ctxt); + return(NULL); + } + return(ctxt); +} + +/** + * xmlNanoFTPCwd: + * @ctx: an FTP context + * @directory: a directory on the server + * + * Tries to change the remote directory + * + * Returns -1 in case of error, 1 if CWD worked, 0 if it failed + */ + +int +xmlNanoFTPCwd(void *ctx, const char *directory) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[400]; + int len; + int res; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1); + if (directory == NULL) return 0; + + /* + * Expected response code for CWD: + * + * CWD + * 250 + * 500, 501, 502, 421, 530, 550 + */ + snprintf(buf, sizeof(buf), "CWD %s\r\n", directory); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + if (res == 4) { + return(-1); + } + if (res == 2) return(1); + if (res == 5) { + return(0); + } + return(0); +} + +/** + * xmlNanoFTPDele: + * @ctx: an FTP context + * @file: a file or directory on the server + * + * Tries to delete an item (file or directory) from server + * + * Returns -1 in case of error, 1 if DELE worked, 0 if it failed + */ + +int +xmlNanoFTPDele(void *ctx, const char *file) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[400]; + int len; + int res; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET) || + (file == NULL)) return(-1); + + /* + * Expected response code for DELE: + * + * DELE + * 250 + * 450, 550 + * 500, 501, 502, 421, 530 + */ + + snprintf(buf, sizeof(buf), "DELE %s\r\n", file); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + return(res); + } + res = xmlNanoFTPGetResponse(ctxt); + if (res == 4) { + return(-1); + } + if (res == 2) return(1); + if (res == 5) { + return(0); + } + return(0); +} +/** + * xmlNanoFTPGetConnection: + * @ctx: an FTP context + * + * Try to open a data connection to the server. Currently only + * passive mode is supported. + * + * Returns -1 in case of error, 0 otherwise + */ + +SOCKET +xmlNanoFTPGetConnection(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[200], *cur; + int len, i; + int res; + unsigned char ad[6], *adp, *portp; + unsigned int temp[6]; +#ifdef SUPPORT_IP6 + struct sockaddr_storage dataAddr; +#else + struct sockaddr_in dataAddr; +#endif + XML_SOCKLEN_T dataAddrLen; + + if (ctxt == NULL) return INVALID_SOCKET; + + memset (&dataAddr, 0, sizeof(dataAddr)); +#ifdef SUPPORT_IP6 + if ((ctxt->ftpAddr).ss_family == AF_INET6) { + ctxt->dataFd = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP); + ((struct sockaddr_in6 *)&dataAddr)->sin6_family = AF_INET6; + dataAddrLen = sizeof(struct sockaddr_in6); + } else +#endif + { + ctxt->dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); + ((struct sockaddr_in *)&dataAddr)->sin_family = AF_INET; + dataAddrLen = sizeof (struct sockaddr_in); + } + + if (ctxt->dataFd == INVALID_SOCKET) { + __xmlIOErr(XML_FROM_FTP, 0, "socket failed"); + return INVALID_SOCKET; + } + + if (ctxt->passive) { +#ifdef SUPPORT_IP6 + if ((ctxt->ftpAddr).ss_family == AF_INET6) + snprintf (buf, sizeof(buf), "EPSV\r\n"); + else +#endif + snprintf (buf, sizeof(buf), "PASV\r\n"); + len = strlen (buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + res = xmlNanoFTPReadResponse(ctx); + if (res != 2) { + if (res == 5) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } else { + /* + * retry with an active connection + */ + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + ctxt->passive = 0; + } + } + cur = &ctxt->controlBuf[ctxt->controlBufAnswer]; + while (((*cur < '0') || (*cur > '9')) && *cur != '\0') cur++; +#ifdef SUPPORT_IP6 + if ((ctxt->ftpAddr).ss_family == AF_INET6) { + if (sscanf (cur, "%u", &temp[0]) != 1) { + __xmlIOErr(XML_FROM_FTP, XML_FTP_EPSV_ANSWER, + "Invalid answer to EPSV\n"); + if (ctxt->dataFd != INVALID_SOCKET) { + closesocket (ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + } + return INVALID_SOCKET; + } + memcpy (&((struct sockaddr_in6 *)&dataAddr)->sin6_addr, &((struct sockaddr_in6 *)&ctxt->ftpAddr)->sin6_addr, sizeof(struct in6_addr)); + ((struct sockaddr_in6 *)&dataAddr)->sin6_port = htons (temp[0]); + } + else +#endif + { + if (sscanf (cur, "%u,%u,%u,%u,%u,%u", &temp[0], &temp[1], &temp[2], + &temp[3], &temp[4], &temp[5]) != 6) { + __xmlIOErr(XML_FROM_FTP, XML_FTP_PASV_ANSWER, + "Invalid answer to PASV\n"); + if (ctxt->dataFd != INVALID_SOCKET) { + closesocket (ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + } + return INVALID_SOCKET; + } + for (i=0; i<6; i++) ad[i] = (unsigned char) (temp[i] & 0xff); + memcpy (&((struct sockaddr_in *)&dataAddr)->sin_addr, &ad[0], 4); + memcpy (&((struct sockaddr_in *)&dataAddr)->sin_port, &ad[4], 2); + } + + if (connect(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "Failed to create a data connection"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + } else { + getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen); +#ifdef SUPPORT_IP6 + if ((ctxt->ftpAddr).ss_family == AF_INET6) + ((struct sockaddr_in6 *)&dataAddr)->sin6_port = 0; + else +#endif + ((struct sockaddr_in *)&dataAddr)->sin_port = 0; + + if (bind(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "bind failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen); + + if (listen(ctxt->dataFd, 1) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "listen failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } +#ifdef SUPPORT_IP6 + if ((ctxt->ftpAddr).ss_family == AF_INET6) { + char buf6[INET6_ADDRSTRLEN]; + inet_ntop (AF_INET6, &((struct sockaddr_in6 *)&dataAddr)->sin6_addr, + buf6, INET6_ADDRSTRLEN); + adp = (unsigned char *) buf6; + portp = (unsigned char *) &((struct sockaddr_in6 *)&dataAddr)->sin6_port; + snprintf (buf, sizeof(buf), "EPRT |2|%s|%s|\r\n", adp, portp); + } else +#endif + { + adp = (unsigned char *) &((struct sockaddr_in *)&dataAddr)->sin_addr; + portp = (unsigned char *) &((struct sockaddr_in *)&dataAddr)->sin_port; + snprintf (buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", + adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, + portp[0] & 0xff, portp[1] & 0xff); + } + + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + res = xmlNanoFTPGetResponse(ctxt); + if (res != 2) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + } + return(ctxt->dataFd); + +} + +/** + * xmlNanoFTPCloseConnection: + * @ctx: an FTP context + * + * Close the data connection from the server + * + * Returns -1 in case of error, 0 otherwise + */ + +int +xmlNanoFTPCloseConnection(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + int res; + fd_set rfd, efd; + struct timeval tv; + + if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1); + + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + tv.tv_sec = 15; + tv.tv_usec = 0; + FD_ZERO(&rfd); + FD_SET(ctxt->controlFd, &rfd); + FD_ZERO(&efd); + FD_SET(ctxt->controlFd, &efd); + res = select(ctxt->controlFd + 1, &rfd, NULL, &efd, &tv); + if (res < 0) { +#ifdef DEBUG_FTP + perror("select"); +#endif + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + if (res == 0) { +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoFTPCloseConnection: timeout\n"); +#endif + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + } else { + res = xmlNanoFTPGetResponse(ctxt); + if (res != 2) { + closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET; + return(-1); + } + } + return(0); +} + +/** + * xmlNanoFTPParseList: + * @list: some data listing received from the server + * @callback: the user callback + * @userData: the user callback data + * + * Parse at most one entry from the listing. + * + * Returns -1 in case of error, the length of data parsed otherwise + */ + +static int +xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData) { + const char *cur = list; + char filename[151]; + char attrib[11]; + char owner[11]; + char group[11]; + char month[4]; + int year = 0; + int minute = 0; + int hour = 0; + int day = 0; + unsigned long size = 0; + int links = 0; + int i; + + if (!strncmp(cur, "total", 5)) { + cur += 5; + while (*cur == ' ') cur++; + while ((*cur >= '0') && (*cur <= '9')) + links = (links * 10) + (*cur++ - '0'); + while ((*cur == ' ') || (*cur == '\n') || (*cur == '\r')) + cur++; + return(cur - list); + } else if (*list == '+') { + return(0); + } else { + while ((*cur == ' ') || (*cur == '\n') || (*cur == '\r')) + cur++; + if (*cur == 0) return(0); + i = 0; + while (*cur != ' ') { + if (i < 10) + attrib[i++] = *cur; + cur++; + if (*cur == 0) return(0); + } + attrib[10] = 0; + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + while ((*cur >= '0') && (*cur <= '9')) + links = (links * 10) + (*cur++ - '0'); + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + i = 0; + while (*cur != ' ') { + if (i < 10) + owner[i++] = *cur; + cur++; + if (*cur == 0) return(0); + } + owner[i] = 0; + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + i = 0; + while (*cur != ' ') { + if (i < 10) + group[i++] = *cur; + cur++; + if (*cur == 0) return(0); + } + group[i] = 0; + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + while ((*cur >= '0') && (*cur <= '9')) + size = (size * 10) + (*cur++ - '0'); + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + i = 0; + while (*cur != ' ') { + if (i < 3) + month[i++] = *cur; + cur++; + if (*cur == 0) return(0); + } + month[i] = 0; + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + while ((*cur >= '0') && (*cur <= '9')) + day = (day * 10) + (*cur++ - '0'); + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + if ((cur[1] == 0) || (cur[2] == 0)) return(0); + if ((cur[1] == ':') || (cur[2] == ':')) { + while ((*cur >= '0') && (*cur <= '9')) + hour = (hour * 10) + (*cur++ - '0'); + if (*cur == ':') cur++; + while ((*cur >= '0') && (*cur <= '9')) + minute = (minute * 10) + (*cur++ - '0'); + } else { + while ((*cur >= '0') && (*cur <= '9')) + year = (year * 10) + (*cur++ - '0'); + } + while (*cur == ' ') cur++; + if (*cur == 0) return(0); + i = 0; + while ((*cur != '\n') && (*cur != '\r')) { + if (i < 150) + filename[i++] = *cur; + cur++; + if (*cur == 0) return(0); + } + filename[i] = 0; + if ((*cur != '\n') && (*cur != '\r')) + return(0); + while ((*cur == '\n') || (*cur == '\r')) + cur++; + } + if (callback != NULL) { + callback(userData, filename, attrib, owner, group, size, links, + year, month, day, hour, minute); + } + return(cur - list); +} + +/** + * xmlNanoFTPList: + * @ctx: an FTP context + * @callback: the user callback + * @userData: the user callback data + * @filename: optional files to list + * + * Do a listing on the server. All files info are passed back + * in the callbacks. + * + * Returns -1 in case of error, 0 otherwise + */ + +int +xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData, + const char *filename) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[4096 + 1]; + int len, res; + int indx = 0, base; + fd_set rfd, efd; + struct timeval tv; + + if (ctxt == NULL) return (-1); + if (filename == NULL) { + if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1) + return(-1); + ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); + if (ctxt->dataFd == INVALID_SOCKET) + return(-1); + snprintf(buf, sizeof(buf), "LIST -L\r\n"); + } else { + if (filename[0] != '/') { + if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1) + return(-1); + } + ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); + if (ctxt->dataFd == INVALID_SOCKET) + return(-1); + snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename); + } + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(res); + } + res = xmlNanoFTPReadResponse(ctxt); + if (res != 1) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(-res); + } + + do { + tv.tv_sec = 1; + tv.tv_usec = 0; + FD_ZERO(&rfd); + FD_SET(ctxt->dataFd, &rfd); + FD_ZERO(&efd); + FD_SET(ctxt->dataFd, &efd); + res = select(ctxt->dataFd + 1, &rfd, NULL, &efd, &tv); + if (res < 0) { +#ifdef DEBUG_FTP + perror("select"); +#endif + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(-1); + } + if (res == 0) { + res = xmlNanoFTPCheckResponse(ctxt); + if (res < 0) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + ctxt->dataFd = INVALID_SOCKET; + return(-1); + } + if (res == 2) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(0); + } + + continue; + } + + if ((len = recv(ctxt->dataFd, &buf[indx], sizeof(buf) - (indx + 1), 0)) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "recv"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + ctxt->dataFd = INVALID_SOCKET; + return(-1); + } +#ifdef DEBUG_FTP + write(1, &buf[indx], len); +#endif + indx += len; + buf[indx] = 0; + base = 0; + do { + res = xmlNanoFTPParseList(&buf[base], callback, userData); + base += res; + } while (res > 0); + + memmove(&buf[0], &buf[base], indx - base); + indx -= base; + } while (len != 0); + xmlNanoFTPCloseConnection(ctxt); + return(0); +} + +/** + * xmlNanoFTPGetSocket: + * @ctx: an FTP context + * @filename: the file to retrieve (or NULL if path is in context). + * + * Initiate fetch of the given file from the server. + * + * Returns the socket for the data connection, or <0 in case of error + */ + + +SOCKET +xmlNanoFTPGetSocket(void *ctx, const char *filename) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[300]; + int res, len; + if (ctx == NULL) + return INVALID_SOCKET; + if ((filename == NULL) && (ctxt->path == NULL)) + return INVALID_SOCKET; + ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); + if (ctxt->dataFd == INVALID_SOCKET) + return INVALID_SOCKET; + + snprintf(buf, sizeof(buf), "TYPE I\r\n"); + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + res = xmlNanoFTPReadResponse(ctxt); + if (res != 2) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + if (filename == NULL) + snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path); + else + snprintf(buf, sizeof(buf), "RETR %s\r\n", filename); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "%s", buf); +#endif + res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0); + if (res < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "send failed"); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + res = xmlNanoFTPReadResponse(ctxt); + if (res != 1) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return INVALID_SOCKET; + } + return(ctxt->dataFd); +} + +/** + * xmlNanoFTPGet: + * @ctx: an FTP context + * @callback: the user callback + * @userData: the user callback data + * @filename: the file to retrieve + * + * Fetch the given file from the server. All data are passed back + * in the callbacks. The last callback has a size of 0 block. + * + * Returns -1 in case of error, 0 otherwise + */ + +int +xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData, + const char *filename) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + char buf[4096]; + int len = 0, res; + fd_set rfd; + struct timeval tv; + + if (ctxt == NULL) return(-1); + if ((filename == NULL) && (ctxt->path == NULL)) + return(-1); + if (callback == NULL) + return(-1); + if (xmlNanoFTPGetSocket(ctxt, filename) == INVALID_SOCKET) + return(-1); + + do { + tv.tv_sec = 1; + tv.tv_usec = 0; + FD_ZERO(&rfd); + FD_SET(ctxt->dataFd, &rfd); + res = select(ctxt->dataFd + 1, &rfd, NULL, NULL, &tv); + if (res < 0) { +#ifdef DEBUG_FTP + perror("select"); +#endif + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(-1); + } + if (res == 0) { + res = xmlNanoFTPCheckResponse(ctxt); + if (res < 0) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + ctxt->dataFd = INVALID_SOCKET; + return(-1); + } + if (res == 2) { + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(0); + } + + continue; + } + if ((len = recv(ctxt->dataFd, buf, sizeof(buf), 0)) < 0) { + __xmlIOErr(XML_FROM_FTP, 0, "recv failed"); + callback(userData, buf, len); + closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET; + return(-1); + } + callback(userData, buf, len); + } while (len != 0); + + return(xmlNanoFTPCloseConnection(ctxt)); +} + +/** + * xmlNanoFTPRead: + * @ctx: the FTP context + * @dest: a buffer + * @len: the buffer length + * + * This function tries to read @len bytes from the existing FTP connection + * and saves them in @dest. This is a blocking call. + * + * Returns the number of byte read. 0 is an indication of an end of connection. + * -1 indicates a parameter error. + */ +int +xmlNanoFTPRead(void *ctx, void *dest, int len) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + + if (ctx == NULL) return(-1); + if (ctxt->dataFd == INVALID_SOCKET) return(0); + if (dest == NULL) return(-1); + if (len <= 0) return(0); + + len = recv(ctxt->dataFd, dest, len, 0); + if (len <= 0) { + if (len < 0) + __xmlIOErr(XML_FROM_FTP, 0, "recv failed"); + xmlNanoFTPCloseConnection(ctxt); + } +#ifdef DEBUG_FTP + xmlGenericError(xmlGenericErrorContext, "Recvd %d bytes\n", len); +#endif + return(len); +} + +/** + * xmlNanoFTPOpen: + * @URL: the URL to the resource + * + * Start to fetch the given ftp:// resource + * + * Returns an FTP context, or NULL + */ + +void* +xmlNanoFTPOpen(const char *URL) { + xmlNanoFTPCtxtPtr ctxt; + SOCKET sock; + + xmlNanoFTPInit(); + if (URL == NULL) return(NULL); + if (strncmp("ftp://", URL, 6)) return(NULL); + + ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(URL); + if (ctxt == NULL) return(NULL); + if (xmlNanoFTPConnect(ctxt) < 0) { + xmlNanoFTPFreeCtxt(ctxt); + return(NULL); + } + sock = xmlNanoFTPGetSocket(ctxt, ctxt->path); + if (sock == INVALID_SOCKET) { + xmlNanoFTPFreeCtxt(ctxt); + return(NULL); + } + return(ctxt); +} + +/** + * xmlNanoFTPClose: + * @ctx: an FTP context + * + * Close the connection and both control and transport + * + * Returns -1 in case of error, 0 otherwise + */ + +int +xmlNanoFTPClose(void *ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; + + if (ctxt == NULL) + return(-1); + + if (ctxt->dataFd != INVALID_SOCKET) { + closesocket(ctxt->dataFd); + ctxt->dataFd = INVALID_SOCKET; + } + if (ctxt->controlFd != INVALID_SOCKET) { + xmlNanoFTPQuit(ctxt); + closesocket(ctxt->controlFd); + ctxt->controlFd = INVALID_SOCKET; + } + xmlNanoFTPFreeCtxt(ctxt); + return(0); +} + +#ifdef STANDALONE +/************************************************************************ + * * + * Basic test in Standalone mode * + * * + ************************************************************************/ +static +void ftpList(void *userData, const char *filename, const char* attrib, + const char *owner, const char *group, unsigned long size, int links, + int year, const char *month, int day, int hour, int minute) { + xmlGenericError(xmlGenericErrorContext, + "%s %s %s %ld %s\n", attrib, owner, group, size, filename); +} +static +void ftpData(void *userData, const char *data, int len) { + if (userData == NULL) return; + if (len <= 0) { + fclose((FILE*)userData); + return; + } + fwrite(data, len, 1, (FILE*)userData); +} + +int main(int argc, char **argv) { + void *ctxt; + FILE *output; + char *tstfile = NULL; + + xmlNanoFTPInit(); + if (argc > 1) { + ctxt = xmlNanoFTPNewCtxt(argv[1]); + if (xmlNanoFTPConnect(ctxt) < 0) { + xmlGenericError(xmlGenericErrorContext, + "Couldn't connect to %s\n", argv[1]); + exit(1); + } + if (argc > 2) + tstfile = argv[2]; + } else + ctxt = xmlNanoFTPConnectTo("localhost", 0); + if (ctxt == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Couldn't connect to localhost\n"); + exit(1); + } + xmlNanoFTPList(ctxt, ftpList, NULL, tstfile); + output = fopen("/tmp/tstdata", "w"); + if (output != NULL) { + if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0) + xmlGenericError(xmlGenericErrorContext, + "Failed to get file\n"); + + } + xmlNanoFTPClose(ctxt); + xmlMemoryDump(); + exit(0); +} +#endif /* STANDALONE */ +#else /* !LIBXML_FTP_ENABLED */ +#ifdef STANDALONE +#include +int main(int argc, char **argv) { + xmlGenericError(xmlGenericErrorContext, + "%s : FTP support not compiled in\n", argv[0]); + return(0); +} +#endif /* STANDALONE */ +#endif /* LIBXML_FTP_ENABLED */ +#define bottom_nanoftp +#include "elfgcchack.h" diff --git a/src/nanohttp.c b/src/nanohttp.c new file mode 100644 index 000000000000..8e840f58b766 --- /dev/null +++ b/src/nanohttp.c @@ -0,0 +1,1899 @@ +/* + * nanohttp.c: minimalist HTTP GET implementation to fetch external subsets. + * focuses on size, streamability, reentrancy and portability + * + * This is clearly not a general purpose HTTP implementation + * If you look for one, check: + * http://www.w3.org/Library/ + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#define IN_LIBXML +#include "libxml.h" + +#ifdef LIBXML_HTTP_ENABLED +#include + +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_RESOLV_H +#ifdef HAVE_ARPA_NAMESER_H +#include +#endif +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifndef HAVE_POLL_H +#ifdef HAVE_SYS_SELECT_H +#include +#endif +#else +#include +#endif +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef LIBXML_ZLIB_ENABLED +#include +#endif + + +#ifdef VMS +#include +#define XML_SOCKLEN_T unsigned int +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) +#include +#endif + +#include +#include +#include +#include /* for xmlStr(n)casecmp() */ +#include +#include +#include + +/** + * A couple portability macros + */ +#ifndef _WINSOCKAPI_ +#if !defined(__BEOS__) || defined(__HAIKU__) +#define closesocket(s) close(s) +#endif +#define SOCKET int +#define INVALID_SOCKET (-1) +#endif + +#ifdef __BEOS__ +#ifndef PF_INET +#define PF_INET AF_INET +#endif +#endif + +#ifndef XML_SOCKLEN_T +#define XML_SOCKLEN_T unsigned int +#endif + +#ifdef STANDALONE +#define DEBUG_HTTP +#define xmlStrncasecmp(a, b, n) strncasecmp((char *)a, (char *)b, n) +#define xmlStrcasecmpi(a, b) strcasecmp((char *)a, (char *)b) +#endif + +#define XML_NANO_HTTP_MAX_REDIR 10 + +#define XML_NANO_HTTP_CHUNK 4096 + +#define XML_NANO_HTTP_CLOSED 0 +#define XML_NANO_HTTP_WRITE 1 +#define XML_NANO_HTTP_READ 2 +#define XML_NANO_HTTP_NONE 4 + +typedef struct xmlNanoHTTPCtxt { + char *protocol; /* the protocol name */ + char *hostname; /* the host name */ + int port; /* the port */ + char *path; /* the path within the URL */ + char *query; /* the query string */ + SOCKET fd; /* the file descriptor for the socket */ + int state; /* WRITE / READ / CLOSED */ + char *out; /* buffer sent (zero terminated) */ + char *outptr; /* index within the buffer sent */ + char *in; /* the receiving buffer */ + char *content; /* the start of the content */ + char *inptr; /* the next byte to read from network */ + char *inrptr; /* the next byte to give back to the client */ + int inlen; /* len of the input buffer */ + int last; /* return code for last operation */ + int returnValue; /* the protocol return value */ + int version; /* the protocol version */ + int ContentLength; /* specified content length from HTTP header */ + char *contentType; /* the MIME type for the input */ + char *location; /* the new URL in case of redirect */ + char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */ + char *encoding; /* encoding extracted from the contentType */ + char *mimeType; /* Mime-Type extracted from the contentType */ +#ifdef LIBXML_ZLIB_ENABLED + z_stream *strm; /* Zlib stream object */ + int usesGzip; /* "Content-Encoding: gzip" was detected */ +#endif +} xmlNanoHTTPCtxt, *xmlNanoHTTPCtxtPtr; + +static int initialized = 0; +static char *proxy = NULL; /* the proxy name if any */ +static int proxyPort; /* the proxy port if any */ +static unsigned int timeout = 60;/* the select() timeout in seconds */ + +static int xmlNanoHTTPFetchContent( void * ctx, char ** ptr, int * len ); + +/** + * xmlHTTPErrMemory: + * @extra: extra information + * + * Handle an out of memory condition + */ +static void +xmlHTTPErrMemory(const char *extra) +{ + __xmlSimpleError(XML_FROM_HTTP, XML_ERR_NO_MEMORY, NULL, NULL, extra); +} + +/** + * A portability function + */ +static int socket_errno(void) { +#ifdef _WINSOCKAPI_ + int err = WSAGetLastError(); + switch(err) { + case WSAECONNRESET: + return(ECONNRESET); + case WSAEINPROGRESS: + return(EINPROGRESS); + case WSAEINTR: + return(EINTR); + case WSAESHUTDOWN: + return(ESHUTDOWN); + case WSAEWOULDBLOCK: + return(EWOULDBLOCK); + default: + return(err); + } +#else + return(errno); +#endif +} + +#ifdef SUPPORT_IP6 +static +int have_ipv6(void) { + SOCKET s; + + s = socket (AF_INET6, SOCK_STREAM, 0); + if (s != INVALID_SOCKET) { + close (s); + return (1); + } + return (0); +} +#endif + +/** + * xmlNanoHTTPInit: + * + * Initialize the HTTP protocol layer. + * Currently it just checks for proxy information + */ + +void +xmlNanoHTTPInit(void) { + const char *env; +#ifdef _WINSOCKAPI_ + WSADATA wsaData; +#endif + + if (initialized) + return; + +#ifdef _WINSOCKAPI_ + if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) + return; +#endif + + if (proxy == NULL) { + proxyPort = 80; + env = getenv("no_proxy"); + if (env && ((env[0] == '*') && (env[1] == 0))) + goto done; + env = getenv("http_proxy"); + if (env != NULL) { + xmlNanoHTTPScanProxy(env); + goto done; + } + env = getenv("HTTP_PROXY"); + if (env != NULL) { + xmlNanoHTTPScanProxy(env); + goto done; + } + } +done: + initialized = 1; +} + +/** + * xmlNanoHTTPCleanup: + * + * Cleanup the HTTP protocol layer. + */ + +void +xmlNanoHTTPCleanup(void) { + if (proxy != NULL) { + xmlFree(proxy); + proxy = NULL; + } +#ifdef _WINSOCKAPI_ + if (initialized) + WSACleanup(); +#endif + initialized = 0; + return; +} + +/** + * xmlNanoHTTPScanURL: + * @ctxt: an HTTP context + * @URL: The URL used to initialize the context + * + * (Re)Initialize an HTTP context by parsing the URL and finding + * the protocol host port and path it indicates. + */ + +static void +xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) { + xmlURIPtr uri; + int len; + + /* + * Clear any existing data from the context + */ + if (ctxt->protocol != NULL) { + xmlFree(ctxt->protocol); + ctxt->protocol = NULL; + } + if (ctxt->hostname != NULL) { + xmlFree(ctxt->hostname); + ctxt->hostname = NULL; + } + if (ctxt->path != NULL) { + xmlFree(ctxt->path); + ctxt->path = NULL; + } + if (ctxt->query != NULL) { + xmlFree(ctxt->query); + ctxt->query = NULL; + } + if (URL == NULL) return; + + uri = xmlParseURIRaw(URL, 1); + if (uri == NULL) + return; + + if ((uri->scheme == NULL) || (uri->server == NULL)) { + xmlFreeURI(uri); + return; + } + + ctxt->protocol = xmlMemStrdup(uri->scheme); + /* special case of IPv6 addresses, the [] need to be removed */ + if ((uri->server != NULL) && (*uri->server == '[')) { + len = strlen(uri->server); + if ((len > 2) && (uri->server[len - 1] == ']')) { + ctxt->hostname = (char *) xmlCharStrndup(uri->server + 1, len -2); + } else + ctxt->hostname = xmlMemStrdup(uri->server); + } else + ctxt->hostname = xmlMemStrdup(uri->server); + if (uri->path != NULL) + ctxt->path = xmlMemStrdup(uri->path); + else + ctxt->path = xmlMemStrdup("/"); + if (uri->query != NULL) + ctxt->query = xmlMemStrdup(uri->query); + if (uri->port != 0) + ctxt->port = uri->port; + + xmlFreeURI(uri); +} + +/** + * xmlNanoHTTPScanProxy: + * @URL: The proxy URL used to initialize the proxy context + * + * (Re)Initialize the HTTP Proxy context by parsing the URL and finding + * the protocol host port it indicates. + * Should be like http://myproxy/ or http://myproxy:3128/ + * A NULL URL cleans up proxy information. + */ + +void +xmlNanoHTTPScanProxy(const char *URL) { + xmlURIPtr uri; + + if (proxy != NULL) { + xmlFree(proxy); + proxy = NULL; + } + proxyPort = 0; + +#ifdef DEBUG_HTTP + if (URL == NULL) + xmlGenericError(xmlGenericErrorContext, + "Removing HTTP proxy info\n"); + else + xmlGenericError(xmlGenericErrorContext, + "Using HTTP proxy %s\n", URL); +#endif + if (URL == NULL) return; + + uri = xmlParseURIRaw(URL, 1); + if ((uri == NULL) || (uri->scheme == NULL) || + (strcmp(uri->scheme, "http")) || (uri->server == NULL)) { + __xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Syntax Error\n"); + if (uri != NULL) + xmlFreeURI(uri); + return; + } + + proxy = xmlMemStrdup(uri->server); + if (uri->port != 0) + proxyPort = uri->port; + + xmlFreeURI(uri); +} + +/** + * xmlNanoHTTPNewCtxt: + * @URL: The URL used to initialize the context + * + * Allocate and initialize a new HTTP context. + * + * Returns an HTTP context or NULL in case of error. + */ + +static xmlNanoHTTPCtxtPtr +xmlNanoHTTPNewCtxt(const char *URL) { + xmlNanoHTTPCtxtPtr ret; + + ret = (xmlNanoHTTPCtxtPtr) xmlMalloc(sizeof(xmlNanoHTTPCtxt)); + if (ret == NULL) { + xmlHTTPErrMemory("allocating context"); + return(NULL); + } + + memset(ret, 0, sizeof(xmlNanoHTTPCtxt)); + ret->port = 80; + ret->returnValue = 0; + ret->fd = INVALID_SOCKET; + ret->ContentLength = -1; + + xmlNanoHTTPScanURL(ret, URL); + + return(ret); +} + +/** + * xmlNanoHTTPFreeCtxt: + * @ctxt: an HTTP context + * + * Frees the context after closing the connection. + */ + +static void +xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) { + if (ctxt == NULL) return; + if (ctxt->hostname != NULL) xmlFree(ctxt->hostname); + if (ctxt->protocol != NULL) xmlFree(ctxt->protocol); + if (ctxt->path != NULL) xmlFree(ctxt->path); + if (ctxt->query != NULL) xmlFree(ctxt->query); + if (ctxt->out != NULL) xmlFree(ctxt->out); + if (ctxt->in != NULL) xmlFree(ctxt->in); + if (ctxt->contentType != NULL) xmlFree(ctxt->contentType); + if (ctxt->encoding != NULL) xmlFree(ctxt->encoding); + if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType); + if (ctxt->location != NULL) xmlFree(ctxt->location); + if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader); +#ifdef LIBXML_ZLIB_ENABLED + if (ctxt->strm != NULL) { + inflateEnd(ctxt->strm); + xmlFree(ctxt->strm); + } +#endif + + ctxt->state = XML_NANO_HTTP_NONE; + if (ctxt->fd != INVALID_SOCKET) closesocket(ctxt->fd); + ctxt->fd = INVALID_SOCKET; + xmlFree(ctxt); +} + +/** + * xmlNanoHTTPSend: + * @ctxt: an HTTP context + * + * Send the input needed to initiate the processing on the server side + * Returns number of bytes sent or -1 on error. + */ + +static int +xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char *xmt_ptr, int outlen) +{ + int total_sent = 0; +#ifdef HAVE_POLL_H + struct pollfd p; +#else + struct timeval tv; + fd_set wfd; +#endif + + if ((ctxt->state & XML_NANO_HTTP_WRITE) && (xmt_ptr != NULL)) { + while (total_sent < outlen) { + int nsent = send(ctxt->fd, SEND_ARG2_CAST (xmt_ptr + total_sent), + outlen - total_sent, 0); + + if (nsent > 0) + total_sent += nsent; + else if ((nsent == -1) && +#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK + (socket_errno() != EAGAIN) && +#endif + (socket_errno() != EWOULDBLOCK)) { + __xmlIOErr(XML_FROM_HTTP, 0, "send failed\n"); + if (total_sent == 0) + total_sent = -1; + break; + } else { + /* + * No data sent + * Since non-blocking sockets are used, wait for + * socket to be writable or default timeout prior + * to retrying. + */ +#ifndef HAVE_POLL_H +#ifndef _WINSOCKAPI_ + if (ctxt->fd > FD_SETSIZE) + return -1; +#endif + + tv.tv_sec = timeout; + tv.tv_usec = 0; + FD_ZERO(&wfd); +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4018) +#endif + FD_SET(ctxt->fd, &wfd); +#ifdef _MSC_VER +#pragma warning(pop) +#endif + (void) select(ctxt->fd + 1, NULL, &wfd, NULL, &tv); +#else + p.fd = ctxt->fd; + p.events = POLLOUT; + (void) poll(&p, 1, timeout * 1000); +#endif /* !HAVE_POLL_H */ + } + } + } + + return total_sent; +} + +/** + * xmlNanoHTTPRecv: + * @ctxt: an HTTP context + * + * Read information coming from the HTTP connection. + * This is a blocking call (but it blocks in select(), not read()). + * + * Returns the number of byte read or -1 in case of error. + */ + +static int +xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) +{ +#ifdef HAVE_POLL_H + struct pollfd p; +#else + fd_set rfd; + struct timeval tv; +#endif + + + while (ctxt->state & XML_NANO_HTTP_READ) { + if (ctxt->in == NULL) { + ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char)); + if (ctxt->in == NULL) { + xmlHTTPErrMemory("allocating input"); + ctxt->last = -1; + return (-1); + } + ctxt->inlen = 65000; + ctxt->inptr = ctxt->content = ctxt->inrptr = ctxt->in; + } + if (ctxt->inrptr > ctxt->in + XML_NANO_HTTP_CHUNK) { + int delta = ctxt->inrptr - ctxt->in; + int len = ctxt->inptr - ctxt->inrptr; + + memmove(ctxt->in, ctxt->inrptr, len); + ctxt->inrptr -= delta; + ctxt->content -= delta; + ctxt->inptr -= delta; + } + if ((ctxt->in + ctxt->inlen) < (ctxt->inptr + XML_NANO_HTTP_CHUNK)) { + int d_inptr = ctxt->inptr - ctxt->in; + int d_content = ctxt->content - ctxt->in; + int d_inrptr = ctxt->inrptr - ctxt->in; + char *tmp_ptr = ctxt->in; + + ctxt->inlen *= 2; + ctxt->in = (char *) xmlRealloc(tmp_ptr, ctxt->inlen); + if (ctxt->in == NULL) { + xmlHTTPErrMemory("allocating input buffer"); + xmlFree(tmp_ptr); + ctxt->last = -1; + return (-1); + } + ctxt->inptr = ctxt->in + d_inptr; + ctxt->content = ctxt->in + d_content; + ctxt->inrptr = ctxt->in + d_inrptr; + } + ctxt->last = recv(ctxt->fd, ctxt->inptr, XML_NANO_HTTP_CHUNK, 0); + if (ctxt->last > 0) { + ctxt->inptr += ctxt->last; + return (ctxt->last); + } + if (ctxt->last == 0) { + return (0); + } + if (ctxt->last == -1) { + switch (socket_errno()) { + case EINPROGRESS: + case EWOULDBLOCK: +#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK + case EAGAIN: +#endif + break; + + case ECONNRESET: + case ESHUTDOWN: + return (0); + + default: + __xmlIOErr(XML_FROM_HTTP, 0, "recv failed\n"); + return (-1); + } + } +#ifdef HAVE_POLL_H + p.fd = ctxt->fd; + p.events = POLLIN; + if ((poll(&p, 1, timeout * 1000) < 1) +#if defined(EINTR) + && (errno != EINTR) +#endif + ) + return (0); +#else /* !HAVE_POLL_H */ +#ifndef _WINSOCKAPI_ + if (ctxt->fd > FD_SETSIZE) + return 0; +#endif + + tv.tv_sec = timeout; + tv.tv_usec = 0; + FD_ZERO(&rfd); + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4018) +#endif + + FD_SET(ctxt->fd, &rfd); + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + if ((select(ctxt->fd + 1, &rfd, NULL, NULL, &tv) < 1) +#if defined(EINTR) + && (socket_errno() != EINTR) +#endif + ) + return (0); +#endif /* !HAVE_POLL_H */ + } + return (0); +} + +/** + * xmlNanoHTTPReadLine: + * @ctxt: an HTTP context + * + * Read one line in the HTTP server output, usually for extracting + * the HTTP protocol information from the answer header. + * + * Returns a newly allocated string with a copy of the line, or NULL + * which indicate the end of the input. + */ + +static char * +xmlNanoHTTPReadLine(xmlNanoHTTPCtxtPtr ctxt) { + char buf[4096]; + char *bp = buf; + int rc; + + while (bp - buf < 4095) { + if (ctxt->inrptr == ctxt->inptr) { + if ( (rc = xmlNanoHTTPRecv(ctxt)) == 0) { + if (bp == buf) + return(NULL); + else + *bp = 0; + return(xmlMemStrdup(buf)); + } + else if ( rc == -1 ) { + return ( NULL ); + } + } + *bp = *ctxt->inrptr++; + if (*bp == '\n') { + *bp = 0; + return(xmlMemStrdup(buf)); + } + if (*bp != '\r') + bp++; + } + buf[4095] = 0; + return(xmlMemStrdup(buf)); +} + + +/** + * xmlNanoHTTPScanAnswer: + * @ctxt: an HTTP context + * @line: an HTTP header line + * + * Try to extract useful information from the server answer. + * We currently parse and process: + * - The HTTP revision/ return code + * - The Content-Type, Mime-Type and charset used + * - The Location for redirect processing. + * + * Returns -1 in case of failure, the file descriptor number otherwise + */ + +static void +xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) { + const char *cur = line; + + if (line == NULL) return; + + if (!strncmp(line, "HTTP/", 5)) { + int version = 0; + int ret = 0; + + cur += 5; + while ((*cur >= '0') && (*cur <= '9')) { + version *= 10; + version += *cur - '0'; + cur++; + } + if (*cur == '.') { + cur++; + if ((*cur >= '0') && (*cur <= '9')) { + version *= 10; + version += *cur - '0'; + cur++; + } + while ((*cur >= '0') && (*cur <= '9')) + cur++; + } else + version *= 10; + if ((*cur != ' ') && (*cur != '\t')) return; + while ((*cur == ' ') || (*cur == '\t')) cur++; + if ((*cur < '0') || (*cur > '9')) return; + while ((*cur >= '0') && (*cur <= '9')) { + ret *= 10; + ret += *cur - '0'; + cur++; + } + if ((*cur != 0) && (*cur != ' ') && (*cur != '\t')) return; + ctxt->returnValue = ret; + ctxt->version = version; + } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Content-Type:", 13)) { + const xmlChar *charset, *last, *mime; + cur += 13; + while ((*cur == ' ') || (*cur == '\t')) cur++; + if (ctxt->contentType != NULL) + xmlFree(ctxt->contentType); + ctxt->contentType = xmlMemStrdup(cur); + mime = (const xmlChar *) cur; + last = mime; + while ((*last != 0) && (*last != ' ') && (*last != '\t') && + (*last != ';') && (*last != ',')) + last++; + if (ctxt->mimeType != NULL) + xmlFree(ctxt->mimeType); + ctxt->mimeType = (char *) xmlStrndup(mime, last - mime); + charset = xmlStrstr(BAD_CAST ctxt->contentType, BAD_CAST "charset="); + if (charset != NULL) { + charset += 8; + last = charset; + while ((*last != 0) && (*last != ' ') && (*last != '\t') && + (*last != ';') && (*last != ',')) + last++; + if (ctxt->encoding != NULL) + xmlFree(ctxt->encoding); + ctxt->encoding = (char *) xmlStrndup(charset, last - charset); + } + } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"ContentType:", 12)) { + const xmlChar *charset, *last, *mime; + cur += 12; + if (ctxt->contentType != NULL) return; + while ((*cur == ' ') || (*cur == '\t')) cur++; + ctxt->contentType = xmlMemStrdup(cur); + mime = (const xmlChar *) cur; + last = mime; + while ((*last != 0) && (*last != ' ') && (*last != '\t') && + (*last != ';') && (*last != ',')) + last++; + if (ctxt->mimeType != NULL) + xmlFree(ctxt->mimeType); + ctxt->mimeType = (char *) xmlStrndup(mime, last - mime); + charset = xmlStrstr(BAD_CAST ctxt->contentType, BAD_CAST "charset="); + if (charset != NULL) { + charset += 8; + last = charset; + while ((*last != 0) && (*last != ' ') && (*last != '\t') && + (*last != ';') && (*last != ',')) + last++; + if (ctxt->encoding != NULL) + xmlFree(ctxt->encoding); + ctxt->encoding = (char *) xmlStrndup(charset, last - charset); + } + } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Location:", 9)) { + cur += 9; + while ((*cur == ' ') || (*cur == '\t')) cur++; + if (ctxt->location != NULL) + xmlFree(ctxt->location); + if (*cur == '/') { + xmlChar *tmp_http = xmlStrdup(BAD_CAST "http://"); + xmlChar *tmp_loc = + xmlStrcat(tmp_http, (const xmlChar *) ctxt->hostname); + ctxt->location = + (char *) xmlStrcat (tmp_loc, (const xmlChar *) cur); + } else { + ctxt->location = xmlMemStrdup(cur); + } + } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"WWW-Authenticate:", 17)) { + cur += 17; + while ((*cur == ' ') || (*cur == '\t')) cur++; + if (ctxt->authHeader != NULL) + xmlFree(ctxt->authHeader); + ctxt->authHeader = xmlMemStrdup(cur); + } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Proxy-Authenticate:", 19)) { + cur += 19; + while ((*cur == ' ') || (*cur == '\t')) cur++; + if (ctxt->authHeader != NULL) + xmlFree(ctxt->authHeader); + ctxt->authHeader = xmlMemStrdup(cur); +#ifdef LIBXML_ZLIB_ENABLED + } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) { + cur += 17; + while ((*cur == ' ') || (*cur == '\t')) cur++; + if ( !xmlStrncasecmp( BAD_CAST cur, BAD_CAST"gzip", 4) ) { + ctxt->usesGzip = 1; + + ctxt->strm = xmlMalloc(sizeof(z_stream)); + + if (ctxt->strm != NULL) { + ctxt->strm->zalloc = Z_NULL; + ctxt->strm->zfree = Z_NULL; + ctxt->strm->opaque = Z_NULL; + ctxt->strm->avail_in = 0; + ctxt->strm->next_in = Z_NULL; + + inflateInit2( ctxt->strm, 31 ); + } + } +#endif + } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Length:", 15) ) { + cur += 15; + ctxt->ContentLength = strtol( cur, NULL, 10 ); + } +} + +/** + * xmlNanoHTTPConnectAttempt: + * @addr: a socket address structure + * + * Attempt a connection to the given IP:port endpoint. It forces + * non-blocking semantic on the socket, and allow 60 seconds for + * the host to answer. + * + * Returns -1 in case of failure, the file descriptor number otherwise + */ + +static SOCKET +xmlNanoHTTPConnectAttempt(struct sockaddr *addr) +{ +#ifndef HAVE_POLL_H + fd_set wfd; +#ifdef _WINSOCKAPI_ + fd_set xfd; +#endif + struct timeval tv; +#else /* !HAVE_POLL_H */ + struct pollfd p; +#endif /* !HAVE_POLL_H */ + int status; + + int addrlen; + + SOCKET s; + +#ifdef SUPPORT_IP6 + if (addr->sa_family == AF_INET6) { + s = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP); + addrlen = sizeof(struct sockaddr_in6); + } else +#endif + { + s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + addrlen = sizeof(struct sockaddr_in); + } + if (s == INVALID_SOCKET) { +#ifdef DEBUG_HTTP + perror("socket"); +#endif + __xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n"); + return INVALID_SOCKET; + } +#ifdef _WINSOCKAPI_ + { + u_long one = 1; + + status = ioctlsocket(s, FIONBIO, &one) == SOCKET_ERROR ? -1 : 0; + } +#else /* _WINSOCKAPI_ */ +#if defined(VMS) + { + int enable = 1; + + status = ioctl(s, FIONBIO, &enable); + } +#else /* VMS */ +#if defined(__BEOS__) && !defined(__HAIKU__) + { + bool noblock = true; + + status = + setsockopt(s, SOL_SOCKET, SO_NONBLOCK, &noblock, + sizeof(noblock)); + } +#else /* __BEOS__ */ + if ((status = fcntl(s, F_GETFL, 0)) != -1) { +#ifdef O_NONBLOCK + status |= O_NONBLOCK; +#else /* O_NONBLOCK */ +#ifdef F_NDELAY + status |= F_NDELAY; +#endif /* F_NDELAY */ +#endif /* !O_NONBLOCK */ + status = fcntl(s, F_SETFL, status); + } + if (status < 0) { +#ifdef DEBUG_HTTP + perror("nonblocking"); +#endif + __xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n"); + closesocket(s); + return INVALID_SOCKET; + } +#endif /* !__BEOS__ */ +#endif /* !VMS */ +#endif /* !_WINSOCKAPI_ */ + + if (connect(s, addr, addrlen) == -1) { + switch (socket_errno()) { + case EINPROGRESS: + case EWOULDBLOCK: + break; + default: + __xmlIOErr(XML_FROM_HTTP, 0, + "error connecting to HTTP server"); + closesocket(s); + return INVALID_SOCKET; + } + } +#ifndef HAVE_POLL_H + tv.tv_sec = timeout; + tv.tv_usec = 0; + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4018) +#endif +#ifndef _WINSOCKAPI_ + if (s > FD_SETSIZE) + return INVALID_SOCKET; +#endif + FD_ZERO(&wfd); + FD_SET(s, &wfd); + +#ifdef _WINSOCKAPI_ + FD_ZERO(&xfd); + FD_SET(s, &xfd); + + switch (select(s + 1, NULL, &wfd, &xfd, &tv)) +#else + switch (select(s + 1, NULL, &wfd, NULL, &tv)) +#endif +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#else /* !HAVE_POLL_H */ + p.fd = s; + p.events = POLLOUT; + switch (poll(&p, 1, timeout * 1000)) +#endif /* !HAVE_POLL_H */ + + { + case 0: + /* Time out */ + __xmlIOErr(XML_FROM_HTTP, 0, "Connect attempt timed out"); + closesocket(s); + return INVALID_SOCKET; + case -1: + /* Ermm.. ?? */ + __xmlIOErr(XML_FROM_HTTP, 0, "Connect failed"); + closesocket(s); + return INVALID_SOCKET; + } + +#ifndef HAVE_POLL_H + if (FD_ISSET(s, &wfd) +#ifdef _WINSOCKAPI_ + || FD_ISSET(s, &xfd) +#endif + ) +#else /* !HAVE_POLL_H */ + if (p.revents == POLLOUT) +#endif /* !HAVE_POLL_H */ + { + XML_SOCKLEN_T len; + + len = sizeof(status); +#ifdef SO_ERROR + if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char *) &status, &len) < + 0) { + /* Solaris error code */ + __xmlIOErr(XML_FROM_HTTP, 0, "getsockopt failed\n"); + closesocket(s); + return INVALID_SOCKET; + } +#endif + if (status) { + __xmlIOErr(XML_FROM_HTTP, 0, + "Error connecting to remote host"); + closesocket(s); + errno = status; + return INVALID_SOCKET; + } + } else { + /* pbm */ + __xmlIOErr(XML_FROM_HTTP, 0, "select failed\n"); + closesocket(s); + return INVALID_SOCKET; + } + + return (s); +} + +/** + * xmlNanoHTTPConnectHost: + * @host: the host name + * @port: the port number + * + * Attempt a connection to the given host:port endpoint. It tries + * the multiple IP provided by the DNS if available. + * + * Returns -1 in case of failure, the file descriptor number otherwise + */ + +static SOCKET +xmlNanoHTTPConnectHost(const char *host, int port) +{ + struct sockaddr *addr = NULL; + struct sockaddr_in sockin; + +#ifdef SUPPORT_IP6 + struct in6_addr ia6; + struct sockaddr_in6 sockin6; +#endif + SOCKET s; + + memset (&sockin, 0, sizeof(sockin)); +#ifdef SUPPORT_IP6 + memset (&sockin6, 0, sizeof(sockin6)); +#endif + +#if !defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && defined(RES_USE_INET6) + if (have_ipv6 ()) + { + if (!(_res.options & RES_INIT)) + res_init(); + _res.options |= RES_USE_INET6; + } +#endif + +#if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32) + if (have_ipv6 ()) +#endif +#if defined(HAVE_GETADDRINFO) && (defined(SUPPORT_IP6) || defined(_WIN32)) + { + int status; + struct addrinfo hints, *res, *result; + + result = NULL; + memset (&hints, 0,sizeof(hints)); + hints.ai_socktype = SOCK_STREAM; + + status = getaddrinfo (host, NULL, &hints, &result); + if (status) { + __xmlIOErr(XML_FROM_HTTP, 0, "getaddrinfo failed\n"); + return INVALID_SOCKET; + } + + for (res = result; res; res = res->ai_next) { + if (res->ai_family == AF_INET) { + if ((size_t)res->ai_addrlen > sizeof(sockin)) { + __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); + freeaddrinfo (result); + return INVALID_SOCKET; + } + memcpy (&sockin, res->ai_addr, res->ai_addrlen); + sockin.sin_port = htons (port); + addr = (struct sockaddr *)&sockin; +#ifdef SUPPORT_IP6 + } else if (have_ipv6 () && (res->ai_family == AF_INET6)) { + if ((size_t)res->ai_addrlen > sizeof(sockin6)) { + __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); + freeaddrinfo (result); + return INVALID_SOCKET; + } + memcpy (&sockin6, res->ai_addr, res->ai_addrlen); + sockin6.sin6_port = htons (port); + addr = (struct sockaddr *)&sockin6; +#endif + } else + continue; /* for */ + + s = xmlNanoHTTPConnectAttempt (addr); + if (s != INVALID_SOCKET) { + freeaddrinfo (result); + return (s); + } + } + + if (result) + freeaddrinfo (result); + } +#endif +#if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32) + else +#endif +#if !defined(HAVE_GETADDRINFO) || !defined(_WIN32) + { + struct hostent *h; + struct in_addr ia; + int i; + + h = gethostbyname (GETHOSTBYNAME_ARG_CAST host); + if (h == NULL) { + +/* + * Okay, I got fed up by the non-portability of this error message + * extraction code. it work on Linux, if it work on your platform + * and one want to enable it, send me the defined(foobar) needed + */ +#if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND) && defined(__linux__) + const char *h_err_txt = ""; + + switch (h_errno) { + case HOST_NOT_FOUND: + h_err_txt = "Authoritative host not found"; + break; + + case TRY_AGAIN: + h_err_txt = + "Non-authoritative host not found or server failure."; + break; + + case NO_RECOVERY: + h_err_txt = + "Non-recoverable errors: FORMERR, REFUSED, or NOTIMP."; + break; + +#ifdef NO_ADDRESS + case NO_ADDRESS: + h_err_txt = + "Valid name, no data record of requested type."; + break; +#endif + + default: + h_err_txt = "No error text defined."; + break; + } + __xmlIOErr(XML_FROM_HTTP, 0, h_err_txt); +#else + __xmlIOErr(XML_FROM_HTTP, 0, "Failed to resolve host"); +#endif + return INVALID_SOCKET; + } + + for (i = 0; h->h_addr_list[i]; i++) { + if (h->h_addrtype == AF_INET) { + /* A records (IPv4) */ + if ((unsigned int) h->h_length > sizeof(ia)) { + __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); + return INVALID_SOCKET; + } + memcpy (&ia, h->h_addr_list[i], h->h_length); + sockin.sin_family = h->h_addrtype; + sockin.sin_addr = ia; + sockin.sin_port = (unsigned short)htons ((unsigned short)port); + addr = (struct sockaddr *) &sockin; +#ifdef SUPPORT_IP6 + } else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) { + /* AAAA records (IPv6) */ + if ((unsigned int) h->h_length > sizeof(ia6)) { + __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n"); + return INVALID_SOCKET; + } + memcpy (&ia6, h->h_addr_list[i], h->h_length); + sockin6.sin6_family = h->h_addrtype; + sockin6.sin6_addr = ia6; + sockin6.sin6_port = htons (port); + addr = (struct sockaddr *) &sockin6; +#endif + } else + break; /* for */ + + s = xmlNanoHTTPConnectAttempt (addr); + if (s != INVALID_SOCKET) + return (s); + } + } +#endif + +#ifdef DEBUG_HTTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoHTTPConnectHost: unable to connect to '%s'.\n", + host); +#endif + return INVALID_SOCKET; +} + + +/** + * xmlNanoHTTPOpen: + * @URL: The URL to load + * @contentType: if available the Content-Type information will be + * returned at that location + * + * This function try to open a connection to the indicated resource + * via HTTP GET. + * + * Returns NULL in case of failure, otherwise a request handler. + * The contentType, if provided must be freed by the caller + */ + +void* +xmlNanoHTTPOpen(const char *URL, char **contentType) { + if (contentType != NULL) *contentType = NULL; + return(xmlNanoHTTPMethod(URL, NULL, NULL, contentType, NULL, 0)); +} + +/** + * xmlNanoHTTPOpenRedir: + * @URL: The URL to load + * @contentType: if available the Content-Type information will be + * returned at that location + * @redir: if available the redirected URL will be returned + * + * This function try to open a connection to the indicated resource + * via HTTP GET. + * + * Returns NULL in case of failure, otherwise a request handler. + * The contentType, if provided must be freed by the caller + */ + +void* +xmlNanoHTTPOpenRedir(const char *URL, char **contentType, char **redir) { + if (contentType != NULL) *contentType = NULL; + if (redir != NULL) *redir = NULL; + return(xmlNanoHTTPMethodRedir(URL, NULL, NULL, contentType, redir, NULL,0)); +} + +/** + * xmlNanoHTTPRead: + * @ctx: the HTTP context + * @dest: a buffer + * @len: the buffer length + * + * This function tries to read @len bytes from the existing HTTP connection + * and saves them in @dest. This is a blocking call. + * + * Returns the number of byte read. 0 is an indication of an end of connection. + * -1 indicates a parameter error. + */ +int +xmlNanoHTTPRead(void *ctx, void *dest, int len) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; +#ifdef LIBXML_ZLIB_ENABLED + int bytes_read = 0; + int orig_avail_in; + int z_ret; +#endif + + if (ctx == NULL) return(-1); + if (dest == NULL) return(-1); + if (len <= 0) return(0); + +#ifdef LIBXML_ZLIB_ENABLED + if (ctxt->usesGzip == 1) { + if (ctxt->strm == NULL) return(0); + + ctxt->strm->next_out = dest; + ctxt->strm->avail_out = len; + ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr; + + while (ctxt->strm->avail_out > 0 && + (ctxt->strm->avail_in > 0 || xmlNanoHTTPRecv(ctxt) > 0)) { + orig_avail_in = ctxt->strm->avail_in = + ctxt->inptr - ctxt->inrptr - bytes_read; + ctxt->strm->next_in = BAD_CAST (ctxt->inrptr + bytes_read); + + z_ret = inflate(ctxt->strm, Z_NO_FLUSH); + bytes_read += orig_avail_in - ctxt->strm->avail_in; + + if (z_ret != Z_OK) break; + } + + ctxt->inrptr += bytes_read; + return(len - ctxt->strm->avail_out); + } +#endif + + while (ctxt->inptr - ctxt->inrptr < len) { + if (xmlNanoHTTPRecv(ctxt) <= 0) break; + } + if (ctxt->inptr - ctxt->inrptr < len) + len = ctxt->inptr - ctxt->inrptr; + memcpy(dest, ctxt->inrptr, len); + ctxt->inrptr += len; + return(len); +} + +/** + * xmlNanoHTTPClose: + * @ctx: the HTTP context + * + * This function closes an HTTP context, it ends up the connection and + * free all data related to it. + */ +void +xmlNanoHTTPClose(void *ctx) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; + + if (ctx == NULL) return; + + xmlNanoHTTPFreeCtxt(ctxt); +} + +/** + * xmlNanoHTTPMethodRedir: + * @URL: The URL to load + * @method: the HTTP method to use + * @input: the input string if any + * @contentType: the Content-Type information IN and OUT + * @redir: the redirected URL OUT + * @headers: the extra headers + * @ilen: input length + * + * This function try to open a connection to the indicated resource + * via HTTP using the given @method, adding the given extra headers + * and the input buffer for the request content. + * + * Returns NULL in case of failure, otherwise a request handler. + * The contentType, or redir, if provided must be freed by the caller + */ + +void* +xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input, + char **contentType, char **redir, + const char *headers, int ilen ) { + xmlNanoHTTPCtxtPtr ctxt; + char *bp, *p; + int blen; + SOCKET ret; + int nbRedirects = 0; + char *redirURL = NULL; +#ifdef DEBUG_HTTP + int xmt_bytes; +#endif + + if (URL == NULL) return(NULL); + if (method == NULL) method = "GET"; + xmlNanoHTTPInit(); + +retry: + if (redirURL == NULL) { + ctxt = xmlNanoHTTPNewCtxt(URL); + if (ctxt == NULL) + return(NULL); + } else { + ctxt = xmlNanoHTTPNewCtxt(redirURL); + if (ctxt == NULL) + return(NULL); + ctxt->location = xmlMemStrdup(redirURL); + } + + if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) { + __xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Not a valid HTTP URI"); + xmlNanoHTTPFreeCtxt(ctxt); + if (redirURL != NULL) xmlFree(redirURL); + return(NULL); + } + if (ctxt->hostname == NULL) { + __xmlIOErr(XML_FROM_HTTP, XML_HTTP_UNKNOWN_HOST, + "Failed to identify host in URI"); + xmlNanoHTTPFreeCtxt(ctxt); + if (redirURL != NULL) xmlFree(redirURL); + return(NULL); + } + if (proxy) { + blen = strlen(ctxt->hostname) * 2 + 16; + ret = xmlNanoHTTPConnectHost(proxy, proxyPort); + } + else { + blen = strlen(ctxt->hostname); + ret = xmlNanoHTTPConnectHost(ctxt->hostname, ctxt->port); + } + if (ret == INVALID_SOCKET) { + xmlNanoHTTPFreeCtxt(ctxt); + if (redirURL != NULL) xmlFree(redirURL); + return(NULL); + } + ctxt->fd = ret; + + if (input == NULL) + ilen = 0; + else + blen += 36; + + if (headers != NULL) + blen += strlen(headers) + 2; + if (contentType && *contentType) + /* reserve for string plus 'Content-Type: \r\n" */ + blen += strlen(*contentType) + 16; + if (ctxt->query != NULL) + /* 1 for '?' */ + blen += strlen(ctxt->query) + 1; + blen += strlen(method) + strlen(ctxt->path) + 24; +#ifdef LIBXML_ZLIB_ENABLED + /* reserve for possible 'Accept-Encoding: gzip' string */ + blen += 23; +#endif + if (ctxt->port != 80) { + /* reserve space for ':xxxxx', incl. potential proxy */ + if (proxy) + blen += 17; + else + blen += 11; + } + bp = (char*)xmlMallocAtomic(blen); + if ( bp == NULL ) { + xmlNanoHTTPFreeCtxt( ctxt ); + xmlHTTPErrMemory("allocating header buffer"); + return ( NULL ); + } + + p = bp; + + if (proxy) { + if (ctxt->port != 80) { + p += snprintf( p, blen - (p - bp), "%s http://%s:%d%s", + method, ctxt->hostname, + ctxt->port, ctxt->path ); + } + else + p += snprintf( p, blen - (p - bp), "%s http://%s%s", method, + ctxt->hostname, ctxt->path); + } + else + p += snprintf( p, blen - (p - bp), "%s %s", method, ctxt->path); + + if (ctxt->query != NULL) + p += snprintf( p, blen - (p - bp), "?%s", ctxt->query); + + if (ctxt->port == 80) { + p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s\r\n", + ctxt->hostname); + } else { + p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s:%d\r\n", + ctxt->hostname, ctxt->port); + } + +#ifdef LIBXML_ZLIB_ENABLED + p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n"); +#endif + + if (contentType != NULL && *contentType) + p += snprintf(p, blen - (p - bp), "Content-Type: %s\r\n", *contentType); + + if (headers != NULL) + p += snprintf( p, blen - (p - bp), "%s", headers ); + + if (input != NULL) + snprintf(p, blen - (p - bp), "Content-Length: %d\r\n\r\n", ilen ); + else + snprintf(p, blen - (p - bp), "\r\n"); + +#ifdef DEBUG_HTTP + xmlGenericError(xmlGenericErrorContext, + "-> %s%s", proxy? "(Proxy) " : "", bp); + if ((blen -= strlen(bp)+1) < 0) + xmlGenericError(xmlGenericErrorContext, + "ERROR: overflowed buffer by %d bytes\n", -blen); +#endif + ctxt->outptr = ctxt->out = bp; + ctxt->state = XML_NANO_HTTP_WRITE; + blen = strlen( ctxt->out ); +#ifdef DEBUG_HTTP + xmt_bytes = xmlNanoHTTPSend(ctxt, ctxt->out, blen ); + if ( xmt_bytes != blen ) + xmlGenericError( xmlGenericErrorContext, + "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n", + xmt_bytes, blen, + "bytes of HTTP headers sent to host", + ctxt->hostname ); +#else + xmlNanoHTTPSend(ctxt, ctxt->out, blen ); +#endif + + if ( input != NULL ) { +#ifdef DEBUG_HTTP + xmt_bytes = xmlNanoHTTPSend( ctxt, input, ilen ); + + if ( xmt_bytes != ilen ) + xmlGenericError( xmlGenericErrorContext, + "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n", + xmt_bytes, ilen, + "bytes of HTTP content sent to host", + ctxt->hostname ); +#else + xmlNanoHTTPSend( ctxt, input, ilen ); +#endif + } + + ctxt->state = XML_NANO_HTTP_READ; + + while ((p = xmlNanoHTTPReadLine(ctxt)) != NULL) { + if (*p == 0) { + ctxt->content = ctxt->inrptr; + xmlFree(p); + break; + } + xmlNanoHTTPScanAnswer(ctxt, p); + +#ifdef DEBUG_HTTP + xmlGenericError(xmlGenericErrorContext, "<- %s\n", p); +#endif + xmlFree(p); + } + + if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) && + (ctxt->returnValue < 400)) { +#ifdef DEBUG_HTTP + xmlGenericError(xmlGenericErrorContext, + "\nRedirect to: %s\n", ctxt->location); +#endif + while ( xmlNanoHTTPRecv(ctxt) > 0 ) + ; + if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) { + nbRedirects++; + if (redirURL != NULL) + xmlFree(redirURL); + redirURL = xmlMemStrdup(ctxt->location); + xmlNanoHTTPFreeCtxt(ctxt); + goto retry; + } + xmlNanoHTTPFreeCtxt(ctxt); + if (redirURL != NULL) xmlFree(redirURL); +#ifdef DEBUG_HTTP + xmlGenericError(xmlGenericErrorContext, + "xmlNanoHTTPMethodRedir: Too many redirects, aborting ...\n"); +#endif + return(NULL); + } + + if (contentType != NULL) { + if (ctxt->contentType != NULL) + *contentType = xmlMemStrdup(ctxt->contentType); + else + *contentType = NULL; + } + + if ((redir != NULL) && (redirURL != NULL)) { + *redir = redirURL; + } else { + if (redirURL != NULL) + xmlFree(redirURL); + if (redir != NULL) + *redir = NULL; + } + +#ifdef DEBUG_HTTP + if (ctxt->contentType != NULL) + xmlGenericError(xmlGenericErrorContext, + "\nCode %d, content-type '%s'\n\n", + ctxt->returnValue, ctxt->contentType); + else + xmlGenericError(xmlGenericErrorContext, + "\nCode %d, no content-type\n\n", + ctxt->returnValue); +#endif + + return((void *) ctxt); +} + +/** + * xmlNanoHTTPMethod: + * @URL: The URL to load + * @method: the HTTP method to use + * @input: the input string if any + * @contentType: the Content-Type information IN and OUT + * @headers: the extra headers + * @ilen: input length + * + * This function try to open a connection to the indicated resource + * via HTTP using the given @method, adding the given extra headers + * and the input buffer for the request content. + * + * Returns NULL in case of failure, otherwise a request handler. + * The contentType, if provided must be freed by the caller + */ + +void* +xmlNanoHTTPMethod(const char *URL, const char *method, const char *input, + char **contentType, const char *headers, int ilen) { + return(xmlNanoHTTPMethodRedir(URL, method, input, contentType, + NULL, headers, ilen)); +} + +/** + * xmlNanoHTTPFetch: + * @URL: The URL to load + * @filename: the filename where the content should be saved + * @contentType: if available the Content-Type information will be + * returned at that location + * + * This function try to fetch the indicated resource via HTTP GET + * and save it's content in the file. + * + * Returns -1 in case of failure, 0 in case of success. The contentType, + * if provided must be freed by the caller + */ +int +xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) { + void *ctxt = NULL; + char *buf = NULL; + int fd; + int len; + int ret = 0; + + if (filename == NULL) return(-1); + ctxt = xmlNanoHTTPOpen(URL, contentType); + if (ctxt == NULL) return(-1); + + if (!strcmp(filename, "-")) + fd = 0; + else { + fd = open(filename, O_CREAT | O_WRONLY, 00644); + if (fd < 0) { + xmlNanoHTTPClose(ctxt); + if ((contentType != NULL) && (*contentType != NULL)) { + xmlFree(*contentType); + *contentType = NULL; + } + return(-1); + } + } + + xmlNanoHTTPFetchContent( ctxt, &buf, &len ); + if ( len > 0 ) { + if (write(fd, buf, len) == -1) { + ret = -1; + } + } + + xmlNanoHTTPClose(ctxt); + close(fd); + return(ret); +} + +#ifdef LIBXML_OUTPUT_ENABLED +/** + * xmlNanoHTTPSave: + * @ctxt: the HTTP context + * @filename: the filename where the content should be saved + * + * This function saves the output of the HTTP transaction to a file + * It closes and free the context at the end + * + * Returns -1 in case of failure, 0 in case of success. + */ +int +xmlNanoHTTPSave(void *ctxt, const char *filename) { + char *buf = NULL; + int fd; + int len; + int ret = 0; + + if ((ctxt == NULL) || (filename == NULL)) return(-1); + + if (!strcmp(filename, "-")) + fd = 0; + else { + fd = open(filename, O_CREAT | O_WRONLY, 0666); + if (fd < 0) { + xmlNanoHTTPClose(ctxt); + return(-1); + } + } + + xmlNanoHTTPFetchContent( ctxt, &buf, &len ); + if ( len > 0 ) { + if (write(fd, buf, len) == -1) { + ret = -1; + } + } + + xmlNanoHTTPClose(ctxt); + close(fd); + return(ret); +} +#endif /* LIBXML_OUTPUT_ENABLED */ + +/** + * xmlNanoHTTPReturnCode: + * @ctx: the HTTP context + * + * Get the latest HTTP return code received + * + * Returns the HTTP return code for the request. + */ +int +xmlNanoHTTPReturnCode(void *ctx) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; + + if (ctxt == NULL) return(-1); + + return(ctxt->returnValue); +} + +/** + * xmlNanoHTTPAuthHeader: + * @ctx: the HTTP context + * + * Get the authentication header of an HTTP context + * + * Returns the stashed value of the WWW-Authenticate or Proxy-Authenticate + * header. + */ +const char * +xmlNanoHTTPAuthHeader(void *ctx) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr) ctx; + + if (ctxt == NULL) return(NULL); + + return(ctxt->authHeader); +} + +/** + * xmlNanoHTTPContentLength: + * @ctx: the HTTP context + * + * Provides the specified content length from the HTTP header. + * + * Return the specified content length from the HTTP header. Note that + * a value of -1 indicates that the content length element was not included in + * the response header. + */ +int +xmlNanoHTTPContentLength( void * ctx ) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; + + return ( ( ctxt == NULL ) ? -1 : ctxt->ContentLength ); +} + +/** + * xmlNanoHTTPRedir: + * @ctx: the HTTP context + * + * Provides the specified redirection URL if available from the HTTP header. + * + * Return the specified redirection URL or NULL if not redirected. + */ +const char * +xmlNanoHTTPRedir( void * ctx ) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; + + return ( ( ctxt == NULL ) ? NULL : ctxt->location ); +} + +/** + * xmlNanoHTTPEncoding: + * @ctx: the HTTP context + * + * Provides the specified encoding if specified in the HTTP headers. + * + * Return the specified encoding or NULL if not available + */ +const char * +xmlNanoHTTPEncoding( void * ctx ) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; + + return ( ( ctxt == NULL ) ? NULL : ctxt->encoding ); +} + +/** + * xmlNanoHTTPMimeType: + * @ctx: the HTTP context + * + * Provides the specified Mime-Type if specified in the HTTP headers. + * + * Return the specified Mime-Type or NULL if not available + */ +const char * +xmlNanoHTTPMimeType( void * ctx ) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; + + return ( ( ctxt == NULL ) ? NULL : ctxt->mimeType ); +} + +/** + * xmlNanoHTTPFetchContent: + * @ctx: the HTTP context + * @ptr: pointer to set to the content buffer. + * @len: integer pointer to hold the length of the content + * + * Check if all the content was read + * + * Returns 0 if all the content was read and available, returns + * -1 if received content length was less than specified or an error + * occurred. + */ +static int +xmlNanoHTTPFetchContent( void * ctx, char ** ptr, int * len ) { + xmlNanoHTTPCtxtPtr ctxt = (xmlNanoHTTPCtxtPtr)ctx; + + int rc = 0; + int cur_lgth; + int rcvd_lgth; + int dummy_int; + char * dummy_ptr = NULL; + + /* Dummy up return input parameters if not provided */ + + if ( len == NULL ) + len = &dummy_int; + + if ( ptr == NULL ) + ptr = &dummy_ptr; + + /* But can't work without the context pointer */ + + if ( ( ctxt == NULL ) || ( ctxt->content == NULL ) ) { + *len = 0; + *ptr = NULL; + return ( -1 ); + } + + rcvd_lgth = ctxt->inptr - ctxt->content; + + while ( (cur_lgth = xmlNanoHTTPRecv( ctxt )) > 0 ) { + + rcvd_lgth += cur_lgth; + if ( (ctxt->ContentLength > 0) && (rcvd_lgth >= ctxt->ContentLength) ) + break; + } + + *ptr = ctxt->content; + *len = rcvd_lgth; + + if ( ( ctxt->ContentLength > 0 ) && ( rcvd_lgth < ctxt->ContentLength ) ) + rc = -1; + else if ( rcvd_lgth == 0 ) + rc = -1; + + return ( rc ); +} + +#ifdef STANDALONE +int main(int argc, char **argv) { + char *contentType = NULL; + + if (argv[1] != NULL) { + if (argv[2] != NULL) + xmlNanoHTTPFetch(argv[1], argv[2], &contentType); + else + xmlNanoHTTPFetch(argv[1], "-", &contentType); + if (contentType != NULL) xmlFree(contentType); + } else { + xmlGenericError(xmlGenericErrorContext, + "%s: minimal HTTP GET implementation\n", argv[0]); + xmlGenericError(xmlGenericErrorContext, + "\tusage %s [ URL [ filename ] ]\n", argv[0]); + } + xmlNanoHTTPCleanup(); + xmlMemoryDump(); + return(0); +} +#endif /* STANDALONE */ +#else /* !LIBXML_HTTP_ENABLED */ +#ifdef STANDALONE +#include +int main(int argc, char **argv) { + xmlGenericError(xmlGenericErrorContext, + "%s : HTTP support not compiled in\n", argv[0]); + return(0); +} +#endif /* STANDALONE */ +#endif /* LIBXML_HTTP_ENABLED */ +#define bottom_nanohttp +#include "elfgcchack.h" diff --git a/src/parser.c b/src/parser.c new file mode 100644 index 000000000000..d5b72e4fc591 --- /dev/null +++ b/src/parser.c @@ -0,0 +1,15571 @@ +/* + * parser.c : an XML 1.0 parser, namespaces and validity support are mostly + * implemented on top of the SAX interfaces + * + * References: + * The XML specification: + * http://www.w3.org/TR/REC-xml + * Original 1.0 version: + * http://www.w3.org/TR/1998/REC-xml-19980210 + * XML second edition working draft + * http://www.w3.org/TR/2000/WD-xml-2e-20000814 + * + * Okay this is a big file, the parser core is around 7000 lines, then it + * is followed by the progressive parser top routines, then the various + * high level APIs to call the parser and a few miscellaneous functions. + * A number of helper functions and deprecated ones have been moved to + * parserInternals.c to reduce this file size. + * As much as possible the functions are associated with their relative + * production in the XML specification. A few productions defining the + * different ranges of character are actually implanted either in + * parserInternals.h or parserInternals.c + * The DOM tree build is realized from the default SAX callbacks in + * the module SAX.c. + * The routines doing the validation checks are in valid.c and called either + * from the SAX callbacks or as standalone functions using a preparsed + * document. + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +/* To avoid EBCDIC trouble when parsing on zOS */ +#if defined(__MVS__) +#pragma convert("ISO8859-1") +#endif + +#define IN_LIBXML +#include "libxml.h" + +#if defined(_WIN32) && !defined (__CYGWIN__) +#define XML_DIR_SEP '\\' +#else +#define XML_DIR_SEP '/' +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef LIBXML_CATALOG_ENABLED +#include +#endif +#ifdef LIBXML_SCHEMAS_ENABLED +#include +#include +#endif +#ifdef HAVE_CTYPE_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "buf.h" +#include "enc.h" + +struct _xmlStartTag { + const xmlChar *prefix; + const xmlChar *URI; + int line; + int nsNr; +}; + +static void +xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info); + +static xmlParserCtxtPtr +xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, + const xmlChar *base, xmlParserCtxtPtr pctx); + +static void xmlHaltParser(xmlParserCtxtPtr ctxt); + +static int +xmlParseElementStart(xmlParserCtxtPtr ctxt); + +static void +xmlParseElementEnd(xmlParserCtxtPtr ctxt); + +/************************************************************************ + * * + * Arbitrary limits set in the parser. See XML_PARSE_HUGE * + * * + ************************************************************************/ + +#define XML_PARSER_BIG_ENTITY 1000 +#define XML_PARSER_LOT_ENTITY 5000 + +/* + * XML_PARSER_NON_LINEAR is the threshold where the ratio of parsed entity + * replacement over the size in byte of the input indicates that you have + * and exponential behaviour. A value of 10 correspond to at least 3 entity + * replacement per byte of input. + */ +#define XML_PARSER_NON_LINEAR 10 + +/* + * xmlParserEntityCheck + * + * Function to check non-linear entity expansion behaviour + * This is here to detect and stop exponential linear entity expansion + * This is not a limitation of the parser but a safety + * boundary feature. It can be disabled with the XML_PARSE_HUGE + * parser option. + */ +static int +xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, + xmlEntityPtr ent, size_t replacement) +{ + size_t consumed = 0; + int i; + + if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE)) + return (0); + if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) + return (1); + + /* + * This may look absurd but is needed to detect + * entities problems + */ + if ((ent != NULL) && (ent->guard == XML_ENTITY_BEING_CHECKED)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return (1); + } + + if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && + (ent->content != NULL) && (ent->checked == 0) && + (ctxt->errNo != XML_ERR_ENTITY_LOOP)) { + unsigned long oldnbent = ctxt->nbentities, diff; + xmlChar *rep; + + ent->guard = XML_ENTITY_BEING_CHECKED; + ent->checked = 1; + + ++ctxt->depth; + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, 0, 0, 0); + --ctxt->depth; + ent->guard = XML_ENTITY_NOT_BEING_CHECKED; + if ((rep == NULL) || (ctxt->errNo == XML_ERR_ENTITY_LOOP)) { + ent->content[0] = 0; + } + + diff = ctxt->nbentities - oldnbent + 1; + if (diff > INT_MAX / 2) + diff = INT_MAX / 2; + ent->checked = diff * 2; + if (rep != NULL) { + if (xmlStrchr(rep, '<')) + ent->checked |= 1; + xmlFree(rep); + rep = NULL; + } + } + + /* + * Prevent entity exponential check, not just replacement while + * parsing the DTD + * The check is potentially costly so do that only once in a thousand + */ + if ((ctxt->instate == XML_PARSER_DTD) && (ctxt->nbentities > 10000) && + (ctxt->nbentities % 1024 == 0)) { + for (i = 0;i < ctxt->inputNr;i++) { + consumed += ctxt->inputTab[i]->consumed + + (ctxt->inputTab[i]->cur - ctxt->inputTab[i]->base); + } + if (ctxt->nbentities > consumed * XML_PARSER_NON_LINEAR) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + ctxt->instate = XML_PARSER_EOF; + return (1); + } + consumed = 0; + } + + + + if (replacement != 0) { + if (replacement < XML_MAX_TEXT_LENGTH) + return(0); + + /* + * If the volume of entity copy reaches 10 times the + * amount of parsed data and over the large text threshold + * then that's very likely to be an abuse. + */ + if (ctxt->input != NULL) { + consumed = ctxt->input->consumed + + (ctxt->input->cur - ctxt->input->base); + } + consumed += ctxt->sizeentities; + + if (replacement < XML_PARSER_NON_LINEAR * consumed) + return(0); + } else if (size != 0) { + /* + * Do the check based on the replacement size of the entity + */ + if (size < XML_PARSER_BIG_ENTITY) + return(0); + + /* + * A limit on the amount of text data reasonably used + */ + if (ctxt->input != NULL) { + consumed = ctxt->input->consumed + + (ctxt->input->cur - ctxt->input->base); + } + consumed += ctxt->sizeentities; + + if ((size < XML_PARSER_NON_LINEAR * consumed) && + (ctxt->nbentities * 3 < XML_PARSER_NON_LINEAR * consumed)) + return (0); + } else if (ent != NULL) { + /* + * use the number of parsed entities in the replacement + */ + size = ent->checked / 2; + + /* + * The amount of data parsed counting entities size only once + */ + if (ctxt->input != NULL) { + consumed = ctxt->input->consumed + + (ctxt->input->cur - ctxt->input->base); + } + consumed += ctxt->sizeentities; + + /* + * Check the density of entities for the amount of data + * knowing an entity reference will take at least 3 bytes + */ + if (size * 3 < consumed * XML_PARSER_NON_LINEAR) + return (0); + } else { + /* + * strange we got no data for checking + */ + if (((ctxt->lastError.code != XML_ERR_UNDECLARED_ENTITY) && + (ctxt->lastError.code != XML_WAR_UNDECLARED_ENTITY)) || + (ctxt->nbentities <= 10000)) + return (0); + } + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return (1); +} + +/** + * xmlParserMaxDepth: + * + * arbitrary depth limit for the XML documents that we allow to + * process. This is not a limitation of the parser but a safety + * boundary feature. It can be disabled with the XML_PARSE_HUGE + * parser option. + */ +unsigned int xmlParserMaxDepth = 256; + + + +#define SAX2 1 +#define XML_PARSER_BIG_BUFFER_SIZE 300 +#define XML_PARSER_BUFFER_SIZE 100 +#define SAX_COMPAT_MODE BAD_CAST "SAX compatibility mode document" + +/** + * XML_PARSER_CHUNK_SIZE + * + * When calling GROW that's the minimal amount of data + * the parser expected to have received. It is not a hard + * limit but an optimization when reading strings like Names + * It is not strictly needed as long as inputs available characters + * are followed by 0, which should be provided by the I/O level + */ +#define XML_PARSER_CHUNK_SIZE 100 + +/* + * List of XML prefixed PI allowed by W3C specs + */ + +static const char *xmlW3CPIs[] = { + "xml-stylesheet", + "xml-model", + NULL +}; + + +/* DEPR void xmlParserHandleReference(xmlParserCtxtPtr ctxt); */ +static xmlEntityPtr xmlParseStringPEReference(xmlParserCtxtPtr ctxt, + const xmlChar **str); + +static xmlParserErrors +xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt, + xmlSAXHandlerPtr sax, + void *user_data, int depth, const xmlChar *URL, + const xmlChar *ID, xmlNodePtr *list); + +static int +xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, + const char *encoding); +#ifdef LIBXML_LEGACY_ENABLED +static void +xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode, + xmlNodePtr lastNode); +#endif /* LIBXML_LEGACY_ENABLED */ + +static xmlParserErrors +xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt, + const xmlChar *string, void *user_data, xmlNodePtr *lst); + +static int +xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity); + +/************************************************************************ + * * + * Some factorized error routines * + * * + ************************************************************************/ + +/** + * xmlErrAttributeDup: + * @ctxt: an XML parser context + * @prefix: the attribute prefix + * @localname: the attribute localname + * + * Handle a redefinition of attribute error + */ +static void +xmlErrAttributeDup(xmlParserCtxtPtr ctxt, const xmlChar * prefix, + const xmlChar * localname) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = XML_ERR_ATTRIBUTE_REDEFINED; + + if (prefix == NULL) + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, + XML_ERR_ATTRIBUTE_REDEFINED, XML_ERR_FATAL, NULL, 0, + (const char *) localname, NULL, NULL, 0, 0, + "Attribute %s redefined\n", localname); + else + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, + XML_ERR_ATTRIBUTE_REDEFINED, XML_ERR_FATAL, NULL, 0, + (const char *) prefix, (const char *) localname, + NULL, 0, 0, "Attribute %s:%s redefined\n", prefix, + localname); + if (ctxt != NULL) { + ctxt->wellFormed = 0; + if (ctxt->recovery == 0) + ctxt->disableSAX = 1; + } +} + +/** + * xmlFatalErr: + * @ctxt: an XML parser context + * @error: the error number + * @extra: extra information string + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void +xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) +{ + const char *errmsg; + + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + switch (error) { + case XML_ERR_INVALID_HEX_CHARREF: + errmsg = "CharRef: invalid hexadecimal value"; + break; + case XML_ERR_INVALID_DEC_CHARREF: + errmsg = "CharRef: invalid decimal value"; + break; + case XML_ERR_INVALID_CHARREF: + errmsg = "CharRef: invalid value"; + break; + case XML_ERR_INTERNAL_ERROR: + errmsg = "internal error"; + break; + case XML_ERR_PEREF_AT_EOF: + errmsg = "PEReference at end of document"; + break; + case XML_ERR_PEREF_IN_PROLOG: + errmsg = "PEReference in prolog"; + break; + case XML_ERR_PEREF_IN_EPILOG: + errmsg = "PEReference in epilog"; + break; + case XML_ERR_PEREF_NO_NAME: + errmsg = "PEReference: no name"; + break; + case XML_ERR_PEREF_SEMICOL_MISSING: + errmsg = "PEReference: expecting ';'"; + break; + case XML_ERR_ENTITY_LOOP: + errmsg = "Detected an entity reference loop"; + break; + case XML_ERR_ENTITY_NOT_STARTED: + errmsg = "EntityValue: \" or ' expected"; + break; + case XML_ERR_ENTITY_PE_INTERNAL: + errmsg = "PEReferences forbidden in internal subset"; + break; + case XML_ERR_ENTITY_NOT_FINISHED: + errmsg = "EntityValue: \" or ' expected"; + break; + case XML_ERR_ATTRIBUTE_NOT_STARTED: + errmsg = "AttValue: \" or ' expected"; + break; + case XML_ERR_LT_IN_ATTRIBUTE: + errmsg = "Unescaped '<' not allowed in attributes values"; + break; + case XML_ERR_LITERAL_NOT_STARTED: + errmsg = "SystemLiteral \" or ' expected"; + break; + case XML_ERR_LITERAL_NOT_FINISHED: + errmsg = "Unfinished System or Public ID \" or ' expected"; + break; + case XML_ERR_MISPLACED_CDATA_END: + errmsg = "Sequence ']]>' not allowed in content"; + break; + case XML_ERR_URI_REQUIRED: + errmsg = "SYSTEM or PUBLIC, the URI is missing"; + break; + case XML_ERR_PUBID_REQUIRED: + errmsg = "PUBLIC, the Public Identifier is missing"; + break; + case XML_ERR_HYPHEN_IN_COMMENT: + errmsg = "Comment must not contain '--' (double-hyphen)"; + break; + case XML_ERR_PI_NOT_STARTED: + errmsg = "xmlParsePI : no target name"; + break; + case XML_ERR_RESERVED_XML_NAME: + errmsg = "Invalid PI name"; + break; + case XML_ERR_NOTATION_NOT_STARTED: + errmsg = "NOTATION: Name expected here"; + break; + case XML_ERR_NOTATION_NOT_FINISHED: + errmsg = "'>' required to close NOTATION declaration"; + break; + case XML_ERR_VALUE_REQUIRED: + errmsg = "Entity value required"; + break; + case XML_ERR_URI_FRAGMENT: + errmsg = "Fragment not allowed"; + break; + case XML_ERR_ATTLIST_NOT_STARTED: + errmsg = "'(' required to start ATTLIST enumeration"; + break; + case XML_ERR_NMTOKEN_REQUIRED: + errmsg = "NmToken expected in ATTLIST enumeration"; + break; + case XML_ERR_ATTLIST_NOT_FINISHED: + errmsg = "')' required to finish ATTLIST enumeration"; + break; + case XML_ERR_MIXED_NOT_STARTED: + errmsg = "MixedContentDecl : '|' or ')*' expected"; + break; + case XML_ERR_PCDATA_REQUIRED: + errmsg = "MixedContentDecl : '#PCDATA' expected"; + break; + case XML_ERR_ELEMCONTENT_NOT_STARTED: + errmsg = "ContentDecl : Name or '(' expected"; + break; + case XML_ERR_ELEMCONTENT_NOT_FINISHED: + errmsg = "ContentDecl : ',' '|' or ')' expected"; + break; + case XML_ERR_PEREF_IN_INT_SUBSET: + errmsg = + "PEReference: forbidden within markup decl in internal subset"; + break; + case XML_ERR_GT_REQUIRED: + errmsg = "expected '>'"; + break; + case XML_ERR_CONDSEC_INVALID: + errmsg = "XML conditional section '[' expected"; + break; + case XML_ERR_EXT_SUBSET_NOT_FINISHED: + errmsg = "Content error in the external subset"; + break; + case XML_ERR_CONDSEC_INVALID_KEYWORD: + errmsg = + "conditional section INCLUDE or IGNORE keyword expected"; + break; + case XML_ERR_CONDSEC_NOT_FINISHED: + errmsg = "XML conditional section not closed"; + break; + case XML_ERR_XMLDECL_NOT_STARTED: + errmsg = "Text declaration '' expected"; + break; + case XML_ERR_EXT_ENTITY_STANDALONE: + errmsg = "external parsed entities cannot be standalone"; + break; + case XML_ERR_ENTITYREF_SEMICOL_MISSING: + errmsg = "EntityRef: expecting ';'"; + break; + case XML_ERR_DOCTYPE_NOT_FINISHED: + errmsg = "DOCTYPE improperly terminated"; + break; + case XML_ERR_LTSLASH_REQUIRED: + errmsg = "EndTag: 'errNo = error; + if (info == NULL) { + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n", + errmsg); + } else { + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n", + errmsg, info); + } + if (ctxt != NULL) { + ctxt->wellFormed = 0; + if (ctxt->recovery == 0) + ctxt->disableSAX = 1; + } +} + +/** + * xmlFatalErrMsg: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg); + if (ctxt != NULL) { + ctxt->wellFormed = 0; + if (ctxt->recovery == 0) + ctxt->disableSAX = 1; + } +} + +/** + * xmlWarningMsg: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @str1: extra data + * @str2: extra data + * + * Handle a warning. + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar *str1, const xmlChar *str2) +{ + xmlStructuredErrorFunc schannel = NULL; + + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if ((ctxt != NULL) && (ctxt->sax != NULL) && + (ctxt->sax->initialized == XML_SAX2_MAGIC)) + schannel = ctxt->sax->serror; + if (ctxt != NULL) { + __xmlRaiseError(schannel, + (ctxt->sax) ? ctxt->sax->warning : NULL, + ctxt->userData, + ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_WARNING, NULL, 0, + (const char *) str1, (const char *) str2, NULL, 0, 0, + msg, (const char *) str1, (const char *) str2); + } else { + __xmlRaiseError(schannel, NULL, NULL, + ctxt, NULL, XML_FROM_PARSER, error, + XML_ERR_WARNING, NULL, 0, + (const char *) str1, (const char *) str2, NULL, 0, 0, + msg, (const char *) str1, (const char *) str2); + } +} + +/** + * xmlValidityError: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @str1: extra data + * + * Handle a validity error. + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar *str1, const xmlChar *str2) +{ + xmlStructuredErrorFunc schannel = NULL; + + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) { + ctxt->errNo = error; + if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC)) + schannel = ctxt->sax->serror; + } + if (ctxt != NULL) { + __xmlRaiseError(schannel, + ctxt->vctxt.error, ctxt->vctxt.userData, + ctxt, NULL, XML_FROM_DTD, error, + XML_ERR_ERROR, NULL, 0, (const char *) str1, + (const char *) str2, NULL, 0, 0, + msg, (const char *) str1, (const char *) str2); + ctxt->valid = 0; + } else { + __xmlRaiseError(schannel, NULL, NULL, + ctxt, NULL, XML_FROM_DTD, error, + XML_ERR_ERROR, NULL, 0, (const char *) str1, + (const char *) str2, NULL, 0, 0, + msg, (const char *) str1, (const char *) str2); + } +} + +/** + * xmlFatalErrMsgInt: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @val: an integer value + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, int val) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, NULL, + ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, + NULL, 0, NULL, NULL, NULL, val, 0, msg, val); + if (ctxt != NULL) { + ctxt->wellFormed = 0; + if (ctxt->recovery == 0) + ctxt->disableSAX = 1; + } +} + +/** + * xmlFatalErrMsgStrIntStr: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @str1: an string info + * @val: an integer value + * @str2: an string info + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar *str1, int val, + const xmlChar *str2) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, NULL, + ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, + NULL, 0, (const char *) str1, (const char *) str2, + NULL, val, 0, msg, str1, val, str2); + if (ctxt != NULL) { + ctxt->wellFormed = 0; + if (ctxt->recovery == 0) + ctxt->disableSAX = 1; + } +} + +/** + * xmlFatalErrMsgStr: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @val: a string value + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar * val) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, + XML_FROM_PARSER, error, XML_ERR_FATAL, + NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg, + val); + if (ctxt != NULL) { + ctxt->wellFormed = 0; + if (ctxt->recovery == 0) + ctxt->disableSAX = 1; + } +} + +/** + * xmlErrMsgStr: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @val: a string value + * + * Handle a non fatal parser error + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar * val) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, + XML_FROM_PARSER, error, XML_ERR_ERROR, + NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg, + val); +} + +/** + * xmlNsErr: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the message + * @info1: extra information string + * @info2: extra information string + * + * Handle a fatal parser error, i.e. violating Well-Formedness constraints + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, + const xmlChar * info1, const xmlChar * info2, + const xmlChar * info3) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + if (ctxt != NULL) + ctxt->errNo = error; + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error, + XML_ERR_ERROR, NULL, 0, (const char *) info1, + (const char *) info2, (const char *) info3, 0, 0, msg, + info1, info2, info3); + if (ctxt != NULL) + ctxt->nsWellFormed = 0; +} + +/** + * xmlNsWarn + * @ctxt: an XML parser context + * @error: the error number + * @msg: the message + * @info1: extra information string + * @info2: extra information string + * + * Handle a namespace warning error + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, + const xmlChar * info1, const xmlChar * info2, + const xmlChar * info3) +{ + if ((ctxt != NULL) && (ctxt->disableSAX != 0) && + (ctxt->instate == XML_PARSER_EOF)) + return; + __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error, + XML_ERR_WARNING, NULL, 0, (const char *) info1, + (const char *) info2, (const char *) info3, 0, 0, msg, + info1, info2, info3); +} + +/************************************************************************ + * * + * Library wide options * + * * + ************************************************************************/ + +/** + * xmlHasFeature: + * @feature: the feature to be examined + * + * Examines if the library has been compiled with a given feature. + * + * Returns a non-zero value if the feature exist, otherwise zero. + * Returns zero (0) if the feature does not exist or an unknown + * unknown feature is requested, non-zero otherwise. + */ +int +xmlHasFeature(xmlFeature feature) +{ + switch (feature) { + case XML_WITH_THREAD: +#ifdef LIBXML_THREAD_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_TREE: +#ifdef LIBXML_TREE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_OUTPUT: +#ifdef LIBXML_OUTPUT_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_PUSH: +#ifdef LIBXML_PUSH_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_READER: +#ifdef LIBXML_READER_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_PATTERN: +#ifdef LIBXML_PATTERN_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_WRITER: +#ifdef LIBXML_WRITER_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SAX1: +#ifdef LIBXML_SAX1_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_FTP: +#ifdef LIBXML_FTP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_HTTP: +#ifdef LIBXML_HTTP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_VALID: +#ifdef LIBXML_VALID_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_HTML: +#ifdef LIBXML_HTML_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_LEGACY: +#ifdef LIBXML_LEGACY_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_C14N: +#ifdef LIBXML_C14N_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_CATALOG: +#ifdef LIBXML_CATALOG_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XPATH: +#ifdef LIBXML_XPATH_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XPTR: +#ifdef LIBXML_XPTR_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XINCLUDE: +#ifdef LIBXML_XINCLUDE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ICONV: +#ifdef LIBXML_ICONV_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ISO8859X: +#ifdef LIBXML_ISO8859X_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_UNICODE: +#ifdef LIBXML_UNICODE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_REGEXP: +#ifdef LIBXML_REGEXP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_AUTOMATA: +#ifdef LIBXML_AUTOMATA_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_EXPR: +#ifdef LIBXML_EXPR_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SCHEMAS: +#ifdef LIBXML_SCHEMAS_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SCHEMATRON: +#ifdef LIBXML_SCHEMATRON_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_MODULES: +#ifdef LIBXML_MODULES_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG: +#ifdef LIBXML_DEBUG_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG_MEM: +#ifdef DEBUG_MEMORY_LOCATION + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG_RUN: +#ifdef LIBXML_DEBUG_RUNTIME + return(1); +#else + return(0); +#endif + case XML_WITH_ZLIB: +#ifdef LIBXML_ZLIB_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_LZMA: +#ifdef LIBXML_LZMA_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ICU: +#ifdef LIBXML_ICU_ENABLED + return(1); +#else + return(0); +#endif + default: + break; + } + return(0); +} + +/************************************************************************ + * * + * SAX2 defaulted attributes handling * + * * + ************************************************************************/ + +/** + * xmlDetectSAX2: + * @ctxt: an XML parser context + * + * Do the SAX2 detection and specific initialization + */ +static void +xmlDetectSAX2(xmlParserCtxtPtr ctxt) { + xmlSAXHandlerPtr sax; + if (ctxt == NULL) return; + sax = ctxt->sax; +#ifdef LIBXML_SAX1_ENABLED + if ((sax) && (sax->initialized == XML_SAX2_MAGIC) && + ((sax->startElementNs != NULL) || + (sax->endElementNs != NULL) || + ((sax->startElement == NULL) && (sax->endElement == NULL)))) + ctxt->sax2 = 1; +#else + ctxt->sax2 = 1; +#endif /* LIBXML_SAX1_ENABLED */ + + ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3); + ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5); + ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36); + if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) || + (ctxt->str_xml_ns == NULL)) { + xmlErrMemory(ctxt, NULL); + } +} + +typedef struct _xmlDefAttrs xmlDefAttrs; +typedef xmlDefAttrs *xmlDefAttrsPtr; +struct _xmlDefAttrs { + int nbAttrs; /* number of defaulted attributes on that element */ + int maxAttrs; /* the size of the array */ +#if __STDC_VERSION__ >= 199901L + /* Using a C99 flexible array member avoids UBSan errors. */ + const xmlChar *values[]; /* array of localname/prefix/values/external */ +#else + const xmlChar *values[5]; +#endif +}; + +/** + * xmlAttrNormalizeSpace: + * @src: the source string + * @dst: the target string + * + * Normalize the space in non CDATA attribute values: + * If the attribute type is not CDATA, then the XML processor MUST further + * process the normalized attribute value by discarding any leading and + * trailing space (#x20) characters, and by replacing sequences of space + * (#x20) characters by a single space (#x20) character. + * Note that the size of dst need to be at least src, and if one doesn't need + * to preserve dst (and it doesn't come from a dictionary or read-only) then + * passing src as dst is just fine. + * + * Returns a pointer to the normalized value (dst) or NULL if no conversion + * is needed. + */ +static xmlChar * +xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst) +{ + if ((src == NULL) || (dst == NULL)) + return(NULL); + + while (*src == 0x20) src++; + while (*src != 0) { + if (*src == 0x20) { + while (*src == 0x20) src++; + if (*src != 0) + *dst++ = 0x20; + } else { + *dst++ = *src++; + } + } + *dst = 0; + if (dst == src) + return(NULL); + return(dst); +} + +/** + * xmlAttrNormalizeSpace2: + * @src: the source string + * + * Normalize the space in non CDATA attribute values, a slightly more complex + * front end to avoid allocation problems when running on attribute values + * coming from the input. + * + * Returns a pointer to the normalized value (dst) or NULL if no conversion + * is needed. + */ +static const xmlChar * +xmlAttrNormalizeSpace2(xmlParserCtxtPtr ctxt, xmlChar *src, int *len) +{ + int i; + int remove_head = 0; + int need_realloc = 0; + const xmlChar *cur; + + if ((ctxt == NULL) || (src == NULL) || (len == NULL)) + return(NULL); + i = *len; + if (i <= 0) + return(NULL); + + cur = src; + while (*cur == 0x20) { + cur++; + remove_head++; + } + while (*cur != 0) { + if (*cur == 0x20) { + cur++; + if ((*cur == 0x20) || (*cur == 0)) { + need_realloc = 1; + break; + } + } else + cur++; + } + if (need_realloc) { + xmlChar *ret; + + ret = xmlStrndup(src + remove_head, i - remove_head + 1); + if (ret == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + xmlAttrNormalizeSpace(ret, ret); + *len = (int) strlen((const char *)ret); + return(ret); + } else if (remove_head) { + *len -= remove_head; + memmove(src, src + remove_head, 1 + *len); + return(src); + } + return(NULL); +} + +/** + * xmlAddDefAttrs: + * @ctxt: an XML parser context + * @fullname: the element fullname + * @fullattr: the attribute fullname + * @value: the attribute value + * + * Add a defaulted attribute for an element + */ +static void +xmlAddDefAttrs(xmlParserCtxtPtr ctxt, + const xmlChar *fullname, + const xmlChar *fullattr, + const xmlChar *value) { + xmlDefAttrsPtr defaults; + int len; + const xmlChar *name; + const xmlChar *prefix; + + /* + * Allows to detect attribute redefinitions + */ + if (ctxt->attsSpecial != NULL) { + if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL) + return; + } + + if (ctxt->attsDefault == NULL) { + ctxt->attsDefault = xmlHashCreateDict(10, ctxt->dict); + if (ctxt->attsDefault == NULL) + goto mem_error; + } + + /* + * split the element name into prefix:localname , the string found + * are within the DTD and then not associated to namespace names. + */ + name = xmlSplitQName3(fullname, &len); + if (name == NULL) { + name = xmlDictLookup(ctxt->dict, fullname, -1); + prefix = NULL; + } else { + name = xmlDictLookup(ctxt->dict, name, -1); + prefix = xmlDictLookup(ctxt->dict, fullname, len); + } + + /* + * make sure there is some storage + */ + defaults = xmlHashLookup2(ctxt->attsDefault, name, prefix); + if (defaults == NULL) { + defaults = (xmlDefAttrsPtr) xmlMalloc(sizeof(xmlDefAttrs) + + (4 * 5) * sizeof(const xmlChar *)); + if (defaults == NULL) + goto mem_error; + defaults->nbAttrs = 0; + defaults->maxAttrs = 4; + if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, + defaults, NULL) < 0) { + xmlFree(defaults); + goto mem_error; + } + } else if (defaults->nbAttrs >= defaults->maxAttrs) { + xmlDefAttrsPtr temp; + + temp = (xmlDefAttrsPtr) xmlRealloc(defaults, sizeof(xmlDefAttrs) + + (2 * defaults->maxAttrs * 5) * sizeof(const xmlChar *)); + if (temp == NULL) + goto mem_error; + defaults = temp; + defaults->maxAttrs *= 2; + if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, + defaults, NULL) < 0) { + xmlFree(defaults); + goto mem_error; + } + } + + /* + * Split the element name into prefix:localname , the string found + * are within the DTD and hen not associated to namespace names. + */ + name = xmlSplitQName3(fullattr, &len); + if (name == NULL) { + name = xmlDictLookup(ctxt->dict, fullattr, -1); + prefix = NULL; + } else { + name = xmlDictLookup(ctxt->dict, name, -1); + prefix = xmlDictLookup(ctxt->dict, fullattr, len); + } + + defaults->values[5 * defaults->nbAttrs] = name; + defaults->values[5 * defaults->nbAttrs + 1] = prefix; + /* intern the string and precompute the end */ + len = xmlStrlen(value); + value = xmlDictLookup(ctxt->dict, value, len); + defaults->values[5 * defaults->nbAttrs + 2] = value; + defaults->values[5 * defaults->nbAttrs + 3] = value + len; + if (ctxt->external) + defaults->values[5 * defaults->nbAttrs + 4] = BAD_CAST "external"; + else + defaults->values[5 * defaults->nbAttrs + 4] = NULL; + defaults->nbAttrs++; + + return; + +mem_error: + xmlErrMemory(ctxt, NULL); + return; +} + +/** + * xmlAddSpecialAttr: + * @ctxt: an XML parser context + * @fullname: the element fullname + * @fullattr: the attribute fullname + * @type: the attribute type + * + * Register this attribute type + */ +static void +xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, + const xmlChar *fullname, + const xmlChar *fullattr, + int type) +{ + if (ctxt->attsSpecial == NULL) { + ctxt->attsSpecial = xmlHashCreateDict(10, ctxt->dict); + if (ctxt->attsSpecial == NULL) + goto mem_error; + } + + if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL) + return; + + xmlHashAddEntry2(ctxt->attsSpecial, fullname, fullattr, + (void *) (ptrdiff_t) type); + return; + +mem_error: + xmlErrMemory(ctxt, NULL); + return; +} + +/** + * xmlCleanSpecialAttrCallback: + * + * Removes CDATA attributes from the special attribute table + */ +static void +xmlCleanSpecialAttrCallback(void *payload, void *data, + const xmlChar *fullname, const xmlChar *fullattr, + const xmlChar *unused ATTRIBUTE_UNUSED) { + xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) data; + + if (((ptrdiff_t) payload) == XML_ATTRIBUTE_CDATA) { + xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL); + } +} + +/** + * xmlCleanSpecialAttr: + * @ctxt: an XML parser context + * + * Trim the list of attributes defined to remove all those of type + * CDATA as they are not special. This call should be done when finishing + * to parse the DTD and before starting to parse the document root. + */ +static void +xmlCleanSpecialAttr(xmlParserCtxtPtr ctxt) +{ + if (ctxt->attsSpecial == NULL) + return; + + xmlHashScanFull(ctxt->attsSpecial, xmlCleanSpecialAttrCallback, ctxt); + + if (xmlHashSize(ctxt->attsSpecial) == 0) { + xmlHashFree(ctxt->attsSpecial, NULL); + ctxt->attsSpecial = NULL; + } + return; +} + +/** + * xmlCheckLanguageID: + * @lang: pointer to the string value + * + * Checks that the value conforms to the LanguageID production: + * + * NOTE: this is somewhat deprecated, those productions were removed from + * the XML Second edition. + * + * [33] LanguageID ::= Langcode ('-' Subcode)* + * [34] Langcode ::= ISO639Code | IanaCode | UserCode + * [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) + * [36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+ + * [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+ + * [38] Subcode ::= ([a-z] | [A-Z])+ + * + * The current REC reference the successors of RFC 1766, currently 5646 + * + * http://www.rfc-editor.org/rfc/rfc5646.txt + * langtag = language + * ["-" script] + * ["-" region] + * *("-" variant) + * *("-" extension) + * ["-" privateuse] + * language = 2*3ALPHA ; shortest ISO 639 code + * ["-" extlang] ; sometimes followed by + * ; extended language subtags + * / 4ALPHA ; or reserved for future use + * / 5*8ALPHA ; or registered language subtag + * + * extlang = 3ALPHA ; selected ISO 639 codes + * *2("-" 3ALPHA) ; permanently reserved + * + * script = 4ALPHA ; ISO 15924 code + * + * region = 2ALPHA ; ISO 3166-1 code + * / 3DIGIT ; UN M.49 code + * + * variant = 5*8alphanum ; registered variants + * / (DIGIT 3alphanum) + * + * extension = singleton 1*("-" (2*8alphanum)) + * + * ; Single alphanumerics + * ; "x" reserved for private use + * singleton = DIGIT ; 0 - 9 + * / %x41-57 ; A - W + * / %x59-5A ; Y - Z + * / %x61-77 ; a - w + * / %x79-7A ; y - z + * + * it sounds right to still allow Irregular i-xxx IANA and user codes too + * The parser below doesn't try to cope with extension or privateuse + * that could be added but that's not interoperable anyway + * + * Returns 1 if correct 0 otherwise + **/ +int +xmlCheckLanguageID(const xmlChar * lang) +{ + const xmlChar *cur = lang, *nxt; + + if (cur == NULL) + return (0); + if (((cur[0] == 'i') && (cur[1] == '-')) || + ((cur[0] == 'I') && (cur[1] == '-')) || + ((cur[0] == 'x') && (cur[1] == '-')) || + ((cur[0] == 'X') && (cur[1] == '-'))) { + /* + * Still allow IANA code and user code which were coming + * from the previous version of the XML-1.0 specification + * it's deprecated but we should not fail + */ + cur += 2; + while (((cur[0] >= 'A') && (cur[0] <= 'Z')) || + ((cur[0] >= 'a') && (cur[0] <= 'z'))) + cur++; + return(cur[0] == 0); + } + nxt = cur; + while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) || + ((nxt[0] >= 'a') && (nxt[0] <= 'z'))) + nxt++; + if (nxt - cur >= 4) { + /* + * Reserved + */ + if ((nxt - cur > 8) || (nxt[0] != 0)) + return(0); + return(1); + } + if (nxt - cur < 2) + return(0); + /* we got an ISO 639 code */ + if (nxt[0] == 0) + return(1); + if (nxt[0] != '-') + return(0); + + nxt++; + cur = nxt; + /* now we can have extlang or script or region or variant */ + if ((nxt[0] >= '0') && (nxt[0] <= '9')) + goto region_m49; + + while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) || + ((nxt[0] >= 'a') && (nxt[0] <= 'z'))) + nxt++; + if (nxt - cur == 4) + goto script; + if (nxt - cur == 2) + goto region; + if ((nxt - cur >= 5) && (nxt - cur <= 8)) + goto variant; + if (nxt - cur != 3) + return(0); + /* we parsed an extlang */ + if (nxt[0] == 0) + return(1); + if (nxt[0] != '-') + return(0); + + nxt++; + cur = nxt; + /* now we can have script or region or variant */ + if ((nxt[0] >= '0') && (nxt[0] <= '9')) + goto region_m49; + + while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) || + ((nxt[0] >= 'a') && (nxt[0] <= 'z'))) + nxt++; + if (nxt - cur == 2) + goto region; + if ((nxt - cur >= 5) && (nxt - cur <= 8)) + goto variant; + if (nxt - cur != 4) + return(0); + /* we parsed a script */ +script: + if (nxt[0] == 0) + return(1); + if (nxt[0] != '-') + return(0); + + nxt++; + cur = nxt; + /* now we can have region or variant */ + if ((nxt[0] >= '0') && (nxt[0] <= '9')) + goto region_m49; + + while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) || + ((nxt[0] >= 'a') && (nxt[0] <= 'z'))) + nxt++; + + if ((nxt - cur >= 5) && (nxt - cur <= 8)) + goto variant; + if (nxt - cur != 2) + return(0); + /* we parsed a region */ +region: + if (nxt[0] == 0) + return(1); + if (nxt[0] != '-') + return(0); + + nxt++; + cur = nxt; + /* now we can just have a variant */ + while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) || + ((nxt[0] >= 'a') && (nxt[0] <= 'z'))) + nxt++; + + if ((nxt - cur < 5) || (nxt - cur > 8)) + return(0); + + /* we parsed a variant */ +variant: + if (nxt[0] == 0) + return(1); + if (nxt[0] != '-') + return(0); + /* extensions and private use subtags not checked */ + return (1); + +region_m49: + if (((nxt[1] >= '0') && (nxt[1] <= '9')) && + ((nxt[2] >= '0') && (nxt[2] <= '9'))) { + nxt += 3; + goto region; + } + return(0); +} + +/************************************************************************ + * * + * Parser stacks related functions and macros * + * * + ************************************************************************/ + +static xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, + const xmlChar ** str); + +#ifdef SAX2 +/** + * nsPush: + * @ctxt: an XML parser context + * @prefix: the namespace prefix or NULL + * @URL: the namespace name + * + * Pushes a new parser namespace on top of the ns stack + * + * Returns -1 in case of error, -2 if the namespace should be discarded + * and the index in the stack otherwise. + */ +static int +nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL) +{ + if (ctxt->options & XML_PARSE_NSCLEAN) { + int i; + for (i = ctxt->nsNr - 2;i >= 0;i -= 2) { + if (ctxt->nsTab[i] == prefix) { + /* in scope */ + if (ctxt->nsTab[i + 1] == URL) + return(-2); + /* out of scope keep it */ + break; + } + } + } + if ((ctxt->nsMax == 0) || (ctxt->nsTab == NULL)) { + ctxt->nsMax = 10; + ctxt->nsNr = 0; + ctxt->nsTab = (const xmlChar **) + xmlMalloc(ctxt->nsMax * sizeof(xmlChar *)); + if (ctxt->nsTab == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->nsMax = 0; + return (-1); + } + } else if (ctxt->nsNr >= ctxt->nsMax) { + const xmlChar ** tmp; + ctxt->nsMax *= 2; + tmp = (const xmlChar **) xmlRealloc((char *) ctxt->nsTab, + ctxt->nsMax * sizeof(ctxt->nsTab[0])); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->nsMax /= 2; + return (-1); + } + ctxt->nsTab = tmp; + } + ctxt->nsTab[ctxt->nsNr++] = prefix; + ctxt->nsTab[ctxt->nsNr++] = URL; + return (ctxt->nsNr); +} +/** + * nsPop: + * @ctxt: an XML parser context + * @nr: the number to pop + * + * Pops the top @nr parser prefix/namespace from the ns stack + * + * Returns the number of namespaces removed + */ +static int +nsPop(xmlParserCtxtPtr ctxt, int nr) +{ + int i; + + if (ctxt->nsTab == NULL) return(0); + if (ctxt->nsNr < nr) { + xmlGenericError(xmlGenericErrorContext, "Pbm popping %d NS\n", nr); + nr = ctxt->nsNr; + } + if (ctxt->nsNr <= 0) + return (0); + + for (i = 0;i < nr;i++) { + ctxt->nsNr--; + ctxt->nsTab[ctxt->nsNr] = NULL; + } + return(nr); +} +#endif + +static int +xmlCtxtGrowAttrs(xmlParserCtxtPtr ctxt, int nr) { + const xmlChar **atts; + int *attallocs; + int maxatts; + + if (ctxt->atts == NULL) { + maxatts = 55; /* allow for 10 attrs by default */ + atts = (const xmlChar **) + xmlMalloc(maxatts * sizeof(xmlChar *)); + if (atts == NULL) goto mem_error; + ctxt->atts = atts; + attallocs = (int *) xmlMalloc((maxatts / 5) * sizeof(int)); + if (attallocs == NULL) goto mem_error; + ctxt->attallocs = attallocs; + ctxt->maxatts = maxatts; + } else if (nr + 5 > ctxt->maxatts) { + maxatts = (nr + 5) * 2; + atts = (const xmlChar **) xmlRealloc((void *) ctxt->atts, + maxatts * sizeof(const xmlChar *)); + if (atts == NULL) goto mem_error; + ctxt->atts = atts; + attallocs = (int *) xmlRealloc((void *) ctxt->attallocs, + (maxatts / 5) * sizeof(int)); + if (attallocs == NULL) goto mem_error; + ctxt->attallocs = attallocs; + ctxt->maxatts = maxatts; + } + return(ctxt->maxatts); +mem_error: + xmlErrMemory(ctxt, NULL); + return(-1); +} + +/** + * inputPush: + * @ctxt: an XML parser context + * @value: the parser input + * + * Pushes a new parser input on top of the input stack + * + * Returns -1 in case of error, the index in the stack otherwise + */ +int +inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value) +{ + if ((ctxt == NULL) || (value == NULL)) + return(-1); + if (ctxt->inputNr >= ctxt->inputMax) { + ctxt->inputMax *= 2; + ctxt->inputTab = + (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab, + ctxt->inputMax * + sizeof(ctxt->inputTab[0])); + if (ctxt->inputTab == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFreeInputStream(value); + ctxt->inputMax /= 2; + value = NULL; + return (-1); + } + } + ctxt->inputTab[ctxt->inputNr] = value; + ctxt->input = value; + return (ctxt->inputNr++); +} +/** + * inputPop: + * @ctxt: an XML parser context + * + * Pops the top parser input from the input stack + * + * Returns the input just removed + */ +xmlParserInputPtr +inputPop(xmlParserCtxtPtr ctxt) +{ + xmlParserInputPtr ret; + + if (ctxt == NULL) + return(NULL); + if (ctxt->inputNr <= 0) + return (NULL); + ctxt->inputNr--; + if (ctxt->inputNr > 0) + ctxt->input = ctxt->inputTab[ctxt->inputNr - 1]; + else + ctxt->input = NULL; + ret = ctxt->inputTab[ctxt->inputNr]; + ctxt->inputTab[ctxt->inputNr] = NULL; + return (ret); +} +/** + * nodePush: + * @ctxt: an XML parser context + * @value: the element node + * + * Pushes a new element node on top of the node stack + * + * Returns -1 in case of error, the index in the stack otherwise + */ +int +nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value) +{ + if (ctxt == NULL) return(0); + if (ctxt->nodeNr >= ctxt->nodeMax) { + xmlNodePtr *tmp; + + tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab, + ctxt->nodeMax * 2 * + sizeof(ctxt->nodeTab[0])); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + return (-1); + } + ctxt->nodeTab = tmp; + ctxt->nodeMax *= 2; + } + if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR, + "Excessive depth in document: %d use XML_PARSE_HUGE option\n", + xmlParserMaxDepth); + xmlHaltParser(ctxt); + return(-1); + } + ctxt->nodeTab[ctxt->nodeNr] = value; + ctxt->node = value; + return (ctxt->nodeNr++); +} + +/** + * nodePop: + * @ctxt: an XML parser context + * + * Pops the top element node from the node stack + * + * Returns the node just removed + */ +xmlNodePtr +nodePop(xmlParserCtxtPtr ctxt) +{ + xmlNodePtr ret; + + if (ctxt == NULL) return(NULL); + if (ctxt->nodeNr <= 0) + return (NULL); + ctxt->nodeNr--; + if (ctxt->nodeNr > 0) + ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1]; + else + ctxt->node = NULL; + ret = ctxt->nodeTab[ctxt->nodeNr]; + ctxt->nodeTab[ctxt->nodeNr] = NULL; + return (ret); +} + +/** + * nameNsPush: + * @ctxt: an XML parser context + * @value: the element name + * @prefix: the element prefix + * @URI: the element namespace name + * @line: the current line number for error messages + * @nsNr: the number of namespaces pushed on the namespace table + * + * Pushes a new element name/prefix/URL on top of the name stack + * + * Returns -1 in case of error, the index in the stack otherwise + */ +static int +nameNsPush(xmlParserCtxtPtr ctxt, const xmlChar * value, + const xmlChar *prefix, const xmlChar *URI, int line, int nsNr) +{ + xmlStartTag *tag; + + if (ctxt->nameNr >= ctxt->nameMax) { + const xmlChar * *tmp; + xmlStartTag *tmp2; + ctxt->nameMax *= 2; + tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab, + ctxt->nameMax * + sizeof(ctxt->nameTab[0])); + if (tmp == NULL) { + ctxt->nameMax /= 2; + goto mem_error; + } + ctxt->nameTab = tmp; + tmp2 = (xmlStartTag *) xmlRealloc((void * *)ctxt->pushTab, + ctxt->nameMax * + sizeof(ctxt->pushTab[0])); + if (tmp2 == NULL) { + ctxt->nameMax /= 2; + goto mem_error; + } + ctxt->pushTab = tmp2; + } else if (ctxt->pushTab == NULL) { + ctxt->pushTab = (xmlStartTag *) xmlMalloc(ctxt->nameMax * + sizeof(ctxt->pushTab[0])); + if (ctxt->pushTab == NULL) + goto mem_error; + } + ctxt->nameTab[ctxt->nameNr] = value; + ctxt->name = value; + tag = &ctxt->pushTab[ctxt->nameNr]; + tag->prefix = prefix; + tag->URI = URI; + tag->line = line; + tag->nsNr = nsNr; + return (ctxt->nameNr++); +mem_error: + xmlErrMemory(ctxt, NULL); + return (-1); +} +#ifdef LIBXML_PUSH_ENABLED +/** + * nameNsPop: + * @ctxt: an XML parser context + * + * Pops the top element/prefix/URI name from the name stack + * + * Returns the name just removed + */ +static const xmlChar * +nameNsPop(xmlParserCtxtPtr ctxt) +{ + const xmlChar *ret; + + if (ctxt->nameNr <= 0) + return (NULL); + ctxt->nameNr--; + if (ctxt->nameNr > 0) + ctxt->name = ctxt->nameTab[ctxt->nameNr - 1]; + else + ctxt->name = NULL; + ret = ctxt->nameTab[ctxt->nameNr]; + ctxt->nameTab[ctxt->nameNr] = NULL; + return (ret); +} +#endif /* LIBXML_PUSH_ENABLED */ + +/** + * namePush: + * @ctxt: an XML parser context + * @value: the element name + * + * Pushes a new element name on top of the name stack + * + * Returns -1 in case of error, the index in the stack otherwise + */ +int +namePush(xmlParserCtxtPtr ctxt, const xmlChar * value) +{ + if (ctxt == NULL) return (-1); + + if (ctxt->nameNr >= ctxt->nameMax) { + const xmlChar * *tmp; + tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab, + ctxt->nameMax * 2 * + sizeof(ctxt->nameTab[0])); + if (tmp == NULL) { + goto mem_error; + } + ctxt->nameTab = tmp; + ctxt->nameMax *= 2; + } + ctxt->nameTab[ctxt->nameNr] = value; + ctxt->name = value; + return (ctxt->nameNr++); +mem_error: + xmlErrMemory(ctxt, NULL); + return (-1); +} +/** + * namePop: + * @ctxt: an XML parser context + * + * Pops the top element name from the name stack + * + * Returns the name just removed + */ +const xmlChar * +namePop(xmlParserCtxtPtr ctxt) +{ + const xmlChar *ret; + + if ((ctxt == NULL) || (ctxt->nameNr <= 0)) + return (NULL); + ctxt->nameNr--; + if (ctxt->nameNr > 0) + ctxt->name = ctxt->nameTab[ctxt->nameNr - 1]; + else + ctxt->name = NULL; + ret = ctxt->nameTab[ctxt->nameNr]; + ctxt->nameTab[ctxt->nameNr] = NULL; + return (ret); +} + +static int spacePush(xmlParserCtxtPtr ctxt, int val) { + if (ctxt->spaceNr >= ctxt->spaceMax) { + int *tmp; + + ctxt->spaceMax *= 2; + tmp = (int *) xmlRealloc(ctxt->spaceTab, + ctxt->spaceMax * sizeof(ctxt->spaceTab[0])); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->spaceMax /=2; + return(-1); + } + ctxt->spaceTab = tmp; + } + ctxt->spaceTab[ctxt->spaceNr] = val; + ctxt->space = &ctxt->spaceTab[ctxt->spaceNr]; + return(ctxt->spaceNr++); +} + +static int spacePop(xmlParserCtxtPtr ctxt) { + int ret; + if (ctxt->spaceNr <= 0) return(0); + ctxt->spaceNr--; + if (ctxt->spaceNr > 0) + ctxt->space = &ctxt->spaceTab[ctxt->spaceNr - 1]; + else + ctxt->space = &ctxt->spaceTab[0]; + ret = ctxt->spaceTab[ctxt->spaceNr]; + ctxt->spaceTab[ctxt->spaceNr] = -1; + return(ret); +} + +/* + * Macros for accessing the content. Those should be used only by the parser, + * and not exported. + * + * Dirty macros, i.e. one often need to make assumption on the context to + * use them + * + * CUR_PTR return the current pointer to the xmlChar to be parsed. + * To be used with extreme caution since operations consuming + * characters may move the input buffer to a different location ! + * CUR returns the current xmlChar value, i.e. a 8 bit value if compiled + * This should be used internally by the parser + * only to compare to ASCII values otherwise it would break when + * running with UTF-8 encoding. + * RAW same as CUR but in the input buffer, bypass any token + * extraction that may have been done + * NXT(n) returns the n'th next xmlChar. Same as CUR is should be used only + * to compare on ASCII based substring. + * SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined + * strings without newlines within the parser. + * NEXT1(l) Skip 1 xmlChar, and must also be used only to skip 1 non-newline ASCII + * defined char within the parser. + * Clean macros, not dependent of an ASCII context, expect UTF-8 encoding + * + * NEXT Skip to the next character, this does the proper decoding + * in UTF-8 mode. It also pop-up unfinished entities on the fly. + * NEXTL(l) Skip the current unicode character of l xmlChars long. + * CUR_CHAR(l) returns the current unicode character (int), set l + * to the number of xmlChars used for the encoding [0-5]. + * CUR_SCHAR same but operate on a string instead of the context + * COPY_BUF copy the current unicode char to the target buffer, increment + * the index + * GROW, SHRINK handling of input buffers + */ + +#define RAW (*ctxt->input->cur) +#define CUR (*ctxt->input->cur) +#define NXT(val) ctxt->input->cur[(val)] +#define CUR_PTR ctxt->input->cur +#define BASE_PTR ctxt->input->base + +#define CMP4( s, c1, c2, c3, c4 ) \ + ( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \ + ((unsigned char *) s)[ 2 ] == c3 && ((unsigned char *) s)[ 3 ] == c4 ) +#define CMP5( s, c1, c2, c3, c4, c5 ) \ + ( CMP4( s, c1, c2, c3, c4 ) && ((unsigned char *) s)[ 4 ] == c5 ) +#define CMP6( s, c1, c2, c3, c4, c5, c6 ) \ + ( CMP5( s, c1, c2, c3, c4, c5 ) && ((unsigned char *) s)[ 5 ] == c6 ) +#define CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) \ + ( CMP6( s, c1, c2, c3, c4, c5, c6 ) && ((unsigned char *) s)[ 6 ] == c7 ) +#define CMP8( s, c1, c2, c3, c4, c5, c6, c7, c8 ) \ + ( CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) && ((unsigned char *) s)[ 7 ] == c8 ) +#define CMP9( s, c1, c2, c3, c4, c5, c6, c7, c8, c9 ) \ + ( CMP8( s, c1, c2, c3, c4, c5, c6, c7, c8 ) && \ + ((unsigned char *) s)[ 8 ] == c9 ) +#define CMP10( s, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 ) \ + ( CMP9( s, c1, c2, c3, c4, c5, c6, c7, c8, c9 ) && \ + ((unsigned char *) s)[ 9 ] == c10 ) + +#define SKIP(val) do { \ + ctxt->input->cur += (val),ctxt->input->col+=(val); \ + if (*ctxt->input->cur == 0) \ + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \ + } while (0) + +#define SKIPL(val) do { \ + int skipl; \ + for(skipl=0; skiplinput->cur) == '\n') { \ + ctxt->input->line++; ctxt->input->col = 1; \ + } else ctxt->input->col++; \ + ctxt->input->cur++; \ + } \ + if (*ctxt->input->cur == 0) \ + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \ + } while (0) + +#define SHRINK if ((ctxt->progressive == 0) && \ + (ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \ + (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \ + xmlSHRINK (ctxt); + +static void xmlSHRINK (xmlParserCtxtPtr ctxt) { + xmlParserInputShrink(ctxt->input); + if (*ctxt->input->cur == 0) + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); +} + +#define GROW if ((ctxt->progressive == 0) && \ + (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \ + xmlGROW (ctxt); + +static void xmlGROW (xmlParserCtxtPtr ctxt) { + ptrdiff_t curEnd = ctxt->input->end - ctxt->input->cur; + ptrdiff_t curBase = ctxt->input->cur - ctxt->input->base; + + if (((curEnd > XML_MAX_LOOKUP_LIMIT) || + (curBase > XML_MAX_LOOKUP_LIMIT)) && + ((ctxt->input->buf) && + (ctxt->input->buf->readcallback != xmlInputReadCallbackNop)) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup"); + xmlHaltParser(ctxt); + return; + } + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); + if ((ctxt->input->cur > ctxt->input->end) || + (ctxt->input->cur < ctxt->input->base)) { + xmlHaltParser(ctxt); + xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound"); + return; + } + if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0)) + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); +} + +#define SKIP_BLANKS xmlSkipBlankChars(ctxt) + +#define NEXT xmlNextChar(ctxt) + +#define NEXT1 { \ + ctxt->input->col++; \ + ctxt->input->cur++; \ + if (*ctxt->input->cur == 0) \ + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \ + } + +#define NEXTL(l) do { \ + if (*(ctxt->input->cur) == '\n') { \ + ctxt->input->line++; ctxt->input->col = 1; \ + } else ctxt->input->col++; \ + ctxt->input->cur += l; \ + } while (0) + +#define CUR_CHAR(l) xmlCurrentChar(ctxt, &l) +#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l) + +#define COPY_BUF(l,b,i,v) \ + if (l == 1) b[i++] = (xmlChar) v; \ + else i += xmlCopyCharMultiByte(&b[i],v) + +/** + * xmlSkipBlankChars: + * @ctxt: the XML parser context + * + * skip all blanks character found at that point in the input streams. + * It pops up finished entities in the process if allowable at that point. + * + * Returns the number of space chars skipped + */ + +int +xmlSkipBlankChars(xmlParserCtxtPtr ctxt) { + int res = 0; + + /* + * It's Okay to use CUR/NEXT here since all the blanks are on + * the ASCII range. + */ + if (ctxt->instate != XML_PARSER_DTD) { + const xmlChar *cur; + /* + * if we are in the document content, go really fast + */ + cur = ctxt->input->cur; + while (IS_BLANK_CH(*cur)) { + if (*cur == '\n') { + ctxt->input->line++; ctxt->input->col = 1; + } else { + ctxt->input->col++; + } + cur++; + res++; + if (*cur == 0) { + ctxt->input->cur = cur; + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); + cur = ctxt->input->cur; + } + } + ctxt->input->cur = cur; + } else { + int expandPE = ((ctxt->external != 0) || (ctxt->inputNr != 1)); + + while (1) { + if (IS_BLANK_CH(CUR)) { /* CHECKED tstblanks.xml */ + NEXT; + } else if (CUR == '%') { + /* + * Need to handle support of entities branching here + */ + if ((expandPE == 0) || (IS_BLANK_CH(NXT(1))) || (NXT(1) == 0)) + break; + xmlParsePEReference(ctxt); + } else if (CUR == 0) { + if (ctxt->inputNr <= 1) + break; + xmlPopInput(ctxt); + } else { + break; + } + + /* + * Also increase the counter when entering or exiting a PERef. + * The spec says: "When a parameter-entity reference is recognized + * in the DTD and included, its replacement text MUST be enlarged + * by the attachment of one leading and one following space (#x20) + * character." + */ + res++; + } + } + return(res); +} + +/************************************************************************ + * * + * Commodity functions to handle entities * + * * + ************************************************************************/ + +/** + * xmlPopInput: + * @ctxt: an XML parser context + * + * xmlPopInput: the current input pointed by ctxt->input came to an end + * pop it and return the next char. + * + * Returns the current xmlChar in the parser context + */ +xmlChar +xmlPopInput(xmlParserCtxtPtr ctxt) { + if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0); + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + "Popping input %d\n", ctxt->inputNr); + if ((ctxt->inputNr > 1) && (ctxt->inSubset == 0) && + (ctxt->instate != XML_PARSER_EOF)) + xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, + "Unfinished entity outside the DTD"); + xmlFreeInputStream(inputPop(ctxt)); + if (*ctxt->input->cur == 0) + xmlParserInputGrow(ctxt->input, INPUT_CHUNK); + return(CUR); +} + +/** + * xmlPushInput: + * @ctxt: an XML parser context + * @input: an XML parser input fragment (entity, XML fragment ...). + * + * xmlPushInput: switch to a new input stream which is stacked on top + * of the previous one(s). + * Returns -1 in case of error or the index in the input stack + */ +int +xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) { + int ret; + if (input == NULL) return(-1); + + if (xmlParserDebugEntities) { + if ((ctxt->input != NULL) && (ctxt->input->filename)) + xmlGenericError(xmlGenericErrorContext, + "%s(%d): ", ctxt->input->filename, + ctxt->input->line); + xmlGenericError(xmlGenericErrorContext, + "Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur); + } + if (((ctxt->inputNr > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) || + (ctxt->inputNr > 1024)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + while (ctxt->inputNr > 1) + xmlFreeInputStream(inputPop(ctxt)); + return(-1); + } + ret = inputPush(ctxt, input); + if (ctxt->instate == XML_PARSER_EOF) + return(-1); + GROW; + return(ret); +} + +/** + * xmlParseCharRef: + * @ctxt: an XML parser context + * + * parse Reference declarations + * + * [66] CharRef ::= '&#' [0-9]+ ';' | + * '&#x' [0-9a-fA-F]+ ';' + * + * [ WFC: Legal Character ] + * Characters referred to using character references must match the + * production for Char. + * + * Returns the value parsed (as an int), 0 in case of error + */ +int +xmlParseCharRef(xmlParserCtxtPtr ctxt) { + int val = 0; + int count = 0; + + /* + * Using RAW/CUR/NEXT is okay since we are working on ASCII range here + */ + if ((RAW == '&') && (NXT(1) == '#') && + (NXT(2) == 'x')) { + SKIP(3); + GROW; + while (RAW != ';') { /* loop blocked by count */ + if (count++ > 20) { + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 16 + (CUR - '0'); + else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20)) + val = val * 16 + (CUR - 'a') + 10; + else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20)) + val = val * 16 + (CUR - 'A') + 10; + else { + xmlFatalErr(ctxt, XML_ERR_INVALID_HEX_CHARREF, NULL); + val = 0; + break; + } + if (val > 0x110000) + val = 0x110000; + + NEXT; + count++; + } + if (RAW == ';') { + /* on purpose to avoid reentrancy problems with NEXT and SKIP */ + ctxt->input->col++; + ctxt->input->cur++; + } + } else if ((RAW == '&') && (NXT(1) == '#')) { + SKIP(2); + GROW; + while (RAW != ';') { /* loop blocked by count */ + if (count++ > 20) { + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 10 + (CUR - '0'); + else { + xmlFatalErr(ctxt, XML_ERR_INVALID_DEC_CHARREF, NULL); + val = 0; + break; + } + if (val > 0x110000) + val = 0x110000; + + NEXT; + count++; + } + if (RAW == ';') { + /* on purpose to avoid reentrancy problems with NEXT and SKIP */ + ctxt->input->col++; + ctxt->input->cur++; + } + } else { + xmlFatalErr(ctxt, XML_ERR_INVALID_CHARREF, NULL); + } + + /* + * [ WFC: Legal Character ] + * Characters referred to using character references must match the + * production for Char. + */ + if (val >= 0x110000) { + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "xmlParseCharRef: character reference out of bounds\n", + val); + } else if (IS_CHAR(val)) { + return(val); + } else { + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "xmlParseCharRef: invalid xmlChar value %d\n", + val); + } + return(0); +} + +/** + * xmlParseStringCharRef: + * @ctxt: an XML parser context + * @str: a pointer to an index in the string + * + * parse Reference declarations, variant parsing from a string rather + * than an an input flow. + * + * [66] CharRef ::= '&#' [0-9]+ ';' | + * '&#x' [0-9a-fA-F]+ ';' + * + * [ WFC: Legal Character ] + * Characters referred to using character references must match the + * production for Char. + * + * Returns the value parsed (as an int), 0 in case of error, str will be + * updated to the current value of the index + */ +static int +xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) { + const xmlChar *ptr; + xmlChar cur; + int val = 0; + + if ((str == NULL) || (*str == NULL)) return(0); + ptr = *str; + cur = *ptr; + if ((cur == '&') && (ptr[1] == '#') && (ptr[2] == 'x')) { + ptr += 3; + cur = *ptr; + while (cur != ';') { /* Non input consuming loop */ + if ((cur >= '0') && (cur <= '9')) + val = val * 16 + (cur - '0'); + else if ((cur >= 'a') && (cur <= 'f')) + val = val * 16 + (cur - 'a') + 10; + else if ((cur >= 'A') && (cur <= 'F')) + val = val * 16 + (cur - 'A') + 10; + else { + xmlFatalErr(ctxt, XML_ERR_INVALID_HEX_CHARREF, NULL); + val = 0; + break; + } + if (val > 0x110000) + val = 0x110000; + + ptr++; + cur = *ptr; + } + if (cur == ';') + ptr++; + } else if ((cur == '&') && (ptr[1] == '#')){ + ptr += 2; + cur = *ptr; + while (cur != ';') { /* Non input consuming loops */ + if ((cur >= '0') && (cur <= '9')) + val = val * 10 + (cur - '0'); + else { + xmlFatalErr(ctxt, XML_ERR_INVALID_DEC_CHARREF, NULL); + val = 0; + break; + } + if (val > 0x110000) + val = 0x110000; + + ptr++; + cur = *ptr; + } + if (cur == ';') + ptr++; + } else { + xmlFatalErr(ctxt, XML_ERR_INVALID_CHARREF, NULL); + return(0); + } + *str = ptr; + + /* + * [ WFC: Legal Character ] + * Characters referred to using character references must match the + * production for Char. + */ + if (val >= 0x110000) { + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "xmlParseStringCharRef: character reference out of bounds\n", + val); + } else if (IS_CHAR(val)) { + return(val); + } else { + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "xmlParseStringCharRef: invalid xmlChar value %d\n", + val); + } + return(0); +} + +/** + * xmlParserHandlePEReference: + * @ctxt: the parser context + * + * [69] PEReference ::= '%' Name ';' + * + * [ WFC: No Recursion ] + * A parsed entity must not contain a recursive + * reference to itself, either directly or indirectly. + * + * [ WFC: Entity Declared ] + * In a document without any DTD, a document with only an internal DTD + * subset which contains no parameter entity references, or a document + * with "standalone='yes'", ... ... The declaration of a parameter + * entity must precede any reference to it... + * + * [ VC: Entity Declared ] + * In a document with an external subset or external parameter entities + * with "standalone='no'", ... ... The declaration of a parameter entity + * must precede any reference to it... + * + * [ WFC: In DTD ] + * Parameter-entity references may only appear in the DTD. + * NOTE: misleading but this is handled. + * + * A PEReference may have been detected in the current input stream + * the handling is done accordingly to + * http://www.w3.org/TR/REC-xml#entproc + * i.e. + * - Included in literal in entity values + * - Included as Parameter Entity reference within DTDs + */ +void +xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + switch(ctxt->instate) { + case XML_PARSER_CDATA_SECTION: + return; + case XML_PARSER_COMMENT: + return; + case XML_PARSER_START_TAG: + return; + case XML_PARSER_END_TAG: + return; + case XML_PARSER_EOF: + xmlFatalErr(ctxt, XML_ERR_PEREF_AT_EOF, NULL); + return; + case XML_PARSER_PROLOG: + case XML_PARSER_START: + case XML_PARSER_MISC: + xmlFatalErr(ctxt, XML_ERR_PEREF_IN_PROLOG, NULL); + return; + case XML_PARSER_ENTITY_DECL: + case XML_PARSER_CONTENT: + case XML_PARSER_ATTRIBUTE_VALUE: + case XML_PARSER_PI: + case XML_PARSER_SYSTEM_LITERAL: + case XML_PARSER_PUBLIC_LITERAL: + /* we just ignore it there */ + return; + case XML_PARSER_EPILOG: + xmlFatalErr(ctxt, XML_ERR_PEREF_IN_EPILOG, NULL); + return; + case XML_PARSER_ENTITY_VALUE: + /* + * NOTE: in the case of entity values, we don't do the + * substitution here since we need the literal + * entity value to be able to save the internal + * subset of the document. + * This will be handled by xmlStringDecodeEntities + */ + return; + case XML_PARSER_DTD: + /* + * [WFC: Well-Formedness Constraint: PEs in Internal Subset] + * In the internal DTD subset, parameter-entity references + * can occur only where markup declarations can occur, not + * within markup declarations. + * In that case this is handled in xmlParseMarkupDecl + */ + if ((ctxt->external == 0) && (ctxt->inputNr == 1)) + return; + if (IS_BLANK_CH(NXT(1)) || NXT(1) == 0) + return; + break; + case XML_PARSER_IGNORE: + return; + } + + xmlParsePEReference(ctxt); +} + +/* + * Macro used to grow the current buffer. + * buffer##_size is expected to be a size_t + * mem_error: is expected to handle memory allocation failures + */ +#define growBuffer(buffer, n) { \ + xmlChar *tmp; \ + size_t new_size = buffer##_size * 2 + n; \ + if (new_size < buffer##_size) goto mem_error; \ + tmp = (xmlChar *) xmlRealloc(buffer, new_size); \ + if (tmp == NULL) goto mem_error; \ + buffer = tmp; \ + buffer##_size = new_size; \ +} + +/** + * xmlStringLenDecodeEntities: + * @ctxt: the parser context + * @str: the input string + * @len: the string length + * @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF + * @end: an end marker xmlChar, 0 if none + * @end2: an end marker xmlChar, 0 if none + * @end3: an end marker xmlChar, 0 if none + * + * Takes a entity string content and process to do the adequate substitutions. + * + * [67] Reference ::= EntityRef | CharRef + * + * [69] PEReference ::= '%' Name ';' + * + * Returns A newly allocated string with the substitution done. The caller + * must deallocate it ! + */ +xmlChar * +xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, + int what, xmlChar end, xmlChar end2, xmlChar end3) { + xmlChar *buffer = NULL; + size_t buffer_size = 0; + size_t nbchars = 0; + + xmlChar *current = NULL; + xmlChar *rep = NULL; + const xmlChar *last; + xmlEntityPtr ent; + int c,l; + + if ((ctxt == NULL) || (str == NULL) || (len < 0)) + return(NULL); + last = str + len; + + if (((ctxt->depth > 40) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) || + (ctxt->depth > 1024)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return(NULL); + } + + /* + * allocate a translation buffer. + */ + buffer_size = XML_PARSER_BIG_BUFFER_SIZE; + buffer = (xmlChar *) xmlMallocAtomic(buffer_size); + if (buffer == NULL) goto mem_error; + + /* + * OK loop until we reach one of the ending char or a size limit. + * we are operating on already parsed values. + */ + if (str < last) + c = CUR_SCHAR(str, l); + else + c = 0; + while ((c != 0) && (c != end) && /* non input consuming loop */ + (c != end2) && (c != end3) && + (ctxt->instate != XML_PARSER_EOF)) { + + if (c == 0) break; + if ((c == '&') && (str[1] == '#')) { + int val = xmlParseStringCharRef(ctxt, &str); + if (val == 0) + goto int_error; + COPY_BUF(0,buffer,nbchars,val); + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) { + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + "String decoding Entity Reference: %.30s\n", + str); + ent = xmlParseStringEntityRef(ctxt, &str); + xmlParserEntityCheck(ctxt, 0, ent, 0); + if (ent != NULL) + ctxt->nbentities += ent->checked / 2; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (ent->content != NULL) { + COPY_BUF(0,buffer,nbchars,ent->content[0]); + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else { + xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, + "predefined entity has no content\n"); + goto int_error; + } + } else if ((ent != NULL) && (ent->content != NULL)) { + ctxt->depth++; + rep = xmlStringDecodeEntities(ctxt, ent->content, what, + 0, 0, 0); + ctxt->depth--; + if (rep == NULL) { + ent->content[0] = 0; + goto int_error; + } + + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + xmlFree(rep); + rep = NULL; + } else if (ent != NULL) { + int i = xmlStrlen(ent->name); + const xmlChar *cur = ent->name; + + buffer[nbchars++] = '&'; + if (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE); + } + for (;i > 0;i--) + buffer[nbchars++] = *cur++; + buffer[nbchars++] = ';'; + } + } else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) { + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + "String decoding PE Reference: %.30s\n", str); + ent = xmlParseStringPEReference(ctxt, &str); + xmlParserEntityCheck(ctxt, 0, ent, 0); + if (ent != NULL) + ctxt->nbentities += ent->checked / 2; + if (ent != NULL) { + if (ent->content == NULL) { + /* + * Note: external parsed entities will not be loaded, + * it is not required for a non-validating parser to + * complete external PEReferences coming from the + * internal subset + */ + if (((ctxt->options & XML_PARSE_NOENT) != 0) || + ((ctxt->options & XML_PARSE_DTDVALID) != 0) || + (ctxt->validate != 0)) { + xmlLoadEntityContent(ctxt, ent); + } else { + xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING, + "not validating will not read content for PE entity %s\n", + ent->name, NULL); + } + } + ctxt->depth++; + rep = xmlStringDecodeEntities(ctxt, ent->content, what, + 0, 0, 0); + ctxt->depth--; + if (rep == NULL) { + if (ent->content != NULL) + ent->content[0] = 0; + goto int_error; + } + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + xmlFree(rep); + rep = NULL; + } + } else { + COPY_BUF(l,buffer,nbchars,c); + str += l; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + if (str < last) + c = CUR_SCHAR(str, l); + else + c = 0; + } + buffer[nbchars] = 0; + return(buffer); + +mem_error: + xmlErrMemory(ctxt, NULL); +int_error: + if (rep != NULL) + xmlFree(rep); + if (buffer != NULL) + xmlFree(buffer); + return(NULL); +} + +/** + * xmlStringDecodeEntities: + * @ctxt: the parser context + * @str: the input string + * @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF + * @end: an end marker xmlChar, 0 if none + * @end2: an end marker xmlChar, 0 if none + * @end3: an end marker xmlChar, 0 if none + * + * Takes a entity string content and process to do the adequate substitutions. + * + * [67] Reference ::= EntityRef | CharRef + * + * [69] PEReference ::= '%' Name ';' + * + * Returns A newly allocated string with the substitution done. The caller + * must deallocate it ! + */ +xmlChar * +xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what, + xmlChar end, xmlChar end2, xmlChar end3) { + if ((ctxt == NULL) || (str == NULL)) return(NULL); + return(xmlStringLenDecodeEntities(ctxt, str, xmlStrlen(str), what, + end, end2, end3)); +} + +/************************************************************************ + * * + * Commodity functions, cleanup needed ? * + * * + ************************************************************************/ + +/** + * areBlanks: + * @ctxt: an XML parser context + * @str: a xmlChar * + * @len: the size of @str + * @blank_chars: we know the chars are blanks + * + * Is this a sequence of blank chars that one can ignore ? + * + * Returns 1 if ignorable 0 otherwise. + */ + +static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, + int blank_chars) { + int i, ret; + xmlNodePtr lastChild; + + /* + * Don't spend time trying to differentiate them, the same callback is + * used ! + */ + if (ctxt->sax->ignorableWhitespace == ctxt->sax->characters) + return(0); + + /* + * Check for xml:space value. + */ + if ((ctxt->space == NULL) || (*(ctxt->space) == 1) || + (*(ctxt->space) == -2)) + return(0); + + /* + * Check that the string is made of blanks + */ + if (blank_chars == 0) { + for (i = 0;i < len;i++) + if (!(IS_BLANK_CH(str[i]))) return(0); + } + + /* + * Look if the element is mixed content in the DTD if available + */ + if (ctxt->node == NULL) return(0); + if (ctxt->myDoc != NULL) { + ret = xmlIsMixedElement(ctxt->myDoc, ctxt->node->name); + if (ret == 0) return(1); + if (ret == 1) return(0); + } + + /* + * Otherwise, heuristic :-\ + */ + if ((RAW != '<') && (RAW != 0xD)) return(0); + if ((ctxt->node->children == NULL) && + (RAW == '<') && (NXT(1) == '/')) return(0); + + lastChild = xmlGetLastChild(ctxt->node); + if (lastChild == NULL) { + if ((ctxt->node->type != XML_ELEMENT_NODE) && + (ctxt->node->content != NULL)) return(0); + } else if (xmlNodeIsText(lastChild)) + return(0); + else if ((ctxt->node->children != NULL) && + (xmlNodeIsText(ctxt->node->children))) + return(0); + return(1); +} + +/************************************************************************ + * * + * Extra stuff for namespace support * + * Relates to http://www.w3.org/TR/WD-xml-names * + * * + ************************************************************************/ + +/** + * xmlSplitQName: + * @ctxt: an XML parser context + * @name: an XML parser context + * @prefix: a xmlChar ** + * + * parse an UTF8 encoded XML qualified name string + * + * [NS 5] QName ::= (Prefix ':')? LocalPart + * + * [NS 6] Prefix ::= NCName + * + * [NS 7] LocalPart ::= NCName + * + * Returns the local part, and prefix is updated + * to get the Prefix if any. + */ + +xmlChar * +xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { + xmlChar buf[XML_MAX_NAMELEN + 5]; + xmlChar *buffer = NULL; + int len = 0; + int max = XML_MAX_NAMELEN; + xmlChar *ret = NULL; + const xmlChar *cur = name; + int c; + + if (prefix == NULL) return(NULL); + *prefix = NULL; + + if (cur == NULL) return(NULL); + +#ifndef XML_XML_NAMESPACE + /* xml: prefix is not really a namespace */ + if ((cur[0] == 'x') && (cur[1] == 'm') && + (cur[2] == 'l') && (cur[3] == ':')) + return(xmlStrdup(name)); +#endif + + /* nasty but well=formed */ + if (cur[0] == ':') + return(xmlStrdup(name)); + + c = *cur++; + while ((c != 0) && (c != ':') && (len < max)) { /* tested bigname.xml */ + buf[len++] = c; + c = *cur++; + } + if (len >= max) { + /* + * Okay someone managed to make a huge name, so he's ready to pay + * for the processing speed. + */ + max = len * 2; + + buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + if (buffer == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + memcpy(buffer, buf, len); + while ((c != 0) && (c != ':')) { /* tested bigname.xml */ + if (len + 10 > max) { + xmlChar *tmp; + + max *= 2; + tmp = (xmlChar *) xmlRealloc(buffer, + max * sizeof(xmlChar)); + if (tmp == NULL) { + xmlFree(buffer); + xmlErrMemory(ctxt, NULL); + return(NULL); + } + buffer = tmp; + } + buffer[len++] = c; + c = *cur++; + } + buffer[len] = 0; + } + + if ((c == ':') && (*cur == 0)) { + if (buffer != NULL) + xmlFree(buffer); + *prefix = NULL; + return(xmlStrdup(name)); + } + + if (buffer == NULL) + ret = xmlStrndup(buf, len); + else { + ret = buffer; + buffer = NULL; + max = XML_MAX_NAMELEN; + } + + + if (c == ':') { + c = *cur; + *prefix = ret; + if (c == 0) { + return(xmlStrndup(BAD_CAST "", 0)); + } + len = 0; + + /* + * Check that the first character is proper to start + * a new name + */ + if (!(((c >= 0x61) && (c <= 0x7A)) || + ((c >= 0x41) && (c <= 0x5A)) || + (c == '_') || (c == ':'))) { + int l; + int first = CUR_SCHAR(cur, l); + + if (!IS_LETTER(first) && (first != '_')) { + xmlFatalErrMsgStr(ctxt, XML_NS_ERR_QNAME, + "Name %s is not XML Namespace compliant\n", + name); + } + } + cur++; + + while ((c != 0) && (len < max)) { /* tested bigname2.xml */ + buf[len++] = c; + c = *cur++; + } + if (len >= max) { + /* + * Okay someone managed to make a huge name, so he's ready to pay + * for the processing speed. + */ + max = len * 2; + + buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + if (buffer == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + memcpy(buffer, buf, len); + while (c != 0) { /* tested bigname2.xml */ + if (len + 10 > max) { + xmlChar *tmp; + + max *= 2; + tmp = (xmlChar *) xmlRealloc(buffer, + max * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buffer); + return(NULL); + } + buffer = tmp; + } + buffer[len++] = c; + c = *cur++; + } + buffer[len] = 0; + } + + if (buffer == NULL) + ret = xmlStrndup(buf, len); + else { + ret = buffer; + } + } + + return(ret); +} + +/************************************************************************ + * * + * The parser itself * + * Relates to http://www.w3.org/TR/REC-xml * + * * + ************************************************************************/ + +/************************************************************************ + * * + * Routines to parse Name, NCName and NmToken * + * * + ************************************************************************/ +#ifdef DEBUG +static unsigned long nbParseName = 0; +static unsigned long nbParseNmToken = 0; +static unsigned long nbParseNCName = 0; +static unsigned long nbParseNCNameComplex = 0; +static unsigned long nbParseNameComplex = 0; +static unsigned long nbParseStringName = 0; +#endif + +/* + * The two following functions are related to the change of accepted + * characters for Name and NmToken in the Revision 5 of XML-1.0 + * They correspond to the modified production [4] and the new production [4a] + * changes in that revision. Also note that the macros used for the + * productions Letter, Digit, CombiningChar and Extender are not needed + * anymore. + * We still keep compatibility to pre-revision5 parsing semantic if the + * new XML_PARSE_OLD10 option is given to the parser. + */ +static int +xmlIsNameStartChar(xmlParserCtxtPtr ctxt, int c) { + if ((ctxt->options & XML_PARSE_OLD10) == 0) { + /* + * Use the new checks of production [4] [4a] amd [5] of the + * Update 5 of XML-1.0 + */ + if ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */ + (((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + (c == '_') || (c == ':') || + ((c >= 0xC0) && (c <= 0xD6)) || + ((c >= 0xD8) && (c <= 0xF6)) || + ((c >= 0xF8) && (c <= 0x2FF)) || + ((c >= 0x370) && (c <= 0x37D)) || + ((c >= 0x37F) && (c <= 0x1FFF)) || + ((c >= 0x200C) && (c <= 0x200D)) || + ((c >= 0x2070) && (c <= 0x218F)) || + ((c >= 0x2C00) && (c <= 0x2FEF)) || + ((c >= 0x3001) && (c <= 0xD7FF)) || + ((c >= 0xF900) && (c <= 0xFDCF)) || + ((c >= 0xFDF0) && (c <= 0xFFFD)) || + ((c >= 0x10000) && (c <= 0xEFFFF)))) + return(1); + } else { + if (IS_LETTER(c) || (c == '_') || (c == ':')) + return(1); + } + return(0); +} + +static int +xmlIsNameChar(xmlParserCtxtPtr ctxt, int c) { + if ((ctxt->options & XML_PARSE_OLD10) == 0) { + /* + * Use the new checks of production [4] [4a] amd [5] of the + * Update 5 of XML-1.0 + */ + if ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */ + (((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + ((c >= '0') && (c <= '9')) || /* !start */ + (c == '_') || (c == ':') || + (c == '-') || (c == '.') || (c == 0xB7) || /* !start */ + ((c >= 0xC0) && (c <= 0xD6)) || + ((c >= 0xD8) && (c <= 0xF6)) || + ((c >= 0xF8) && (c <= 0x2FF)) || + ((c >= 0x300) && (c <= 0x36F)) || /* !start */ + ((c >= 0x370) && (c <= 0x37D)) || + ((c >= 0x37F) && (c <= 0x1FFF)) || + ((c >= 0x200C) && (c <= 0x200D)) || + ((c >= 0x203F) && (c <= 0x2040)) || /* !start */ + ((c >= 0x2070) && (c <= 0x218F)) || + ((c >= 0x2C00) && (c <= 0x2FEF)) || + ((c >= 0x3001) && (c <= 0xD7FF)) || + ((c >= 0xF900) && (c <= 0xFDCF)) || + ((c >= 0xFDF0) && (c <= 0xFFFD)) || + ((c >= 0x10000) && (c <= 0xEFFFF)))) + return(1); + } else { + if ((IS_LETTER(c)) || (IS_DIGIT(c)) || + (c == '.') || (c == '-') || + (c == '_') || (c == ':') || + (IS_COMBINING(c)) || + (IS_EXTENDER(c))) + return(1); + } + return(0); +} + +static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, + int *len, int *alloc, int normalize); + +static const xmlChar * +xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + int len = 0, l; + int c; + int count = 0; + +#ifdef DEBUG + nbParseNameComplex++; +#endif + + /* + * Handler for more complex cases + */ + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + c = CUR_CHAR(l); + if ((ctxt->options & XML_PARSE_OLD10) == 0) { + /* + * Use the new checks of production [4] [4a] amd [5] of the + * Update 5 of XML-1.0 + */ + if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ + (!(((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + (c == '_') || (c == ':') || + ((c >= 0xC0) && (c <= 0xD6)) || + ((c >= 0xD8) && (c <= 0xF6)) || + ((c >= 0xF8) && (c <= 0x2FF)) || + ((c >= 0x370) && (c <= 0x37D)) || + ((c >= 0x37F) && (c <= 0x1FFF)) || + ((c >= 0x200C) && (c <= 0x200D)) || + ((c >= 0x2070) && (c <= 0x218F)) || + ((c >= 0x2C00) && (c <= 0x2FEF)) || + ((c >= 0x3001) && (c <= 0xD7FF)) || + ((c >= 0xF900) && (c <= 0xFDCF)) || + ((c >= 0xFDF0) && (c <= 0xFFFD)) || + ((c >= 0x10000) && (c <= 0xEFFFF))))) { + return(NULL); + } + len += l; + NEXTL(l); + c = CUR_CHAR(l); + while ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */ + (((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + ((c >= '0') && (c <= '9')) || /* !start */ + (c == '_') || (c == ':') || + (c == '-') || (c == '.') || (c == 0xB7) || /* !start */ + ((c >= 0xC0) && (c <= 0xD6)) || + ((c >= 0xD8) && (c <= 0xF6)) || + ((c >= 0xF8) && (c <= 0x2FF)) || + ((c >= 0x300) && (c <= 0x36F)) || /* !start */ + ((c >= 0x370) && (c <= 0x37D)) || + ((c >= 0x37F) && (c <= 0x1FFF)) || + ((c >= 0x200C) && (c <= 0x200D)) || + ((c >= 0x203F) && (c <= 0x2040)) || /* !start */ + ((c >= 0x2070) && (c <= 0x218F)) || + ((c >= 0x2C00) && (c <= 0x2FEF)) || + ((c >= 0x3001) && (c <= 0xD7FF)) || + ((c >= 0xF900) && (c <= 0xFDCF)) || + ((c >= 0xFDF0) && (c <= 0xFFFD)) || + ((c >= 0x10000) && (c <= 0xEFFFF)) + )) { + if (count++ > XML_PARSER_CHUNK_SIZE) { + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + } + len += l; + NEXTL(l); + c = CUR_CHAR(l); + } + } else { + if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ + (!IS_LETTER(c) && (c != '_') && + (c != ':'))) { + return(NULL); + } + len += l; + NEXTL(l); + c = CUR_CHAR(l); + + while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */ + ((IS_LETTER(c)) || (IS_DIGIT(c)) || + (c == '.') || (c == '-') || + (c == '_') || (c == ':') || + (IS_COMBINING(c)) || + (IS_EXTENDER(c)))) { + if (count++ > XML_PARSER_CHUNK_SIZE) { + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + } + len += l; + NEXTL(l); + c = CUR_CHAR(l); + } + } + if ((len > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name"); + return(NULL); + } + if (ctxt->input->cur - ctxt->input->base < len) { + /* + * There were a couple of bugs where PERefs lead to to a change + * of the buffer. Check the buffer size to avoid passing an invalid + * pointer to xmlDictLookup. + */ + xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, + "unexpected change of input buffer"); + return (NULL); + } + if ((*ctxt->input->cur == '\n') && (ctxt->input->cur[-1] == '\r')) + return(xmlDictLookup(ctxt->dict, ctxt->input->cur - (len + 1), len)); + return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len)); +} + +/** + * xmlParseName: + * @ctxt: an XML parser context + * + * parse an XML name. + * + * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | + * CombiningChar | Extender + * + * [5] Name ::= (Letter | '_' | ':') (NameChar)* + * + * [6] Names ::= Name (#x20 Name)* + * + * Returns the Name parsed or NULL + */ + +const xmlChar * +xmlParseName(xmlParserCtxtPtr ctxt) { + const xmlChar *in; + const xmlChar *ret; + int count = 0; + + GROW; + +#ifdef DEBUG + nbParseName++; +#endif + + /* + * Accelerator for simple ASCII names + */ + in = ctxt->input->cur; + if (((*in >= 0x61) && (*in <= 0x7A)) || + ((*in >= 0x41) && (*in <= 0x5A)) || + (*in == '_') || (*in == ':')) { + in++; + while (((*in >= 0x61) && (*in <= 0x7A)) || + ((*in >= 0x41) && (*in <= 0x5A)) || + ((*in >= 0x30) && (*in <= 0x39)) || + (*in == '_') || (*in == '-') || + (*in == ':') || (*in == '.')) + in++; + if ((*in > 0) && (*in < 0x80)) { + count = in - ctxt->input->cur; + if ((count > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name"); + return(NULL); + } + ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); + ctxt->input->cur = in; + ctxt->input->col += count; + if (ret == NULL) + xmlErrMemory(ctxt, NULL); + return(ret); + } + } + /* accelerator for special cases */ + return(xmlParseNameComplex(ctxt)); +} + +static const xmlChar * +xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { + int len = 0, l; + int c; + int count = 0; + size_t startPosition = 0; + +#ifdef DEBUG + nbParseNCNameComplex++; +#endif + + /* + * Handler for more complex cases + */ + GROW; + startPosition = CUR_PTR - BASE_PTR; + c = CUR_CHAR(l); + if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ + (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) { + return(NULL); + } + + while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */ + (xmlIsNameChar(ctxt, c) && (c != ':'))) { + if (count++ > XML_PARSER_CHUNK_SIZE) { + if ((len > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); + return(NULL); + } + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + } + len += l; + NEXTL(l); + c = CUR_CHAR(l); + if (c == 0) { + count = 0; + /* + * when shrinking to extend the buffer we really need to preserve + * the part of the name we already parsed. Hence rolling back + * by current length. + */ + ctxt->input->cur -= l; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + ctxt->input->cur += l; + c = CUR_CHAR(l); + } + } + if ((len > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); + return(NULL); + } + return(xmlDictLookup(ctxt->dict, (BASE_PTR + startPosition), len)); +} + +/** + * xmlParseNCName: + * @ctxt: an XML parser context + * @len: length of the string parsed + * + * parse an XML name. + * + * [4NS] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | + * CombiningChar | Extender + * + * [5NS] NCName ::= (Letter | '_') (NCNameChar)* + * + * Returns the Name parsed or NULL + */ + +static const xmlChar * +xmlParseNCName(xmlParserCtxtPtr ctxt) { + const xmlChar *in, *e; + const xmlChar *ret; + int count = 0; + +#ifdef DEBUG + nbParseNCName++; +#endif + + /* + * Accelerator for simple ASCII names + */ + in = ctxt->input->cur; + e = ctxt->input->end; + if ((((*in >= 0x61) && (*in <= 0x7A)) || + ((*in >= 0x41) && (*in <= 0x5A)) || + (*in == '_')) && (in < e)) { + in++; + while ((((*in >= 0x61) && (*in <= 0x7A)) || + ((*in >= 0x41) && (*in <= 0x5A)) || + ((*in >= 0x30) && (*in <= 0x39)) || + (*in == '_') || (*in == '-') || + (*in == '.')) && (in < e)) + in++; + if (in >= e) + goto complex; + if ((*in > 0) && (*in < 0x80)) { + count = in - ctxt->input->cur; + if ((count > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); + return(NULL); + } + ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); + ctxt->input->cur = in; + ctxt->input->col += count; + if (ret == NULL) { + xmlErrMemory(ctxt, NULL); + } + return(ret); + } + } +complex: + return(xmlParseNCNameComplex(ctxt)); +} + +/** + * xmlParseNameAndCompare: + * @ctxt: an XML parser context + * + * parse an XML name and compares for match + * (specialized for endtag parsing) + * + * Returns NULL for an illegal name, (xmlChar*) 1 for success + * and the name for mismatch + */ + +static const xmlChar * +xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) { + register const xmlChar *cmp = other; + register const xmlChar *in; + const xmlChar *ret; + + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + + in = ctxt->input->cur; + while (*in != 0 && *in == *cmp) { + ++in; + ++cmp; + } + if (*cmp == 0 && (*in == '>' || IS_BLANK_CH (*in))) { + /* success */ + ctxt->input->col += in - ctxt->input->cur; + ctxt->input->cur = in; + return (const xmlChar*) 1; + } + /* failure (or end of input buffer), check with full function */ + ret = xmlParseName (ctxt); + /* strings coming from the dictionary direct compare possible */ + if (ret == other) { + return (const xmlChar*) 1; + } + return ret; +} + +/** + * xmlParseStringName: + * @ctxt: an XML parser context + * @str: a pointer to the string pointer (IN/OUT) + * + * parse an XML name. + * + * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | + * CombiningChar | Extender + * + * [5] Name ::= (Letter | '_' | ':') (NameChar)* + * + * [6] Names ::= Name (#x20 Name)* + * + * Returns the Name parsed or NULL. The @str pointer + * is updated to the current location in the string. + */ + +static xmlChar * +xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) { + xmlChar buf[XML_MAX_NAMELEN + 5]; + const xmlChar *cur = *str; + int len = 0, l; + int c; + +#ifdef DEBUG + nbParseStringName++; +#endif + + c = CUR_SCHAR(cur, l); + if (!xmlIsNameStartChar(ctxt, c)) { + return(NULL); + } + + COPY_BUF(l,buf,len,c); + cur += l; + c = CUR_SCHAR(cur, l); + while (xmlIsNameChar(ctxt, c)) { + COPY_BUF(l,buf,len,c); + cur += l; + c = CUR_SCHAR(cur, l); + if (len >= XML_MAX_NAMELEN) { /* test bigentname.xml */ + /* + * Okay someone managed to make a huge name, so he's ready to pay + * for the processing speed. + */ + xmlChar *buffer; + int max = len * 2; + + buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + if (buffer == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + memcpy(buffer, buf, len); + while (xmlIsNameChar(ctxt, c)) { + if (len + 10 > max) { + xmlChar *tmp; + + if ((len > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); + xmlFree(buffer); + return(NULL); + } + max *= 2; + tmp = (xmlChar *) xmlRealloc(buffer, + max * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buffer); + return(NULL); + } + buffer = tmp; + } + COPY_BUF(l,buffer,len,c); + cur += l; + c = CUR_SCHAR(cur, l); + } + buffer[len] = 0; + *str = cur; + return(buffer); + } + } + if ((len > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); + return(NULL); + } + *str = cur; + return(xmlStrndup(buf, len)); +} + +/** + * xmlParseNmtoken: + * @ctxt: an XML parser context + * + * parse an XML Nmtoken. + * + * [7] Nmtoken ::= (NameChar)+ + * + * [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)* + * + * Returns the Nmtoken parsed or NULL + */ + +xmlChar * +xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + xmlChar buf[XML_MAX_NAMELEN + 5]; + int len = 0, l; + int c; + int count = 0; + +#ifdef DEBUG + nbParseNmToken++; +#endif + + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + c = CUR_CHAR(l); + + while (xmlIsNameChar(ctxt, c)) { + if (count++ > XML_PARSER_CHUNK_SIZE) { + count = 0; + GROW; + } + COPY_BUF(l,buf,len,c); + NEXTL(l); + c = CUR_CHAR(l); + if (c == 0) { + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return(NULL); + c = CUR_CHAR(l); + } + if (len >= XML_MAX_NAMELEN) { + /* + * Okay someone managed to make a huge token, so he's ready to pay + * for the processing speed. + */ + xmlChar *buffer; + int max = len * 2; + + buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + if (buffer == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + memcpy(buffer, buf, len); + while (xmlIsNameChar(ctxt, c)) { + if (count++ > XML_PARSER_CHUNK_SIZE) { + count = 0; + GROW; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buffer); + return(NULL); + } + } + if (len + 10 > max) { + xmlChar *tmp; + + if ((max > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken"); + xmlFree(buffer); + return(NULL); + } + max *= 2; + tmp = (xmlChar *) xmlRealloc(buffer, + max * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buffer); + return(NULL); + } + buffer = tmp; + } + COPY_BUF(l,buffer,len,c); + NEXTL(l); + c = CUR_CHAR(l); + } + buffer[len] = 0; + return(buffer); + } + } + if (len == 0) + return(NULL); + if ((len > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken"); + return(NULL); + } + return(xmlStrndup(buf, len)); +} + +/** + * xmlParseEntityValue: + * @ctxt: an XML parser context + * @orig: if non-NULL store a copy of the original entity value + * + * parse a value for ENTITY declarations + * + * [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | + * "'" ([^%&'] | PEReference | Reference)* "'" + * + * Returns the EntityValue parsed with reference substituted or NULL + */ + +xmlChar * +xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + int c, l; + xmlChar stop; + xmlChar *ret = NULL; + const xmlChar *cur = NULL; + xmlParserInputPtr input; + + if (RAW == '"') stop = '"'; + else if (RAW == '\'') stop = '\''; + else { + xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_STARTED, NULL); + return(NULL); + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + + /* + * The content of the entity definition is copied in a buffer. + */ + + ctxt->instate = XML_PARSER_ENTITY_VALUE; + input = ctxt->input; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + goto error; + NEXT; + c = CUR_CHAR(l); + /* + * NOTE: 4.4.5 Included in Literal + * When a parameter entity reference appears in a literal entity + * value, ... a single or double quote character in the replacement + * text is always treated as a normal data character and will not + * terminate the literal. + * In practice it means we stop the loop only when back at parsing + * the initial entity and the quote is found + */ + while (((IS_CHAR(c)) && ((c != stop) || /* checked */ + (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) { + if (len + 5 >= size) { + xmlChar *tmp; + + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + goto error; + } + buf = tmp; + } + COPY_BUF(l,buf,len,c); + NEXTL(l); + + GROW; + c = CUR_CHAR(l); + if (c == 0) { + GROW; + c = CUR_CHAR(l); + } + } + buf[len] = 0; + if (ctxt->instate == XML_PARSER_EOF) + goto error; + if (c != stop) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL); + goto error; + } + NEXT; + + /* + * Raise problem w.r.t. '&' and '%' being used in non-entities + * reference constructs. Note Charref will be handled in + * xmlStringDecodeEntities() + */ + cur = buf; + while (*cur != 0) { /* non input consuming */ + if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) { + xmlChar *name; + xmlChar tmp = *cur; + int nameOk = 0; + + cur++; + name = xmlParseStringName(ctxt, &cur); + if (name != NULL) { + nameOk = 1; + xmlFree(name); + } + if ((nameOk == 0) || (*cur != ';')) { + xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR, + "EntityValue: '%c' forbidden except for entities references\n", + tmp); + goto error; + } + if ((tmp == '%') && (ctxt->inSubset == 1) && + (ctxt->inputNr == 1)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_PE_INTERNAL, NULL); + goto error; + } + if (*cur == 0) + break; + } + cur++; + } + + /* + * Then PEReference entities are substituted. + * + * NOTE: 4.4.7 Bypassed + * When a general entity reference appears in the EntityValue in + * an entity declaration, it is bypassed and left as is. + * so XML_SUBSTITUTE_REF is not set here. + */ + ++ctxt->depth; + ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, + 0, 0, 0); + --ctxt->depth; + if (orig != NULL) { + *orig = buf; + buf = NULL; + } + +error: + if (buf != NULL) + xmlFree(buf); + return(ret); +} + +/** + * xmlParseAttValueComplex: + * @ctxt: an XML parser context + * @len: the resulting attribute len + * @normalize: whether to apply the inner normalization + * + * parse a value for an attribute, this is the fallback function + * of xmlParseAttValue() when the attribute parsing requires handling + * of non-ASCII characters, or normalization compaction. + * + * Returns the AttValue parsed or NULL. The value has to be freed by the caller. + */ +static xmlChar * +xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + xmlChar limit = 0; + xmlChar *buf = NULL; + xmlChar *rep = NULL; + size_t len = 0; + size_t buf_size = 0; + int c, l, in_space = 0; + xmlChar *current = NULL; + xmlEntityPtr ent; + + if (NXT(0) == '"') { + ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE; + limit = '"'; + NEXT; + } else if (NXT(0) == '\'') { + limit = '\''; + ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE; + NEXT; + } else { + xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL); + return(NULL); + } + + /* + * allocate a translation buffer. + */ + buf_size = XML_PARSER_BUFFER_SIZE; + buf = (xmlChar *) xmlMallocAtomic(buf_size); + if (buf == NULL) goto mem_error; + + /* + * OK loop until we reach one of the ending char or a size limit. + */ + c = CUR_CHAR(l); + while (((NXT(0) != limit) && /* checked */ + (IS_CHAR(c)) && (c != '<')) && + (ctxt->instate != XML_PARSER_EOF)) { + /* + * Impose a reasonable limit on attribute size, unless XML_PARSE_HUGE + * special option is given + */ + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + "AttValue length too long\n"); + goto mem_error; + } + if (c == '&') { + in_space = 0; + if (NXT(1) == '#') { + int val = xmlParseCharRef(ctxt); + + if (val == '&') { + if (ctxt->replaceEntities) { + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + buf[len++] = '&'; + } else { + /* + * The reparsing will be done in xmlStringGetNodeList() + * called by the attribute() function in SAX.c + */ + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + buf[len++] = '&'; + buf[len++] = '#'; + buf[len++] = '3'; + buf[len++] = '8'; + buf[len++] = ';'; + } + } else if (val != 0) { + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + len += xmlCopyChar(0, &buf[len], val); + } + } else { + ent = xmlParseEntityRef(ctxt); + ctxt->nbentities++; + if (ent != NULL) + ctxt->nbentities += ent->owner; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + if ((ctxt->replaceEntities == 0) && + (ent->content[0] == '&')) { + buf[len++] = '&'; + buf[len++] = '#'; + buf[len++] = '3'; + buf[len++] = '8'; + buf[len++] = ';'; + } else { + buf[len++] = ent->content[0]; + } + } else if ((ent != NULL) && + (ctxt->replaceEntities != 0)) { + if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) { + ++ctxt->depth; + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, + 0, 0, 0); + --ctxt->depth; + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming */ + if ((*current == 0xD) || (*current == 0xA) || + (*current == 0x9)) { + buf[len++] = 0x20; + current++; + } else + buf[len++] = *current++; + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + } + xmlFree(rep); + rep = NULL; + } + } else { + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + if (ent->content != NULL) + buf[len++] = ent->content[0]; + } + } else if (ent != NULL) { + int i = xmlStrlen(ent->name); + const xmlChar *cur = ent->name; + + /* + * This may look absurd but is needed to detect + * entities problems + */ + if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && + (ent->content != NULL) && (ent->checked == 0)) { + unsigned long oldnbent = ctxt->nbentities, diff; + + ++ctxt->depth; + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, 0, 0, 0); + --ctxt->depth; + + diff = ctxt->nbentities - oldnbent + 1; + if (diff > INT_MAX / 2) + diff = INT_MAX / 2; + ent->checked = diff * 2; + if (rep != NULL) { + if (xmlStrchr(rep, '<')) + ent->checked |= 1; + xmlFree(rep); + rep = NULL; + } else { + ent->content[0] = 0; + } + } + + /* + * Just output the reference + */ + buf[len++] = '&'; + while (len + i + 10 > buf_size) { + growBuffer(buf, i + 10); + } + for (;i > 0;i--) + buf[len++] = *cur++; + buf[len++] = ';'; + } + } + } else { + if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) { + if ((len != 0) || (!normalize)) { + if ((!normalize) || (!in_space)) { + COPY_BUF(l,buf,len,0x20); + while (len + 10 > buf_size) { + growBuffer(buf, 10); + } + } + in_space = 1; + } + } else { + in_space = 0; + COPY_BUF(l,buf,len,c); + if (len + 10 > buf_size) { + growBuffer(buf, 10); + } + } + NEXTL(l); + } + GROW; + c = CUR_CHAR(l); + } + if (ctxt->instate == XML_PARSER_EOF) + goto error; + + if ((in_space) && (normalize)) { + while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } + buf[len] = 0; + if (RAW == '<') { + xmlFatalErr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, NULL); + } else if (RAW != limit) { + if ((c != 0) && (!IS_CHAR(c))) { + xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR, + "invalid character in attribute value\n"); + } else { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + "AttValue: ' expected\n"); + } + } else + NEXT; + + /* + * There we potentially risk an overflow, don't allow attribute value of + * length more than INT_MAX it is a very reasonable assumption ! + */ + if (len >= INT_MAX) { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + "AttValue length too long\n"); + goto mem_error; + } + + if (attlen != NULL) *attlen = (int) len; + return(buf); + +mem_error: + xmlErrMemory(ctxt, NULL); +error: + if (buf != NULL) + xmlFree(buf); + if (rep != NULL) + xmlFree(rep); + return(NULL); +} + +/** + * xmlParseAttValue: + * @ctxt: an XML parser context + * + * parse a value for an attribute + * Note: the parser won't do substitution of entities here, this + * will be handled later in xmlStringGetNodeList + * + * [10] AttValue ::= '"' ([^<&"] | Reference)* '"' | + * "'" ([^<&'] | Reference)* "'" + * + * 3.3.3 Attribute-Value Normalization: + * Before the value of an attribute is passed to the application or + * checked for validity, the XML processor must normalize it as follows: + * - a character reference is processed by appending the referenced + * character to the attribute value + * - an entity reference is processed by recursively processing the + * replacement text of the entity + * - a whitespace character (#x20, #xD, #xA, #x9) is processed by + * appending #x20 to the normalized value, except that only a single + * #x20 is appended for a "#xD#xA" sequence that is part of an external + * parsed entity or the literal entity value of an internal parsed entity + * - other characters are processed by appending them to the normalized value + * If the declared value is not CDATA, then the XML processor must further + * process the normalized attribute value by discarding any leading and + * trailing space (#x20) characters, and by replacing sequences of space + * (#x20) characters by a single space (#x20) character. + * All attributes for which no declaration has been read should be treated + * by a non-validating parser as if declared CDATA. + * + * Returns the AttValue parsed or NULL. The value has to be freed by the caller. + */ + + +xmlChar * +xmlParseAttValue(xmlParserCtxtPtr ctxt) { + if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL); + return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0)); +} + +/** + * xmlParseSystemLiteral: + * @ctxt: an XML parser context + * + * parse an XML Literal + * + * [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'") + * + * Returns the SystemLiteral parsed or NULL + */ + +xmlChar * +xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + int cur, l; + xmlChar stop; + int state = ctxt->instate; + int count = 0; + + SHRINK; + if (RAW == '"') { + NEXT; + stop = '"'; + } else if (RAW == '\'') { + NEXT; + stop = '\''; + } else { + xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, NULL); + return(NULL); + } + + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + ctxt->instate = XML_PARSER_SYSTEM_LITERAL; + cur = CUR_CHAR(l); + while ((IS_CHAR(cur)) && (cur != stop)) { /* checked */ + if (len + 5 >= size) { + xmlChar *tmp; + + if ((size > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "SystemLiteral"); + xmlFree(buf); + ctxt->instate = (xmlParserInputState) state; + return(NULL); + } + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlFree(buf); + xmlErrMemory(ctxt, NULL); + ctxt->instate = (xmlParserInputState) state; + return(NULL); + } + buf = tmp; + } + count++; + if (count > 50) { + SHRINK; + GROW; + count = 0; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return(NULL); + } + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); + cur = CUR_CHAR(l); + if (cur == 0) { + GROW; + SHRINK; + cur = CUR_CHAR(l); + } + } + buf[len] = 0; + ctxt->instate = (xmlParserInputState) state; + if (!IS_CHAR(cur)) { + xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, NULL); + } else { + NEXT; + } + return(buf); +} + +/** + * xmlParsePubidLiteral: + * @ctxt: an XML parser context + * + * parse an XML public literal + * + * [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'" + * + * Returns the PubidLiteral parsed or NULL. + */ + +xmlChar * +xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + xmlChar cur; + xmlChar stop; + int count = 0; + xmlParserInputState oldstate = ctxt->instate; + + SHRINK; + if (RAW == '"') { + NEXT; + stop = '"'; + } else if (RAW == '\'') { + NEXT; + stop = '\''; + } else { + xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, NULL); + return(NULL); + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + ctxt->instate = XML_PARSER_PUBLIC_LITERAL; + cur = CUR; + while ((IS_PUBIDCHAR_CH(cur)) && (cur != stop)) { /* checked */ + if (len + 1 >= size) { + xmlChar *tmp; + + if ((size > XML_MAX_NAME_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Public ID"); + xmlFree(buf); + return(NULL); + } + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + return(NULL); + } + buf = tmp; + } + buf[len++] = cur; + count++; + if (count > 50) { + SHRINK; + GROW; + count = 0; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return(NULL); + } + } + NEXT; + cur = CUR; + if (cur == 0) { + GROW; + SHRINK; + cur = CUR; + } + } + buf[len] = 0; + if (cur != stop) { + xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, NULL); + } else { + NEXT; + } + ctxt->instate = oldstate; + return(buf); +} + +static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata); + +/* + * used for the test in the inner loop of the char data testing + */ +static const unsigned char test_char_data[256] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9, CR/LF separated */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x00, 0x27, /* & */ + 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3A, 0x3B, 0x00, 0x3D, 0x3E, 0x3F, /* < */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x00, 0x5E, 0x5F, /* ] */ + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* non-ascii */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/** + * xmlParseCharData: + * @ctxt: an XML parser context + * @cdata: int indicating whether we are within a CDATA section + * + * parse a CharData section. + * if we are within a CDATA section ']]>' marks an end of section. + * + * The right angle bracket (>) may be represented using the string ">", + * and must, for compatibility, be escaped using ">" or a character + * reference when it appears in the string "]]>" in content, when that + * string is not marking the end of a CDATA section. + * + * [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) + */ + +void +xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) { + const xmlChar *in; + int nbchar = 0; + int line = ctxt->input->line; + int col = ctxt->input->col; + int ccol; + + SHRINK; + GROW; + /* + * Accelerated common case where input don't need to be + * modified before passing it to the handler. + */ + if (!cdata) { + in = ctxt->input->cur; + do { +get_more_space: + while (*in == 0x20) { in++; ctxt->input->col++; } + if (*in == 0xA) { + do { + ctxt->input->line++; ctxt->input->col = 1; + in++; + } while (*in == 0xA); + goto get_more_space; + } + if (*in == '<') { + nbchar = in - ctxt->input->cur; + if (nbchar > 0) { + const xmlChar *tmp = ctxt->input->cur; + ctxt->input->cur = in; + + if ((ctxt->sax != NULL) && + (ctxt->sax->ignorableWhitespace != + ctxt->sax->characters)) { + if (areBlanks(ctxt, tmp, nbchar, 1)) { + if (ctxt->sax->ignorableWhitespace != NULL) + ctxt->sax->ignorableWhitespace(ctxt->userData, + tmp, nbchar); + } else { + if (ctxt->sax->characters != NULL) + ctxt->sax->characters(ctxt->userData, + tmp, nbchar); + if (*ctxt->space == -1) + *ctxt->space = -2; + } + } else if ((ctxt->sax != NULL) && + (ctxt->sax->characters != NULL)) { + ctxt->sax->characters(ctxt->userData, + tmp, nbchar); + } + } + return; + } + +get_more: + ccol = ctxt->input->col; + while (test_char_data[*in]) { + in++; + ccol++; + } + ctxt->input->col = ccol; + if (*in == 0xA) { + do { + ctxt->input->line++; ctxt->input->col = 1; + in++; + } while (*in == 0xA); + goto get_more; + } + if (*in == ']') { + if ((in[1] == ']') && (in[2] == '>')) { + xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL); + ctxt->input->cur = in + 1; + return; + } + in++; + ctxt->input->col++; + goto get_more; + } + nbchar = in - ctxt->input->cur; + if (nbchar > 0) { + if ((ctxt->sax != NULL) && + (ctxt->sax->ignorableWhitespace != + ctxt->sax->characters) && + (IS_BLANK_CH(*ctxt->input->cur))) { + const xmlChar *tmp = ctxt->input->cur; + ctxt->input->cur = in; + + if (areBlanks(ctxt, tmp, nbchar, 0)) { + if (ctxt->sax->ignorableWhitespace != NULL) + ctxt->sax->ignorableWhitespace(ctxt->userData, + tmp, nbchar); + } else { + if (ctxt->sax->characters != NULL) + ctxt->sax->characters(ctxt->userData, + tmp, nbchar); + if (*ctxt->space == -1) + *ctxt->space = -2; + } + line = ctxt->input->line; + col = ctxt->input->col; + } else if (ctxt->sax != NULL) { + if (ctxt->sax->characters != NULL) + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, nbchar); + line = ctxt->input->line; + col = ctxt->input->col; + } + /* something really bad happened in the SAX callback */ + if (ctxt->instate != XML_PARSER_CONTENT) + return; + } + ctxt->input->cur = in; + if (*in == 0xD) { + in++; + if (*in == 0xA) { + ctxt->input->cur = in; + in++; + ctxt->input->line++; ctxt->input->col = 1; + continue; /* while */ + } + in--; + } + if (*in == '<') { + return; + } + if (*in == '&') { + return; + } + SHRINK; + GROW; + if (ctxt->instate == XML_PARSER_EOF) + return; + in = ctxt->input->cur; + } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a)); + nbchar = 0; + } + ctxt->input->line = line; + ctxt->input->col = col; + xmlParseCharDataComplex(ctxt, cdata); +} + +/** + * xmlParseCharDataComplex: + * @ctxt: an XML parser context + * @cdata: int indicating whether we are within a CDATA section + * + * parse a CharData section.this is the fallback function + * of xmlParseCharData() when the parsing requires handling + * of non-ASCII characters. + */ +static void +xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) { + xmlChar buf[XML_PARSER_BIG_BUFFER_SIZE + 5]; + int nbchar = 0; + int cur, l; + int count = 0; + + SHRINK; + GROW; + cur = CUR_CHAR(l); + while ((cur != '<') && /* checked */ + (cur != '&') && + (IS_CHAR(cur))) /* test also done in xmlCurrentChar() */ { + if ((cur == ']') && (NXT(1) == ']') && + (NXT(2) == '>')) { + if (cdata) break; + else { + xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL); + } + } + COPY_BUF(l,buf,nbchar,cur); + if (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) { + buf[nbchar] = 0; + + /* + * OK the segment is to be consumed as chars. + */ + if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) { + if (areBlanks(ctxt, buf, nbchar, 0)) { + if (ctxt->sax->ignorableWhitespace != NULL) + ctxt->sax->ignorableWhitespace(ctxt->userData, + buf, nbchar); + } else { + if (ctxt->sax->characters != NULL) + ctxt->sax->characters(ctxt->userData, buf, nbchar); + if ((ctxt->sax->characters != + ctxt->sax->ignorableWhitespace) && + (*ctxt->space == -1)) + *ctxt->space = -2; + } + } + nbchar = 0; + /* something really bad happened in the SAX callback */ + if (ctxt->instate != XML_PARSER_CONTENT) + return; + } + count++; + if (count > 50) { + SHRINK; + GROW; + count = 0; + if (ctxt->instate == XML_PARSER_EOF) + return; + } + NEXTL(l); + cur = CUR_CHAR(l); + } + if (nbchar != 0) { + buf[nbchar] = 0; + /* + * OK the segment is to be consumed as chars. + */ + if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) { + if (areBlanks(ctxt, buf, nbchar, 0)) { + if (ctxt->sax->ignorableWhitespace != NULL) + ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar); + } else { + if (ctxt->sax->characters != NULL) + ctxt->sax->characters(ctxt->userData, buf, nbchar); + if ((ctxt->sax->characters != ctxt->sax->ignorableWhitespace) && + (*ctxt->space == -1)) + *ctxt->space = -2; + } + } + } + if ((cur != 0) && (!IS_CHAR(cur))) { + /* Generate the error and skip the offending character */ + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "PCDATA invalid Char value %d\n", + cur); + NEXTL(l); + } +} + +/** + * xmlParseExternalID: + * @ctxt: an XML parser context + * @publicID: a xmlChar** receiving PubidLiteral + * @strict: indicate whether we should restrict parsing to only + * production [75], see NOTE below + * + * Parse an External ID or a Public ID + * + * NOTE: Productions [75] and [83] interact badly since [75] can generate + * 'PUBLIC' S PubidLiteral S SystemLiteral + * + * [75] ExternalID ::= 'SYSTEM' S SystemLiteral + * | 'PUBLIC' S PubidLiteral S SystemLiteral + * + * [83] PublicID ::= 'PUBLIC' S PubidLiteral + * + * Returns the function returns SystemLiteral and in the second + * case publicID receives PubidLiteral, is strict is off + * it is possible to return NULL and have publicID set. + */ + +xmlChar * +xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) { + xmlChar *URI = NULL; + + SHRINK; + + *publicID = NULL; + if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) { + SKIP(6); + if (SKIP_BLANKS == 0) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + "Space required after 'SYSTEM'\n"); + } + URI = xmlParseSystemLiteral(ctxt); + if (URI == NULL) { + xmlFatalErr(ctxt, XML_ERR_URI_REQUIRED, NULL); + } + } else if (CMP6(CUR_PTR, 'P', 'U', 'B', 'L', 'I', 'C')) { + SKIP(6); + if (SKIP_BLANKS == 0) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + "Space required after 'PUBLIC'\n"); + } + *publicID = xmlParsePubidLiteral(ctxt); + if (*publicID == NULL) { + xmlFatalErr(ctxt, XML_ERR_PUBID_REQUIRED, NULL); + } + if (strict) { + /* + * We don't handle [83] so "S SystemLiteral" is required. + */ + if (SKIP_BLANKS == 0) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + "Space required after the Public Identifier\n"); + } + } else { + /* + * We handle [83] so we return immediately, if + * "S SystemLiteral" is not detected. We skip blanks if no + * system literal was found, but this is harmless since we must + * be at the end of a NotationDecl. + */ + if (SKIP_BLANKS == 0) return(NULL); + if ((CUR != '\'') && (CUR != '"')) return(NULL); + } + URI = xmlParseSystemLiteral(ctxt); + if (URI == NULL) { + xmlFatalErr(ctxt, XML_ERR_URI_REQUIRED, NULL); + } + } + return(URI); +} + +/** + * xmlParseCommentComplex: + * @ctxt: an XML parser context + * @buf: the already parsed part of the buffer + * @len: number of bytes in the buffer + * @size: allocated size of the buffer + * + * Skip an XML (SGML) comment + * The spec says that "For compatibility, the string "--" (double-hyphen) + * must not occur within comments. " + * This is the slow routine in case the accelerator for ascii didn't work + * + * [15] Comment ::= '' + */ +static void +xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, + size_t len, size_t size) { + int q, ql; + int r, rl; + int cur, l; + size_t count = 0; + int inputid; + + inputid = ctxt->input->id; + + if (buf == NULL) { + len = 0; + size = XML_PARSER_BUFFER_SIZE; + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + return; + } + } + GROW; /* Assure there's enough input data */ + q = CUR_CHAR(ql); + if (q == 0) + goto not_terminated; + if (!IS_CHAR(q)) { + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "xmlParseComment: invalid xmlChar value %d\n", + q); + xmlFree (buf); + return; + } + NEXTL(ql); + r = CUR_CHAR(rl); + if (r == 0) + goto not_terminated; + if (!IS_CHAR(r)) { + xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR, + "xmlParseComment: invalid xmlChar value %d\n", + q); + xmlFree (buf); + return; + } + NEXTL(rl); + cur = CUR_CHAR(l); + if (cur == 0) + goto not_terminated; + while (IS_CHAR(cur) && /* checked */ + ((cur != '>') || + (r != '-') || (q != '-'))) { + if ((r == '-') && (q == '-')) { + xmlFatalErr(ctxt, XML_ERR_HYPHEN_IN_COMMENT, NULL); + } + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, + "Comment too big found", NULL); + xmlFree (buf); + return; + } + if (len + 5 >= size) { + xmlChar *new_buf; + size_t new_size; + + new_size = size * 2; + new_buf = (xmlChar *) xmlRealloc(buf, new_size); + if (new_buf == NULL) { + xmlFree (buf); + xmlErrMemory(ctxt, NULL); + return; + } + buf = new_buf; + size = new_size; + } + COPY_BUF(ql,buf,len,q); + q = r; + ql = rl; + r = cur; + rl = l; + + count++; + if (count > 50) { + SHRINK; + GROW; + count = 0; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return; + } + } + NEXTL(l); + cur = CUR_CHAR(l); + if (cur == 0) { + SHRINK; + GROW; + cur = CUR_CHAR(l); + } + } + buf[len] = 0; + if (cur == 0) { + xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, + "Comment not terminated \n + * The spec says that "For compatibility, the string "--" (double-hyphen) + * must not occur within comments. " + * + * [15] Comment ::= '' + */ +void +xmlParseComment(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + size_t size = XML_PARSER_BUFFER_SIZE; + size_t len = 0; + xmlParserInputState state; + const xmlChar *in; + size_t nbchar = 0; + int ccol; + int inputid; + + /* + * Check that there is a comment right here. + */ + if ((RAW != '<') || (NXT(1) != '!') || + (NXT(2) != '-') || (NXT(3) != '-')) return; + state = ctxt->instate; + ctxt->instate = XML_PARSER_COMMENT; + inputid = ctxt->input->id; + SKIP(4); + SHRINK; + GROW; + + /* + * Accelerated common case where input don't need to be + * modified before passing it to the handler. + */ + in = ctxt->input->cur; + do { + if (*in == 0xA) { + do { + ctxt->input->line++; ctxt->input->col = 1; + in++; + } while (*in == 0xA); + } +get_more: + ccol = ctxt->input->col; + while (((*in > '-') && (*in <= 0x7F)) || + ((*in >= 0x20) && (*in < '-')) || + (*in == 0x09)) { + in++; + ccol++; + } + ctxt->input->col = ccol; + if (*in == 0xA) { + do { + ctxt->input->line++; ctxt->input->col = 1; + in++; + } while (*in == 0xA); + goto get_more; + } + nbchar = in - ctxt->input->cur; + /* + * save current set of data + */ + if (nbchar > 0) { + if ((ctxt->sax != NULL) && + (ctxt->sax->comment != NULL)) { + if (buf == NULL) { + if ((*in == '-') && (in[1] == '-')) + size = nbchar + 1; + else + size = XML_PARSER_BUFFER_SIZE + nbchar; + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->instate = state; + return; + } + len = 0; + } else if (len + nbchar + 1 >= size) { + xmlChar *new_buf; + size += len + nbchar + XML_PARSER_BUFFER_SIZE; + new_buf = (xmlChar *) xmlRealloc(buf, + size * sizeof(xmlChar)); + if (new_buf == NULL) { + xmlFree (buf); + xmlErrMemory(ctxt, NULL); + ctxt->instate = state; + return; + } + buf = new_buf; + } + memcpy(&buf[len], ctxt->input->cur, nbchar); + len += nbchar; + buf[len] = 0; + } + } + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, + "Comment too big found", NULL); + xmlFree (buf); + return; + } + ctxt->input->cur = in; + if (*in == 0xA) { + in++; + ctxt->input->line++; ctxt->input->col = 1; + } + if (*in == 0xD) { + in++; + if (*in == 0xA) { + ctxt->input->cur = in; + in++; + ctxt->input->line++; ctxt->input->col = 1; + continue; /* while */ + } + in--; + } + SHRINK; + GROW; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return; + } + in = ctxt->input->cur; + if (*in == '-') { + if (in[1] == '-') { + if (in[2] == '>') { + if (ctxt->input->id != inputid) { + xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, + "comment doesn't start and stop in the" + " same entity\n"); + } + SKIP(3); + if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) && + (!ctxt->disableSAX)) { + if (buf != NULL) + ctxt->sax->comment(ctxt->userData, buf); + else + ctxt->sax->comment(ctxt->userData, BAD_CAST ""); + } + if (buf != NULL) + xmlFree(buf); + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + return; + } + if (buf != NULL) { + xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT, + "Double hyphen within comment: " + " + + + + noname + + . + xmllint + test + result + *.xml + err + + + + + XML Regression Tests + failed to load external entity + + + XML Entity Subst Regression Tests + noent + --noent + + + XML Namespaces Regression Tests + namespaces + namespaces + + + xml:id Regression Tests + testXPath + xmlid + xmlid + -i + id_*.xml + "id('bar')" + + + Error Cases Regression Tests + errors + errors + + + Error Cases Stream Regression Tests + errors + errors + str + --stream + + + Reader Regression Tests + rdr + --nonet + --debug + --stream + * + None + + + Walker Regression Tests + rdr + --nonet + --debug + --walker + * + None + + + Reader Entities Substitution Regression Tests + rde + --nonet + --debug + --stream + --noent + * + None + + + SAX Callbacks Regression Tests + testSAX + sax + * + utf16*.xml + None + + + XML Push Regression Tests + --push + failed to load external entity + + + HTML Regression Tests + testHTML + HTML + HTML + * + wired.html + + + Push HTML Regression Tests + testHTML + --push + HTML + HTML + * + + + HTML SAX Regression Tests + testHTML + --sax + HTML + HTML + sax + None + * + + + Push HTML SAX Regression Tests + testHTML + --sax + --push + HTML + HTML + sax + None + * + + + Valid Documents Regression Tests + VCM + VCM + None + None + * + --valid + --noout + --nowarning + + + Validity Checking Regression Tests + VC + VC + None + + * + --valid + --noout + + + General Documents Valid Regression Tests + valid + valid + * + --valid + + + URI Module Regression Tests (1) + testURI + URI + + URI + None + *.data + + -base "http://foo.com/path/to/index.html?orig#help" + + + URI Module Regression Tests (2) + testURI + URI + + URI + None + *.uri + + + XPath Regression Tests (1) + testXPath + XPath/expr + XPath/expr + * + -f + --expr + + + XInclude Regression Tests + XInclude/docs + XInclude + * + --nowarning + --xinclude + + + XInclude xmlReader Regression Tests + XInclude/docs + XInclude + rdr + * + --nowarning + --xinclude + --stream + --debug + + diff --git a/src/runsuite.c b/src/runsuite.c new file mode 100644 index 000000000000..d24b5ec3f0ef --- /dev/null +++ b/src/runsuite.c @@ -0,0 +1,1157 @@ +/* + * runsuite.c: C program to run libxml2 against published testsuites + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#include + +#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#endif +#include +#include +#include +#include + +#include +#include +#include +#include +#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_XPATH_ENABLED) +#include + +#include +#include + +#include +#include +#include + +#define LOGFILE "runsuite.log" +static FILE *logfile = NULL; +static int verbose = 0; + + +/************************************************************************ + * * + * File name and path utilities * + * * + ************************************************************************/ + +static int checkTestFile(const char *filename) { + struct stat buf; + + if (stat(filename, &buf) == -1) + return(0); + +#if defined(_WIN32) && !defined(__CYGWIN__) + if (!(buf.st_mode & _S_IFREG)) + return(0); +#else + if (!S_ISREG(buf.st_mode)) + return(0); +#endif + + return(1); +} + +static xmlChar *composeDir(const xmlChar *dir, const xmlChar *path) { + char buf[500]; + + if (dir == NULL) return(xmlStrdup(path)); + if (path == NULL) return(NULL); + + snprintf(buf, 500, "%s/%s", (const char *) dir, (const char *) path); + return(xmlStrdup((const xmlChar *) buf)); +} + +/************************************************************************ + * * + * Libxml2 specific routines * + * * + ************************************************************************/ + +static int nb_tests = 0; +static int nb_errors = 0; +static int nb_internals = 0; +static int nb_schematas = 0; +static int nb_unimplemented = 0; +static int nb_leaks = 0; +static int extraMemoryFromResolver = 0; + +static int +fatalError(void) { + fprintf(stderr, "Exitting tests on fatal error\n"); + exit(1); +} + +/* + * that's needed to implement + */ +#define MAX_ENTITIES 20 +static char *testEntitiesName[MAX_ENTITIES]; +static char *testEntitiesValue[MAX_ENTITIES]; +static int nb_entities = 0; +static void resetEntities(void) { + int i; + + for (i = 0;i < nb_entities;i++) { + if (testEntitiesName[i] != NULL) + xmlFree(testEntitiesName[i]); + if (testEntitiesValue[i] != NULL) + xmlFree(testEntitiesValue[i]); + } + nb_entities = 0; +} +static int addEntity(char *name, char *content) { + if (nb_entities >= MAX_ENTITIES) { + fprintf(stderr, "Too many entities defined\n"); + return(-1); + } + testEntitiesName[nb_entities] = name; + testEntitiesValue[nb_entities] = content; + nb_entities++; + return(0); +} + +/* + * We need to trap calls to the resolver to not account memory for the catalog + * which is shared to the current running test. We also don't want to have + * network downloads modifying tests. + */ +static xmlParserInputPtr +testExternalEntityLoader(const char *URL, const char *ID, + xmlParserCtxtPtr ctxt) { + xmlParserInputPtr ret; + int i; + + for (i = 0;i < nb_entities;i++) { + if (!strcmp(testEntitiesName[i], URL)) { + ret = xmlNewStringInputStream(ctxt, + (const xmlChar *) testEntitiesValue[i]); + if (ret != NULL) { + ret->filename = (const char *) + xmlStrdup((xmlChar *)testEntitiesName[i]); + } + return(ret); + } + } + if (checkTestFile(URL)) { + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + } else { + int memused = xmlMemUsed(); + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + extraMemoryFromResolver += xmlMemUsed() - memused; + } +#if 0 + if (ret == NULL) { + fprintf(stderr, "Failed to find resource %s\n", URL); + } +#endif + + return(ret); +} + +/* + * Trapping the error messages at the generic level to grab the equivalent of + * stderr messages on CLI tools. + */ +static char testErrors[32769]; +static int testErrorsSize = 0; + +static void test_log(const char *msg, ...) { + va_list args; + if (logfile != NULL) { + fprintf(logfile, "\n------------\n"); + va_start(args, msg); + vfprintf(logfile, msg, args); + va_end(args); + fprintf(logfile, "%s", testErrors); + testErrorsSize = 0; testErrors[0] = 0; + } + if (verbose) { + va_start(args, msg); + vfprintf(stderr, msg, args); + va_end(args); + } +} + +static void +testErrorHandler(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { + va_list args; + int res; + + if (testErrorsSize >= 32768) + return; + va_start(args, msg); + res = vsnprintf(&testErrors[testErrorsSize], + 32768 - testErrorsSize, + msg, args); + va_end(args); + if (testErrorsSize + res >= 32768) { + /* buffer is full */ + testErrorsSize = 32768; + testErrors[testErrorsSize] = 0; + } else { + testErrorsSize += res; + } + testErrors[testErrorsSize] = 0; +} + +static xmlXPathContextPtr ctxtXPath; + +static void +initializeLibxml2(void) { + xmlGetWarningsDefaultValue = 0; + xmlPedanticParserDefault(0); + + xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); + xmlInitParser(); + xmlSetExternalEntityLoader(testExternalEntityLoader); + ctxtXPath = xmlXPathNewContext(NULL); + /* + * Deactivate the cache if created; otherwise we have to create/free it + * for every test, since it will confuse the memory leak detection. + * Note that normally this need not be done, since the cache is not + * created until set explicitly with xmlXPathContextSetCache(); + * but for test purposes it is sometimes useful to activate the + * cache by default for the whole library. + */ + if (ctxtXPath->cache != NULL) + xmlXPathContextSetCache(ctxtXPath, 0, -1, 0); + /* used as default namespace in xstc tests */ + xmlXPathRegisterNs(ctxtXPath, BAD_CAST "ts", BAD_CAST "TestSuite"); + xmlXPathRegisterNs(ctxtXPath, BAD_CAST "xlink", + BAD_CAST "http://www.w3.org/1999/xlink"); + xmlSetGenericErrorFunc(NULL, testErrorHandler); +#ifdef LIBXML_SCHEMAS_ENABLED + xmlSchemaInitTypes(); + xmlRelaxNGInitTypes(); +#endif +} + +static xmlNodePtr +getNext(xmlNodePtr cur, const char *xpath) { + xmlNodePtr ret = NULL; + xmlXPathObjectPtr res; + xmlXPathCompExprPtr comp; + + if ((cur == NULL) || (cur->doc == NULL) || (xpath == NULL)) + return(NULL); + ctxtXPath->doc = cur->doc; + ctxtXPath->node = cur; + comp = xmlXPathCompile(BAD_CAST xpath); + if (comp == NULL) { + fprintf(stderr, "Failed to compile %s\n", xpath); + return(NULL); + } + res = xmlXPathCompiledEval(comp, ctxtXPath); + xmlXPathFreeCompExpr(comp); + if (res == NULL) + return(NULL); + if ((res->type == XPATH_NODESET) && + (res->nodesetval != NULL) && + (res->nodesetval->nodeNr > 0) && + (res->nodesetval->nodeTab != NULL)) + ret = res->nodesetval->nodeTab[0]; + xmlXPathFreeObject(res); + return(ret); +} + +static xmlChar * +getString(xmlNodePtr cur, const char *xpath) { + xmlChar *ret = NULL; + xmlXPathObjectPtr res; + xmlXPathCompExprPtr comp; + + if ((cur == NULL) || (cur->doc == NULL) || (xpath == NULL)) + return(NULL); + ctxtXPath->doc = cur->doc; + ctxtXPath->node = cur; + comp = xmlXPathCompile(BAD_CAST xpath); + if (comp == NULL) { + fprintf(stderr, "Failed to compile %s\n", xpath); + return(NULL); + } + res = xmlXPathCompiledEval(comp, ctxtXPath); + xmlXPathFreeCompExpr(comp); + if (res == NULL) + return(NULL); + if (res->type == XPATH_STRING) { + ret = res->stringval; + res->stringval = NULL; + } + xmlXPathFreeObject(res); + return(ret); +} + +/************************************************************************ + * * + * Test test/xsdtest/xsdtestsuite.xml * + * * + ************************************************************************/ + +static int +xsdIncorrectTestCase(xmlNodePtr cur) { + xmlNodePtr test; + xmlBufferPtr buf; + xmlRelaxNGParserCtxtPtr pctxt; + xmlRelaxNGPtr rng = NULL; + int ret = 0, memt; + + cur = getNext(cur, "./incorrect[1]"); + if (cur == NULL) { + return(0); + } + + test = getNext(cur, "./*"); + if (test == NULL) { + test_log("Failed to find test in correct line %ld\n", + xmlGetLineNo(cur)); + return(1); + } + + memt = xmlMemUsed(); + extraMemoryFromResolver = 0; + /* + * dump the schemas to a buffer, then reparse it and compile the schemas + */ + buf = xmlBufferCreate(); + if (buf == NULL) { + fprintf(stderr, "out of memory !\n"); + fatalError(); + } + xmlNodeDump(buf, test->doc, test, 0, 0); + pctxt = xmlRelaxNGNewMemParserCtxt((const char *)buf->content, buf->use); + xmlRelaxNGSetParserErrors(pctxt, testErrorHandler, testErrorHandler, + pctxt); + rng = xmlRelaxNGParse(pctxt); + xmlRelaxNGFreeParserCtxt(pctxt); + if (rng != NULL) { + test_log("Failed to detect incorrect RNG line %ld\n", + xmlGetLineNo(test)); + ret = 1; + goto done; + } + +done: + if (buf != NULL) + xmlBufferFree(buf); + if (rng != NULL) + xmlRelaxNGFree(rng); + xmlResetLastError(); + if ((memt < xmlMemUsed()) && (extraMemoryFromResolver == 0)) { + test_log("Validation of tests starting line %ld leaked %d\n", + xmlGetLineNo(cur), xmlMemUsed() - memt); + nb_leaks++; + } + return(ret); +} + +static void +installResources(xmlNodePtr tst, const xmlChar *base) { + xmlNodePtr test; + xmlBufferPtr buf; + xmlChar *name, *content, *res; + + buf = xmlBufferCreate(); + if (buf == NULL) { + fprintf(stderr, "out of memory !\n"); + fatalError(); + } + xmlNodeDump(buf, tst->doc, tst, 0, 0); + + while (tst != NULL) { + test = getNext(tst, "./*"); + if (test != NULL) { + xmlBufferEmpty(buf); + xmlNodeDump(buf, test->doc, test, 0, 0); + name = getString(tst, "string(@name)"); + content = xmlStrdup(buf->content); + if ((name != NULL) && (content != NULL)) { + res = composeDir(base, name); + xmlFree(name); + addEntity((char *) res, (char *) content); + } else { + if (name != NULL) xmlFree(name); + if (content != NULL) xmlFree(content); + } + } + tst = getNext(tst, "following-sibling::resource[1]"); + } + if (buf != NULL) + xmlBufferFree(buf); +} + +static void +installDirs(xmlNodePtr tst, const xmlChar *base) { + xmlNodePtr test; + xmlChar *name, *res; + + name = getString(tst, "string(@name)"); + if (name == NULL) + return; + res = composeDir(base, name); + xmlFree(name); + if (res == NULL) { + return; + } + /* Now process resources and subdir recursively */ + test = getNext(tst, "./resource[1]"); + if (test != NULL) { + installResources(test, res); + } + test = getNext(tst, "./dir[1]"); + while (test != NULL) { + installDirs(test, res); + test = getNext(test, "following-sibling::dir[1]"); + } + xmlFree(res); +} + +static int +xsdTestCase(xmlNodePtr tst) { + xmlNodePtr test, tmp, cur; + xmlBufferPtr buf; + xmlDocPtr doc = NULL; + xmlRelaxNGParserCtxtPtr pctxt; + xmlRelaxNGValidCtxtPtr ctxt; + xmlRelaxNGPtr rng = NULL; + int ret = 0, mem, memt; + xmlChar *dtd; + + resetEntities(); + testErrorsSize = 0; testErrors[0] = 0; + + tmp = getNext(tst, "./dir[1]"); + if (tmp != NULL) { + installDirs(tmp, NULL); + } + tmp = getNext(tst, "./resource[1]"); + if (tmp != NULL) { + installResources(tmp, NULL); + } + + cur = getNext(tst, "./correct[1]"); + if (cur == NULL) { + return(xsdIncorrectTestCase(tst)); + } + + test = getNext(cur, "./*"); + if (test == NULL) { + fprintf(stderr, "Failed to find test in correct line %ld\n", + xmlGetLineNo(cur)); + return(1); + } + + memt = xmlMemUsed(); + extraMemoryFromResolver = 0; + /* + * dump the schemas to a buffer, then reparse it and compile the schemas + */ + buf = xmlBufferCreate(); + if (buf == NULL) { + fprintf(stderr, "out of memory !\n"); + fatalError(); + } + xmlNodeDump(buf, test->doc, test, 0, 0); + pctxt = xmlRelaxNGNewMemParserCtxt((const char *)buf->content, buf->use); + xmlRelaxNGSetParserErrors(pctxt, testErrorHandler, testErrorHandler, + pctxt); + rng = xmlRelaxNGParse(pctxt); + xmlRelaxNGFreeParserCtxt(pctxt); + if (extraMemoryFromResolver) + memt = 0; + + if (rng == NULL) { + test_log("Failed to parse RNGtest line %ld\n", + xmlGetLineNo(test)); + nb_errors++; + ret = 1; + goto done; + } + /* + * now scan all the siblings of correct to process the tests + */ + tmp = getNext(cur, "following-sibling::valid[1]"); + while (tmp != NULL) { + dtd = xmlGetProp(tmp, BAD_CAST "dtd"); + test = getNext(tmp, "./*"); + if (test == NULL) { + fprintf(stderr, "Failed to find test in line %ld\n", + xmlGetLineNo(tmp)); + + } else { + xmlBufferEmpty(buf); + if (dtd != NULL) + xmlBufferAdd(buf, dtd, -1); + xmlNodeDump(buf, test->doc, test, 0, 0); + + /* + * We are ready to run the test + */ + mem = xmlMemUsed(); + extraMemoryFromResolver = 0; + doc = xmlReadMemory((const char *)buf->content, buf->use, + "test", NULL, 0); + if (doc == NULL) { + test_log("Failed to parse valid instance line %ld\n", + xmlGetLineNo(tmp)); + nb_errors++; + } else { + nb_tests++; + ctxt = xmlRelaxNGNewValidCtxt(rng); + xmlRelaxNGSetValidErrors(ctxt, + testErrorHandler, testErrorHandler, ctxt); + ret = xmlRelaxNGValidateDoc(ctxt, doc); + xmlRelaxNGFreeValidCtxt(ctxt); + if (ret > 0) { + test_log("Failed to validate valid instance line %ld\n", + xmlGetLineNo(tmp)); + nb_errors++; + } else if (ret < 0) { + test_log("Internal error validating instance line %ld\n", + xmlGetLineNo(tmp)); + nb_errors++; + } + xmlFreeDoc(doc); + } + xmlResetLastError(); + if ((mem != xmlMemUsed()) && (extraMemoryFromResolver == 0)) { + test_log("Validation of instance line %ld leaked %d\n", + xmlGetLineNo(tmp), xmlMemUsed() - mem); + xmlMemoryDump(); + nb_leaks++; + } + } + if (dtd != NULL) + xmlFree(dtd); + tmp = getNext(tmp, "following-sibling::valid[1]"); + } + /* + * now scan all the siblings of correct to process the tests + */ + tmp = getNext(cur, "following-sibling::invalid[1]"); + while (tmp != NULL) { + test = getNext(tmp, "./*"); + if (test == NULL) { + fprintf(stderr, "Failed to find test in line %ld\n", + xmlGetLineNo(tmp)); + + } else { + xmlBufferEmpty(buf); + xmlNodeDump(buf, test->doc, test, 0, 0); + + /* + * We are ready to run the test + */ + mem = xmlMemUsed(); + extraMemoryFromResolver = 0; + doc = xmlReadMemory((const char *)buf->content, buf->use, + "test", NULL, 0); + if (doc == NULL) { + test_log("Failed to parse valid instance line %ld\n", + xmlGetLineNo(tmp)); + nb_errors++; + } else { + nb_tests++; + ctxt = xmlRelaxNGNewValidCtxt(rng); + xmlRelaxNGSetValidErrors(ctxt, + testErrorHandler, testErrorHandler, ctxt); + ret = xmlRelaxNGValidateDoc(ctxt, doc); + xmlRelaxNGFreeValidCtxt(ctxt); + if (ret == 0) { + test_log("Failed to detect invalid instance line %ld\n", + xmlGetLineNo(tmp)); + nb_errors++; + } else if (ret < 0) { + test_log("Internal error validating instance line %ld\n", + xmlGetLineNo(tmp)); + nb_errors++; + } + xmlFreeDoc(doc); + } + xmlResetLastError(); + if ((mem != xmlMemUsed()) && (extraMemoryFromResolver == 0)) { + test_log("Validation of instance line %ld leaked %d\n", + xmlGetLineNo(tmp), xmlMemUsed() - mem); + xmlMemoryDump(); + nb_leaks++; + } + } + tmp = getNext(tmp, "following-sibling::invalid[1]"); + } + +done: + if (buf != NULL) + xmlBufferFree(buf); + if (rng != NULL) + xmlRelaxNGFree(rng); + xmlResetLastError(); + if ((memt != xmlMemUsed()) && (memt != 0)) { + test_log("Validation of tests starting line %ld leaked %d\n", + xmlGetLineNo(cur), xmlMemUsed() - memt); + nb_leaks++; + } + return(ret); +} + +static int +xsdTestSuite(xmlNodePtr cur) { + if (verbose) { + xmlChar *doc = getString(cur, "string(documentation)"); + + if (doc != NULL) { + printf("Suite %s\n", doc); + xmlFree(doc); + } + } + cur = getNext(cur, "./testCase[1]"); + while (cur != NULL) { + xsdTestCase(cur); + cur = getNext(cur, "following-sibling::testCase[1]"); + } + + return(0); +} + +static int +xsdTest(void) { + xmlDocPtr doc; + xmlNodePtr cur; + const char *filename = "test/xsdtest/xsdtestsuite.xml"; + int ret = 0; + + doc = xmlReadFile(filename, NULL, XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", filename); + return(-1); + } + printf("## XML Schemas datatypes test suite from James Clark\n"); + + cur = xmlDocGetRootElement(doc); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSuite"))) { + fprintf(stderr, "Unexpected format %s\n", filename); + ret = -1; + goto done; + } + + cur = getNext(cur, "./testSuite[1]"); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSuite"))) { + fprintf(stderr, "Unexpected format %s\n", filename); + ret = -1; + goto done; + } + while (cur != NULL) { + xsdTestSuite(cur); + cur = getNext(cur, "following-sibling::testSuite[1]"); + } + +done: + if (doc != NULL) + xmlFreeDoc(doc); + return(ret); +} + +static int +rngTestSuite(xmlNodePtr cur) { + if (verbose) { + xmlChar *doc = getString(cur, "string(documentation)"); + + if (doc != NULL) { + printf("Suite %s\n", doc); + xmlFree(doc); + } else { + doc = getString(cur, "string(section)"); + if (doc != NULL) { + printf("Section %s\n", doc); + xmlFree(doc); + } + } + } + cur = getNext(cur, "./testSuite[1]"); + while (cur != NULL) { + xsdTestSuite(cur); + cur = getNext(cur, "following-sibling::testSuite[1]"); + } + + return(0); +} + +static int +rngTest1(void) { + xmlDocPtr doc; + xmlNodePtr cur; + const char *filename = "test/relaxng/OASIS/spectest.xml"; + int ret = 0; + + doc = xmlReadFile(filename, NULL, XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", filename); + return(-1); + } + printf("## Relax NG test suite from James Clark\n"); + + cur = xmlDocGetRootElement(doc); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSuite"))) { + fprintf(stderr, "Unexpected format %s\n", filename); + ret = -1; + goto done; + } + + cur = getNext(cur, "./testSuite[1]"); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSuite"))) { + fprintf(stderr, "Unexpected format %s\n", filename); + ret = -1; + goto done; + } + while (cur != NULL) { + rngTestSuite(cur); + cur = getNext(cur, "following-sibling::testSuite[1]"); + } + +done: + if (doc != NULL) + xmlFreeDoc(doc); + return(ret); +} + +static int +rngTest2(void) { + xmlDocPtr doc; + xmlNodePtr cur; + const char *filename = "test/relaxng/testsuite.xml"; + int ret = 0; + + doc = xmlReadFile(filename, NULL, XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", filename); + return(-1); + } + printf("## Relax NG test suite for libxml2\n"); + + cur = xmlDocGetRootElement(doc); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSuite"))) { + fprintf(stderr, "Unexpected format %s\n", filename); + ret = -1; + goto done; + } + + cur = getNext(cur, "./testSuite[1]"); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSuite"))) { + fprintf(stderr, "Unexpected format %s\n", filename); + ret = -1; + goto done; + } + while (cur != NULL) { + xsdTestSuite(cur); + cur = getNext(cur, "following-sibling::testSuite[1]"); + } + +done: + if (doc != NULL) + xmlFreeDoc(doc); + return(ret); +} + +/************************************************************************ + * * + * Schemas test suites from W3C/NIST/MS/Sun * + * * + ************************************************************************/ + +static int +xstcTestInstance(xmlNodePtr cur, xmlSchemaPtr schemas, + const xmlChar *spath, const char *base) { + xmlChar *href = NULL; + xmlChar *path = NULL; + xmlChar *validity = NULL; + xmlSchemaValidCtxtPtr ctxt = NULL; + xmlDocPtr doc = NULL; + int ret = 0, mem; + + xmlResetLastError(); + testErrorsSize = 0; testErrors[0] = 0; + mem = xmlMemUsed(); + href = getString(cur, + "string(ts:instanceDocument/@xlink:href)"); + if ((href == NULL) || (href[0] == 0)) { + test_log("testGroup line %ld misses href for schemaDocument\n", + xmlGetLineNo(cur)); + ret = -1; + goto done; + } + path = xmlBuildURI(href, BAD_CAST base); + if (path == NULL) { + fprintf(stderr, + "Failed to build path to schemas testGroup line %ld : %s\n", + xmlGetLineNo(cur), href); + ret = -1; + goto done; + } + if (checkTestFile((const char *) path) <= 0) { + test_log("schemas for testGroup line %ld is missing: %s\n", + xmlGetLineNo(cur), path); + ret = -1; + goto done; + } + validity = getString(cur, + "string(ts:expected/@validity)"); + if (validity == NULL) { + fprintf(stderr, "instanceDocument line %ld misses expected validity\n", + xmlGetLineNo(cur)); + ret = -1; + goto done; + } + nb_tests++; + doc = xmlReadFile((const char *) path, NULL, XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "instance %s fails to parse\n", path); + ret = -1; + nb_errors++; + goto done; + } + + ctxt = xmlSchemaNewValidCtxt(schemas); + xmlSchemaSetValidErrors(ctxt, testErrorHandler, testErrorHandler, ctxt); + ret = xmlSchemaValidateDoc(ctxt, doc); + + if (xmlStrEqual(validity, BAD_CAST "valid")) { + if (ret > 0) { + test_log("valid instance %s failed to validate against %s\n", + path, spath); + nb_errors++; + } else if (ret < 0) { + test_log("valid instance %s got internal error validating %s\n", + path, spath); + nb_internals++; + nb_errors++; + } + } else if (xmlStrEqual(validity, BAD_CAST "invalid")) { + if (ret == 0) { + test_log("Failed to detect invalid instance %s against %s\n", + path, spath); + nb_errors++; + } + } else { + test_log("instanceDocument line %ld has unexpected validity value%s\n", + xmlGetLineNo(cur), validity); + ret = -1; + goto done; + } + +done: + if (href != NULL) xmlFree(href); + if (path != NULL) xmlFree(path); + if (validity != NULL) xmlFree(validity); + if (ctxt != NULL) xmlSchemaFreeValidCtxt(ctxt); + if (doc != NULL) xmlFreeDoc(doc); + xmlResetLastError(); + if (mem != xmlMemUsed()) { + test_log("Validation of tests starting line %ld leaked %d\n", + xmlGetLineNo(cur), xmlMemUsed() - mem); + nb_leaks++; + } + return(ret); +} + +static int +xstcTestGroup(xmlNodePtr cur, const char *base) { + xmlChar *href = NULL; + xmlChar *path = NULL; + xmlChar *validity = NULL; + xmlSchemaPtr schemas = NULL; + xmlSchemaParserCtxtPtr ctxt; + xmlNodePtr instance; + int ret = 0, mem; + + xmlResetLastError(); + testErrorsSize = 0; testErrors[0] = 0; + mem = xmlMemUsed(); + href = getString(cur, + "string(ts:schemaTest/ts:schemaDocument/@xlink:href)"); + if ((href == NULL) || (href[0] == 0)) { + test_log("testGroup line %ld misses href for schemaDocument\n", + xmlGetLineNo(cur)); + ret = -1; + goto done; + } + path = xmlBuildURI(href, BAD_CAST base); + if (path == NULL) { + test_log("Failed to build path to schemas testGroup line %ld : %s\n", + xmlGetLineNo(cur), href); + ret = -1; + goto done; + } + if (checkTestFile((const char *) path) <= 0) { + test_log("schemas for testGroup line %ld is missing: %s\n", + xmlGetLineNo(cur), path); + ret = -1; + goto done; + } + validity = getString(cur, + "string(ts:schemaTest/ts:expected/@validity)"); + if (validity == NULL) { + test_log("testGroup line %ld misses expected validity\n", + xmlGetLineNo(cur)); + ret = -1; + goto done; + } + nb_tests++; + if (xmlStrEqual(validity, BAD_CAST "valid")) { + nb_schematas++; + ctxt = xmlSchemaNewParserCtxt((const char *) path); + xmlSchemaSetParserErrors(ctxt, testErrorHandler, testErrorHandler, + ctxt); + schemas = xmlSchemaParse(ctxt); + xmlSchemaFreeParserCtxt(ctxt); + if (schemas == NULL) { + test_log("valid schemas %s failed to parse\n", + path); + ret = 1; + nb_errors++; + } + if ((ret == 0) && (strstr(testErrors, "nimplemented") != NULL)) { + test_log("valid schemas %s hit an unimplemented block\n", + path); + ret = 1; + nb_unimplemented++; + nb_errors++; + } + instance = getNext(cur, "./ts:instanceTest[1]"); + while (instance != NULL) { + if (schemas != NULL) { + xstcTestInstance(instance, schemas, path, base); + } else { + /* + * We'll automatically mark the instances as failed + * if the schema was broken. + */ + nb_errors++; + } + instance = getNext(instance, + "following-sibling::ts:instanceTest[1]"); + } + } else if (xmlStrEqual(validity, BAD_CAST "invalid")) { + nb_schematas++; + ctxt = xmlSchemaNewParserCtxt((const char *) path); + xmlSchemaSetParserErrors(ctxt, testErrorHandler, testErrorHandler, + ctxt); + schemas = xmlSchemaParse(ctxt); + xmlSchemaFreeParserCtxt(ctxt); + if (schemas != NULL) { + test_log("Failed to detect error in schemas %s\n", + path); + nb_errors++; + ret = 1; + } + if ((ret == 0) && (strstr(testErrors, "nimplemented") != NULL)) { + nb_unimplemented++; + test_log("invalid schemas %s hit an unimplemented block\n", + path); + ret = 1; + nb_errors++; + } + } else { + test_log("testGroup line %ld misses unexpected validity value%s\n", + xmlGetLineNo(cur), validity); + ret = -1; + goto done; + } + +done: + if (href != NULL) xmlFree(href); + if (path != NULL) xmlFree(path); + if (validity != NULL) xmlFree(validity); + if (schemas != NULL) xmlSchemaFree(schemas); + xmlResetLastError(); + if ((mem != xmlMemUsed()) && (extraMemoryFromResolver == 0)) { + test_log("Processing test line %ld %s leaked %d\n", + xmlGetLineNo(cur), path, xmlMemUsed() - mem); + nb_leaks++; + } + return(ret); +} + +static int +xstcMetadata(const char *metadata, const char *base) { + xmlDocPtr doc; + xmlNodePtr cur; + xmlChar *contributor; + xmlChar *name; + int ret = 0; + + doc = xmlReadFile(metadata, NULL, XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", metadata); + return(-1); + } + + cur = xmlDocGetRootElement(doc); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testSet"))) { + fprintf(stderr, "Unexpected format %s\n", metadata); + return(-1); + } + contributor = xmlGetProp(cur, BAD_CAST "contributor"); + if (contributor == NULL) { + contributor = xmlStrdup(BAD_CAST "Unknown"); + } + name = xmlGetProp(cur, BAD_CAST "name"); + if (name == NULL) { + name = xmlStrdup(BAD_CAST "Unknown"); + } + printf("## %s test suite for Schemas version %s\n", contributor, name); + xmlFree(contributor); + xmlFree(name); + + cur = getNext(cur, "./ts:testGroup[1]"); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "testGroup"))) { + fprintf(stderr, "Unexpected format %s\n", metadata); + ret = -1; + goto done; + } + while (cur != NULL) { + xstcTestGroup(cur, base); + cur = getNext(cur, "following-sibling::ts:testGroup[1]"); + } + +done: + xmlFreeDoc(doc); + return(ret); +} + +/************************************************************************ + * * + * The driver for the tests * + * * + ************************************************************************/ + +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + int ret = 0; + int old_errors, old_tests, old_leaks; + + logfile = fopen(LOGFILE, "w"); + if (logfile == NULL) { + fprintf(stderr, + "Could not open the log file, running in verbose mode\n"); + verbose = 1; + } + initializeLibxml2(); + + if ((argc >= 2) && (!strcmp(argv[1], "-v"))) + verbose = 1; + + + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + xsdTest(); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + rngTest1(); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + rngTest2(); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + nb_internals = 0; + nb_schematas = 0; + xstcMetadata("xstc/Tests/Metadata/NISTXMLSchemaDatatypes.testSet", + "xstc/Tests/Metadata/"); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests (%d schemata), no errors\n", + nb_tests - old_tests, nb_schematas); + else + printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n", + nb_tests - old_tests, + nb_schematas, + nb_errors - old_errors, + nb_internals, + nb_leaks - old_leaks); + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + nb_internals = 0; + nb_schematas = 0; + xstcMetadata("xstc/Tests/Metadata/SunXMLSchema1-0-20020116.testSet", + "xstc/Tests/"); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests (%d schemata), no errors\n", + nb_tests - old_tests, nb_schematas); + else + printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n", + nb_tests - old_tests, + nb_schematas, + nb_errors - old_errors, + nb_internals, + nb_leaks - old_leaks); + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + nb_internals = 0; + nb_schematas = 0; + xstcMetadata("xstc/Tests/Metadata/MSXMLSchema1-0-20020116.testSet", + "xstc/Tests/"); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests (%d schemata), no errors\n", + nb_tests - old_tests, nb_schematas); + else + printf("Ran %d tests (%d schemata), %d errors (%d internals), %d leaks\n", + nb_tests - old_tests, + nb_schematas, + nb_errors - old_errors, + nb_internals, + nb_leaks - old_leaks); + + if ((nb_errors == 0) && (nb_leaks == 0)) { + ret = 0; + printf("Total %d tests, no errors\n", + nb_tests); + } else { + ret = 1; + printf("Total %d tests, %d errors, %d leaks\n", + nb_tests, nb_errors, nb_leaks); + } + xmlXPathFreeContext(ctxtXPath); + xmlCleanupParser(); + xmlMemoryDump(); + + if (logfile != NULL) + fclose(logfile); + return(ret); +} +#else /* !SCHEMAS */ +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + fprintf(stderr, "runsuite requires support for schemas and xpath in libxml2\n"); +} +#endif diff --git a/src/runtest.c b/src/runtest.c new file mode 100644 index 000000000000..0f178cb050af --- /dev/null +++ b/src/runtest.c @@ -0,0 +1,4606 @@ +/* + * runtest.c: C program to run libxml2 regression tests without + * requiring make or Python, and reducing platform dependencies + * to a strict minimum. + * + * To compile on Unixes: + * cc -o runtest `xml2-config --cflags` runtest.c `xml2-config --libs` -lpthread + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#include + +#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#endif +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef LIBXML_READER_ENABLED +#include +#endif + +#ifdef LIBXML_XINCLUDE_ENABLED +#include +#endif + +#ifdef LIBXML_XPATH_ENABLED +#include +#include +#ifdef LIBXML_XPTR_ENABLED +#include +#endif +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED +#include +#include +#include +#endif + +#ifdef LIBXML_PATTERN_ENABLED +#include +#endif + +#ifdef LIBXML_C14N_ENABLED +#include +#endif + +#ifdef LIBXML_HTML_ENABLED +#include +#include + +/* + * pseudo flag for the unification of HTML and XML tests + */ +#define XML_PARSE_HTML 1 << 24 +#endif + +#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) +#include +#include +#include +#include +#include +#endif + +/* + * O_BINARY is just for Windows compatibility - if it isn't defined + * on this system, avoid any compilation error + */ +#ifdef O_BINARY +#define RD_FLAGS O_RDONLY | O_BINARY +#define WR_FLAGS O_WRONLY | O_CREAT | O_TRUNC | O_BINARY +#else +#define RD_FLAGS O_RDONLY +#define WR_FLAGS O_WRONLY | O_CREAT | O_TRUNC +#endif + +typedef int (*functest) (const char *filename, const char *result, + const char *error, int options); + +typedef struct testDesc testDesc; +typedef testDesc *testDescPtr; +struct testDesc { + const char *desc; /* description of the test */ + functest func; /* function implementing the test */ + const char *in; /* glob to path for input files */ + const char *out; /* output directory */ + const char *suffix;/* suffix for output files */ + const char *err; /* suffix for error output files */ + int options; /* parser options for the test */ +}; + +static int update_results = 0; +static char* temp_directory = NULL; +static int checkTestFile(const char *filename); + +#if defined(_WIN32) && !defined(__CYGWIN__) + +#include +#include + +typedef struct +{ + size_t gl_pathc; /* Count of paths matched so far */ + char **gl_pathv; /* List of matched pathnames. */ + size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */ +} glob_t; + +#define GLOB_DOOFFS 0 +static int glob(const char *pattern, ATTRIBUTE_UNUSED int flags, + ATTRIBUTE_UNUSED int errfunc(const char *epath, int eerrno), + glob_t *pglob) { + glob_t *ret; + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + unsigned int nb_paths = 0; + char directory[500]; + int len; + + if ((pattern == NULL) || (pglob == NULL)) return(-1); + + strncpy(directory, pattern, 499); + for (len = strlen(directory);len >= 0;len--) { + if (directory[len] == '/') { + len++; + directory[len] = 0; + break; + } + } + if (len <= 0) + len = 0; + + + ret = pglob; + memset(ret, 0, sizeof(glob_t)); + + hFind = FindFirstFileA(pattern, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) + return(0); + nb_paths = 20; + ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *)); + if (ret->gl_pathv == NULL) { + FindClose(hFind); + return(-1); + } + strncpy(directory + len, FindFileData.cFileName, 499 - len); + ret->gl_pathv[ret->gl_pathc] = strdup(directory); + if (ret->gl_pathv[ret->gl_pathc] == NULL) + goto done; + ret->gl_pathc++; + while(FindNextFileA(hFind, &FindFileData)) { + if (FindFileData.cFileName[0] == '.') + continue; + if (ret->gl_pathc + 2 > nb_paths) { + char **tmp = realloc(ret->gl_pathv, nb_paths * 2 * sizeof(char *)); + if (tmp == NULL) + break; + ret->gl_pathv = tmp; + nb_paths *= 2; + } + strncpy(directory + len, FindFileData.cFileName, 499 - len); + ret->gl_pathv[ret->gl_pathc] = strdup(directory); + if (ret->gl_pathv[ret->gl_pathc] == NULL) + break; + ret->gl_pathc++; + } + ret->gl_pathv[ret->gl_pathc] = NULL; + +done: + FindClose(hFind); + return(0); +} + + + +static void globfree(glob_t *pglob) { + unsigned int i; + if (pglob == NULL) + return; + + for (i = 0;i < pglob->gl_pathc;i++) { + if (pglob->gl_pathv[i] != NULL) + free(pglob->gl_pathv[i]); + } +} + +#else +#include +#endif + +/************************************************************************ + * * + * Libxml2 specific routines * + * * + ************************************************************************/ + +static int nb_tests = 0; +static int nb_errors = 0; +static int nb_leaks = 0; +static int extraMemoryFromResolver = 0; + +static int +fatalError(void) { + fprintf(stderr, "Exitting tests on fatal error\n"); + exit(1); +} + +/* + * We need to trap calls to the resolver to not account memory for the catalog + * which is shared to the current running test. We also don't want to have + * network downloads modifying tests. + */ +static xmlParserInputPtr +testExternalEntityLoader(const char *URL, const char *ID, + xmlParserCtxtPtr ctxt) { + xmlParserInputPtr ret; + + if (checkTestFile(URL)) { + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + } else { + int memused = xmlMemUsed(); + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + extraMemoryFromResolver += xmlMemUsed() - memused; + } + + return(ret); +} + +/* + * Trapping the error messages at the generic level to grab the equivalent of + * stderr messages on CLI tools. + */ +static char testErrors[32769]; +static int testErrorsSize = 0; + +static void XMLCDECL +testErrorHandler(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { + va_list args; + int res; + + if (testErrorsSize >= 32768) + return; + va_start(args, msg); + res = vsnprintf(&testErrors[testErrorsSize], + 32768 - testErrorsSize, + msg, args); + va_end(args); + if (testErrorsSize + res >= 32768) { + /* buffer is full */ + testErrorsSize = 32768; + testErrors[testErrorsSize] = 0; + } else { + testErrorsSize += res; + } + testErrors[testErrorsSize] = 0; +} + +static void XMLCDECL +channel(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { + va_list args; + int res; + + if (testErrorsSize >= 32768) + return; + va_start(args, msg); + res = vsnprintf(&testErrors[testErrorsSize], + 32768 - testErrorsSize, + msg, args); + va_end(args); + if (testErrorsSize + res >= 32768) { + /* buffer is full */ + testErrorsSize = 32768; + testErrors[testErrorsSize] = 0; + } else { + testErrorsSize += res; + } + testErrors[testErrorsSize] = 0; +} + +/** + * xmlParserPrintFileContext: + * @input: an xmlParserInputPtr input + * + * Displays current context within the input content for error tracking + */ + +static void +xmlParserPrintFileContextInternal(xmlParserInputPtr input , + xmlGenericErrorFunc chanl, void *data ) { + const xmlChar *cur, *base; + unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */ + xmlChar content[81]; /* space for 80 chars + line terminator */ + xmlChar *ctnt; + + if (input == NULL) return; + cur = input->cur; + base = input->base; + /* skip backwards over any end-of-lines */ + while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { + cur--; + } + n = 0; + /* search backwards for beginning-of-line (to max buff size) */ + while ((n++ < (sizeof(content)-1)) && (cur > base) && + (*(cur) != '\n') && (*(cur) != '\r')) + cur--; + if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; + /* calculate the error position in terms of the current position */ + col = input->cur - cur; + /* search forward for end-of-line (to max buff size) */ + n = 0; + ctnt = content; + /* copy selected text to our buffer */ + while ((*cur != 0) && (*(cur) != '\n') && + (*(cur) != '\r') && (n < sizeof(content)-1)) { + *ctnt++ = *cur++; + n++; + } + *ctnt = 0; + /* print out the selected text */ + chanl(data ,"%s\n", content); + /* create blank line with problem pointer */ + n = 0; + ctnt = content; + /* (leave buffer space for pointer + line terminator) */ + while ((nfile; + line = err->line; + code = err->code; + domain = err->domain; + level = err->level; + node = err->node; + if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || + (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || + (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { + ctxt = err->ctxt; + } + str = err->message; + + if (code == XML_ERR_OK) + return; + + if ((node != NULL) && (node->type == XML_ELEMENT_NODE)) + name = node->name; + + /* + * Maintain the compatibility with the legacy error handling + */ + if (ctxt != NULL) { + input = ctxt->input; + if ((input != NULL) && (input->filename == NULL) && + (ctxt->inputNr > 1)) { + cur = input; + input = ctxt->inputTab[ctxt->inputNr - 2]; + } + if (input != NULL) { + if (input->filename) + channel(data, "%s:%d: ", input->filename, input->line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: ", input->line); + } + } else { + if (file != NULL) + channel(data, "%s:%d: ", file, line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: ", line); + } + if (name != NULL) { + channel(data, "element %s: ", name); + } + if (code == XML_ERR_OK) + return; + switch (domain) { + case XML_FROM_PARSER: + channel(data, "parser "); + break; + case XML_FROM_NAMESPACE: + channel(data, "namespace "); + break; + case XML_FROM_DTD: + case XML_FROM_VALID: + channel(data, "validity "); + break; + case XML_FROM_HTML: + channel(data, "HTML parser "); + break; + case XML_FROM_MEMORY: + channel(data, "memory "); + break; + case XML_FROM_OUTPUT: + channel(data, "output "); + break; + case XML_FROM_IO: + channel(data, "I/O "); + break; + case XML_FROM_XINCLUDE: + channel(data, "XInclude "); + break; + case XML_FROM_XPATH: + channel(data, "XPath "); + break; + case XML_FROM_XPOINTER: + channel(data, "parser "); + break; + case XML_FROM_REGEXP: + channel(data, "regexp "); + break; + case XML_FROM_MODULE: + channel(data, "module "); + break; + case XML_FROM_SCHEMASV: + channel(data, "Schemas validity "); + break; + case XML_FROM_SCHEMASP: + channel(data, "Schemas parser "); + break; + case XML_FROM_RELAXNGP: + channel(data, "Relax-NG parser "); + break; + case XML_FROM_RELAXNGV: + channel(data, "Relax-NG validity "); + break; + case XML_FROM_CATALOG: + channel(data, "Catalog "); + break; + case XML_FROM_C14N: + channel(data, "C14N "); + break; + case XML_FROM_XSLT: + channel(data, "XSLT "); + break; + default: + break; + } + if (code == XML_ERR_OK) + return; + switch (level) { + case XML_ERR_NONE: + channel(data, ": "); + break; + case XML_ERR_WARNING: + channel(data, "warning : "); + break; + case XML_ERR_ERROR: + channel(data, "error : "); + break; + case XML_ERR_FATAL: + channel(data, "error : "); + break; + } + if (code == XML_ERR_OK) + return; + if (str != NULL) { + int len; + len = xmlStrlen((const xmlChar *)str); + if ((len > 0) && (str[len - 1] != '\n')) + channel(data, "%s\n", str); + else + channel(data, "%s", str); + } else { + channel(data, "%s\n", "out of memory error"); + } + if (code == XML_ERR_OK) + return; + + if (ctxt != NULL) { + xmlParserPrintFileContextInternal(input, channel, data); + if (cur != NULL) { + if (cur->filename) + channel(data, "%s:%d: \n", cur->filename, cur->line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: \n", cur->line); + xmlParserPrintFileContextInternal(cur, channel, data); + } + } + if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) && + (err->int1 < 100) && + (err->int1 < xmlStrlen((const xmlChar *)err->str1))) { + xmlChar buf[150]; + int i; + + channel(data, "%s\n", err->str1); + for (i=0;i < err->int1;i++) + buf[i] = ' '; + buf[i++] = '^'; + buf[i] = 0; + channel(data, "%s\n", buf); + } +} + +static void +initializeLibxml2(void) { + xmlGetWarningsDefaultValue = 0; + xmlPedanticParserDefault(0); + + xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); + xmlInitParser(); + xmlSetExternalEntityLoader(testExternalEntityLoader); + xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); +#ifdef LIBXML_SCHEMAS_ENABLED + xmlSchemaInitTypes(); + xmlRelaxNGInitTypes(); +#endif +} + + +/************************************************************************ + * * + * File name and path utilities * + * * + ************************************************************************/ + +static const char *baseFilename(const char *filename) { + const char *cur; + if (filename == NULL) + return(NULL); + cur = &filename[strlen(filename)]; + while ((cur > filename) && (*cur != '/')) + cur--; + if (*cur == '/') + return(cur + 1); + return(cur); +} + +static char *resultFilename(const char *filename, const char *out, + const char *suffix) { + const char *base; + char res[500]; + char suffixbuff[500]; + +/************* + if ((filename[0] == 't') && (filename[1] == 'e') && + (filename[2] == 's') && (filename[3] == 't') && + (filename[4] == '/')) + filename = &filename[5]; + *************/ + + base = baseFilename(filename); + if (suffix == NULL) + suffix = ".tmp"; + if (out == NULL) + out = ""; + + strncpy(suffixbuff,suffix,499); +#ifdef VMS + if(strstr(base,".") && suffixbuff[0]=='.') + suffixbuff[0]='_'; +#endif + + if (snprintf(res, 499, "%s%s%s", out, base, suffixbuff) >= 499) + res[499] = 0; + return(strdup(res)); +} + +static int checkTestFile(const char *filename) { + struct stat buf; + + if (stat(filename, &buf) == -1) + return(0); + +#if defined(_WIN32) && !defined(__CYGWIN__) + if (!(buf.st_mode & _S_IFREG)) + return(0); +#else + if (!S_ISREG(buf.st_mode)) + return(0); +#endif + + return(1); +} + +static int compareFiles(const char *r1 /* temp */, const char *r2 /* result */) { + int res1, res2; + int fd1, fd2; + char bytes1[4096]; + char bytes2[4096]; + + if (update_results) { + fd1 = open(r1, RD_FLAGS); + if (fd1 < 0) + return(-1); + fd2 = open(r2, WR_FLAGS, 0644); + if (fd2 < 0) { + close(fd1); + return(-1); + } + do { + res1 = read(fd1, bytes1, 4096); + if (res1 <= 0) + break; + res2 = write(fd2, bytes1, res1); + if (res2 <= 0 || res2 != res1) + break; + } while (1); + close(fd2); + close(fd1); + return(res1 != 0); + } + + fd1 = open(r1, RD_FLAGS); + if (fd1 < 0) + return(-1); + fd2 = open(r2, RD_FLAGS); + if (fd2 < 0) { + close(fd1); + return(-1); + } + while (1) { + res1 = read(fd1, bytes1, 4096); + res2 = read(fd2, bytes2, 4096); + if ((res1 != res2) || (res1 < 0)) { + close(fd1); + close(fd2); + return(1); + } + if (res1 == 0) + break; + if (memcmp(bytes1, bytes2, res1) != 0) { + close(fd1); + close(fd2); + return(1); + } + } + close(fd1); + close(fd2); + return(0); +} + +static int compareFileMem(const char *filename, const char *mem, int size) { + int res; + int fd; + char bytes[4096]; + int idx = 0; + struct stat info; + + if (update_results) { + fd = open(filename, WR_FLAGS, 0644); + if (fd < 0) { + fprintf(stderr, "failed to open %s for writing", filename); + return(-1); + } + res = write(fd, mem, size); + close(fd); + return(res != size); + } + + if (stat(filename, &info) < 0) { + fprintf(stderr, "failed to stat %s\n", filename); + return(-1); + } + if (info.st_size != size) { + fprintf(stderr, "file %s is %ld bytes, result is %d bytes\n", + filename, (long) info.st_size, size); + return(-1); + } + fd = open(filename, RD_FLAGS); + if (fd < 0) { + fprintf(stderr, "failed to open %s for reading", filename); + return(-1); + } + while (idx < size) { + res = read(fd, bytes, 4096); + if (res <= 0) + break; + if (res + idx > size) + break; + if (memcmp(bytes, &mem[idx], res) != 0) { + int ix; + for (ix=0; ix 0) { + siz += res; + } + close(fd); +#if !defined(_WIN32) + if (siz != info.st_size) { + free(base); + return(-1); + } +#endif + base[siz] = 0; + *mem = base; + *size = siz; + return(0); +} + +static int unloadMem(const char *mem) { + free((char *)mem); + return(0); +} + +/************************************************************************ + * * + * Tests implementations * + * * + ************************************************************************/ + +/************************************************************************ + * * + * Parse to SAX based tests * + * * + ************************************************************************/ + +static FILE *SAXdebug = NULL; + +/* + * empty SAX block + */ +static xmlSAXHandler emptySAXHandlerStruct = { + NULL, /* internalSubset */ + NULL, /* isStandalone */ + NULL, /* hasInternalSubset */ + NULL, /* hasExternalSubset */ + NULL, /* resolveEntity */ + NULL, /* getEntity */ + NULL, /* entityDecl */ + NULL, /* notationDecl */ + NULL, /* attributeDecl */ + NULL, /* elementDecl */ + NULL, /* unparsedEntityDecl */ + NULL, /* setDocumentLocator */ + NULL, /* startDocument */ + NULL, /* endDocument */ + NULL, /* startElement */ + NULL, /* endElement */ + NULL, /* reference */ + NULL, /* characters */ + NULL, /* ignorableWhitespace */ + NULL, /* processingInstruction */ + NULL, /* comment */ + NULL, /* xmlParserWarning */ + NULL, /* xmlParserError */ + NULL, /* xmlParserError */ + NULL, /* getParameterEntity */ + NULL, /* cdataBlock; */ + NULL, /* externalSubset; */ + 1, + NULL, + NULL, /* startElementNs */ + NULL, /* endElementNs */ + NULL /* xmlStructuredErrorFunc */ +}; + +static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; +static int callbacks = 0; +static int quiet = 0; + +/** + * isStandaloneDebug: + * @ctxt: An XML parser context + * + * Is this document tagged standalone ? + * + * Returns 1 if true + */ +static int +isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return(0); + fprintf(SAXdebug, "SAX.isStandalone()\n"); + return(0); +} + +/** + * hasInternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + * + * Returns 1 if true + */ +static int +hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return(0); + fprintf(SAXdebug, "SAX.hasInternalSubset()\n"); + return(0); +} + +/** + * hasExternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an external subset + * + * Returns 1 if true + */ +static int +hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return(0); + fprintf(SAXdebug, "SAX.hasExternalSubset()\n"); + return(0); +} + +/** + * internalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + */ +static void +internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) +{ + callbacks++; + if (quiet) + return; + if (name == NULL) + name = BAD_CAST "(null)"; + fprintf(SAXdebug, "SAX.internalSubset(%s,", name); + if (ExternalID == NULL) + fprintf(SAXdebug, " ,"); + else + fprintf(SAXdebug, " %s,", ExternalID); + if (SystemID == NULL) + fprintf(SAXdebug, " )\n"); + else + fprintf(SAXdebug, " %s)\n", SystemID); +} + +/** + * externalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an external subset + */ +static void +externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.externalSubset(%s,", name); + if (ExternalID == NULL) + fprintf(SAXdebug, " ,"); + else + fprintf(SAXdebug, " %s,", ExternalID); + if (SystemID == NULL) + fprintf(SAXdebug, " )\n"); + else + fprintf(SAXdebug, " %s)\n", SystemID); +} + +/** + * resolveEntityDebug: + * @ctxt: An XML parser context + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Special entity resolver, better left to the parser, it has + * more context than the application layer. + * The default behaviour is to NOT resolve the entities, in that case + * the ENTITY_REF nodes are built in the structure (and the parameter + * values). + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlParserInputPtr +resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) +{ + callbacks++; + if (quiet) + return(NULL); + /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ + + + fprintf(SAXdebug, "SAX.resolveEntity("); + if (publicId != NULL) + fprintf(SAXdebug, "%s", (char *)publicId); + else + fprintf(SAXdebug, " "); + if (systemId != NULL) + fprintf(SAXdebug, ", %s)\n", (char *)systemId); + else + fprintf(SAXdebug, ", )\n"); +/********* + if (systemId != NULL) { + return(xmlNewInputFromFile(ctxt, (char *) systemId)); + } + *********/ + return(NULL); +} + +/** + * getEntityDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get an entity by name + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlEntityPtr +getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + callbacks++; + if (quiet) + return(NULL); + fprintf(SAXdebug, "SAX.getEntity(%s)\n", name); + return(NULL); +} + +/** + * getParameterEntityDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get a parameter entity by name + * + * Returns the xmlParserInputPtr + */ +static xmlEntityPtr +getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + callbacks++; + if (quiet) + return(NULL); + fprintf(SAXdebug, "SAX.getParameterEntity(%s)\n", name); + return(NULL); +} + + +/** + * entityDeclDebug: + * @ctxt: An XML parser context + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed + */ +static void +entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, + const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) +{ +const xmlChar *nullstr = BAD_CAST "(null)"; + /* not all libraries handle printing null pointers nicely */ + if (publicId == NULL) + publicId = nullstr; + if (systemId == NULL) + systemId = nullstr; + if (content == NULL) + content = (xmlChar *)nullstr; + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", + name, type, publicId, systemId, content); +} + +/** + * attributeDeclDebug: + * @ctxt: An XML parser context + * @name: the attribute name + * @type: the attribute type + * + * An attribute definition has been parsed + */ +static void +attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, + const xmlChar * name, int type, int def, + const xmlChar * defaultValue, xmlEnumerationPtr tree) +{ + callbacks++; + if (quiet) + return; + if (defaultValue == NULL) + fprintf(SAXdebug, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", + elem, name, type, def); + else + fprintf(SAXdebug, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", + elem, name, type, def, defaultValue); + xmlFreeEnumeration(tree); +} + +/** + * elementDeclDebug: + * @ctxt: An XML parser context + * @name: the element name + * @type: the element type + * @content: the element value (without processing). + * + * An element definition has been parsed + */ +static void +elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, + xmlElementContentPtr content ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.elementDecl(%s, %d, ...)\n", + name, type); +} + +/** + * notationDeclDebug: + * @ctxt: An XML parser context + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +static void +notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *publicId, const xmlChar *systemId) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.notationDecl(%s, %s, %s)\n", + (char *) name, (char *) publicId, (char *) systemId); +} + +/** + * unparsedEntityDeclDebug: + * @ctxt: An XML parser context + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed + */ +static void +unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *publicId, const xmlChar *systemId, + const xmlChar *notationName) +{ +const xmlChar *nullstr = BAD_CAST "(null)"; + + if (publicId == NULL) + publicId = nullstr; + if (systemId == NULL) + systemId = nullstr; + if (notationName == NULL) + notationName = nullstr; + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", + (char *) name, (char *) publicId, (char *) systemId, + (char *) notationName); +} + +/** + * setDocumentLocatorDebug: + * @ctxt: An XML parser context + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator + * Everything is available on the context, so this is useless in our case. + */ +static void +setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.setDocumentLocator()\n"); +} + +/** + * startDocumentDebug: + * @ctxt: An XML parser context + * + * called when the document start being processed. + */ +static void +startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.startDocument()\n"); +} + +/** + * endDocumentDebug: + * @ctxt: An XML parser context + * + * called when the document end has been detected. + */ +static void +endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.endDocument()\n"); +} + +/** + * startElementDebug: + * @ctxt: An XML parser context + * @name: The element name + * + * called when an opening tag has been processed. + */ +static void +startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) +{ + int i; + + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.startElement(%s", (char *) name); + if (atts != NULL) { + for (i = 0;(atts[i] != NULL);i++) { + fprintf(SAXdebug, ", %s='", atts[i++]); + if (atts[i] != NULL) + fprintf(SAXdebug, "%s'", atts[i]); + } + } + fprintf(SAXdebug, ")\n"); +} + +/** + * endElementDebug: + * @ctxt: An XML parser context + * @name: The element name + * + * called when the end of an element has been detected. + */ +static void +endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + callbacks++; + if (quiet) + return; + fprintf(SAXdebug, "SAX.endElement(%s)\n", (char *) name); +} + +/** + * charactersDebug: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * receiving some chars from the parser. + * Question: how much at a time ??? + */ +static void +charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) +{ + char output[40]; + int i; + + callbacks++; + if (quiet) + return; + for (i = 0;(isax, emptySAXHandler, sizeof(xmlSAXHandler)); + xmlCtxtUseOptions(ctxt, options); + xmlParseDocument(ctxt); + ret = ctxt->wellFormed ? 0 : ctxt->errNo; + xmlFreeDoc(ctxt->myDoc); + xmlFreeParserCtxt(ctxt); + } + if (ret == XML_WAR_UNDECLARED_ENTITY) { + fprintf(SAXdebug, "xmlSAXUserParseFile returned error %d\n", ret); + ret = 0; + } + if (ret != 0) { + fprintf(stderr, "Failed to parse %s\n", filename); + ret = 1; + goto done; + } +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) { + htmlSAXParseFile(filename, NULL, debugHTMLSAXHandler, NULL); + ret = 0; + } else +#endif + { + xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(filename); + if (options & XML_PARSE_SAX1) { + memcpy(ctxt->sax, debugSAXHandler, sizeof(xmlSAXHandler)); + options -= XML_PARSE_SAX1; + } else { + memcpy(ctxt->sax, debugSAX2Handler, sizeof(xmlSAXHandler)); + } + xmlCtxtUseOptions(ctxt, options); + xmlParseDocument(ctxt); + ret = ctxt->wellFormed ? 0 : ctxt->errNo; + xmlFreeDoc(ctxt->myDoc); + xmlFreeParserCtxt(ctxt); + } + if (ret == XML_WAR_UNDECLARED_ENTITY) { + fprintf(SAXdebug, "xmlSAXUserParseFile returned error %d\n", ret); + ret = 0; + } + fclose(SAXdebug); + if (compareFiles(temp, result)) { + fprintf(stderr, "Got a difference for %s\n", filename); + ret = 1; + } + +done: + if (temp != NULL) { + unlink(temp); + free(temp); + } + + /* switch back to structured error handling */ + xmlSetGenericErrorFunc(NULL, NULL); + xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); + + return(ret); +} + +/************************************************************************ + * * + * Parse to tree based tests * + * * + ************************************************************************/ +/** + * oldParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a file using the old xmlParseFile API, then serialize back + * reparse the result and serialize again, then check for deviation + * in serialization. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +oldParseTest(const char *filename, const char *result, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + xmlDocPtr doc; + char *temp; + int res = 0; + + nb_tests++; + /* + * base of the test, parse with the old API + */ +#ifdef LIBXML_SAX1_ENABLED + doc = xmlParseFile(filename); +#else + doc = xmlReadFile(filename, NULL, 0); +#endif + if (doc == NULL) + return(1); + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "out of memory\n"); + fatalError(); + } + xmlSaveFile(temp, doc); + if (compareFiles(temp, result)) { + res = 1; + } + xmlFreeDoc(doc); + + /* + * Parse the saved result to make sure the round trip is okay + */ +#ifdef LIBXML_SAX1_ENABLED + doc = xmlParseFile(temp); +#else + doc = xmlReadFile(temp, NULL, 0); +#endif + if (doc == NULL) + return(1); + xmlSaveFile(temp, doc); + if (compareFiles(temp, result)) { + res = 1; + } + xmlFreeDoc(doc); + + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(res); +} + +#ifdef LIBXML_PUSH_ENABLED +/** + * pushParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a file using the Push API, then serialize back + * to check for content. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +pushParseTest(const char *filename, const char *result, + const char *err ATTRIBUTE_UNUSED, + int options) { + xmlParserCtxtPtr ctxt; + xmlDocPtr doc; + const char *base; + int size, res; + int cur = 0; + int chunkSize = 4; + + nb_tests++; + /* + * load the document in memory and work from there. + */ + if (loadMem(filename, &base, &size) != 0) { + fprintf(stderr, "Failed to load %s\n", filename); + return(-1); + } + + if (chunkSize > size) + chunkSize = size; + +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) + ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, chunkSize, filename, + XML_CHAR_ENCODING_NONE); + else +#endif + ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, chunkSize, filename); + xmlCtxtUseOptions(ctxt, options); + cur += chunkSize; + chunkSize = 1024; + do { + if (cur + chunkSize >= size) { +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) + htmlParseChunk(ctxt, base + cur, size - cur, 1); + else +#endif + xmlParseChunk(ctxt, base + cur, size - cur, 1); + break; + } else { +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) + htmlParseChunk(ctxt, base + cur, chunkSize, 0); + else +#endif + xmlParseChunk(ctxt, base + cur, chunkSize, 0); + cur += chunkSize; + } + } while (cur < size); + doc = ctxt->myDoc; +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) + res = 1; + else +#endif + res = ctxt->wellFormed; + xmlFreeParserCtxt(ctxt); + free((char *)base); + if (!res) { + xmlFreeDoc(doc); + fprintf(stderr, "Failed to parse %s\n", filename); + return(-1); + } +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) + htmlDocDumpMemory(doc, (xmlChar **) &base, &size); + else +#endif + xmlDocDumpMemory(doc, (xmlChar **) &base, &size); + xmlFreeDoc(doc); + res = compareFileMem(result, base, size); + if ((base == NULL) || (res != 0)) { + if (base != NULL) + xmlFree((char *)base); + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + return(-1); + } + xmlFree((char *)base); + if (err != NULL) { + res = compareFileMem(err, testErrors, testErrorsSize); + if (res != 0) { + fprintf(stderr, "Error for %s failed\n", filename); + return(-1); + } + } + return(0); +} +#endif + +/** + * memParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a file using the old xmlReadMemory API, then serialize back + * reparse the result and serialize again, then check for deviation + * in serialization. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +memParseTest(const char *filename, const char *result, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + xmlDocPtr doc; + const char *base; + int size, res; + + nb_tests++; + /* + * load and parse the memory + */ + if (loadMem(filename, &base, &size) != 0) { + fprintf(stderr, "Failed to load %s\n", filename); + return(-1); + } + + doc = xmlReadMemory(base, size, filename, NULL, 0); + unloadMem(base); + if (doc == NULL) { + return(1); + } + xmlDocDumpMemory(doc, (xmlChar **) &base, &size); + xmlFreeDoc(doc); + res = compareFileMem(result, base, size); + if ((base == NULL) || (res != 0)) { + if (base != NULL) + xmlFree((char *)base); + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + return(-1); + } + xmlFree((char *)base); + return(0); +} + +/** + * noentParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a file with entity resolution, then serialize back + * reparse the result and serialize again, then check for deviation + * in serialization. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +noentParseTest(const char *filename, const char *result, + const char *err ATTRIBUTE_UNUSED, + int options) { + xmlDocPtr doc; + char *temp; + int res = 0; + + nb_tests++; + /* + * base of the test, parse with the old API + */ + doc = xmlReadFile(filename, NULL, options); + if (doc == NULL) + return(1); + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + xmlSaveFile(temp, doc); + if (compareFiles(temp, result)) { + res = 1; + } + xmlFreeDoc(doc); + + /* + * Parse the saved result to make sure the round trip is okay + */ + doc = xmlReadFile(filename, NULL, options); + if (doc == NULL) + return(1); + xmlSaveFile(temp, doc); + if (compareFiles(temp, result)) { + res = 1; + } + xmlFreeDoc(doc); + + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(res); +} + +/** + * errParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file using the xmlReadFile API and check for errors. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +errParseTest(const char *filename, const char *result, const char *err, + int options) { + xmlDocPtr doc; + const char *base = NULL; + int size, res = 0; + + nb_tests++; +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) { + doc = htmlReadFile(filename, NULL, options); + } else +#endif +#ifdef LIBXML_XINCLUDE_ENABLED + if (options & XML_PARSE_XINCLUDE) { + doc = xmlReadFile(filename, NULL, options); + xmlXIncludeProcessFlags(doc, options); + } else +#endif + { + xmlGetWarningsDefaultValue = 1; + doc = xmlReadFile(filename, NULL, options); + } + xmlGetWarningsDefaultValue = 0; + if (result) { + if (doc == NULL) { + base = ""; + size = 0; + } else { +#ifdef LIBXML_HTML_ENABLED + if (options & XML_PARSE_HTML) { + htmlDocDumpMemory(doc, (xmlChar **) &base, &size); + } else +#endif + xmlDocDumpMemory(doc, (xmlChar **) &base, &size); + } + res = compareFileMem(result, base, size); + } + if (doc != NULL) { + if (base != NULL) + xmlFree((char *)base); + xmlFreeDoc(doc); + } + if (res != 0) { + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + return(-1); + } + if (err != NULL) { + res = compareFileMem(err, testErrors, testErrorsSize); + if (res != 0) { + fprintf(stderr, "Error for %s failed\n", filename); + return(-1); + } + } else if (options & XML_PARSE_DTDVALID) { + if (testErrorsSize != 0) + fprintf(stderr, "Validation for %s failed\n", filename); + } + + return(0); +} + +#ifdef LIBXML_READER_ENABLED +/************************************************************************ + * * + * Reader based tests * + * * + ************************************************************************/ + +static void processNode(FILE *out, xmlTextReaderPtr reader) { + const xmlChar *name, *value; + int type, empty; + + type = xmlTextReaderNodeType(reader); + empty = xmlTextReaderIsEmptyElement(reader); + + name = xmlTextReaderConstName(reader); + if (name == NULL) + name = BAD_CAST "--"; + + value = xmlTextReaderConstValue(reader); + + + fprintf(out, "%d %d %s %d %d", + xmlTextReaderDepth(reader), + type, + name, + empty, + xmlTextReaderHasValue(reader)); + if (value == NULL) + fprintf(out, "\n"); + else { + fprintf(out, " %s\n", value); + } +} +static int +streamProcessTest(const char *filename, const char *result, const char *err, + xmlTextReaderPtr reader, const char *rng, + int options ATTRIBUTE_UNUSED) { + int ret; + char *temp = NULL; + FILE *t = NULL; + + if (reader == NULL) + return(-1); + + nb_tests++; + if (result != NULL) { + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + t = fopen(temp, "wb"); + if (t == NULL) { + fprintf(stderr, "Can't open temp file %s\n", temp); + free(temp); + return(-1); + } + } +#ifdef LIBXML_SCHEMAS_ENABLED + if (rng != NULL) { + ret = xmlTextReaderRelaxNGValidate(reader, rng); + if (ret < 0) { + testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n", + rng); + fclose(t); + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(0); + } + } +#endif + xmlGetWarningsDefaultValue = 1; + ret = xmlTextReaderRead(reader); + while (ret == 1) { + if ((t != NULL) && (rng == NULL)) + processNode(t, reader); + ret = xmlTextReaderRead(reader); + } + if (ret != 0) { + testErrorHandler(NULL, "%s : failed to parse\n", filename); + } + if (rng != NULL) { + if (xmlTextReaderIsValid(reader) != 1) { + testErrorHandler(NULL, "%s fails to validate\n", filename); + } else { + testErrorHandler(NULL, "%s validates\n", filename); + } + } + xmlGetWarningsDefaultValue = 0; + if (t != NULL) { + fclose(t); + ret = compareFiles(temp, result); + if (temp != NULL) { + unlink(temp); + free(temp); + } + if (ret) { + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + return(-1); + } + } + if (err != NULL) { + ret = compareFileMem(err, testErrors, testErrorsSize); + if (ret != 0) { + fprintf(stderr, "Error for %s failed\n", filename); + printf("%s", testErrors); + return(-1); + } + } + + return(0); +} + +/** + * streamParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file using the reader API and check for errors. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +streamParseTest(const char *filename, const char *result, const char *err, + int options) { + xmlTextReaderPtr reader; + int ret; + + reader = xmlReaderForFile(filename, NULL, options); + ret = streamProcessTest(filename, result, err, reader, NULL, options); + xmlFreeTextReader(reader); + return(ret); +} + +/** + * walkerParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file using the walker, i.e. a reader built from a atree. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +walkerParseTest(const char *filename, const char *result, const char *err, + int options) { + xmlDocPtr doc; + xmlTextReaderPtr reader; + int ret; + + doc = xmlReadFile(filename, NULL, options); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", filename); + return(-1); + } + reader = xmlReaderWalker(doc); + ret = streamProcessTest(filename, result, err, reader, NULL, options); + xmlFreeTextReader(reader); + xmlFreeDoc(doc); + return(ret); +} + +/** + * streamMemParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file using the reader API from memory and check for errors. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +streamMemParseTest(const char *filename, const char *result, const char *err, + int options) { + xmlTextReaderPtr reader; + int ret; + const char *base; + int size; + + /* + * load and parse the memory + */ + if (loadMem(filename, &base, &size) != 0) { + fprintf(stderr, "Failed to load %s\n", filename); + return(-1); + } + reader = xmlReaderForMemory(base, size, filename, NULL, options); + ret = streamProcessTest(filename, result, err, reader, NULL, options); + free((char *)base); + xmlFreeTextReader(reader); + return(ret); +} +#endif + +#ifdef LIBXML_XPATH_ENABLED +#ifdef LIBXML_DEBUG_ENABLED +/************************************************************************ + * * + * XPath and XPointer based tests * + * * + ************************************************************************/ + +static FILE *xpathOutput; +static xmlDocPtr xpathDocument; + +static void +ignoreGenericError(void *ctx ATTRIBUTE_UNUSED, + const char *msg ATTRIBUTE_UNUSED, ...) { +} + +static void +testXPath(const char *str, int xptr, int expr) { + xmlGenericErrorFunc handler = ignoreGenericError; + xmlXPathObjectPtr res; + xmlXPathContextPtr ctxt; + + /* Don't print generic errors to stderr. */ + initGenericErrorDefaultFunc(&handler); + + nb_tests++; +#if defined(LIBXML_XPTR_ENABLED) + if (xptr) { + ctxt = xmlXPtrNewContext(xpathDocument, NULL, NULL); + res = xmlXPtrEval(BAD_CAST str, ctxt); + } else { +#endif + ctxt = xmlXPathNewContext(xpathDocument); + ctxt->node = xmlDocGetRootElement(xpathDocument); + if (expr) + res = xmlXPathEvalExpression(BAD_CAST str, ctxt); + else { + /* res = xmlXPathEval(BAD_CAST str, ctxt); */ + xmlXPathCompExprPtr comp; + + comp = xmlXPathCompile(BAD_CAST str); + if (comp != NULL) { + res = xmlXPathCompiledEval(comp, ctxt); + xmlXPathFreeCompExpr(comp); + } else + res = NULL; + } +#if defined(LIBXML_XPTR_ENABLED) + } +#endif + xmlXPathDebugDumpObject(xpathOutput, res, 0); + xmlXPathFreeObject(res); + xmlXPathFreeContext(ctxt); + + /* Reset generic error handler. */ + initGenericErrorDefaultFunc(NULL); +} + +/** + * xpathExprTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing XPath standalone expressions and evaluate them + * + * Returns 0 in case of success, an error code otherwise + */ +static int +xpathCommonTest(const char *filename, const char *result, + int xptr, int expr) { + FILE *input; + char expression[5000]; + int len, ret = 0; + char *temp; + + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + xpathOutput = fopen(temp, "wb"); + if (xpathOutput == NULL) { + fprintf(stderr, "failed to open output file %s\n", temp); + free(temp); + return(-1); + } + + input = fopen(filename, "rb"); + if (input == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot open %s for reading\n", filename); + free(temp); + return(-1); + } + while (fgets(expression, 4500, input) != NULL) { + len = strlen(expression); + len--; + while ((len >= 0) && + ((expression[len] == '\n') || (expression[len] == '\t') || + (expression[len] == '\r') || (expression[len] == ' '))) len--; + expression[len + 1] = 0; + if (len >= 0) { + fprintf(xpathOutput, + "\n========================\nExpression: %s\n", + expression) ; + testXPath(expression, xptr, expr); + } + } + + fclose(input); + fclose(xpathOutput); + if (result != NULL) { + ret = compareFiles(temp, result); + if (ret) { + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + } + } + + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(ret); +} + +/** + * xpathExprTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing XPath standalone expressions and evaluate them + * + * Returns 0 in case of success, an error code otherwise + */ +static int +xpathExprTest(const char *filename, const char *result, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + return(xpathCommonTest(filename, result, 0, 1)); +} + +/** + * xpathDocTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing XPath expressions and evaluate them against + * a set of corresponding documents. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +xpathDocTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options) { + + char pattern[500]; + char result[500]; + glob_t globbuf; + size_t i; + int ret = 0, res; + + xpathDocument = xmlReadFile(filename, NULL, + options | XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (xpathDocument == NULL) { + fprintf(stderr, "Failed to load %s\n", filename); + return(-1); + } + + res = snprintf(pattern, 499, "./test/XPath/tests/%s*", + baseFilename(filename)); + if (res >= 499) + pattern[499] = 0; + globbuf.gl_offs = 0; + glob(pattern, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + res = snprintf(result, 499, "result/XPath/tests/%s", + baseFilename(globbuf.gl_pathv[i])); + if (res >= 499) + result[499] = 0; + res = xpathCommonTest(globbuf.gl_pathv[i], &result[0], 0, 0); + if (res != 0) + ret = res; + } + globfree(&globbuf); + + xmlFreeDoc(xpathDocument); + return(ret); +} + +#ifdef LIBXML_XPTR_ENABLED +/** + * xptrDocTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing XPath expressions and evaluate them against + * a set of corresponding documents. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +xptrDocTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options) { + + char pattern[500]; + char result[500]; + glob_t globbuf; + size_t i; + int ret = 0, res; + + xpathDocument = xmlReadFile(filename, NULL, + options | XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (xpathDocument == NULL) { + fprintf(stderr, "Failed to load %s\n", filename); + return(-1); + } + + res = snprintf(pattern, 499, "./test/XPath/xptr/%s*", + baseFilename(filename)); + if (res >= 499) + pattern[499] = 0; + globbuf.gl_offs = 0; + glob(pattern, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + res = snprintf(result, 499, "result/XPath/xptr/%s", + baseFilename(globbuf.gl_pathv[i])); + if (res >= 499) + result[499] = 0; + res = xpathCommonTest(globbuf.gl_pathv[i], &result[0], 1, 0); + if (res != 0) + ret = res; + } + globfree(&globbuf); + + xmlFreeDoc(xpathDocument); + return(ret); +} +#endif /* LIBXML_XPTR_ENABLED */ + +/** + * xmlidDocTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing xml:id and check for errors and verify + * that XPath queries will work on them as expected. + * + * Returns 0 in case of success, an error code otherwise + */ +static int +xmlidDocTest(const char *filename, + const char *result, + const char *err, + int options) { + + int res = 0; + int ret = 0; + char *temp; + + xpathDocument = xmlReadFile(filename, NULL, + options | XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (xpathDocument == NULL) { + fprintf(stderr, "Failed to load %s\n", filename); + return(-1); + } + + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + xpathOutput = fopen(temp, "wb"); + if (xpathOutput == NULL) { + fprintf(stderr, "failed to open output file %s\n", temp); + xmlFreeDoc(xpathDocument); + free(temp); + return(-1); + } + + testXPath("id('bar')", 0, 0); + + fclose(xpathOutput); + if (result != NULL) { + ret = compareFiles(temp, result); + if (ret) { + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + res = 1; + } + } + + if (temp != NULL) { + unlink(temp); + free(temp); + } + xmlFreeDoc(xpathDocument); + + if (err != NULL) { + ret = compareFileMem(err, testErrors, testErrorsSize); + if (ret != 0) { + fprintf(stderr, "Error for %s failed\n", filename); + res = 1; + } + } + return(res); +} + +#endif /* LIBXML_DEBUG_ENABLED */ +#endif /* XPATH */ +/************************************************************************ + * * + * URI based tests * + * * + ************************************************************************/ + +static void +handleURI(const char *str, const char *base, FILE *o) { + int ret; + xmlURIPtr uri; + xmlChar *res = NULL; + + uri = xmlCreateURI(); + + if (base == NULL) { + ret = xmlParseURIReference(uri, str); + if (ret != 0) + fprintf(o, "%s : error %d\n", str, ret); + else { + xmlNormalizeURIPath(uri->path); + xmlPrintURI(o, uri); + fprintf(o, "\n"); + } + } else { + res = xmlBuildURI((xmlChar *)str, (xmlChar *) base); + if (res != NULL) { + fprintf(o, "%s\n", (char *) res); + } + else + fprintf(o, "::ERROR::\n"); + } + if (res != NULL) + xmlFree(res); + xmlFreeURI(uri); +} + +/** + * uriCommonTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing URI and check for errors + * + * Returns 0 in case of success, an error code otherwise + */ +static int +uriCommonTest(const char *filename, + const char *result, + const char *err, + const char *base) { + char *temp; + FILE *o, *f; + char str[1024]; + int res = 0, i, ret; + + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + o = fopen(temp, "wb"); + if (o == NULL) { + fprintf(stderr, "failed to open output file %s\n", temp); + free(temp); + return(-1); + } + f = fopen(filename, "rb"); + if (f == NULL) { + fprintf(stderr, "failed to open input file %s\n", filename); + fclose(o); + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(-1); + } + + while (1) { + /* + * read one line in string buffer. + */ + if (fgets (&str[0], sizeof (str) - 1, f) == NULL) + break; + + /* + * remove the ending spaces + */ + i = strlen(str); + while ((i > 0) && + ((str[i - 1] == '\n') || (str[i - 1] == '\r') || + (str[i - 1] == ' ') || (str[i - 1] == '\t'))) { + i--; + str[i] = 0; + } + nb_tests++; + handleURI(str, base, o); + } + + fclose(f); + fclose(o); + + if (result != NULL) { + ret = compareFiles(temp, result); + if (ret) { + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + res = 1; + } + } + if (err != NULL) { + ret = compareFileMem(err, testErrors, testErrorsSize); + if (ret != 0) { + fprintf(stderr, "Error for %s failed\n", filename); + res = 1; + } + } + + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(res); +} + +/** + * uriParseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing URI and check for errors + * + * Returns 0 in case of success, an error code otherwise + */ +static int +uriParseTest(const char *filename, + const char *result, + const char *err, + int options ATTRIBUTE_UNUSED) { + return(uriCommonTest(filename, result, err, NULL)); +} + +/** + * uriBaseTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing URI, compose them against a fixed base and + * check for errors + * + * Returns 0 in case of success, an error code otherwise + */ +static int +uriBaseTest(const char *filename, + const char *result, + const char *err, + int options ATTRIBUTE_UNUSED) { + return(uriCommonTest(filename, result, err, + "http://foo.com/path/to/index.html?orig#help")); +} + +static int urip_success = 1; +static int urip_current = 0; +static const char *urip_testURLs[] = { + "urip://example.com/a b.html", + "urip://example.com/a%20b.html", + "file:///path/to/a b.html", + "file:///path/to/a%20b.html", + "/path/to/a b.html", + "/path/to/a%20b.html", + "urip://example.com/r" "\xe9" "sum" "\xe9" ".html", + "urip://example.com/test?a=1&b=2%263&c=4#foo", + NULL +}; +static const char *urip_rcvsURLs[] = { + /* it is an URI the strings must be escaped */ + "urip://example.com/a%20b.html", + /* check that % escaping is not broken */ + "urip://example.com/a%20b.html", + /* it's an URI path the strings must be escaped */ + "file:///path/to/a%20b.html", + /* check that % escaping is not broken */ + "file:///path/to/a%20b.html", + /* this is not an URI, this is a path, so this should not be escaped */ + "/path/to/a b.html", + /* check that paths with % are not broken */ + "/path/to/a%20b.html", + /* out of context the encoding can't be guessed byte by byte conversion */ + "urip://example.com/r%E9sum%E9.html", + /* verify we don't destroy URIs especially the query part */ + "urip://example.com/test?a=1&b=2%263&c=4#foo", + NULL +}; +static const char *urip_res = ""; +static const char *urip_cur = NULL; +static int urip_rlen; + +/** + * uripMatch: + * @URI: an URI to test + * + * Check for an urip: query + * + * Returns 1 if yes and 0 if another Input module should be used + */ +static int +uripMatch(const char * URI) { + if ((URI == NULL) || (!strcmp(URI, "file:///etc/xml/catalog"))) + return(0); + /* Verify we received the escaped URL */ + if (strcmp(urip_rcvsURLs[urip_current], URI)) + urip_success = 0; + return(1); +} + +/** + * uripOpen: + * @URI: an URI to test + * + * Return a pointer to the urip: query handler, in this example simply + * the urip_current pointer... + * + * Returns an Input context or NULL in case or error + */ +static void * +uripOpen(const char * URI) { + if ((URI == NULL) || (!strcmp(URI, "file:///etc/xml/catalog"))) + return(NULL); + /* Verify we received the escaped URL */ + if (strcmp(urip_rcvsURLs[urip_current], URI)) + urip_success = 0; + urip_cur = urip_res; + urip_rlen = strlen(urip_res); + return((void *) urip_cur); +} + +/** + * uripClose: + * @context: the read context + * + * Close the urip: query handler + * + * Returns 0 or -1 in case of error + */ +static int +uripClose(void * context) { + if (context == NULL) return(-1); + urip_cur = NULL; + urip_rlen = 0; + return(0); +} + +/** + * uripRead: + * @context: the read context + * @buffer: where to store data + * @len: number of bytes to read + * + * Implement an urip: query read. + * + * Returns the number of bytes read or -1 in case of error + */ +static int +uripRead(void * context, char * buffer, int len) { + const char *ptr = (const char *) context; + + if ((context == NULL) || (buffer == NULL) || (len < 0)) + return(-1); + + if (len > urip_rlen) len = urip_rlen; + memcpy(buffer, ptr, len); + urip_rlen -= len; + return(len); +} + +static int +urip_checkURL(const char *URL) { + xmlDocPtr doc; + + doc = xmlReadFile(URL, NULL, 0); + if (doc == NULL) + return(-1); + xmlFreeDoc(doc); + return(1); +} + +/** + * uriPathTest: + * @filename: ignored + * @result: ignored + * @err: ignored + * + * Run a set of tests to check how Path and URI are handled before + * being passed to the I/O layer + * + * Returns 0 in case of success, an error code otherwise + */ +static int +uriPathTest(const char *filename ATTRIBUTE_UNUSED, + const char *result ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + int parsed; + int failures = 0; + + /* + * register the new I/O handlers + */ + if (xmlRegisterInputCallbacks(uripMatch, uripOpen, uripRead, uripClose) < 0) + { + fprintf(stderr, "failed to register HTTP handler\n"); + return(-1); + } + + for (urip_current = 0;urip_testURLs[urip_current] != NULL;urip_current++) { + urip_success = 1; + parsed = urip_checkURL(urip_testURLs[urip_current]); + if (urip_success != 1) { + fprintf(stderr, "failed the URL passing test for %s", + urip_testURLs[urip_current]); + failures++; + } else if (parsed != 1) { + fprintf(stderr, "failed the parsing test for %s", + urip_testURLs[urip_current]); + failures++; + } + nb_tests++; + } + + xmlPopInputCallbacks(); + return(failures); +} + +#ifdef LIBXML_SCHEMAS_ENABLED +/************************************************************************ + * * + * Schemas tests * + * * + ************************************************************************/ +static int +schemasOneTest(const char *sch, + const char *filename, + const char *result, + const char *err, + int options, + xmlSchemaPtr schemas) { + xmlDocPtr doc; + xmlSchemaValidCtxtPtr ctxt; + int ret = 0; + int validResult = 0; + char *temp; + FILE *schemasOutput; + + doc = xmlReadFile(filename, NULL, options); + if (doc == NULL) { + fprintf(stderr, "failed to parse instance %s for %s\n", filename, sch); + return(-1); + } + + temp = resultFilename(result, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + schemasOutput = fopen(temp, "wb"); + if (schemasOutput == NULL) { + fprintf(stderr, "failed to open output file %s\n", temp); + xmlFreeDoc(doc); + free(temp); + return(-1); + } + + ctxt = xmlSchemaNewValidCtxt(schemas); + xmlSchemaSetValidErrors(ctxt, testErrorHandler, testErrorHandler, ctxt); + validResult = xmlSchemaValidateDoc(ctxt, doc); + if (validResult == 0) { + fprintf(schemasOutput, "%s validates\n", filename); + } else if (validResult > 0) { + fprintf(schemasOutput, "%s fails to validate\n", filename); + } else { + fprintf(schemasOutput, "%s validation generated an internal error\n", + filename); + } + fclose(schemasOutput); + if (result) { + if (compareFiles(temp, result)) { + fprintf(stderr, "Result for %s on %s failed\n", filename, sch); + ret = 1; + } + } + if (temp != NULL) { + unlink(temp); + free(temp); + } + + if ((validResult != 0) && (err != NULL)) { + if (compareFileMem(err, testErrors, testErrorsSize)) { + fprintf(stderr, "Error for %s on %s failed\n", filename, sch); + ret = 1; + } + } + + xmlSchemaFreeValidCtxt(ctxt); + xmlFreeDoc(doc); + return(ret); +} +/** + * schemasTest: + * @filename: the schemas file + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a file containing URI, compose them against a fixed base and + * check for errors + * + * Returns 0 in case of success, an error code otherwise + */ +static int +schemasTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *errr ATTRIBUTE_UNUSED, + int options) { + const char *base = baseFilename(filename); + const char *base2; + const char *instance; + xmlSchemaParserCtxtPtr ctxt; + xmlSchemaPtr schemas; + int res = 0, len, ret; + char pattern[500]; + char prefix[500]; + char result[500]; + char err[500]; + glob_t globbuf; + size_t i; + char count = 0; + + /* first compile the schemas if possible */ + ctxt = xmlSchemaNewParserCtxt(filename); + xmlSchemaSetParserErrors(ctxt, testErrorHandler, testErrorHandler, ctxt); + schemas = xmlSchemaParse(ctxt); + xmlSchemaFreeParserCtxt(ctxt); + + /* + * most of the mess is about the output filenames generated by the Makefile + */ + len = strlen(base); + if ((len > 499) || (len < 5)) { + xmlSchemaFree(schemas); + return(-1); + } + len -= 4; /* remove trailing .xsd */ + if (base[len - 2] == '_') { + len -= 2; /* remove subtest number */ + } + if (base[len - 2] == '_') { + len -= 2; /* remove subtest number */ + } + memcpy(prefix, base, len); + prefix[len] = 0; + + if (snprintf(pattern, 499, "./test/schemas/%s_?.xml", prefix) >= 499) + pattern[499] = 0; + + if (base[len] == '_') { + len += 2; + memcpy(prefix, base, len); + prefix[len] = 0; + } + + globbuf.gl_offs = 0; + glob(pattern, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + testErrorsSize = 0; + testErrors[0] = 0; + instance = globbuf.gl_pathv[i]; + base2 = baseFilename(instance); + len = strlen(base2); + if ((len > 6) && (base2[len - 6] == '_')) { + count = base2[len - 5]; + ret = snprintf(result, 499, "result/schemas/%s_%c", + prefix, count); + if (ret >= 499) + result[499] = 0; + ret = snprintf(err, 499, "result/schemas/%s_%c.err", + prefix, count); + if (ret >= 499) + err[499] = 0; + } else { + fprintf(stderr, "don't know how to process %s\n", instance); + continue; + } + if (schemas == NULL) { + } else { + nb_tests++; + ret = schemasOneTest(filename, instance, result, err, + options, schemas); + if (ret != 0) + res = ret; + } + } + globfree(&globbuf); + xmlSchemaFree(schemas); + + return(res); +} + +/************************************************************************ + * * + * Schemas tests * + * * + ************************************************************************/ +static int +rngOneTest(const char *sch, + const char *filename, + const char *result, + const char *err, + int options, + xmlRelaxNGPtr schemas) { + xmlDocPtr doc; + xmlRelaxNGValidCtxtPtr ctxt; + int ret = 0; + char *temp; + FILE *schemasOutput; + + doc = xmlReadFile(filename, NULL, options); + if (doc == NULL) { + fprintf(stderr, "failed to parse instance %s for %s\n", filename, sch); + return(-1); + } + + temp = resultFilename(result, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + schemasOutput = fopen(temp, "wb"); + if (schemasOutput == NULL) { + fprintf(stderr, "failed to open output file %s\n", temp); + xmlFreeDoc(doc); + free(temp); + return(-1); + } + + ctxt = xmlRelaxNGNewValidCtxt(schemas); + xmlRelaxNGSetValidErrors(ctxt, testErrorHandler, testErrorHandler, ctxt); + ret = xmlRelaxNGValidateDoc(ctxt, doc); + if (ret == 0) { + testErrorHandler(NULL, "%s validates\n", filename); + } else if (ret > 0) { + testErrorHandler(NULL, "%s fails to validate\n", filename); + } else { + testErrorHandler(NULL, "%s validation generated an internal error\n", + filename); + } + fclose(schemasOutput); + ret = 0; + if (result) { + if (compareFiles(temp, result)) { + fprintf(stderr, "Result for %s on %s failed\n", filename, sch); + ret = 1; + } + } + if (temp != NULL) { + unlink(temp); + free(temp); + } + + if (err != NULL) { + if (compareFileMem(err, testErrors, testErrorsSize)) { + fprintf(stderr, "Error for %s on %s failed\n", filename, sch); + ret = 1; + printf("%s", testErrors); + } + } + + + xmlRelaxNGFreeValidCtxt(ctxt); + xmlFreeDoc(doc); + return(ret); +} +/** + * rngTest: + * @filename: the schemas file + * @result: the file with expected result + * @err: the file with error messages + * + * Parse an RNG schemas and then apply it to the related .xml + * + * Returns 0 in case of success, an error code otherwise + */ +static int +rngTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *errr ATTRIBUTE_UNUSED, + int options) { + const char *base = baseFilename(filename); + const char *base2; + const char *instance; + xmlRelaxNGParserCtxtPtr ctxt; + xmlRelaxNGPtr schemas; + int res = 0, len, ret = 0; + char pattern[500]; + char prefix[500]; + char result[500]; + char err[500]; + glob_t globbuf; + size_t i; + char count = 0; + + /* first compile the schemas if possible */ + ctxt = xmlRelaxNGNewParserCtxt(filename); + xmlRelaxNGSetParserErrors(ctxt, testErrorHandler, testErrorHandler, ctxt); + schemas = xmlRelaxNGParse(ctxt); + xmlRelaxNGFreeParserCtxt(ctxt); + + /* + * most of the mess is about the output filenames generated by the Makefile + */ + len = strlen(base); + if ((len > 499) || (len < 5)) { + xmlRelaxNGFree(schemas); + return(-1); + } + len -= 4; /* remove trailing .rng */ + memcpy(prefix, base, len); + prefix[len] = 0; + + if (snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix) >= 499) + pattern[499] = 0; + + globbuf.gl_offs = 0; + glob(pattern, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + testErrorsSize = 0; + testErrors[0] = 0; + instance = globbuf.gl_pathv[i]; + base2 = baseFilename(instance); + len = strlen(base2); + if ((len > 6) && (base2[len - 6] == '_')) { + count = base2[len - 5]; + res = snprintf(result, 499, "result/relaxng/%s_%c", + prefix, count); + if (res >= 499) + result[499] = 0; + res = snprintf(err, 499, "result/relaxng/%s_%c.err", + prefix, count); + if (res >= 499) + err[499] = 0; + } else { + fprintf(stderr, "don't know how to process %s\n", instance); + continue; + } + if (schemas == NULL) { + } else { + nb_tests++; + res = rngOneTest(filename, instance, result, err, + options, schemas); + if (res != 0) + ret = res; + } + } + globfree(&globbuf); + xmlRelaxNGFree(schemas); + + return(ret); +} + +#ifdef LIBXML_READER_ENABLED +/** + * rngStreamTest: + * @filename: the schemas file + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a set of files with streaming, applying an RNG schemas + * + * Returns 0 in case of success, an error code otherwise + */ +static int +rngStreamTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *errr ATTRIBUTE_UNUSED, + int options) { + const char *base = baseFilename(filename); + const char *base2; + const char *instance; + int res = 0, len, ret; + char pattern[500]; + char prefix[500]; + char result[500]; + char err[500]; + glob_t globbuf; + size_t i; + char count = 0; + xmlTextReaderPtr reader; + int disable_err = 0; + + /* + * most of the mess is about the output filenames generated by the Makefile + */ + len = strlen(base); + if ((len > 499) || (len < 5)) { + fprintf(stderr, "len(base) == %d !\n", len); + return(-1); + } + len -= 4; /* remove trailing .rng */ + memcpy(prefix, base, len); + prefix[len] = 0; + + /* + * strictly unifying the error messages is nearly impossible this + * hack is also done in the Makefile + */ + if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) || + (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")) || + (!strcmp(prefix, "tutor8_2"))) + disable_err = 1; + + if (snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix) >= 499) + pattern[499] = 0; + + globbuf.gl_offs = 0; + glob(pattern, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + testErrorsSize = 0; + testErrors[0] = 0; + instance = globbuf.gl_pathv[i]; + base2 = baseFilename(instance); + len = strlen(base2); + if ((len > 6) && (base2[len - 6] == '_')) { + count = base2[len - 5]; + ret = snprintf(result, 499, "result/relaxng/%s_%c", + prefix, count); + if (ret >= 499) + result[499] = 0; + ret = snprintf(err, 499, "result/relaxng/%s_%c.err", + prefix, count); + if (ret >= 499) + err[499] = 0; + } else { + fprintf(stderr, "don't know how to process %s\n", instance); + continue; + } + reader = xmlReaderForFile(instance, NULL, options); + if (reader == NULL) { + fprintf(stderr, "Failed to build reader for %s\n", instance); + } + if (disable_err == 1) + ret = streamProcessTest(instance, result, NULL, reader, filename, + options); + else + ret = streamProcessTest(instance, result, err, reader, filename, + options); + xmlFreeTextReader(reader); + if (ret != 0) { + fprintf(stderr, "instance %s failed\n", instance); + res = ret; + } + } + globfree(&globbuf); + + return(res); +} +#endif /* READER */ + +#endif + +#ifdef LIBXML_PATTERN_ENABLED +#ifdef LIBXML_READER_ENABLED +/************************************************************************ + * * + * Patterns tests * + * * + ************************************************************************/ +static void patternNode(FILE *out, xmlTextReaderPtr reader, + const char *pattern, xmlPatternPtr patternc, + xmlStreamCtxtPtr patstream) { + xmlChar *path = NULL; + int match = -1; + int type, empty; + + type = xmlTextReaderNodeType(reader); + empty = xmlTextReaderIsEmptyElement(reader); + + if (type == XML_READER_TYPE_ELEMENT) { + /* do the check only on element start */ + match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); + + if (match) { + path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); + fprintf(out, "Node %s matches pattern %s\n", path, pattern); + } + } + if (patstream != NULL) { + int ret; + + if (type == XML_READER_TYPE_ELEMENT) { + ret = xmlStreamPush(patstream, + xmlTextReaderConstLocalName(reader), + xmlTextReaderConstNamespaceUri(reader)); + if (ret < 0) { + fprintf(out, "xmlStreamPush() failure\n"); + xmlFreeStreamCtxt(patstream); + patstream = NULL; + } else if (ret != match) { + if (path == NULL) { + path = xmlGetNodePath( + xmlTextReaderCurrentNode(reader)); + } + fprintf(out, + "xmlPatternMatch and xmlStreamPush disagree\n"); + fprintf(out, + " pattern %s node %s\n", + pattern, path); + } + + + } + if ((type == XML_READER_TYPE_END_ELEMENT) || + ((type == XML_READER_TYPE_ELEMENT) && (empty))) { + ret = xmlStreamPop(patstream); + if (ret < 0) { + fprintf(out, "xmlStreamPop() failure\n"); + xmlFreeStreamCtxt(patstream); + patstream = NULL; + } + } + } + if (path != NULL) + xmlFree(path); +} + +/** + * patternTest: + * @filename: the schemas file + * @result: the file with expected result + * @err: the file with error messages + * + * Parse a set of files with streaming, applying an RNG schemas + * + * Returns 0 in case of success, an error code otherwise + */ +static int +patternTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options) { + xmlPatternPtr patternc = NULL; + xmlStreamCtxtPtr patstream = NULL; + FILE *o, *f; + char str[1024]; + char xml[500]; + char result[500]; + int len, i; + int ret = 0, res; + char *temp; + xmlTextReaderPtr reader; + xmlDocPtr doc; + + len = strlen(filename); + len -= 4; + memcpy(xml, filename, len); + xml[len] = 0; + if (snprintf(result, 499, "result/pattern/%s", baseFilename(xml)) >= 499) + result[499] = 0; + memcpy(xml + len, ".xml", 5); + + if (!checkTestFile(xml) && !update_results) { + fprintf(stderr, "Missing xml file %s\n", xml); + return(-1); + } + if (!checkTestFile(result) && !update_results) { + fprintf(stderr, "Missing result file %s\n", result); + return(-1); + } + f = fopen(filename, "rb"); + if (f == NULL) { + fprintf(stderr, "Failed to open %s\n", filename); + return(-1); + } + temp = resultFilename(filename, temp_directory, ".res"); + if (temp == NULL) { + fprintf(stderr, "Out of memory\n"); + fatalError(); + } + o = fopen(temp, "wb"); + if (o == NULL) { + fprintf(stderr, "failed to open output file %s\n", temp); + fclose(f); + free(temp); + return(-1); + } + while (1) { + /* + * read one line in string buffer. + */ + if (fgets (&str[0], sizeof (str) - 1, f) == NULL) + break; + + /* + * remove the ending spaces + */ + i = strlen(str); + while ((i > 0) && + ((str[i - 1] == '\n') || (str[i - 1] == '\r') || + (str[i - 1] == ' ') || (str[i - 1] == '\t'))) { + i--; + str[i] = 0; + } + doc = xmlReadFile(xml, NULL, options); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", xml); + ret = 1; + } else { + xmlNodePtr root; + const xmlChar *namespaces[22]; + int j; + xmlNsPtr ns; + + root = xmlDocGetRootElement(doc); + for (ns = root->nsDef, j = 0;ns != NULL && j < 20;ns=ns->next) { + namespaces[j++] = ns->href; + namespaces[j++] = ns->prefix; + } + namespaces[j++] = NULL; + namespaces[j] = NULL; + + patternc = xmlPatterncompile((const xmlChar *) str, doc->dict, + 0, &namespaces[0]); + if (patternc == NULL) { + testErrorHandler(NULL, + "Pattern %s failed to compile\n", str); + xmlFreeDoc(doc); + ret = 1; + continue; + } + patstream = xmlPatternGetStreamCtxt(patternc); + if (patstream != NULL) { + ret = xmlStreamPush(patstream, NULL, NULL); + if (ret < 0) { + fprintf(stderr, "xmlStreamPush() failure\n"); + xmlFreeStreamCtxt(patstream); + patstream = NULL; + } + } + nb_tests++; + + reader = xmlReaderWalker(doc); + res = xmlTextReaderRead(reader); + while (res == 1) { + patternNode(o, reader, str, patternc, patstream); + res = xmlTextReaderRead(reader); + } + if (res != 0) { + fprintf(o, "%s : failed to parse\n", filename); + } + xmlFreeTextReader(reader); + xmlFreeDoc(doc); + xmlFreeStreamCtxt(patstream); + patstream = NULL; + xmlFreePattern(patternc); + + } + } + + fclose(f); + fclose(o); + + ret = compareFiles(temp, result); + if (ret) { + fprintf(stderr, "Result for %s failed in %s\n", filename, result); + ret = 1; + } + if (temp != NULL) { + unlink(temp); + free(temp); + } + return(ret); +} +#endif /* READER */ +#endif /* PATTERN */ +#ifdef LIBXML_C14N_ENABLED +/************************************************************************ + * * + * Canonicalization tests * + * * + ************************************************************************/ +static xmlXPathObjectPtr +load_xpath_expr (xmlDocPtr parent_doc, const char* filename) { + xmlXPathObjectPtr xpath; + xmlDocPtr doc; + xmlChar *expr; + xmlXPathContextPtr ctx; + xmlNodePtr node; + xmlNsPtr ns; + + /* + * load XPath expr as a file + */ + xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + xmlSubstituteEntitiesDefault(1); + + doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); + return(NULL); + } + + /* + * Check the document is of the right kind + */ + if(xmlDocGetRootElement(doc) == NULL) { + fprintf(stderr,"Error: empty document for file \"%s\"\n", filename); + xmlFreeDoc(doc); + return(NULL); + } + + node = doc->children; + while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) { + node = node->next; + } + + if(node == NULL) { + fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", filename); + xmlFreeDoc(doc); + return(NULL); + } + + expr = xmlNodeGetContent(node); + if(expr == NULL) { + fprintf(stderr,"Error: XPath content element is NULL \"%s\"\n", filename); + xmlFreeDoc(doc); + return(NULL); + } + + ctx = xmlXPathNewContext(parent_doc); + if(ctx == NULL) { + fprintf(stderr,"Error: unable to create new context\n"); + xmlFree(expr); + xmlFreeDoc(doc); + return(NULL); + } + + /* + * Register namespaces + */ + ns = node->nsDef; + while(ns != NULL) { + if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) { + fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href); + xmlFree(expr); + xmlXPathFreeContext(ctx); + xmlFreeDoc(doc); + return(NULL); + } + ns = ns->next; + } + + /* + * Evaluate xpath + */ + xpath = xmlXPathEvalExpression(expr, ctx); + if(xpath == NULL) { + fprintf(stderr,"Error: unable to evaluate xpath expression\n"); +xmlFree(expr); + xmlXPathFreeContext(ctx); + xmlFreeDoc(doc); + return(NULL); + } + + /* print_xpath_nodes(xpath->nodesetval); */ + + xmlFree(expr); + xmlXPathFreeContext(ctx); + xmlFreeDoc(doc); + return(xpath); +} + +/* + * Macro used to grow the current buffer. + */ +#define xxx_growBufferReentrant() { \ + buffer_size *= 2; \ + buffer = (xmlChar **) \ + xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \ + if (buffer == NULL) { \ + perror("realloc failed"); \ + return(NULL); \ + } \ +} + +static xmlChar ** +parse_list(xmlChar *str) { + xmlChar **buffer; + xmlChar **out = NULL; + int buffer_size = 0; + int len; + + if(str == NULL) { + return(NULL); + } + + len = xmlStrlen(str); + if((str[0] == '\'') && (str[len - 1] == '\'')) { + str[len - 1] = '\0'; + str++; + } + /* + * allocate an translation buffer. + */ + buffer_size = 1000; + buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*)); + if (buffer == NULL) { + perror("malloc failed"); + return(NULL); + } + out = buffer; + + while(*str != '\0') { + if (out - buffer > buffer_size - 10) { + int indx = out - buffer; + + xxx_growBufferReentrant(); + out = &buffer[indx]; + } + (*out++) = str; + while(*str != ',' && *str != '\0') ++str; + if(*str == ',') *(str++) = '\0'; + } + (*out) = NULL; + return buffer; +} + +static int +c14nRunTest(const char* xml_filename, int with_comments, int mode, + const char* xpath_filename, const char *ns_filename, + const char* result_file) { + xmlDocPtr doc; + xmlXPathObjectPtr xpath = NULL; + xmlChar *result = NULL; + int ret; + xmlChar **inclusive_namespaces = NULL; + const char *nslist = NULL; + int nssize; + + + /* + * build an XML tree from a the file; we need to add default + * attributes and resolve all character and entities references + */ + xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + xmlSubstituteEntitiesDefault(1); + + doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename); + return(-1); + } + + /* + * Check the document is of the right kind + */ + if(xmlDocGetRootElement(doc) == NULL) { + fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename); + xmlFreeDoc(doc); + return(-1); + } + + /* + * load xpath file if specified + */ + if(xpath_filename) { + xpath = load_xpath_expr(doc, xpath_filename); + if(xpath == NULL) { + fprintf(stderr,"Error: unable to evaluate xpath expression\n"); + xmlFreeDoc(doc); + return(-1); + } + } + + if (ns_filename != NULL) { + if (loadMem(ns_filename, &nslist, &nssize)) { + fprintf(stderr,"Error: unable to evaluate xpath expression\n"); + if(xpath != NULL) xmlXPathFreeObject(xpath); + xmlFreeDoc(doc); + return(-1); + } + inclusive_namespaces = parse_list((xmlChar *) nslist); + } + + /* + * Canonical form + */ + /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */ + ret = xmlC14NDocDumpMemory(doc, + (xpath) ? xpath->nodesetval : NULL, + mode, inclusive_namespaces, + with_comments, &result); + if (ret >= 0) { + if(result != NULL) { + if (compareFileMem(result_file, (const char *) result, ret)) { + fprintf(stderr, "Result mismatch for %s\n", xml_filename); + fprintf(stderr, "RESULT:\n%s\n", (const char*)result); + ret = -1; + } + } + } else { + fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret); + ret = -1; + } + + /* + * Cleanup + */ + if (result != NULL) xmlFree(result); + if(xpath != NULL) xmlXPathFreeObject(xpath); + if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces); + if (nslist != NULL) free((char *) nslist); + xmlFreeDoc(doc); + + return(ret); +} + +static int +c14nCommonTest(const char *filename, int with_comments, int mode, + const char *subdir) { + char buf[500]; + char prefix[500]; + const char *base; + int len; + char *result = NULL; + char *xpath = NULL; + char *ns = NULL; + int ret = 0; + + base = baseFilename(filename); + len = strlen(base); + len -= 4; + memcpy(prefix, base, len); + prefix[len] = 0; + + if (snprintf(buf, 499, "result/c14n/%s/%s", subdir, prefix) >= 499) + buf[499] = 0; + if (!checkTestFile(buf) && !update_results) { + fprintf(stderr, "Missing result file %s", buf); + return(-1); + } + result = strdup(buf); + if (snprintf(buf, 499, "test/c14n/%s/%s.xpath", subdir, prefix) >= 499) + buf[499] = 0; + if (checkTestFile(buf)) { + xpath = strdup(buf); + } + if (snprintf(buf, 499, "test/c14n/%s/%s.ns", subdir, prefix) >= 499) + buf[499] = 0; + if (checkTestFile(buf)) { + ns = strdup(buf); + } + + nb_tests++; + if (c14nRunTest(filename, with_comments, mode, + xpath, ns, result) < 0) + ret = 1; + + if (result != NULL) free(result); + if (xpath != NULL) free(xpath); + if (ns != NULL) free(ns); + return(ret); +} + +static int +c14nWithCommentTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + return(c14nCommonTest(filename, 1, XML_C14N_1_0, "with-comments")); +} +static int +c14nWithoutCommentTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + return(c14nCommonTest(filename, 0, XML_C14N_1_0, "without-comments")); +} +static int +c14nExcWithoutCommentTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + return(c14nCommonTest(filename, 0, XML_C14N_EXCLUSIVE_1_0, "exc-without-comments")); +} +static int +c14n11WithoutCommentTest(const char *filename, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + return(c14nCommonTest(filename, 0, XML_C14N_1_1, "1-1-without-comments")); +} +#endif +#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) +/************************************************************************ + * * + * Catalog and threads test * + * * + ************************************************************************/ + +/* + * mostly a cut and paste from testThreads.c + */ +#define MAX_ARGC 20 + +typedef struct { + const char *filename; + int okay; +} xmlThreadParams; + +static const char *catalog = "test/threads/complex.xml"; +static xmlThreadParams threadParams[] = { + { "test/threads/abc.xml", 0 }, + { "test/threads/acb.xml", 0 }, + { "test/threads/bac.xml", 0 }, + { "test/threads/bca.xml", 0 }, + { "test/threads/cab.xml", 0 }, + { "test/threads/cba.xml", 0 }, + { "test/threads/invalid.xml", 0 } +}; +static const unsigned int num_threads = sizeof(threadParams) / + sizeof(threadParams[0]); + +#ifndef xmlDoValidityCheckingDefaultValue +#error xmlDoValidityCheckingDefaultValue is not a macro +#endif +#ifndef xmlGenericErrorContext +#error xmlGenericErrorContext is not a macro +#endif + +static void * +thread_specific_data(void *private_data) +{ + xmlDocPtr myDoc; + xmlThreadParams *params = (xmlThreadParams *) private_data; + const char *filename = params->filename; + int okay = 1; + + if (!strcmp(filename, "test/threads/invalid.xml")) { + xmlDoValidityCheckingDefaultValue = 0; + xmlGenericErrorContext = stdout; + } else { + xmlDoValidityCheckingDefaultValue = 1; + xmlGenericErrorContext = stderr; + } +#ifdef LIBXML_SAX1_ENABLED + myDoc = xmlParseFile(filename); +#else + myDoc = xmlReadFile(filename, NULL, XML_WITH_CATALOG); +#endif + if (myDoc) { + xmlFreeDoc(myDoc); + } else { + printf("parse failed\n"); + okay = 0; + } + if (!strcmp(filename, "test/threads/invalid.xml")) { + if (xmlDoValidityCheckingDefaultValue != 0) { + printf("ValidityCheckingDefaultValue override failed\n"); + okay = 0; + } + if (xmlGenericErrorContext != stdout) { + printf("xmlGenericErrorContext override failed\n"); + okay = 0; + } + } else { + if (xmlDoValidityCheckingDefaultValue != 1) { + printf("ValidityCheckingDefaultValue override failed\n"); + okay = 0; + } + if (xmlGenericErrorContext != stderr) { + printf("xmlGenericErrorContext override failed\n"); + okay = 0; + } + } + params->okay = okay; + return(NULL); +} + +#if defined(_WIN32) && !defined(__CYGWIN__) +#include +#include + +#define TEST_REPEAT_COUNT 500 + +static HANDLE tid[MAX_ARGC]; + +static DWORD WINAPI +win32_thread_specific_data(void *private_data) +{ + thread_specific_data(private_data); + return(0); +} + +static int +testThread(void) +{ + unsigned int i, repeat; + BOOL ret; + int res = 0; + + xmlInitParser(); + for (repeat = 0; repeat < TEST_REPEAT_COUNT; repeat++) { + xmlLoadCatalog(catalog); + nb_tests++; + + for (i = 0; i < num_threads; i++) { + tid[i] = (HANDLE) - 1; + } + + for (i = 0; i < num_threads; i++) { + DWORD useless; + + tid[i] = CreateThread(NULL, 0, + win32_thread_specific_data, + (void *) &threadParams[i], 0, + &useless); + if (tid[i] == NULL) { + fprintf(stderr, "CreateThread failed\n"); + return(1); + } + } + + if (WaitForMultipleObjects(num_threads, tid, TRUE, INFINITE) == + WAIT_FAILED) { + fprintf(stderr, "WaitForMultipleObjects failed\n"); + return(1); + } + + for (i = 0; i < num_threads; i++) { + DWORD exitCode; + ret = GetExitCodeThread(tid[i], &exitCode); + if (ret == 0) { + fprintf(stderr, "GetExitCodeThread failed\n"); + return(1); + } + CloseHandle(tid[i]); + } + + xmlCatalogCleanup(); + for (i = 0; i < num_threads; i++) { + if (threadParams[i].okay == 0) { + fprintf(stderr, "Thread %d handling %s failed\n", + i, threadParams[i].filename); + res = 1; + } + } + } + + return (res); +} + +#elif defined __BEOS__ +#include + +static thread_id tid[MAX_ARGC]; + +static int +testThread(void) +{ + unsigned int i, repeat; + status_t ret; + int res = 0; + + xmlInitParser(); + for (repeat = 0; repeat < 500; repeat++) { + xmlLoadCatalog(catalog); + for (i = 0; i < num_threads; i++) { + tid[i] = (thread_id) - 1; + } + for (i = 0; i < num_threads; i++) { + tid[i] = + spawn_thread(thread_specific_data, "xmlTestThread", + B_NORMAL_PRIORITY, (void *) &threadParams[i]); + if (tid[i] < B_OK) { + fprintf(stderr, "beos_thread_create failed\n"); + return (1); + } + printf("beos_thread_create %d -> %d\n", i, tid[i]); + } + for (i = 0; i < num_threads; i++) { + void *result; + ret = wait_for_thread(tid[i], &result); + printf("beos_thread_wait %d -> %d\n", i, ret); + if (ret != B_OK) { + fprintf(stderr, "beos_thread_wait failed\n"); + return (1); + } + } + + xmlCatalogCleanup(); + ret = B_OK; + for (i = 0; i < num_threads; i++) + if (threadParams[i].okay == 0) { + printf("Thread %d handling %s failed\n", i, + threadParams[i].filename); + ret = B_ERROR; + } + } + if (ret != B_OK) + return(1); + return (0); +} + +#elif defined HAVE_PTHREAD_H +#include + +static pthread_t tid[MAX_ARGC]; + +static int +testThread(void) +{ + unsigned int i, repeat; + int ret; + int res = 0; + + xmlInitParser(); + + for (repeat = 0; repeat < 500; repeat++) { + xmlLoadCatalog(catalog); + nb_tests++; + + for (i = 0; i < num_threads; i++) { + tid[i] = (pthread_t) - 1; + } + + for (i = 0; i < num_threads; i++) { + ret = pthread_create(&tid[i], 0, thread_specific_data, + (void *) &threadParams[i]); + if (ret != 0) { + fprintf(stderr, "pthread_create failed\n"); + return (1); + } + } + for (i = 0; i < num_threads; i++) { + void *result; + ret = pthread_join(tid[i], &result); + if (ret != 0) { + fprintf(stderr, "pthread_join failed\n"); + return (1); + } + } + + xmlCatalogCleanup(); + for (i = 0; i < num_threads; i++) + if (threadParams[i].okay == 0) { + fprintf(stderr, "Thread %d handling %s failed\n", + i, threadParams[i].filename); + res = 1; + } + } + return (res); +} + +#else +static int +testThread(void) +{ + fprintf(stderr, + "Specific platform thread support not detected\n"); + return (-1); +} +#endif +static int +threadsTest(const char *filename ATTRIBUTE_UNUSED, + const char *resul ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + return(testThread()); +} +#endif +/************************************************************************ + * * + * Tests Descriptions * + * * + ************************************************************************/ + +static +testDesc testDescriptions[] = { + { "XML regression tests" , + oldParseTest, "./test/*", "result/", "", NULL, + 0 }, + { "XML regression tests on memory" , + memParseTest, "./test/*", "result/", "", NULL, + 0 }, + { "XML entity subst regression tests" , + noentParseTest, "./test/*", "result/noent/", "", NULL, + XML_PARSE_NOENT }, + { "XML Namespaces regression tests", + errParseTest, "./test/namespaces/*", "result/namespaces/", "", ".err", + 0 }, + { "Error cases regression tests", + errParseTest, "./test/errors/*.xml", "result/errors/", "", ".err", + 0 }, + { "Error cases regression tests with entity substitution", + errParseTest, "./test/errors/*.xml", "result/errors/", NULL, ".ent", + XML_PARSE_NOENT }, + { "Error cases regression tests (old 1.0)", + errParseTest, "./test/errors10/*.xml", "result/errors10/", "", ".err", + XML_PARSE_OLD10 }, +#ifdef LIBXML_READER_ENABLED + { "Error cases stream regression tests", + streamParseTest, "./test/errors/*.xml", "result/errors/", NULL, ".str", + 0 }, + { "Reader regression tests", + streamParseTest, "./test/*", "result/", ".rdr", NULL, + 0 }, + { "Reader entities substitution regression tests", + streamParseTest, "./test/*", "result/", ".rde", NULL, + XML_PARSE_NOENT }, + { "Reader on memory regression tests", + streamMemParseTest, "./test/*", "result/", ".rdr", NULL, + 0 }, + { "Walker regression tests", + walkerParseTest, "./test/*", "result/", ".rdr", NULL, + 0 }, +#endif +#ifdef LIBXML_SAX1_ENABLED + { "SAX1 callbacks regression tests" , + saxParseTest, "./test/*", "result/", ".sax", NULL, + XML_PARSE_SAX1 }, +#endif + { "SAX2 callbacks regression tests" , + saxParseTest, "./test/*", "result/", ".sax2", NULL, + 0 }, + { "SAX2 callbacks regression tests with entity substitution" , + saxParseTest, "./test/*", "result/noent/", ".sax2", NULL, + XML_PARSE_NOENT }, +#ifdef LIBXML_PUSH_ENABLED + { "XML push regression tests" , + pushParseTest, "./test/*", "result/", "", NULL, + 0 }, +#endif +#ifdef LIBXML_HTML_ENABLED + { "HTML regression tests" , + errParseTest, "./test/HTML/*", "result/HTML/", "", ".err", + XML_PARSE_HTML }, +#ifdef LIBXML_PUSH_ENABLED + { "Push HTML regression tests" , + pushParseTest, "./test/HTML/*", "result/HTML/", "", ".err", + XML_PARSE_HTML }, +#endif + { "HTML SAX regression tests" , + saxParseTest, "./test/HTML/*", "result/HTML/", ".sax", NULL, + XML_PARSE_HTML }, +#endif +#ifdef LIBXML_VALID_ENABLED + { "Valid documents regression tests" , + errParseTest, "./test/VCM/*", NULL, NULL, NULL, + XML_PARSE_DTDVALID }, + { "Validity checking regression tests" , + errParseTest, "./test/VC/*", "result/VC/", NULL, "", + XML_PARSE_DTDVALID }, +#ifdef LIBXML_READER_ENABLED + { "Streaming validity checking regression tests" , + streamParseTest, "./test/valid/*.xml", "result/valid/", NULL, ".err.rdr", + XML_PARSE_DTDVALID }, + { "Streaming validity error checking regression tests" , + streamParseTest, "./test/VC/*", "result/VC/", NULL, ".rdr", + XML_PARSE_DTDVALID }, +#endif + { "General documents valid regression tests" , + errParseTest, "./test/valid/*", "result/valid/", "", ".err", + XML_PARSE_DTDVALID }, +#endif +#ifdef LIBXML_XINCLUDE_ENABLED + { "XInclude regression tests" , + errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL, + /* Ignore errors at this point ".err", */ + XML_PARSE_XINCLUDE }, +#ifdef LIBXML_READER_ENABLED + { "XInclude xmlReader regression tests", + streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr", + /* Ignore errors at this point ".err", */ + NULL, XML_PARSE_XINCLUDE }, +#endif + { "XInclude regression tests stripping include nodes" , + errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL, + /* Ignore errors at this point ".err", */ + XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, +#ifdef LIBXML_READER_ENABLED + { "XInclude xmlReader regression tests stripping include nodes", + streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr", + /* Ignore errors at this point ".err", */ + NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE }, +#endif +#endif +#ifdef LIBXML_XPATH_ENABLED +#ifdef LIBXML_DEBUG_ENABLED + { "XPath expressions regression tests" , + xpathExprTest, "./test/XPath/expr/*", "result/XPath/expr/", "", NULL, + 0 }, + { "XPath document queries regression tests" , + xpathDocTest, "./test/XPath/docs/*", NULL, NULL, NULL, + 0 }, +#ifdef LIBXML_XPTR_ENABLED + { "XPointer document queries regression tests" , + xptrDocTest, "./test/XPath/docs/*", NULL, NULL, NULL, + 0 }, +#endif + { "xml:id regression tests" , + xmlidDocTest, "./test/xmlid/*", "result/xmlid/", "", ".err", + 0 }, +#endif +#endif + { "URI parsing tests" , + uriParseTest, "./test/URI/*.uri", "result/URI/", "", NULL, + 0 }, + { "URI base composition tests" , + uriBaseTest, "./test/URI/*.data", "result/URI/", "", NULL, + 0 }, + { "Path URI conversion tests" , + uriPathTest, NULL, NULL, NULL, NULL, + 0 }, +#ifdef LIBXML_SCHEMAS_ENABLED + { "Schemas regression tests" , + schemasTest, "./test/schemas/*_*.xsd", NULL, NULL, NULL, + 0 }, + { "Relax-NG regression tests" , + rngTest, "./test/relaxng/*.rng", NULL, NULL, NULL, + XML_PARSE_DTDATTR | XML_PARSE_NOENT }, +#ifdef LIBXML_READER_ENABLED + { "Relax-NG streaming regression tests" , + rngStreamTest, "./test/relaxng/*.rng", NULL, NULL, NULL, + XML_PARSE_DTDATTR | XML_PARSE_NOENT }, +#endif +#endif +#ifdef LIBXML_PATTERN_ENABLED +#ifdef LIBXML_READER_ENABLED + { "Pattern regression tests" , + patternTest, "./test/pattern/*.pat", "result/pattern/", NULL, NULL, + 0 }, +#endif +#endif +#ifdef LIBXML_C14N_ENABLED + { "C14N with comments regression tests" , + c14nWithCommentTest, "./test/c14n/with-comments/*.xml", NULL, NULL, NULL, + 0 }, + { "C14N without comments regression tests" , + c14nWithoutCommentTest, "./test/c14n/without-comments/*.xml", NULL, NULL, NULL, + 0 }, + { "C14N exclusive without comments regression tests" , + c14nExcWithoutCommentTest, "./test/c14n/exc-without-comments/*.xml", NULL, NULL, NULL, + 0 }, + { "C14N 1.1 without comments regression tests" , + c14n11WithoutCommentTest, "./test/c14n/1-1-without-comments/*.xml", NULL, NULL, NULL, + 0 }, +#endif +#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) + { "Catalog and Threads regression tests" , + threadsTest, NULL, NULL, NULL, NULL, + 0 }, +#endif + {NULL, NULL, NULL, NULL, NULL, NULL, 0} +}; + +/************************************************************************ + * * + * The main code driving the tests * + * * + ************************************************************************/ + +static int +launchTests(testDescPtr tst) { + int res = 0, err = 0; + size_t i; + char *result; + char *error; + int mem; + xmlCharEncodingHandlerPtr ebcdicHandler, eucJpHandler; + + ebcdicHandler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EBCDIC); + eucJpHandler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EUC_JP); + + if (tst == NULL) return(-1); + if (tst->in != NULL) { + glob_t globbuf; + + globbuf.gl_offs = 0; + glob(tst->in, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + if (!checkTestFile(globbuf.gl_pathv[i])) + continue; + if (((ebcdicHandler == NULL) && + (strstr(globbuf.gl_pathv[i], "ebcdic") != NULL)) || + ((eucJpHandler == NULL) && + (strstr(globbuf.gl_pathv[i], "icu_parse_test") != NULL))) + continue; + if (tst->suffix != NULL) { + result = resultFilename(globbuf.gl_pathv[i], tst->out, + tst->suffix); + if (result == NULL) { + fprintf(stderr, "Out of memory !\n"); + fatalError(); + } + } else { + result = NULL; + } + if (tst->err != NULL) { + error = resultFilename(globbuf.gl_pathv[i], tst->out, + tst->err); + if (error == NULL) { + fprintf(stderr, "Out of memory !\n"); + fatalError(); + } + } else { + error = NULL; + } + if ((result) &&(!checkTestFile(result)) && !update_results) { + fprintf(stderr, "Missing result file %s\n", result); + } else if ((error) &&(!checkTestFile(error)) && !update_results) { + fprintf(stderr, "Missing error file %s\n", error); + } else { + mem = xmlMemUsed(); + extraMemoryFromResolver = 0; + testErrorsSize = 0; + testErrors[0] = 0; + res = tst->func(globbuf.gl_pathv[i], result, error, + tst->options | XML_PARSE_COMPACT); + xmlResetLastError(); + if (res != 0) { + fprintf(stderr, "File %s generated an error\n", + globbuf.gl_pathv[i]); + nb_errors++; + err++; + } + else if (xmlMemUsed() != mem) { + if ((xmlMemUsed() != mem) && + (extraMemoryFromResolver == 0)) { + fprintf(stderr, "File %s leaked %d bytes\n", + globbuf.gl_pathv[i], xmlMemUsed() - mem); + nb_leaks++; + err++; + } + } + testErrorsSize = 0; + } + if (result) + free(result); + if (error) + free(error); + } + globfree(&globbuf); + } else { + testErrorsSize = 0; + testErrors[0] = 0; + extraMemoryFromResolver = 0; + res = tst->func(NULL, NULL, NULL, tst->options); + if (res != 0) { + nb_errors++; + err++; + } + } + + xmlCharEncCloseFunc(ebcdicHandler); + xmlCharEncCloseFunc(eucJpHandler); + + return(err); +} + +static int verbose = 0; +static int tests_quiet = 0; + +static int +runtest(int i) { + int ret = 0, res; + int old_errors, old_tests, old_leaks; + + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + if ((tests_quiet == 0) && (testDescriptions[i].desc != NULL)) + printf("## %s\n", testDescriptions[i].desc); + res = launchTests(&testDescriptions[i]); + if (res != 0) + ret++; + if (verbose) { + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + } + return(ret); +} + +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + int i, a, ret = 0; + int subset = 0; + +#if defined(_WIN32) && !defined(__CYGWIN__) + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1900 + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif + + initializeLibxml2(); + + for (a = 1; a < argc;a++) { + if (!strcmp(argv[a], "-v")) + verbose = 1; + else if (!strcmp(argv[a], "-u")) + update_results = 1; + else if (!strcmp(argv[a], "-quiet")) + tests_quiet = 1; + else if (!strcmp(argv[a], "--out")) + temp_directory = argv[++a]; + else { + for (i = 0; testDescriptions[i].func != NULL; i++) { + if (strstr(testDescriptions[i].desc, argv[a])) { + ret += runtest(i); + subset++; + } + } + } + } + if (subset == 0) { + for (i = 0; testDescriptions[i].func != NULL; i++) { + ret += runtest(i); + } + } + if ((nb_errors == 0) && (nb_leaks == 0)) { + ret = 0; + printf("Total %d tests, no errors\n", + nb_tests); + } else { + ret = 1; + printf("Total %d tests, %d errors, %d leaks\n", + nb_tests, nb_errors, nb_leaks); + } + xmlCleanupParser(); + xmlMemoryDump(); + + return(ret); +} + +#else /* ! LIBXML_OUTPUT_ENABLED */ +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + fprintf(stderr, "runtest requires output to be enabled in libxml2\n"); + return(1); +} +#endif diff --git a/src/runxmlconf.c b/src/runxmlconf.c new file mode 100644 index 000000000000..8a37aa8f0475 --- /dev/null +++ b/src/runxmlconf.c @@ -0,0 +1,607 @@ +/* + * runxmlconf.c: C program to run XML W3C conformance testsuites + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#include + +#ifdef LIBXML_XPATH_ENABLED + +#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#endif +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#define LOGFILE "runxmlconf.log" +static FILE *logfile = NULL; +static int verbose = 0; + +#define NB_EXPECTED_ERRORS 15 + + +const char *skipped_tests[] = { +/* http://lists.w3.org/Archives/Public/public-xml-testsuite/2008Jul/0000.html */ + "rmt-ns10-035", + NULL +}; + +/************************************************************************ + * * + * File name and path utilities * + * * + ************************************************************************/ + +static int checkTestFile(const char *filename) { + struct stat buf; + + if (stat(filename, &buf) == -1) + return(0); + +#if defined(_WIN32) && !defined(__CYGWIN__) + if (!(buf.st_mode & _S_IFREG)) + return(0); +#else + if (!S_ISREG(buf.st_mode)) + return(0); +#endif + + return(1); +} + +static xmlChar *composeDir(const xmlChar *dir, const xmlChar *path) { + char buf[500]; + + if (dir == NULL) return(xmlStrdup(path)); + if (path == NULL) return(NULL); + + snprintf(buf, 500, "%s/%s", (const char *) dir, (const char *) path); + return(xmlStrdup((const xmlChar *) buf)); +} + +/************************************************************************ + * * + * Libxml2 specific routines * + * * + ************************************************************************/ + +static int nb_skipped = 0; +static int nb_tests = 0; +static int nb_errors = 0; +static int nb_leaks = 0; + +/* + * We need to trap calls to the resolver to not account memory for the catalog + * and not rely on any external resources. + */ +static xmlParserInputPtr +testExternalEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED, + xmlParserCtxtPtr ctxt) { + xmlParserInputPtr ret; + + ret = xmlNewInputFromFile(ctxt, (const char *) URL); + + return(ret); +} + +/* + * Trapping the error messages at the generic level to grab the equivalent of + * stderr messages on CLI tools. + */ +static char testErrors[32769]; +static int testErrorsSize = 0; +static int nbError = 0; +static int nbFatal = 0; + +static void test_log(const char *msg, ...) { + va_list args; + if (logfile != NULL) { + fprintf(logfile, "\n------------\n"); + va_start(args, msg); + vfprintf(logfile, msg, args); + va_end(args); + fprintf(logfile, "%s", testErrors); + testErrorsSize = 0; testErrors[0] = 0; + } + if (verbose) { + va_start(args, msg); + vfprintf(stderr, msg, args); + va_end(args); + } +} + +static void +testErrorHandler(void *userData ATTRIBUTE_UNUSED, xmlErrorPtr error) { + int res; + + if (testErrorsSize >= 32768) + return; + res = snprintf(&testErrors[testErrorsSize], + 32768 - testErrorsSize, + "%s:%d: %s\n", (error->file ? error->file : "entity"), + error->line, error->message); + if (error->level == XML_ERR_FATAL) + nbFatal++; + else if (error->level == XML_ERR_ERROR) + nbError++; + if (testErrorsSize + res >= 32768) { + /* buffer is full */ + testErrorsSize = 32768; + testErrors[testErrorsSize] = 0; + } else { + testErrorsSize += res; + } + testErrors[testErrorsSize] = 0; +} + +static xmlXPathContextPtr ctxtXPath; + +static void +initializeLibxml2(void) { + xmlGetWarningsDefaultValue = 0; + xmlPedanticParserDefault(0); + + xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); + xmlInitParser(); + xmlSetExternalEntityLoader(testExternalEntityLoader); + ctxtXPath = xmlXPathNewContext(NULL); + /* + * Deactivate the cache if created; otherwise we have to create/free it + * for every test, since it will confuse the memory leak detection. + * Note that normally this need not be done, since the cache is not + * created until set explicitly with xmlXPathContextSetCache(); + * but for test purposes it is sometimes useful to activate the + * cache by default for the whole library. + */ + if (ctxtXPath->cache != NULL) + xmlXPathContextSetCache(ctxtXPath, 0, -1, 0); + xmlSetStructuredErrorFunc(NULL, testErrorHandler); +} + +/************************************************************************ + * * + * Run the xmlconf test if found * + * * + ************************************************************************/ + +static int +xmlconfTestInvalid(const char *id, const char *filename, int options) { + xmlDocPtr doc; + xmlParserCtxtPtr ctxt; + int ret = 1; + + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + test_log("test %s : %s out of memory\n", + id, filename); + return(0); + } + doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + if (doc == NULL) { + test_log("test %s : %s invalid document turned not well-formed too\n", + id, filename); + } else { + /* invalidity should be reported both in the context and in the document */ + if ((ctxt->valid != 0) || (doc->properties & XML_DOC_DTDVALID)) { + test_log("test %s : %s failed to detect invalid document\n", + id, filename); + nb_errors++; + ret = 0; + } + xmlFreeDoc(doc); + } + xmlFreeParserCtxt(ctxt); + return(ret); +} + +static int +xmlconfTestValid(const char *id, const char *filename, int options) { + xmlDocPtr doc; + xmlParserCtxtPtr ctxt; + int ret = 1; + + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + test_log("test %s : %s out of memory\n", + id, filename); + return(0); + } + doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + if (doc == NULL) { + test_log("test %s : %s failed to parse a valid document\n", + id, filename); + nb_errors++; + ret = 0; + } else { + /* validity should be reported both in the context and in the document */ + if ((ctxt->valid == 0) || ((doc->properties & XML_DOC_DTDVALID) == 0)) { + test_log("test %s : %s failed to validate a valid document\n", + id, filename); + nb_errors++; + ret = 0; + } + xmlFreeDoc(doc); + } + xmlFreeParserCtxt(ctxt); + return(ret); +} + +static int +xmlconfTestNotNSWF(const char *id, const char *filename, int options) { + xmlDocPtr doc; + int ret = 1; + + /* + * In case of Namespace errors, libxml2 will still parse the document + * but log a Namespace error. + */ + doc = xmlReadFile(filename, NULL, options); + if (doc == NULL) { + test_log("test %s : %s failed to parse the XML\n", + id, filename); + nb_errors++; + ret = 0; + } else { + if ((xmlLastError.code == XML_ERR_OK) || + (xmlLastError.domain != XML_FROM_NAMESPACE)) { + test_log("test %s : %s failed to detect namespace error\n", + id, filename); + nb_errors++; + ret = 0; + } + xmlFreeDoc(doc); + } + return(ret); +} + +static int +xmlconfTestNotWF(const char *id, const char *filename, int options) { + xmlDocPtr doc; + int ret = 1; + + doc = xmlReadFile(filename, NULL, options); + if (doc != NULL) { + test_log("test %s : %s failed to detect not well formedness\n", + id, filename); + nb_errors++; + xmlFreeDoc(doc); + ret = 0; + } + return(ret); +} + +static int +xmlconfTestItem(xmlDocPtr doc, xmlNodePtr cur) { + int ret = -1; + xmlChar *type = NULL; + xmlChar *filename = NULL; + xmlChar *uri = NULL; + xmlChar *base = NULL; + xmlChar *id = NULL; + xmlChar *rec = NULL; + xmlChar *version = NULL; + xmlChar *entities = NULL; + xmlChar *edition = NULL; + int options = 0; + int nstest = 0; + int mem, final; + int i; + + testErrorsSize = 0; testErrors[0] = 0; + nbError = 0; + nbFatal = 0; + id = xmlGetProp(cur, BAD_CAST "ID"); + if (id == NULL) { + test_log("test missing ID, line %ld\n", xmlGetLineNo(cur)); + goto error; + } + for (i = 0;skipped_tests[i] != NULL;i++) { + if (!strcmp(skipped_tests[i], (char *) id)) { + test_log("Skipping test %s from skipped list\n", (char *) id); + ret = 0; + nb_skipped++; + goto error; + } + } + type = xmlGetProp(cur, BAD_CAST "TYPE"); + if (type == NULL) { + test_log("test %s missing TYPE\n", (char *) id); + goto error; + } + uri = xmlGetProp(cur, BAD_CAST "URI"); + if (uri == NULL) { + test_log("test %s missing URI\n", (char *) id); + goto error; + } + base = xmlNodeGetBase(doc, cur); + filename = composeDir(base, uri); + if (!checkTestFile((char *) filename)) { + test_log("test %s missing file %s \n", id, + (filename ? (char *)filename : "NULL")); + goto error; + } + + version = xmlGetProp(cur, BAD_CAST "VERSION"); + + entities = xmlGetProp(cur, BAD_CAST "ENTITIES"); + if (!xmlStrEqual(entities, BAD_CAST "none")) { + options |= XML_PARSE_DTDLOAD; + options |= XML_PARSE_NOENT; + } + rec = xmlGetProp(cur, BAD_CAST "RECOMMENDATION"); + if ((rec == NULL) || + (xmlStrEqual(rec, BAD_CAST "XML1.0")) || + (xmlStrEqual(rec, BAD_CAST "XML1.0-errata2e")) || + (xmlStrEqual(rec, BAD_CAST "XML1.0-errata3e")) || + (xmlStrEqual(rec, BAD_CAST "XML1.0-errata4e"))) { + if ((version != NULL) && (!xmlStrEqual(version, BAD_CAST "1.0"))) { + test_log("Skipping test %s for %s\n", (char *) id, + (char *) version); + ret = 0; + nb_skipped++; + goto error; + } + ret = 1; + } else if ((xmlStrEqual(rec, BAD_CAST "NS1.0")) || + (xmlStrEqual(rec, BAD_CAST "NS1.0-errata1e"))) { + ret = 1; + nstest = 1; + } else { + test_log("Skipping test %s for REC %s\n", (char *) id, (char *) rec); + ret = 0; + nb_skipped++; + goto error; + } + edition = xmlGetProp(cur, BAD_CAST "EDITION"); + if ((edition != NULL) && (xmlStrchr(edition, '5') == NULL)) { + /* test limited to all versions before 5th */ + options |= XML_PARSE_OLD10; + } + + /* + * Reset errors and check memory usage before the test + */ + xmlResetLastError(); + testErrorsSize = 0; testErrors[0] = 0; + mem = xmlMemUsed(); + + if (xmlStrEqual(type, BAD_CAST "not-wf")) { + if (nstest == 0) + xmlconfTestNotWF((char *) id, (char *) filename, options); + else + xmlconfTestNotNSWF((char *) id, (char *) filename, options); + } else if (xmlStrEqual(type, BAD_CAST "valid")) { + options |= XML_PARSE_DTDVALID; + xmlconfTestValid((char *) id, (char *) filename, options); + } else if (xmlStrEqual(type, BAD_CAST "invalid")) { + options |= XML_PARSE_DTDVALID; + xmlconfTestInvalid((char *) id, (char *) filename, options); + } else if (xmlStrEqual(type, BAD_CAST "error")) { + test_log("Skipping error test %s \n", (char *) id); + ret = 0; + nb_skipped++; + goto error; + } else { + test_log("test %s unknown TYPE value %s\n", (char *) id, (char *)type); + ret = -1; + goto error; + } + + /* + * Reset errors and check memory usage after the test + */ + xmlResetLastError(); + final = xmlMemUsed(); + if (final > mem) { + test_log("test %s : %s leaked %d bytes\n", + id, filename, final - mem); + nb_leaks++; + xmlMemDisplayLast(logfile, final - mem); + } + nb_tests++; + +error: + if (type != NULL) + xmlFree(type); + if (entities != NULL) + xmlFree(entities); + if (edition != NULL) + xmlFree(edition); + if (version != NULL) + xmlFree(version); + if (filename != NULL) + xmlFree(filename); + if (uri != NULL) + xmlFree(uri); + if (base != NULL) + xmlFree(base); + if (id != NULL) + xmlFree(id); + if (rec != NULL) + xmlFree(rec); + return(ret); +} + +static int +xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur, int level) { + xmlChar *profile; + int ret = 0; + int tests = 0; + int output = 0; + + if (level == 1) { + profile = xmlGetProp(cur, BAD_CAST "PROFILE"); + if (profile != NULL) { + output = 1; + level++; + printf("Test cases: %s\n", (char *) profile); + xmlFree(profile); + } + } + cur = cur->children; + while (cur != NULL) { + /* look only at elements we ignore everything else */ + if (cur->type == XML_ELEMENT_NODE) { + if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) { + ret += xmlconfTestCases(doc, cur, level); + } else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) { + if (xmlconfTestItem(doc, cur) >= 0) + ret++; + tests++; + } else { + fprintf(stderr, "Unhandled element %s\n", (char *)cur->name); + } + } + cur = cur->next; + } + if (output == 1) { + if (tests > 0) + printf("Test cases: %d tests\n", tests); + } + return(ret); +} + +static int +xmlconfTestSuite(xmlDocPtr doc, xmlNodePtr cur) { + xmlChar *profile; + int ret = 0; + + profile = xmlGetProp(cur, BAD_CAST "PROFILE"); + if (profile != NULL) { + printf("Test suite: %s\n", (char *) profile); + xmlFree(profile); + } else + printf("Test suite\n"); + cur = cur->children; + while (cur != NULL) { + /* look only at elements we ignore everything else */ + if (cur->type == XML_ELEMENT_NODE) { + if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) { + ret += xmlconfTestCases(doc, cur, 1); + } else { + fprintf(stderr, "Unhandled element %s\n", (char *)cur->name); + } + } + cur = cur->next; + } + return(ret); +} + +static void +xmlconfInfo(void) { + fprintf(stderr, " you need to fetch and extract the\n"); + fprintf(stderr, " latest XML Conformance Test Suites\n"); + fprintf(stderr, " http://www.w3.org/XML/Test/xmlts20080827.tar.gz\n"); + fprintf(stderr, " see http://www.w3.org/XML/Test/ for information\n"); +} + +static int +xmlconfTest(void) { + const char *confxml = "xmlconf/xmlconf.xml"; + xmlDocPtr doc; + xmlNodePtr cur; + int ret = 0; + + if (!checkTestFile(confxml)) { + fprintf(stderr, "%s is missing \n", confxml); + xmlconfInfo(); + return(-1); + } + doc = xmlReadFile(confxml, NULL, XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "%s is corrupted \n", confxml); + xmlconfInfo(); + return(-1); + } + + cur = xmlDocGetRootElement(doc); + if ((cur == NULL) || (!xmlStrEqual(cur->name, BAD_CAST "TESTSUITE"))) { + fprintf(stderr, "Unexpected format %s\n", confxml); + xmlconfInfo(); + ret = -1; + } else { + ret = xmlconfTestSuite(doc, cur); + } + xmlFreeDoc(doc); + return(ret); +} + +/************************************************************************ + * * + * The driver for the tests * + * * + ************************************************************************/ + +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + int ret = 0; + int old_errors, old_tests, old_leaks; + + logfile = fopen(LOGFILE, "w"); + if (logfile == NULL) { + fprintf(stderr, + "Could not open the log file, running in verbose mode\n"); + verbose = 1; + } + initializeLibxml2(); + + if ((argc >= 2) && (!strcmp(argv[1], "-v"))) + verbose = 1; + + + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + xmlconfTest(); + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + if ((nb_errors == 0) && (nb_leaks == 0)) { + ret = 0; + printf("Total %d tests, no errors\n", + nb_tests); + } else { + ret = 1; + printf("Total %d tests, %d errors, %d leaks\n", + nb_tests, nb_errors, nb_leaks); + printf("See %s for detailed output\n", LOGFILE); + if ((nb_leaks == 0) && (nb_errors == NB_EXPECTED_ERRORS)) { + printf("%d errors were expected\n", nb_errors); + ret = 0; + } + } + xmlXPathFreeContext(ctxtXPath); + xmlCleanupParser(); + xmlMemoryDump(); + + if (logfile != NULL) + fclose(logfile); + return(ret); +} + +#else /* ! LIBXML_XPATH_ENABLED */ +#include +int +main(int argc, char **argv) { + fprintf(stderr, "%s need XPath support\n", argv[0]); +} +#endif diff --git a/src/save.h b/src/save.h new file mode 100644 index 000000000000..192b67413358 --- /dev/null +++ b/src/save.h @@ -0,0 +1,36 @@ +/* + * Summary: Internal Interfaces for saving in libxml2 + * Description: this module describes a few interfaces which were + * added along with the API changes in 2.9.0 + * those are private routines at this point + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_SAVE_H__ +#define __XML_SAVE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LIBXML_OUTPUT_ENABLED +void xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc, + xmlAttrPtr attr, const xmlChar * string); +void xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table); +void xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem); +void xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr); +void xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent); +#endif + +xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_SAVE_H__ */ + diff --git a/src/testAutomata.c b/src/testAutomata.c new file mode 100644 index 000000000000..13213c69c039 --- /dev/null +++ b/src/testAutomata.c @@ -0,0 +1,309 @@ +/* + * testAutomata.c: simple module for testing regexp automata + * + * See Copyright for the status of this software. + * + * Daniel Veillard + */ + +#include "libxml.h" +#ifdef LIBXML_AUTOMATA_ENABLED +#include + +#include +#include + +static int scanNumber(char **ptr) { + int ret = 0; + char *cur; + + cur = *ptr; + while ((*cur >= '0') && (*cur <= '9')) { + ret = ret * 10 + (*cur - '0'); + cur++; + } + *ptr = cur; + return(ret); +} + +static void +testRegexpFile(const char *filename) { + FILE *input; + char expr[5000]; + int len; + int ret; + int i; + xmlAutomataPtr am; + xmlAutomataStatePtr states[1000]; + xmlRegexpPtr regexp = NULL; + xmlRegExecCtxtPtr exec = NULL; + + for (i = 0;i<1000;i++) + states[i] = NULL; + + input = fopen(filename, "r"); + if (input == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot open %s for reading\n", filename); + return; + } + + am = xmlNewAutomata(); + if (am == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot create automata\n"); + fclose(input); + return; + } + states[0] = xmlAutomataGetInitState(am); + if (states[0] == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot get start state\n"); + xmlFreeAutomata(am); + fclose(input); + return; + } + ret = 0; + + while (fgets(expr, 4500, input) != NULL) { + if (expr[0] == '#') + continue; + len = strlen(expr); + len--; + while ((len >= 0) && + ((expr[len] == '\n') || (expr[len] == '\t') || + (expr[len] == '\r') || (expr[len] == ' '))) len--; + expr[len + 1] = 0; + if (len >= 0) { + if ((am != NULL) && (expr[0] == 't') && (expr[1] == ' ')) { + char *ptr = &expr[2]; + int from, to; + + from = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + if (states[from] == NULL) + states[from] = xmlAutomataNewState(am); + ptr++; + to = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + if (states[to] == NULL) + states[to] = xmlAutomataNewState(am); + ptr++; + xmlAutomataNewTransition(am, states[from], states[to], + BAD_CAST ptr, NULL); + } else if ((am != NULL) && (expr[0] == 'e') && (expr[1] == ' ')) { + char *ptr = &expr[2]; + int from, to; + + from = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + if (states[from] == NULL) + states[from] = xmlAutomataNewState(am); + ptr++; + to = scanNumber(&ptr); + if (states[to] == NULL) + states[to] = xmlAutomataNewState(am); + xmlAutomataNewEpsilon(am, states[from], states[to]); + } else if ((am != NULL) && (expr[0] == 'f') && (expr[1] == ' ')) { + char *ptr = &expr[2]; + int state; + + state = scanNumber(&ptr); + if (states[state] == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Bad state %d : %s\n", state, expr); + break; + } + xmlAutomataSetFinalState(am, states[state]); + } else if ((am != NULL) && (expr[0] == 'c') && (expr[1] == ' ')) { + char *ptr = &expr[2]; + int from, to; + int min, max; + + from = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + if (states[from] == NULL) + states[from] = xmlAutomataNewState(am); + ptr++; + to = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + if (states[to] == NULL) + states[to] = xmlAutomataNewState(am); + ptr++; + min = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + ptr++; + max = scanNumber(&ptr); + if (*ptr != ' ') { + xmlGenericError(xmlGenericErrorContext, + "Bad line %s\n", expr); + break; + } + ptr++; + xmlAutomataNewCountTrans(am, states[from], states[to], + BAD_CAST ptr, min, max, NULL); + } else if ((am != NULL) && (expr[0] == '-') && (expr[1] == '-')) { + /* end of the automata */ + regexp = xmlAutomataCompile(am); + xmlFreeAutomata(am); + am = NULL; + if (regexp == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Failed to compile the automata"); + break; + } + } else if ((expr[0] == '=') && (expr[1] == '>')) { + if (regexp == NULL) { + printf("=> failed not compiled\n"); + } else { + if (exec == NULL) + exec = xmlRegNewExecCtxt(regexp, NULL, NULL); + if (ret == 0) { + ret = xmlRegExecPushString(exec, NULL, NULL); + } + if (ret == 1) + printf("=> Passed\n"); + else if ((ret == 0) || (ret == -1)) + printf("=> Failed\n"); + else if (ret < 0) + printf("=> Error\n"); + xmlRegFreeExecCtxt(exec); + exec = NULL; + } + ret = 0; + } else if (regexp != NULL) { + if (exec == NULL) + exec = xmlRegNewExecCtxt(regexp, NULL, NULL); + ret = xmlRegExecPushString(exec, BAD_CAST expr, NULL); + } else { + xmlGenericError(xmlGenericErrorContext, + "Unexpected line %s\n", expr); + } + } + } + fclose(input); + if (regexp != NULL) + xmlRegFreeRegexp(regexp); + if (exec != NULL) + xmlRegFreeExecCtxt(exec); + if (am != NULL) + xmlFreeAutomata(am); +} + +int main(int argc, char **argv) { + + xmlInitMemory(); + + if (argc == 1) { + int ret; + xmlAutomataPtr am; + xmlAutomataStatePtr start, cur; + xmlRegexpPtr regexp; + xmlRegExecCtxtPtr exec; + + am = xmlNewAutomata(); + start = xmlAutomataGetInitState(am); + + /* generate a[ba]*a */ + cur = xmlAutomataNewTransition(am, start, NULL, BAD_CAST"a", NULL); + xmlAutomataNewTransition(am, cur, cur, BAD_CAST"b", NULL); + xmlAutomataNewTransition(am, cur, cur, BAD_CAST"a", NULL); + cur = xmlAutomataNewCountTrans(am, cur, NULL, BAD_CAST"a", 2, 3, NULL); + xmlAutomataSetFinalState(am, cur); + + /* compile it in a regexp and free the automata */ + regexp = xmlAutomataCompile(am); + xmlFreeAutomata(am); + + /* test the regexp */ + xmlRegexpPrint(stdout, regexp); + exec = xmlRegNewExecCtxt(regexp, NULL, NULL); + ret = xmlRegExecPushString(exec, BAD_CAST"a", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + ret =xmlRegExecPushString(exec, BAD_CAST"b", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + ret =xmlRegExecPushString(exec, BAD_CAST"a", NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + if (ret == 0) { + ret = xmlRegExecPushString(exec, NULL, NULL); + if (ret == 1) + printf("final\n"); + else if (ret < 0) + printf("error\n"); + } + xmlRegFreeExecCtxt(exec); + + /* free the regexp */ + xmlRegFreeRegexp(regexp); + } else { + int i; + + for (i = 1;i < argc;i++) + testRegexpFile(argv[i]); + } + + xmlCleanupParser(); + xmlMemoryDump(); + return(0); +} + +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : Automata support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_AUTOMATA_ENABLED */ diff --git a/src/testC14N.c b/src/testC14N.c new file mode 100644 index 000000000000..addc800e0be7 --- /dev/null +++ b/src/testC14N.c @@ -0,0 +1,373 @@ +/* + * Canonical XML implementation test program + * (http://www.w3.org/TR/2001/REC-xml-c14n-20010315) + * + * See Copyright for the status of this software. + * + * Author: Aleksey Sanin + */ +#include "libxml.h" +#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + +#include +#include +#ifndef STDOUT_FILENO +#ifdef HAVE_UNISTD_H +#include +#else +#define STDOUT_FILENO fileno(stdout) +#endif /* HAVE_UNISTD_H */ +#endif +#ifdef _WIN32 +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif + +#include +#include +#include +#include + +#include + + +static void usage(const char *name) { + fprintf(stderr, + "Usage: %s [] []\n", + name); + fprintf(stderr, "where is one of following:\n"); + fprintf(stderr, + "--with-comments \t XML file canonicalization v1.0 w comments \n"); + fprintf(stderr, + "--without-comments \t XML file canonicalization v1.0 w/o comments\n"); + fprintf(stderr, + "--1-1-with-comments \t XML file canonicalization v1.1 w comments\n"); + fprintf(stderr, + "--1-1-without-comments \t XML file canonicalization v1.1 w/o comments\n"); + fprintf(stderr, + "--exc-with-comments \t Exclusive XML file canonicalization v1.0 w comments\n"); + fprintf(stderr, + "--exc-without-comments\t Exclusive XML file canonicalization v1.0 w/o comments\n"); +} + +static xmlXPathObjectPtr +load_xpath_expr (xmlDocPtr parent_doc, const char* filename); + +static xmlChar **parse_list(xmlChar *str); + +/* static void print_xpath_nodes(xmlNodeSetPtr nodes); */ + +static int +test_c14n(const char* xml_filename, int with_comments, int mode, + const char* xpath_filename, xmlChar **inclusive_namespaces) { + xmlDocPtr doc; + xmlXPathObjectPtr xpath = NULL; + xmlChar *result = NULL; + int ret; + + /* + * build an XML tree from a the file; we need to add default + * attributes and resolve all character and entities references + */ + xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + xmlSubstituteEntitiesDefault(1); + + doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename); + return(-1); + } + + /* + * Check the document is of the right kind + */ + if(xmlDocGetRootElement(doc) == NULL) { + fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename); + xmlFreeDoc(doc); + return(-1); + } + + /* + * load xpath file if specified + */ + if(xpath_filename) { + xpath = load_xpath_expr(doc, xpath_filename); + if(xpath == NULL) { + fprintf(stderr,"Error: unable to evaluate xpath expression\n"); + xmlFreeDoc(doc); + return(-1); + } + } + + /* + * Canonical form + */ + /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */ + ret = xmlC14NDocDumpMemory(doc, + (xpath) ? xpath->nodesetval : NULL, + mode, inclusive_namespaces, + with_comments, &result); + if(ret >= 0) { + if(result != NULL) { + if (write(STDOUT_FILENO, result, ret) == -1) { + fprintf(stderr, "Can't write data\n"); + } + xmlFree(result); + } + } else { + fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret); + if(result != NULL) xmlFree(result); + xmlFreeDoc(doc); + return(-1); + } + + /* + * Cleanup + */ + if(xpath != NULL) xmlXPathFreeObject(xpath); + xmlFreeDoc(doc); + + return(ret); +} + +int main(int argc, char **argv) { + int ret = -1; + + /* + * Init libxml + */ + xmlInitParser(); + LIBXML_TEST_VERSION + + /* + * Parse command line and process file + */ + if( argc < 3 ) { + fprintf(stderr, "Error: wrong number of arguments.\n"); + usage(argv[0]); + } else if(strcmp(argv[1], "--with-comments") == 0) { + ret = test_c14n(argv[2], 1, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL); + } else if(strcmp(argv[1], "--without-comments") == 0) { + ret = test_c14n(argv[2], 0, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL); + } else if(strcmp(argv[1], "--1-1-with-comments") == 0) { + ret = test_c14n(argv[2], 1, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL); + } else if(strcmp(argv[1], "--1-1-without-comments") == 0) { + ret = test_c14n(argv[2], 0, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL); + } else if(strcmp(argv[1], "--exc-with-comments") == 0) { + xmlChar **list; + + /* load exclusive namespace from command line */ + list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL; + ret = test_c14n(argv[2], 1, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list); + if(list != NULL) xmlFree(list); + } else if(strcmp(argv[1], "--exc-without-comments") == 0) { + xmlChar **list; + + /* load exclusive namespace from command line */ + list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL; + ret = test_c14n(argv[2], 0, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list); + if(list != NULL) xmlFree(list); + } else { + fprintf(stderr, "Error: bad option.\n"); + usage(argv[0]); + } + + /* + * Shutdown libxml + */ + xmlCleanupParser(); + xmlMemoryDump(); + + return((ret >= 0) ? 0 : 1); +} + +/* + * Macro used to grow the current buffer. + */ +#define growBufferReentrant() { \ + buffer_size *= 2; \ + buffer = (xmlChar **) \ + xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \ + if (buffer == NULL) { \ + perror("realloc failed"); \ + return(NULL); \ + } \ +} + +static xmlChar ** +parse_list(xmlChar *str) { + xmlChar **buffer; + xmlChar **out = NULL; + int buffer_size = 0; + int len; + + if(str == NULL) { + return(NULL); + } + + len = xmlStrlen(str); + if((str[0] == '\'') && (str[len - 1] == '\'')) { + str[len - 1] = '\0'; + str++; + } + /* + * allocate an translation buffer. + */ + buffer_size = 1000; + buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*)); + if (buffer == NULL) { + perror("malloc failed"); + return(NULL); + } + out = buffer; + + while(*str != '\0') { + if (out - buffer > buffer_size - 10) { + int indx = out - buffer; + + growBufferReentrant(); + out = &buffer[indx]; + } + (*out++) = str; + while(*str != ',' && *str != '\0') ++str; + if(*str == ',') *(str++) = '\0'; + } + (*out) = NULL; + return buffer; +} + +static xmlXPathObjectPtr +load_xpath_expr (xmlDocPtr parent_doc, const char* filename) { + xmlXPathObjectPtr xpath; + xmlDocPtr doc; + xmlChar *expr; + xmlXPathContextPtr ctx; + xmlNodePtr node; + xmlNsPtr ns; + + /* + * load XPath expr as a file + */ + xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + xmlSubstituteEntitiesDefault(1); + + doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); + if (doc == NULL) { + fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); + return(NULL); + } + + /* + * Check the document is of the right kind + */ + if(xmlDocGetRootElement(doc) == NULL) { + fprintf(stderr,"Error: empty document for file \"%s\"\n", filename); + xmlFreeDoc(doc); + return(NULL); + } + + node = doc->children; + while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) { + node = node->next; + } + + if(node == NULL) { + fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", filename); + xmlFreeDoc(doc); + return(NULL); + } + + expr = xmlNodeGetContent(node); + if(expr == NULL) { + fprintf(stderr,"Error: XPath content element is NULL \"%s\"\n", filename); + xmlFreeDoc(doc); + return(NULL); + } + + ctx = xmlXPathNewContext(parent_doc); + if(ctx == NULL) { + fprintf(stderr,"Error: unable to create new context\n"); + xmlFree(expr); + xmlFreeDoc(doc); + return(NULL); + } + + /* + * Register namespaces + */ + ns = node->nsDef; + while(ns != NULL) { + if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) { + fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href); + xmlFree(expr); + xmlXPathFreeContext(ctx); + xmlFreeDoc(doc); + return(NULL); + } + ns = ns->next; + } + + /* + * Evaluate xpath + */ + xpath = xmlXPathEvalExpression(expr, ctx); + if(xpath == NULL) { + fprintf(stderr,"Error: unable to evaluate xpath expression\n"); + xmlFree(expr); + xmlXPathFreeContext(ctx); + xmlFreeDoc(doc); + return(NULL); + } + + /* print_xpath_nodes(xpath->nodesetval); */ + + xmlFree(expr); + xmlXPathFreeContext(ctx); + xmlFreeDoc(doc); + return(xpath); +} + +/* +static void +print_xpath_nodes(xmlNodeSetPtr nodes) { + xmlNodePtr cur; + int i; + + if(nodes == NULL ){ + fprintf(stderr, "Error: no nodes set defined\n"); + return; + } + + fprintf(stderr, "Nodes Set:\n-----\n"); + for(i = 0; i < nodes->nodeNr; ++i) { + if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) { + xmlNsPtr ns; + + ns = (xmlNsPtr)nodes->nodeTab[i]; + cur = (xmlNodePtr)ns->next; + fprintf(stderr, "namespace \"%s\"=\"%s\" for node %s:%s\n", + ns->prefix, ns->href, + (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name); + } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) { + cur = nodes->nodeTab[i]; + fprintf(stderr, "element node \"%s:%s\"\n", + (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name); + } else { + cur = nodes->nodeTab[i]; + fprintf(stderr, "node \"%s\": type %d\n", cur->name, cur->type); + } + } +} +*/ + +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : XPath/Canonicalization and output support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_C14N_ENABLED */ + + diff --git a/src/testHTML.c b/src/testHTML.c new file mode 100644 index 000000000000..9b42778c80d5 --- /dev/null +++ b/src/testHTML.c @@ -0,0 +1,880 @@ +/* + * testHTML.c : a small tester program for HTML input. + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" + +#ifdef LIBXML_HTML_ENABLED + +#include +#include + + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED +static int debug = 0; +#endif +static int copy = 0; +static int sax = 0; +static int repeat = 0; +static int noout = 0; +#ifdef LIBXML_PUSH_ENABLED +static int push = 0; +#endif /* LIBXML_PUSH_ENABLED */ +static char *encoding = NULL; +static int options = 0; + +static xmlSAXHandler emptySAXHandlerStruct = { + NULL, /* internalSubset */ + NULL, /* isStandalone */ + NULL, /* hasInternalSubset */ + NULL, /* hasExternalSubset */ + NULL, /* resolveEntity */ + NULL, /* getEntity */ + NULL, /* entityDecl */ + NULL, /* notationDecl */ + NULL, /* attributeDecl */ + NULL, /* elementDecl */ + NULL, /* unparsedEntityDecl */ + NULL, /* setDocumentLocator */ + NULL, /* startDocument */ + NULL, /* endDocument */ + NULL, /* startElement */ + NULL, /* endElement */ + NULL, /* reference */ + NULL, /* characters */ + NULL, /* ignorableWhitespace */ + NULL, /* processingInstruction */ + NULL, /* comment */ + NULL, /* xmlParserWarning */ + NULL, /* xmlParserError */ + NULL, /* xmlParserError */ + NULL, /* getParameterEntity */ + NULL, /* cdataBlock */ + NULL, /* externalSubset */ + 1, /* initialized */ + NULL, /* private */ + NULL, /* startElementNsSAX2Func */ + NULL, /* endElementNsSAX2Func */ + NULL /* xmlStructuredErrorFunc */ +}; + +static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; +extern xmlSAXHandlerPtr debugSAXHandler; + +/************************************************************************ + * * + * Debug Handlers * + * * + ************************************************************************/ + +/** + * isStandaloneDebug: + * @ctxt: An XML parser context + * + * Is this document tagged standalone ? + * + * Returns 1 if true + */ +static int +isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.isStandalone()\n"); + return(0); +} + +/** + * hasInternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + * + * Returns 1 if true + */ +static int +hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.hasInternalSubset()\n"); + return(0); +} + +/** + * hasExternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an external subset + * + * Returns 1 if true + */ +static int +hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.hasExternalSubset()\n"); + return(0); +} + +/** + * hasInternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + */ +static void +internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) +{ + fprintf(stdout, "SAX.internalSubset(%s,", name); + if (ExternalID == NULL) + fprintf(stdout, " ,"); + else + fprintf(stdout, " %s,", ExternalID); + if (SystemID == NULL) + fprintf(stdout, " )\n"); + else + fprintf(stdout, " %s)\n", SystemID); +} + +/** + * resolveEntityDebug: + * @ctxt: An XML parser context + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Special entity resolver, better left to the parser, it has + * more context than the application layer. + * The default behaviour is to NOT resolve the entities, in that case + * the ENTITY_REF nodes are built in the structure (and the parameter + * values). + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlParserInputPtr +resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) +{ + /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ + + + fprintf(stdout, "SAX.resolveEntity("); + if (publicId != NULL) + fprintf(stdout, "%s", (char *)publicId); + else + fprintf(stdout, " "); + if (systemId != NULL) + fprintf(stdout, ", %s)\n", (char *)systemId); + else + fprintf(stdout, ", )\n"); +/********* + if (systemId != NULL) { + return(xmlNewInputFromFile(ctxt, (char *) systemId)); + } + *********/ + return(NULL); +} + +/** + * getEntityDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get an entity by name + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlEntityPtr +getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + fprintf(stdout, "SAX.getEntity(%s)\n", name); + return(NULL); +} + +/** + * getParameterEntityDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get a parameter entity by name + * + * Returns the xmlParserInputPtr + */ +static xmlEntityPtr +getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); + return(NULL); +} + + +/** + * entityDeclDebug: + * @ctxt: An XML parser context + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed + */ +static void +entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, + const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) +{ + fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", + name, type, publicId, systemId, content); +} + +/** + * attributeDeclDebug: + * @ctxt: An XML parser context + * @name: the attribute name + * @type: the attribute type + * + * An attribute definition has been parsed + */ +static void +attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *elem, const xmlChar *name, + int type, int def, const xmlChar *defaultValue, + xmlEnumerationPtr tree ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", + elem, name, type, def, defaultValue); +} + +/** + * elementDeclDebug: + * @ctxt: An XML parser context + * @name: the element name + * @type: the element type + * @content: the element value (without processing). + * + * An element definition has been parsed + */ +static void +elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, + xmlElementContentPtr content ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", + name, type); +} + +/** + * notationDeclDebug: + * @ctxt: An XML parser context + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +static void +notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *publicId, const xmlChar *systemId) +{ + fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", + (char *) name, (char *) publicId, (char *) systemId); +} + +/** + * unparsedEntityDeclDebug: + * @ctxt: An XML parser context + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed + */ +static void +unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *publicId, const xmlChar *systemId, + const xmlChar *notationName) +{ + fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", + (char *) name, (char *) publicId, (char *) systemId, + (char *) notationName); +} + +/** + * setDocumentLocatorDebug: + * @ctxt: An XML parser context + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator + * Everything is available on the context, so this is useless in our case. + */ +static void +setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.setDocumentLocator()\n"); +} + +/** + * startDocumentDebug: + * @ctxt: An XML parser context + * + * called when the document start being processed. + */ +static void +startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.startDocument()\n"); +} + +/** + * endDocumentDebug: + * @ctxt: An XML parser context + * + * called when the document end has been detected. + */ +static void +endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) +{ + fprintf(stdout, "SAX.endDocument()\n"); +} + +/** + * startElementDebug: + * @ctxt: An XML parser context + * @name: The element name + * + * called when an opening tag has been processed. + */ +static void +startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) +{ + int i; + + fprintf(stdout, "SAX.startElement(%s", (char *) name); + if (atts != NULL) { + for (i = 0;(atts[i] != NULL);i++) { + fprintf(stdout, ", %s", atts[i++]); + if (atts[i] != NULL) { + unsigned char output[40]; + const unsigned char *att = atts[i]; + int outlen, attlen; + fprintf(stdout, "='"); + while ((attlen = strlen((char*)att)) > 0) { + outlen = sizeof output - 1; + htmlEncodeEntities(output, &outlen, att, &attlen, '\''); + output[outlen] = 0; + fprintf(stdout, "%s", (char *) output); + att += attlen; + } + fprintf(stdout, "'"); + } + } + } + fprintf(stdout, ")\n"); +} + +/** + * endElementDebug: + * @ctxt: An XML parser context + * @name: The element name + * + * called when the end of an element has been detected. + */ +static void +endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); +} + +/** + * charactersDebug: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * receiving some chars from the parser. + * Question: how much at a time ??? + */ +static void +charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) +{ + unsigned char output[40]; + int inlen = len, outlen = 30; + + htmlEncodeEntities(output, &outlen, ch, &inlen, 0); + output[outlen] = 0; + + fprintf(stdout, "SAX.characters(%s, %d)\n", output, len); +} + +/** + * cdataDebug: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * receiving some cdata chars from the parser. + * Question: how much at a time ??? + */ +static void +cdataDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) +{ + unsigned char output[40]; + int inlen = len, outlen = 30; + + htmlEncodeEntities(output, &outlen, ch, &inlen, 0); + output[outlen] = 0; + + fprintf(stdout, "SAX.cdata(%s, %d)\n", output, len); +} + +/** + * referenceDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * called when an entity reference is detected. + */ +static void +referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + fprintf(stdout, "SAX.reference(%s)\n", name); +} + +/** + * ignorableWhitespaceDebug: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @start: the first char in the string + * @len: the number of xmlChar + * + * receiving some ignorable whitespaces from the parser. + * Question: how much at a time ??? + */ +static void +ignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) +{ + char output[40]; + int i; + + for (i = 0;(i 0) { + ctxt = htmlCreatePushParserCtxt(emptySAXHandler, NULL, + chars, res, filename, XML_CHAR_ENCODING_NONE); + while ((res = fread(chars, 1, size, f)) > 0) { + htmlParseChunk(ctxt, chars, res, 0); + } + htmlParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + htmlFreeParserCtxt(ctxt); + } + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + fclose(f); + } + if (!noout) { +#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) + f = fopen(filename, "rb"); +#else + f = fopen(filename, "r"); +#endif + if (f != NULL) { + int res, size = 3; + char chars[4096]; + htmlParserCtxtPtr ctxt; + + /* if (repeat) */ + size = 4096; + res = fread(chars, 1, 4, f); + if (res > 0) { + ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL, + chars, res, filename, XML_CHAR_ENCODING_NONE); + while ((res = fread(chars, 1, size, f)) > 0) { + htmlParseChunk(ctxt, chars, res, 0); + } + htmlParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + htmlFreeParserCtxt(ctxt); + } + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + fclose(f); + } + } + } else { +#endif /* LIBXML_PUSH_ENABLED */ + doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL); + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + + if (!noout) { + /* + * Debug callback + */ + doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL); + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + } +#ifdef LIBXML_PUSH_ENABLED + } +#endif /* LIBXML_PUSH_ENABLED */ +} + +static void +parseAndPrintFile(char *filename) { + htmlDocPtr doc = NULL; + + /* + * build an HTML tree from a string; + */ +#ifdef LIBXML_PUSH_ENABLED + if (push) { + FILE *f; + +#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) + f = fopen(filename, "rb"); +#else + f = fopen(filename, "r"); +#endif + if (f != NULL) { + int res, size = 3; + char chars[4096]; + htmlParserCtxtPtr ctxt; + + /* if (repeat) */ + size = 4096; + res = fread(chars, 1, 4, f); + if (res > 0) { + ctxt = htmlCreatePushParserCtxt(NULL, NULL, + chars, res, filename, XML_CHAR_ENCODING_NONE); + while ((res = fread(chars, 1, size, f)) > 0) { + htmlParseChunk(ctxt, chars, res, 0); + } + htmlParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + htmlFreeParserCtxt(ctxt); + } + fclose(f); + } + } else { + doc = htmlReadFile(filename, NULL, options); + } +#else + doc = htmlReadFile(filename,NULL,options); +#endif + if (doc == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Could not parse %s\n", filename); + } + +#ifdef LIBXML_TREE_ENABLED + /* + * test intermediate copy if needed. + */ + if (copy) { + htmlDocPtr tmp; + + tmp = doc; + doc = xmlCopyDoc(doc, 1); + xmlFreeDoc(tmp); + } +#endif + +#ifdef LIBXML_OUTPUT_ENABLED + /* + * print it. + */ + if (!noout) { +#ifdef LIBXML_DEBUG_ENABLED + if (!debug) { + if (encoding) + htmlSaveFileEnc("-", doc, encoding); + else + htmlDocDump(stdout, doc); + } else + xmlDebugDumpDocument(stdout, doc); +#else + if (encoding) + htmlSaveFileEnc("-", doc, encoding); + else + htmlDocDump(stdout, doc); +#endif + } +#endif /* LIBXML_OUTPUT_ENABLED */ + + /* + * free it. + */ + xmlFreeDoc(doc); +} + +int main(int argc, char **argv) { + int i, count; + int files = 0; + + for (i = 1; i < argc ; i++) { +#ifdef LIBXML_DEBUG_ENABLED + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) + debug++; + else +#endif + if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) + copy++; +#ifdef LIBXML_PUSH_ENABLED + else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push"))) + push++; +#endif /* LIBXML_PUSH_ENABLED */ + else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax"))) + sax++; + else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) + noout++; + else if ((!strcmp(argv[i], "-repeat")) || + (!strcmp(argv[i], "--repeat"))) + repeat++; + else if ((!strcmp(argv[i], "-encode")) || + (!strcmp(argv[i], "--encode"))) { + i++; + encoding = argv[i]; + } + } + for (i = 1; i < argc ; i++) { + if ((!strcmp(argv[i], "-encode")) || + (!strcmp(argv[i], "--encode"))) { + i++; + continue; + } + if (argv[i][0] != '-') { + if (repeat) { + for (count = 0;count < 100 * repeat;count++) { + if (sax) + parseSAXFile(argv[i]); + else + parseAndPrintFile(argv[i]); + } + } else { + if (sax) + parseSAXFile(argv[i]); + else + parseAndPrintFile(argv[i]); + } + files ++; + } + } + if (files == 0) { + printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n", + argv[0]); + printf("\tParse the HTML files and output the result of the parsing\n"); +#ifdef LIBXML_DEBUG_ENABLED + printf("\t--debug : dump a debug tree of the in-memory document\n"); +#endif + printf("\t--copy : used to test the internal copy implementation\n"); + printf("\t--sax : debug the sequence of SAX callbacks\n"); + printf("\t--repeat : parse the file 100 times, for timing\n"); + printf("\t--noout : do not print the result\n"); +#ifdef LIBXML_PUSH_ENABLED + printf("\t--push : use the push mode parser\n"); +#endif /* LIBXML_PUSH_ENABLED */ + printf("\t--encode encoding : output in the given encoding\n"); + } + xmlCleanupParser(); + xmlMemoryDump(); + + return(0); +} +#else /* !LIBXML_HTML_ENABLED */ +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : HTML support not compiled in\n", argv[0]); + return(0); +} +#endif diff --git a/src/testModule.c b/src/testModule.c new file mode 100644 index 000000000000..77b7ba106abd --- /dev/null +++ b/src/testModule.c @@ -0,0 +1,82 @@ +/* + * testModule.c : a small tester program for xmlModule + * + * See Copyright for the status of this software. + * + * joelwreed@comcast.net + */ + +#include "libxml.h" +#ifdef LIBXML_MODULES_ENABLED +#include + +#include +#include +#include +#include + +#include +#include +#include + +#ifdef _WIN32 +#define MODULE_PATH "." +#include /* for _MAX_PATH */ +#ifndef __MINGW32__ +#define PATH_MAX _MAX_PATH +#endif +#else +#define MODULE_PATH ".libs" +#endif + +/* Used for SCO Openserver*/ +#ifndef PATH_MAX +#ifdef _POSIX_PATH_MAX +#define PATH_MAX _POSIX_PATH_MAX +#else +#define PATH_MAX 4096 +#endif +#endif + +typedef int (*hello_world_t)(void); + +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + xmlChar filename[PATH_MAX]; + xmlModulePtr module = NULL; + hello_world_t hello_world = NULL; + + /* build the module filename, and confirm the module exists */ + xmlStrPrintf(filename, sizeof(filename), + "%s/testdso%s", + (const xmlChar*)MODULE_PATH, + (const xmlChar*)LIBXML_MODULE_EXTENSION); + + module = xmlModuleOpen((const char*)filename, 0); + if (module) + { + if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) { + fprintf(stderr, "Failure to lookup\n"); + return(1); + } + if (hello_world == NULL) { + fprintf(stderr, "Lookup returned NULL\n"); + return(1); + } + + (*hello_world)(); + + xmlModuleClose(module); + } + + xmlMemoryDump(); + + return(0); +} + +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : Module support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_SCHEMAS_ENABLED */ diff --git a/src/testReader.c b/src/testReader.c new file mode 100644 index 000000000000..da2f1b02cd29 --- /dev/null +++ b/src/testReader.c @@ -0,0 +1,145 @@ +/* + * testReader.c : a small tester program for parsing using the xmlReader + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" + +#ifdef LIBXML_READER_ENABLED +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + + +#include + +static int debug = 0; +static int dump = 0; +static int noent = 0; +static int count = 0; +static int valid = 0; +static int consumed = 0; + +static void usage(const char *progname) { + printf("Usage : %s [options] XMLfiles ...\n", progname); + printf("\tParse the XML files using the xmlTextReader API\n"); + printf("\t --count: count the number of attribute and elements\n"); + printf("\t --valid: validate the document\n"); + printf("\t --consumed: count the number of bytes consumed\n"); + exit(1); +} +static int elem, attrs; + +static void processNode(xmlTextReaderPtr reader) { + int type; + + type = xmlTextReaderNodeType(reader); + if (count) { + if (type == 1) { + elem++; + attrs += xmlTextReaderAttributeCount(reader); + } + } +} + +static void handleFile(const char *filename) { + xmlTextReaderPtr reader; + int ret; + + if (count) { + elem = 0; + attrs = 0; + } + + reader = xmlNewTextReaderFilename(filename); + if (reader != NULL) { + if (valid) + xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); + + /* + * Process all nodes in sequence + */ + ret = xmlTextReaderRead(reader); + while (ret == 1) { + processNode(reader); + ret = xmlTextReaderRead(reader); + } + + /* + * Done, cleanup and status + */ + if (consumed) + printf("%ld bytes consumed by parser\n", xmlTextReaderByteConsumed(reader)); + xmlFreeTextReader(reader); + if (ret != 0) { + printf("%s : failed to parse\n", filename); + } else if (count) + printf("%s : %d elements, %d attributes\n", filename, elem, attrs); + } else { + fprintf(stderr, "Unable to open %s\n", filename); + } +} + +int main(int argc, char **argv) { + int i; + int files = 0; + + if (argc <= 1) { + usage(argv[0]); + return(1); + } + LIBXML_TEST_VERSION + for (i = 1; i < argc ; i++) { + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) + debug++; + else if ((!strcmp(argv[i], "-dump")) || (!strcmp(argv[i], "--dump"))) + dump++; + else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count"))) + count++; + else if ((!strcmp(argv[i], "-consumed")) || (!strcmp(argv[i], "--consumed"))) + consumed++; + else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) + valid++; + else if ((!strcmp(argv[i], "-noent")) || + (!strcmp(argv[i], "--noent"))) + noent++; + } + if (noent != 0) xmlSubstituteEntitiesDefault(1); + for (i = 1; i < argc ; i++) { + if (argv[i][0] != '-') { + handleFile(argv[i]); + files ++; + } + } + xmlCleanupParser(); + xmlMemoryDump(); + + return(0); +} +#else +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : xmlReader parser support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_READER_ENABLED */ diff --git a/src/testRegexp.c b/src/testRegexp.c new file mode 100644 index 000000000000..218174144b4c --- /dev/null +++ b/src/testRegexp.c @@ -0,0 +1,402 @@ +/* + * testRegexp.c: simple module for testing regular expressions + * + * See Copyright for the status of this software. + * + * Daniel Veillard + */ + +#include "libxml.h" +#ifdef LIBXML_REGEXP_ENABLED +#include + +#include +#include + +static int repeat = 0; +static int debug = 0; + +static void testRegexp(xmlRegexpPtr comp, const char *value) { + int ret; + + ret = xmlRegexpExec(comp, (const xmlChar *) value); + if (ret == 1) + printf("%s: Ok\n", value); + else if (ret == 0) + printf("%s: Fail\n", value); + else + printf("%s: Error: %d\n", value, ret); + if (repeat) { + int j; + for (j = 0;j < 999999;j++) + xmlRegexpExec(comp, (const xmlChar *) value); + } +} + +static void +testRegexpFile(const char *filename) { + xmlRegexpPtr comp = NULL; + FILE *input; + char expression[5000]; + int len; + + input = fopen(filename, "r"); + if (input == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot open %s for reading\n", filename); + return; + } + while (fgets(expression, 4500, input) != NULL) { + len = strlen(expression); + len--; + while ((len >= 0) && + ((expression[len] == '\n') || (expression[len] == '\t') || + (expression[len] == '\r') || (expression[len] == ' '))) len--; + expression[len + 1] = 0; + if (len >= 0) { + if (expression[0] == '#') + continue; + if ((expression[0] == '=') && (expression[1] == '>')) { + char *pattern = &expression[2]; + + if (comp != NULL) { + xmlRegFreeRegexp(comp); + comp = NULL; + } + printf("Regexp: %s\n", pattern) ; + comp = xmlRegexpCompile((const xmlChar *) pattern); + if (comp == NULL) { + printf(" failed to compile\n"); + break; + } + } else if (comp == NULL) { + printf("Regexp: %s\n", expression) ; + comp = xmlRegexpCompile((const xmlChar *) expression); + if (comp == NULL) { + printf(" failed to compile\n"); + break; + } + } else if (comp != NULL) { + testRegexp(comp, expression); + } + } + } + fclose(input); + if (comp != NULL) + xmlRegFreeRegexp(comp); +} + +#ifdef LIBXML_EXPR_ENABLED +static void +runFileTest(xmlExpCtxtPtr ctxt, const char *filename) { + xmlExpNodePtr expr = NULL, sub; + FILE *input; + char expression[5000]; + int len; + + input = fopen(filename, "r"); + if (input == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot open %s for reading\n", filename); + return; + } + while (fgets(expression, 4500, input) != NULL) { + len = strlen(expression); + len--; + while ((len >= 0) && + ((expression[len] == '\n') || (expression[len] == '\t') || + (expression[len] == '\r') || (expression[len] == ' '))) len--; + expression[len + 1] = 0; + if (len >= 0) { + if (expression[0] == '#') + continue; + if ((expression[0] == '=') && (expression[1] == '>')) { + char *str = &expression[2]; + + if (expr != NULL) { + xmlExpFree(ctxt, expr); + if (xmlExpCtxtNbNodes(ctxt) != 0) + printf(" Parse/free of Expression leaked %d\n", + xmlExpCtxtNbNodes(ctxt)); + expr = NULL; + } + printf("Expression: %s\n", str) ; + expr = xmlExpParse(ctxt, str); + if (expr == NULL) { + printf(" parsing Failed\n"); + break; + } + } else if (expr != NULL) { + int expect = -1; + int nodes1, nodes2; + + if (expression[0] == '0') + expect = 0; + if (expression[0] == '1') + expect = 1; + printf("Subexp: %s", expression + 2) ; + nodes1 = xmlExpCtxtNbNodes(ctxt); + sub = xmlExpParse(ctxt, expression + 2); + if (sub == NULL) { + printf(" parsing Failed\n"); + break; + } else { + int ret; + + nodes2 = xmlExpCtxtNbNodes(ctxt); + ret = xmlExpSubsume(ctxt, expr, sub); + + if ((expect == 1) && (ret == 1)) { + printf(" => accept, Ok\n"); + } else if ((expect == 0) && (ret == 0)) { + printf(" => reject, Ok\n"); + } else if ((expect == 1) && (ret == 0)) { + printf(" => reject, Failed\n"); + } else if ((expect == 0) && (ret == 1)) { + printf(" => accept, Failed\n"); + } else { + printf(" => fail internally\n"); + } + if (xmlExpCtxtNbNodes(ctxt) > nodes2) { + printf(" Subsume leaked %d\n", + xmlExpCtxtNbNodes(ctxt) - nodes2); + nodes1 += xmlExpCtxtNbNodes(ctxt) - nodes2; + } + xmlExpFree(ctxt, sub); + if (xmlExpCtxtNbNodes(ctxt) > nodes1) { + printf(" Parse/free leaked %d\n", + xmlExpCtxtNbNodes(ctxt) - nodes1); + } + } + + } + } + } + if (expr != NULL) { + xmlExpFree(ctxt, expr); + if (xmlExpCtxtNbNodes(ctxt) != 0) + printf(" Parse/free of Expression leaked %d\n", + xmlExpCtxtNbNodes(ctxt)); + } + fclose(input); +} + +static void +testReduce(xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, const char *tst) { + xmlBufferPtr xmlExpBuf; + xmlExpNodePtr sub, deriv; + + sub = xmlExpParse(ctxt, tst); + if (sub == NULL) { + printf("Subset %s failed to parse\n", tst); + return; + } + xmlExpBuf = xmlBufferCreate(); + xmlExpDump(xmlExpBuf, sub); + printf("Subset parsed as: %s\n", + (const char *) xmlBufferContent(xmlExpBuf)); + deriv = xmlExpExpDerive(ctxt, expr, sub); + if (deriv == NULL) { + printf("Derivation led to an internal error, report this !\n"); + } else { + xmlBufferEmpty(xmlExpBuf); + xmlExpDump(xmlExpBuf, deriv); + if (xmlExpIsNillable(deriv)) + printf("Resulting nillable derivation: %s\n", + (const char *) xmlBufferContent(xmlExpBuf)); + else + printf("Resulting derivation: %s\n", + (const char *) xmlBufferContent(xmlExpBuf)); + xmlExpFree(ctxt, deriv); + } + xmlBufferFree(xmlExpBuf); + xmlExpFree(ctxt, sub); +} + +static void +exprDebug(xmlExpCtxtPtr ctxt, xmlExpNodePtr expr) { + xmlBufferPtr xmlExpBuf; + xmlExpNodePtr deriv; + const char *list[40]; + int ret; + + xmlExpBuf = xmlBufferCreate(); + + if (expr == NULL) { + printf("Failed to parse\n"); + return; + } + xmlExpDump(xmlExpBuf, expr); + printf("Parsed as: %s\n", (const char *) xmlBufferContent(xmlExpBuf)); + printf("Max token input = %d\n", xmlExpMaxToken(expr)); + if (xmlExpIsNillable(expr) == 1) + printf("Is nillable\n"); + ret = xmlExpGetLanguage(ctxt, expr, (const xmlChar **) &list[0], 40); + if (ret < 0) + printf("Failed to get list: %d\n", ret); + else { + int i; + + printf("Language has %d strings, testing string derivations\n", ret); + for (i = 0;i < ret;i++) { + deriv = xmlExpStringDerive(ctxt, expr, BAD_CAST list[i], -1); + if (deriv == NULL) { + printf(" %s -> derivation failed\n", list[i]); + } else { + xmlBufferEmpty(xmlExpBuf); + xmlExpDump(xmlExpBuf, deriv); + printf(" %s -> %s\n", list[i], + (const char *) xmlBufferContent(xmlExpBuf)); + } + xmlExpFree(ctxt, deriv); + } + } + xmlBufferFree(xmlExpBuf); +} +#endif + +static void usage(const char *name) { + fprintf(stderr, "Usage: %s [flags]\n", name); + fprintf(stderr, "Testing tool for libxml2 string and pattern regexps\n"); + fprintf(stderr, " --debug: switch on debugging\n"); + fprintf(stderr, " --repeat: loop on the operation\n"); +#ifdef LIBXML_EXPR_ENABLED + fprintf(stderr, " --expr: test xmlExp and not xmlRegexp\n"); +#endif + fprintf(stderr, " --input filename: use the given filename for regexp\n"); + fprintf(stderr, " --input filename: use the given filename for exp\n"); +} + +int main(int argc, char **argv) { + xmlRegexpPtr comp = NULL; +#ifdef LIBXML_EXPR_ENABLED + xmlExpNodePtr expr = NULL; + int use_exp = 0; + xmlExpCtxtPtr ctxt = NULL; +#endif + const char *pattern = NULL; + char *filename = NULL; + int i; + + xmlInitMemory(); + + if (argc <= 1) { + usage(argv[0]); + return(1); + } + for (i = 1; i < argc ; i++) { + if (!strcmp(argv[i], "-")) + break; + + if (argv[i][0] != '-') + continue; + if (!strcmp(argv[i], "--")) + break; + + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) { + debug++; + } else if ((!strcmp(argv[i], "-repeat")) || + (!strcmp(argv[i], "--repeat"))) { + repeat++; +#ifdef LIBXML_EXPR_ENABLED + } else if ((!strcmp(argv[i], "-expr")) || + (!strcmp(argv[i], "--expr"))) { + use_exp++; +#endif + } else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "-f")) || + (!strcmp(argv[i], "--input"))) + filename = argv[++i]; + else { + fprintf(stderr, "Unknown option %s\n", argv[i]); + usage(argv[0]); + } + } + +#ifdef LIBXML_EXPR_ENABLED + if (use_exp) + ctxt = xmlExpNewCtxt(0, NULL); +#endif + + if (filename != NULL) { +#ifdef LIBXML_EXPR_ENABLED + if (use_exp) + runFileTest(ctxt, filename); + else +#endif + testRegexpFile(filename); + } else { + int data = 0; +#ifdef LIBXML_EXPR_ENABLED + + if (use_exp) { + for (i = 1; i < argc ; i++) { + if (strcmp(argv[i], "--") == 0) + data = 1; + else if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0) || + (data == 1)) { + if (pattern == NULL) { + pattern = argv[i]; + printf("Testing expr %s:\n", pattern); + expr = xmlExpParse(ctxt, pattern); + if (expr == NULL) { + printf(" failed to compile\n"); + break; + } + if (debug) { + exprDebug(ctxt, expr); + } + } else { + testReduce(ctxt, expr, argv[i]); + } + } + } + if (expr != NULL) { + xmlExpFree(ctxt, expr); + expr = NULL; + } + } else +#endif + { + for (i = 1; i < argc ; i++) { + if (strcmp(argv[i], "--") == 0) + data = 1; + else if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0) || + (data == 1)) { + if (pattern == NULL) { + pattern = argv[i]; + printf("Testing %s:\n", pattern); + comp = xmlRegexpCompile((const xmlChar *) pattern); + if (comp == NULL) { + printf(" failed to compile\n"); + break; + } + if (debug) + xmlRegexpPrint(stdout, comp); + } else { + testRegexp(comp, argv[i]); + } + } + } + if (comp != NULL) + xmlRegFreeRegexp(comp); + } + } +#ifdef LIBXML_EXPR_ENABLED + if (ctxt != NULL) { + printf("Ops: %d nodes, %d cons\n", + xmlExpCtxtNbNodes(ctxt), xmlExpCtxtNbCons(ctxt)); + xmlExpFreeCtxt(ctxt); + } +#endif + xmlCleanupParser(); + xmlMemoryDump(); + return(0); +} + +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : Regexp support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_REGEXP_ENABLED */ diff --git a/src/testRelax.c b/src/testRelax.c new file mode 100644 index 000000000000..3549f938f1de --- /dev/null +++ b/src/testRelax.c @@ -0,0 +1,188 @@ +/* + * testRelax.c : a small tester program for RelaxNG validation + * + * See Copyright for the status of this software. + * + * Daniel.Veillard@w3.org + */ + +#include "libxml.h" +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include + +#include +#include +#include + + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_SYS_MMAN_H +#include +/* seems needed for Solaris */ +#ifndef MAP_FAILED +#define MAP_FAILED ((void *) -1) +#endif +#endif + +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED +static int debug = 0; +#endif +static int noout = 0; +static int tree = 0; +#ifdef HAVE_MMAP +static int memory = 0; +#endif + + +int main(int argc, char **argv) { + int i; + int files = 0; + xmlRelaxNGPtr schema = NULL; + + for (i = 1; i < argc ; i++) { +#ifdef LIBXML_DEBUG_ENABLED + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) + debug++; + else +#endif +#ifdef HAVE_MMAP + if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) { + memory++; + } else +#endif + if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) { + noout++; + } else + if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree"))) { + tree++; + } + } + xmlLineNumbersDefault(1); + xmlSubstituteEntitiesDefault(1); + for (i = 1; i < argc ; i++) { + if (argv[i][0] != '-') { + if (schema == NULL) { + xmlRelaxNGParserCtxtPtr ctxt; + +#ifdef HAVE_MMAP + if (memory) { + int fd; + struct stat info; + const char *base; + if (stat(argv[i], &info) < 0) + break; + if ((fd = open(argv[i], O_RDONLY)) < 0) + break; + base = mmap(NULL, info.st_size, PROT_READ, + MAP_SHARED, fd, 0) ; + if (base == (void *) MAP_FAILED) + break; + + ctxt = xmlRelaxNGNewMemParserCtxt((char *)base,info.st_size); + + xmlRelaxNGSetParserErrors(ctxt, + xmlGenericError, xmlGenericError, NULL); + schema = xmlRelaxNGParse(ctxt); + xmlRelaxNGFreeParserCtxt(ctxt); + munmap((char *) base, info.st_size); + } else +#endif + { + ctxt = xmlRelaxNGNewParserCtxt(argv[i]); + xmlRelaxNGSetParserErrors(ctxt, + xmlGenericError, xmlGenericError, NULL); + schema = xmlRelaxNGParse(ctxt); + xmlRelaxNGFreeParserCtxt(ctxt); + } + if (schema == NULL) { + printf("Relax-NG schema %s failed to compile\n", argv[i]); + files = -1; + break; + } +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef LIBXML_DEBUG_ENABLED + if (debug) + xmlRelaxNGDump(stdout, schema); +#endif + if (tree) + xmlRelaxNGDumpTree(stdout, schema); +#endif /* LIBXML_OUTPUT_ENABLED */ + } else { + xmlDocPtr doc; + + doc = xmlReadFile(argv[i],NULL,0); + + if (doc == NULL) { + fprintf(stderr, "Could not parse %s\n", argv[i]); + } else { + xmlRelaxNGValidCtxtPtr ctxt; + int ret; + + ctxt = xmlRelaxNGNewValidCtxt(schema); + xmlRelaxNGSetValidErrors(ctxt, + xmlGenericError, xmlGenericError, NULL); + ret = xmlRelaxNGValidateDoc(ctxt, doc); + if (ret == 0) { + printf("%s validates\n", argv[i]); + } else if (ret > 0) { + printf("%s fails to validate\n", argv[i]); + } else { + printf("%s validation generated an internal error\n", + argv[i]); + } + xmlRelaxNGFreeValidCtxt(ctxt); + xmlFreeDoc(doc); + } + } + files ++; + } + } + if (schema != NULL) + xmlRelaxNGFree(schema); + if (files == 0) { + printf("Usage : %s [--debug] [--noout] schemas XMLfiles ...\n", + argv[0]); + printf("\tParse the HTML files and output the result of the parsing\n"); +#ifdef LIBXML_DEBUG_ENABLED + printf("\t--debug : dump a debug tree of the in-memory document\n"); +#endif + printf("\t--noout : do not print the result\n"); + printf("\t--tree : print the intermediate Relax-NG document tree\n"); +#ifdef HAVE_MMAP + printf("\t--memory : test the schemas in memory parsing\n"); +#endif + } + xmlRelaxNGCleanupTypes(); + xmlCleanupParser(); + xmlMemoryDump(); + + return(0); +} + +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : RelaxNG support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_SCHEMAS_ENABLED */ diff --git a/src/testSAX.c b/src/testSAX.c new file mode 100644 index 000000000000..81c4b93d62e1 --- /dev/null +++ b/src/testSAX.c @@ -0,0 +1,1198 @@ +/* + * testSAX.c : a small tester program for parsing using the SAX API. + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" + +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_TIMEB_H +#include +#endif +#ifdef HAVE_TIME_H +#include +#endif + +#ifdef LIBXML_SAX1_ENABLED +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + + +#include +#include +#include +#include /* only for xmlNewInputFromFile() */ +#include +#include +#include + +static int debug = 0; +static int copy = 0; +static int recovery = 0; +static int push = 0; +static int speed = 0; +static int noent = 0; +static int quiet = 0; +static int nonull = 0; +static int sax2 = 0; +static int repeat = 0; +static int callbacks = 0; +static int timing = 0; + +/* + * Timing routines. + */ +/* + * Internal timing routines to remove the necessity to have unix-specific + * function calls + */ + +#ifndef HAVE_GETTIMEOFDAY +#ifdef HAVE_SYS_TIMEB_H +#ifdef HAVE_SYS_TIME_H +#ifdef HAVE_FTIME + +static int +my_gettimeofday(struct timeval *tvp, void *tzp) +{ + struct timeb timebuffer; + + ftime(&timebuffer); + if (tvp) { + tvp->tv_sec = timebuffer.time; + tvp->tv_usec = timebuffer.millitm * 1000L; + } + return (0); +} +#define HAVE_GETTIMEOFDAY 1 +#define gettimeofday my_gettimeofday + +#endif /* HAVE_FTIME */ +#endif /* HAVE_SYS_TIME_H */ +#endif /* HAVE_SYS_TIMEB_H */ +#endif /* !HAVE_GETTIMEOFDAY */ + +#if defined(HAVE_GETTIMEOFDAY) +static struct timeval begin, end; + +/* + * startTimer: call where you want to start timing + */ +static void +startTimer(void) +{ + gettimeofday(&begin, NULL); +} + +/* + * endTimer: call where you want to stop timing and to print out a + * message about the timing performed; format is a printf + * type argument + */ +static void XMLCDECL +endTimer(const char *fmt, ...) +{ + long msec; + va_list ap; + + gettimeofday(&end, NULL); + msec = end.tv_sec - begin.tv_sec; + msec *= 1000; + msec += (end.tv_usec - begin.tv_usec) / 1000; + +#ifndef HAVE_STDARG_H +#error "endTimer required stdarg functions" +#endif + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + fprintf(stderr, " took %ld ms\n", msec); +} +#elif defined(HAVE_TIME_H) +/* + * No gettimeofday function, so we have to make do with calling clock. + * This is obviously less accurate, but there's little we can do about + * that. + */ +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 100 +#endif + +static clock_t begin, end; +static void +startTimer(void) +{ + begin = clock(); +} +static void XMLCDECL +endTimer(const char *fmt, ...) +{ + long msec; + va_list ap; + + end = clock(); + msec = ((end - begin) * 1000) / CLOCKS_PER_SEC; + +#ifndef HAVE_STDARG_H +#error "endTimer required stdarg functions" +#endif + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, " took %ld ms\n", msec); +} +#else + +/* + * We don't have a gettimeofday or time.h, so we just don't do timing + */ +static void +startTimer(void) +{ + /* + * Do nothing + */ +} +static void XMLCDECL +endTimer(char *format, ...) +{ + /* + * We cannot do anything because we don't have a timing function + */ +#ifdef HAVE_STDARG_H + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + fprintf(stderr, " was not timed\n", msec); +#else + /* We don't have gettimeofday, time or stdarg.h, what crazy world is + * this ?! + */ +#endif +} +#endif + +/* + * empty SAX block + */ +static xmlSAXHandler emptySAXHandlerStruct = { + NULL, /* internalSubset */ + NULL, /* isStandalone */ + NULL, /* hasInternalSubset */ + NULL, /* hasExternalSubset */ + NULL, /* resolveEntity */ + NULL, /* getEntity */ + NULL, /* entityDecl */ + NULL, /* notationDecl */ + NULL, /* attributeDecl */ + NULL, /* elementDecl */ + NULL, /* unparsedEntityDecl */ + NULL, /* setDocumentLocator */ + NULL, /* startDocument */ + NULL, /* endDocument */ + NULL, /* startElement */ + NULL, /* endElement */ + NULL, /* reference */ + NULL, /* characters */ + NULL, /* ignorableWhitespace */ + NULL, /* processingInstruction */ + NULL, /* comment */ + NULL, /* xmlParserWarning */ + NULL, /* xmlParserError */ + NULL, /* xmlParserError */ + NULL, /* getParameterEntity */ + NULL, /* cdataBlock; */ + NULL, /* externalSubset; */ + 1, + NULL, + NULL, /* startElementNs */ + NULL, /* endElementNs */ + NULL /* xmlStructuredErrorFunc */ +}; + +static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; +extern xmlSAXHandlerPtr debugSAXHandler; + +/************************************************************************ + * * + * Debug Handlers * + * * + ************************************************************************/ + +/** + * isStandaloneDebug: + * @ctxt: An XML parser context + * + * Is this document tagged standalone ? + * + * Returns 1 if true + */ +static int +isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return(0); + fprintf(stdout, "SAX.isStandalone()\n"); + return(0); +} + +/** + * hasInternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + * + * Returns 1 if true + */ +static int +hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return(0); + fprintf(stdout, "SAX.hasInternalSubset()\n"); + return(0); +} + +/** + * hasExternalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an external subset + * + * Returns 1 if true + */ +static int +hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return(0); + fprintf(stdout, "SAX.hasExternalSubset()\n"); + return(0); +} + +/** + * internalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + */ +static void +internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.internalSubset(%s,", name); + if (ExternalID == NULL) + fprintf(stdout, " ,"); + else + fprintf(stdout, " %s,", ExternalID); + if (SystemID == NULL) + fprintf(stdout, " )\n"); + else + fprintf(stdout, " %s)\n", SystemID); +} + +/** + * externalSubsetDebug: + * @ctxt: An XML parser context + * + * Does this document has an external subset + */ +static void +externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.externalSubset(%s,", name); + if (ExternalID == NULL) + fprintf(stdout, " ,"); + else + fprintf(stdout, " %s,", ExternalID); + if (SystemID == NULL) + fprintf(stdout, " )\n"); + else + fprintf(stdout, " %s)\n", SystemID); +} + +/** + * resolveEntityDebug: + * @ctxt: An XML parser context + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Special entity resolver, better left to the parser, it has + * more context than the application layer. + * The default behaviour is to NOT resolve the entities, in that case + * the ENTITY_REF nodes are built in the structure (and the parameter + * values). + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlParserInputPtr +resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) +{ + callbacks++; + if (quiet) + return(NULL); + /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ + + + fprintf(stdout, "SAX.resolveEntity("); + if (publicId != NULL) + fprintf(stdout, "%s", (char *)publicId); + else + fprintf(stdout, " "); + if (systemId != NULL) + fprintf(stdout, ", %s)\n", (char *)systemId); + else + fprintf(stdout, ", )\n"); +/********* + if (systemId != NULL) { + return(xmlNewInputFromFile(ctxt, (char *) systemId)); + } + *********/ + return(NULL); +} + +/** + * getEntityDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get an entity by name + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlEntityPtr +getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + callbacks++; + if (quiet) + return(NULL); + fprintf(stdout, "SAX.getEntity(%s)\n", name); + return(NULL); +} + +/** + * getParameterEntityDebug: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get a parameter entity by name + * + * Returns the xmlParserInputPtr + */ +static xmlEntityPtr +getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + callbacks++; + if (quiet) + return(NULL); + fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); + return(NULL); +} + + +/** + * entityDeclDebug: + * @ctxt: An XML parser context + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed + */ +static void +entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, + const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) +{ +const xmlChar *nullstr = BAD_CAST "(null)"; + /* not all libraries handle printing null pointers nicely */ + if (publicId == NULL) + publicId = nullstr; + if (systemId == NULL) + systemId = nullstr; + if (content == NULL) + content = (xmlChar *)nullstr; + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", + name, type, publicId, systemId, content); +} + +/** + * attributeDeclDebug: + * @ctxt: An XML parser context + * @name: the attribute name + * @type: the attribute type + * + * An attribute definition has been parsed + */ +static void +attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, + const xmlChar * name, int type, int def, + const xmlChar * defaultValue, xmlEnumerationPtr tree) +{ + callbacks++; + if (quiet) + return; + if (defaultValue == NULL) + fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", + elem, name, type, def); + else + fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", + elem, name, type, def, defaultValue); + xmlFreeEnumeration(tree); +} + +/** + * elementDeclDebug: + * @ctxt: An XML parser context + * @name: the element name + * @type: the element type + * @content: the element value (without processing). + * + * An element definition has been parsed + */ +static void +elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, + xmlElementContentPtr content ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", + name, type); +} + +/** + * notationDeclDebug: + * @ctxt: An XML parser context + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +static void +notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *publicId, const xmlChar *systemId) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", + (char *) name, (char *) publicId, (char *) systemId); +} + +/** + * unparsedEntityDeclDebug: + * @ctxt: An XML parser context + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed + */ +static void +unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, + const xmlChar *publicId, const xmlChar *systemId, + const xmlChar *notationName) +{ +const xmlChar *nullstr = BAD_CAST "(null)"; + + if (publicId == NULL) + publicId = nullstr; + if (systemId == NULL) + systemId = nullstr; + if (notationName == NULL) + notationName = nullstr; + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", + (char *) name, (char *) publicId, (char *) systemId, + (char *) notationName); +} + +/** + * setDocumentLocatorDebug: + * @ctxt: An XML parser context + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator + * Everything is available on the context, so this is useless in our case. + */ +static void +setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.setDocumentLocator()\n"); +} + +/** + * startDocumentDebug: + * @ctxt: An XML parser context + * + * called when the document start being processed. + */ +static void +startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.startDocument()\n"); +} + +/** + * endDocumentDebug: + * @ctxt: An XML parser context + * + * called when the document end has been detected. + */ +static void +endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.endDocument()\n"); +} + +/** + * startElementDebug: + * @ctxt: An XML parser context + * @name: The element name + * + * called when an opening tag has been processed. + */ +static void +startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) +{ + int i; + + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.startElement(%s", (char *) name); + if (atts != NULL) { + for (i = 0;(atts[i] != NULL);i++) { + fprintf(stdout, ", %s='", atts[i++]); + if (atts[i] != NULL) + fprintf(stdout, "%s'", atts[i]); + } + } + fprintf(stdout, ")\n"); +} + +/** + * endElementDebug: + * @ctxt: An XML parser context + * @name: The element name + * + * called when the end of an element has been detected. + */ +static void +endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) +{ + callbacks++; + if (quiet) + return; + fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); +} + +/** + * charactersDebug: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * receiving some chars from the parser. + * Question: how much at a time ??? + */ +static void +charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) +{ + char output[40]; + int i; + + callbacks++; + if (quiet) + return; + for (i = 0;(i 0) { + ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL, + chars, ret, filename); + while ((ret = fread(chars, 1, 3, f)) > 0) { + xmlParseChunk(ctxt, chars, ret, 0); + } + xmlParseChunk(ctxt, chars, 0, 1); + xmlFreeParserCtxt(ctxt); + } + fclose(f); + } else { + xmlGenericError(xmlGenericErrorContext, + "Cannot read file %s\n", filename); + } + } + /* + * Debug callback + */ +#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) + f = fopen(filename, "rb"); +#else + f = fopen(filename, "r"); +#endif + if (f != NULL) { + int ret; + char chars[10]; + xmlParserCtxtPtr ctxt; + + ret = fread(chars, 1, 4, f); + if (ret > 0) { + if (sax2) + ctxt = xmlCreatePushParserCtxt(debugSAX2Handler, NULL, + chars, ret, filename); + else + ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL, + chars, ret, filename); + while ((ret = fread(chars, 1, 3, f)) > 0) { + xmlParseChunk(ctxt, chars, ret, 0); + } + ret = xmlParseChunk(ctxt, chars, 0, 1); + xmlFreeParserCtxt(ctxt); + if (ret != 0) { + fprintf(stdout, + "xmlSAXUserParseFile returned error %d\n", ret); + } + } + fclose(f); + } + } else { +#endif /* LIBXML_PUSH_ENABLED */ + if (!speed) { + /* + * Empty callbacks for checking + */ + if ((!quiet) && (!nonull)) { + res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename); + if (res != 0) { + fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res); + } + } + + /* + * Debug callback + */ + callbacks = 0; + if (repeat) { + int i; + for (i = 0;i < 99;i++) { + if (sax2) + res = xmlSAXUserParseFile(debugSAX2Handler, NULL, + filename); + else + res = xmlSAXUserParseFile(debugSAXHandler, NULL, + filename); + } + } + if (sax2) + res = xmlSAXUserParseFile(debugSAX2Handler, NULL, filename); + else + res = xmlSAXUserParseFile(debugSAXHandler, NULL, filename); + if (res != 0) { + fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res); + } + if (quiet) + fprintf(stdout, "%d callbacks generated\n", callbacks); + } else { + /* + * test 100x the SAX parse + */ + int i; + + for (i = 0; i<100;i++) + res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename); + if (res != 0) { + fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res); + } + } +#ifdef LIBXML_PUSH_ENABLED + } +#endif +} + + +int main(int argc, char **argv) { + int i; + int files = 0; + + LIBXML_TEST_VERSION /* be safe, plus calls xmlInitParser */ + + for (i = 1; i < argc ; i++) { + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) + debug++; + else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) + copy++; + else if ((!strcmp(argv[i], "-recover")) || + (!strcmp(argv[i], "--recover"))) + recovery++; + else if ((!strcmp(argv[i], "-push")) || + (!strcmp(argv[i], "--push"))) +#ifdef LIBXML_PUSH_ENABLED + push++; +#else + fprintf(stderr,"'push' not enabled in library - ignoring\n"); +#endif /* LIBXML_PUSH_ENABLED */ + else if ((!strcmp(argv[i], "-speed")) || + (!strcmp(argv[i], "--speed"))) + speed++; + else if ((!strcmp(argv[i], "-timing")) || + (!strcmp(argv[i], "--timing"))) { + nonull++; + timing++; + quiet++; + } else if ((!strcmp(argv[i], "-repeat")) || + (!strcmp(argv[i], "--repeat"))) { + repeat++; + quiet++; + } else if ((!strcmp(argv[i], "-noent")) || + (!strcmp(argv[i], "--noent"))) + noent++; + else if ((!strcmp(argv[i], "-quiet")) || + (!strcmp(argv[i], "--quiet"))) + quiet++; + else if ((!strcmp(argv[i], "-sax2")) || + (!strcmp(argv[i], "--sax2"))) + sax2++; + else if ((!strcmp(argv[i], "-nonull")) || + (!strcmp(argv[i], "--nonull"))) + nonull++; + } + if (noent != 0) xmlSubstituteEntitiesDefault(1); + for (i = 1; i < argc ; i++) { + if (argv[i][0] != '-') { + if (timing) { + startTimer(); + } + parseAndPrintFile(argv[i]); + if (timing) { + endTimer("Parsing"); + } + files ++; + } + } + xmlCleanupParser(); + xmlMemoryDump(); + + return(0); +} +#else +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : SAX1 parsing support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_SAX1_ENABLED */ diff --git a/src/testSchemas.c b/src/testSchemas.c new file mode 100644 index 000000000000..fc39862c6410 --- /dev/null +++ b/src/testSchemas.c @@ -0,0 +1,179 @@ +/* + * testSchemas.c : a small tester program for Schema validation + * + * See Copyright for the status of this software. + * + * Daniel.Veillard@w3.org + */ + +#include "libxml.h" +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include + +#include +#include +#include + + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_SYS_MMAN_H +#include +/* seems needed for Solaris */ +#ifndef MAP_FAILED +#define MAP_FAILED ((void *) -1) +#endif +#endif + +#include +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED +static int debug = 0; +#endif +static int noout = 0; +#ifdef HAVE_MMAP +static int memory = 0; +#endif + + +int main(int argc, char **argv) { + int i; + int files = 0; + xmlSchemaPtr schema = NULL; + + for (i = 1; i < argc ; i++) { +#ifdef LIBXML_DEBUG_ENABLED + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) + debug++; + else +#endif +#ifdef HAVE_MMAP + if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) { + memory++; + } else +#endif + if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) { + noout++; + } + } + xmlLineNumbersDefault(1); + for (i = 1; i < argc ; i++) { + if (argv[i][0] != '-') { + if (schema == NULL) { + xmlSchemaParserCtxtPtr ctxt; + +#ifdef HAVE_MMAP + if (memory) { + int fd; + struct stat info; + const char *base; + if (stat(argv[i], &info) < 0) + break; + if ((fd = open(argv[i], O_RDONLY)) < 0) + break; + base = mmap(NULL, info.st_size, PROT_READ, + MAP_SHARED, fd, 0) ; + if (base == (void *) MAP_FAILED) + break; + + ctxt = xmlSchemaNewMemParserCtxt((char *)base,info.st_size); + + xmlSchemaSetParserErrors(ctxt, + xmlGenericError, xmlGenericError, NULL); + schema = xmlSchemaParse(ctxt); + xmlSchemaFreeParserCtxt(ctxt); + munmap((char *) base, info.st_size); + } else +#endif + { + ctxt = xmlSchemaNewParserCtxt(argv[i]); + xmlSchemaSetParserErrors(ctxt, + xmlGenericError, xmlGenericError, NULL); + schema = xmlSchemaParse(ctxt); + xmlSchemaFreeParserCtxt(ctxt); + } +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef LIBXML_DEBUG_ENABLED + if (debug) + xmlSchemaDump(stdout, schema); +#endif +#endif /* LIBXML_OUTPUT_ENABLED */ + if (schema == NULL) + goto failed_schemas; + } else { + xmlDocPtr doc; + + doc = xmlReadFile(argv[i],NULL,0); + + if (doc == NULL) { + fprintf(stderr, "Could not parse %s\n", argv[i]); + } else { + xmlSchemaValidCtxtPtr ctxt; + int ret; + + ctxt = xmlSchemaNewValidCtxt(schema); + xmlSchemaSetValidErrors(ctxt, + xmlGenericError, xmlGenericError, NULL); + ret = xmlSchemaValidateDoc(ctxt, doc); + if (ret == 0) { + printf("%s validates\n", argv[i]); + } else if (ret > 0) { + printf("%s fails to validate\n", argv[i]); + } else { + printf("%s validation generated an internal error\n", + argv[i]); + } + xmlSchemaFreeValidCtxt(ctxt); + xmlFreeDoc(doc); + } + } + files ++; + } + } + if (schema != NULL) + xmlSchemaFree(schema); + if (files == 0) { + printf("Usage : %s [--debug] [--noout] schemas XMLfiles ...\n", + argv[0]); + printf("\tParse the HTML files and output the result of the parsing\n"); +#ifdef LIBXML_DEBUG_ENABLED + printf("\t--debug : dump a debug tree of the in-memory document\n"); +#endif + printf("\t--noout : do not print the result\n"); +#ifdef HAVE_MMAP + printf("\t--memory : test the schemas in memory parsing\n"); +#endif + } +failed_schemas: + xmlSchemaCleanupTypes(); + xmlCleanupParser(); + xmlMemoryDump(); + + return(0); +} + +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : Schemas support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_SCHEMAS_ENABLED */ diff --git a/src/testThreads.c b/src/testThreads.c new file mode 100644 index 000000000000..bef6537744b2 --- /dev/null +++ b/src/testThreads.c @@ -0,0 +1,275 @@ +#include "libxml.h" + +#include +#include + +#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) +#include +#include +#include +#include +#ifdef HAVE_PTHREAD_H +#include +#elif defined HAVE_WIN32_THREADS +#include +#elif defined HAVE_BEOS_THREADS +#include +#endif +#include +#if !defined(_MSC_VER) +#include +#endif +#include + +#define MAX_ARGC 20 +#define TEST_REPEAT_COUNT 500 +#ifdef HAVE_PTHREAD_H +static pthread_t tid[MAX_ARGC]; +#elif defined HAVE_WIN32_THREADS +static HANDLE tid[MAX_ARGC]; +#elif defined HAVE_BEOS_THREADS +static thread_id tid[MAX_ARGC]; +#endif + +typedef struct { + const char *filename; + int okay; +} xmlThreadParams; + +static const char *catalog = "test/threads/complex.xml"; +static xmlThreadParams threadParams[] = { + { "test/threads/abc.xml", 0 }, + { "test/threads/acb.xml", 0 }, + { "test/threads/bac.xml", 0 }, + { "test/threads/bca.xml", 0 }, + { "test/threads/cab.xml", 0 }, + { "test/threads/cba.xml", 0 }, + { "test/threads/invalid.xml", 0 } +}; +static const unsigned int num_threads = sizeof(threadParams) / + sizeof(threadParams[0]); + +#ifndef xmlDoValidityCheckingDefaultValue +#error xmlDoValidityCheckingDefaultValue is not a macro +#endif +#ifndef xmlGenericErrorContext +#error xmlGenericErrorContext is not a macro +#endif + +static void * +thread_specific_data(void *private_data) +{ + xmlDocPtr myDoc; + xmlThreadParams *params = (xmlThreadParams *) private_data; + const char *filename = params->filename; + int okay = 1; + + if (!strcmp(filename, "test/threads/invalid.xml")) { + xmlDoValidityCheckingDefaultValue = 0; + xmlGenericErrorContext = stdout; + } else { + xmlDoValidityCheckingDefaultValue = 1; + xmlGenericErrorContext = stderr; + } +#ifdef LIBXML_SAX1_ENABLED + myDoc = xmlParseFile(filename); +#else + myDoc = xmlReadFile(filename, NULL, XML_WITH_CATALOG); +#endif + if (myDoc) { + xmlFreeDoc(myDoc); + } else { + printf("parse failed\n"); + okay = 0; + } + if (!strcmp(filename, "test/threads/invalid.xml")) { + if (xmlDoValidityCheckingDefaultValue != 0) { + printf("ValidityCheckingDefaultValue override failed\n"); + okay = 0; + } + if (xmlGenericErrorContext != stdout) { + printf("xmlGenericErrorContext override failed\n"); + okay = 0; + } + } else { + if (xmlDoValidityCheckingDefaultValue != 1) { + printf("ValidityCheckingDefaultValue override failed\n"); + okay = 0; + } + if (xmlGenericErrorContext != stderr) { + printf("xmlGenericErrorContext override failed\n"); + okay = 0; + } + } + params->okay = okay; + return(NULL); +} + +#ifdef HAVE_PTHREAD_H +int +main(void) +{ + unsigned int i, repeat; + int ret; + + xmlInitParser(); + for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) { + xmlLoadCatalog(catalog); + + memset(tid, 0xff, sizeof(*tid)*num_threads); + + for (i = 0; i < num_threads; i++) { + ret = pthread_create(&tid[i], NULL, thread_specific_data, + (void *) &threadParams[i]); + if (ret != 0) { + perror("pthread_create"); + exit(1); + } + } + for (i = 0; i < num_threads; i++) { + void *result; + ret = pthread_join(tid[i], &result); + if (ret != 0) { + perror("pthread_join"); + exit(1); + } + } + + xmlCatalogCleanup(); + for (i = 0; i < num_threads; i++) + if (threadParams[i].okay == 0) + printf("Thread %d handling %s failed\n", i, + threadParams[i].filename); + } + xmlCleanupParser(); + xmlMemoryDump(); + return (0); +} +#elif defined HAVE_WIN32_THREADS +static DWORD WINAPI +win32_thread_specific_data(void *private_data) +{ + thread_specific_data(private_data); + return(0); +} + +int +main(void) +{ + unsigned int i, repeat; + BOOL ret; + + xmlInitParser(); + for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) + { + xmlLoadCatalog(catalog); + + for (i = 0; i < num_threads; i++) + { + tid[i] = (HANDLE) -1; + } + + for (i = 0; i < num_threads; i++) + { + DWORD useless; + tid[i] = CreateThread(NULL, 0, + win32_thread_specific_data, &threadParams[i], 0, &useless); + if (tid[i] == NULL) + { + perror("CreateThread"); + exit(1); + } + } + + if (WaitForMultipleObjects (num_threads, tid, TRUE, INFINITE) == WAIT_FAILED) + perror ("WaitForMultipleObjects failed"); + + for (i = 0; i < num_threads; i++) + { + DWORD exitCode; + ret = GetExitCodeThread (tid[i], &exitCode); + if (ret == 0) + { + perror("GetExitCodeThread"); + exit(1); + } + CloseHandle (tid[i]); + } + + xmlCatalogCleanup(); + for (i = 0; i < num_threads; i++) { + if (threadParams[i].okay == 0) + printf("Thread %d handling %s failed\n", i, + threadParams[i].filename); + } + } + + xmlCleanupParser(); + xmlMemoryDump(); + + return (0); +} +#elif defined HAVE_BEOS_THREADS +int +main(void) +{ + unsigned int i, repeat; + status_t ret; + + xmlInitParser(); + printf("Parser initialized\n"); + for (repeat = 0;repeat < TEST_REPEAT_COUNT;repeat++) { + printf("repeat: %d\n",repeat); + xmlLoadCatalog(catalog); + printf("loaded catalog: %s\n", catalog); + for (i = 0; i < num_threads; i++) { + tid[i] = (thread_id) -1; + } + printf("cleaned threads\n"); + for (i = 0; i < num_threads; i++) { + tid[i] = spawn_thread(thread_specific_data, "xmlTestThread", B_NORMAL_PRIORITY, (void *) &threadParams[i]); + if (tid[i] < B_OK) { + perror("beos_thread_create"); + exit(1); + } + printf("beos_thread_create %d -> %d\n", i, tid[i]); + } + for (i = 0; i < num_threads; i++) { + void *result; + ret = wait_for_thread(tid[i], &result); + printf("beos_thread_wait %d -> %d\n", i, ret); + if (ret != B_OK) { + perror("beos_thread_wait"); + exit(1); + } + } + + xmlCatalogCleanup(); + ret = B_OK; + for (i = 0; i < num_threads; i++) + if (threadParams[i].okay == 0) { + printf("Thread %d handling %s failed\n", i, + threadParams[i].filename); + ret = B_ERROR; + } + } + xmlCleanupParser(); + xmlMemoryDump(); + + if (ret == B_OK) + printf("testThread : BeOS : SUCCESS!\n"); + else + printf("testThread : BeOS : FAILED!\n"); + + return (0); +} +#endif /* pthreads or BeOS threads */ + +#else /* !LIBXML_THREADS_ENABLED */ +int +main(void) +{ + fprintf(stderr, "libxml was not compiled with thread or catalog support\n"); + return (0); +} +#endif diff --git a/src/testURI.c b/src/testURI.c new file mode 100644 index 000000000000..0043b203dde9 --- /dev/null +++ b/src/testURI.c @@ -0,0 +1,135 @@ +/* + * testURI.c : a small tester program for XML input. + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" + +#include +#include +#include + +#include +#include +#include + +static const char *base = NULL; +static int escape = 0; +static int debug = 0; +static int relative = 0; + +static void handleURI(const char *str) { + int ret; + xmlURIPtr uri; + xmlChar *res = NULL, *parsed = NULL; + + uri = xmlCreateURI(); + + if (base == NULL) { + ret = xmlParseURIReference(uri, str); + if (ret != 0) + printf("%s : error %d\n", str, ret); + else { + if (debug) { + if (uri->scheme) printf("scheme: %s\n", uri->scheme); + if (uri->opaque) printf("opaque: %s\n", uri->opaque); + if (uri->authority) printf("authority: %s\n", uri->authority); + if (uri->server) printf("server: %s\n", uri->server); + if (uri->user) printf("user: %s\n", uri->user); + if (uri->port != 0) printf("port: %d\n", uri->port); + if (uri->path) printf("path: %s\n", uri->path); + if (uri->query) printf("query: %s\n", uri->query); + if (uri->fragment) printf("fragment: %s\n", uri->fragment); + if (uri->query_raw) printf("query_raw: %s\n", uri->query_raw); + if (uri->cleanup != 0) printf("cleanup\n"); + } + xmlNormalizeURIPath(uri->path); + if (escape != 0) { + parsed = xmlSaveUri(uri); + res = xmlURIEscape(parsed); + printf("%s\n", (char *) res); + + } else { + xmlPrintURI(stdout, uri); + printf("\n"); + } + } + } else { + if (relative) { + res = xmlBuildRelativeURI((xmlChar *)str, (xmlChar *) base); + } else { + res = xmlBuildURI((xmlChar *)str, (xmlChar *) base); + } + + if (res != NULL) { + printf("%s\n", (char *) res); + } + else + printf("::ERROR::\n"); + } + if (res != NULL) + xmlFree(res); + if (parsed != NULL) + xmlFree(parsed); + xmlFreeURI(uri); +} + +int main(int argc, char **argv) { + int i, arg = 1; + + if ((argc > arg) && (argv[arg] != NULL) && + (!strcmp(argv[arg], "--relative"))) { + arg++; + relative++; + } + if ((argc > arg) && (argv[arg] != NULL) && + ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) { + arg++; + base = argv[arg]; + if (base != NULL) + arg++; + } + if ((argc > arg) && (argv[arg] != NULL) && + ((!strcmp(argv[arg], "-escape")) || (!strcmp(argv[arg], "--escape")))) { + arg++; + escape++; + } + if ((argc > arg) && (argv[arg] != NULL) && + ((!strcmp(argv[arg], "-debug")) || (!strcmp(argv[arg], "--debug")))) { + arg++; + debug++; + } + if (argv[arg] == NULL) { + char str[1024]; + + while (1) { + /* + * read one line in string buffer. + */ + if (fgets (&str[0], sizeof (str) - 1, stdin) == NULL) + break; + + /* + * remove the ending spaces + */ + i = strlen(str); + while ((i > 0) && + ((str[i - 1] == '\n') || (str[i - 1] == '\r') || + (str[i - 1] == ' ') || (str[i - 1] == '\t'))) { + i--; + str[i] = 0; + } + handleURI(str); + } + } else { + while (argv[arg] != NULL) { + handleURI(argv[arg]); + arg++; + } + } + xmlMemoryDump(); + return(0); +} diff --git a/src/testXPath.c b/src/testXPath.c new file mode 100644 index 000000000000..ebb9ff7bbd85 --- /dev/null +++ b/src/testXPath.c @@ -0,0 +1,229 @@ +/* + * testXPath.c : a small tester program for XPath. + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) + +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(LIBXML_XPTR_ENABLED) +#include +static int xptr = 0; +#endif +static int debug = 0; +static int valid = 0; +static int expr = 0; +static int tree = 0; +static int nocdata = 0; +static xmlDocPtr document = NULL; + +/* + * Default document + */ +static xmlChar buffer[] = +"\n\ +\n\ + \n\ + Welcome to Gnome\n\ + \n\ + \n\ + The Linux adventure\n\ +

    bla bla bla ...

    \n\ + \n\ +

    ...

    \n\ +
    \n\ + \n\ + Chapter 2\n\ +

    this is chapter 2 ...

    \n\ +
    \n\ + \n\ + Chapter 3\n\ +

    this is chapter 3 ...

    \n\ +
    \n\ +
    \n\ +"; + + +static void +testXPath(const char *str) { + xmlXPathObjectPtr res; + xmlXPathContextPtr ctxt; + +#if defined(LIBXML_XPTR_ENABLED) + if (xptr) { + ctxt = xmlXPtrNewContext(document, NULL, NULL); + res = xmlXPtrEval(BAD_CAST str, ctxt); + } else { +#endif + ctxt = xmlXPathNewContext(document); + ctxt->node = xmlDocGetRootElement(document); + if (expr) + res = xmlXPathEvalExpression(BAD_CAST str, ctxt); + else { + /* res = xmlXPathEval(BAD_CAST str, ctxt); */ + xmlXPathCompExprPtr comp; + + comp = xmlXPathCompile(BAD_CAST str); + if (comp != NULL) { + if (tree) + xmlXPathDebugDumpCompExpr(stdout, comp, 0); + + res = xmlXPathCompiledEval(comp, ctxt); + xmlXPathFreeCompExpr(comp); + } else + res = NULL; + } +#if defined(LIBXML_XPTR_ENABLED) + } +#endif + xmlXPathDebugDumpObject(stdout, res, 0); + xmlXPathFreeObject(res); + xmlXPathFreeContext(ctxt); +} + +static void +testXPathFile(const char *filename) { + FILE *input; + char expression[5000]; + int len; + + input = fopen(filename, "r"); + if (input == NULL) { + xmlGenericError(xmlGenericErrorContext, + "Cannot open %s for reading\n", filename); + return; + } + while (fgets(expression, 4500, input) != NULL) { + len = strlen(expression); + len--; + while ((len >= 0) && + ((expression[len] == '\n') || (expression[len] == '\t') || + (expression[len] == '\r') || (expression[len] == ' '))) len--; + expression[len + 1] = 0; + if (len >= 0) { + printf("\n========================\nExpression: %s\n", expression) ; + testXPath(expression); + } + } + + fclose(input); +} + +int main(int argc, char **argv) { + int i; + int strings = 0; + int usefile = 0; + char *filename = NULL; + + for (i = 1; i < argc ; i++) { +#if defined(LIBXML_XPTR_ENABLED) + if ((!strcmp(argv[i], "-xptr")) || (!strcmp(argv[i], "--xptr"))) + xptr++; + else +#endif + if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) + debug++; + else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) + valid++; + else if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr"))) + expr++; + else if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree"))) + tree++; + else if ((!strcmp(argv[i], "-nocdata")) || + (!strcmp(argv[i], "--nocdata"))) + nocdata++; + else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input"))) + filename = argv[++i]; + else if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file"))) + usefile++; + } + if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; + xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS; + xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS; + xmlSubstituteEntitiesDefaultValue = 1; +#ifdef LIBXML_SAX1_ENABLED + if (nocdata != 0) { + xmlDefaultSAXHandlerInit(); + xmlDefaultSAXHandler.cdataBlock = NULL; + } +#endif + if (document == NULL) { + if (filename == NULL) + document = xmlReadDoc(buffer,NULL,NULL,XML_PARSE_COMPACT); + else + document = xmlReadFile(filename,NULL,XML_PARSE_COMPACT); + } + for (i = 1; i < argc ; i++) { + if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input"))) { + i++; continue; + } + if (argv[i][0] != '-') { + if (usefile) + testXPathFile(argv[i]); + else + testXPath(argv[i]); + strings ++; + } + } + if (strings == 0) { + printf("Usage : %s [--debug] [--copy] stringsorfiles ...\n", + argv[0]); + printf("\tParse the XPath strings and output the result of the parsing\n"); + printf("\t--debug : dump a debug version of the result\n"); + printf("\t--valid : switch on DTD support in the parser\n"); +#if defined(LIBXML_XPTR_ENABLED) + printf("\t--xptr : expressions are XPointer expressions\n"); +#endif + printf("\t--expr : debug XPath expressions only\n"); + printf("\t--tree : show the compiled XPath tree\n"); + printf("\t--nocdata : do not generate CDATA nodes\n"); + printf("\t--input filename : or\n"); + printf("\t-i filename : read the document from filename\n"); + printf("\t--file : or\n"); + printf("\t-f : read queries from files, args\n"); + } + if (document != NULL) + xmlFreeDoc(document); + xmlCleanupParser(); + xmlMemoryDump(); + + return(0); +} +#else +#include +int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + printf("%s : XPath/Debug support not compiled in\n", argv[0]); + return(0); +} +#endif /* LIBXML_XPATH_ENABLED */ diff --git a/src/testapi.c b/src/testapi.c new file mode 100644 index 000000000000..6f19c6fc9676 --- /dev/null +++ b/src/testapi.c @@ -0,0 +1,52376 @@ +/* + * testapi.c: libxml2 API tester program. + * + * Automatically generated by gentest.py from libxml2-api.xml + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#include + +#include /* for putenv() */ +#include +#include +#include + + +static int testlibxml2(void); +static int test_module(const char *module); + +static int generic_errors = 0; +static int call_tests = 0; +static int function_tests = 0; + +static xmlChar chartab[1024]; +static int inttab[1024]; +static unsigned long longtab[1024]; + +static xmlDocPtr api_doc = NULL; +static xmlDtdPtr api_dtd = NULL; +static xmlNodePtr api_root = NULL; +static xmlAttrPtr api_attr = NULL; +static xmlNsPtr api_ns = NULL; + +static void +structured_errors(void *userData ATTRIBUTE_UNUSED, + xmlErrorPtr error ATTRIBUTE_UNUSED) { + generic_errors++; +} + +static void +free_api_doc(void) { + xmlFreeDoc(api_doc); + api_doc = NULL; + api_dtd = NULL; + api_root = NULL; + api_attr = NULL; + api_ns = NULL; +} + +static xmlDocPtr +get_api_doc(void) { + if (api_doc == NULL) { + api_doc = xmlReadMemory("]>", 88, "root_test", NULL, 0); + api_root = NULL; + api_attr = NULL; + } + return(api_doc); +} + +static xmlDtdPtr +get_api_dtd(void) { + if ((api_dtd == NULL) || (api_dtd->type != XML_DTD_NODE)) { + get_api_doc(); + if ((api_doc != NULL) && (api_doc->children != NULL) && + (api_doc->children->type == XML_DTD_NODE)) + api_dtd = (xmlDtdPtr) api_doc->children; + } + return(api_dtd); +} + +static xmlNodePtr +get_api_root(void) { + if ((api_root == NULL) || (api_root->type != XML_ELEMENT_NODE)) { + get_api_doc(); + if ((api_doc != NULL) && (api_doc->children != NULL) && + (api_doc->children->next != NULL) && + (api_doc->children->next->type == XML_ELEMENT_NODE)) + api_root = api_doc->children->next; + } + return(api_root); +} + +static xmlNsPtr +get_api_ns(void) { + get_api_root(); + if (api_root != NULL) + api_ns = api_root->nsDef; + return(api_ns); +} + +static xmlAttrPtr +get_api_attr(void) { +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) + static int nr = 0; + xmlChar name[20]; +#endif + + if ((api_root == NULL) || (api_root->type != XML_ELEMENT_NODE)) { + get_api_root(); + } + if (api_root == NULL) + return(NULL); + if (api_root->properties != NULL) { + api_attr = api_root->properties; + return(api_root->properties); + } + api_attr = NULL; +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) + snprintf((char *) name, 20, "foo%d", nr++); + api_attr = xmlSetProp(api_root, name, (const xmlChar *) "bar"); +#endif + return(api_attr); +} + +static int quiet = 0; + +int main(int argc, char **argv) { + int ret; + int blocks, mem; + +#ifdef HAVE_PUTENV + /* access to the proxy can slow up regression tests a lot */ + putenv((char *) "http_proxy="); +#endif + + memset(chartab, 0, sizeof(chartab)); + strncpy((char *) chartab, " chartab\n", 20); + memset(inttab, 0, sizeof(inttab)); + memset(longtab, 0, sizeof(longtab)); + + xmlInitParser(); +#ifdef LIBXML_SCHEMAS_ENABLED + xmlRelaxNGInitTypes(); +#endif + + LIBXML_TEST_VERSION + + xmlSetStructuredErrorFunc(NULL, structured_errors); + + if (argc >= 2) { + if (!strcmp(argv[1], "-q")) { + quiet = 1; + if (argc >= 3) + ret = test_module(argv[2]); + else + ret = testlibxml2(); + } else { + ret = test_module(argv[1]); + } + } else + ret = testlibxml2(); + + xmlCleanupParser(); + blocks = xmlMemBlocks(); + mem = xmlMemUsed(); + if ((blocks != 0) || (mem != 0)) { + printf("testapi leaked %d bytes in %d blocks\n", mem, blocks); + } + xmlMemoryDump(); + + return (ret != 0); +} + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + We manually define xmlErrMemory because it's normal declaration + is "hidden" by #ifdef IN_LIBXML +*/ +void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra); + +/* + We need some "remote" addresses, but want to avoid getting into + name resolution delays, so we use these +*/ +#define REMOTE1GOOD "http://localhost/" +#define REMOTE1BAD "http:http://http" +#define REMOTE2GOOD "ftp://localhost/foo" + +#define gen_nb_void_ptr 2 + +static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#if 0 +#define gen_nb_const_void_ptr 2 + +static const void *gen_const_void_ptr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return((const void *) "immutable string"); + return(NULL); +} +static void des_const_void_ptr(int no ATTRIBUTE_UNUSED, const void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#define gen_nb_userdata 3 + +static void *gen_userdata(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return((void *) &call_tests); + if (no == 1) return((void *) -1); + return(NULL); +} +static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + + +#define gen_nb_int 4 + +static int gen_int(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(0); + if (no == 1) return(1); + if (no == 2) return(-1); + if (no == 3) return(122); + return(-1); +} + +static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_parseroptions 5 + +static int gen_parseroptions(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(XML_PARSE_NOBLANKS | XML_PARSE_RECOVER); + if (no == 1) return(XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_DTDVALID | XML_PARSE_NOCDATA); + if (no == 2) return(XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE | XML_PARSE_NSCLEAN); + if (no == 3) return(XML_PARSE_XINCLUDE | XML_PARSE_NODICT); + return(XML_PARSE_SAX1); +} + +static void des_parseroptions(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#if 0 +#define gen_nb_long 5 + +static long gen_long(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(0); + if (no == 1) return(1); + if (no == 2) return(-1); + if (no == 3) return(122); + return(-1); +} + +static void des_long(int no ATTRIBUTE_UNUSED, long val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#define gen_nb_xmlChar 4 + +static xmlChar gen_xmlChar(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return('a'); + if (no == 1) return(' '); + if (no == 2) return((xmlChar) '\xf8'); + return(0); +} + +static void des_xmlChar(int no ATTRIBUTE_UNUSED, xmlChar val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_unsigned_int 3 + +static unsigned int gen_unsigned_int(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(0); + if (no == 1) return(1); + if (no == 2) return(122); + return((unsigned int) -1); +} + +static void des_unsigned_int(int no ATTRIBUTE_UNUSED, unsigned int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_unsigned_long 4 + +static unsigned long gen_unsigned_long(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(0); + if (no == 1) return(1); + if (no == 2) return(122); + return((unsigned long) -1); +} + +static void des_unsigned_long(int no ATTRIBUTE_UNUSED, unsigned long val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_double 4 + +static double gen_double(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(0); + if (no == 1) return(-1.1); +#if defined(LIBXML_XPATH_ENABLED) + if (no == 2) return(xmlXPathNAN); +#endif + return(-1); +} + +static void des_double(int no ATTRIBUTE_UNUSED, double val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_unsigned_long_ptr 2 + +static unsigned long *gen_unsigned_long_ptr(int no, int nr) { + if (no == 0) return(&longtab[nr]); + return(NULL); +} + +static void des_unsigned_long_ptr(int no ATTRIBUTE_UNUSED, unsigned long *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_int_ptr 2 + +static int *gen_int_ptr(int no, int nr) { + if (no == 0) return(&inttab[nr]); + return(NULL); +} + +static void des_int_ptr(int no ATTRIBUTE_UNUSED, int *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_const_char_ptr 4 + +static char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return((char *) "foo"); + if (no == 1) return((char *) ""); + if (no == 2) return((char *) "test/ent2"); + return(NULL); +} +static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlChar_ptr 2 + +static xmlChar *gen_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(&chartab[0]); + return(NULL); +} +static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_FILE_ptr 2 + +static FILE *gen_FILE_ptr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(fopen("test.out", "a+")); + return(NULL); +} +static void des_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) fclose(val); +} + +#define gen_nb_debug_FILE_ptr 2 +static FILE *gen_debug_FILE_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(fopen("test.out", "a+")); +} +static void des_debug_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) fclose(val); +} + +#define gen_nb_const_xmlChar_ptr 5 + +static xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return((xmlChar *) "foo"); + if (no == 1) return((xmlChar *) ""); + if (no == 2) return((xmlChar *) "n" "\xf8" "ne"); + if (no == 3) return((xmlChar *) " 2ab "); + return(NULL); +} +static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_filepath 8 + +static const char *gen_filepath(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return("missing.xml"); + if (no == 1) return(""); + if (no == 2) return("test/ent2"); + if (no == 3) return("test/valid/REC-xml-19980210.xml"); + if (no == 4) return("test/valid/dtds/xhtml1-strict.dtd"); + if (no == 5) return(REMOTE1GOOD); + if (no == 6) return(REMOTE1BAD); + return(NULL); +} +static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_eaten_name 2 + +static xmlChar *gen_eaten_name(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlStrdup(BAD_CAST "eaten")); + return(NULL); +} +static void des_eaten_name(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_fileoutput 6 + +static const char *gen_fileoutput(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return("/missing.xml"); + if (no == 1) return(""); + if (no == 2) return(REMOTE2GOOD); + if (no == 3) return(REMOTE1GOOD); + if (no == 4) return(REMOTE1BAD); + return(NULL); +} +static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlParserCtxtPtr 3 +static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewParserCtxt()); + if (no == 1) return(xmlCreateMemoryParserCtxt("", 6)); + return(NULL); +} +static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) + xmlFreeParserCtxt(val); +} + +#define gen_nb_xmlSAXHandlerPtr 2 +static xmlSAXHandlerPtr gen_xmlSAXHandlerPtr(int no, int nr ATTRIBUTE_UNUSED) { +#ifdef LIBXML_SAX1_ENABLED + if (no == 0) return((xmlSAXHandlerPtr) &xmlDefaultSAXHandler); +#endif + return(NULL); +} +static void des_xmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, xmlSAXHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlValidCtxtPtr 2 +static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) { +#ifdef LIBXML_VALID_ENABLED + if (no == 0) return(xmlNewValidCtxt()); +#endif + return(NULL); +} +static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val, int nr ATTRIBUTE_UNUSED) { +#ifdef LIBXML_VALID_ENABLED + if (val != NULL) + xmlFreeValidCtxt(val); +#endif +} + +#define gen_nb_xmlParserInputBufferPtr 8 + +static xmlParserInputBufferPtr gen_xmlParserInputBufferPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlParserInputBufferCreateFilename("missing.xml", XML_CHAR_ENCODING_NONE)); + if (no == 1) return(xmlParserInputBufferCreateFilename("", XML_CHAR_ENCODING_NONE)); + if (no == 2) return(xmlParserInputBufferCreateFilename("test/ent2", XML_CHAR_ENCODING_NONE)); + if (no == 3) return(xmlParserInputBufferCreateFilename("test/valid/REC-xml-19980210.xml", XML_CHAR_ENCODING_NONE)); + if (no == 4) return(xmlParserInputBufferCreateFilename("test/valid/dtds/xhtml1-strict.dtd", XML_CHAR_ENCODING_NONE)); + if (no == 5) return(xmlParserInputBufferCreateFilename(REMOTE1GOOD, XML_CHAR_ENCODING_NONE)); + if (no == 6) return(xmlParserInputBufferCreateFilename(REMOTE1BAD, XML_CHAR_ENCODING_NONE)); + return(NULL); +} +static void des_xmlParserInputBufferPtr(int no ATTRIBUTE_UNUSED, xmlParserInputBufferPtr val, int nr ATTRIBUTE_UNUSED) { + xmlFreeParserInputBuffer(val); +} + +#define gen_nb_xmlDocPtr 4 +static xmlDocPtr gen_xmlDocPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewDoc(BAD_CAST "1.0")); + if (no == 1) return(xmlReadMemory("", 6, "test", NULL, 0)); + if (no == 2) return(xmlReadMemory(" ", 24, "test", NULL, 0)); + return(NULL); +} +static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val, int nr ATTRIBUTE_UNUSED) { + if ((val != NULL) && (val != api_doc) && (val->doc != api_doc)) + xmlFreeDoc(val); +} + +#define gen_nb_xmlAttrPtr 2 +static xmlAttrPtr gen_xmlAttrPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(get_api_attr()); + return(NULL); +} +static void des_xmlAttrPtr(int no, xmlAttrPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + if (no == 0) free_api_doc(); +} + +#define gen_nb_xmlDictPtr 2 +static xmlDictPtr gen_xmlDictPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlDictCreate()); + return(NULL); +} +static void des_xmlDictPtr(int no ATTRIBUTE_UNUSED, xmlDictPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) + xmlDictFree(val); +} + +#define gen_nb_xmlNodePtr 3 +static xmlNodePtr gen_xmlNodePtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL)); + if (no == 1) return(get_api_root()); + return(NULL); +/* if (no == 2) return((xmlNodePtr) get_api_doc()); */ +} +static void des_xmlNodePtr(int no, xmlNodePtr val, int nr ATTRIBUTE_UNUSED) { + if (no == 1) { + free_api_doc(); + } else if (val != NULL) { + xmlUnlinkNode(val); + xmlFreeNode(val); + } +} + +#define gen_nb_xmlDtdPtr 3 +static xmlDtdPtr gen_xmlDtdPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) + return(xmlNewDtd(NULL, BAD_CAST "dtd", BAD_CAST"foo", BAD_CAST"bar")); + if (no == 1) return(get_api_dtd()); + return(NULL); +} +static void des_xmlDtdPtr(int no, xmlDtdPtr val, int nr ATTRIBUTE_UNUSED) { + if (no == 1) free_api_doc(); + else if (val != NULL) { + xmlUnlinkNode((xmlNodePtr) val); + xmlFreeNode((xmlNodePtr) val); + } +} + +#define gen_nb_xmlNsPtr 2 +static xmlNsPtr gen_xmlNsPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(get_api_ns()); + return(NULL); +} +static void des_xmlNsPtr(int no, xmlNsPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + if (no == 0) free_api_doc(); +} + +#define gen_nb_xmlNodePtr_in 3 +static xmlNodePtr gen_xmlNodePtr_in(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL)); + if (no == 0) return(xmlNewText(BAD_CAST "text")); + return(NULL); +} +static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#ifdef LIBXML_WRITER_ENABLED +#define gen_nb_xmlTextWriterPtr 2 +static xmlTextWriterPtr gen_xmlTextWriterPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewTextWriterFilename("test.out", 0)); + return(NULL); +} +static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) xmlFreeTextWriter(val); +} +#endif + +#ifdef LIBXML_READER_ENABLED +#define gen_nb_xmlTextReaderPtr 4 +static xmlTextReaderPtr gen_xmlTextReaderPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewTextReaderFilename("test/ent2")); + if (no == 1) return(xmlNewTextReaderFilename("test/valid/REC-xml-19980210.xml")); + if (no == 2) return(xmlNewTextReaderFilename("test/valid/dtds/xhtml1-strict.dtd")); + return(NULL); +} +static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) xmlFreeTextReader(val); +} +#endif + +#define gen_nb_xmlBufferPtr 3 +static const xmlChar *static_buf_content = (xmlChar *)"a static buffer"; +static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlBufferCreate()); + if (no == 1) return(xmlBufferCreateStatic((void *)static_buf_content, 13)); + return(NULL); +} +static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlBufferFree(val); + } +} + +#define gen_nb_xmlListPtr 2 +static xmlListPtr gen_xmlListPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlListCreate(NULL, NULL)); + return(NULL); +} +static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlListDelete(val); + } +} + +#define gen_nb_xmlHashTablePtr 2 +static xmlHashTablePtr gen_xmlHashTablePtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlHashCreate(10)); + return(NULL); +} +static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlHashFree(val, NULL); + } +} + +#include + +#ifdef LIBXML_XPATH_ENABLED +#define gen_nb_xmlXPathObjectPtr 5 +static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlXPathNewString(BAD_CAST "string object")); + if (no == 1) return(xmlXPathNewFloat(1.1)); + if (no == 2) return(xmlXPathNewBoolean(1)); + if (no == 3) return(xmlXPathNewNodeSet(NULL)); + return(NULL); +} +static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlXPathFreeObject(val); + } +} +#endif + +#ifdef LIBXML_OUTPUT_ENABLED +#define gen_nb_xmlOutputBufferPtr 2 +static xmlOutputBufferPtr gen_xmlOutputBufferPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlOutputBufferCreateFilename("test.out", NULL, 0)); + return(NULL); +} +static void des_xmlOutputBufferPtr(int no ATTRIBUTE_UNUSED, xmlOutputBufferPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlOutputBufferClose(val); + } +} +#endif + +#ifdef LIBXML_FTP_ENABLED +#define gen_nb_xmlNanoFTPCtxtPtr 4 +static void *gen_xmlNanoFTPCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNanoFTPNewCtxt(REMOTE2GOOD)); + if (no == 1) return(xmlNanoFTPNewCtxt(REMOTE1GOOD)); + if (no == 2) return(xmlNanoFTPNewCtxt("foo")); + return(NULL); +} +static void des_xmlNanoFTPCtxtPtr(int no ATTRIBUTE_UNUSED, void *val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlNanoFTPFreeCtxt(val); + } +} +#endif + +#ifdef LIBXML_HTTP_ENABLED +#define gen_nb_xmlNanoHTTPCtxtPtr 1 +static void *gen_xmlNanoHTTPCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNanoHTTPOpen(REMOTE1GOOD, NULL)); + if (no == 1) return(xmlNanoHTTPOpen(REMOTE2GOOD, NULL)); + if (no == 2) return(xmlNanoHTTPOpen(REMOTE1BAD, NULL)); + return(NULL); +} +static void des_xmlNanoHTTPCtxtPtr(int no ATTRIBUTE_UNUSED, void *val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) { + xmlNanoHTTPClose(val); + } +} +#endif + +#define gen_nb_xmlCharEncoding 4 +static xmlCharEncoding gen_xmlCharEncoding(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(XML_CHAR_ENCODING_UTF8); + if (no == 1) return(XML_CHAR_ENCODING_NONE); + if (no == 2) return(XML_CHAR_ENCODING_8859_1); + return(XML_CHAR_ENCODING_ERROR); +} +static void des_xmlCharEncoding(int no ATTRIBUTE_UNUSED, xmlCharEncoding val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + +#define gen_nb_xmlExpCtxtPtr 1 +static xmlExpCtxtPtr gen_xmlExpCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlExpCtxtPtr(int no ATTRIBUTE_UNUSED, xmlExpCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlExpNodePtr 1 +static xmlExpNodePtr gen_xmlExpNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlExpNodePtr(int no ATTRIBUTE_UNUSED, xmlExpNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#endif + +#if defined(LIBXML_SCHEMAS_ENABLED) +#define gen_nb_xmlSchemaPtr 1 +static xmlSchemaPtr gen_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, xmlSchemaPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlSchemaValidCtxtPtr 1 +static xmlSchemaValidCtxtPtr gen_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#endif /* LIBXML_SCHEMAS_ENABLED */ + +#define gen_nb_xmlHashDeallocator 2 +static void +test_xmlHashDeallocator(void *payload ATTRIBUTE_UNUSED, + const xmlChar *name ATTRIBUTE_UNUSED) { +} + +static xmlHashDeallocator gen_xmlHashDeallocator(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(test_xmlHashDeallocator); + return(NULL); +} +static void des_xmlHashDeallocator(int no ATTRIBUTE_UNUSED, xmlHashDeallocator val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + + +static void desret_int(int val ATTRIBUTE_UNUSED) { +} +static void desret_xmlChar(xmlChar val ATTRIBUTE_UNUSED) { +} +static void desret_long(long val ATTRIBUTE_UNUSED) { +} +static void desret_unsigned_long(unsigned long val ATTRIBUTE_UNUSED) { +} +static void desret_double(double val ATTRIBUTE_UNUSED) { +} +static void desret_xmlCharEncoding(xmlCharEncoding val ATTRIBUTE_UNUSED) { +} +#if 0 +static void desret_const_void_ptr(void *val ATTRIBUTE_UNUSED) { +} +#endif +static void desret_void_ptr(void *val ATTRIBUTE_UNUSED) { +} +static void desret_const_char_ptr(const char *val ATTRIBUTE_UNUSED) { +} +static void desret_const_xmlChar_ptr(const xmlChar *val ATTRIBUTE_UNUSED) { +} +static void desret_xmlChar_ptr(xmlChar *val) { + if (val != NULL) + xmlFree(val); +} +static void desret_xmlDocPtr(xmlDocPtr val) { + if (val != api_doc) + xmlFreeDoc(val); +} +static void desret_xmlDictPtr(xmlDictPtr val) { + xmlDictFree(val); +} +#ifdef LIBXML_OUTPUT_ENABLED +static void desret_xmlOutputBufferPtr(xmlOutputBufferPtr val) { + xmlOutputBufferClose(val); +} +#endif +#ifdef LIBXML_READER_ENABLED +static void desret_xmlTextReaderPtr(xmlTextReaderPtr val) { + xmlFreeTextReader(val); +} +#endif +static void desret_xmlNodePtr(xmlNodePtr val) { + if ((val != NULL) && (val != api_root) && (val != (xmlNodePtr) api_doc)) { + xmlUnlinkNode(val); + xmlFreeNode(val); + } +} +static void desret_xmlAttrPtr(xmlAttrPtr val) { + if (val != NULL) { + xmlUnlinkNode((xmlNodePtr) val); + xmlFreeNode((xmlNodePtr) val); + } +} +static void desret_xmlEntityPtr(xmlEntityPtr val) { + if (val != NULL) { + xmlUnlinkNode((xmlNodePtr) val); + xmlFreeNode((xmlNodePtr) val); + } +} +static void desret_xmlElementPtr(xmlElementPtr val) { + if (val != NULL) { + xmlUnlinkNode((xmlNodePtr) val); + } +} +static void desret_xmlAttributePtr(xmlAttributePtr val) { + if (val != NULL) { + xmlUnlinkNode((xmlNodePtr) val); + } +} +static void desret_xmlNsPtr(xmlNsPtr val ATTRIBUTE_UNUSED) { +} +static void desret_xmlDtdPtr(xmlDtdPtr val) { + desret_xmlNodePtr((xmlNodePtr)val); +} +#ifdef LIBXML_XPATH_ENABLED +static void desret_xmlXPathObjectPtr(xmlXPathObjectPtr val) { + xmlXPathFreeObject(val); +} +static void desret_xmlNodeSetPtr(xmlNodeSetPtr val) { + xmlXPathFreeNodeSet(val); +} +#endif +static void desret_xmlParserCtxtPtr(xmlParserCtxtPtr val) { + xmlFreeParserCtxt(val); +} +static void desret_xmlParserInputBufferPtr(xmlParserInputBufferPtr val) { + xmlFreeParserInputBuffer(val); +} +static void desret_xmlParserInputPtr(xmlParserInputPtr val) { + xmlFreeInputStream(val); +} +#ifdef LIBXML_WRITER_ENABLED +static void desret_xmlTextWriterPtr(xmlTextWriterPtr val) { + xmlFreeTextWriter(val); +} +#endif +static void desret_xmlBufferPtr(xmlBufferPtr val) { + xmlBufferFree(val); +} +#ifdef LIBXML_SCHEMAS_ENABLED +static void desret_xmlSchemaParserCtxtPtr(xmlSchemaParserCtxtPtr val) { + xmlSchemaFreeParserCtxt(val); +} +static void desret_xmlSchemaTypePtr(xmlSchemaTypePtr val ATTRIBUTE_UNUSED) { +} +static void desret_xmlRelaxNGParserCtxtPtr(xmlRelaxNGParserCtxtPtr val) { + xmlRelaxNGFreeParserCtxt(val); +} +#endif +#ifdef LIBXML_HTML_ENABLED +static void desret_const_htmlEntityDesc_ptr(const htmlEntityDesc * val ATTRIBUTE_UNUSED) { +} +#endif +#ifdef LIBXML_HTTP_ENABLED +static void desret_xmlNanoHTTPCtxtPtr(void *val) { + xmlNanoHTTPClose(val); +} +#endif +#ifdef LIBXML_FTP_ENABLED +static void desret_xmlNanoFTPCtxtPtr(void *val) { + xmlNanoFTPClose(val); +} +#endif +/* cut and pasted from autogenerated to avoid troubles */ +#define gen_nb_const_xmlChar_ptr_ptr 1 +static xmlChar ** gen_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, const xmlChar ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_unsigned_char_ptr 1 +static unsigned char * gen_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_const_unsigned_char_ptr 1 +static unsigned char * gen_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, const unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#ifdef LIBXML_HTML_ENABLED +#define gen_nb_const_htmlNodePtr 1 +static htmlNodePtr gen_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, const htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_HTML_ENABLED +#define gen_nb_htmlDocPtr 3 +static htmlDocPtr gen_htmlDocPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(htmlNewDoc(NULL, NULL)); + if (no == 1) return(htmlReadMemory("", 7, "test", NULL, 0)); + return(NULL); +} +static void des_htmlDocPtr(int no ATTRIBUTE_UNUSED, htmlDocPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + if ((val != NULL) && (val != api_doc) && (val->doc != api_doc)) + xmlFreeDoc(val); +} +static void desret_htmlDocPtr(htmlDocPtr val) { + if ((val != NULL) && (val != api_doc) && (val->doc != api_doc)) + xmlFreeDoc(val); +} +#define gen_nb_htmlParserCtxtPtr 3 +static htmlParserCtxtPtr gen_htmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + if (no == 0) return(xmlNewParserCtxt()); + if (no == 1) return(htmlCreateMemoryParserCtxt("", 7)); + return(NULL); +} +static void des_htmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, htmlParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) + htmlFreeParserCtxt(val); +} +static void desret_htmlParserCtxtPtr(htmlParserCtxtPtr val) { + if (val != NULL) + htmlFreeParserCtxt(val); +} +#endif + +#ifdef LIBXML_XPATH_ENABLED +#define gen_nb_xmlNodeSetPtr 1 +static xmlNodeSetPtr gen_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, xmlNodeSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_DEBUG_ENABLED +#ifdef LIBXML_XPATH_ENABLED +#define gen_nb_xmlShellCtxtPtr 1 +static xmlShellCtxtPtr gen_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, xmlShellCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif +#endif + +#ifdef LIBXML_PATTERN_ENABLED +#define gen_nb_xmlPatternPtr 1 +static xmlPatternPtr gen_xmlPatternPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlPatternPtr(int no ATTRIBUTE_UNUSED, xmlPatternPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#define gen_nb_xmlElementContentPtr 1 +static xmlElementContentPtr gen_xmlElementContentPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlElementContentPtr(int no ATTRIBUTE_UNUSED, xmlElementContentPtr val, int nr ATTRIBUTE_UNUSED) { + if (val != NULL) + xmlFreeElementContent(val); +} +static void desret_xmlElementContentPtr(xmlElementContentPtr val) { + if (val != NULL) + xmlFreeElementContent(val); +} + +#define gen_nb_xmlParserNodeInfoSeqPtr 1 +static xmlParserNodeInfoSeqPtr gen_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, xmlParserNodeInfoSeqPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static void desret_const_xmlParserNodeInfo_ptr(const xmlParserNodeInfo *val ATTRIBUTE_UNUSED) { +} + +#define gen_nb_void_ptr_ptr 1 +static void ** gen_void_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_void_ptr_ptr(int no ATTRIBUTE_UNUSED, void ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +/************************************************************************ + * * + * WARNING: end of the manually maintained part of the test code * + * do not remove or alter the CUT HERE line * + * * + ************************************************************************/ + +/* CUT HERE: everything below that line is generated */ +#ifdef LIBXML_HTML_ENABLED +static void desret_htmlStatus(htmlStatus val ATTRIBUTE_UNUSED) { +} + +#endif + +#define gen_nb_xmlAttributeDefault 4 +static xmlAttributeDefault gen_xmlAttributeDefault(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_ATTRIBUTE_FIXED); + if (no == 2) return(XML_ATTRIBUTE_IMPLIED); + if (no == 3) return(XML_ATTRIBUTE_NONE); + if (no == 4) return(XML_ATTRIBUTE_REQUIRED); + return(0); +} + +static void des_xmlAttributeDefault(int no ATTRIBUTE_UNUSED, xmlAttributeDefault val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlAttributeType 4 +static xmlAttributeType gen_xmlAttributeType(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_ATTRIBUTE_CDATA); + if (no == 2) return(XML_ATTRIBUTE_ENTITIES); + if (no == 3) return(XML_ATTRIBUTE_ENTITY); + if (no == 4) return(XML_ATTRIBUTE_ENUMERATION); + return(0); +} + +static void des_xmlAttributeType(int no ATTRIBUTE_UNUSED, xmlAttributeType val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlBufferAllocationScheme 4 +static xmlBufferAllocationScheme gen_xmlBufferAllocationScheme(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_BUFFER_ALLOC_BOUNDED); + if (no == 2) return(XML_BUFFER_ALLOC_DOUBLEIT); + if (no == 3) return(XML_BUFFER_ALLOC_EXACT); + if (no == 4) return(XML_BUFFER_ALLOC_HYBRID); + return(0); +} + +static void des_xmlBufferAllocationScheme(int no ATTRIBUTE_UNUSED, xmlBufferAllocationScheme val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static void desret_xmlBufferAllocationScheme(xmlBufferAllocationScheme val ATTRIBUTE_UNUSED) { +} + +#ifdef LIBXML_CATALOG_ENABLED +#define gen_nb_xmlCatalogAllow 4 +static xmlCatalogAllow gen_xmlCatalogAllow(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_CATA_ALLOW_ALL); + if (no == 2) return(XML_CATA_ALLOW_DOCUMENT); + if (no == 3) return(XML_CATA_ALLOW_GLOBAL); + if (no == 4) return(XML_CATA_ALLOW_NONE); + return(0); +} + +static void des_xmlCatalogAllow(int no ATTRIBUTE_UNUSED, xmlCatalogAllow val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static void desret_xmlCatalogAllow(xmlCatalogAllow val ATTRIBUTE_UNUSED) { +} + +#endif + +#ifdef LIBXML_CATALOG_ENABLED +#define gen_nb_xmlCatalogPrefer 3 +static xmlCatalogPrefer gen_xmlCatalogPrefer(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_CATA_PREFER_NONE); + if (no == 2) return(XML_CATA_PREFER_PUBLIC); + if (no == 3) return(XML_CATA_PREFER_SYSTEM); + return(0); +} + +static void des_xmlCatalogPrefer(int no ATTRIBUTE_UNUSED, xmlCatalogPrefer val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static void desret_xmlCatalogPrefer(xmlCatalogPrefer val ATTRIBUTE_UNUSED) { +} + +#endif + +#define gen_nb_xmlElementContentType 4 +static xmlElementContentType gen_xmlElementContentType(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_ELEMENT_CONTENT_ELEMENT); + if (no == 2) return(XML_ELEMENT_CONTENT_OR); + if (no == 3) return(XML_ELEMENT_CONTENT_PCDATA); + if (no == 4) return(XML_ELEMENT_CONTENT_SEQ); + return(0); +} + +static void des_xmlElementContentType(int no ATTRIBUTE_UNUSED, xmlElementContentType val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlElementTypeVal 4 +static xmlElementTypeVal gen_xmlElementTypeVal(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_ELEMENT_TYPE_ANY); + if (no == 2) return(XML_ELEMENT_TYPE_ELEMENT); + if (no == 3) return(XML_ELEMENT_TYPE_EMPTY); + if (no == 4) return(XML_ELEMENT_TYPE_MIXED); + return(0); +} + +static void des_xmlElementTypeVal(int no ATTRIBUTE_UNUSED, xmlElementTypeVal val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_xmlFeature 4 +static xmlFeature gen_xmlFeature(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_WITH_AUTOMATA); + if (no == 2) return(XML_WITH_C14N); + if (no == 3) return(XML_WITH_CATALOG); + if (no == 4) return(XML_WITH_DEBUG); + return(0); +} + +static void des_xmlFeature(int no ATTRIBUTE_UNUSED, xmlFeature val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static void desret_xmlParserErrors(xmlParserErrors val ATTRIBUTE_UNUSED) { +} + +#ifdef LIBXML_SCHEMAS_ENABLED +#define gen_nb_xmlSchemaValType 4 +static xmlSchemaValType gen_xmlSchemaValType(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_SCHEMAS_ANYSIMPLETYPE); + if (no == 2) return(XML_SCHEMAS_ANYTYPE); + if (no == 3) return(XML_SCHEMAS_ANYURI); + if (no == 4) return(XML_SCHEMAS_BASE64BINARY); + return(0); +} + +static void des_xmlSchemaValType(int no ATTRIBUTE_UNUSED, xmlSchemaValType val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static void desret_xmlSchemaValType(xmlSchemaValType val ATTRIBUTE_UNUSED) { +} + +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED +#define gen_nb_xmlSchemaWhitespaceValueType 4 +static xmlSchemaWhitespaceValueType gen_xmlSchemaWhitespaceValueType(int no, int nr ATTRIBUTE_UNUSED) { + if (no == 1) return(XML_SCHEMA_WHITESPACE_COLLAPSE); + if (no == 2) return(XML_SCHEMA_WHITESPACE_PRESERVE); + if (no == 3) return(XML_SCHEMA_WHITESPACE_REPLACE); + if (no == 4) return(XML_SCHEMA_WHITESPACE_UNKNOWN); + return(0); +} + +static void des_xmlSchemaWhitespaceValueType(int no ATTRIBUTE_UNUSED, xmlSchemaWhitespaceValueType val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +static int test_HTMLparser(void); +static int test_HTMLtree(void); +static int test_SAX2(void); +static int test_c14n(void); +static int test_catalog(void); +static int test_chvalid(void); +static int test_debugXML(void); +static int test_dict(void); +static int test_encoding(void); +static int test_entities(void); +static int test_hash(void); +static int test_list(void); +static int test_nanoftp(void); +static int test_nanohttp(void); +static int test_parser(void); +static int test_parserInternals(void); +static int test_pattern(void); +static int test_relaxng(void); +static int test_schemasInternals(void); +static int test_schematron(void); +static int test_tree(void); +static int test_uri(void); +static int test_valid(void); +static int test_xinclude(void); +static int test_xmlIO(void); +static int test_xmlautomata(void); +static int test_xmlerror(void); +static int test_xmlmodule(void); +static int test_xmlreader(void); +static int test_xmlregexp(void); +static int test_xmlsave(void); +static int test_xmlschemas(void); +static int test_xmlschemastypes(void); +static int test_xmlstring(void); +static int test_xmlunicode(void); +static int test_xmlwriter(void); +static int test_xpath(void); +static int test_xpathInternals(void); +static int test_xpointer(void); + +/** + * testlibxml2: + * + * Main entry point of the tester for the full libxml2 module, + * it calls all the tester entry point for each module. + * + * Returns the number of error found + */ +static int +testlibxml2(void) +{ + int test_ret = 0; + + test_ret += test_HTMLparser(); + test_ret += test_HTMLtree(); + test_ret += test_SAX2(); + test_ret += test_c14n(); + test_ret += test_catalog(); + test_ret += test_chvalid(); + test_ret += test_debugXML(); + test_ret += test_dict(); + test_ret += test_encoding(); + test_ret += test_entities(); + test_ret += test_hash(); + test_ret += test_list(); + test_ret += test_nanoftp(); + test_ret += test_nanohttp(); + test_ret += test_parser(); + test_ret += test_parserInternals(); + test_ret += test_pattern(); + test_ret += test_relaxng(); + test_ret += test_schemasInternals(); + test_ret += test_schematron(); + test_ret += test_tree(); + test_ret += test_uri(); + test_ret += test_valid(); + test_ret += test_xinclude(); + test_ret += test_xmlIO(); + test_ret += test_xmlautomata(); + test_ret += test_xmlerror(); + test_ret += test_xmlmodule(); + test_ret += test_xmlreader(); + test_ret += test_xmlregexp(); + test_ret += test_xmlsave(); + test_ret += test_xmlschemas(); + test_ret += test_xmlschemastypes(); + test_ret += test_xmlstring(); + test_ret += test_xmlunicode(); + test_ret += test_xmlwriter(); + test_ret += test_xpath(); + test_ret += test_xpathInternals(); + test_ret += test_xpointer(); + + printf("Total: %d functions, %d tests, %d errors\n", + function_tests, call_tests, test_ret); + return(test_ret); +} + + +static int +test_UTF8ToHtml(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + unsigned char * out; /* a pointer to an array of bytes to store the result */ + int n_out; + int * outlen; /* the length of @out */ + int n_outlen; + unsigned char * in; /* a pointer to an array of UTF-8 chars */ + int n_in; + int * inlen; /* the length of @in */ + int n_inlen; + + for (n_out = 0;n_out < gen_nb_unsigned_char_ptr;n_out++) { + for (n_outlen = 0;n_outlen < gen_nb_int_ptr;n_outlen++) { + for (n_in = 0;n_in < gen_nb_const_unsigned_char_ptr;n_in++) { + for (n_inlen = 0;n_inlen < gen_nb_int_ptr;n_inlen++) { + mem_base = xmlMemBlocks(); + out = gen_unsigned_char_ptr(n_out, 0); + outlen = gen_int_ptr(n_outlen, 1); + in = gen_const_unsigned_char_ptr(n_in, 2); + inlen = gen_int_ptr(n_inlen, 3); + + ret_val = UTF8ToHtml(out, outlen, (const unsigned char *)in, inlen); + desret_int(ret_val); + call_tests++; + des_unsigned_char_ptr(n_out, out, 0); + des_int_ptr(n_outlen, outlen, 1); + des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_int_ptr(n_inlen, inlen, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in UTF8ToHtml", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_outlen); + printf(" %d", n_in); + printf(" %d", n_inlen); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_HTML_ENABLED + +#define gen_nb_const_htmlElemDesc_ptr 1 +static htmlElemDesc * gen_const_htmlElemDesc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_htmlElemDesc_ptr(int no ATTRIBUTE_UNUSED, const htmlElemDesc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_htmlAttrAllowed(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlStatus ret_val; + htmlElemDesc * elt; /* HTML element */ + int n_elt; + xmlChar * attr; /* HTML attribute */ + int n_attr; + int legacy; /* whether to allow deprecated attributes */ + int n_legacy; + + for (n_elt = 0;n_elt < gen_nb_const_htmlElemDesc_ptr;n_elt++) { + for (n_attr = 0;n_attr < gen_nb_const_xmlChar_ptr;n_attr++) { + for (n_legacy = 0;n_legacy < gen_nb_int;n_legacy++) { + mem_base = xmlMemBlocks(); + elt = gen_const_htmlElemDesc_ptr(n_elt, 0); + attr = gen_const_xmlChar_ptr(n_attr, 1); + legacy = gen_int(n_legacy, 2); + + ret_val = htmlAttrAllowed((const htmlElemDesc *)elt, (const xmlChar *)attr, legacy); + desret_htmlStatus(ret_val); + call_tests++; + des_const_htmlElemDesc_ptr(n_elt, (const htmlElemDesc *)elt, 0); + des_const_xmlChar_ptr(n_attr, (const xmlChar *)attr, 1); + des_int(n_legacy, legacy, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlAttrAllowed", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_elt); + printf(" %d", n_attr); + printf(" %d", n_legacy); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_HTML_ENABLED + +#define gen_nb_htmlNodePtr 1 +static htmlNodePtr gen_htmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_htmlNodePtr(int no ATTRIBUTE_UNUSED, htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_htmlAutoCloseTag(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlDocPtr doc; /* the HTML document */ + int n_doc; + xmlChar * name; /* The tag name */ + int n_name; + htmlNodePtr elem; /* the HTML element */ + int n_elem; + + for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_elem = 0;n_elem < gen_nb_htmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + doc = gen_htmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + elem = gen_htmlNodePtr(n_elem, 2); + + ret_val = htmlAutoCloseTag(doc, (const xmlChar *)name, elem); + desret_int(ret_val); + call_tests++; + des_htmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_htmlNodePtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlAutoCloseTag", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlCreateMemoryParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlParserCtxtPtr ret_val; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = htmlCreateMemoryParserCtxt((const char *)buffer, size); + desret_htmlParserCtxtPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCreateMemoryParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_HTML_ENABLED + +#define gen_nb_htmlSAXHandlerPtr 1 +static htmlSAXHandlerPtr gen_htmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_htmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, htmlSAXHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_htmlCreatePushParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) + int mem_base; + htmlParserCtxtPtr ret_val; + htmlSAXHandlerPtr sax; /* a SAX handler */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks */ + int n_user_data; + char * chunk; /* a pointer to an array of chars */ + int n_chunk; + int size; /* number of chars in the array */ + int n_size; + const char * filename; /* an optional file name or URI */ + int n_filename; + xmlCharEncoding enc; /* an optional encoding */ + int n_enc; + + for (n_sax = 0;n_sax < gen_nb_htmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + sax = gen_htmlSAXHandlerPtr(n_sax, 0); + user_data = gen_userdata(n_user_data, 1); + chunk = gen_const_char_ptr(n_chunk, 2); + size = gen_int(n_size, 3); + filename = gen_fileoutput(n_filename, 4); + enc = gen_xmlCharEncoding(n_enc, 5); + if ((chunk != NULL) && + (size > (int) strlen((const char *) chunk) + 1)) + continue; + + ret_val = htmlCreatePushParserCtxt(sax, user_data, (const char *)chunk, size, filename, enc); + desret_htmlParserCtxtPtr(ret_val); + call_tests++; + des_htmlSAXHandlerPtr(n_sax, sax, 0); + des_userdata(n_user_data, user_data, 1); + des_const_char_ptr(n_chunk, (const char *)chunk, 2); + des_int(n_size, size, 3); + des_fileoutput(n_filename, filename, 4); + des_xmlCharEncoding(n_enc, enc, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCreatePushParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_chunk); + printf(" %d", n_size); + printf(" %d", n_filename); + printf(" %d", n_enc); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlCtxtReadDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + xmlChar * cur; /* a pointer to a zero terminated string */ + int n_cur; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + cur = gen_const_xmlChar_ptr(n_cur, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_int(n_options, 4); + + ret_val = htmlCtxtReadDoc(ctxt, (const xmlChar *)cur, URL, (const char *)encoding, options); + desret_htmlDocPtr(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_int(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCtxtReadDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlCtxtReadFile(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + htmlDocPtr ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + const char * filename; /* a file or URL */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + filename = gen_filepath(n_filename, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + options = gen_int(n_options, 3); + + ret_val = htmlCtxtReadFile(ctxt, filename, (const char *)encoding, options); + desret_htmlDocPtr(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_filepath(n_filename, filename, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_int(n_options, options, 3); + xmlResetLastError(); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlCtxtReadMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + buffer = gen_const_char_ptr(n_buffer, 1); + size = gen_int(n_size, 2); + URL = gen_filepath(n_URL, 3); + encoding = gen_const_char_ptr(n_encoding, 4); + options = gen_int(n_options, 5); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = htmlCtxtReadMemory(ctxt, (const char *)buffer, size, URL, (const char *)encoding, options); + desret_htmlDocPtr(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_int(n_size, size, 2); + des_filepath(n_URL, URL, 3); + des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_int(n_options, options, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCtxtReadMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlCtxtReset(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + + htmlCtxtReset(ctxt); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCtxtReset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlCtxtUseOptions(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + options = gen_int(n_options, 1); + + ret_val = htmlCtxtUseOptions(ctxt, options); + desret_int(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_int(n_options, options, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCtxtUseOptions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_options); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlElementAllowedHere(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlElemDesc * parent; /* HTML parent element */ + int n_parent; + xmlChar * elt; /* HTML element */ + int n_elt; + + for (n_parent = 0;n_parent < gen_nb_const_htmlElemDesc_ptr;n_parent++) { + for (n_elt = 0;n_elt < gen_nb_const_xmlChar_ptr;n_elt++) { + mem_base = xmlMemBlocks(); + parent = gen_const_htmlElemDesc_ptr(n_parent, 0); + elt = gen_const_xmlChar_ptr(n_elt, 1); + + ret_val = htmlElementAllowedHere((const htmlElemDesc *)parent, (const xmlChar *)elt); + desret_int(ret_val); + call_tests++; + des_const_htmlElemDesc_ptr(n_parent, (const htmlElemDesc *)parent, 0); + des_const_xmlChar_ptr(n_elt, (const xmlChar *)elt, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlElementAllowedHere", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf(" %d", n_elt); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlElementStatusHere(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlStatus ret_val; + htmlElemDesc * parent; /* HTML parent element */ + int n_parent; + htmlElemDesc * elt; /* HTML element */ + int n_elt; + + for (n_parent = 0;n_parent < gen_nb_const_htmlElemDesc_ptr;n_parent++) { + for (n_elt = 0;n_elt < gen_nb_const_htmlElemDesc_ptr;n_elt++) { + mem_base = xmlMemBlocks(); + parent = gen_const_htmlElemDesc_ptr(n_parent, 0); + elt = gen_const_htmlElemDesc_ptr(n_elt, 1); + + ret_val = htmlElementStatusHere((const htmlElemDesc *)parent, (const htmlElemDesc *)elt); + desret_htmlStatus(ret_val); + call_tests++; + des_const_htmlElemDesc_ptr(n_parent, (const htmlElemDesc *)parent, 0); + des_const_htmlElemDesc_ptr(n_elt, (const htmlElemDesc *)elt, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlElementStatusHere", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf(" %d", n_elt); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlEncodeEntities(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + unsigned char * out; /* a pointer to an array of bytes to store the result */ + int n_out; + int * outlen; /* the length of @out */ + int n_outlen; + unsigned char * in; /* a pointer to an array of UTF-8 chars */ + int n_in; + int * inlen; /* the length of @in */ + int n_inlen; + int quoteChar; /* the quote character to escape (' or ") or zero. */ + int n_quoteChar; + + for (n_out = 0;n_out < gen_nb_unsigned_char_ptr;n_out++) { + for (n_outlen = 0;n_outlen < gen_nb_int_ptr;n_outlen++) { + for (n_in = 0;n_in < gen_nb_const_unsigned_char_ptr;n_in++) { + for (n_inlen = 0;n_inlen < gen_nb_int_ptr;n_inlen++) { + for (n_quoteChar = 0;n_quoteChar < gen_nb_int;n_quoteChar++) { + mem_base = xmlMemBlocks(); + out = gen_unsigned_char_ptr(n_out, 0); + outlen = gen_int_ptr(n_outlen, 1); + in = gen_const_unsigned_char_ptr(n_in, 2); + inlen = gen_int_ptr(n_inlen, 3); + quoteChar = gen_int(n_quoteChar, 4); + + ret_val = htmlEncodeEntities(out, outlen, (const unsigned char *)in, inlen, quoteChar); + desret_int(ret_val); + call_tests++; + des_unsigned_char_ptr(n_out, out, 0); + des_int_ptr(n_outlen, outlen, 1); + des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_int_ptr(n_inlen, inlen, 3); + des_int(n_quoteChar, quoteChar, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlEncodeEntities", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_outlen); + printf(" %d", n_in); + printf(" %d", n_inlen); + printf(" %d", n_quoteChar); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlEntityLookup(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + const htmlEntityDesc * ret_val; + xmlChar * name; /* the entity name */ + int n_name; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + + ret_val = htmlEntityLookup((const xmlChar *)name); + desret_const_htmlEntityDesc_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlEntityLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlEntityValueLookup(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + const htmlEntityDesc * ret_val; + unsigned int value; /* the entity's unicode value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_unsigned_int;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_unsigned_int(n_value, 0); + + ret_val = htmlEntityValueLookup(value); + desret_const_htmlEntityDesc_ptr(ret_val); + call_tests++; + des_unsigned_int(n_value, value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlEntityValueLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlHandleOmittedElem(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + int val; /* int 0 or 1 */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = htmlHandleOmittedElem(val); + desret_int(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlHandleOmittedElem", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlIsAutoClosed(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlDocPtr doc; /* the HTML document */ + int n_doc; + htmlNodePtr elem; /* the HTML element */ + int n_elem; + + for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_htmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + doc = gen_htmlDocPtr(n_doc, 0); + elem = gen_htmlNodePtr(n_elem, 1); + + ret_val = htmlIsAutoClosed(doc, elem); + desret_int(ret_val); + call_tests++; + des_htmlDocPtr(n_doc, doc, 0); + des_htmlNodePtr(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlIsAutoClosed", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlIsScriptAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + xmlChar * name; /* an attribute name */ + int n_name; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + + ret_val = htmlIsScriptAttribute((const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlIsScriptAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNewParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlParserCtxtPtr ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = htmlNewParserCtxt(); + desret_htmlParserCtxtPtr(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNewParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNodeStatus(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlStatus ret_val; + htmlNodePtr node; /* an htmlNodePtr in a tree */ + int n_node; + int legacy; /* whether to allow deprecated elements (YES is faster here for Element nodes) */ + int n_legacy; + + for (n_node = 0;n_node < gen_nb_const_htmlNodePtr;n_node++) { + for (n_legacy = 0;n_legacy < gen_nb_int;n_legacy++) { + mem_base = xmlMemBlocks(); + node = gen_const_htmlNodePtr(n_node, 0); + legacy = gen_int(n_legacy, 1); + + ret_val = htmlNodeStatus((const htmlNodePtr)node, legacy); + desret_htmlStatus(ret_val); + call_tests++; + des_const_htmlNodePtr(n_node, (const htmlNodePtr)node, 0); + des_int(n_legacy, legacy, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNodeStatus", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_legacy); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseCharRef(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + + ret_val = htmlParseCharRef(ctxt); + desret_int(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlParseCharRef", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseChunk(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) + int mem_base; + int ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + char * chunk; /* an char array */ + int n_chunk; + int size; /* the size in byte of the chunk */ + int n_size; + int terminate; /* last chunk indicator */ + int n_terminate; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_terminate = 0;n_terminate < gen_nb_int;n_terminate++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + chunk = gen_const_char_ptr(n_chunk, 1); + size = gen_int(n_size, 2); + terminate = gen_int(n_terminate, 3); + if ((chunk != NULL) && + (size > (int) strlen((const char *) chunk) + 1)) + continue; + + ret_val = htmlParseChunk(ctxt, (const char *)chunk, size, terminate); + if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} + desret_int(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_chunk, (const char *)chunk, 1); + des_int(n_size, size, 2); + des_int(n_terminate, terminate, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlParseChunk", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_chunk); + printf(" %d", n_size); + printf(" %d", n_terminate); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + xmlChar * cur; /* a pointer to an array of xmlChar */ + int n_cur; + char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + int n_encoding; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + + ret_val = htmlParseDoc((const xmlChar *)cur, (const char *)encoding); + desret_htmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlParseDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + + ret_val = htmlParseDocument(ctxt); + if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} + desret_int(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlParseDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseElement(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + + htmlParseElement(ctxt); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlParseElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseEntityRef(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + const htmlEntityDesc * ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + xmlChar ** str; /* location to store the entity name */ + int n_str; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr_ptr;n_str++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + str = gen_const_xmlChar_ptr_ptr(n_str, 1); + + ret_val = htmlParseEntityRef(ctxt, (const xmlChar **)str); + desret_const_htmlEntityDesc_ptr(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr_ptr(n_str, (const xmlChar **)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlParseEntityRef", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlParseFile(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + htmlDocPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + int n_encoding; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + filename = gen_filepath(n_filename, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + + ret_val = htmlParseFile(filename, (const char *)encoding); + desret_htmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + xmlResetLastError(); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlReadDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + xmlChar * cur; /* a pointer to a zero terminated string */ + int n_cur; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + URL = gen_filepath(n_URL, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + options = gen_int(n_options, 3); + + ret_val = htmlReadDoc((const xmlChar *)cur, URL, (const char *)encoding, options); + desret_htmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_filepath(n_URL, URL, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_int(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlReadDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlReadFile(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + const char * filename; /* a file or URL */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + options = gen_int(n_options, 2); + + ret_val = htmlReadFile(filename, (const char *)encoding, options); + desret_htmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_int(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlReadFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlReadMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of htmlParserOption(s) */ + int n_options; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_int(n_options, 4); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = htmlReadMemory((const char *)buffer, size, URL, (const char *)encoding, options); + desret_htmlDocPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_int(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlReadMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlSAXParseDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + xmlChar * cur; /* a pointer to an array of xmlChar */ + int n_cur; + char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + int n_encoding; + htmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + void * userData; /* if using SAX, this pointer will be provided on callbacks. */ + int n_userData; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_sax = 0;n_sax < gen_nb_htmlSAXHandlerPtr;n_sax++) { + for (n_userData = 0;n_userData < gen_nb_userdata;n_userData++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + sax = gen_htmlSAXHandlerPtr(n_sax, 2); + userData = gen_userdata(n_userData, 3); + + ret_val = htmlSAXParseDoc((const xmlChar *)cur, (const char *)encoding, sax, userData); + desret_htmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_htmlSAXHandlerPtr(n_sax, sax, 2); + des_userdata(n_userData, userData, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlSAXParseDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_sax); + printf(" %d", n_userData); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlSAXParseFile(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + int n_encoding; + htmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + void * userData; /* if using SAX, this pointer will be provided on callbacks. */ + int n_userData; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_sax = 0;n_sax < gen_nb_htmlSAXHandlerPtr;n_sax++) { + for (n_userData = 0;n_userData < gen_nb_userdata;n_userData++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + sax = gen_htmlSAXHandlerPtr(n_sax, 2); + userData = gen_userdata(n_userData, 3); + + ret_val = htmlSAXParseFile(filename, (const char *)encoding, sax, userData); + desret_htmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_htmlSAXHandlerPtr(n_sax, sax, 2); + des_userdata(n_userData, userData, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlSAXParseFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf(" %d", n_sax); + printf(" %d", n_userData); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlTagLookup(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_HTMLparser(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing HTMLparser : 32 of 38 functions ...\n"); + test_ret += test_UTF8ToHtml(); + test_ret += test_htmlAttrAllowed(); + test_ret += test_htmlAutoCloseTag(); + test_ret += test_htmlCreateMemoryParserCtxt(); + test_ret += test_htmlCreatePushParserCtxt(); + test_ret += test_htmlCtxtReadDoc(); + test_ret += test_htmlCtxtReadFile(); + test_ret += test_htmlCtxtReadMemory(); + test_ret += test_htmlCtxtReset(); + test_ret += test_htmlCtxtUseOptions(); + test_ret += test_htmlElementAllowedHere(); + test_ret += test_htmlElementStatusHere(); + test_ret += test_htmlEncodeEntities(); + test_ret += test_htmlEntityLookup(); + test_ret += test_htmlEntityValueLookup(); + test_ret += test_htmlHandleOmittedElem(); + test_ret += test_htmlIsAutoClosed(); + test_ret += test_htmlIsScriptAttribute(); + test_ret += test_htmlNewParserCtxt(); + test_ret += test_htmlNodeStatus(); + test_ret += test_htmlParseCharRef(); + test_ret += test_htmlParseChunk(); + test_ret += test_htmlParseDoc(); + test_ret += test_htmlParseDocument(); + test_ret += test_htmlParseElement(); + test_ret += test_htmlParseEntityRef(); + test_ret += test_htmlParseFile(); + test_ret += test_htmlReadDoc(); + test_ret += test_htmlReadFile(); + test_ret += test_htmlReadMemory(); + test_ret += test_htmlSAXParseDoc(); + test_ret += test_htmlSAXParseFile(); + test_ret += test_htmlTagLookup(); + + if (test_ret != 0) + printf("Module HTMLparser: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_htmlDocContentDumpFormatOutput(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr buf; /* the HTML buffer output */ + int n_buf; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the encoding string (unused) */ + int n_encoding; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + format = gen_int(n_format, 3); + + htmlDocContentDumpFormatOutput(buf, cur, (const char *)encoding, format); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_int(n_format, format, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlDocContentDumpFormatOutput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlDocContentDumpOutput(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr buf; /* the HTML buffer output */ + int n_buf; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the encoding string (unused) */ + int n_encoding; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + + htmlDocContentDumpOutput(buf, cur, (const char *)encoding); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlDocContentDumpOutput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlDocDump(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + FILE * f; /* the FILE* */ + int n_f; + xmlDocPtr cur; /* the document */ + int n_cur; + + for (n_f = 0;n_f < gen_nb_FILE_ptr;n_f++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + mem_base = xmlMemBlocks(); + f = gen_FILE_ptr(n_f, 0); + cur = gen_xmlDocPtr(n_cur, 1); + + ret_val = htmlDocDump(f, cur); + desret_int(ret_val); + call_tests++; + des_FILE_ptr(n_f, f, 0); + des_xmlDocPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlDocDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_f); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlChar_ptr_ptr 1 +static xmlChar ** gen_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, xmlChar ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_htmlDocDumpMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlDocPtr cur; /* the document */ + int n_cur; + xmlChar ** mem; /* OUT: the memory pointer */ + int n_mem; + int * size; /* OUT: the memory length */ + int n_size; + + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_mem = 0;n_mem < gen_nb_xmlChar_ptr_ptr;n_mem++) { + for (n_size = 0;n_size < gen_nb_int_ptr;n_size++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlDocPtr(n_cur, 0); + mem = gen_xmlChar_ptr_ptr(n_mem, 1); + size = gen_int_ptr(n_size, 2); + + htmlDocDumpMemory(cur, mem, size); + call_tests++; + des_xmlDocPtr(n_cur, cur, 0); + des_xmlChar_ptr_ptr(n_mem, mem, 1); + des_int_ptr(n_size, size, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlDocDumpMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_mem); + printf(" %d", n_size); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlDocDumpMemoryFormat(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlDocPtr cur; /* the document */ + int n_cur; + xmlChar ** mem; /* OUT: the memory pointer */ + int n_mem; + int * size; /* OUT: the memory length */ + int n_size; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_mem = 0;n_mem < gen_nb_xmlChar_ptr_ptr;n_mem++) { + for (n_size = 0;n_size < gen_nb_int_ptr;n_size++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlDocPtr(n_cur, 0); + mem = gen_xmlChar_ptr_ptr(n_mem, 1); + size = gen_int_ptr(n_size, 2); + format = gen_int(n_format, 3); + + htmlDocDumpMemoryFormat(cur, mem, size, format); + call_tests++; + des_xmlDocPtr(n_cur, cur, 0); + des_xmlChar_ptr_ptr(n_mem, mem, 1); + des_int_ptr(n_size, size, 2); + des_int(n_format, format, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlDocDumpMemoryFormat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_mem); + printf(" %d", n_size); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlGetMetaEncoding(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + const xmlChar * ret_val; + htmlDocPtr doc; /* the document */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_htmlDocPtr(n_doc, 0); + + ret_val = htmlGetMetaEncoding(doc); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_htmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlGetMetaEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlIsBooleanAttr(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + xmlChar * name; /* the name of the attribute to check */ + int n_name; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + + ret_val = htmlIsBooleanAttr((const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlIsBooleanAttr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNewDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + xmlChar * URI; /* URI for the dtd, or NULL */ + int n_URI; + xmlChar * ExternalID; /* the external ID of the DTD, or NULL */ + int n_ExternalID; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1); + + ret_val = htmlNewDoc((const xmlChar *)URI, (const xmlChar *)ExternalID); + desret_htmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNewDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_ExternalID); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNewDocNoDtD(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + xmlChar * URI; /* URI for the dtd, or NULL */ + int n_URI; + xmlChar * ExternalID; /* the external ID of the DTD, or NULL */ + int n_ExternalID; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1); + + ret_val = htmlNewDocNoDtD((const xmlChar *)URI, (const xmlChar *)ExternalID); + desret_htmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNewDocNoDtD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_ExternalID); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNodeDump(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the HTML buffer output */ + int n_buf; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + + ret_val = htmlNodeDump(buf, doc, cur); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNodeDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNodeDumpFile(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + FILE * out; /* the FILE pointer */ + int n_out; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + + for (n_out = 0;n_out < gen_nb_FILE_ptr;n_out++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + out = gen_FILE_ptr(n_out, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + + htmlNodeDumpFile(out, doc, cur); + call_tests++; + des_FILE_ptr(n_out, out, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNodeDumpFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNodeDumpFileFormat(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + FILE * out; /* the FILE pointer */ + int n_out; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + char * encoding; /* the document encoding */ + int n_encoding; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_out = 0;n_out < gen_nb_FILE_ptr;n_out++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + out = gen_FILE_ptr(n_out, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + format = gen_int(n_format, 4); + + ret_val = htmlNodeDumpFileFormat(out, doc, cur, (const char *)encoding, format); + desret_int(ret_val); + call_tests++; + des_FILE_ptr(n_out, out, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_int(n_format, format, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNodeDumpFileFormat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNodeDumpFormatOutput(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr buf; /* the HTML buffer output */ + int n_buf; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + char * encoding; /* the encoding string (unused) */ + int n_encoding; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + format = gen_int(n_format, 4); + + htmlNodeDumpFormatOutput(buf, doc, cur, (const char *)encoding, format); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_int(n_format, format, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNodeDumpFormatOutput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlNodeDumpOutput(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr buf; /* the HTML buffer output */ + int n_buf; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + char * encoding; /* the encoding string (unused) */ + int n_encoding; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + + htmlNodeDumpOutput(buf, doc, cur, (const char *)encoding); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlNodeDumpOutput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlSaveFile(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename (or URL) */ + int n_filename; + xmlDocPtr cur; /* the document */ + int n_cur; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + + ret_val = htmlSaveFile(filename, cur); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlSaveFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlSaveFileEnc(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename */ + int n_filename; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the document encoding */ + int n_encoding; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + + ret_val = htmlSaveFileEnc(filename, cur, (const char *)encoding); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlSaveFileEnc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlSaveFileFormat(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename */ + int n_filename; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the document encoding */ + int n_encoding; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + format = gen_int(n_format, 3); + + ret_val = htmlSaveFileFormat(filename, cur, (const char *)encoding, format); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_int(n_format, format, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlSaveFileFormat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlSetMetaEncoding(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + int ret_val; + htmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * encoding; /* the encoding string */ + int n_encoding; + + for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) { + for (n_encoding = 0;n_encoding < gen_nb_const_xmlChar_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + doc = gen_htmlDocPtr(n_doc, 0); + encoding = gen_const_xmlChar_ptr(n_encoding, 1); + + ret_val = htmlSetMetaEncoding(doc, (const xmlChar *)encoding); + desret_int(ret_val); + call_tests++; + des_htmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_encoding, (const xmlChar *)encoding, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlSetMetaEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_HTMLtree(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing HTMLtree : 18 of 18 functions ...\n"); + test_ret += test_htmlDocContentDumpFormatOutput(); + test_ret += test_htmlDocContentDumpOutput(); + test_ret += test_htmlDocDump(); + test_ret += test_htmlDocDumpMemory(); + test_ret += test_htmlDocDumpMemoryFormat(); + test_ret += test_htmlGetMetaEncoding(); + test_ret += test_htmlIsBooleanAttr(); + test_ret += test_htmlNewDoc(); + test_ret += test_htmlNewDocNoDtD(); + test_ret += test_htmlNodeDump(); + test_ret += test_htmlNodeDumpFile(); + test_ret += test_htmlNodeDumpFileFormat(); + test_ret += test_htmlNodeDumpFormatOutput(); + test_ret += test_htmlNodeDumpOutput(); + test_ret += test_htmlSaveFile(); + test_ret += test_htmlSaveFileEnc(); + test_ret += test_htmlSaveFileFormat(); + test_ret += test_htmlSetMetaEncoding(); + + if (test_ret != 0) + printf("Module HTMLtree: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_docbDefaultSAXHandlerInit(void) { + int test_ret = 0; + +#if defined(LIBXML_DOCB_ENABLED) +#ifdef LIBXML_DOCB_ENABLED + int mem_base; + + mem_base = xmlMemBlocks(); + + docbDefaultSAXHandlerInit(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in docbDefaultSAXHandlerInit", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_htmlDefaultSAXHandlerInit(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) +#ifdef LIBXML_HTML_ENABLED + int mem_base; + + mem_base = xmlMemBlocks(); + + htmlDefaultSAXHandlerInit(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlDefaultSAXHandlerInit", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlDefaultSAXHandlerInit(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlDefaultSAXHandlerInit(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDefaultSAXHandlerInit", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlEnumerationPtr 1 +static xmlEnumerationPtr gen_xmlEnumerationPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlEnumerationPtr(int no ATTRIBUTE_UNUSED, xmlEnumerationPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlSAX2AttributeDecl(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * elem; /* the name of the element */ + int n_elem; + xmlChar * fullname; /* the attribute name */ + int n_fullname; + int type; /* the attribute type */ + int n_type; + int def; /* the type of default value */ + int n_def; + xmlChar * defaultValue; /* the attribute default value */ + int n_defaultValue; + xmlEnumerationPtr tree; /* the tree of enumerated value set */ + int n_tree; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_elem = 0;n_elem < gen_nb_const_xmlChar_ptr;n_elem++) { + for (n_fullname = 0;n_fullname < gen_nb_const_xmlChar_ptr;n_fullname++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_def = 0;n_def < gen_nb_int;n_def++) { + for (n_defaultValue = 0;n_defaultValue < gen_nb_const_xmlChar_ptr;n_defaultValue++) { + for (n_tree = 0;n_tree < gen_nb_xmlEnumerationPtr;n_tree++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + elem = gen_const_xmlChar_ptr(n_elem, 1); + fullname = gen_const_xmlChar_ptr(n_fullname, 2); + type = gen_int(n_type, 3); + def = gen_int(n_def, 4); + defaultValue = gen_const_xmlChar_ptr(n_defaultValue, 5); + tree = gen_xmlEnumerationPtr(n_tree, 6); + + xmlSAX2AttributeDecl(ctx, (const xmlChar *)elem, (const xmlChar *)fullname, type, def, (const xmlChar *)defaultValue, tree); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 1); + des_const_xmlChar_ptr(n_fullname, (const xmlChar *)fullname, 2); + des_int(n_type, type, 3); + des_int(n_def, def, 4); + des_const_xmlChar_ptr(n_defaultValue, (const xmlChar *)defaultValue, 5); + des_xmlEnumerationPtr(n_tree, tree, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2AttributeDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_elem); + printf(" %d", n_fullname); + printf(" %d", n_type); + printf(" %d", n_def); + printf(" %d", n_defaultValue); + printf(" %d", n_tree); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2CDataBlock(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * value; /* The pcdata content */ + int n_value; + int len; /* the block length */ + int n_len; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + len = gen_int(n_len, 2); + if ((value != NULL) && + (len > (int) strlen((const char *) value) + 1)) + continue; + + xmlSAX2CDataBlock(ctx, (const xmlChar *)value, len); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2CDataBlock", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_value); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2Characters(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * ch; /* a xmlChar string */ + int n_ch; + int len; /* the number of xmlChar */ + int n_len; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_ch = 0;n_ch < gen_nb_const_xmlChar_ptr;n_ch++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + ch = gen_const_xmlChar_ptr(n_ch, 1); + len = gen_int(n_len, 2); + if ((ch != NULL) && + (len > (int) strlen((const char *) ch) + 1)) + continue; + + xmlSAX2Characters(ctx, (const xmlChar *)ch, len); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_ch, (const xmlChar *)ch, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2Characters", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_ch); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2Comment(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * value; /* the xmlSAX2Comment content */ + int n_value; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + + xmlSAX2Comment(ctx, (const xmlChar *)value); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2Comment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2ElementDecl(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* the element name */ + int n_name; + int type; /* the element type */ + int n_type; + xmlElementContentPtr content; /* the element value tree */ + int n_content; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_content = 0;n_content < gen_nb_xmlElementContentPtr;n_content++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_int(n_type, 2); + content = gen_xmlElementContentPtr(n_content, 3); + + xmlSAX2ElementDecl(ctx, (const xmlChar *)name, type, content); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_type, type, 2); + des_xmlElementContentPtr(n_content, content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2ElementDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2EndDocument(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + xmlSAX2EndDocument(ctx); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2EndDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2EndElement(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* The element name */ + int n_name; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + xmlSAX2EndElement(ctx, (const xmlChar *)name); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2EndElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAX2EndElementNs(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * localname; /* the local name of the element */ + int n_localname; + xmlChar * prefix; /* the element namespace prefix if available */ + int n_prefix; + xmlChar * URI; /* the element namespace name if available */ + int n_URI; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_localname = 0;n_localname < gen_nb_const_xmlChar_ptr;n_localname++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + localname = gen_const_xmlChar_ptr(n_localname, 1); + prefix = gen_const_xmlChar_ptr(n_prefix, 2); + URI = gen_const_xmlChar_ptr(n_URI, 3); + + xmlSAX2EndElementNs(ctx, (const xmlChar *)localname, (const xmlChar *)prefix, (const xmlChar *)URI); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_localname, (const xmlChar *)localname, 1); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2EndElementNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_localname); + printf(" %d", n_prefix); + printf(" %d", n_URI); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2EntityDecl(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* the entity name */ + int n_name; + int type; /* the entity type */ + int n_type; + xmlChar * publicId; /* The public ID of the entity */ + int n_publicId; + xmlChar * systemId; /* The system ID of the entity */ + int n_systemId; + xmlChar * content; /* the entity value (without processing). */ + int n_content; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_publicId = 0;n_publicId < gen_nb_const_xmlChar_ptr;n_publicId++) { + for (n_systemId = 0;n_systemId < gen_nb_const_xmlChar_ptr;n_systemId++) { + for (n_content = 0;n_content < gen_nb_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_int(n_type, 2); + publicId = gen_const_xmlChar_ptr(n_publicId, 3); + systemId = gen_const_xmlChar_ptr(n_systemId, 4); + content = gen_xmlChar_ptr(n_content, 5); + + xmlSAX2EntityDecl(ctx, (const xmlChar *)name, type, (const xmlChar *)publicId, (const xmlChar *)systemId, content); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_type, type, 2); + des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 3); + des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 4); + des_xmlChar_ptr(n_content, content, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2EntityDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_publicId); + printf(" %d", n_systemId); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2ExternalSubset(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* the root element name */ + int n_name; + xmlChar * ExternalID; /* the external ID */ + int n_ExternalID; + xmlChar * SystemID; /* the SYSTEM ID (e.g. filename or URL) */ + int n_SystemID; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); + + xmlSAX2ExternalSubset(ctx, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2ExternalSubset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2GetColumnNumber(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2GetColumnNumber(ctx); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2GetColumnNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2GetEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* The entity name */ + int n_name; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlSAX2GetEntity(ctx, (const xmlChar *)name); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2GetEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2GetLineNumber(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2GetLineNumber(ctx); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2GetLineNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2GetParameterEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* The entity name */ + int n_name; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlSAX2GetParameterEntity(ctx, (const xmlChar *)name); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2GetParameterEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2GetPublicId(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2GetPublicId(ctx); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2GetPublicId", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2GetSystemId(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2GetSystemId(ctx); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2GetSystemId", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2HasExternalSubset(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2HasExternalSubset(ctx); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2HasExternalSubset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2HasInternalSubset(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2HasInternalSubset(ctx); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2HasInternalSubset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2IgnorableWhitespace(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * ch; /* a xmlChar string */ + int n_ch; + int len; /* the number of xmlChar */ + int n_len; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_ch = 0;n_ch < gen_nb_const_xmlChar_ptr;n_ch++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + ch = gen_const_xmlChar_ptr(n_ch, 1); + len = gen_int(n_len, 2); + if ((ch != NULL) && + (len > (int) strlen((const char *) ch) + 1)) + continue; + + xmlSAX2IgnorableWhitespace(ctx, (const xmlChar *)ch, len); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_ch, (const xmlChar *)ch, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2IgnorableWhitespace", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_ch); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlSAXHandler_ptr 1 +static xmlSAXHandler * gen_xmlSAXHandler_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSAXHandler_ptr(int no ATTRIBUTE_UNUSED, xmlSAXHandler * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlSAX2InitDefaultSAXHandler(void) { + int test_ret = 0; + + int mem_base; + xmlSAXHandler * hdlr; /* the SAX handler */ + int n_hdlr; + int warning; /* flag if non-zero sets the handler warning procedure */ + int n_warning; + + for (n_hdlr = 0;n_hdlr < gen_nb_xmlSAXHandler_ptr;n_hdlr++) { + for (n_warning = 0;n_warning < gen_nb_int;n_warning++) { + mem_base = xmlMemBlocks(); + hdlr = gen_xmlSAXHandler_ptr(n_hdlr, 0); + warning = gen_int(n_warning, 1); + + xmlSAX2InitDefaultSAXHandler(hdlr, warning); + call_tests++; + des_xmlSAXHandler_ptr(n_hdlr, hdlr, 0); + des_int(n_warning, warning, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2InitDefaultSAXHandler", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hdlr); + printf(" %d", n_warning); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2InitDocbDefaultSAXHandler(void) { + int test_ret = 0; + +#if defined(LIBXML_DOCB_ENABLED) + int mem_base; + xmlSAXHandler * hdlr; /* the SAX handler */ + int n_hdlr; + + for (n_hdlr = 0;n_hdlr < gen_nb_xmlSAXHandler_ptr;n_hdlr++) { + mem_base = xmlMemBlocks(); + hdlr = gen_xmlSAXHandler_ptr(n_hdlr, 0); + + xmlSAX2InitDocbDefaultSAXHandler(hdlr); + call_tests++; + des_xmlSAXHandler_ptr(n_hdlr, hdlr, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2InitDocbDefaultSAXHandler", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hdlr); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSAX2InitHtmlDefaultSAXHandler(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + xmlSAXHandler * hdlr; /* the SAX handler */ + int n_hdlr; + + for (n_hdlr = 0;n_hdlr < gen_nb_xmlSAXHandler_ptr;n_hdlr++) { + mem_base = xmlMemBlocks(); + hdlr = gen_xmlSAXHandler_ptr(n_hdlr, 0); + + xmlSAX2InitHtmlDefaultSAXHandler(hdlr); + call_tests++; + des_xmlSAXHandler_ptr(n_hdlr, hdlr, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2InitHtmlDefaultSAXHandler", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hdlr); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSAX2InternalSubset(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* the root element name */ + int n_name; + xmlChar * ExternalID; /* the external ID */ + int n_ExternalID; + xmlChar * SystemID; /* the SYSTEM ID (e.g. filename or URL) */ + int n_SystemID; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); + + xmlSAX2InternalSubset(ctx, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2InternalSubset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2IsStandalone(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + ret_val = xmlSAX2IsStandalone(ctx); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2IsStandalone", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2NotationDecl(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* The name of the notation */ + int n_name; + xmlChar * publicId; /* The public ID of the entity */ + int n_publicId; + xmlChar * systemId; /* The system ID of the entity */ + int n_systemId; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_publicId = 0;n_publicId < gen_nb_const_xmlChar_ptr;n_publicId++) { + for (n_systemId = 0;n_systemId < gen_nb_const_xmlChar_ptr;n_systemId++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + publicId = gen_const_xmlChar_ptr(n_publicId, 2); + systemId = gen_const_xmlChar_ptr(n_systemId, 3); + + xmlSAX2NotationDecl(ctx, (const xmlChar *)name, (const xmlChar *)publicId, (const xmlChar *)systemId); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 2); + des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2NotationDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf(" %d", n_publicId); + printf(" %d", n_systemId); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2ProcessingInstruction(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * target; /* the target name */ + int n_target; + xmlChar * data; /* the PI data's */ + int n_data; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_target = 0;n_target < gen_nb_const_xmlChar_ptr;n_target++) { + for (n_data = 0;n_data < gen_nb_const_xmlChar_ptr;n_data++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + target = gen_const_xmlChar_ptr(n_target, 1); + data = gen_const_xmlChar_ptr(n_data, 2); + + xmlSAX2ProcessingInstruction(ctx, (const xmlChar *)target, (const xmlChar *)data); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_target, (const xmlChar *)target, 1); + des_const_xmlChar_ptr(n_data, (const xmlChar *)data, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2ProcessingInstruction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_target); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2Reference(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* The entity name */ + int n_name; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + xmlSAX2Reference(ctx, (const xmlChar *)name); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2Reference", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2ResolveEntity(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * publicId; /* The public ID of the entity */ + int n_publicId; + xmlChar * systemId; /* The system ID of the entity */ + int n_systemId; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_publicId = 0;n_publicId < gen_nb_const_xmlChar_ptr;n_publicId++) { + for (n_systemId = 0;n_systemId < gen_nb_const_xmlChar_ptr;n_systemId++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + publicId = gen_const_xmlChar_ptr(n_publicId, 1); + systemId = gen_const_xmlChar_ptr(n_systemId, 2); + + ret_val = xmlSAX2ResolveEntity(ctx, (const xmlChar *)publicId, (const xmlChar *)systemId); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 1); + des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2ResolveEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_publicId); + printf(" %d", n_systemId); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlSAXLocatorPtr 1 +static xmlSAXLocatorPtr gen_xmlSAXLocatorPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSAXLocatorPtr(int no ATTRIBUTE_UNUSED, xmlSAXLocatorPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlSAX2SetDocumentLocator(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlSAXLocatorPtr loc; /* A SAX Locator */ + int n_loc; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_loc = 0;n_loc < gen_nb_xmlSAXLocatorPtr;n_loc++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + loc = gen_xmlSAXLocatorPtr(n_loc, 1); + + xmlSAX2SetDocumentLocator(ctx, loc); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_xmlSAXLocatorPtr(n_loc, loc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2SetDocumentLocator", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_loc); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2StartDocument(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + xmlSAX2StartDocument(ctx); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2StartDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2StartElement(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * fullname; /* The element name, including namespace prefix */ + int n_fullname; + xmlChar ** atts; /* An array of name/value attributes pairs, NULL terminated */ + int n_atts; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_fullname = 0;n_fullname < gen_nb_const_xmlChar_ptr;n_fullname++) { + for (n_atts = 0;n_atts < gen_nb_const_xmlChar_ptr_ptr;n_atts++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + fullname = gen_const_xmlChar_ptr(n_fullname, 1); + atts = gen_const_xmlChar_ptr_ptr(n_atts, 2); + + xmlSAX2StartElement(ctx, (const xmlChar *)fullname, (const xmlChar **)atts); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_fullname, (const xmlChar *)fullname, 1); + des_const_xmlChar_ptr_ptr(n_atts, (const xmlChar **)atts, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2StartElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_fullname); + printf(" %d", n_atts); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAX2StartElementNs(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * localname; /* the local name of the element */ + int n_localname; + xmlChar * prefix; /* the element namespace prefix if available */ + int n_prefix; + xmlChar * URI; /* the element namespace name if available */ + int n_URI; + int nb_namespaces; /* number of namespace definitions on that node */ + int n_nb_namespaces; + xmlChar ** namespaces; /* pointer to the array of prefix/URI pairs namespace definitions */ + int n_namespaces; + int nb_attributes; /* the number of attributes on that node */ + int n_nb_attributes; + int nb_defaulted; /* the number of defaulted attributes. */ + int n_nb_defaulted; + xmlChar ** attributes; /* pointer to the array of (localname/prefix/URI/value/end) attribute values. */ + int n_attributes; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_localname = 0;n_localname < gen_nb_const_xmlChar_ptr;n_localname++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_nb_namespaces = 0;n_nb_namespaces < gen_nb_int;n_nb_namespaces++) { + for (n_namespaces = 0;n_namespaces < gen_nb_const_xmlChar_ptr_ptr;n_namespaces++) { + for (n_nb_attributes = 0;n_nb_attributes < gen_nb_int;n_nb_attributes++) { + for (n_nb_defaulted = 0;n_nb_defaulted < gen_nb_int;n_nb_defaulted++) { + for (n_attributes = 0;n_attributes < gen_nb_const_xmlChar_ptr_ptr;n_attributes++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + localname = gen_const_xmlChar_ptr(n_localname, 1); + prefix = gen_const_xmlChar_ptr(n_prefix, 2); + URI = gen_const_xmlChar_ptr(n_URI, 3); + nb_namespaces = gen_int(n_nb_namespaces, 4); + namespaces = gen_const_xmlChar_ptr_ptr(n_namespaces, 5); + nb_attributes = gen_int(n_nb_attributes, 6); + nb_defaulted = gen_int(n_nb_defaulted, 7); + attributes = gen_const_xmlChar_ptr_ptr(n_attributes, 8); + + xmlSAX2StartElementNs(ctx, (const xmlChar *)localname, (const xmlChar *)prefix, (const xmlChar *)URI, nb_namespaces, (const xmlChar **)namespaces, nb_attributes, nb_defaulted, (const xmlChar **)attributes); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_localname, (const xmlChar *)localname, 1); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 3); + des_int(n_nb_namespaces, nb_namespaces, 4); + des_const_xmlChar_ptr_ptr(n_namespaces, (const xmlChar **)namespaces, 5); + des_int(n_nb_attributes, nb_attributes, 6); + des_int(n_nb_defaulted, nb_defaulted, 7); + des_const_xmlChar_ptr_ptr(n_attributes, (const xmlChar **)attributes, 8); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2StartElementNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_localname); + printf(" %d", n_prefix); + printf(" %d", n_URI); + printf(" %d", n_nb_namespaces); + printf(" %d", n_namespaces); + printf(" %d", n_nb_attributes); + printf(" %d", n_nb_defaulted); + printf(" %d", n_attributes); + printf("\n"); + } + } + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAX2UnparsedEntityDecl(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* the user data (XML parser context) */ + int n_ctx; + xmlChar * name; /* The name of the entity */ + int n_name; + xmlChar * publicId; /* The public ID of the entity */ + int n_publicId; + xmlChar * systemId; /* The system ID of the entity */ + int n_systemId; + xmlChar * notationName; /* the name of the notation */ + int n_notationName; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_publicId = 0;n_publicId < gen_nb_const_xmlChar_ptr;n_publicId++) { + for (n_systemId = 0;n_systemId < gen_nb_const_xmlChar_ptr;n_systemId++) { + for (n_notationName = 0;n_notationName < gen_nb_const_xmlChar_ptr;n_notationName++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + publicId = gen_const_xmlChar_ptr(n_publicId, 2); + systemId = gen_const_xmlChar_ptr(n_systemId, 3); + notationName = gen_const_xmlChar_ptr(n_notationName, 4); + + xmlSAX2UnparsedEntityDecl(ctx, (const xmlChar *)name, (const xmlChar *)publicId, (const xmlChar *)systemId, (const xmlChar *)notationName); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 2); + des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 3); + des_const_xmlChar_ptr(n_notationName, (const xmlChar *)notationName, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAX2UnparsedEntityDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_name); + printf(" %d", n_publicId); + printf(" %d", n_systemId); + printf(" %d", n_notationName); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSAXDefaultVersion(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + int ret_val; + int version; /* the version, 1 or 2 */ + int n_version; + + for (n_version = 0;n_version < gen_nb_int;n_version++) { + mem_base = xmlMemBlocks(); + version = gen_int(n_version, 0); + + ret_val = xmlSAXDefaultVersion(version); + desret_int(ret_val); + call_tests++; + des_int(n_version, version, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXDefaultVersion", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_version); + printf("\n"); + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXVersion(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlSAXHandler * hdlr; /* the SAX handler */ + int n_hdlr; + int version; /* the version, 1 or 2 */ + int n_version; + + for (n_hdlr = 0;n_hdlr < gen_nb_xmlSAXHandler_ptr;n_hdlr++) { + for (n_version = 0;n_version < gen_nb_int;n_version++) { + mem_base = xmlMemBlocks(); + hdlr = gen_xmlSAXHandler_ptr(n_hdlr, 0); + version = gen_int(n_version, 1); + + ret_val = xmlSAXVersion(hdlr, version); + desret_int(ret_val); + call_tests++; + des_xmlSAXHandler_ptr(n_hdlr, hdlr, 0); + des_int(n_version, version, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXVersion", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hdlr); + printf(" %d", n_version); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + +static int +test_SAX2(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing SAX2 : 38 of 38 functions ...\n"); + test_ret += test_docbDefaultSAXHandlerInit(); + test_ret += test_htmlDefaultSAXHandlerInit(); + test_ret += test_xmlDefaultSAXHandlerInit(); + test_ret += test_xmlSAX2AttributeDecl(); + test_ret += test_xmlSAX2CDataBlock(); + test_ret += test_xmlSAX2Characters(); + test_ret += test_xmlSAX2Comment(); + test_ret += test_xmlSAX2ElementDecl(); + test_ret += test_xmlSAX2EndDocument(); + test_ret += test_xmlSAX2EndElement(); + test_ret += test_xmlSAX2EndElementNs(); + test_ret += test_xmlSAX2EntityDecl(); + test_ret += test_xmlSAX2ExternalSubset(); + test_ret += test_xmlSAX2GetColumnNumber(); + test_ret += test_xmlSAX2GetEntity(); + test_ret += test_xmlSAX2GetLineNumber(); + test_ret += test_xmlSAX2GetParameterEntity(); + test_ret += test_xmlSAX2GetPublicId(); + test_ret += test_xmlSAX2GetSystemId(); + test_ret += test_xmlSAX2HasExternalSubset(); + test_ret += test_xmlSAX2HasInternalSubset(); + test_ret += test_xmlSAX2IgnorableWhitespace(); + test_ret += test_xmlSAX2InitDefaultSAXHandler(); + test_ret += test_xmlSAX2InitDocbDefaultSAXHandler(); + test_ret += test_xmlSAX2InitHtmlDefaultSAXHandler(); + test_ret += test_xmlSAX2InternalSubset(); + test_ret += test_xmlSAX2IsStandalone(); + test_ret += test_xmlSAX2NotationDecl(); + test_ret += test_xmlSAX2ProcessingInstruction(); + test_ret += test_xmlSAX2Reference(); + test_ret += test_xmlSAX2ResolveEntity(); + test_ret += test_xmlSAX2SetDocumentLocator(); + test_ret += test_xmlSAX2StartDocument(); + test_ret += test_xmlSAX2StartElement(); + test_ret += test_xmlSAX2StartElementNs(); + test_ret += test_xmlSAX2UnparsedEntityDecl(); + test_ret += test_xmlSAXDefaultVersion(); + test_ret += test_xmlSAXVersion(); + + if (test_ret != 0) + printf("Module SAX2: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlC14NDocDumpMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlDocPtr doc; /* the XML document for canonization */ + int n_doc; + xmlNodeSetPtr nodes; /* the nodes set to be included in the canonized image or NULL if all document nodes should be included */ + int n_nodes; + int mode; /* the c14n mode (see @xmlC14NMode) */ + int n_mode; + xmlChar ** inclusive_ns_prefixes; /* the list of inclusive namespace prefixes ended with a NULL or NULL if there is no inclusive namespaces (only for exclusive canonicalization, ignored otherwise) */ + int n_inclusive_ns_prefixes; + int with_comments; /* include comments in the result (!=0) or not (==0) */ + int n_with_comments; + xmlChar ** doc_txt_ptr; /* the memory pointer for allocated canonical XML text; the caller of this functions is responsible for calling xmlFree() to free allocated memory */ + int n_doc_txt_ptr; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { + for (n_inclusive_ns_prefixes = 0;n_inclusive_ns_prefixes < gen_nb_xmlChar_ptr_ptr;n_inclusive_ns_prefixes++) { + for (n_with_comments = 0;n_with_comments < gen_nb_int;n_with_comments++) { + for (n_doc_txt_ptr = 0;n_doc_txt_ptr < gen_nb_xmlChar_ptr_ptr;n_doc_txt_ptr++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + nodes = gen_xmlNodeSetPtr(n_nodes, 1); + mode = gen_int(n_mode, 2); + inclusive_ns_prefixes = gen_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, 3); + with_comments = gen_int(n_with_comments, 4); + doc_txt_ptr = gen_xmlChar_ptr_ptr(n_doc_txt_ptr, 5); + + ret_val = xmlC14NDocDumpMemory(doc, nodes, mode, inclusive_ns_prefixes, with_comments, doc_txt_ptr); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodeSetPtr(n_nodes, nodes, 1); + des_int(n_mode, mode, 2); + des_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, inclusive_ns_prefixes, 3); + des_int(n_with_comments, with_comments, 4); + des_xmlChar_ptr_ptr(n_doc_txt_ptr, doc_txt_ptr, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlC14NDocDumpMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_nodes); + printf(" %d", n_mode); + printf(" %d", n_inclusive_ns_prefixes); + printf(" %d", n_with_comments); + printf(" %d", n_doc_txt_ptr); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlC14NDocSave(void) { + int test_ret = 0; + +#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlDocPtr doc; /* the XML document for canonization */ + int n_doc; + xmlNodeSetPtr nodes; /* the nodes set to be included in the canonized image or NULL if all document nodes should be included */ + int n_nodes; + int mode; /* the c14n mode (see @xmlC14NMode) */ + int n_mode; + xmlChar ** inclusive_ns_prefixes; /* the list of inclusive namespace prefixes ended with a NULL or NULL if there is no inclusive namespaces (only for exclusive canonicalization, ignored otherwise) */ + int n_inclusive_ns_prefixes; + int with_comments; /* include comments in the result (!=0) or not (==0) */ + int n_with_comments; + const char * filename; /* the filename to store canonical XML image */ + int n_filename; + int compression; /* the compression level (zlib required): -1 - libxml default, 0 - uncompressed, >0 - compression level */ + int n_compression; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { + for (n_inclusive_ns_prefixes = 0;n_inclusive_ns_prefixes < gen_nb_xmlChar_ptr_ptr;n_inclusive_ns_prefixes++) { + for (n_with_comments = 0;n_with_comments < gen_nb_int;n_with_comments++) { + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_compression = 0;n_compression < gen_nb_int;n_compression++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + nodes = gen_xmlNodeSetPtr(n_nodes, 1); + mode = gen_int(n_mode, 2); + inclusive_ns_prefixes = gen_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, 3); + with_comments = gen_int(n_with_comments, 4); + filename = gen_fileoutput(n_filename, 5); + compression = gen_int(n_compression, 6); + + ret_val = xmlC14NDocSave(doc, nodes, mode, inclusive_ns_prefixes, with_comments, filename, compression); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodeSetPtr(n_nodes, nodes, 1); + des_int(n_mode, mode, 2); + des_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, inclusive_ns_prefixes, 3); + des_int(n_with_comments, with_comments, 4); + des_fileoutput(n_filename, filename, 5); + des_int(n_compression, compression, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlC14NDocSave", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_nodes); + printf(" %d", n_mode); + printf(" %d", n_inclusive_ns_prefixes); + printf(" %d", n_with_comments); + printf(" %d", n_filename); + printf(" %d", n_compression); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlC14NDocSaveTo(void) { + int test_ret = 0; + +#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlDocPtr doc; /* the XML document for canonization */ + int n_doc; + xmlNodeSetPtr nodes; /* the nodes set to be included in the canonized image or NULL if all document nodes should be included */ + int n_nodes; + int mode; /* the c14n mode (see @xmlC14NMode) */ + int n_mode; + xmlChar ** inclusive_ns_prefixes; /* the list of inclusive namespace prefixes ended with a NULL or NULL if there is no inclusive namespaces (only for exclusive canonicalization, ignored otherwise) */ + int n_inclusive_ns_prefixes; + int with_comments; /* include comments in the result (!=0) or not (==0) */ + int n_with_comments; + xmlOutputBufferPtr buf; /* the output buffer to store canonical XML; this buffer MUST have encoder==NULL because C14N requires UTF-8 output */ + int n_buf; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { + for (n_inclusive_ns_prefixes = 0;n_inclusive_ns_prefixes < gen_nb_xmlChar_ptr_ptr;n_inclusive_ns_prefixes++) { + for (n_with_comments = 0;n_with_comments < gen_nb_int;n_with_comments++) { + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + nodes = gen_xmlNodeSetPtr(n_nodes, 1); + mode = gen_int(n_mode, 2); + inclusive_ns_prefixes = gen_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, 3); + with_comments = gen_int(n_with_comments, 4); + buf = gen_xmlOutputBufferPtr(n_buf, 5); + + ret_val = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes, with_comments, buf); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodeSetPtr(n_nodes, nodes, 1); + des_int(n_mode, mode, 2); + des_xmlChar_ptr_ptr(n_inclusive_ns_prefixes, inclusive_ns_prefixes, 3); + des_int(n_with_comments, with_comments, 4); + des_xmlOutputBufferPtr(n_buf, buf, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlC14NDocSaveTo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_nodes); + printf(" %d", n_mode); + printf(" %d", n_inclusive_ns_prefixes); + printf(" %d", n_with_comments); + printf(" %d", n_buf); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlC14NExecute(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_c14n(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing c14n : 3 of 4 functions ...\n"); + test_ret += test_xmlC14NDocDumpMemory(); + test_ret += test_xmlC14NDocSave(); + test_ret += test_xmlC14NDocSaveTo(); + test_ret += test_xmlC14NExecute(); + + if (test_ret != 0) + printf("Module c14n: %d errors\n", test_ret); + return(test_ret); +} +#ifdef LIBXML_CATALOG_ENABLED + +#define gen_nb_xmlCatalogPtr 1 +static xmlCatalogPtr gen_xmlCatalogPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlCatalogPtr(int no ATTRIBUTE_UNUSED, xmlCatalogPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlACatalogAdd(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + int ret_val; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + xmlChar * type; /* the type of record to add to the catalog */ + int n_type; + xmlChar * orig; /* the system, public or prefix to match */ + int n_orig; + xmlChar * replace; /* the replacement value for the match */ + int n_replace; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_type = 0;n_type < gen_nb_const_xmlChar_ptr;n_type++) { + for (n_orig = 0;n_orig < gen_nb_const_xmlChar_ptr;n_orig++) { + for (n_replace = 0;n_replace < gen_nb_const_xmlChar_ptr;n_replace++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + type = gen_const_xmlChar_ptr(n_type, 1); + orig = gen_const_xmlChar_ptr(n_orig, 2); + replace = gen_const_xmlChar_ptr(n_replace, 3); + + ret_val = xmlACatalogAdd(catal, (const xmlChar *)type, (const xmlChar *)orig, (const xmlChar *)replace); + desret_int(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_const_xmlChar_ptr(n_type, (const xmlChar *)type, 1); + des_const_xmlChar_ptr(n_orig, (const xmlChar *)orig, 2); + des_const_xmlChar_ptr(n_replace, (const xmlChar *)replace, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogAdd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_type); + printf(" %d", n_orig); + printf(" %d", n_replace); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlACatalogDump(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + FILE * out; /* the file. */ + int n_out; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_out = 0;n_out < gen_nb_FILE_ptr;n_out++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + out = gen_FILE_ptr(n_out, 1); + + xmlACatalogDump(catal, out); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_FILE_ptr(n_out, out, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_out); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlACatalogRemove(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + int ret_val; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + xmlChar * value; /* the value to remove */ + int n_value; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + + ret_val = xmlACatalogRemove(catal, (const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogRemove", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlACatalogResolve(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + xmlChar * pubID; /* the public ID string */ + int n_pubID; + xmlChar * sysID; /* the system ID string */ + int n_sysID; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { + for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + pubID = gen_const_xmlChar_ptr(n_pubID, 1); + sysID = gen_const_xmlChar_ptr(n_sysID, 2); + + ret_val = xmlACatalogResolve(catal, (const xmlChar *)pubID, (const xmlChar *)sysID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 1); + des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogResolve", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_pubID); + printf(" %d", n_sysID); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlACatalogResolvePublic(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + xmlChar * pubID; /* the public ID string */ + int n_pubID; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + pubID = gen_const_xmlChar_ptr(n_pubID, 1); + + ret_val = xmlACatalogResolvePublic(catal, (const xmlChar *)pubID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogResolvePublic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_pubID); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlACatalogResolveSystem(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + xmlChar * sysID; /* the system ID string */ + int n_sysID; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + sysID = gen_const_xmlChar_ptr(n_sysID, 1); + + ret_val = xmlACatalogResolveSystem(catal, (const xmlChar *)sysID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogResolveSystem", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_sysID); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlACatalogResolveURI(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlCatalogPtr catal; /* a Catalog */ + int n_catal; + xmlChar * URI; /* the URI */ + int n_URI; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + URI = gen_const_xmlChar_ptr(n_URI, 1); + + ret_val = xmlACatalogResolveURI(catal, (const xmlChar *)URI); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlACatalogResolveURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf(" %d", n_URI); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogAdd(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + int ret_val; + xmlChar * type; /* the type of record to add to the catalog */ + int n_type; + xmlChar * orig; /* the system, public or prefix to match */ + int n_orig; + xmlChar * replace; /* the replacement value for the match */ + int n_replace; + + for (n_type = 0;n_type < gen_nb_const_xmlChar_ptr;n_type++) { + for (n_orig = 0;n_orig < gen_nb_const_xmlChar_ptr;n_orig++) { + for (n_replace = 0;n_replace < gen_nb_const_xmlChar_ptr;n_replace++) { + mem_base = xmlMemBlocks(); + type = gen_const_xmlChar_ptr(n_type, 0); + orig = gen_const_xmlChar_ptr(n_orig, 1); + replace = gen_const_xmlChar_ptr(n_replace, 2); + + ret_val = xmlCatalogAdd((const xmlChar *)type, (const xmlChar *)orig, (const xmlChar *)replace); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_type, (const xmlChar *)type, 0); + des_const_xmlChar_ptr(n_orig, (const xmlChar *)orig, 1); + des_const_xmlChar_ptr(n_replace, (const xmlChar *)replace, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogAdd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_orig); + printf(" %d", n_replace); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogCleanup(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + + + xmlCatalogCleanup(); + call_tests++; + xmlResetLastError(); + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogConvert(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int ret_val; + + + ret_val = xmlCatalogConvert(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogDump(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + FILE * out; /* the file. */ + int n_out; + + for (n_out = 0;n_out < gen_nb_FILE_ptr;n_out++) { + mem_base = xmlMemBlocks(); + out = gen_FILE_ptr(n_out, 0); + + xmlCatalogDump(out); + call_tests++; + des_FILE_ptr(n_out, out, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogGetDefaults(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlCatalogAllow ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlCatalogGetDefaults(); + desret_xmlCatalogAllow(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogGetDefaults", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogIsEmpty(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + int ret_val; + xmlCatalogPtr catal; /* should this create an SGML catalog */ + int n_catal; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + + ret_val = xmlCatalogIsEmpty(catal); + desret_int(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogIsEmpty", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogLocalResolve(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + void * catalogs; /* a document's list of catalogs */ + int n_catalogs; + xmlChar * pubID; /* the public ID string */ + int n_pubID; + xmlChar * sysID; /* the system ID string */ + int n_sysID; + + for (n_catalogs = 0;n_catalogs < gen_nb_void_ptr;n_catalogs++) { + for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { + for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { + mem_base = xmlMemBlocks(); + catalogs = gen_void_ptr(n_catalogs, 0); + pubID = gen_const_xmlChar_ptr(n_pubID, 1); + sysID = gen_const_xmlChar_ptr(n_sysID, 2); + + ret_val = xmlCatalogLocalResolve(catalogs, (const xmlChar *)pubID, (const xmlChar *)sysID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_void_ptr(n_catalogs, catalogs, 0); + des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 1); + des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogLocalResolve", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catalogs); + printf(" %d", n_pubID); + printf(" %d", n_sysID); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogLocalResolveURI(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + void * catalogs; /* a document's list of catalogs */ + int n_catalogs; + xmlChar * URI; /* the URI */ + int n_URI; + + for (n_catalogs = 0;n_catalogs < gen_nb_void_ptr;n_catalogs++) { + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + mem_base = xmlMemBlocks(); + catalogs = gen_void_ptr(n_catalogs, 0); + URI = gen_const_xmlChar_ptr(n_URI, 1); + + ret_val = xmlCatalogLocalResolveURI(catalogs, (const xmlChar *)URI); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_void_ptr(n_catalogs, catalogs, 0); + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogLocalResolveURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catalogs); + printf(" %d", n_URI); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogRemove(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int ret_val; + xmlChar * value; /* the value to remove */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlCatalogRemove((const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogResolve(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + xmlChar * ret_val; + xmlChar * pubID; /* the public ID string */ + int n_pubID; + xmlChar * sysID; /* the system ID string */ + int n_sysID; + + for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { + for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { + pubID = gen_const_xmlChar_ptr(n_pubID, 0); + sysID = gen_const_xmlChar_ptr(n_sysID, 1); + + ret_val = xmlCatalogResolve((const xmlChar *)pubID, (const xmlChar *)sysID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 0); + des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 1); + xmlResetLastError(); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogResolvePublic(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlChar * pubID; /* the public ID string */ + int n_pubID; + + for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { + mem_base = xmlMemBlocks(); + pubID = gen_const_xmlChar_ptr(n_pubID, 0); + + ret_val = xmlCatalogResolvePublic((const xmlChar *)pubID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogResolvePublic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_pubID); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogResolveSystem(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlChar * sysID; /* the system ID string */ + int n_sysID; + + for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { + mem_base = xmlMemBlocks(); + sysID = gen_const_xmlChar_ptr(n_sysID, 0); + + ret_val = xmlCatalogResolveSystem((const xmlChar *)sysID); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogResolveSystem", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sysID); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogResolveURI(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlChar * URI; /* the URI */ + int n_URI; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + + ret_val = xmlCatalogResolveURI((const xmlChar *)URI); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogResolveURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogSetDefaultPrefer(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlCatalogPrefer ret_val; + xmlCatalogPrefer prefer; /* the default preference for delegation */ + int n_prefer; + + for (n_prefer = 0;n_prefer < gen_nb_xmlCatalogPrefer;n_prefer++) { + mem_base = xmlMemBlocks(); + prefer = gen_xmlCatalogPrefer(n_prefer, 0); + + ret_val = xmlCatalogSetDefaultPrefer(prefer); + desret_xmlCatalogPrefer(ret_val); + call_tests++; + des_xmlCatalogPrefer(n_prefer, prefer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogSetDefaultPrefer", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_prefer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCatalogSetDefaults(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlCatalogAllow allow; /* what catalogs should be accepted */ + int n_allow; + + for (n_allow = 0;n_allow < gen_nb_xmlCatalogAllow;n_allow++) { + mem_base = xmlMemBlocks(); + allow = gen_xmlCatalogAllow(n_allow, 0); + + xmlCatalogSetDefaults(allow); + call_tests++; + des_xmlCatalogAllow(n_allow, allow, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCatalogSetDefaults", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_allow); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlConvertSGMLCatalog(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + int ret_val; + xmlCatalogPtr catal; /* the catalog */ + int n_catal; + + for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { + mem_base = xmlMemBlocks(); + catal = gen_xmlCatalogPtr(n_catal, 0); + + ret_val = xmlConvertSGMLCatalog(catal); + desret_int(ret_val); + call_tests++; + des_xmlCatalogPtr(n_catal, catal, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlConvertSGMLCatalog", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_catal); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlInitializeCatalog(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlInitializeCatalog(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitializeCatalog", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlLoadACatalog(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlLoadCatalog(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int ret_val; + const char * filename; /* a file path */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + filename = gen_filepath(n_filename, 0); + + ret_val = xmlLoadCatalog(filename); + desret_int(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlLoadCatalogs(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + char * pathss; /* a list of directories separated by a colon or a space. */ + int n_pathss; + + for (n_pathss = 0;n_pathss < gen_nb_const_char_ptr;n_pathss++) { + pathss = gen_const_char_ptr(n_pathss, 0); + + xmlLoadCatalogs((const char *)pathss); + call_tests++; + des_const_char_ptr(n_pathss, (const char *)pathss, 0); + xmlResetLastError(); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlLoadSGMLSuperCatalog(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNewCatalog(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParseCatalogFile(void) { + int test_ret = 0; + +#if defined(LIBXML_CATALOG_ENABLED) + int mem_base; + xmlDocPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlParseCatalogFile(filename); + desret_xmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseCatalogFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_catalog(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing catalog : 27 of 36 functions ...\n"); + test_ret += test_xmlACatalogAdd(); + test_ret += test_xmlACatalogDump(); + test_ret += test_xmlACatalogRemove(); + test_ret += test_xmlACatalogResolve(); + test_ret += test_xmlACatalogResolvePublic(); + test_ret += test_xmlACatalogResolveSystem(); + test_ret += test_xmlACatalogResolveURI(); + test_ret += test_xmlCatalogAdd(); + test_ret += test_xmlCatalogCleanup(); + test_ret += test_xmlCatalogConvert(); + test_ret += test_xmlCatalogDump(); + test_ret += test_xmlCatalogGetDefaults(); + test_ret += test_xmlCatalogIsEmpty(); + test_ret += test_xmlCatalogLocalResolve(); + test_ret += test_xmlCatalogLocalResolveURI(); + test_ret += test_xmlCatalogRemove(); + test_ret += test_xmlCatalogResolve(); + test_ret += test_xmlCatalogResolvePublic(); + test_ret += test_xmlCatalogResolveSystem(); + test_ret += test_xmlCatalogResolveURI(); + test_ret += test_xmlCatalogSetDefaultPrefer(); + test_ret += test_xmlCatalogSetDefaults(); + test_ret += test_xmlConvertSGMLCatalog(); + test_ret += test_xmlInitializeCatalog(); + test_ret += test_xmlLoadACatalog(); + test_ret += test_xmlLoadCatalog(); + test_ret += test_xmlLoadCatalogs(); + test_ret += test_xmlLoadSGMLSuperCatalog(); + test_ret += test_xmlNewCatalog(); + test_ret += test_xmlParseCatalogFile(); + + if (test_ret != 0) + printf("Module catalog: %d errors\n", test_ret); + return(test_ret); +} + +#define gen_nb_const_xmlChRangeGroup_ptr 1 +static xmlChRangeGroup * gen_const_xmlChRangeGroup_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlChRangeGroup_ptr(int no ATTRIBUTE_UNUSED, const xmlChRangeGroup * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlCharInRange(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int val; /* character to be validated */ + int n_val; + xmlChRangeGroup * rptr; /* pointer to range to be used to validate */ + int n_rptr; + + for (n_val = 0;n_val < gen_nb_unsigned_int;n_val++) { + for (n_rptr = 0;n_rptr < gen_nb_const_xmlChRangeGroup_ptr;n_rptr++) { + mem_base = xmlMemBlocks(); + val = gen_unsigned_int(n_val, 0); + rptr = gen_const_xmlChRangeGroup_ptr(n_rptr, 1); + + ret_val = xmlCharInRange(val, (const xmlChRangeGroup *)rptr); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_val, val, 0); + des_const_xmlChRangeGroup_ptr(n_rptr, (const xmlChRangeGroup *)rptr, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharInRange", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf(" %d", n_rptr); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsBaseChar(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsBaseChar(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsBaseChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsBlank(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsBlank(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsBlank", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsChar(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsChar(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsCombining(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsCombining(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsCombining", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsDigit(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsDigit(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsDigit", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsExtender(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsExtender(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsExtender", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsIdeographic(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsIdeographic(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsIdeographic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsPubidChar(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned int ch; /* character to validate */ + int n_ch; + + for (n_ch = 0;n_ch < gen_nb_unsigned_int;n_ch++) { + mem_base = xmlMemBlocks(); + ch = gen_unsigned_int(n_ch, 0); + + ret_val = xmlIsPubidChar(ch); + desret_int(ret_val); + call_tests++; + des_unsigned_int(n_ch, ch, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsPubidChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ch); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + +static int +test_chvalid(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing chvalid : 9 of 9 functions ...\n"); + test_ret += test_xmlCharInRange(); + test_ret += test_xmlIsBaseChar(); + test_ret += test_xmlIsBlank(); + test_ret += test_xmlIsChar(); + test_ret += test_xmlIsCombining(); + test_ret += test_xmlIsDigit(); + test_ret += test_xmlIsExtender(); + test_ret += test_xmlIsIdeographic(); + test_ret += test_xmlIsPubidChar(); + + if (test_ret != 0) + printf("Module chvalid: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlBoolToText(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + const char * ret_val; + int boolval; /* a bool to turn into text */ + int n_boolval; + + for (n_boolval = 0;n_boolval < gen_nb_int;n_boolval++) { + mem_base = xmlMemBlocks(); + boolval = gen_int(n_boolval, 0); + + ret_val = xmlBoolToText(boolval); + desret_const_char_ptr(ret_val); + call_tests++; + des_int(n_boolval, boolval, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBoolToText", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_boolval); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugCheckDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + int ret_val; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlDocPtr doc; /* the document */ + int n_doc; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlDebugCheckDocument(output, doc); + desret_int(ret_val); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugCheckDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpAttr(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlAttrPtr attr; /* the attribute */ + int n_attr; + int depth; /* the indentation level. */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + attr = gen_xmlAttrPtr(n_attr, 1); + depth = gen_int(n_depth, 2); + + xmlDebugDumpAttr(output, attr, depth); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlAttrPtr(n_attr, attr, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpAttr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_attr); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpAttrList(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlAttrPtr attr; /* the attribute list */ + int n_attr; + int depth; /* the indentation level. */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + attr = gen_xmlAttrPtr(n_attr, 1); + depth = gen_int(n_depth, 2); + + xmlDebugDumpAttrList(output, attr, depth); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlAttrPtr(n_attr, attr, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpAttrList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_attr); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlDtdPtr dtd; /* the DTD */ + int n_dtd; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + dtd = gen_xmlDtdPtr(n_dtd, 1); + + xmlDebugDumpDTD(output, dtd); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlDtdPtr(n_dtd, dtd, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpDTD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_dtd); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlDocPtr doc; /* the document */ + int n_doc; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + xmlDebugDumpDocument(output, doc); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpDocumentHead(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlDocPtr doc; /* the document */ + int n_doc; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + xmlDebugDumpDocumentHead(output, doc); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpDocumentHead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpEntities(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlDocPtr doc; /* the document */ + int n_doc; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + xmlDebugDumpEntities(output, doc); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpEntities", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpNode(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlNodePtr node; /* the node */ + int n_node; + int depth; /* the indentation level. */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + node = gen_xmlNodePtr(n_node, 1); + depth = gen_int(n_depth, 2); + + xmlDebugDumpNode(output, node, depth); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlNodePtr(n_node, node, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_node); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpNodeList(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlNodePtr node; /* the node list */ + int n_node; + int depth; /* the indentation level. */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + node = gen_xmlNodePtr(n_node, 1); + depth = gen_int(n_depth, 2); + + xmlDebugDumpNodeList(output, node, depth); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlNodePtr(n_node, node, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpNodeList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_node); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpOneNode(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlNodePtr node; /* the node */ + int n_node; + int depth; /* the indentation level. */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + node = gen_xmlNodePtr(n_node, 1); + depth = gen_int(n_depth, 2); + + xmlDebugDumpOneNode(output, node, depth); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlNodePtr(n_node, node, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpOneNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_node); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDebugDumpString(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlChar * str; /* the string */ + int n_str; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + + xmlDebugDumpString(output, (const xmlChar *)str); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDebugDumpString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlLsCountNode(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr node; /* the node to count */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlLsCountNode(node); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLsCountNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlLsOneNode(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlNodePtr node; /* the node to dump */ + int n_node; + + for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + output = gen_debug_FILE_ptr(n_output, 0); + node = gen_xmlNodePtr(n_node, 1); + + xmlLsOneNode(output, node); + call_tests++; + des_debug_FILE_ptr(n_output, output, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLsOneNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShell(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +#define gen_nb_char_ptr 1 +static char * gen_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_char_ptr(int no ATTRIBUTE_UNUSED, char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlShellBase(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * arg; /* unused */ + int n_arg; + xmlNodePtr node; /* a node */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + arg = gen_char_ptr(n_arg, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellBase(ctxt, arg, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_arg, arg, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellBase", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_arg); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellCat(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * arg; /* unused */ + int n_arg; + xmlNodePtr node; /* a node */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + arg = gen_char_ptr(n_arg, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellCat(ctxt, arg, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_arg, arg, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellCat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_arg); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellDir(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * arg; /* unused */ + int n_arg; + xmlNodePtr node; /* a node */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + arg = gen_char_ptr(n_arg, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellDir(ctxt, arg, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_arg, arg, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellDir", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_arg); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellDu(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * arg; /* unused */ + int n_arg; + xmlNodePtr tree; /* a node defining a subtree */ + int n_tree; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) { + for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + arg = gen_char_ptr(n_arg, 1); + tree = gen_xmlNodePtr(n_tree, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellDu(ctxt, arg, tree, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_arg, arg, 1); + des_xmlNodePtr(n_tree, tree, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellDu", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_arg); + printf(" %d", n_tree); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellList(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * arg; /* unused */ + int n_arg; + xmlNodePtr node; /* a node */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + arg = gen_char_ptr(n_arg, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellList(ctxt, arg, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_arg, arg, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_arg); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellLoad(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * filename; /* the file name */ + int n_filename; + xmlNodePtr node; /* unused */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_char_ptr;n_filename++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + filename = gen_char_ptr(n_filename, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellLoad(ctxt, filename, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_filename, filename, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellLoad", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellPrintXPathResult(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr list; /* a valid result generated by an xpath evaluation */ + int n_list; + + for (n_list = 0;n_list < gen_nb_xmlXPathObjectPtr;n_list++) { + mem_base = xmlMemBlocks(); + list = gen_xmlXPathObjectPtr(n_list, 0); + + xmlShellPrintXPathResult(list); + call_tests++; + des_xmlXPathObjectPtr(n_list, list, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellPrintXPathResult", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_list); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellPwd(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * buffer; /* the output buffer */ + int n_buffer; + xmlNodePtr node; /* a node */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_buffer = 0;n_buffer < gen_nb_char_ptr;n_buffer++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + buffer = gen_char_ptr(n_buffer, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellPwd(ctxt, buffer, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_buffer, buffer, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellPwd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_buffer); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellSave(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * filename; /* the file name (optional) */ + int n_filename; + xmlNodePtr node; /* unused */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_char_ptr;n_filename++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + filename = gen_char_ptr(n_filename, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellSave(ctxt, filename, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_filename, filename, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellSave", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellValidate(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * dtd; /* the DTD URI (optional) */ + int n_dtd; + xmlNodePtr node; /* unused */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_dtd = 0;n_dtd < gen_nb_char_ptr;n_dtd++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + dtd = gen_char_ptr(n_dtd, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellValidate(ctxt, dtd, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_dtd, dtd, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellValidate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_dtd); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlShellWrite(void) { + int test_ret = 0; + +#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlShellCtxtPtr ctxt; /* the shell context */ + int n_ctxt; + char * filename; /* the file name */ + int n_filename; + xmlNodePtr node; /* a node in the tree */ + int n_node; + xmlNodePtr node2; /* unused */ + int n_node2; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_char_ptr;n_filename++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0); + filename = gen_char_ptr(n_filename, 1); + node = gen_xmlNodePtr(n_node, 2); + node2 = gen_xmlNodePtr(n_node2, 3); + + ret_val = xmlShellWrite(ctxt, filename, node, node2); + desret_int(ret_val); + call_tests++; + des_xmlShellCtxtPtr(n_ctxt, ctxt, 0); + des_char_ptr(n_filename, filename, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr(n_node2, node2, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlShellWrite", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf(" %d", n_node); + printf(" %d", n_node2); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_debugXML(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing debugXML : 25 of 28 functions ...\n"); + test_ret += test_xmlBoolToText(); + test_ret += test_xmlDebugCheckDocument(); + test_ret += test_xmlDebugDumpAttr(); + test_ret += test_xmlDebugDumpAttrList(); + test_ret += test_xmlDebugDumpDTD(); + test_ret += test_xmlDebugDumpDocument(); + test_ret += test_xmlDebugDumpDocumentHead(); + test_ret += test_xmlDebugDumpEntities(); + test_ret += test_xmlDebugDumpNode(); + test_ret += test_xmlDebugDumpNodeList(); + test_ret += test_xmlDebugDumpOneNode(); + test_ret += test_xmlDebugDumpString(); + test_ret += test_xmlLsCountNode(); + test_ret += test_xmlLsOneNode(); + test_ret += test_xmlShell(); + test_ret += test_xmlShellBase(); + test_ret += test_xmlShellCat(); + test_ret += test_xmlShellDir(); + test_ret += test_xmlShellDu(); + test_ret += test_xmlShellList(); + test_ret += test_xmlShellLoad(); + test_ret += test_xmlShellPrintXPathResult(); + test_ret += test_xmlShellPwd(); + test_ret += test_xmlShellSave(); + test_ret += test_xmlShellValidate(); + test_ret += test_xmlShellWrite(); + + if (test_ret != 0) + printf("Module debugXML: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlDictCleanup(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlDictCleanup(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictCleanup", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictCreate(void) { + int test_ret = 0; + + int mem_base; + xmlDictPtr ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlDictCreate(); + desret_xmlDictPtr(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictCreate", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictCreateSub(void) { + int test_ret = 0; + + int mem_base; + xmlDictPtr ret_val; + xmlDictPtr sub; /* an existing dictionary */ + int n_sub; + + for (n_sub = 0;n_sub < gen_nb_xmlDictPtr;n_sub++) { + mem_base = xmlMemBlocks(); + sub = gen_xmlDictPtr(n_sub, 0); + + ret_val = xmlDictCreateSub(sub); + desret_xmlDictPtr(ret_val); + call_tests++; + des_xmlDictPtr(n_sub, sub, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictCreateSub", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sub); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictExists(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlDictPtr dict; /* the dictionary */ + int n_dict; + xmlChar * name; /* the name of the userdata */ + int n_name; + int len; /* the length of the name, if -1 it is recomputed */ + int n_len; + + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + dict = gen_xmlDictPtr(n_dict, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + len = gen_int(n_len, 2); + if ((name != NULL) && + (len > (int) strlen((const char *) name) + 1)) + continue; + + ret_val = xmlDictExists(dict, (const xmlChar *)name, len); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlDictPtr(n_dict, dict, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictExists", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dict); + printf(" %d", n_name); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictGetUsage(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlDictLookup(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlDictPtr dict; /* the dictionary */ + int n_dict; + xmlChar * name; /* the name of the userdata */ + int n_name; + int len; /* the length of the name, if -1 it is recomputed */ + int n_len; + + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + dict = gen_xmlDictPtr(n_dict, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + len = gen_int(n_len, 2); + if ((name != NULL) && + (len > (int) strlen((const char *) name) + 1)) + continue; + + ret_val = xmlDictLookup(dict, (const xmlChar *)name, len); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlDictPtr(n_dict, dict, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dict); + printf(" %d", n_name); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictOwns(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDictPtr dict; /* the dictionary */ + int n_dict; + xmlChar * str; /* the string */ + int n_str; + + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + dict = gen_xmlDictPtr(n_dict, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + + ret_val = xmlDictOwns(dict, (const xmlChar *)str); + desret_int(ret_val); + call_tests++; + des_xmlDictPtr(n_dict, dict, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictOwns", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dict); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictQLookup(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlDictPtr dict; /* the dictionary */ + int n_dict; + xmlChar * prefix; /* the prefix */ + int n_prefix; + xmlChar * name; /* the name */ + int n_name; + + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + dict = gen_xmlDictPtr(n_dict, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + + ret_val = xmlDictQLookup(dict, (const xmlChar *)prefix, (const xmlChar *)name); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlDictPtr(n_dict, dict, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictQLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dict); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictReference(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDictPtr dict; /* the dictionary */ + int n_dict; + + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + mem_base = xmlMemBlocks(); + dict = gen_xmlDictPtr(n_dict, 0); + + ret_val = xmlDictReference(dict); + xmlDictFree(dict); + desret_int(ret_val); + call_tests++; + des_xmlDictPtr(n_dict, dict, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictReference", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dict); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDictSetLimit(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlDictSize(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDictPtr dict; /* the dictionary */ + int n_dict; + + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + mem_base = xmlMemBlocks(); + dict = gen_xmlDictPtr(n_dict, 0); + + ret_val = xmlDictSize(dict); + desret_int(ret_val); + call_tests++; + des_xmlDictPtr(n_dict, dict, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDictSize", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dict); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlInitializeDict(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlInitializeDict(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitializeDict", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + +static int +test_dict(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing dict : 10 of 13 functions ...\n"); + test_ret += test_xmlDictCleanup(); + test_ret += test_xmlDictCreate(); + test_ret += test_xmlDictCreateSub(); + test_ret += test_xmlDictExists(); + test_ret += test_xmlDictGetUsage(); + test_ret += test_xmlDictLookup(); + test_ret += test_xmlDictOwns(); + test_ret += test_xmlDictQLookup(); + test_ret += test_xmlDictReference(); + test_ret += test_xmlDictSetLimit(); + test_ret += test_xmlDictSize(); + test_ret += test_xmlInitializeDict(); + + if (test_ret != 0) + printf("Module dict: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_UTF8Toisolat1(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) +#ifdef LIBXML_OUTPUT_ENABLED + int mem_base; + int ret_val; + unsigned char * out; /* a pointer to an array of bytes to store the result */ + int n_out; + int * outlen; /* the length of @out */ + int n_outlen; + unsigned char * in; /* a pointer to an array of UTF-8 chars */ + int n_in; + int * inlen; /* the length of @in */ + int n_inlen; + + for (n_out = 0;n_out < gen_nb_unsigned_char_ptr;n_out++) { + for (n_outlen = 0;n_outlen < gen_nb_int_ptr;n_outlen++) { + for (n_in = 0;n_in < gen_nb_const_unsigned_char_ptr;n_in++) { + for (n_inlen = 0;n_inlen < gen_nb_int_ptr;n_inlen++) { + mem_base = xmlMemBlocks(); + out = gen_unsigned_char_ptr(n_out, 0); + outlen = gen_int_ptr(n_outlen, 1); + in = gen_const_unsigned_char_ptr(n_in, 2); + inlen = gen_int_ptr(n_inlen, 3); + + ret_val = UTF8Toisolat1(out, outlen, (const unsigned char *)in, inlen); + desret_int(ret_val); + call_tests++; + des_unsigned_char_ptr(n_out, out, 0); + des_int_ptr(n_outlen, outlen, 1); + des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_int_ptr(n_inlen, inlen, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in UTF8Toisolat1", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_outlen); + printf(" %d", n_in); + printf(" %d", n_inlen); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_isolat1ToUTF8(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned char * out; /* a pointer to an array of bytes to store the result */ + int n_out; + int * outlen; /* the length of @out */ + int n_outlen; + unsigned char * in; /* a pointer to an array of ISO Latin 1 chars */ + int n_in; + int * inlen; /* the length of @in */ + int n_inlen; + + for (n_out = 0;n_out < gen_nb_unsigned_char_ptr;n_out++) { + for (n_outlen = 0;n_outlen < gen_nb_int_ptr;n_outlen++) { + for (n_in = 0;n_in < gen_nb_const_unsigned_char_ptr;n_in++) { + for (n_inlen = 0;n_inlen < gen_nb_int_ptr;n_inlen++) { + mem_base = xmlMemBlocks(); + out = gen_unsigned_char_ptr(n_out, 0); + outlen = gen_int_ptr(n_outlen, 1); + in = gen_const_unsigned_char_ptr(n_in, 2); + inlen = gen_int_ptr(n_inlen, 3); + + ret_val = isolat1ToUTF8(out, outlen, (const unsigned char *)in, inlen); + desret_int(ret_val); + call_tests++; + des_unsigned_char_ptr(n_out, out, 0); + des_int_ptr(n_outlen, outlen, 1); + des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_int_ptr(n_inlen, inlen, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in isolat1ToUTF8", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_outlen); + printf(" %d", n_in); + printf(" %d", n_inlen); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddEncodingAlias(void) { + int test_ret = 0; + + int ret_val; + char * name; /* the encoding name as parsed, in UTF-8 format (ASCII actually) */ + int n_name; + char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ + int n_alias; + + for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { + for (n_alias = 0;n_alias < gen_nb_const_char_ptr;n_alias++) { + name = gen_const_char_ptr(n_name, 0); + alias = gen_const_char_ptr(n_alias, 1); + + ret_val = xmlAddEncodingAlias((const char *)name, (const char *)alias); + desret_int(ret_val); + call_tests++; + des_const_char_ptr(n_name, (const char *)name, 0); + des_const_char_ptr(n_alias, (const char *)alias, 1); + xmlResetLastError(); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlCharEncodingHandler_ptr 1 +static xmlCharEncodingHandler * gen_xmlCharEncodingHandler_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlCharEncodingHandler_ptr(int no ATTRIBUTE_UNUSED, xmlCharEncodingHandler * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlCharEncCloseFunc(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlCharEncodingHandler * handler; /* char encoding transformation data structure */ + int n_handler; + + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandler_ptr;n_handler++) { + mem_base = xmlMemBlocks(); + handler = gen_xmlCharEncodingHandler_ptr(n_handler, 0); + + ret_val = xmlCharEncCloseFunc(handler); + desret_int(ret_val); + call_tests++; + des_xmlCharEncodingHandler_ptr(n_handler, handler, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharEncCloseFunc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_handler); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCharEncFirstLine(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlCharEncodingHandler * handler; /* char encoding transformation data structure */ + int n_handler; + xmlBufferPtr out; /* an xmlBuffer for the output. */ + int n_out; + xmlBufferPtr in; /* an xmlBuffer for the input */ + int n_in; + + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandler_ptr;n_handler++) { + for (n_out = 0;n_out < gen_nb_xmlBufferPtr;n_out++) { + for (n_in = 0;n_in < gen_nb_xmlBufferPtr;n_in++) { + mem_base = xmlMemBlocks(); + handler = gen_xmlCharEncodingHandler_ptr(n_handler, 0); + out = gen_xmlBufferPtr(n_out, 1); + in = gen_xmlBufferPtr(n_in, 2); + + ret_val = xmlCharEncFirstLine(handler, out, in); + desret_int(ret_val); + call_tests++; + des_xmlCharEncodingHandler_ptr(n_handler, handler, 0); + des_xmlBufferPtr(n_out, out, 1); + des_xmlBufferPtr(n_in, in, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharEncFirstLine", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_handler); + printf(" %d", n_out); + printf(" %d", n_in); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCharEncInFunc(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlCharEncodingHandler * handler; /* char encoding transformation data structure */ + int n_handler; + xmlBufferPtr out; /* an xmlBuffer for the output. */ + int n_out; + xmlBufferPtr in; /* an xmlBuffer for the input */ + int n_in; + + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandler_ptr;n_handler++) { + for (n_out = 0;n_out < gen_nb_xmlBufferPtr;n_out++) { + for (n_in = 0;n_in < gen_nb_xmlBufferPtr;n_in++) { + mem_base = xmlMemBlocks(); + handler = gen_xmlCharEncodingHandler_ptr(n_handler, 0); + out = gen_xmlBufferPtr(n_out, 1); + in = gen_xmlBufferPtr(n_in, 2); + + ret_val = xmlCharEncInFunc(handler, out, in); + desret_int(ret_val); + call_tests++; + des_xmlCharEncodingHandler_ptr(n_handler, handler, 0); + des_xmlBufferPtr(n_out, out, 1); + des_xmlBufferPtr(n_in, in, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharEncInFunc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_handler); + printf(" %d", n_out); + printf(" %d", n_in); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCharEncOutFunc(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlCharEncodingHandler * handler; /* char encoding transformation data structure */ + int n_handler; + xmlBufferPtr out; /* an xmlBuffer for the output. */ + int n_out; + xmlBufferPtr in; /* an xmlBuffer for the input */ + int n_in; + + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandler_ptr;n_handler++) { + for (n_out = 0;n_out < gen_nb_xmlBufferPtr;n_out++) { + for (n_in = 0;n_in < gen_nb_xmlBufferPtr;n_in++) { + mem_base = xmlMemBlocks(); + handler = gen_xmlCharEncodingHandler_ptr(n_handler, 0); + out = gen_xmlBufferPtr(n_out, 1); + in = gen_xmlBufferPtr(n_in, 2); + + ret_val = xmlCharEncOutFunc(handler, out, in); + desret_int(ret_val); + call_tests++; + des_xmlCharEncodingHandler_ptr(n_handler, handler, 0); + des_xmlBufferPtr(n_out, out, 1); + des_xmlBufferPtr(n_in, in, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharEncOutFunc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_handler); + printf(" %d", n_out); + printf(" %d", n_in); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCleanupCharEncodingHandlers(void) { + int test_ret = 0; + + + + xmlCleanupCharEncodingHandlers(); + call_tests++; + xmlResetLastError(); + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCleanupEncodingAliases(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlCleanupEncodingAliases(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCleanupEncodingAliases", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDelEncodingAlias(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ + int n_alias; + + for (n_alias = 0;n_alias < gen_nb_const_char_ptr;n_alias++) { + mem_base = xmlMemBlocks(); + alias = gen_const_char_ptr(n_alias, 0); + + ret_val = xmlDelEncodingAlias((const char *)alias); + desret_int(ret_val); + call_tests++; + des_const_char_ptr(n_alias, (const char *)alias, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDelEncodingAlias", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_alias); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDetectCharEncoding(void) { + int test_ret = 0; + + int mem_base; + xmlCharEncoding ret_val; + unsigned char * in; /* a pointer to the first bytes of the XML entity, must be at least 2 bytes long (at least 4 if encoding is UTF4 variant). */ + int n_in; + int len; /* pointer to the length of the buffer */ + int n_len; + + for (n_in = 0;n_in < gen_nb_const_unsigned_char_ptr;n_in++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + in = gen_const_unsigned_char_ptr(n_in, 0); + len = gen_int(n_len, 1); + + ret_val = xmlDetectCharEncoding((const unsigned char *)in, len); + desret_xmlCharEncoding(ret_val); + call_tests++; + des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDetectCharEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlFindCharEncodingHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlGetCharEncodingHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlGetCharEncodingName(void) { + int test_ret = 0; + + int mem_base; + const char * ret_val; + xmlCharEncoding enc; /* the encoding */ + int n_enc; + + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + enc = gen_xmlCharEncoding(n_enc, 0); + + ret_val = xmlGetCharEncodingName(enc); + desret_const_char_ptr(ret_val); + call_tests++; + des_xmlCharEncoding(n_enc, enc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetCharEncodingName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_enc); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetEncodingAlias(void) { + int test_ret = 0; + + int mem_base; + const char * ret_val; + char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ + int n_alias; + + for (n_alias = 0;n_alias < gen_nb_const_char_ptr;n_alias++) { + mem_base = xmlMemBlocks(); + alias = gen_const_char_ptr(n_alias, 0); + + ret_val = xmlGetEncodingAlias((const char *)alias); + desret_const_char_ptr(ret_val); + call_tests++; + des_const_char_ptr(n_alias, (const char *)alias, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetEncodingAlias", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_alias); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlInitCharEncodingHandlers(void) { + int test_ret = 0; + + + + xmlInitCharEncodingHandlers(); + call_tests++; + xmlResetLastError(); + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewCharEncodingHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParseCharEncoding(void) { + int test_ret = 0; + + int mem_base; + xmlCharEncoding ret_val; + char * name; /* the encoding name as parsed, in UTF-8 format (ASCII actually) */ + int n_name; + + for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { + mem_base = xmlMemBlocks(); + name = gen_const_char_ptr(n_name, 0); + + ret_val = xmlParseCharEncoding((const char *)name); + desret_xmlCharEncoding(ret_val); + call_tests++; + des_const_char_ptr(n_name, (const char *)name, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseCharEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlCharEncodingHandlerPtr 1 +static xmlCharEncodingHandlerPtr gen_xmlCharEncodingHandlerPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlCharEncodingHandlerPtr(int no ATTRIBUTE_UNUSED, xmlCharEncodingHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlRegisterCharEncodingHandler(void) { + int test_ret = 0; + + int mem_base; + xmlCharEncodingHandlerPtr handler; /* the xmlCharEncodingHandlerPtr handler block */ + int n_handler; + + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandlerPtr;n_handler++) { + mem_base = xmlMemBlocks(); + handler = gen_xmlCharEncodingHandlerPtr(n_handler, 0); + + xmlRegisterCharEncodingHandler(handler); + call_tests++; + des_xmlCharEncodingHandlerPtr(n_handler, handler, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegisterCharEncodingHandler", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_handler); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + +static int +test_encoding(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing encoding : 16 of 19 functions ...\n"); + test_ret += test_UTF8Toisolat1(); + test_ret += test_isolat1ToUTF8(); + test_ret += test_xmlAddEncodingAlias(); + test_ret += test_xmlCharEncCloseFunc(); + test_ret += test_xmlCharEncFirstLine(); + test_ret += test_xmlCharEncInFunc(); + test_ret += test_xmlCharEncOutFunc(); + test_ret += test_xmlCleanupCharEncodingHandlers(); + test_ret += test_xmlCleanupEncodingAliases(); + test_ret += test_xmlDelEncodingAlias(); + test_ret += test_xmlDetectCharEncoding(); + test_ret += test_xmlFindCharEncodingHandler(); + test_ret += test_xmlGetCharEncodingHandler(); + test_ret += test_xmlGetCharEncodingName(); + test_ret += test_xmlGetEncodingAlias(); + test_ret += test_xmlInitCharEncodingHandlers(); + test_ret += test_xmlNewCharEncodingHandler(); + test_ret += test_xmlParseCharEncoding(); + test_ret += test_xmlRegisterCharEncodingHandler(); + + if (test_ret != 0) + printf("Module encoding: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlAddDocEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + int type; /* the entity type XML_xxx_yyy_ENTITY */ + int n_type; + xmlChar * ExternalID; /* the entity external ID if available */ + int n_ExternalID; + xmlChar * SystemID; /* the entity system ID if available */ + int n_SystemID; + xmlChar * content; /* the entity content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_int(n_type, 2); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 3); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); + content = gen_const_xmlChar_ptr(n_content, 5); + + ret_val = xmlAddDocEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_type, type, 2); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddDocEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddDtdEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + int type; /* the entity type XML_xxx_yyy_ENTITY */ + int n_type; + xmlChar * ExternalID; /* the entity external ID if available */ + int n_ExternalID; + xmlChar * SystemID; /* the entity system ID if available */ + int n_SystemID; + xmlChar * content; /* the entity content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_int(n_type, 2); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 3); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); + content = gen_const_xmlChar_ptr(n_content, 5); + + ret_val = xmlAddDtdEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_type, type, 2); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddDtdEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCleanupPredefinedEntities(void) { + int test_ret = 0; + +#if defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_LEGACY_ENABLED + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlCleanupPredefinedEntities(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCleanupPredefinedEntities", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlCopyEntitiesTable(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCreateEntitiesTable(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +#define gen_nb_xmlEntitiesTablePtr 1 +static xmlEntitiesTablePtr gen_xmlEntitiesTablePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlEntitiesTablePtr(int no ATTRIBUTE_UNUSED, xmlEntitiesTablePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpEntitiesTable(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* An XML buffer. */ + int n_buf; + xmlEntitiesTablePtr table; /* An entity table */ + int n_table; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_table = 0;n_table < gen_nb_xmlEntitiesTablePtr;n_table++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + table = gen_xmlEntitiesTablePtr(n_table, 1); + + xmlDumpEntitiesTable(buf, table); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlEntitiesTablePtr(n_table, table, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpEntitiesTable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_table); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlEntityPtr 1 +static xmlEntityPtr gen_xmlEntityPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlEntityPtr(int no ATTRIBUTE_UNUSED, xmlEntityPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpEntityDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* An XML buffer. */ + int n_buf; + xmlEntityPtr ent; /* An entity table */ + int n_ent; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_ent = 0;n_ent < gen_nb_xmlEntityPtr;n_ent++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + ent = gen_xmlEntityPtr(n_ent, 1); + + xmlDumpEntityDecl(buf, ent); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlEntityPtr(n_ent, ent, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpEntityDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_ent); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlEncodeEntitiesReentrant(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlDocPtr doc; /* the document containing the string */ + int n_doc; + xmlChar * input; /* A string to convert to XML. */ + int n_input; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_input = 0;n_input < gen_nb_const_xmlChar_ptr;n_input++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + input = gen_const_xmlChar_ptr(n_input, 1); + + ret_val = xmlEncodeEntitiesReentrant(doc, (const xmlChar *)input); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_input, (const xmlChar *)input, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlEncodeEntitiesReentrant", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_input); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_const_xmlDoc_ptr 1 +static xmlDoc * gen_const_xmlDoc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlDoc_ptr(int no ATTRIBUTE_UNUSED, const xmlDoc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlEncodeSpecialChars(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlDoc * doc; /* the document containing the string */ + int n_doc; + xmlChar * input; /* A string to convert to XML. */ + int n_input; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_input = 0;n_input < gen_nb_const_xmlChar_ptr;n_input++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + input = gen_const_xmlChar_ptr(n_input, 1); + + ret_val = xmlEncodeSpecialChars((const xmlDoc *)doc, (const xmlChar *)input); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlChar_ptr(n_input, (const xmlChar *)input, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlEncodeSpecialChars", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_input); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetDocEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDoc * doc; /* the document referencing the entity */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlGetDocEntity((const xmlDoc *)doc, (const xmlChar *)name); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDocEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetDtdEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDocPtr doc; /* the document referencing the entity */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlGetDtdEntity(doc, (const xmlChar *)name); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDtdEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetParameterEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDocPtr doc; /* the document referencing the entity */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlGetParameterEntity(doc, (const xmlChar *)name); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetParameterEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetPredefinedEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlChar * name; /* the entity name */ + int n_name; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + + ret_val = xmlGetPredefinedEntity((const xmlChar *)name); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetPredefinedEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlInitializePredefinedEntities(void) { + int test_ret = 0; + +#if defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_LEGACY_ENABLED + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlInitializePredefinedEntities(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitializePredefinedEntities", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlNewEntity(void) { + int test_ret = 0; + + int mem_base; + xmlEntityPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the entity name */ + int n_name; + int type; /* the entity type XML_xxx_yyy_ENTITY */ + int n_type; + xmlChar * ExternalID; /* the entity external ID if available */ + int n_ExternalID; + xmlChar * SystemID; /* the entity system ID if available */ + int n_SystemID; + xmlChar * content; /* the entity content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_int(n_type, 2); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 3); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); + content = gen_const_xmlChar_ptr(n_content, 5); + + ret_val = xmlNewEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + desret_xmlEntityPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_int(n_type, type, 2); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + +static int +test_entities(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing entities : 13 of 17 functions ...\n"); + test_ret += test_xmlAddDocEntity(); + test_ret += test_xmlAddDtdEntity(); + test_ret += test_xmlCleanupPredefinedEntities(); + test_ret += test_xmlCopyEntitiesTable(); + test_ret += test_xmlCreateEntitiesTable(); + test_ret += test_xmlDumpEntitiesTable(); + test_ret += test_xmlDumpEntityDecl(); + test_ret += test_xmlEncodeEntitiesReentrant(); + test_ret += test_xmlEncodeSpecialChars(); + test_ret += test_xmlGetDocEntity(); + test_ret += test_xmlGetDtdEntity(); + test_ret += test_xmlGetParameterEntity(); + test_ret += test_xmlGetPredefinedEntity(); + test_ret += test_xmlInitializePredefinedEntities(); + test_ret += test_xmlNewEntity(); + + if (test_ret != 0) + printf("Module entities: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlHashAddEntry(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + void * userdata; /* a pointer to the userdata */ + int n_userdata; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + userdata = gen_userdata(n_userdata, 2); + + ret_val = xmlHashAddEntry(table, (const xmlChar *)name, userdata); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_userdata(n_userdata, userdata, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashAddEntry", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_userdata); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashAddEntry2(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + void * userdata; /* a pointer to the userdata */ + int n_userdata; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + userdata = gen_userdata(n_userdata, 3); + + ret_val = xmlHashAddEntry2(table, (const xmlChar *)name, (const xmlChar *)name2, userdata); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_userdata(n_userdata, userdata, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashAddEntry2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_userdata); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashAddEntry3(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + xmlChar * name3; /* a third name of the userdata */ + int n_name3; + void * userdata; /* a pointer to the userdata */ + int n_userdata; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) { + for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + name3 = gen_const_xmlChar_ptr(n_name3, 3); + userdata = gen_userdata(n_userdata, 4); + + ret_val = xmlHashAddEntry3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3, userdata); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3); + des_userdata(n_userdata, userdata, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashAddEntry3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_name3); + printf(" %d", n_userdata); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashCopy(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashCreate(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashCreateDict(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashDefaultDeallocator(void) { + int test_ret = 0; + + int mem_base; + void * entry; /* the hash table entry */ + int n_entry; + xmlChar * name; /* the entry's name */ + int n_name; + + for (n_entry = 0;n_entry < gen_nb_void_ptr;n_entry++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + entry = gen_void_ptr(n_entry, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + xmlHashDefaultDeallocator(entry, (const xmlChar *)name); + call_tests++; + des_void_ptr(n_entry, entry, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashDefaultDeallocator", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_entry); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashLookup(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlHashLookup(table, (const xmlChar *)name); + desret_void_ptr(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashLookup2(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + + ret_val = xmlHashLookup2(table, (const xmlChar *)name, (const xmlChar *)name2); + desret_void_ptr(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashLookup2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashLookup3(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + xmlChar * name3; /* a third name of the userdata */ + int n_name3; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + name3 = gen_const_xmlChar_ptr(n_name3, 3); + + ret_val = xmlHashLookup3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3); + desret_void_ptr(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashLookup3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_name3); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashQLookup(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * prefix; /* the prefix of the userdata */ + int n_prefix; + xmlChar * name; /* the name of the userdata */ + int n_name; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + + ret_val = xmlHashQLookup(table, (const xmlChar *)prefix, (const xmlChar *)name); + desret_void_ptr(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashQLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashQLookup2(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * prefix; /* the prefix of the userdata */ + int n_prefix; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * prefix2; /* the second prefix of the userdata */ + int n_prefix2; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_prefix2 = 0;n_prefix2 < gen_nb_const_xmlChar_ptr;n_prefix2++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + prefix2 = gen_const_xmlChar_ptr(n_prefix2, 3); + name2 = gen_const_xmlChar_ptr(n_name2, 4); + + ret_val = xmlHashQLookup2(table, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2); + desret_void_ptr(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_prefix2, (const xmlChar *)prefix2, 3); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashQLookup2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf(" %d", n_prefix2); + printf(" %d", n_name2); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashQLookup3(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * prefix; /* the prefix of the userdata */ + int n_prefix; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * prefix2; /* the second prefix of the userdata */ + int n_prefix2; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + xmlChar * prefix3; /* the third prefix of the userdata */ + int n_prefix3; + xmlChar * name3; /* a third name of the userdata */ + int n_name3; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_prefix2 = 0;n_prefix2 < gen_nb_const_xmlChar_ptr;n_prefix2++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_prefix3 = 0;n_prefix3 < gen_nb_const_xmlChar_ptr;n_prefix3++) { + for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + prefix2 = gen_const_xmlChar_ptr(n_prefix2, 3); + name2 = gen_const_xmlChar_ptr(n_name2, 4); + prefix3 = gen_const_xmlChar_ptr(n_prefix3, 5); + name3 = gen_const_xmlChar_ptr(n_name3, 6); + + ret_val = xmlHashQLookup3(table, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2, (const xmlChar *)prefix3, (const xmlChar *)name3); + desret_void_ptr(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_prefix2, (const xmlChar *)prefix2, 3); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 4); + des_const_xmlChar_ptr(n_prefix3, (const xmlChar *)prefix3, 5); + des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashQLookup3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf(" %d", n_prefix2); + printf(" %d", n_name2); + printf(" %d", n_prefix3); + printf(" %d", n_name3); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashRemoveEntry(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlHashDeallocator f; /* the deallocator function for removed item (if any) */ + int n_f; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + f = gen_xmlHashDeallocator(n_f, 2); + + ret_val = xmlHashRemoveEntry(table, (const xmlChar *)name, f); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_xmlHashDeallocator(n_f, f, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashRemoveEntry", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_f); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashRemoveEntry2(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + xmlHashDeallocator f; /* the deallocator function for removed item (if any) */ + int n_f; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + f = gen_xmlHashDeallocator(n_f, 3); + + ret_val = xmlHashRemoveEntry2(table, (const xmlChar *)name, (const xmlChar *)name2, f); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_xmlHashDeallocator(n_f, f, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashRemoveEntry2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_f); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashRemoveEntry3(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + xmlChar * name3; /* a third name of the userdata */ + int n_name3; + xmlHashDeallocator f; /* the deallocator function for removed item (if any) */ + int n_f; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) { + for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + name3 = gen_const_xmlChar_ptr(n_name3, 3); + f = gen_xmlHashDeallocator(n_f, 4); + + ret_val = xmlHashRemoveEntry3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3, f); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3); + des_xmlHashDeallocator(n_f, f, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashRemoveEntry3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_name3); + printf(" %d", n_f); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashScan(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashScan3(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashScanFull(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashScanFull3(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlHashSize(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + + ret_val = xmlHashSize(table); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashSize", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashUpdateEntry(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + void * userdata; /* a pointer to the userdata */ + int n_userdata; + xmlHashDeallocator f; /* the deallocator function for replaced item (if any) */ + int n_f; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) { + for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + userdata = gen_userdata(n_userdata, 2); + f = gen_xmlHashDeallocator(n_f, 3); + + ret_val = xmlHashUpdateEntry(table, (const xmlChar *)name, userdata, f); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_userdata(n_userdata, userdata, 2); + des_xmlHashDeallocator(n_f, f, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashUpdateEntry", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_userdata); + printf(" %d", n_f); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashUpdateEntry2(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + void * userdata; /* a pointer to the userdata */ + int n_userdata; + xmlHashDeallocator f; /* the deallocator function for replaced item (if any) */ + int n_f; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) { + for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + userdata = gen_userdata(n_userdata, 3); + f = gen_xmlHashDeallocator(n_f, 4); + + ret_val = xmlHashUpdateEntry2(table, (const xmlChar *)name, (const xmlChar *)name2, userdata, f); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_userdata(n_userdata, userdata, 3); + des_xmlHashDeallocator(n_f, f, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashUpdateEntry2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_userdata); + printf(" %d", n_f); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashUpdateEntry3(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr table; /* the hash table */ + int n_table; + xmlChar * name; /* the name of the userdata */ + int n_name; + xmlChar * name2; /* a second name of the userdata */ + int n_name2; + xmlChar * name3; /* a third name of the userdata */ + int n_name3; + void * userdata; /* a pointer to the userdata */ + int n_userdata; + xmlHashDeallocator f; /* the deallocator function for replaced item (if any) */ + int n_f; + + for (n_table = 0;n_table < gen_nb_xmlHashTablePtr;n_table++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_name2 = 0;n_name2 < gen_nb_const_xmlChar_ptr;n_name2++) { + for (n_name3 = 0;n_name3 < gen_nb_const_xmlChar_ptr;n_name3++) { + for (n_userdata = 0;n_userdata < gen_nb_userdata;n_userdata++) { + for (n_f = 0;n_f < gen_nb_xmlHashDeallocator;n_f++) { + mem_base = xmlMemBlocks(); + table = gen_xmlHashTablePtr(n_table, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + name2 = gen_const_xmlChar_ptr(n_name2, 2); + name3 = gen_const_xmlChar_ptr(n_name3, 3); + userdata = gen_userdata(n_userdata, 4); + f = gen_xmlHashDeallocator(n_f, 5); + + ret_val = xmlHashUpdateEntry3(table, (const xmlChar *)name, (const xmlChar *)name2, (const xmlChar *)name3, userdata, f); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_table, table, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 2); + des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 3); + des_userdata(n_userdata, userdata, 4); + des_xmlHashDeallocator(n_f, f, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashUpdateEntry3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_table); + printf(" %d", n_name); + printf(" %d", n_name2); + printf(" %d", n_name3); + printf(" %d", n_userdata); + printf(" %d", n_f); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + +static int +test_hash(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing hash : 17 of 25 functions ...\n"); + test_ret += test_xmlHashAddEntry(); + test_ret += test_xmlHashAddEntry2(); + test_ret += test_xmlHashAddEntry3(); + test_ret += test_xmlHashCopy(); + test_ret += test_xmlHashCreate(); + test_ret += test_xmlHashCreateDict(); + test_ret += test_xmlHashDefaultDeallocator(); + test_ret += test_xmlHashLookup(); + test_ret += test_xmlHashLookup2(); + test_ret += test_xmlHashLookup3(); + test_ret += test_xmlHashQLookup(); + test_ret += test_xmlHashQLookup2(); + test_ret += test_xmlHashQLookup3(); + test_ret += test_xmlHashRemoveEntry(); + test_ret += test_xmlHashRemoveEntry2(); + test_ret += test_xmlHashRemoveEntry3(); + test_ret += test_xmlHashScan(); + test_ret += test_xmlHashScan3(); + test_ret += test_xmlHashScanFull(); + test_ret += test_xmlHashScanFull3(); + test_ret += test_xmlHashSize(); + test_ret += test_xmlHashUpdateEntry(); + test_ret += test_xmlHashUpdateEntry2(); + test_ret += test_xmlHashUpdateEntry3(); + + if (test_ret != 0) + printf("Module hash: %d errors\n", test_ret); + return(test_ret); +} + +#define gen_nb_xmlLinkPtr 1 +static xmlLinkPtr gen_xmlLinkPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlLinkPtr(int no ATTRIBUTE_UNUSED, xmlLinkPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlLinkGetData(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlLinkPtr lk; /* a link */ + int n_lk; + + for (n_lk = 0;n_lk < gen_nb_xmlLinkPtr;n_lk++) { + mem_base = xmlMemBlocks(); + lk = gen_xmlLinkPtr(n_lk, 0); + + ret_val = xmlLinkGetData(lk); + desret_void_ptr(ret_val); + call_tests++; + des_xmlLinkPtr(n_lk, lk, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLinkGetData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_lk); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListAppend(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* the data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListAppend(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListAppend", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListClear(void) { + int test_ret = 0; + + int mem_base; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + xmlListClear(l); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListClear", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_const_xmlListPtr 1 +static xmlListPtr gen_const_xmlListPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlListPtr(int no ATTRIBUTE_UNUSED, const xmlListPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlListCopy(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr cur; /* the new list */ + int n_cur; + xmlListPtr old; /* the old list */ + int n_old; + + for (n_cur = 0;n_cur < gen_nb_xmlListPtr;n_cur++) { + for (n_old = 0;n_old < gen_nb_const_xmlListPtr;n_old++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlListPtr(n_cur, 0); + old = gen_const_xmlListPtr(n_old, 1); + + ret_val = xmlListCopy(cur, (const xmlListPtr)old); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_cur, cur, 0); + des_const_xmlListPtr(n_old, (const xmlListPtr)old, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListCopy", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_old); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListCreate(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlListDup(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlListEmpty(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + ret_val = xmlListEmpty(l); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListEmpty", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListEnd(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlListFront(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlListInsert(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* the data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListInsert(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListInsert", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListMerge(void) { + int test_ret = 0; + + int mem_base; + xmlListPtr l1; /* the original list */ + int n_l1; + xmlListPtr l2; /* the new list */ + int n_l2; + + for (n_l1 = 0;n_l1 < gen_nb_xmlListPtr;n_l1++) { + for (n_l2 = 0;n_l2 < gen_nb_xmlListPtr;n_l2++) { + mem_base = xmlMemBlocks(); + l1 = gen_xmlListPtr(n_l1, 0); + l2 = gen_xmlListPtr(n_l2, 1); + + xmlListMerge(l1, l2); + call_tests++; + des_xmlListPtr(n_l1, l1, 0); + des_xmlListPtr(n_l2, l2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListMerge", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l1); + printf(" %d", n_l2); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListPopBack(void) { + int test_ret = 0; + + int mem_base; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + xmlListPopBack(l); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListPopBack", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListPopFront(void) { + int test_ret = 0; + + int mem_base; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + xmlListPopFront(l); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListPopFront", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListPushBack(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* new data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListPushBack(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListPushBack", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListPushFront(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* new data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListPushFront(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListPushFront", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListRemoveAll(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* list data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListRemoveAll(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListRemoveAll", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListRemoveFirst(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* list data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListRemoveFirst(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListRemoveFirst", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListRemoveLast(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* list data */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListRemoveLast(l, data); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListRemoveLast", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListReverse(void) { + int test_ret = 0; + + int mem_base; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + xmlListReverse(l); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListReverse", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListReverseSearch(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* a search value */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListReverseSearch(l, data); + desret_void_ptr(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListReverseSearch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListReverseWalk(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlListSearch(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlListPtr l; /* a list */ + int n_l; + void * data; /* a search value */ + int n_data; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + data = gen_userdata(n_data, 1); + + ret_val = xmlListSearch(l, data); + desret_void_ptr(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + des_userdata(n_data, data, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListSearch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf(" %d", n_data); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListSize(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + ret_val = xmlListSize(l); + desret_int(ret_val); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListSize", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListSort(void) { + int test_ret = 0; + + int mem_base; + xmlListPtr l; /* a list */ + int n_l; + + for (n_l = 0;n_l < gen_nb_xmlListPtr;n_l++) { + mem_base = xmlMemBlocks(); + l = gen_xmlListPtr(n_l, 0); + + xmlListSort(l); + call_tests++; + des_xmlListPtr(n_l, l, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlListSort", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_l); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlListWalk(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_list(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing list : 19 of 26 functions ...\n"); + test_ret += test_xmlLinkGetData(); + test_ret += test_xmlListAppend(); + test_ret += test_xmlListClear(); + test_ret += test_xmlListCopy(); + test_ret += test_xmlListCreate(); + test_ret += test_xmlListDup(); + test_ret += test_xmlListEmpty(); + test_ret += test_xmlListEnd(); + test_ret += test_xmlListFront(); + test_ret += test_xmlListInsert(); + test_ret += test_xmlListMerge(); + test_ret += test_xmlListPopBack(); + test_ret += test_xmlListPopFront(); + test_ret += test_xmlListPushBack(); + test_ret += test_xmlListPushFront(); + test_ret += test_xmlListRemoveAll(); + test_ret += test_xmlListRemoveFirst(); + test_ret += test_xmlListRemoveLast(); + test_ret += test_xmlListReverse(); + test_ret += test_xmlListReverseSearch(); + test_ret += test_xmlListReverseWalk(); + test_ret += test_xmlListSearch(); + test_ret += test_xmlListSize(); + test_ret += test_xmlListSort(); + test_ret += test_xmlListWalk(); + + if (test_ret != 0) + printf("Module list: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlNanoFTPCheckResponse(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoFTPCheckResponse(ctx); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPCheckResponse", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPCleanup(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlNanoFTPCleanup(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPCleanup", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPCloseConnection(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoFTPCloseConnection(ctx); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPCloseConnection", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPCwd(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + char * directory; /* a directory on the server */ + int n_directory; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + for (n_directory = 0;n_directory < gen_nb_const_char_ptr;n_directory++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + directory = gen_const_char_ptr(n_directory, 1); + + ret_val = xmlNanoFTPCwd(ctx, (const char *)directory); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + des_const_char_ptr(n_directory, (const char *)directory, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPCwd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_directory); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPDele(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + const char * file; /* a file or directory on the server */ + int n_file; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + for (n_file = 0;n_file < gen_nb_filepath;n_file++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + file = gen_filepath(n_file, 1); + + ret_val = xmlNanoFTPDele(ctx, file); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + des_filepath(n_file, file, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPDele", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_file); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPGet(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNanoFTPGetConnection(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNanoFTPGetResponse(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoFTPGetResponse(ctx); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPGetResponse", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPGetSocket(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNanoFTPInit(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlNanoFTPInit(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPInit", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPList(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNanoFTPNewCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + void * ret_val; + const char * URL; /* The URL used to initialize the context */ + int n_URL; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + mem_base = xmlMemBlocks(); + URL = gen_filepath(n_URL, 0); + + ret_val = xmlNanoFTPNewCtxt(URL); + desret_xmlNanoFTPCtxtPtr(ret_val); + call_tests++; + des_filepath(n_URL, URL, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPNewCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPOpen(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + void * ret_val; + const char * URL; /* the URL to the resource */ + int n_URL; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + mem_base = xmlMemBlocks(); + URL = gen_filepath(n_URL, 0); + + ret_val = xmlNanoFTPOpen(URL); + desret_xmlNanoFTPCtxtPtr(ret_val); + call_tests++; + des_filepath(n_URL, URL, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPOpen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPProxy(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + char * host; /* the proxy host name */ + int n_host; + int port; /* the proxy port */ + int n_port; + char * user; /* the proxy user name */ + int n_user; + char * passwd; /* the proxy password */ + int n_passwd; + int type; /* the type of proxy 1 for using SITE, 2 for USER a@b */ + int n_type; + + for (n_host = 0;n_host < gen_nb_const_char_ptr;n_host++) { + for (n_port = 0;n_port < gen_nb_int;n_port++) { + for (n_user = 0;n_user < gen_nb_const_char_ptr;n_user++) { + for (n_passwd = 0;n_passwd < gen_nb_const_char_ptr;n_passwd++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + host = gen_const_char_ptr(n_host, 0); + port = gen_int(n_port, 1); + user = gen_const_char_ptr(n_user, 2); + passwd = gen_const_char_ptr(n_passwd, 3); + type = gen_int(n_type, 4); + + xmlNanoFTPProxy((const char *)host, port, (const char *)user, (const char *)passwd, type); + call_tests++; + des_const_char_ptr(n_host, (const char *)host, 0); + des_int(n_port, port, 1); + des_const_char_ptr(n_user, (const char *)user, 2); + des_const_char_ptr(n_passwd, (const char *)passwd, 3); + des_int(n_type, type, 4); + xmlResetLastError(); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPQuit(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoFTPQuit(ctx); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPQuit", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPRead(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* the FTP context */ + int n_ctx; + void * dest; /* a buffer */ + int n_dest; + int len; /* the buffer length */ + int n_len; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + for (n_dest = 0;n_dest < gen_nb_void_ptr;n_dest++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + dest = gen_void_ptr(n_dest, 1); + len = gen_int(n_len, 2); + + ret_val = xmlNanoFTPRead(ctx, dest, len); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + des_void_ptr(n_dest, dest, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_dest); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPScanProxy(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + const char * URL; /* The proxy URL used to initialize the proxy context */ + int n_URL; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + URL = gen_filepath(n_URL, 0); + + xmlNanoFTPScanProxy(URL); + call_tests++; + des_filepath(n_URL, URL, 0); + xmlResetLastError(); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoFTPUpdateURL(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* an FTP context */ + int n_ctx; + const char * URL; /* The URL used to update the context */ + int n_URL; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoFTPCtxtPtr;n_ctx++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoFTPCtxtPtr(n_ctx, 0); + URL = gen_filepath(n_URL, 1); + + ret_val = xmlNanoFTPUpdateURL(ctx, URL); + desret_int(ret_val); + call_tests++; + des_xmlNanoFTPCtxtPtr(n_ctx, ctx, 0); + des_filepath(n_URL, URL, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoFTPUpdateURL", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_URL); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_nanoftp(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing nanoftp : 14 of 22 functions ...\n"); + test_ret += test_xmlNanoFTPCheckResponse(); + test_ret += test_xmlNanoFTPCleanup(); + test_ret += test_xmlNanoFTPCloseConnection(); + test_ret += test_xmlNanoFTPCwd(); + test_ret += test_xmlNanoFTPDele(); + test_ret += test_xmlNanoFTPGet(); + test_ret += test_xmlNanoFTPGetConnection(); + test_ret += test_xmlNanoFTPGetResponse(); + test_ret += test_xmlNanoFTPGetSocket(); + test_ret += test_xmlNanoFTPInit(); + test_ret += test_xmlNanoFTPList(); + test_ret += test_xmlNanoFTPNewCtxt(); + test_ret += test_xmlNanoFTPOpen(); + test_ret += test_xmlNanoFTPProxy(); + test_ret += test_xmlNanoFTPQuit(); + test_ret += test_xmlNanoFTPRead(); + test_ret += test_xmlNanoFTPScanProxy(); + test_ret += test_xmlNanoFTPUpdateURL(); + + if (test_ret != 0) + printf("Module nanoftp: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlNanoHTTPAuthHeader(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + const char * ret_val; + void * ctx; /* the HTTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoHTTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoHTTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoHTTPAuthHeader(ctx); + desret_const_char_ptr(ret_val); + call_tests++; + des_xmlNanoHTTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPAuthHeader", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPCleanup(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlNanoHTTPCleanup(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPCleanup", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPContentLength(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* the HTTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoHTTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoHTTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoHTTPContentLength(ctx); + desret_int(ret_val); + call_tests++; + des_xmlNanoHTTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPContentLength", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPEncoding(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + const char * ret_val; + void * ctx; /* the HTTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoHTTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoHTTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoHTTPEncoding(ctx); + desret_const_char_ptr(ret_val); + call_tests++; + des_xmlNanoHTTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_char_ptr_ptr 1 +static char ** gen_char_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_char_ptr_ptr(int no ATTRIBUTE_UNUSED, char ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlNanoHTTPFetch(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + const char * URL; /* The URL to load */ + int n_URL; + const char * filename; /* the filename where the content should be saved */ + int n_filename; + char ** contentType; /* if available the Content-Type information will be returned at that location */ + int n_contentType; + + for (n_URL = 0;n_URL < gen_nb_fileoutput;n_URL++) { + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_contentType = 0;n_contentType < gen_nb_char_ptr_ptr;n_contentType++) { + mem_base = xmlMemBlocks(); + URL = gen_fileoutput(n_URL, 0); + filename = gen_fileoutput(n_filename, 1); + contentType = gen_char_ptr_ptr(n_contentType, 2); + + ret_val = xmlNanoHTTPFetch(URL, filename, contentType); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_URL, URL, 0); + des_fileoutput(n_filename, filename, 1); + des_char_ptr_ptr(n_contentType, contentType, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPFetch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf(" %d", n_filename); + printf(" %d", n_contentType); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPInit(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlNanoHTTPInit(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPInit", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPMimeType(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + const char * ret_val; + void * ctx; /* the HTTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoHTTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoHTTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoHTTPMimeType(ctx); + desret_const_char_ptr(ret_val); + call_tests++; + des_xmlNanoHTTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPMimeType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPOpen(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + void * ret_val; + const char * URL; /* The URL to load */ + int n_URL; + char ** contentType; /* if available the Content-Type information will be returned at that location */ + int n_contentType; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_contentType = 0;n_contentType < gen_nb_char_ptr_ptr;n_contentType++) { + mem_base = xmlMemBlocks(); + URL = gen_filepath(n_URL, 0); + contentType = gen_char_ptr_ptr(n_contentType, 1); + + ret_val = xmlNanoHTTPOpen(URL, contentType); + desret_xmlNanoHTTPCtxtPtr(ret_val); + call_tests++; + des_filepath(n_URL, URL, 0); + des_char_ptr_ptr(n_contentType, contentType, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPOpen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf(" %d", n_contentType); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPOpenRedir(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + void * ret_val; + const char * URL; /* The URL to load */ + int n_URL; + char ** contentType; /* if available the Content-Type information will be returned at that location */ + int n_contentType; + char ** redir; /* if available the redirected URL will be returned */ + int n_redir; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_contentType = 0;n_contentType < gen_nb_char_ptr_ptr;n_contentType++) { + for (n_redir = 0;n_redir < gen_nb_char_ptr_ptr;n_redir++) { + mem_base = xmlMemBlocks(); + URL = gen_filepath(n_URL, 0); + contentType = gen_char_ptr_ptr(n_contentType, 1); + redir = gen_char_ptr_ptr(n_redir, 2); + + ret_val = xmlNanoHTTPOpenRedir(URL, contentType, redir); + desret_xmlNanoHTTPCtxtPtr(ret_val); + call_tests++; + des_filepath(n_URL, URL, 0); + des_char_ptr_ptr(n_contentType, contentType, 1); + des_char_ptr_ptr(n_redir, redir, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPOpenRedir", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf(" %d", n_contentType); + printf(" %d", n_redir); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPRead(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* the HTTP context */ + int n_ctx; + void * dest; /* a buffer */ + int n_dest; + int len; /* the buffer length */ + int n_len; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoHTTPCtxtPtr;n_ctx++) { + for (n_dest = 0;n_dest < gen_nb_void_ptr;n_dest++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoHTTPCtxtPtr(n_ctx, 0); + dest = gen_void_ptr(n_dest, 1); + len = gen_int(n_len, 2); + + ret_val = xmlNanoHTTPRead(ctx, dest, len); + desret_int(ret_val); + call_tests++; + des_xmlNanoHTTPCtxtPtr(n_ctx, ctx, 0); + des_void_ptr(n_dest, dest, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_dest); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPRedir(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNanoHTTPReturnCode(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + void * ctx; /* the HTTP context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_xmlNanoHTTPCtxtPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlNanoHTTPCtxtPtr(n_ctx, 0); + + ret_val = xmlNanoHTTPReturnCode(ctx); + desret_int(ret_val); + call_tests++; + des_xmlNanoHTTPCtxtPtr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPReturnCode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPSave(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + void * ctxt; /* the HTTP context */ + int n_ctxt; + const char * filename; /* the filename where the content should be saved */ + int n_filename; + + for (n_ctxt = 0;n_ctxt < gen_nb_void_ptr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + mem_base = xmlMemBlocks(); + ctxt = gen_void_ptr(n_ctxt, 0); + filename = gen_fileoutput(n_filename, 1); + + ret_val = xmlNanoHTTPSave(ctxt, filename); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_ctxt, ctxt, 0); + des_fileoutput(n_filename, filename, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNanoHTTPSave", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNanoHTTPScanProxy(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + const char * URL; /* The proxy URL used to initialize the proxy context */ + int n_URL; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + URL = gen_filepath(n_URL, 0); + + xmlNanoHTTPScanProxy(URL); + call_tests++; + des_filepath(n_URL, URL, 0); + xmlResetLastError(); + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_nanohttp(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing nanohttp : 13 of 17 functions ...\n"); + test_ret += test_xmlNanoHTTPAuthHeader(); + test_ret += test_xmlNanoHTTPCleanup(); + test_ret += test_xmlNanoHTTPContentLength(); + test_ret += test_xmlNanoHTTPEncoding(); + test_ret += test_xmlNanoHTTPFetch(); + test_ret += test_xmlNanoHTTPInit(); + test_ret += test_xmlNanoHTTPMimeType(); + test_ret += test_xmlNanoHTTPOpen(); + test_ret += test_xmlNanoHTTPOpenRedir(); + test_ret += test_xmlNanoHTTPRead(); + test_ret += test_xmlNanoHTTPRedir(); + test_ret += test_xmlNanoHTTPReturnCode(); + test_ret += test_xmlNanoHTTPSave(); + test_ret += test_xmlNanoHTTPScanProxy(); + + if (test_ret != 0) + printf("Module nanohttp: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlByteConsumed(void) { + int test_ret = 0; + + int mem_base; + long ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlByteConsumed(ctxt); + desret_long(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlByteConsumed", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlClearNodeInfoSeq(void) { + int test_ret = 0; + + int mem_base; + xmlParserNodeInfoSeqPtr seq; /* a node info sequence pointer */ + int n_seq; + + for (n_seq = 0;n_seq < gen_nb_xmlParserNodeInfoSeqPtr;n_seq++) { + mem_base = xmlMemBlocks(); + seq = gen_xmlParserNodeInfoSeqPtr(n_seq, 0); + + xmlClearNodeInfoSeq(seq); + call_tests++; + des_xmlParserNodeInfoSeqPtr(n_seq, seq, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlClearNodeInfoSeq", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_seq); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlClearParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + xmlClearParserCtxt(ctxt); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlClearParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateDocParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ret_val; + xmlChar * cur; /* a pointer to an array of xmlChar */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + + ret_val = xmlCreateDocParserCtxt((const xmlChar *)cur); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreateDocParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreatePushParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_PUSH_ENABLED) + int mem_base; + xmlParserCtxtPtr ret_val; + xmlSAXHandlerPtr sax; /* a SAX handler */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks */ + int n_user_data; + char * chunk; /* a pointer to an array of chars */ + int n_chunk; + int size; /* number of chars in the array */ + int n_size; + const char * filename; /* an optional file name or URI */ + int n_filename; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + user_data = gen_userdata(n_user_data, 1); + chunk = gen_const_char_ptr(n_chunk, 2); + size = gen_int(n_size, 3); + filename = gen_fileoutput(n_filename, 4); + if ((chunk != NULL) && + (size > (int) strlen((const char *) chunk) + 1)) + continue; + + ret_val = xmlCreatePushParserCtxt(sax, user_data, (const char *)chunk, size, filename); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_userdata(n_user_data, user_data, 1); + des_const_char_ptr(n_chunk, (const char *)chunk, 2); + des_int(n_size, size, 3); + des_fileoutput(n_filename, filename, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreatePushParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_chunk); + printf(" %d", n_size); + printf(" %d", n_filename); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCtxtReadDoc(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlChar * cur; /* a pointer to a zero terminated string */ + int n_cur; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + cur = gen_const_xmlChar_ptr(n_cur, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_parseroptions(n_options, 4); + + ret_val = xmlCtxtReadDoc(ctxt, (const xmlChar *)cur, URL, (const char *)encoding, options); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_parseroptions(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtReadDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtReadFile(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + const char * filename; /* a file or URL */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + filename = gen_filepath(n_filename, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + options = gen_parseroptions(n_options, 3); + + ret_val = xmlCtxtReadFile(ctxt, filename, (const char *)encoding, options); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_filepath(n_filename, filename, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_parseroptions(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtReadFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtReadMemory(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + buffer = gen_const_char_ptr(n_buffer, 1); + size = gen_int(n_size, 2); + URL = gen_filepath(n_URL, 3); + encoding = gen_const_char_ptr(n_encoding, 4); + options = gen_parseroptions(n_options, 5); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlCtxtReadMemory(ctxt, (const char *)buffer, size, URL, (const char *)encoding, options); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_int(n_size, size, 2); + des_filepath(n_URL, URL, 3); + des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_parseroptions(n_options, options, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtReadMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtReset(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + xmlCtxtReset(ctxt); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtReset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtResetPush(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + char * chunk; /* a pointer to an array of chars */ + int n_chunk; + int size; /* number of chars in the array */ + int n_size; + const char * filename; /* an optional file name or URI */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + chunk = gen_const_char_ptr(n_chunk, 1); + size = gen_int(n_size, 2); + filename = gen_filepath(n_filename, 3); + encoding = gen_const_char_ptr(n_encoding, 4); + if ((chunk != NULL) && + (size > (int) strlen((const char *) chunk) + 1)) + continue; + + ret_val = xmlCtxtResetPush(ctxt, (const char *)chunk, size, filename, (const char *)encoding); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_chunk, (const char *)chunk, 1); + des_int(n_size, size, 2); + des_filepath(n_filename, filename, 3); + des_const_char_ptr(n_encoding, (const char *)encoding, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtResetPush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_chunk); + printf(" %d", n_size); + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtUseOptions(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + options = gen_parseroptions(n_options, 1); + + ret_val = xmlCtxtUseOptions(ctxt, options); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_parseroptions(n_options, options, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtUseOptions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_options); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetExternalEntityLoader(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlGetFeature(void) { + int test_ret = 0; + +#if defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_LEGACY_ENABLED + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML/HTML parser context */ + int n_ctxt; + char * name; /* the feature name */ + int n_name; + void * result; /* location to store the result */ + int n_result; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { + for (n_result = 0;n_result < gen_nb_void_ptr;n_result++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + name = gen_const_char_ptr(n_name, 1); + result = gen_void_ptr(n_result, 2); + + ret_val = xmlGetFeature(ctxt, (const char *)name, result); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_name, (const char *)name, 1); + des_void_ptr(n_result, result, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetFeature", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf(" %d", n_result); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +#define gen_nb_const_char_ptr_ptr 1 +static char ** gen_const_char_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_char_ptr_ptr(int no ATTRIBUTE_UNUSED, const char ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlGetFeaturesList(void) { + int test_ret = 0; + +#if defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_LEGACY_ENABLED + int mem_base; + int ret_val; + int * len; /* the length of the features name array (input/output) */ + int n_len; + char ** result; /* an array of string to be filled with the features name. */ + int n_result; + + for (n_len = 0;n_len < gen_nb_int_ptr;n_len++) { + for (n_result = 0;n_result < gen_nb_const_char_ptr_ptr;n_result++) { + mem_base = xmlMemBlocks(); + len = gen_int_ptr(n_len, 0); + result = gen_const_char_ptr_ptr(n_result, 1); + + ret_val = xmlGetFeaturesList(len, (const char **)result); + desret_int(ret_val); + call_tests++; + des_int_ptr(n_len, len, 0); + des_const_char_ptr_ptr(n_result, (const char **)result, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetFeaturesList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_len); + printf(" %d", n_result); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlHasFeature(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlFeature feature; /* the feature to be examined */ + int n_feature; + + for (n_feature = 0;n_feature < gen_nb_xmlFeature;n_feature++) { + mem_base = xmlMemBlocks(); + feature = gen_xmlFeature(n_feature, 0); + + ret_val = xmlHasFeature(feature); + desret_int(ret_val); + call_tests++; + des_xmlFeature(n_feature, feature, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHasFeature", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_feature); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIOParseDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) +#ifdef LIBXML_VALID_ENABLED + xmlDtdPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block or NULL */ + int n_sax; + xmlParserInputBufferPtr input; /* an Input Buffer */ + int n_input; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + input = gen_xmlParserInputBufferPtr(n_input, 1); + enc = gen_xmlCharEncoding(n_enc, 2); + + ret_val = xmlIOParseDTD(sax, input, enc); + input = NULL; + desret_xmlDtdPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_xmlParserInputBufferPtr(n_input, input, 1); + des_xmlCharEncoding(n_enc, enc, 2); + xmlResetLastError(); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlInitNodeInfoSeq(void) { + int test_ret = 0; + + int mem_base; + xmlParserNodeInfoSeqPtr seq; /* a node info sequence pointer */ + int n_seq; + + for (n_seq = 0;n_seq < gen_nb_xmlParserNodeInfoSeqPtr;n_seq++) { + mem_base = xmlMemBlocks(); + seq = gen_xmlParserNodeInfoSeqPtr(n_seq, 0); + + xmlInitNodeInfoSeq(seq); + call_tests++; + des_xmlParserNodeInfoSeqPtr(n_seq, seq, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitNodeInfoSeq", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_seq); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlInitParser(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlInitParser(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitParser", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlInitParserCtxt(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlInitParserCtxt(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlKeepBlanksDefault(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + int val; /* int 0 or 1 */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlKeepBlanksDefault(val); + desret_int(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlKeepBlanksDefault", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlLineNumbersDefault(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + int val; /* int 0 or 1 */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlLineNumbersDefault(val); + desret_int(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLineNumbersDefault", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlLoadExternalEntity(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + const char * URL; /* the URL for the entity to load */ + int n_URL; + char * ID; /* the Public ID for the entity to load */ + int n_ID; + xmlParserCtxtPtr ctxt; /* the context in which the entity is called or NULL */ + int n_ctxt; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_ID = 0;n_ID < gen_nb_const_char_ptr;n_ID++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + URL = gen_filepath(n_URL, 0); + ID = gen_const_char_ptr(n_ID, 1); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 2); + + ret_val = xmlLoadExternalEntity(URL, (const char *)ID, ctxt); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_filepath(n_URL, URL, 0); + des_const_char_ptr(n_ID, (const char *)ID, 1); + des_xmlParserCtxtPtr(n_ctxt, ctxt, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLoadExternalEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf(" %d", n_ID); + printf(" %d", n_ctxt); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewIOInputStream(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlParserInputBufferPtr input; /* an I/O Input */ + int n_input; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + input = gen_xmlParserInputBufferPtr(n_input, 1); + enc = gen_xmlCharEncoding(n_enc, 2); + + ret_val = xmlNewIOInputStream(ctxt, input, enc); + if (ret_val != NULL) input = NULL; + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputBufferPtr(n_input, input, 1); + des_xmlCharEncoding(n_enc, enc, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewIOInputStream", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_input); + printf(" %d", n_enc); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlNewParserCtxt(); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlNodePtr_ptr 1 +static xmlNodePtr * gen_xmlNodePtr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlNodePtr_ptr(int no ATTRIBUTE_UNUSED, xmlNodePtr * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlParseBalancedChunkMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document the chunk pertains to (must not be NULL) */ + int n_doc; + xmlSAXHandlerPtr sax; /* the SAX handler block (possibly NULL) */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks (possibly NULL) */ + int n_user_data; + int depth; /* Used for loop detection, use 0 */ + int n_depth; + xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ + int n_string; + xmlNodePtr * lst; /* the return value for the set of parsed nodes */ + int n_lst; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr;n_string++) { + for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + sax = gen_xmlSAXHandlerPtr(n_sax, 1); + user_data = gen_userdata(n_user_data, 2); + depth = gen_int(n_depth, 3); + string = gen_const_xmlChar_ptr(n_string, 4); + lst = gen_xmlNodePtr_ptr(n_lst, 5); + +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif + + + ret_val = xmlParseBalancedChunkMemory(doc, sax, user_data, depth, (const xmlChar *)string, lst); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlSAXHandlerPtr(n_sax, sax, 1); + des_userdata(n_user_data, user_data, 2); + des_int(n_depth, depth, 3); + des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 4); + des_xmlNodePtr_ptr(n_lst, lst, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseBalancedChunkMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_depth); + printf(" %d", n_string); + printf(" %d", n_lst); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseBalancedChunkMemoryRecover(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document the chunk pertains to (must not be NULL) */ + int n_doc; + xmlSAXHandlerPtr sax; /* the SAX handler block (possibly NULL) */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks (possibly NULL) */ + int n_user_data; + int depth; /* Used for loop detection, use 0 */ + int n_depth; + xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ + int n_string; + xmlNodePtr * lst; /* the return value for the set of parsed nodes */ + int n_lst; + int recover; /* return nodes even if the data is broken (use 0) */ + int n_recover; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr;n_string++) { + for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + for (n_recover = 0;n_recover < gen_nb_int;n_recover++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + sax = gen_xmlSAXHandlerPtr(n_sax, 1); + user_data = gen_userdata(n_user_data, 2); + depth = gen_int(n_depth, 3); + string = gen_const_xmlChar_ptr(n_string, 4); + lst = gen_xmlNodePtr_ptr(n_lst, 5); + recover = gen_int(n_recover, 6); + +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif + + + ret_val = xmlParseBalancedChunkMemoryRecover(doc, sax, user_data, depth, (const xmlChar *)string, lst, recover); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlSAXHandlerPtr(n_sax, sax, 1); + des_userdata(n_user_data, user_data, 2); + des_int(n_depth, depth, 3); + des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 4); + des_xmlNodePtr_ptr(n_lst, lst, 5); + des_int(n_recover, recover, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseBalancedChunkMemoryRecover", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_depth); + printf(" %d", n_string); + printf(" %d", n_lst); + printf(" %d", n_recover); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseChunk(void) { + int test_ret = 0; + +#if defined(LIBXML_PUSH_ENABLED) + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + char * chunk; /* an char array */ + int n_chunk; + int size; /* the size in byte of the chunk */ + int n_size; + int terminate; /* last chunk indicator */ + int n_terminate; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_terminate = 0;n_terminate < gen_nb_int;n_terminate++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + chunk = gen_const_char_ptr(n_chunk, 1); + size = gen_int(n_size, 2); + terminate = gen_int(n_terminate, 3); + if ((chunk != NULL) && + (size > (int) strlen((const char *) chunk) + 1)) + continue; + + ret_val = xmlParseChunk(ctxt, (const char *)chunk, size, terminate); + if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_chunk, (const char *)chunk, 1); + des_int(n_size, size, 2); + des_int(n_terminate, terminate, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseChunk", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_chunk); + printf(" %d", n_size); + printf(" %d", n_terminate); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlParseCtxtExternalEntity(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctx; /* the existing parsing context */ + int n_ctx; + xmlChar * URL; /* the URL for the entity to load */ + int n_URL; + xmlChar * ID; /* the System ID for the entity to load */ + int n_ID; + xmlNodePtr * lst; /* the return value for the set of parsed nodes */ + int n_lst; + + for (n_ctx = 0;n_ctx < gen_nb_xmlParserCtxtPtr;n_ctx++) { + for (n_URL = 0;n_URL < gen_nb_const_xmlChar_ptr;n_URL++) { + for (n_ID = 0;n_ID < gen_nb_const_xmlChar_ptr;n_ID++) { + for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + mem_base = xmlMemBlocks(); + ctx = gen_xmlParserCtxtPtr(n_ctx, 0); + URL = gen_const_xmlChar_ptr(n_URL, 1); + ID = gen_const_xmlChar_ptr(n_ID, 2); + lst = gen_xmlNodePtr_ptr(n_lst, 3); + + ret_val = xmlParseCtxtExternalEntity(ctx, (const xmlChar *)URL, (const xmlChar *)ID, lst); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctx, ctx, 0); + des_const_xmlChar_ptr(n_URL, (const xmlChar *)URL, 1); + des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 2); + des_xmlNodePtr_ptr(n_lst, lst, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseCtxtExternalEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_URL); + printf(" %d", n_ID); + printf(" %d", n_lst); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParseDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) +#ifdef LIBXML_VALID_ENABLED + int mem_base; + xmlDtdPtr ret_val; + xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */ + int n_ExternalID; + xmlChar * SystemID; /* a NAME* containing the URL to the DTD */ + int n_SystemID; + + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + mem_base = xmlMemBlocks(); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 0); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 1); + + ret_val = xmlParseDTD((const xmlChar *)ExternalID, (const xmlChar *)SystemID); + desret_xmlDtdPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 0); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseDTD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlChar * cur; /* a pointer to an array of xmlChar */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + + ret_val = xmlParseDoc((const xmlChar *)cur); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseDocument(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlParseDocument(ctxt); + if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParseEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlParseEntity(filename); + desret_xmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseExtParsedEnt(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlParseExtParsedEnt(ctxt); + if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseExtParsedEnt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParseExternalEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document the chunk pertains to */ + int n_doc; + xmlSAXHandlerPtr sax; /* the SAX handler block (possibly NULL) */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks (possibly NULL) */ + int n_user_data; + int depth; /* Used for loop detection, use 0 */ + int n_depth; + xmlChar * URL; /* the URL for the entity to load */ + int n_URL; + xmlChar * ID; /* the System ID for the entity to load */ + int n_ID; + xmlNodePtr * lst; /* the return value for the set of parsed nodes */ + int n_lst; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + for (n_URL = 0;n_URL < gen_nb_const_xmlChar_ptr;n_URL++) { + for (n_ID = 0;n_ID < gen_nb_const_xmlChar_ptr;n_ID++) { + for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + sax = gen_xmlSAXHandlerPtr(n_sax, 1); + user_data = gen_userdata(n_user_data, 2); + depth = gen_int(n_depth, 3); + URL = gen_const_xmlChar_ptr(n_URL, 4); + ID = gen_const_xmlChar_ptr(n_ID, 5); + lst = gen_xmlNodePtr_ptr(n_lst, 6); + + ret_val = xmlParseExternalEntity(doc, sax, user_data, depth, (const xmlChar *)URL, (const xmlChar *)ID, lst); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlSAXHandlerPtr(n_sax, sax, 1); + des_userdata(n_user_data, user_data, 2); + des_int(n_depth, depth, 3); + des_const_xmlChar_ptr(n_URL, (const xmlChar *)URL, 4); + des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 5); + des_xmlNodePtr_ptr(n_lst, lst, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseExternalEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_depth); + printf(" %d", n_URL); + printf(" %d", n_ID); + printf(" %d", n_lst); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseFile(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlParseFile(filename); + desret_xmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlParseInNodeContext(void) { + int test_ret = 0; + + int mem_base; + xmlParserErrors ret_val; + xmlNodePtr node; /* the context node */ + int n_node; + char * data; /* the input string */ + int n_data; + int datalen; /* the input string length in bytes */ + int n_datalen; + int options; /* a combination of xmlParserOption */ + int n_options; + xmlNodePtr * lst; /* the return value for the set of parsed nodes */ + int n_lst; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_data = 0;n_data < gen_nb_const_char_ptr;n_data++) { + for (n_datalen = 0;n_datalen < gen_nb_int;n_datalen++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + data = gen_const_char_ptr(n_data, 1); + datalen = gen_int(n_datalen, 2); + options = gen_parseroptions(n_options, 3); + lst = gen_xmlNodePtr_ptr(n_lst, 4); + + ret_val = xmlParseInNodeContext(node, (const char *)data, datalen, options, lst); + desret_xmlParserErrors(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_char_ptr(n_data, (const char *)data, 1); + des_int(n_datalen, datalen, 2); + des_parseroptions(n_options, options, 3); + des_xmlNodePtr_ptr(n_lst, lst, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseInNodeContext", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_data); + printf(" %d", n_datalen); + printf(" %d", n_options); + printf(" %d", n_lst); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParseMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + char * buffer; /* an pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlParseMemory((const char *)buffer, size); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +#define gen_nb_const_xmlParserNodeInfoPtr 1 +static xmlParserNodeInfoPtr gen_const_xmlParserNodeInfoPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlParserNodeInfoPtr(int no ATTRIBUTE_UNUSED, const xmlParserNodeInfoPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlParserAddNodeInfo(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlParserNodeInfoPtr info; /* a node info sequence pointer */ + int n_info; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_info = 0;n_info < gen_nb_const_xmlParserNodeInfoPtr;n_info++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + info = gen_const_xmlParserNodeInfoPtr(n_info, 1); + + xmlParserAddNodeInfo(ctxt, (const xmlParserNodeInfoPtr)info); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlParserNodeInfoPtr(n_info, (const xmlParserNodeInfoPtr)info, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserAddNodeInfo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_info); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_const_xmlParserCtxtPtr 1 +static xmlParserCtxtPtr gen_const_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, const xmlParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +#define gen_nb_const_xmlNodePtr 1 +static xmlNodePtr gen_const_xmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlNodePtr(int no ATTRIBUTE_UNUSED, const xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlParserFindNodeInfo(void) { + int test_ret = 0; + + int mem_base; + const xmlParserNodeInfo * ret_val; + xmlParserCtxtPtr ctx; /* an XML parser context */ + int n_ctx; + xmlNodePtr node; /* an XML node within the tree */ + int n_node; + + for (n_ctx = 0;n_ctx < gen_nb_const_xmlParserCtxtPtr;n_ctx++) { + for (n_node = 0;n_node < gen_nb_const_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + ctx = gen_const_xmlParserCtxtPtr(n_ctx, 0); + node = gen_const_xmlNodePtr(n_node, 1); + + ret_val = xmlParserFindNodeInfo((const xmlParserCtxtPtr)ctx, (const xmlNodePtr)node); + desret_const_xmlParserNodeInfo_ptr(ret_val); + call_tests++; + des_const_xmlParserCtxtPtr(n_ctx, (const xmlParserCtxtPtr)ctx, 0); + des_const_xmlNodePtr(n_node, (const xmlNodePtr)node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserFindNodeInfo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_const_xmlParserNodeInfoSeqPtr 1 +static xmlParserNodeInfoSeqPtr gen_const_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, const xmlParserNodeInfoSeqPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlParserFindNodeInfoIndex(void) { + int test_ret = 0; + + int mem_base; + unsigned long ret_val; + xmlParserNodeInfoSeqPtr seq; /* a node info sequence pointer */ + int n_seq; + xmlNodePtr node; /* an XML node pointer */ + int n_node; + + for (n_seq = 0;n_seq < gen_nb_const_xmlParserNodeInfoSeqPtr;n_seq++) { + for (n_node = 0;n_node < gen_nb_const_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + seq = gen_const_xmlParserNodeInfoSeqPtr(n_seq, 0); + node = gen_const_xmlNodePtr(n_node, 1); + + ret_val = xmlParserFindNodeInfoIndex((const xmlParserNodeInfoSeqPtr)seq, (const xmlNodePtr)node); + desret_unsigned_long(ret_val); + call_tests++; + des_const_xmlParserNodeInfoSeqPtr(n_seq, (const xmlParserNodeInfoSeqPtr)seq, 0); + des_const_xmlNodePtr(n_node, (const xmlNodePtr)node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserFindNodeInfoIndex", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_seq); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlParserInputPtr 1 +static xmlParserInputPtr gen_xmlParserInputPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlParserInputPtr(int no ATTRIBUTE_UNUSED, xmlParserInputPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlParserInputGrow(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserInputPtr in; /* an XML parser input */ + int n_in; + int len; /* an indicative size for the lookahead */ + int n_len; + + for (n_in = 0;n_in < gen_nb_xmlParserInputPtr;n_in++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + in = gen_xmlParserInputPtr(n_in, 0); + len = gen_int(n_len, 1); + + ret_val = xmlParserInputGrow(in, len); + desret_int(ret_val); + call_tests++; + des_xmlParserInputPtr(n_in, in, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputGrow", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputRead(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserInputPtr in; /* an XML parser input */ + int n_in; + int len; /* an indicative size for the lookahead */ + int n_len; + + for (n_in = 0;n_in < gen_nb_xmlParserInputPtr;n_in++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + in = gen_xmlParserInputPtr(n_in, 0); + len = gen_int(n_len, 1); + + ret_val = xmlParserInputRead(in, len); + desret_int(ret_val); + call_tests++; + des_xmlParserInputPtr(n_in, in, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPedanticParserDefault(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + int val; /* int 0 or 1 */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlPedanticParserDefault(val); + desret_int(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPedanticParserDefault", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlReadDoc(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + xmlChar * cur; /* a pointer to a zero terminated string */ + int n_cur; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + URL = gen_filepath(n_URL, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + options = gen_parseroptions(n_options, 3); + + ret_val = xmlReadDoc((const xmlChar *)cur, URL, (const char *)encoding, options); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_filepath(n_URL, URL, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_parseroptions(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReadDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlReadFile(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + const char * filename; /* a file or URL */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + options = gen_parseroptions(n_options, 2); + + ret_val = xmlReadFile(filename, (const char *)encoding, options); + desret_xmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_parseroptions(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReadFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlReadMemory(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_parseroptions(n_options, 4); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlReadMemory((const char *)buffer, size, URL, (const char *)encoding, options); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_parseroptions(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReadMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlRecoverDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlChar * cur; /* a pointer to an array of xmlChar */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + + ret_val = xmlRecoverDoc((const xmlChar *)cur); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRecoverDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlRecoverFile(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlRecoverFile(filename); + desret_xmlDocPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRecoverFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlRecoverMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + char * buffer; /* an pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlRecoverMemory((const char *)buffer, size); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRecoverMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDtdPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */ + int n_ExternalID; + xmlChar * SystemID; /* a NAME* containing the URL to the DTD */ + int n_SystemID; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 2); + + ret_val = xmlSAXParseDTD(sax, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + desret_xmlDtdPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 1); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseDTD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + xmlChar * cur; /* a pointer to an array of xmlChar */ + int n_cur; + int recovery; /* work in recovery mode, i.e. tries to read no Well Formed documents */ + int n_recovery; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_recovery = 0;n_recovery < gen_nb_int;n_recovery++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + cur = gen_const_xmlChar_ptr(n_cur, 1); + recovery = gen_int(n_recovery, 2); + + ret_val = xmlSAXParseDoc(sax, (const xmlChar *)cur, recovery); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_int(n_recovery, recovery, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_cur); + printf(" %d", n_recovery); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + const char * filename; /* the filename */ + int n_filename; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + filename = gen_filepath(n_filename, 1); + + ret_val = xmlSAXParseEntity(sax, filename); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_filepath(n_filename, filename, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_filename); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseFile(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + const char * filename; /* the filename */ + int n_filename; + int recovery; /* work in recovery mode, i.e. tries to read no Well Formed documents */ + int n_recovery; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_recovery = 0;n_recovery < gen_nb_int;n_recovery++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + filename = gen_filepath(n_filename, 1); + recovery = gen_int(n_recovery, 2); + + ret_val = xmlSAXParseFile(sax, filename, recovery); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_filepath(n_filename, filename, 1); + des_int(n_recovery, recovery, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_filename); + printf(" %d", n_recovery); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseFileWithData(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + const char * filename; /* the filename */ + int n_filename; + int recovery; /* work in recovery mode, i.e. tries to read no Well Formed documents */ + int n_recovery; + void * data; /* the userdata */ + int n_data; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_recovery = 0;n_recovery < gen_nb_int;n_recovery++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + filename = gen_filepath(n_filename, 1); + recovery = gen_int(n_recovery, 2); + data = gen_userdata(n_data, 3); + + ret_val = xmlSAXParseFileWithData(sax, filename, recovery, data); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_filepath(n_filename, filename, 1); + des_int(n_recovery, recovery, 2); + des_userdata(n_data, data, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseFileWithData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_filename); + printf(" %d", n_recovery); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + char * buffer; /* an pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + int recovery; /* work in recovery mode, i.e. tries to read not Well Formed documents */ + int n_recovery; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_recovery = 0;n_recovery < gen_nb_int;n_recovery++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + buffer = gen_const_char_ptr(n_buffer, 1); + size = gen_int(n_size, 2); + recovery = gen_int(n_recovery, 3); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlSAXParseMemory(sax, (const char *)buffer, size, recovery); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_int(n_size, size, 2); + des_int(n_recovery, recovery, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_recovery); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXParseMemoryWithData(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlDocPtr ret_val; + xmlSAXHandlerPtr sax; /* the SAX handler block */ + int n_sax; + char * buffer; /* an pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + int recovery; /* work in recovery mode, i.e. tries to read no Well Formed documents */ + int n_recovery; + void * data; /* the userdata */ + int n_data; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_recovery = 0;n_recovery < gen_nb_int;n_recovery++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + buffer = gen_const_char_ptr(n_buffer, 1); + size = gen_int(n_size, 2); + recovery = gen_int(n_recovery, 3); + data = gen_userdata(n_data, 4); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlSAXParseMemoryWithData(sax, (const char *)buffer, size, recovery, data); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_int(n_size, size, 2); + des_int(n_recovery, recovery, 3); + des_userdata(n_data, data, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXParseMemoryWithData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_recovery); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXUserParseFile(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + int ret_val; + xmlSAXHandlerPtr sax; /* a SAX handler */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks */ + int n_user_data; + const char * filename; /* a file name */ + int n_filename; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + user_data = gen_userdata(n_user_data, 1); + filename = gen_filepath(n_filename, 2); + +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif + + + ret_val = xmlSAXUserParseFile(sax, user_data, filename); + desret_int(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_userdata(n_user_data, user_data, 1); + des_filepath(n_filename, filename, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXUserParseFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_filename); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSAXUserParseMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + int ret_val; + xmlSAXHandlerPtr sax; /* a SAX handler */ + int n_sax; + void * user_data; /* The user data returned on SAX callbacks */ + int n_user_data; + char * buffer; /* an in-memory XML document input */ + int n_buffer; + int size; /* the length of the XML document in bytes */ + int n_size; + + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + sax = gen_xmlSAXHandlerPtr(n_sax, 0); + user_data = gen_userdata(n_user_data, 1); + buffer = gen_const_char_ptr(n_buffer, 2); + size = gen_int(n_size, 3); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + +#ifdef LIBXML_SAX1_ENABLED + if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; +#endif + + + ret_val = xmlSAXUserParseMemory(sax, user_data, (const char *)buffer, size); + desret_int(ret_val); + call_tests++; + des_xmlSAXHandlerPtr(n_sax, sax, 0); + des_userdata(n_user_data, user_data, 1); + des_const_char_ptr(n_buffer, (const char *)buffer, 2); + des_int(n_size, size, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSAXUserParseMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSetExternalEntityLoader(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSetFeature(void) { + int test_ret = 0; + +#if defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_LEGACY_ENABLED + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML/HTML parser context */ + int n_ctxt; + char * name; /* the feature name */ + int n_name; + void * value; /* pointer to the location of the new value */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_void_ptr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + name = gen_const_char_ptr(n_name, 1); + value = gen_void_ptr(n_value, 2); + + ret_val = xmlSetFeature(ctxt, (const char *)name, value); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_name, (const char *)name, 1); + des_void_ptr(n_value, value, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetFeature", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlSetupParserForBuffer(void) { + int test_ret = 0; + +#if defined(LIBXML_SAX1_ENABLED) +#ifdef LIBXML_SAX1_ENABLED + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlChar * buffer; /* a xmlChar * buffer */ + int n_buffer; + const char * filename; /* a file name */ + int n_filename; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_buffer = 0;n_buffer < gen_nb_const_xmlChar_ptr;n_buffer++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + buffer = gen_const_xmlChar_ptr(n_buffer, 1); + filename = gen_filepath(n_filename, 2); + + xmlSetupParserForBuffer(ctxt, (const xmlChar *)buffer, filename); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_buffer, (const xmlChar *)buffer, 1); + des_filepath(n_filename, filename, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetupParserForBuffer", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_buffer); + printf(" %d", n_filename); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlStopParser(void) { + int test_ret = 0; + +#ifdef LIBXML_PUSH_ENABLED + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + xmlStopParser(ctxt); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStopParser", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSubstituteEntitiesDefault(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + int val; /* int 0 or 1 */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlSubstituteEntitiesDefault(val); + desret_int(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSubstituteEntitiesDefault", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + +static int +test_parser(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing parser : 61 of 70 functions ...\n"); + test_ret += test_xmlByteConsumed(); + test_ret += test_xmlClearNodeInfoSeq(); + test_ret += test_xmlClearParserCtxt(); + test_ret += test_xmlCreateDocParserCtxt(); + test_ret += test_xmlCreatePushParserCtxt(); + test_ret += test_xmlCtxtReadDoc(); + test_ret += test_xmlCtxtReadFile(); + test_ret += test_xmlCtxtReadMemory(); + test_ret += test_xmlCtxtReset(); + test_ret += test_xmlCtxtResetPush(); + test_ret += test_xmlCtxtUseOptions(); + test_ret += test_xmlGetExternalEntityLoader(); + test_ret += test_xmlGetFeature(); + test_ret += test_xmlGetFeaturesList(); + test_ret += test_xmlHasFeature(); + test_ret += test_xmlIOParseDTD(); + test_ret += test_xmlInitNodeInfoSeq(); + test_ret += test_xmlInitParser(); + test_ret += test_xmlInitParserCtxt(); + test_ret += test_xmlKeepBlanksDefault(); + test_ret += test_xmlLineNumbersDefault(); + test_ret += test_xmlLoadExternalEntity(); + test_ret += test_xmlNewIOInputStream(); + test_ret += test_xmlNewParserCtxt(); + test_ret += test_xmlParseBalancedChunkMemory(); + test_ret += test_xmlParseBalancedChunkMemoryRecover(); + test_ret += test_xmlParseChunk(); + test_ret += test_xmlParseCtxtExternalEntity(); + test_ret += test_xmlParseDTD(); + test_ret += test_xmlParseDoc(); + test_ret += test_xmlParseDocument(); + test_ret += test_xmlParseEntity(); + test_ret += test_xmlParseExtParsedEnt(); + test_ret += test_xmlParseExternalEntity(); + test_ret += test_xmlParseFile(); + test_ret += test_xmlParseInNodeContext(); + test_ret += test_xmlParseMemory(); + test_ret += test_xmlParserAddNodeInfo(); + test_ret += test_xmlParserFindNodeInfo(); + test_ret += test_xmlParserFindNodeInfoIndex(); + test_ret += test_xmlParserInputGrow(); + test_ret += test_xmlParserInputRead(); + test_ret += test_xmlPedanticParserDefault(); + test_ret += test_xmlReadDoc(); + test_ret += test_xmlReadFile(); + test_ret += test_xmlReadMemory(); + test_ret += test_xmlRecoverDoc(); + test_ret += test_xmlRecoverFile(); + test_ret += test_xmlRecoverMemory(); + test_ret += test_xmlSAXParseDTD(); + test_ret += test_xmlSAXParseDoc(); + test_ret += test_xmlSAXParseEntity(); + test_ret += test_xmlSAXParseFile(); + test_ret += test_xmlSAXParseFileWithData(); + test_ret += test_xmlSAXParseMemory(); + test_ret += test_xmlSAXParseMemoryWithData(); + test_ret += test_xmlSAXUserParseFile(); + test_ret += test_xmlSAXUserParseMemory(); + test_ret += test_xmlSetExternalEntityLoader(); + test_ret += test_xmlSetFeature(); + test_ret += test_xmlSetupParserForBuffer(); + test_ret += test_xmlStopParser(); + test_ret += test_xmlSubstituteEntitiesDefault(); + + if (test_ret != 0) + printf("Module parser: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_htmlCreateFileParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlParserCtxtPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + int n_encoding; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + + ret_val = htmlCreateFileParserCtxt(filename, (const char *)encoding); + desret_htmlParserCtxtPtr(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCreateFileParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_htmlInitAutoClose(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + htmlInitAutoClose(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlInitAutoClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_inputPop(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = inputPop(ctxt); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in inputPop", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_inputPush(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlParserInputPtr value; /* the parser input */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_value = 0;n_value < gen_nb_xmlParserInputPtr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + value = gen_xmlParserInputPtr(n_value, 1); + + ret_val = inputPush(ctxt, value); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputPtr(n_value, value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in inputPush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_namePop(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = namePop(ctxt); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in namePop", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_namePush(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlChar * value; /* the element name */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + + ret_val = namePush(ctxt, (const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in namePush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_nodePop(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = nodePop(ctxt); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in nodePop", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_nodePush(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlNodePtr value; /* the element node */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_value = 0;n_value < gen_nb_xmlNodePtr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + value = gen_xmlNodePtr(n_value, 1); + + ret_val = nodePush(ctxt, value); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_value, value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in nodePush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCheckLanguageID(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * lang; /* pointer to the string value */ + int n_lang; + + for (n_lang = 0;n_lang < gen_nb_const_xmlChar_ptr;n_lang++) { + mem_base = xmlMemBlocks(); + lang = gen_const_xmlChar_ptr(n_lang, 0); + + ret_val = xmlCheckLanguageID((const xmlChar *)lang); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_lang, (const xmlChar *)lang, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCheckLanguageID", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_lang); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyChar(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + int len; /* Ignored, compatibility */ + int n_len; + xmlChar * out; /* pointer to an array of xmlChar */ + int n_out; + int val; /* the char value */ + int n_val; + + for (n_len = 0;n_len < gen_nb_int;n_len++) { + for (n_out = 0;n_out < gen_nb_xmlChar_ptr;n_out++) { + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + len = gen_int(n_len, 0); + out = gen_xmlChar_ptr(n_out, 1); + val = gen_int(n_val, 2); + + ret_val = xmlCopyChar(len, out, val); + desret_int(ret_val); + call_tests++; + des_int(n_len, len, 0); + des_xmlChar_ptr(n_out, out, 1); + des_int(n_val, val, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_len); + printf(" %d", n_out); + printf(" %d", n_val); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyCharMultiByte(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * out; /* pointer to an array of xmlChar */ + int n_out; + int val; /* the char value */ + int n_val; + + for (n_out = 0;n_out < gen_nb_xmlChar_ptr;n_out++) { + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + out = gen_xmlChar_ptr(n_out, 0); + val = gen_int(n_val, 1); + + ret_val = xmlCopyCharMultiByte(out, val); + desret_int(ret_val); + call_tests++; + des_xmlChar_ptr(n_out, out, 0); + des_int(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyCharMultiByte", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateEntityParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ret_val; + xmlChar * URL; /* the entity URL */ + int n_URL; + xmlChar * ID; /* the entity PUBLIC ID */ + int n_ID; + xmlChar * base; /* a possible base for the target URI */ + int n_base; + + for (n_URL = 0;n_URL < gen_nb_const_xmlChar_ptr;n_URL++) { + for (n_ID = 0;n_ID < gen_nb_const_xmlChar_ptr;n_ID++) { + for (n_base = 0;n_base < gen_nb_const_xmlChar_ptr;n_base++) { + mem_base = xmlMemBlocks(); + URL = gen_const_xmlChar_ptr(n_URL, 0); + ID = gen_const_xmlChar_ptr(n_ID, 1); + base = gen_const_xmlChar_ptr(n_base, 2); + + ret_val = xmlCreateEntityParserCtxt((const xmlChar *)URL, (const xmlChar *)ID, (const xmlChar *)base); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URL, (const xmlChar *)URL, 0); + des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 1); + des_const_xmlChar_ptr(n_base, (const xmlChar *)base, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreateEntityParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf(" %d", n_ID); + printf(" %d", n_base); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateFileParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ret_val; + const char * filename; /* the filename */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + + ret_val = xmlCreateFileParserCtxt(filename); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreateFileParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateMemoryParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ret_val; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlCreateMemoryParserCtxt((const char *)buffer, size); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreateMemoryParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateURLParserCtxt(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ret_val; + const char * filename; /* the filename or URL */ + int n_filename; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + options = gen_int(n_options, 1); + + ret_val = xmlCreateURLParserCtxt(filename, options); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_int(n_options, options, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreateURLParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_options); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCurrentChar(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* the XML parser context */ + int n_ctxt; + int * len; /* pointer to the length of the char read */ + int n_len; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_len = 0;n_len < gen_nb_int_ptr;n_len++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + len = gen_int_ptr(n_len, 1); + + ret_val = xmlCurrentChar(ctxt, len); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_int_ptr(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCurrentChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlErrMemory(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + char * extra; /* extra information */ + int n_extra; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_extra = 0;n_extra < gen_nb_const_char_ptr;n_extra++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + extra = gen_const_char_ptr(n_extra, 1); + + xmlErrMemory(ctxt, (const char *)extra); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_extra, (const char *)extra, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlErrMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_extra); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsLetter(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + int c; /* an unicode character (int) */ + int n_c; + + for (n_c = 0;n_c < gen_nb_int;n_c++) { + mem_base = xmlMemBlocks(); + c = gen_int(n_c, 0); + + ret_val = xmlIsLetter(c); + desret_int(ret_val); + call_tests++; + des_int(n_c, c, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsLetter", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_c); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewEntityInputStream(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlEntityPtr entity; /* an Entity pointer */ + int n_entity; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_entity = 0;n_entity < gen_nb_xmlEntityPtr;n_entity++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + entity = gen_xmlEntityPtr(n_entity, 1); + + ret_val = xmlNewEntityInputStream(ctxt, entity); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlEntityPtr(n_entity, entity, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewEntityInputStream", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_entity); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewInputFromFile(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + const char * filename; /* the filename to use as entity */ + int n_filename; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + filename = gen_filepath(n_filename, 1); + + ret_val = xmlNewInputFromFile(ctxt, filename); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_filepath(n_filename, filename, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewInputFromFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewInputStream(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlNewInputStream(ctxt); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewInputStream", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewStringInputStream(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlChar * buffer; /* an memory buffer */ + int n_buffer; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_buffer = 0;n_buffer < gen_nb_const_xmlChar_ptr;n_buffer++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + buffer = gen_const_xmlChar_ptr(n_buffer, 1); + + ret_val = xmlNewStringInputStream(ctxt, (const xmlChar *)buffer); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_buffer, (const xmlChar *)buffer, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewStringInputStream", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_buffer); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNextChar(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* the XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + xmlNextChar(ctxt); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNextChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputShrink(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr in; /* an XML parser input */ + int n_in; + + for (n_in = 0;n_in < gen_nb_xmlParserInputPtr;n_in++) { + mem_base = xmlMemBlocks(); + in = gen_xmlParserInputPtr(n_in, 0); + + xmlParserInputShrink(in); + call_tests++; + des_xmlParserInputPtr(n_in, in, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputShrink", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPopInput(void) { + int test_ret = 0; + + int mem_base; + xmlChar ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlPopInput(ctxt); + desret_xmlChar(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPopInput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPushInput(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlParserInputPtr input; /* an XML parser input fragment (entity, XML fragment ...). */ + int n_input; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + input = gen_xmlParserInputPtr(n_input, 1); + + ret_val = xmlPushInput(ctxt, input); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputPtr(n_input, input, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPushInput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_input); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetEntityReferenceFunc(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSplitQName(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlChar * name; /* an XML parser context */ + int n_name; + xmlChar ** prefix; /* a xmlChar ** */ + int n_prefix; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_prefix = 0;n_prefix < gen_nb_xmlChar_ptr_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + prefix = gen_xmlChar_ptr_ptr(n_prefix, 2); + + ret_val = xmlSplitQName(ctxt, (const xmlChar *)name, prefix); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_xmlChar_ptr_ptr(n_prefix, prefix, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSplitQName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStringCurrentChar(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* the XML parser context */ + int n_ctxt; + xmlChar * cur; /* pointer to the beginning of the char */ + int n_cur; + int * len; /* pointer to the length of the char read */ + int n_len; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_len = 0;n_len < gen_nb_int_ptr;n_len++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + cur = gen_const_xmlChar_ptr(n_cur, 1); + len = gen_int_ptr(n_len, 2); + + ret_val = xmlStringCurrentChar(ctxt, (const xmlChar *)cur, len); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_int_ptr(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStringCurrentChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStringDecodeEntities(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlParserCtxtPtr ctxt; /* the parser context */ + int n_ctxt; + xmlChar * str; /* the input string */ + int n_str; + int what; /* combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF */ + int n_what; + xmlChar end; /* an end marker xmlChar, 0 if none */ + int n_end; + xmlChar end2; /* an end marker xmlChar, 0 if none */ + int n_end2; + xmlChar end3; /* an end marker xmlChar, 0 if none */ + int n_end3; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_what = 0;n_what < gen_nb_int;n_what++) { + for (n_end = 0;n_end < gen_nb_xmlChar;n_end++) { + for (n_end2 = 0;n_end2 < gen_nb_xmlChar;n_end2++) { + for (n_end3 = 0;n_end3 < gen_nb_xmlChar;n_end3++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + what = gen_int(n_what, 2); + end = gen_xmlChar(n_end, 3); + end2 = gen_xmlChar(n_end2, 4); + end3 = gen_xmlChar(n_end3, 5); + + ret_val = xmlStringDecodeEntities(ctxt, (const xmlChar *)str, what, end, end2, end3); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_int(n_what, what, 2); + des_xmlChar(n_end, end, 3); + des_xmlChar(n_end2, end2, 4); + des_xmlChar(n_end3, end3, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStringDecodeEntities", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_str); + printf(" %d", n_what); + printf(" %d", n_end); + printf(" %d", n_end2); + printf(" %d", n_end3); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStringLenDecodeEntities(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlParserCtxtPtr ctxt; /* the parser context */ + int n_ctxt; + xmlChar * str; /* the input string */ + int n_str; + int len; /* the string length */ + int n_len; + int what; /* combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF */ + int n_what; + xmlChar end; /* an end marker xmlChar, 0 if none */ + int n_end; + xmlChar end2; /* an end marker xmlChar, 0 if none */ + int n_end2; + xmlChar end3; /* an end marker xmlChar, 0 if none */ + int n_end3; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + for (n_what = 0;n_what < gen_nb_int;n_what++) { + for (n_end = 0;n_end < gen_nb_xmlChar;n_end++) { + for (n_end2 = 0;n_end2 < gen_nb_xmlChar;n_end2++) { + for (n_end3 = 0;n_end3 < gen_nb_xmlChar;n_end3++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + len = gen_int(n_len, 2); + what = gen_int(n_what, 3); + end = gen_xmlChar(n_end, 4); + end2 = gen_xmlChar(n_end2, 5); + end3 = gen_xmlChar(n_end3, 6); + if ((str != NULL) && + (len > (int) strlen((const char *) str) + 1)) + continue; + + ret_val = xmlStringLenDecodeEntities(ctxt, (const xmlChar *)str, len, what, end, end2, end3); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_int(n_len, len, 2); + des_int(n_what, what, 3); + des_xmlChar(n_end, end, 4); + des_xmlChar(n_end2, end2, 5); + des_xmlChar(n_end3, end3, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStringLenDecodeEntities", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_str); + printf(" %d", n_len); + printf(" %d", n_what); + printf(" %d", n_end); + printf(" %d", n_end2); + printf(" %d", n_end3); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSwitchEncoding(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* the parser context */ + int n_ctxt; + xmlCharEncoding enc; /* the encoding value (number) */ + int n_enc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + enc = gen_xmlCharEncoding(n_enc, 1); + + ret_val = xmlSwitchEncoding(ctxt, enc); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlCharEncoding(n_enc, enc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSwitchEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_enc); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSwitchInputEncoding(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* the parser context */ + int n_ctxt; + xmlParserInputPtr input; /* the input stream */ + int n_input; + xmlCharEncodingHandlerPtr handler; /* the encoding handler */ + int n_handler; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) { + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandlerPtr;n_handler++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + input = gen_xmlParserInputPtr(n_input, 1); + handler = gen_xmlCharEncodingHandlerPtr(n_handler, 2); + + ret_val = xmlSwitchInputEncoding(ctxt, input, handler); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputPtr(n_input, input, 1); + des_xmlCharEncodingHandlerPtr(n_handler, handler, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSwitchInputEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_input); + printf(" %d", n_handler); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSwitchToEncoding(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* the parser context */ + int n_ctxt; + xmlCharEncodingHandlerPtr handler; /* the encoding handler */ + int n_handler; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandlerPtr;n_handler++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + handler = gen_xmlCharEncodingHandlerPtr(n_handler, 1); + + ret_val = xmlSwitchToEncoding(ctxt, handler); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlCharEncodingHandlerPtr(n_handler, handler, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSwitchToEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_handler); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + +static int +test_parserInternals(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing parserInternals : 33 of 90 functions ...\n"); + test_ret += test_htmlCreateFileParserCtxt(); + test_ret += test_htmlInitAutoClose(); + test_ret += test_inputPop(); + test_ret += test_inputPush(); + test_ret += test_namePop(); + test_ret += test_namePush(); + test_ret += test_nodePop(); + test_ret += test_nodePush(); + test_ret += test_xmlCheckLanguageID(); + test_ret += test_xmlCopyChar(); + test_ret += test_xmlCopyCharMultiByte(); + test_ret += test_xmlCreateEntityParserCtxt(); + test_ret += test_xmlCreateFileParserCtxt(); + test_ret += test_xmlCreateMemoryParserCtxt(); + test_ret += test_xmlCreateURLParserCtxt(); + test_ret += test_xmlCurrentChar(); + test_ret += test_xmlErrMemory(); + test_ret += test_xmlIsLetter(); + test_ret += test_xmlNewEntityInputStream(); + test_ret += test_xmlNewInputFromFile(); + test_ret += test_xmlNewInputStream(); + test_ret += test_xmlNewStringInputStream(); + test_ret += test_xmlNextChar(); + test_ret += test_xmlParserInputShrink(); + test_ret += test_xmlPopInput(); + test_ret += test_xmlPushInput(); + test_ret += test_xmlSetEntityReferenceFunc(); + test_ret += test_xmlSplitQName(); + test_ret += test_xmlStringCurrentChar(); + test_ret += test_xmlStringDecodeEntities(); + test_ret += test_xmlStringLenDecodeEntities(); + test_ret += test_xmlSwitchEncoding(); + test_ret += test_xmlSwitchInputEncoding(); + test_ret += test_xmlSwitchToEncoding(); + + if (test_ret != 0) + printf("Module parserInternals: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlPatternFromRoot(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlPatternPtr comp; /* the precompiled pattern */ + int n_comp; + + for (n_comp = 0;n_comp < gen_nb_xmlPatternPtr;n_comp++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlPatternPtr(n_comp, 0); + + ret_val = xmlPatternFromRoot(comp); + desret_int(ret_val); + call_tests++; + des_xmlPatternPtr(n_comp, comp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPatternFromRoot", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlPatternGetStreamCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlPatternMatch(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlPatternPtr comp; /* the precompiled pattern */ + int n_comp; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_comp = 0;n_comp < gen_nb_xmlPatternPtr;n_comp++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlPatternPtr(n_comp, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlPatternMatch(comp, node); + desret_int(ret_val); + call_tests++; + des_xmlPatternPtr(n_comp, comp, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPatternMatch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlPatternMaxDepth(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlPatternPtr comp; /* the precompiled pattern */ + int n_comp; + + for (n_comp = 0;n_comp < gen_nb_xmlPatternPtr;n_comp++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlPatternPtr(n_comp, 0); + + ret_val = xmlPatternMaxDepth(comp); + desret_int(ret_val); + call_tests++; + des_xmlPatternPtr(n_comp, comp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPatternMaxDepth", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlPatternMinDepth(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlPatternPtr comp; /* the precompiled pattern */ + int n_comp; + + for (n_comp = 0;n_comp < gen_nb_xmlPatternPtr;n_comp++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlPatternPtr(n_comp, 0); + + ret_val = xmlPatternMinDepth(comp); + desret_int(ret_val); + call_tests++; + des_xmlPatternPtr(n_comp, comp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPatternMinDepth", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlPatternStreamable(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlPatternPtr comp; /* the precompiled pattern */ + int n_comp; + + for (n_comp = 0;n_comp < gen_nb_xmlPatternPtr;n_comp++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlPatternPtr(n_comp, 0); + + ret_val = xmlPatternStreamable(comp); + desret_int(ret_val); + call_tests++; + des_xmlPatternPtr(n_comp, comp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPatternStreamable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlPatterncompile(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_PATTERN_ENABLED + +#define gen_nb_xmlStreamCtxtPtr 1 +static xmlStreamCtxtPtr gen_xmlStreamCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlStreamCtxtPtr(int no ATTRIBUTE_UNUSED, xmlStreamCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlStreamPop(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlStreamCtxtPtr stream; /* the stream context */ + int n_stream; + + for (n_stream = 0;n_stream < gen_nb_xmlStreamCtxtPtr;n_stream++) { + mem_base = xmlMemBlocks(); + stream = gen_xmlStreamCtxtPtr(n_stream, 0); + + ret_val = xmlStreamPop(stream); + desret_int(ret_val); + call_tests++; + des_xmlStreamCtxtPtr(n_stream, stream, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStreamPop", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_stream); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlStreamPush(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlStreamCtxtPtr stream; /* the stream context */ + int n_stream; + xmlChar * name; /* the current name */ + int n_name; + xmlChar * ns; /* the namespace name */ + int n_ns; + + for (n_stream = 0;n_stream < gen_nb_xmlStreamCtxtPtr;n_stream++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns = 0;n_ns < gen_nb_const_xmlChar_ptr;n_ns++) { + mem_base = xmlMemBlocks(); + stream = gen_xmlStreamCtxtPtr(n_stream, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ns = gen_const_xmlChar_ptr(n_ns, 2); + + ret_val = xmlStreamPush(stream, (const xmlChar *)name, (const xmlChar *)ns); + desret_int(ret_val); + call_tests++; + des_xmlStreamCtxtPtr(n_stream, stream, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStreamPush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_stream); + printf(" %d", n_name); + printf(" %d", n_ns); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlStreamPushAttr(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlStreamCtxtPtr stream; /* the stream context */ + int n_stream; + xmlChar * name; /* the current name */ + int n_name; + xmlChar * ns; /* the namespace name */ + int n_ns; + + for (n_stream = 0;n_stream < gen_nb_xmlStreamCtxtPtr;n_stream++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns = 0;n_ns < gen_nb_const_xmlChar_ptr;n_ns++) { + mem_base = xmlMemBlocks(); + stream = gen_xmlStreamCtxtPtr(n_stream, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ns = gen_const_xmlChar_ptr(n_ns, 2); + + ret_val = xmlStreamPushAttr(stream, (const xmlChar *)name, (const xmlChar *)ns); + desret_int(ret_val); + call_tests++; + des_xmlStreamCtxtPtr(n_stream, stream, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStreamPushAttr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_stream); + printf(" %d", n_name); + printf(" %d", n_ns); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlStreamPushNode(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlStreamCtxtPtr stream; /* the stream context */ + int n_stream; + xmlChar * name; /* the current name */ + int n_name; + xmlChar * ns; /* the namespace name */ + int n_ns; + int nodeType; /* the type of the node being pushed */ + int n_nodeType; + + for (n_stream = 0;n_stream < gen_nb_xmlStreamCtxtPtr;n_stream++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns = 0;n_ns < gen_nb_const_xmlChar_ptr;n_ns++) { + for (n_nodeType = 0;n_nodeType < gen_nb_int;n_nodeType++) { + mem_base = xmlMemBlocks(); + stream = gen_xmlStreamCtxtPtr(n_stream, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ns = gen_const_xmlChar_ptr(n_ns, 2); + nodeType = gen_int(n_nodeType, 3); + + ret_val = xmlStreamPushNode(stream, (const xmlChar *)name, (const xmlChar *)ns, nodeType); + desret_int(ret_val); + call_tests++; + des_xmlStreamCtxtPtr(n_stream, stream, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 2); + des_int(n_nodeType, nodeType, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStreamPushNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_stream); + printf(" %d", n_name); + printf(" %d", n_ns); + printf(" %d", n_nodeType); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlStreamWantsAnyNode(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + xmlStreamCtxtPtr streamCtxt; /* the stream context */ + int n_streamCtxt; + + for (n_streamCtxt = 0;n_streamCtxt < gen_nb_xmlStreamCtxtPtr;n_streamCtxt++) { + mem_base = xmlMemBlocks(); + streamCtxt = gen_xmlStreamCtxtPtr(n_streamCtxt, 0); + + ret_val = xmlStreamWantsAnyNode(streamCtxt); + desret_int(ret_val); + call_tests++; + des_xmlStreamCtxtPtr(n_streamCtxt, streamCtxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStreamWantsAnyNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_streamCtxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_pattern(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing pattern : 10 of 15 functions ...\n"); + test_ret += test_xmlPatternFromRoot(); + test_ret += test_xmlPatternGetStreamCtxt(); + test_ret += test_xmlPatternMatch(); + test_ret += test_xmlPatternMaxDepth(); + test_ret += test_xmlPatternMinDepth(); + test_ret += test_xmlPatternStreamable(); + test_ret += test_xmlPatterncompile(); + test_ret += test_xmlStreamPop(); + test_ret += test_xmlStreamPush(); + test_ret += test_xmlStreamPushAttr(); + test_ret += test_xmlStreamPushNode(); + test_ret += test_xmlStreamWantsAnyNode(); + + if (test_ret != 0) + printf("Module pattern: %d errors\n", test_ret); + return(test_ret); +} +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlRelaxNGPtr 1 +static xmlRelaxNGPtr gen_xmlRelaxNGPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRelaxNGPtr(int no ATTRIBUTE_UNUSED, xmlRelaxNGPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlRelaxNGDump(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + FILE * output; /* the file output */ + int n_output; + xmlRelaxNGPtr schema; /* a schema structure */ + int n_schema; + + for (n_output = 0;n_output < gen_nb_FILE_ptr;n_output++) { + for (n_schema = 0;n_schema < gen_nb_xmlRelaxNGPtr;n_schema++) { + mem_base = xmlMemBlocks(); + output = gen_FILE_ptr(n_output, 0); + schema = gen_xmlRelaxNGPtr(n_schema, 1); + + xmlRelaxNGDump(output, schema); + call_tests++; + des_FILE_ptr(n_output, output, 0); + des_xmlRelaxNGPtr(n_schema, schema, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_schema); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGDumpTree(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + FILE * output; /* the file output */ + int n_output; + xmlRelaxNGPtr schema; /* a schema structure */ + int n_schema; + + for (n_output = 0;n_output < gen_nb_FILE_ptr;n_output++) { + for (n_schema = 0;n_schema < gen_nb_xmlRelaxNGPtr;n_schema++) { + mem_base = xmlMemBlocks(); + output = gen_FILE_ptr(n_output, 0); + schema = gen_xmlRelaxNGPtr(n_schema, 1); + + xmlRelaxNGDumpTree(output, schema); + call_tests++; + des_FILE_ptr(n_output, output, 0); + des_xmlRelaxNGPtr(n_schema, schema, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGDumpTree", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_schema); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlRelaxNGParserCtxtPtr 1 +static xmlRelaxNGParserCtxtPtr gen_xmlRelaxNGParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRelaxNGParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlRelaxNGParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlRelaxNGValidityErrorFunc_ptr 1 +static xmlRelaxNGValidityErrorFunc * gen_xmlRelaxNGValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRelaxNGValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlRelaxNGValidityErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlRelaxNGValidityWarningFunc_ptr 1 +static xmlRelaxNGValidityWarningFunc * gen_xmlRelaxNGValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRelaxNGValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, xmlRelaxNGValidityWarningFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlRelaxNGGetParserErrors(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGParserCtxtPtr ctxt; /* a Relax-NG validation context */ + int n_ctxt; + xmlRelaxNGValidityErrorFunc * err; /* the error callback result */ + int n_err; + xmlRelaxNGValidityWarningFunc * warn; /* the warning callback result */ + int n_warn; + void ** ctx; /* contextual data for the callbacks result */ + int n_ctx; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGParserCtxtPtr;n_ctxt++) { + for (n_err = 0;n_err < gen_nb_xmlRelaxNGValidityErrorFunc_ptr;n_err++) { + for (n_warn = 0;n_warn < gen_nb_xmlRelaxNGValidityWarningFunc_ptr;n_warn++) { + for (n_ctx = 0;n_ctx < gen_nb_void_ptr_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGParserCtxtPtr(n_ctxt, 0); + err = gen_xmlRelaxNGValidityErrorFunc_ptr(n_err, 1); + warn = gen_xmlRelaxNGValidityWarningFunc_ptr(n_warn, 2); + ctx = gen_void_ptr_ptr(n_ctx, 3); + + ret_val = xmlRelaxNGGetParserErrors(ctxt, err, warn, ctx); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlRelaxNGValidityErrorFunc_ptr(n_err, err, 1); + des_xmlRelaxNGValidityWarningFunc_ptr(n_warn, warn, 2); + des_void_ptr_ptr(n_ctx, ctx, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGGetParserErrors", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_err); + printf(" %d", n_warn); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlRelaxNGValidCtxtPtr 1 +static xmlRelaxNGValidCtxtPtr gen_xmlRelaxNGValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRelaxNGValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlRelaxNGValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlRelaxNGGetValidErrors(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGValidCtxtPtr ctxt; /* a Relax-NG validation context */ + int n_ctxt; + xmlRelaxNGValidityErrorFunc * err; /* the error function result */ + int n_err; + xmlRelaxNGValidityWarningFunc * warn; /* the warning function result */ + int n_warn; + void ** ctx; /* the functions context result */ + int n_ctx; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_err = 0;n_err < gen_nb_xmlRelaxNGValidityErrorFunc_ptr;n_err++) { + for (n_warn = 0;n_warn < gen_nb_xmlRelaxNGValidityWarningFunc_ptr;n_warn++) { + for (n_ctx = 0;n_ctx < gen_nb_void_ptr_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 0); + err = gen_xmlRelaxNGValidityErrorFunc_ptr(n_err, 1); + warn = gen_xmlRelaxNGValidityWarningFunc_ptr(n_warn, 2); + ctx = gen_void_ptr_ptr(n_ctx, 3); + + ret_val = xmlRelaxNGGetValidErrors(ctxt, err, warn, ctx); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlRelaxNGValidityErrorFunc_ptr(n_err, err, 1); + des_xmlRelaxNGValidityWarningFunc_ptr(n_warn, warn, 2); + des_void_ptr_ptr(n_ctx, ctx, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGGetValidErrors", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_err); + printf(" %d", n_warn); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGInitTypes(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlRelaxNGInitTypes(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGInitTypes", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGNewDocParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlRelaxNGParserCtxtPtr ret_val; + xmlDocPtr doc; /* a preparsed document tree */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + + ret_val = xmlRelaxNGNewDocParserCtxt(doc); + desret_xmlRelaxNGParserCtxtPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGNewDocParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGNewMemParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlRelaxNGParserCtxtPtr ret_val; + char * buffer; /* a pointer to a char array containing the schemas */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlRelaxNGNewMemParserCtxt((const char *)buffer, size); + desret_xmlRelaxNGParserCtxtPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGNewMemParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGNewParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlRelaxNGParserCtxtPtr ret_val; + char * URL; /* the location of the schema */ + int n_URL; + + for (n_URL = 0;n_URL < gen_nb_const_char_ptr;n_URL++) { + mem_base = xmlMemBlocks(); + URL = gen_const_char_ptr(n_URL, 0); + + ret_val = xmlRelaxNGNewParserCtxt((const char *)URL); + desret_xmlRelaxNGParserCtxtPtr(ret_val); + call_tests++; + des_const_char_ptr(n_URL, (const char *)URL, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGNewParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGNewValidCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRelaxNGParse(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRelaxNGSetParserErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRelaxNGSetParserStructuredErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRelaxNGSetValidErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRelaxNGSetValidStructuredErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRelaxNGValidateDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGValidCtxtPtr ctxt; /* a Relax-NG validation context */ + int n_ctxt; + xmlDocPtr doc; /* a parsed document tree */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlRelaxNGValidateDoc(ctxt, doc); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGValidateDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGValidateFullElement(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + + ret_val = xmlRelaxNGValidateFullElement(ctxt, doc, elem); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGValidateFullElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGValidatePopElement(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + + ret_val = xmlRelaxNGValidatePopElement(ctxt, doc, elem); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGValidatePopElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGValidatePushCData(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG validation context */ + int n_ctxt; + xmlChar * data; /* some character data read */ + int n_data; + int len; /* the length of the data */ + int n_len; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_data = 0;n_data < gen_nb_const_xmlChar_ptr;n_data++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 0); + data = gen_const_xmlChar_ptr(n_data, 1); + len = gen_int(n_len, 2); + if ((data != NULL) && + (len > (int) strlen((const char *) data) + 1)) + continue; + + ret_val = xmlRelaxNGValidatePushCData(ctxt, (const xmlChar *)data, len); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_data, (const xmlChar *)data, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGValidatePushCData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_data); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxNGValidatePushElement(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + + ret_val = xmlRelaxNGValidatePushElement(ctxt, doc, elem); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxNGValidatePushElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRelaxParserSetFlag(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlRelaxNGParserCtxtPtr ctxt; /* a RelaxNG parser context */ + int n_ctxt; + int flags; /* a set of flags values */ + int n_flags; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGParserCtxtPtr;n_ctxt++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlRelaxNGParserCtxtPtr(n_ctxt, 0); + flags = gen_int(n_flags, 1); + + ret_val = xmlRelaxParserSetFlag(ctxt, flags); + desret_int(ret_val); + call_tests++; + des_xmlRelaxNGParserCtxtPtr(n_ctxt, ctxt, 0); + des_int(n_flags, flags, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRelaxParserSetFlag", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_flags); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_relaxng(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing relaxng : 14 of 24 functions ...\n"); + test_ret += test_xmlRelaxNGDump(); + test_ret += test_xmlRelaxNGDumpTree(); + test_ret += test_xmlRelaxNGGetParserErrors(); + test_ret += test_xmlRelaxNGGetValidErrors(); + test_ret += test_xmlRelaxNGInitTypes(); + test_ret += test_xmlRelaxNGNewDocParserCtxt(); + test_ret += test_xmlRelaxNGNewMemParserCtxt(); + test_ret += test_xmlRelaxNGNewParserCtxt(); + test_ret += test_xmlRelaxNGNewValidCtxt(); + test_ret += test_xmlRelaxNGParse(); + test_ret += test_xmlRelaxNGSetParserErrors(); + test_ret += test_xmlRelaxNGSetParserStructuredErrors(); + test_ret += test_xmlRelaxNGSetValidErrors(); + test_ret += test_xmlRelaxNGSetValidStructuredErrors(); + test_ret += test_xmlRelaxNGValidateDoc(); + test_ret += test_xmlRelaxNGValidateFullElement(); + test_ret += test_xmlRelaxNGValidatePopElement(); + test_ret += test_xmlRelaxNGValidatePushCData(); + test_ret += test_xmlRelaxNGValidatePushElement(); + test_ret += test_xmlRelaxParserSetFlag(); + + if (test_ret != 0) + printf("Module relaxng: %d errors\n", test_ret); + return(test_ret); +} +static int +test_schemasInternals(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing schemasInternals : 0 of 2 functions ...\n"); + + if (test_ret != 0) + printf("Module schemasInternals: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlSchematronNewDocParserCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchematronNewMemParserCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchematronNewParserCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchematronNewValidCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchematronParse(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchematronSetValidStructuredErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_SCHEMATRON_ENABLED + +#define gen_nb_xmlSchematronValidCtxtPtr 1 +static xmlSchematronValidCtxtPtr gen_xmlSchematronValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchematronValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchematronValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSchematronValidateDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMATRON_ENABLED) + int mem_base; + int ret_val; + xmlSchematronValidCtxtPtr ctxt; /* the schema validation context */ + int n_ctxt; + xmlDocPtr instance; /* the document instance tree */ + int n_instance; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchematronValidCtxtPtr;n_ctxt++) { + for (n_instance = 0;n_instance < gen_nb_xmlDocPtr;n_instance++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchematronValidCtxtPtr(n_ctxt, 0); + instance = gen_xmlDocPtr(n_instance, 1); + + ret_val = xmlSchematronValidateDoc(ctxt, instance); + desret_int(ret_val); + call_tests++; + des_xmlSchematronValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_instance, instance, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchematronValidateDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_instance); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_schematron(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing schematron : 1 of 10 functions ...\n"); + test_ret += test_xmlSchematronNewDocParserCtxt(); + test_ret += test_xmlSchematronNewMemParserCtxt(); + test_ret += test_xmlSchematronNewParserCtxt(); + test_ret += test_xmlSchematronNewValidCtxt(); + test_ret += test_xmlSchematronParse(); + test_ret += test_xmlSchematronSetValidStructuredErrors(); + test_ret += test_xmlSchematronValidateDoc(); + + if (test_ret != 0) + printf("Module schematron: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlAddChild(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + xmlNodePtr cur; /* the child node */ + int n_cur; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + cur = gen_xmlNodePtr_in(n_cur, 1); + + ret_val = xmlAddChild(parent, cur); + if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + des_xmlNodePtr_in(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddChildList(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + xmlNodePtr cur; /* the first node in the list */ + int n_cur; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + cur = gen_xmlNodePtr_in(n_cur, 1); + + ret_val = xmlAddChildList(parent, cur); + if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + des_xmlNodePtr_in(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddChildList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddNextSibling(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr cur; /* the child node */ + int n_cur; + xmlNodePtr elem; /* the new node */ + int n_elem; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + elem = gen_xmlNodePtr_in(n_elem, 1); + + ret_val = xmlAddNextSibling(cur, elem); + if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_xmlNodePtr_in(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddNextSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddPrevSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr cur; /* the child node */ + int n_cur; + xmlNodePtr elem; /* the new node */ + int n_elem; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + elem = gen_xmlNodePtr_in(n_elem, 1); + + ret_val = xmlAddPrevSibling(cur, elem); + if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_xmlNodePtr_in(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddPrevSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlAddSibling(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr cur; /* the child node */ + int n_cur; + xmlNodePtr elem; /* the new node */ + int n_elem; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + elem = gen_xmlNodePtr_in(n_elem, 1); + + ret_val = xmlAddSibling(cur, elem); + if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_xmlNodePtr_in(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAttrSerializeTxtContent(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) +#ifdef LIBXML_OUTPUT_ENABLED + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlAttrPtr attr; /* the attribute node */ + int n_attr; + xmlChar * string; /* the text content */ + int n_string; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr;n_string++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + doc = gen_xmlDocPtr(n_doc, 1); + attr = gen_xmlAttrPtr(n_attr, 2); + string = gen_const_xmlChar_ptr(n_string, 3); + + xmlAttrSerializeTxtContent(buf, doc, attr, (const xmlChar *)string); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlAttrPtr(n_attr, attr, 2); + des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAttrSerializeTxtContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_doc); + printf(" %d", n_attr); + printf(" %d", n_string); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +#define gen_nb_const_xmlBuf_ptr 1 +static xmlBuf * gen_const_xmlBuf_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlBuf_ptr(int no ATTRIBUTE_UNUSED, const xmlBuf * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlBufContent(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlBuf * buf; /* the buffer */ + int n_buf; + + for (n_buf = 0;n_buf < gen_nb_const_xmlBuf_ptr;n_buf++) { + mem_base = xmlMemBlocks(); + buf = gen_const_xmlBuf_ptr(n_buf, 0); + + ret_val = xmlBufContent((const xmlBuf *)buf); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlBuf_ptr(n_buf, (const xmlBuf *)buf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlBufPtr 1 +static xmlBufPtr gen_xmlBufPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlBufPtr(int no ATTRIBUTE_UNUSED, xmlBufPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlBufEnd(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlBufPtr buf; /* the buffer */ + int n_buf; + + for (n_buf = 0;n_buf < gen_nb_xmlBufPtr;n_buf++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufPtr(n_buf, 0); + + ret_val = xmlBufEnd(buf); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlBufPtr(n_buf, buf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufEnd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_const_xmlNode_ptr 1 +static xmlNode * gen_const_xmlNode_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlNode_ptr(int no ATTRIBUTE_UNUSED, const xmlNode * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlBufGetNodeContent(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufPtr buf; /* a buffer xmlBufPtr */ + int n_buf; + xmlNode * cur; /* the node being read */ + int n_cur; + + for (n_buf = 0;n_buf < gen_nb_xmlBufPtr;n_buf++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufPtr(n_buf, 0); + cur = gen_const_xmlNode_ptr(n_cur, 1); + + ret_val = xmlBufGetNodeContent(buf, (const xmlNode *)cur); + desret_int(ret_val); + call_tests++; + des_xmlBufPtr(n_buf, buf, 0); + des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufGetNodeContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufNodeDump(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlBufShrink(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlBufUse(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlBufferAdd(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer to dump */ + int n_buf; + xmlChar * str; /* the #xmlChar string */ + int n_str; + int len; /* the number of #xmlChar to add */ + int n_len; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + len = gen_int(n_len, 2); + if ((str != NULL) && + (len > (int) strlen((const char *) str) + 1)) + continue; + + ret_val = xmlBufferAdd(buf, (const xmlChar *)str, len); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferAdd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_str); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferAddHead(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer */ + int n_buf; + xmlChar * str; /* the #xmlChar string */ + int n_str; + int len; /* the number of #xmlChar to add */ + int n_len; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + len = gen_int(n_len, 2); + if ((str != NULL) && + (len > (int) strlen((const char *) str) + 1)) + continue; + + ret_val = xmlBufferAddHead(buf, (const xmlChar *)str, len); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferAddHead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_str); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferCCat(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer to dump */ + int n_buf; + char * str; /* the C char string */ + int n_str; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_str = 0;n_str < gen_nb_const_char_ptr;n_str++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + str = gen_const_char_ptr(n_str, 1); + + ret_val = xmlBufferCCat(buf, (const char *)str); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_char_ptr(n_str, (const char *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferCCat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferCat(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer to add to */ + int n_buf; + xmlChar * str; /* the #xmlChar string */ + int n_str; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + + ret_val = xmlBufferCat(buf, (const xmlChar *)str); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferCat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_const_xmlBuffer_ptr 1 +static xmlBuffer * gen_const_xmlBuffer_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_const_xmlBuffer_ptr(int no ATTRIBUTE_UNUSED, const xmlBuffer * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlBufferContent(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlBuffer * buf; /* the buffer */ + int n_buf; + + for (n_buf = 0;n_buf < gen_nb_const_xmlBuffer_ptr;n_buf++) { + mem_base = xmlMemBlocks(); + buf = gen_const_xmlBuffer_ptr(n_buf, 0); + + ret_val = xmlBufferContent((const xmlBuffer *)buf); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlBuffer_ptr(n_buf, (const xmlBuffer *)buf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferCreate(void) { + int test_ret = 0; + + int mem_base; + xmlBufferPtr ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlBufferCreate(); + desret_xmlBufferPtr(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferCreate", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferCreateSize(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlBufferCreateStatic(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlBufferDetach(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlBufferPtr buf; /* the buffer */ + int n_buf; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + + ret_val = xmlBufferDetach(buf); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferDetach", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferEmpty(void) { + int test_ret = 0; + + int mem_base; + xmlBufferPtr buf; /* the buffer */ + int n_buf; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + + xmlBufferEmpty(buf); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferEmpty", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferGrow(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer */ + int n_buf; + unsigned int len; /* the minimum free size to allocate */ + int n_len; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_len = 0;n_len < gen_nb_unsigned_int;n_len++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + len = gen_unsigned_int(n_len, 1); + + ret_val = xmlBufferGrow(buf, len); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_unsigned_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferGrow", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferLength(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBuffer * buf; /* the buffer */ + int n_buf; + + for (n_buf = 0;n_buf < gen_nb_const_xmlBuffer_ptr;n_buf++) { + mem_base = xmlMemBlocks(); + buf = gen_const_xmlBuffer_ptr(n_buf, 0); + + ret_val = xmlBufferLength((const xmlBuffer *)buf); + desret_int(ret_val); + call_tests++; + des_const_xmlBuffer_ptr(n_buf, (const xmlBuffer *)buf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferLength", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferResize(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer to resize */ + int n_buf; + unsigned int size; /* the desired size */ + int n_size; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_size = 0;n_size < gen_nb_unsigned_int;n_size++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + size = gen_unsigned_int(n_size, 1); + + ret_val = xmlBufferResize(buf, size); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_unsigned_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferResize", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferSetAllocationScheme(void) { + int test_ret = 0; + + int mem_base; + xmlBufferPtr buf; /* the buffer to tune */ + int n_buf; + xmlBufferAllocationScheme scheme; /* allocation scheme to use */ + int n_scheme; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_scheme = 0;n_scheme < gen_nb_xmlBufferAllocationScheme;n_scheme++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + scheme = gen_xmlBufferAllocationScheme(n_scheme, 1); + + xmlBufferSetAllocationScheme(buf, scheme); + if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;} + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlBufferAllocationScheme(n_scheme, scheme, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferSetAllocationScheme", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_scheme); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferShrink(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the buffer to dump */ + int n_buf; + unsigned int len; /* the number of xmlChar to remove */ + int n_len; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_len = 0;n_len < gen_nb_unsigned_int;n_len++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + len = gen_unsigned_int(n_len, 1); + + ret_val = xmlBufferShrink(buf, len); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_unsigned_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferShrink", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferWriteCHAR(void) { + int test_ret = 0; + + int mem_base; + xmlBufferPtr buf; /* the XML buffer */ + int n_buf; + xmlChar * string; /* the string to add */ + int n_string; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr;n_string++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + string = gen_const_xmlChar_ptr(n_string, 1); + + xmlBufferWriteCHAR(buf, (const xmlChar *)string); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferWriteCHAR", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_string); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferWriteChar(void) { + int test_ret = 0; + + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + char * string; /* the string to add */ + int n_string; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_string = 0;n_string < gen_nb_const_char_ptr;n_string++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + string = gen_const_char_ptr(n_string, 1); + + xmlBufferWriteChar(buf, (const char *)string); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_char_ptr(n_string, (const char *)string, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferWriteChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_string); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBufferWriteQuotedString(void) { + int test_ret = 0; + + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlChar * string; /* the string to add */ + int n_string; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr;n_string++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + string = gen_const_xmlChar_ptr(n_string, 1); + + xmlBufferWriteQuotedString(buf, (const xmlChar *)string); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBufferWriteQuotedString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_string); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBuildQName(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * ncname; /* the Name */ + int n_ncname; + xmlChar * prefix; /* the prefix */ + int n_prefix; + xmlChar * memory; /* preallocated memory */ + int n_memory; + int len; /* preallocated memory length */ + int n_len; + + for (n_ncname = 0;n_ncname < gen_nb_const_xmlChar_ptr;n_ncname++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_memory = 0;n_memory < gen_nb_xmlChar_ptr;n_memory++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ncname = gen_const_xmlChar_ptr(n_ncname, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + memory = gen_xmlChar_ptr(n_memory, 2); + len = gen_int(n_len, 3); + if ((prefix != NULL) && + (len > (int) strlen((const char *) prefix) + 1)) + continue; + + ret_val = xmlBuildQName((const xmlChar *)ncname, (const xmlChar *)prefix, memory, len); + if ((ret_val != NULL) && (ret_val != ncname) && + (ret_val != prefix) && (ret_val != memory)) + xmlFree(ret_val); + ret_val = NULL; + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_ncname, (const xmlChar *)ncname, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_xmlChar_ptr(n_memory, memory, 2); + des_int(n_len, len, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBuildQName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ncname); + printf(" %d", n_prefix); + printf(" %d", n_memory); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlChildElementCount(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + unsigned long ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + + ret_val = xmlChildElementCount(parent); + desret_unsigned_long(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlChildElementCount", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCopyDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlDocPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + int recursive; /* if not zero do a recursive copy. */ + int n_recursive; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_recursive = 0;n_recursive < gen_nb_int;n_recursive++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + recursive = gen_int(n_recursive, 1); + + ret_val = xmlCopyDoc(doc, recursive); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_int(n_recursive, recursive, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_recursive); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCopyDtd(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlDtdPtr ret_val; + xmlDtdPtr dtd; /* the dtd */ + int n_dtd; + + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + mem_base = xmlMemBlocks(); + dtd = gen_xmlDtdPtr(n_dtd, 0); + + ret_val = xmlCopyDtd(dtd); + desret_xmlDtdPtr(ret_val); + call_tests++; + des_xmlDtdPtr(n_dtd, dtd, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyDtd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dtd); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlCopyNamespace(void) { + int test_ret = 0; + + int mem_base; + xmlNsPtr ret_val; + xmlNsPtr cur; /* the namespace */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_xmlNsPtr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNsPtr(n_cur, 0); + + ret_val = xmlCopyNamespace(cur); + if (ret_val != NULL) xmlFreeNs(ret_val); + desret_xmlNsPtr(ret_val); + call_tests++; + des_xmlNsPtr(n_cur, cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyNamespace", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyNamespaceList(void) { + int test_ret = 0; + + int mem_base; + xmlNsPtr ret_val; + xmlNsPtr cur; /* the first namespace */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_xmlNsPtr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNsPtr(n_cur, 0); + + ret_val = xmlCopyNamespaceList(cur); + if (ret_val != NULL) xmlFreeNsList(ret_val); + desret_xmlNsPtr(ret_val); + call_tests++; + des_xmlNsPtr(n_cur, cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyNamespaceList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyNode(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the node */ + int n_node; + int extended; /* if 1 do a recursive copy (properties, namespaces and children when applicable) if 2 copy properties and namespaces (when applicable) */ + int n_extended; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_extended = 0;n_extended < gen_nb_int;n_extended++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + extended = gen_int(n_extended, 1); + + ret_val = xmlCopyNode(node, extended); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_int(n_extended, extended, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_extended); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyNodeList(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the first node in the list. */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlCopyNodeList(node); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyNodeList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyProp(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr target; /* the element where the attribute will be grafted */ + int n_target; + xmlAttrPtr cur; /* the attribute */ + int n_cur; + + for (n_target = 0;n_target < gen_nb_xmlNodePtr;n_target++) { + for (n_cur = 0;n_cur < gen_nb_xmlAttrPtr;n_cur++) { + mem_base = xmlMemBlocks(); + target = gen_xmlNodePtr(n_target, 0); + cur = gen_xmlAttrPtr(n_cur, 1); + + ret_val = xmlCopyProp(target, cur); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_target, target, 0); + des_xmlAttrPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_target); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyPropList(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr target; /* the element where the attributes will be grafted */ + int n_target; + xmlAttrPtr cur; /* the first attribute */ + int n_cur; + + for (n_target = 0;n_target < gen_nb_xmlNodePtr;n_target++) { + for (n_cur = 0;n_cur < gen_nb_xmlAttrPtr;n_cur++) { + mem_base = xmlMemBlocks(); + target = gen_xmlNodePtr(n_target, 0); + cur = gen_xmlAttrPtr(n_cur, 1); + + ret_val = xmlCopyPropList(target, cur); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_target, target, 0); + des_xmlAttrPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyPropList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_target); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateIntSubset(void) { + int test_ret = 0; + + int mem_base; + xmlDtdPtr ret_val; + xmlDocPtr doc; /* the document pointer */ + int n_doc; + xmlChar * name; /* the DTD name */ + int n_name; + xmlChar * ExternalID; /* the external (PUBLIC) ID */ + int n_ExternalID; + xmlChar * SystemID; /* the system ID */ + int n_SystemID; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); + + ret_val = xmlCreateIntSubset(doc, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + desret_xmlDtdPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCreateIntSubset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlDOMWrapCtxtPtr 1 +static xmlDOMWrapCtxtPtr gen_xmlDOMWrapCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlDOMWrapCtxtPtr(int no ATTRIBUTE_UNUSED, xmlDOMWrapCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDOMWrapAdoptNode(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDOMWrapCtxtPtr ctxt; /* the optional context for custom processing */ + int n_ctxt; + xmlDocPtr sourceDoc; /* the optional sourceDoc */ + int n_sourceDoc; + xmlNodePtr node; /* the node to start with */ + int n_node; + xmlDocPtr destDoc; /* the destination doc */ + int n_destDoc; + xmlNodePtr destParent; /* the optional new parent of @node in @destDoc */ + int n_destParent; + int options; /* option flags */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlDOMWrapCtxtPtr;n_ctxt++) { + for (n_sourceDoc = 0;n_sourceDoc < gen_nb_xmlDocPtr;n_sourceDoc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_destDoc = 0;n_destDoc < gen_nb_xmlDocPtr;n_destDoc++) { + for (n_destParent = 0;n_destParent < gen_nb_xmlNodePtr;n_destParent++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlDOMWrapCtxtPtr(n_ctxt, 0); + sourceDoc = gen_xmlDocPtr(n_sourceDoc, 1); + node = gen_xmlNodePtr(n_node, 2); + destDoc = gen_xmlDocPtr(n_destDoc, 3); + destParent = gen_xmlNodePtr(n_destParent, 4); + options = gen_int(n_options, 5); + + ret_val = xmlDOMWrapAdoptNode(ctxt, sourceDoc, node, destDoc, destParent, options); + if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;} + desret_int(ret_val); + call_tests++; + des_xmlDOMWrapCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_sourceDoc, sourceDoc, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlDocPtr(n_destDoc, destDoc, 3); + des_xmlNodePtr(n_destParent, destParent, 4); + des_int(n_options, options, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDOMWrapAdoptNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_sourceDoc); + printf(" %d", n_node); + printf(" %d", n_destDoc); + printf(" %d", n_destParent); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDOMWrapCloneNode(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDOMWrapCtxtPtr ctxt; /* the optional context for custom processing */ + int n_ctxt; + xmlDocPtr sourceDoc; /* the optional sourceDoc */ + int n_sourceDoc; + xmlNodePtr node; /* the node to start with */ + int n_node; + xmlNodePtr * resNode; /* the clone of the given @node */ + int n_resNode; + xmlDocPtr destDoc; /* the destination doc */ + int n_destDoc; + xmlNodePtr destParent; /* the optional new parent of @node in @destDoc */ + int n_destParent; + int deep; /* descend into child if set */ + int n_deep; + int options; /* option flags */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlDOMWrapCtxtPtr;n_ctxt++) { + for (n_sourceDoc = 0;n_sourceDoc < gen_nb_xmlDocPtr;n_sourceDoc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_resNode = 0;n_resNode < gen_nb_xmlNodePtr_ptr;n_resNode++) { + for (n_destDoc = 0;n_destDoc < gen_nb_xmlDocPtr;n_destDoc++) { + for (n_destParent = 0;n_destParent < gen_nb_xmlNodePtr;n_destParent++) { + for (n_deep = 0;n_deep < gen_nb_int;n_deep++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlDOMWrapCtxtPtr(n_ctxt, 0); + sourceDoc = gen_xmlDocPtr(n_sourceDoc, 1); + node = gen_xmlNodePtr(n_node, 2); + resNode = gen_xmlNodePtr_ptr(n_resNode, 3); + destDoc = gen_xmlDocPtr(n_destDoc, 4); + destParent = gen_xmlNodePtr(n_destParent, 5); + deep = gen_int(n_deep, 6); + options = gen_int(n_options, 7); + + ret_val = xmlDOMWrapCloneNode(ctxt, sourceDoc, node, resNode, destDoc, destParent, deep, options); + desret_int(ret_val); + call_tests++; + des_xmlDOMWrapCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_sourceDoc, sourceDoc, 1); + des_xmlNodePtr(n_node, node, 2); + des_xmlNodePtr_ptr(n_resNode, resNode, 3); + des_xmlDocPtr(n_destDoc, destDoc, 4); + des_xmlNodePtr(n_destParent, destParent, 5); + des_int(n_deep, deep, 6); + des_int(n_options, options, 7); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDOMWrapCloneNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_sourceDoc); + printf(" %d", n_node); + printf(" %d", n_resNode); + printf(" %d", n_destDoc); + printf(" %d", n_destParent); + printf(" %d", n_deep); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDOMWrapNewCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlDOMWrapReconcileNamespaces(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDOMWrapCtxtPtr ctxt; /* DOM wrapper context, unused at the moment */ + int n_ctxt; + xmlNodePtr elem; /* the element-node */ + int n_elem; + int options; /* option flags */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlDOMWrapCtxtPtr;n_ctxt++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlDOMWrapCtxtPtr(n_ctxt, 0); + elem = gen_xmlNodePtr(n_elem, 1); + options = gen_int(n_options, 2); + + ret_val = xmlDOMWrapReconcileNamespaces(ctxt, elem, options); + desret_int(ret_val); + call_tests++; + des_xmlDOMWrapCtxtPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_elem, elem, 1); + des_int(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDOMWrapReconcileNamespaces", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_elem); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDOMWrapRemoveNode(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDOMWrapCtxtPtr ctxt; /* a DOM wrapper context */ + int n_ctxt; + xmlDocPtr doc; /* the doc */ + int n_doc; + xmlNodePtr node; /* the node to be removed. */ + int n_node; + int options; /* set of options, unused at the moment */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlDOMWrapCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlDOMWrapCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + node = gen_xmlNodePtr(n_node, 2); + options = gen_int(n_options, 3); + + ret_val = xmlDOMWrapRemoveNode(ctxt, doc, node, options); + desret_int(ret_val); + call_tests++; + des_xmlDOMWrapCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_node, node, 2); + des_int(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDOMWrapRemoveNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_node); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDocCopyNode(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the node */ + int n_node; + xmlDocPtr doc; /* the document */ + int n_doc; + int extended; /* if 1 do a recursive copy (properties, namespaces and children when applicable) if 2 copy properties and namespaces (when applicable) */ + int n_extended; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_extended = 0;n_extended < gen_nb_int;n_extended++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + doc = gen_xmlDocPtr(n_doc, 1); + extended = gen_int(n_extended, 2); + + ret_val = xmlDocCopyNode(node, doc, extended); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_int(n_extended, extended, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocCopyNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_doc); + printf(" %d", n_extended); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDocCopyNodeList(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the target document */ + int n_doc; + xmlNodePtr node; /* the first node in the list. */ + int n_node; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlDocCopyNodeList(doc, node); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocCopyNodeList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDocDump(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + FILE * f; /* the FILE* */ + int n_f; + xmlDocPtr cur; /* the document */ + int n_cur; + + for (n_f = 0;n_f < gen_nb_FILE_ptr;n_f++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + mem_base = xmlMemBlocks(); + f = gen_FILE_ptr(n_f, 0); + cur = gen_xmlDocPtr(n_cur, 1); + + ret_val = xmlDocDump(f, cur); + desret_int(ret_val); + call_tests++; + des_FILE_ptr(n_f, f, 0); + des_xmlDocPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_f); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDocDumpFormatMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlDocPtr cur; /* the document */ + int n_cur; + xmlChar ** mem; /* OUT: the memory pointer */ + int n_mem; + int * size; /* OUT: the memory length */ + int n_size; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_mem = 0;n_mem < gen_nb_xmlChar_ptr_ptr;n_mem++) { + for (n_size = 0;n_size < gen_nb_int_ptr;n_size++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlDocPtr(n_cur, 0); + mem = gen_xmlChar_ptr_ptr(n_mem, 1); + size = gen_int_ptr(n_size, 2); + format = gen_int(n_format, 3); + + xmlDocDumpFormatMemory(cur, mem, size, format); + call_tests++; + des_xmlDocPtr(n_cur, cur, 0); + des_xmlChar_ptr_ptr(n_mem, mem, 1); + des_int_ptr(n_size, size, 2); + des_int(n_format, format, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocDumpFormatMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_mem); + printf(" %d", n_size); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDocDumpFormatMemoryEnc(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlDocPtr out_doc; /* Document to generate XML text from */ + int n_out_doc; + xmlChar ** doc_txt_ptr; /* Memory pointer for allocated XML text */ + int n_doc_txt_ptr; + int * doc_txt_len; /* Length of the generated XML text */ + int n_doc_txt_len; + char * txt_encoding; /* Character encoding to use when generating XML text */ + int n_txt_encoding; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_out_doc = 0;n_out_doc < gen_nb_xmlDocPtr;n_out_doc++) { + for (n_doc_txt_ptr = 0;n_doc_txt_ptr < gen_nb_xmlChar_ptr_ptr;n_doc_txt_ptr++) { + for (n_doc_txt_len = 0;n_doc_txt_len < gen_nb_int_ptr;n_doc_txt_len++) { + for (n_txt_encoding = 0;n_txt_encoding < gen_nb_const_char_ptr;n_txt_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + out_doc = gen_xmlDocPtr(n_out_doc, 0); + doc_txt_ptr = gen_xmlChar_ptr_ptr(n_doc_txt_ptr, 1); + doc_txt_len = gen_int_ptr(n_doc_txt_len, 2); + txt_encoding = gen_const_char_ptr(n_txt_encoding, 3); + format = gen_int(n_format, 4); + + xmlDocDumpFormatMemoryEnc(out_doc, doc_txt_ptr, doc_txt_len, (const char *)txt_encoding, format); + call_tests++; + des_xmlDocPtr(n_out_doc, out_doc, 0); + des_xmlChar_ptr_ptr(n_doc_txt_ptr, doc_txt_ptr, 1); + des_int_ptr(n_doc_txt_len, doc_txt_len, 2); + des_const_char_ptr(n_txt_encoding, (const char *)txt_encoding, 3); + des_int(n_format, format, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocDumpFormatMemoryEnc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out_doc); + printf(" %d", n_doc_txt_ptr); + printf(" %d", n_doc_txt_len); + printf(" %d", n_txt_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDocDumpMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlDocPtr cur; /* the document */ + int n_cur; + xmlChar ** mem; /* OUT: the memory pointer */ + int n_mem; + int * size; /* OUT: the memory length */ + int n_size; + + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_mem = 0;n_mem < gen_nb_xmlChar_ptr_ptr;n_mem++) { + for (n_size = 0;n_size < gen_nb_int_ptr;n_size++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlDocPtr(n_cur, 0); + mem = gen_xmlChar_ptr_ptr(n_mem, 1); + size = gen_int_ptr(n_size, 2); + + xmlDocDumpMemory(cur, mem, size); + call_tests++; + des_xmlDocPtr(n_cur, cur, 0); + des_xmlChar_ptr_ptr(n_mem, mem, 1); + des_int_ptr(n_size, size, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocDumpMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_mem); + printf(" %d", n_size); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDocDumpMemoryEnc(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlDocPtr out_doc; /* Document to generate XML text from */ + int n_out_doc; + xmlChar ** doc_txt_ptr; /* Memory pointer for allocated XML text */ + int n_doc_txt_ptr; + int * doc_txt_len; /* Length of the generated XML text */ + int n_doc_txt_len; + char * txt_encoding; /* Character encoding to use when generating XML text */ + int n_txt_encoding; + + for (n_out_doc = 0;n_out_doc < gen_nb_xmlDocPtr;n_out_doc++) { + for (n_doc_txt_ptr = 0;n_doc_txt_ptr < gen_nb_xmlChar_ptr_ptr;n_doc_txt_ptr++) { + for (n_doc_txt_len = 0;n_doc_txt_len < gen_nb_int_ptr;n_doc_txt_len++) { + for (n_txt_encoding = 0;n_txt_encoding < gen_nb_const_char_ptr;n_txt_encoding++) { + mem_base = xmlMemBlocks(); + out_doc = gen_xmlDocPtr(n_out_doc, 0); + doc_txt_ptr = gen_xmlChar_ptr_ptr(n_doc_txt_ptr, 1); + doc_txt_len = gen_int_ptr(n_doc_txt_len, 2); + txt_encoding = gen_const_char_ptr(n_txt_encoding, 3); + + xmlDocDumpMemoryEnc(out_doc, doc_txt_ptr, doc_txt_len, (const char *)txt_encoding); + call_tests++; + des_xmlDocPtr(n_out_doc, out_doc, 0); + des_xmlChar_ptr_ptr(n_doc_txt_ptr, doc_txt_ptr, 1); + des_int_ptr(n_doc_txt_len, doc_txt_len, 2); + des_const_char_ptr(n_txt_encoding, (const char *)txt_encoding, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocDumpMemoryEnc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out_doc); + printf(" %d", n_doc_txt_ptr); + printf(" %d", n_doc_txt_len); + printf(" %d", n_txt_encoding); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDocFormatDump(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + FILE * f; /* the FILE* */ + int n_f; + xmlDocPtr cur; /* the document */ + int n_cur; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_f = 0;n_f < gen_nb_FILE_ptr;n_f++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + f = gen_FILE_ptr(n_f, 0); + cur = gen_xmlDocPtr(n_cur, 1); + format = gen_int(n_format, 2); + + ret_val = xmlDocFormatDump(f, cur, format); + desret_int(ret_val); + call_tests++; + des_FILE_ptr(n_f, f, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_int(n_format, format, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocFormatDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_f); + printf(" %d", n_cur); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlDocGetRootElement(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + + ret_val = xmlDocGetRootElement((const xmlDoc *)doc); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocGetRootElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlDocSetRootElement(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr root; /* the new document root element, if root is NULL no action is taken, to remove a node from a document use xmlUnlinkNode(root) instead. */ + int n_root; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_root = 0;n_root < gen_nb_xmlNodePtr_in;n_root++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + root = gen_xmlNodePtr_in(n_root, 1); + + ret_val = xmlDocSetRootElement(doc, root); + if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr_in(n_root, root, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDocSetRootElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_root); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlElemDump(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + FILE * f; /* the FILE * for the output */ + int n_f; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + + for (n_f = 0;n_f < gen_nb_FILE_ptr;n_f++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + f = gen_FILE_ptr(n_f, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + + xmlElemDump(f, doc, cur); + call_tests++; + des_FILE_ptr(n_f, f, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlElemDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_f); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlFirstElementChild(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + + ret_val = xmlFirstElementChild(parent); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlFirstElementChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlGetBufferAllocationScheme(void) { + int test_ret = 0; + + int mem_base; + xmlBufferAllocationScheme ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlGetBufferAllocationScheme(); + desret_xmlBufferAllocationScheme(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetBufferAllocationScheme", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetCompressMode(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlGetCompressMode(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetCompressMode", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetDocCompressMode(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + + ret_val = xmlGetDocCompressMode((const xmlDoc *)doc); + desret_int(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDocCompressMode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetIntSubset(void) { + int test_ret = 0; + + int mem_base; + xmlDtdPtr ret_val; + xmlDoc * doc; /* the document pointer */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + + ret_val = xmlGetIntSubset((const xmlDoc *)doc); + desret_xmlDtdPtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetIntSubset", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetLastChild(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNode * parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_const_xmlNode_ptr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_const_xmlNode_ptr(n_parent, 0); + + ret_val = xmlGetLastChild((const xmlNode *)parent); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_parent, (const xmlNode *)parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetLastChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetLineNo(void) { + int test_ret = 0; + + int mem_base; + long ret_val; + xmlNode * node; /* valid node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + + ret_val = xmlGetLineNo((const xmlNode *)node); + desret_long(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetLineNo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetNoNsProp(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlNode * node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name */ + int n_name; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlGetNoNsProp((const xmlNode *)node, (const xmlChar *)name); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetNoNsProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetNodePath(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlNode * node; /* a node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + + ret_val = xmlGetNodePath((const xmlNode *)node); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetNodePath", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlGetNsList(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlGetNsProp(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlNode * node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * nameSpace; /* the URI of the namespace */ + int n_nameSpace; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_nameSpace = 0;n_nameSpace < gen_nb_const_xmlChar_ptr;n_nameSpace++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + nameSpace = gen_const_xmlChar_ptr(n_nameSpace, 2); + + ret_val = xmlGetNsProp((const xmlNode *)node, (const xmlChar *)name, (const xmlChar *)nameSpace); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_nameSpace, (const xmlChar *)nameSpace, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetNsProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf(" %d", n_nameSpace); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetProp(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlNode * node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name */ + int n_name; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlGetProp((const xmlNode *)node, (const xmlChar *)name); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHasNsProp(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlNode * node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * nameSpace; /* the URI of the namespace */ + int n_nameSpace; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_nameSpace = 0;n_nameSpace < gen_nb_const_xmlChar_ptr;n_nameSpace++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + nameSpace = gen_const_xmlChar_ptr(n_nameSpace, 2); + + ret_val = xmlHasNsProp((const xmlNode *)node, (const xmlChar *)name, (const xmlChar *)nameSpace); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_nameSpace, (const xmlChar *)nameSpace, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHasNsProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf(" %d", n_nameSpace); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHasProp(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlNode * node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name */ + int n_name; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlHasProp((const xmlNode *)node, (const xmlChar *)name); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHasProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsBlankNode(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlNode * node; /* the node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + + ret_val = xmlIsBlankNode((const xmlNode *)node); + desret_int(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsBlankNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsXHTML(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * systemID; /* the system identifier */ + int n_systemID; + xmlChar * publicID; /* the public identifier */ + int n_publicID; + + for (n_systemID = 0;n_systemID < gen_nb_const_xmlChar_ptr;n_systemID++) { + for (n_publicID = 0;n_publicID < gen_nb_const_xmlChar_ptr;n_publicID++) { + mem_base = xmlMemBlocks(); + systemID = gen_const_xmlChar_ptr(n_systemID, 0); + publicID = gen_const_xmlChar_ptr(n_publicID, 1); + + ret_val = xmlIsXHTML((const xmlChar *)systemID, (const xmlChar *)publicID); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_systemID, (const xmlChar *)systemID, 0); + des_const_xmlChar_ptr(n_publicID, (const xmlChar *)publicID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsXHTML", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_systemID); + printf(" %d", n_publicID); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlLastElementChild(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + + ret_val = xmlLastElementChild(parent); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlLastElementChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewCDataBlock(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * content; /* the CDATA block content content */ + int n_content; + int len; /* the length of the block */ + int n_len; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + len = gen_int(n_len, 2); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + ret_val = xmlNewCDataBlock(doc, (const xmlChar *)content, len); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewCDataBlock", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewCharRef(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the char ref string, starting with # or "&# ... ;" */ + int n_name; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlNewCharRef(doc, (const xmlChar *)name); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewCharRef", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewChild(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + xmlNsPtr ns; /* a namespace if any */ + int n_ns; + xmlChar * name; /* the name of the child */ + int n_name; + xmlChar * content; /* the XML content of the child if any. */ + int n_content; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + content = gen_const_xmlChar_ptr(n_content, 3); + + ret_val = xmlNewChild(parent, ns, (const xmlChar *)name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlNewComment(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlChar * content; /* the comment content */ + int n_content; + + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + content = gen_const_xmlChar_ptr(n_content, 0); + + ret_val = xmlNewComment((const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewComment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_content); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDoc(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + xmlChar * version; /* xmlChar string giving the version of XML "1.0" */ + int n_version; + + for (n_version = 0;n_version < gen_nb_const_xmlChar_ptr;n_version++) { + mem_base = xmlMemBlocks(); + version = gen_const_xmlChar_ptr(n_version, 0); + + ret_val = xmlNewDoc((const xmlChar *)version); + desret_xmlDocPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_version, (const xmlChar *)version, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_version); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocComment(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * content; /* the comment content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlNewDocComment(doc, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocComment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocFragment(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document owning the fragment */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + + ret_val = xmlNewDocFragment(doc); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocFragment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewDocNode(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNsPtr ns; /* namespace if any */ + int n_ns; + xmlChar * name; /* the node name */ + int n_name; + xmlChar * content; /* the XML text content if any */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + content = gen_const_xmlChar_ptr(n_content, 3); + + ret_val = xmlNewDocNode(doc, ns, (const xmlChar *)name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocNodeEatName(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNsPtr ns; /* namespace if any */ + int n_ns; + xmlChar * name; /* the node name */ + int n_name; + xmlChar * content; /* the XML text content if any */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_eaten_name;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_eaten_name(n_name, 2); + content = gen_const_xmlChar_ptr(n_content, 3); + + ret_val = xmlNewDocNodeEatName(doc, ns, name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_eaten_name(n_name, name, 2); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocNodeEatName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocPI(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the target document */ + int n_doc; + xmlChar * name; /* the processing instruction name */ + int n_name; + xmlChar * content; /* the PI content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + content = gen_const_xmlChar_ptr(n_content, 2); + + ret_val = xmlNewDocPI(doc, (const xmlChar *)name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocPI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocProp(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the name of the attribute */ + int n_name; + xmlChar * value; /* the value of the attribute */ + int n_value; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + value = gen_const_xmlChar_ptr(n_value, 2); + + ret_val = xmlNewDocProp(doc, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocRawNode(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNsPtr ns; /* namespace if any */ + int n_ns; + xmlChar * name; /* the node name */ + int n_name; + xmlChar * content; /* the text content if any */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + content = gen_const_xmlChar_ptr(n_content, 3); + + ret_val = xmlNewDocRawNode(doc, ns, (const xmlChar *)name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocRawNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlNewDocText(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + xmlChar * content; /* the text content */ + int n_content; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlNewDocText((const xmlDoc *)doc, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocText", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocTextLen(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * content; /* the text content */ + int n_content; + int len; /* the text len. */ + int n_len; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + len = gen_int(n_len, 2); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + ret_val = xmlNewDocTextLen(doc, (const xmlChar *)content, len); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocTextLen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDtd(void) { + int test_ret = 0; + + int mem_base; + xmlDtdPtr ret_val; + xmlDocPtr doc; /* the document pointer */ + int n_doc; + xmlChar * name; /* the DTD name */ + int n_name; + xmlChar * ExternalID; /* the external ID */ + int n_ExternalID; + xmlChar * SystemID; /* the system ID */ + int n_SystemID; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); + + ret_val = xmlNewDtd(doc, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + desret_xmlDtdPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDtd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewNode(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNsPtr ns; /* namespace if any */ + int n_ns; + xmlChar * name; /* the node name */ + int n_name; + + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + ns = gen_xmlNsPtr(n_ns, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlNewNode(ns, (const xmlChar *)name); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNsPtr(n_ns, ns, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ns); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewNodeEatName(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNsPtr ns; /* namespace if any */ + int n_ns; + xmlChar * name; /* the node name */ + int n_name; + + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_eaten_name;n_name++) { + mem_base = xmlMemBlocks(); + ns = gen_xmlNsPtr(n_ns, 0); + name = gen_eaten_name(n_name, 1); + + ret_val = xmlNewNodeEatName(ns, name); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNsPtr(n_ns, ns, 0); + des_eaten_name(n_name, name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewNodeEatName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ns); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewNs(void) { + int test_ret = 0; + + int mem_base; + xmlNsPtr ret_val; + xmlNodePtr node; /* the element carrying the namespace */ + int n_node; + xmlChar * href; /* the URI associated */ + int n_href; + xmlChar * prefix; /* the prefix for the namespace */ + int n_prefix; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_href = 0;n_href < gen_nb_const_xmlChar_ptr;n_href++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + href = gen_const_xmlChar_ptr(n_href, 1); + prefix = gen_const_xmlChar_ptr(n_prefix, 2); + + ret_val = xmlNewNs(node, (const xmlChar *)href, (const xmlChar *)prefix); + if ((node == NULL) && (ret_val != NULL)) xmlFreeNs(ret_val); + desret_xmlNsPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_xmlChar_ptr(n_href, (const xmlChar *)href, 1); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_href); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewNsProp(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr node; /* the holding node */ + int n_node; + xmlNsPtr ns; /* the namespace */ + int n_ns; + xmlChar * name; /* the name of the attribute */ + int n_name; + xmlChar * value; /* the value of the attribute */ + int n_value; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + value = gen_const_xmlChar_ptr(n_value, 3); + + ret_val = xmlNewNsProp(node, ns, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewNsProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewNsPropEatName(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr node; /* the holding node */ + int n_node; + xmlNsPtr ns; /* the namespace */ + int n_ns; + xmlChar * name; /* the name of the attribute */ + int n_name; + xmlChar * value; /* the value of the attribute */ + int n_value; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_eaten_name;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_eaten_name(n_name, 2); + value = gen_const_xmlChar_ptr(n_value, 3); + + ret_val = xmlNewNsPropEatName(node, ns, name, (const xmlChar *)value); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_eaten_name(n_name, name, 2); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewNsPropEatName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewPI(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlChar * name; /* the processing instruction name */ + int n_name; + xmlChar * content; /* the PI content */ + int n_content; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlNewPI((const xmlChar *)name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewPI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewProp(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr node; /* the holding node */ + int n_node; + xmlChar * name; /* the name of the attribute */ + int n_name; + xmlChar * value; /* the value of the attribute */ + int n_value; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + value = gen_const_xmlChar_ptr(n_value, 2); + + ret_val = xmlNewProp(node, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlNewReference(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + xmlChar * name; /* the reference name, or the reference string with & and ; */ + int n_name; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlNewReference((const xmlDoc *)doc, (const xmlChar *)name); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewReference", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewText(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlChar * content; /* the text content */ + int n_content; + + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + content = gen_const_xmlChar_ptr(n_content, 0); + + ret_val = xmlNewText((const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewText", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_content); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewTextChild(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr parent; /* the parent node */ + int n_parent; + xmlNsPtr ns; /* a namespace if any */ + int n_ns; + xmlChar * name; /* the name of the child */ + int n_name; + xmlChar * content; /* the text content of the child if any. */ + int n_content; + + for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + parent = gen_xmlNodePtr(n_parent, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + content = gen_const_xmlChar_ptr(n_content, 3); + + ret_val = xmlNewTextChild(parent, ns, (const xmlChar *)name, (const xmlChar *)content); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_parent, parent, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_parent); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlNewTextLen(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlChar * content; /* the text content */ + int n_content; + int len; /* the text len. */ + int n_len; + + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + content = gen_const_xmlChar_ptr(n_content, 0); + len = gen_int(n_len, 1); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + ret_val = xmlNewTextLen((const xmlChar *)content, len); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextLen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNextElementSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the current node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlNextElementSibling(node); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNextElementSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeAddContent(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr cur; /* the node being modified */ + int n_cur; + xmlChar * content; /* extra content */ + int n_content; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + xmlNodeAddContent(cur, (const xmlChar *)content); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeAddContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeAddContentLen(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr cur; /* the node being modified */ + int n_cur; + xmlChar * content; /* extra content */ + int n_content; + int len; /* the size of @content */ + int n_len; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + len = gen_int(n_len, 2); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + xmlNodeAddContentLen(cur, (const xmlChar *)content, len); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeAddContentLen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeBufGetContent(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlBufferPtr buffer; /* a buffer */ + int n_buffer; + xmlNode * cur; /* the node being read */ + int n_cur; + + for (n_buffer = 0;n_buffer < gen_nb_xmlBufferPtr;n_buffer++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + buffer = gen_xmlBufferPtr(n_buffer, 0); + cur = gen_const_xmlNode_ptr(n_cur, 1); + + ret_val = xmlNodeBufGetContent(buffer, (const xmlNode *)cur); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buffer, buffer, 0); + des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeBufGetContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeDump(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + int level; /* the imbrication level for indenting */ + int n_level; + int format; /* is formatting allowed */ + int n_format; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_level = 0;n_level < gen_nb_int;n_level++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + level = gen_int(n_level, 3); + format = gen_int(n_format, 4); + + ret_val = xmlNodeDump(buf, doc, cur, level, format); + desret_int(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + des_int(n_level, level, 3); + des_int(n_format, format, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf(" %d", n_level); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeDumpOutput(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr cur; /* the current node */ + int n_cur; + int level; /* the imbrication level for indenting */ + int n_level; + int format; /* is formatting allowed */ + int n_format; + char * encoding; /* an optional encoding string */ + int n_encoding; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_level = 0;n_level < gen_nb_int;n_level++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + doc = gen_xmlDocPtr(n_doc, 1); + cur = gen_xmlNodePtr(n_cur, 2); + level = gen_int(n_level, 3); + format = gen_int(n_format, 4); + encoding = gen_const_char_ptr(n_encoding, 5); + + xmlNodeDumpOutput(buf, doc, cur, level, format, (const char *)encoding); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_cur, cur, 2); + des_int(n_level, level, 3); + des_int(n_format, format, 4); + des_const_char_ptr(n_encoding, (const char *)encoding, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeDumpOutput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_doc); + printf(" %d", n_cur); + printf(" %d", n_level); + printf(" %d", n_format); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeGetBase(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlDoc * doc; /* the document the node pertains to */ + int n_doc; + xmlNode * cur; /* the node being checked */ + int n_cur; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + cur = gen_const_xmlNode_ptr(n_cur, 1); + + ret_val = xmlNodeGetBase((const xmlDoc *)doc, (const xmlNode *)cur); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeGetBase", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeGetContent(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlNode * cur; /* the node being read */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlNode_ptr(n_cur, 0); + + ret_val = xmlNodeGetContent((const xmlNode *)cur); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeGetContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeGetLang(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlNode * cur; /* the node being checked */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlNode_ptr(n_cur, 0); + + ret_val = xmlNodeGetLang((const xmlNode *)cur); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeGetLang", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeGetSpacePreserve(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlNode * cur; /* the node being checked */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlNode_ptr(n_cur, 0); + + ret_val = xmlNodeGetSpacePreserve((const xmlNode *)cur); + desret_int(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeGetSpacePreserve", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeIsText(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlNode * node; /* the node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + + ret_val = xmlNodeIsText((const xmlNode *)node); + desret_int(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeIsText", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeListGetRawString(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + xmlNode * list; /* a Node list */ + int n_list; + int inLine; /* should we replace entity contents or show their external form */ + int n_inLine; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_list = 0;n_list < gen_nb_const_xmlNode_ptr;n_list++) { + for (n_inLine = 0;n_inLine < gen_nb_int;n_inLine++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + list = gen_const_xmlNode_ptr(n_list, 1); + inLine = gen_int(n_inLine, 2); + + ret_val = xmlNodeListGetRawString((const xmlDoc *)doc, (const xmlNode *)list, inLine); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlNode_ptr(n_list, (const xmlNode *)list, 1); + des_int(n_inLine, inLine, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeListGetRawString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_list); + printf(" %d", n_inLine); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeListGetString(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNode * list; /* a Node list */ + int n_list; + int inLine; /* should we replace entity contents or show their external form */ + int n_inLine; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_list = 0;n_list < gen_nb_const_xmlNode_ptr;n_list++) { + for (n_inLine = 0;n_inLine < gen_nb_int;n_inLine++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + list = gen_const_xmlNode_ptr(n_list, 1); + inLine = gen_int(n_inLine, 2); + + ret_val = xmlNodeListGetString(doc, (const xmlNode *)list, inLine); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlNode_ptr(n_list, (const xmlNode *)list, 1); + des_int(n_inLine, inLine, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeListGetString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_list); + printf(" %d", n_inLine); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeSetBase(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + xmlNodePtr cur; /* the node being changed */ + int n_cur; + xmlChar * uri; /* the new base URI */ + int n_uri; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_uri = 0;n_uri < gen_nb_const_xmlChar_ptr;n_uri++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + uri = gen_const_xmlChar_ptr(n_uri, 1); + + xmlNodeSetBase(cur, (const xmlChar *)uri); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_uri, (const xmlChar *)uri, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeSetBase", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_uri); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeSetContent(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr cur; /* the node being modified */ + int n_cur; + xmlChar * content; /* the new value of the content */ + int n_content; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + xmlNodeSetContent(cur, (const xmlChar *)content); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeSetContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNodeSetContentLen(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr cur; /* the node being modified */ + int n_cur; + xmlChar * content; /* the new value of the content */ + int n_content; + int len; /* the size of @content */ + int n_len; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + len = gen_int(n_len, 2); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + xmlNodeSetContentLen(cur, (const xmlChar *)content, len); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeSetContentLen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeSetLang(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr cur; /* the node being changed */ + int n_cur; + xmlChar * lang; /* the language description */ + int n_lang; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_lang = 0;n_lang < gen_nb_const_xmlChar_ptr;n_lang++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + lang = gen_const_xmlChar_ptr(n_lang, 1); + + xmlNodeSetLang(cur, (const xmlChar *)lang); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_lang, (const xmlChar *)lang, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeSetLang", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_lang); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeSetName(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr cur; /* the node being changed */ + int n_cur; + xmlChar * name; /* the new tag name */ + int n_name; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + xmlNodeSetName(cur, (const xmlChar *)name); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeSetName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNodeSetSpacePreserve(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr cur; /* the node being changed */ + int n_cur; + int val; /* the xml:space value ("0": default, 1: "preserve") */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodePtr(n_cur, 0); + val = gen_int(n_val, 1); + + xmlNodeSetSpacePreserve(cur, val); + call_tests++; + des_xmlNodePtr(n_cur, cur, 0); + des_int(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeSetSpacePreserve", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlPreviousElementSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr node; /* the current node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlPreviousElementSibling(node); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPreviousElementSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReconciliateNs(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr tree; /* a node defining the subtree to reconciliate */ + int n_tree; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + tree = gen_xmlNodePtr(n_tree, 1); + + ret_val = xmlReconciliateNs(doc, tree); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_tree, tree, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReconciliateNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_tree); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlRemoveProp(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlAttrPtr cur; /* an attribute */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_xmlAttrPtr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlAttrPtr(n_cur, 0); + + ret_val = xmlRemoveProp(cur); + cur = NULL; + desret_int(ret_val); + call_tests++; + des_xmlAttrPtr(n_cur, cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRemoveProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlReplaceNode(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr old; /* the old node */ + int n_old; + xmlNodePtr cur; /* the node */ + int n_cur; + + for (n_old = 0;n_old < gen_nb_xmlNodePtr;n_old++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) { + mem_base = xmlMemBlocks(); + old = gen_xmlNodePtr(n_old, 0); + cur = gen_xmlNodePtr_in(n_cur, 1); + + ret_val = xmlReplaceNode(old, cur); + if (cur != NULL) { + xmlUnlinkNode(cur); + xmlFreeNode(cur) ; cur = NULL ; } + if (old != NULL) { + xmlUnlinkNode(old); + xmlFreeNode(old) ; old = NULL ; } + ret_val = NULL; + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr(n_old, old, 0); + des_xmlNodePtr_in(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReplaceNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_old); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFile(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename (or URL) */ + int n_filename; + xmlDocPtr cur; /* the document */ + int n_cur; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + + ret_val = xmlSaveFile(filename, cur); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFileEnc(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename (or URL) */ + int n_filename; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the name of an encoding (or NULL) */ + int n_encoding; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + + ret_val = xmlSaveFileEnc(filename, cur, (const char *)encoding); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFileEnc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFileTo(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlOutputBufferPtr buf; /* an output I/O buffer */ + int n_buf; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the encoding if any assuming the I/O layer handles the transcoding */ + int n_encoding; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + + ret_val = xmlSaveFileTo(buf, cur, (const char *)encoding); + buf = NULL; + desret_int(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFileTo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFormatFile(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename (or URL) */ + int n_filename; + xmlDocPtr cur; /* the document */ + int n_cur; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + format = gen_int(n_format, 2); + + ret_val = xmlSaveFormatFile(filename, cur, format); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_int(n_format, format, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFormatFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFormatFileEnc(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the filename or URL to output */ + int n_filename; + xmlDocPtr cur; /* the document being saved */ + int n_cur; + char * encoding; /* the name of the encoding to use or NULL. */ + int n_encoding; + int format; /* should formatting spaces be added. */ + int n_format; + + for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + filename = gen_fileoutput(n_filename, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + format = gen_int(n_format, 3); + + ret_val = xmlSaveFormatFileEnc(filename, cur, (const char *)encoding, format); + desret_int(ret_val); + call_tests++; + des_fileoutput(n_filename, filename, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_int(n_format, format, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFormatFileEnc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFormatFileTo(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlOutputBufferPtr buf; /* an output I/O buffer */ + int n_buf; + xmlDocPtr cur; /* the document */ + int n_cur; + char * encoding; /* the encoding if any assuming the I/O layer handles the transcoding */ + int n_encoding; + int format; /* should formatting spaces been added */ + int n_format; + + for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { + for (n_cur = 0;n_cur < gen_nb_xmlDocPtr;n_cur++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_format = 0;n_format < gen_nb_int;n_format++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlOutputBufferPtr(n_buf, 0); + cur = gen_xmlDocPtr(n_cur, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + format = gen_int(n_format, 3); + + ret_val = xmlSaveFormatFileTo(buf, cur, (const char *)encoding, format); + buf = NULL; + desret_int(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_buf, buf, 0); + des_xmlDocPtr(n_cur, cur, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_int(n_format, format, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFormatFileTo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_cur); + printf(" %d", n_encoding); + printf(" %d", n_format); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSearchNs(void) { + int test_ret = 0; + + int mem_base; + xmlNsPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr node; /* the current node */ + int n_node; + xmlChar * nameSpace; /* the namespace prefix */ + int n_nameSpace; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_nameSpace = 0;n_nameSpace < gen_nb_const_xmlChar_ptr;n_nameSpace++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + node = gen_xmlNodePtr(n_node, 1); + nameSpace = gen_const_xmlChar_ptr(n_nameSpace, 2); + + ret_val = xmlSearchNs(doc, node, (const xmlChar *)nameSpace); + desret_xmlNsPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_node, node, 1); + des_const_xmlChar_ptr(n_nameSpace, (const xmlChar *)nameSpace, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSearchNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_node); + printf(" %d", n_nameSpace); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSearchNsByHref(void) { + int test_ret = 0; + + int mem_base; + xmlNsPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr node; /* the current node */ + int n_node; + xmlChar * href; /* the namespace value */ + int n_href; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_href = 0;n_href < gen_nb_const_xmlChar_ptr;n_href++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + node = gen_xmlNodePtr(n_node, 1); + href = gen_const_xmlChar_ptr(n_href, 2); + + ret_val = xmlSearchNsByHref(doc, node, (const xmlChar *)href); + desret_xmlNsPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_node, node, 1); + des_const_xmlChar_ptr(n_href, (const xmlChar *)href, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSearchNsByHref", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_node); + printf(" %d", n_href); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetBufferAllocationScheme(void) { + int test_ret = 0; + + int mem_base; + xmlBufferAllocationScheme scheme; /* allocation method to use */ + int n_scheme; + + for (n_scheme = 0;n_scheme < gen_nb_xmlBufferAllocationScheme;n_scheme++) { + mem_base = xmlMemBlocks(); + scheme = gen_xmlBufferAllocationScheme(n_scheme, 0); + + xmlSetBufferAllocationScheme(scheme); + call_tests++; + des_xmlBufferAllocationScheme(n_scheme, scheme, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetBufferAllocationScheme", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_scheme); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetCompressMode(void) { + int test_ret = 0; + + int mem_base; + int mode; /* the compression ratio */ + int n_mode; + + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { + mem_base = xmlMemBlocks(); + mode = gen_int(n_mode, 0); + + xmlSetCompressMode(mode); + call_tests++; + des_int(n_mode, mode, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetCompressMode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_mode); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetDocCompressMode(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr doc; /* the document */ + int n_doc; + int mode; /* the compression ratio */ + int n_mode; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_mode = 0;n_mode < gen_nb_int;n_mode++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + mode = gen_int(n_mode, 1); + + xmlSetDocCompressMode(doc, mode); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_int(n_mode, mode, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetDocCompressMode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_mode); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetNs(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr node; /* a node in the document */ + int n_node; + xmlNsPtr ns; /* a namespace pointer */ + int n_ns; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + ns = gen_xmlNsPtr(n_ns, 1); + + xmlSetNs(node, ns); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlNsPtr(n_ns, ns, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_ns); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetNsProp(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr node; /* the node */ + int n_node; + xmlNsPtr ns; /* the namespace definition */ + int n_ns; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * value; /* the attribute value */ + int n_value; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + value = gen_const_xmlChar_ptr(n_value, 3); + + ret_val = xmlSetNsProp(node, ns, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetNsProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_ns); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSetProp(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) + int mem_base; + xmlAttrPtr ret_val; + xmlNodePtr node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name (a QName) */ + int n_name; + xmlChar * value; /* the attribute value */ + int n_value; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + value = gen_const_xmlChar_ptr(n_value, 2); + + ret_val = xmlSetProp(node, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSetProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSplitQName2(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * name; /* the full QName */ + int n_name; + xmlChar ** prefix; /* a xmlChar ** */ + int n_prefix; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_prefix = 0;n_prefix < gen_nb_xmlChar_ptr_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + prefix = gen_xmlChar_ptr_ptr(n_prefix, 1); + + ret_val = xmlSplitQName2((const xmlChar *)name, prefix); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_xmlChar_ptr_ptr(n_prefix, prefix, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSplitQName2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSplitQName3(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlChar * name; /* the full QName */ + int n_name; + int * len; /* an int * */ + int n_len; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_len = 0;n_len < gen_nb_int_ptr;n_len++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + len = gen_int_ptr(n_len, 1); + + ret_val = xmlSplitQName3((const xmlChar *)name, len); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_int_ptr(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSplitQName3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStringGetNodeList(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + xmlChar * value; /* the value of the attribute */ + int n_value; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + + ret_val = xmlStringGetNodeList((const xmlDoc *)doc, (const xmlChar *)value); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStringGetNodeList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStringLenGetNodeList(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlDoc * doc; /* the document */ + int n_doc; + xmlChar * value; /* the value of the text */ + int n_value; + int len; /* the length of the string value */ + int n_len; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + len = gen_int(n_len, 2); + if ((value != NULL) && + (len > (int) strlen((const char *) value) + 1)) + continue; + + ret_val = xmlStringLenGetNodeList((const xmlDoc *)doc, (const xmlChar *)value, len); + desret_xmlNodePtr(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStringLenGetNodeList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_value); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlTextConcat(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlNodePtr node; /* the node */ + int n_node; + xmlChar * content; /* the content */ + int n_content; + int len; /* @content length */ + int n_len; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + len = gen_int(n_len, 2); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + ret_val = xmlTextConcat(node, (const xmlChar *)content, len); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextConcat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlTextMerge(void) { + int test_ret = 0; + + int mem_base; + xmlNodePtr ret_val; + xmlNodePtr first; /* the first text node */ + int n_first; + xmlNodePtr second; /* the second text node being merged */ + int n_second; + + for (n_first = 0;n_first < gen_nb_xmlNodePtr_in;n_first++) { + for (n_second = 0;n_second < gen_nb_xmlNodePtr_in;n_second++) { + mem_base = xmlMemBlocks(); + first = gen_xmlNodePtr_in(n_first, 0); + second = gen_xmlNodePtr_in(n_second, 1); + + ret_val = xmlTextMerge(first, second); + if ((first != NULL) && (first->type != XML_TEXT_NODE)) { + xmlUnlinkNode(second); + xmlFreeNode(second) ; second = NULL ; } + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlNodePtr_in(n_first, first, 0); + des_xmlNodePtr_in(n_second, second, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextMerge", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_first); + printf(" %d", n_second); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUnsetNsProp(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr node; /* the node */ + int n_node; + xmlNsPtr ns; /* the namespace definition */ + int n_ns; + xmlChar * name; /* the attribute name */ + int n_name; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + ns = gen_xmlNsPtr(n_ns, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + + ret_val = xmlUnsetNsProp(node, ns, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlNsPtr(n_ns, ns, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUnsetNsProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_ns); + printf(" %d", n_name); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUnsetProp(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr node; /* the node */ + int n_node; + xmlChar * name; /* the attribute name */ + int n_name; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlUnsetProp(node, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUnsetProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNCName(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + int ret_val; + xmlChar * value; /* the value to check */ + int n_value; + int space; /* allow spaces in front and end of the string */ + int n_space; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_space = 0;n_space < gen_nb_int;n_space++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + space = gen_int(n_space, 1); + + ret_val = xmlValidateNCName((const xmlChar *)value, space); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_int(n_space, space, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNCName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf(" %d", n_space); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNMToken(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + int ret_val; + xmlChar * value; /* the value to check */ + int n_value; + int space; /* allow spaces in front and end of the string */ + int n_space; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_space = 0;n_space < gen_nb_int;n_space++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + space = gen_int(n_space, 1); + + ret_val = xmlValidateNMToken((const xmlChar *)value, space); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_int(n_space, space, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNMToken", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf(" %d", n_space); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlValidateName(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + int ret_val; + xmlChar * value; /* the value to check */ + int n_value; + int space; /* allow spaces in front and end of the string */ + int n_space; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_space = 0;n_space < gen_nb_int;n_space++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + space = gen_int(n_space, 1); + + ret_val = xmlValidateName((const xmlChar *)value, space); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_int(n_space, space, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf(" %d", n_space); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlValidateQName(void) { + int test_ret = 0; + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_TREE_ENABLED + int mem_base; + int ret_val; + xmlChar * value; /* the value to check */ + int n_value; + int space; /* allow spaces in front and end of the string */ + int n_space; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_space = 0;n_space < gen_nb_int;n_space++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + space = gen_int(n_space, 1); + + ret_val = xmlValidateQName((const xmlChar *)value, space); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_int(n_space, space, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateQName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf(" %d", n_space); + printf("\n"); + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + +static int +test_tree(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing tree : 142 of 164 functions ...\n"); + test_ret += test_xmlAddChild(); + test_ret += test_xmlAddChildList(); + test_ret += test_xmlAddNextSibling(); + test_ret += test_xmlAddPrevSibling(); + test_ret += test_xmlAddSibling(); + test_ret += test_xmlAttrSerializeTxtContent(); + test_ret += test_xmlBufContent(); + test_ret += test_xmlBufEnd(); + test_ret += test_xmlBufGetNodeContent(); + test_ret += test_xmlBufNodeDump(); + test_ret += test_xmlBufShrink(); + test_ret += test_xmlBufUse(); + test_ret += test_xmlBufferAdd(); + test_ret += test_xmlBufferAddHead(); + test_ret += test_xmlBufferCCat(); + test_ret += test_xmlBufferCat(); + test_ret += test_xmlBufferContent(); + test_ret += test_xmlBufferCreate(); + test_ret += test_xmlBufferCreateSize(); + test_ret += test_xmlBufferCreateStatic(); + test_ret += test_xmlBufferDetach(); + test_ret += test_xmlBufferEmpty(); + test_ret += test_xmlBufferGrow(); + test_ret += test_xmlBufferLength(); + test_ret += test_xmlBufferResize(); + test_ret += test_xmlBufferSetAllocationScheme(); + test_ret += test_xmlBufferShrink(); + test_ret += test_xmlBufferWriteCHAR(); + test_ret += test_xmlBufferWriteChar(); + test_ret += test_xmlBufferWriteQuotedString(); + test_ret += test_xmlBuildQName(); + test_ret += test_xmlChildElementCount(); + test_ret += test_xmlCopyDoc(); + test_ret += test_xmlCopyDtd(); + test_ret += test_xmlCopyNamespace(); + test_ret += test_xmlCopyNamespaceList(); + test_ret += test_xmlCopyNode(); + test_ret += test_xmlCopyNodeList(); + test_ret += test_xmlCopyProp(); + test_ret += test_xmlCopyPropList(); + test_ret += test_xmlCreateIntSubset(); + test_ret += test_xmlDOMWrapAdoptNode(); + test_ret += test_xmlDOMWrapCloneNode(); + test_ret += test_xmlDOMWrapNewCtxt(); + test_ret += test_xmlDOMWrapReconcileNamespaces(); + test_ret += test_xmlDOMWrapRemoveNode(); + test_ret += test_xmlDocCopyNode(); + test_ret += test_xmlDocCopyNodeList(); + test_ret += test_xmlDocDump(); + test_ret += test_xmlDocDumpFormatMemory(); + test_ret += test_xmlDocDumpFormatMemoryEnc(); + test_ret += test_xmlDocDumpMemory(); + test_ret += test_xmlDocDumpMemoryEnc(); + test_ret += test_xmlDocFormatDump(); + test_ret += test_xmlDocGetRootElement(); + test_ret += test_xmlDocSetRootElement(); + test_ret += test_xmlElemDump(); + test_ret += test_xmlFirstElementChild(); + test_ret += test_xmlGetBufferAllocationScheme(); + test_ret += test_xmlGetCompressMode(); + test_ret += test_xmlGetDocCompressMode(); + test_ret += test_xmlGetIntSubset(); + test_ret += test_xmlGetLastChild(); + test_ret += test_xmlGetLineNo(); + test_ret += test_xmlGetNoNsProp(); + test_ret += test_xmlGetNodePath(); + test_ret += test_xmlGetNsList(); + test_ret += test_xmlGetNsProp(); + test_ret += test_xmlGetProp(); + test_ret += test_xmlHasNsProp(); + test_ret += test_xmlHasProp(); + test_ret += test_xmlIsBlankNode(); + test_ret += test_xmlIsXHTML(); + test_ret += test_xmlLastElementChild(); + test_ret += test_xmlNewCDataBlock(); + test_ret += test_xmlNewCharRef(); + test_ret += test_xmlNewChild(); + test_ret += test_xmlNewComment(); + test_ret += test_xmlNewDoc(); + test_ret += test_xmlNewDocComment(); + test_ret += test_xmlNewDocFragment(); + test_ret += test_xmlNewDocNode(); + test_ret += test_xmlNewDocNodeEatName(); + test_ret += test_xmlNewDocPI(); + test_ret += test_xmlNewDocProp(); + test_ret += test_xmlNewDocRawNode(); + test_ret += test_xmlNewDocText(); + test_ret += test_xmlNewDocTextLen(); + test_ret += test_xmlNewDtd(); + test_ret += test_xmlNewNode(); + test_ret += test_xmlNewNodeEatName(); + test_ret += test_xmlNewNs(); + test_ret += test_xmlNewNsProp(); + test_ret += test_xmlNewNsPropEatName(); + test_ret += test_xmlNewPI(); + test_ret += test_xmlNewProp(); + test_ret += test_xmlNewReference(); + test_ret += test_xmlNewText(); + test_ret += test_xmlNewTextChild(); + test_ret += test_xmlNewTextLen(); + test_ret += test_xmlNextElementSibling(); + test_ret += test_xmlNodeAddContent(); + test_ret += test_xmlNodeAddContentLen(); + test_ret += test_xmlNodeBufGetContent(); + test_ret += test_xmlNodeDump(); + test_ret += test_xmlNodeDumpOutput(); + test_ret += test_xmlNodeGetBase(); + test_ret += test_xmlNodeGetContent(); + test_ret += test_xmlNodeGetLang(); + test_ret += test_xmlNodeGetSpacePreserve(); + test_ret += test_xmlNodeIsText(); + test_ret += test_xmlNodeListGetRawString(); + test_ret += test_xmlNodeListGetString(); + test_ret += test_xmlNodeSetBase(); + test_ret += test_xmlNodeSetContent(); + test_ret += test_xmlNodeSetContentLen(); + test_ret += test_xmlNodeSetLang(); + test_ret += test_xmlNodeSetName(); + test_ret += test_xmlNodeSetSpacePreserve(); + test_ret += test_xmlPreviousElementSibling(); + test_ret += test_xmlReconciliateNs(); + test_ret += test_xmlRemoveProp(); + test_ret += test_xmlReplaceNode(); + test_ret += test_xmlSaveFile(); + test_ret += test_xmlSaveFileEnc(); + test_ret += test_xmlSaveFileTo(); + test_ret += test_xmlSaveFormatFile(); + test_ret += test_xmlSaveFormatFileEnc(); + test_ret += test_xmlSaveFormatFileTo(); + test_ret += test_xmlSearchNs(); + test_ret += test_xmlSearchNsByHref(); + test_ret += test_xmlSetBufferAllocationScheme(); + test_ret += test_xmlSetCompressMode(); + test_ret += test_xmlSetDocCompressMode(); + test_ret += test_xmlSetNs(); + test_ret += test_xmlSetNsProp(); + test_ret += test_xmlSetProp(); + test_ret += test_xmlSplitQName2(); + test_ret += test_xmlSplitQName3(); + test_ret += test_xmlStringGetNodeList(); + test_ret += test_xmlStringLenGetNodeList(); + test_ret += test_xmlTextConcat(); + test_ret += test_xmlTextMerge(); + test_ret += test_xmlUnsetNsProp(); + test_ret += test_xmlUnsetProp(); + test_ret += test_xmlValidateNCName(); + test_ret += test_xmlValidateNMToken(); + test_ret += test_xmlValidateName(); + test_ret += test_xmlValidateQName(); + + if (test_ret != 0) + printf("Module tree: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlBuildRelativeURI(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * URI; /* the URI reference under consideration */ + int n_URI; + xmlChar * base; /* the base value */ + int n_base; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_base = 0;n_base < gen_nb_const_xmlChar_ptr;n_base++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + base = gen_const_xmlChar_ptr(n_base, 1); + + ret_val = xmlBuildRelativeURI((const xmlChar *)URI, (const xmlChar *)base); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); + des_const_xmlChar_ptr(n_base, (const xmlChar *)base, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBuildRelativeURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_base); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlBuildURI(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * URI; /* the URI instance found in the document */ + int n_URI; + xmlChar * base; /* the base value */ + int n_base; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_base = 0;n_base < gen_nb_const_xmlChar_ptr;n_base++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + base = gen_const_xmlChar_ptr(n_base, 1); + + ret_val = xmlBuildURI((const xmlChar *)URI, (const xmlChar *)base); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); + des_const_xmlChar_ptr(n_base, (const xmlChar *)base, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBuildURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_base); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCanonicPath(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * path; /* the resource locator in a filesystem notation */ + int n_path; + + for (n_path = 0;n_path < gen_nb_const_xmlChar_ptr;n_path++) { + mem_base = xmlMemBlocks(); + path = gen_const_xmlChar_ptr(n_path, 0); + + ret_val = xmlCanonicPath((const xmlChar *)path); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_path, (const xmlChar *)path, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCanonicPath", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_path); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCreateURI(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlNormalizeURIPath(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + char * path; /* pointer to the path string */ + int n_path; + + for (n_path = 0;n_path < gen_nb_char_ptr;n_path++) { + mem_base = xmlMemBlocks(); + path = gen_char_ptr(n_path, 0); + + ret_val = xmlNormalizeURIPath(path); + desret_int(ret_val); + call_tests++; + des_char_ptr(n_path, path, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNormalizeURIPath", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_path); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParseURI(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParseURIRaw(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +#define gen_nb_xmlURIPtr 1 +static xmlURIPtr gen_xmlURIPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlURIPtr(int no ATTRIBUTE_UNUSED, xmlURIPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlParseURIReference(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlURIPtr uri; /* pointer to an URI structure */ + int n_uri; + char * str; /* the string to analyze */ + int n_str; + + for (n_uri = 0;n_uri < gen_nb_xmlURIPtr;n_uri++) { + for (n_str = 0;n_str < gen_nb_const_char_ptr;n_str++) { + mem_base = xmlMemBlocks(); + uri = gen_xmlURIPtr(n_uri, 0); + str = gen_const_char_ptr(n_str, 1); + + ret_val = xmlParseURIReference(uri, (const char *)str); + desret_int(ret_val); + call_tests++; + des_xmlURIPtr(n_uri, uri, 0); + des_const_char_ptr(n_str, (const char *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseURIReference", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_uri); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPathToURI(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * path; /* the resource locator in a filesystem notation */ + int n_path; + + for (n_path = 0;n_path < gen_nb_const_xmlChar_ptr;n_path++) { + mem_base = xmlMemBlocks(); + path = gen_const_xmlChar_ptr(n_path, 0); + + ret_val = xmlPathToURI((const xmlChar *)path); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_path, (const xmlChar *)path, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPathToURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_path); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPrintURI(void) { + int test_ret = 0; + + int mem_base; + FILE * stream; /* a FILE* for the output */ + int n_stream; + xmlURIPtr uri; /* pointer to an xmlURI */ + int n_uri; + + for (n_stream = 0;n_stream < gen_nb_FILE_ptr;n_stream++) { + for (n_uri = 0;n_uri < gen_nb_xmlURIPtr;n_uri++) { + mem_base = xmlMemBlocks(); + stream = gen_FILE_ptr(n_stream, 0); + uri = gen_xmlURIPtr(n_uri, 1); + + xmlPrintURI(stream, uri); + call_tests++; + des_FILE_ptr(n_stream, stream, 0); + des_xmlURIPtr(n_uri, uri, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPrintURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_stream); + printf(" %d", n_uri); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSaveUri(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlURIPtr uri; /* pointer to an xmlURI */ + int n_uri; + + for (n_uri = 0;n_uri < gen_nb_xmlURIPtr;n_uri++) { + mem_base = xmlMemBlocks(); + uri = gen_xmlURIPtr(n_uri, 0); + + ret_val = xmlSaveUri(uri); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlURIPtr(n_uri, uri, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveUri", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_uri); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlURIEscape(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * str; /* the string of the URI to escape */ + int n_str; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + + ret_val = xmlURIEscape((const xmlChar *)str); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlURIEscape", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlURIEscapeStr(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * str; /* string to escape */ + int n_str; + xmlChar * list; /* exception list string of chars not to escape */ + int n_list; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_list = 0;n_list < gen_nb_const_xmlChar_ptr;n_list++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + list = gen_const_xmlChar_ptr(n_list, 1); + + ret_val = xmlURIEscapeStr((const xmlChar *)str, (const xmlChar *)list); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_list, (const xmlChar *)list, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlURIEscapeStr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_list); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlURIUnescapeString(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_uri(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing uri : 10 of 15 functions ...\n"); + test_ret += test_xmlBuildRelativeURI(); + test_ret += test_xmlBuildURI(); + test_ret += test_xmlCanonicPath(); + test_ret += test_xmlCreateURI(); + test_ret += test_xmlNormalizeURIPath(); + test_ret += test_xmlParseURI(); + test_ret += test_xmlParseURIRaw(); + test_ret += test_xmlParseURIReference(); + test_ret += test_xmlPathToURI(); + test_ret += test_xmlPrintURI(); + test_ret += test_xmlSaveUri(); + test_ret += test_xmlURIEscape(); + test_ret += test_xmlURIEscapeStr(); + test_ret += test_xmlURIUnescapeString(); + + if (test_ret != 0) + printf("Module uri: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlAddAttributeDecl(void) { + int test_ret = 0; + + int mem_base; + xmlAttributePtr ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDtdPtr dtd; /* pointer to the DTD */ + int n_dtd; + xmlChar * elem; /* the element name */ + int n_elem; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * ns; /* the attribute namespace prefix */ + int n_ns; + xmlAttributeType type; /* the attribute type */ + int n_type; + xmlAttributeDefault def; /* the attribute default type */ + int n_def; + xmlChar * defaultValue; /* the attribute default value */ + int n_defaultValue; + xmlEnumerationPtr tree; /* if it's an enumeration, the associated list */ + int n_tree; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + for (n_elem = 0;n_elem < gen_nb_const_xmlChar_ptr;n_elem++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns = 0;n_ns < gen_nb_const_xmlChar_ptr;n_ns++) { + for (n_type = 0;n_type < gen_nb_xmlAttributeType;n_type++) { + for (n_def = 0;n_def < gen_nb_xmlAttributeDefault;n_def++) { + for (n_defaultValue = 0;n_defaultValue < gen_nb_const_xmlChar_ptr;n_defaultValue++) { + for (n_tree = 0;n_tree < gen_nb_xmlEnumerationPtr;n_tree++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + dtd = gen_xmlDtdPtr(n_dtd, 1); + elem = gen_const_xmlChar_ptr(n_elem, 2); + name = gen_const_xmlChar_ptr(n_name, 3); + ns = gen_const_xmlChar_ptr(n_ns, 4); + type = gen_xmlAttributeType(n_type, 5); + def = gen_xmlAttributeDefault(n_def, 6); + defaultValue = gen_const_xmlChar_ptr(n_defaultValue, 7); + tree = gen_xmlEnumerationPtr(n_tree, 8); + + ret_val = xmlAddAttributeDecl(ctxt, dtd, (const xmlChar *)elem, (const xmlChar *)name, (const xmlChar *)ns, type, def, (const xmlChar *)defaultValue, tree); + desret_xmlAttributePtr(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDtdPtr(n_dtd, dtd, 1); + des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 2); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 3); + des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 4); + des_xmlAttributeType(n_type, type, 5); + des_xmlAttributeDefault(n_def, def, 6); + des_const_xmlChar_ptr(n_defaultValue, (const xmlChar *)defaultValue, 7); + des_xmlEnumerationPtr(n_tree, tree, 8); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddAttributeDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_dtd); + printf(" %d", n_elem); + printf(" %d", n_name); + printf(" %d", n_ns); + printf(" %d", n_type); + printf(" %d", n_def); + printf(" %d", n_defaultValue); + printf(" %d", n_tree); + printf("\n"); + } + } + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddElementDecl(void) { + int test_ret = 0; + + int mem_base; + xmlElementPtr ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDtdPtr dtd; /* pointer to the DTD */ + int n_dtd; + xmlChar * name; /* the entity name */ + int n_name; + xmlElementTypeVal type; /* the element type */ + int n_type; + xmlElementContentPtr content; /* the element content tree or NULL */ + int n_content; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_xmlElementTypeVal;n_type++) { + for (n_content = 0;n_content < gen_nb_xmlElementContentPtr;n_content++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + dtd = gen_xmlDtdPtr(n_dtd, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + type = gen_xmlElementTypeVal(n_type, 3); + content = gen_xmlElementContentPtr(n_content, 4); + + ret_val = xmlAddElementDecl(ctxt, dtd, (const xmlChar *)name, type, content); + desret_xmlElementPtr(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDtdPtr(n_dtd, dtd, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_xmlElementTypeVal(n_type, type, 3); + des_xmlElementContentPtr(n_content, content, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddElementDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_dtd); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlAddID(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAddNotationDecl(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAddRef(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCopyAttributeTable(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCopyDocElementContent(void) { + int test_ret = 0; + + int mem_base; + xmlElementContentPtr ret_val; + xmlDocPtr doc; /* the document owning the element declaration */ + int n_doc; + xmlElementContentPtr cur; /* An element content pointer. */ + int n_cur; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_xmlElementContentPtr;n_cur++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + cur = gen_xmlElementContentPtr(n_cur, 1); + + ret_val = xmlCopyDocElementContent(doc, cur); + desret_xmlElementContentPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlElementContentPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyDocElementContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyElementContent(void) { + int test_ret = 0; + + int mem_base; + xmlElementContentPtr ret_val; + xmlElementContentPtr cur; /* An element content pointer. */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_xmlElementContentPtr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlElementContentPtr(n_cur, 0); + + ret_val = xmlCopyElementContent(cur); + desret_xmlElementContentPtr(ret_val); + call_tests++; + des_xmlElementContentPtr(n_cur, cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyElementContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCopyElementTable(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCopyEnumeration(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCopyNotationTable(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCreateEnumeration(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +#define gen_nb_xmlAttributePtr 1 +static xmlAttributePtr gen_xmlAttributePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlAttributePtr(int no ATTRIBUTE_UNUSED, xmlAttributePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpAttributeDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlAttributePtr attr; /* An attribute declaration */ + int n_attr; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttributePtr;n_attr++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + attr = gen_xmlAttributePtr(n_attr, 1); + + xmlDumpAttributeDecl(buf, attr); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlAttributePtr(n_attr, attr, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpAttributeDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_attr); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlAttributeTablePtr 1 +static xmlAttributeTablePtr gen_xmlAttributeTablePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlAttributeTablePtr(int no ATTRIBUTE_UNUSED, xmlAttributeTablePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpAttributeTable(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlAttributeTablePtr table; /* An attribute table */ + int n_table; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_table = 0;n_table < gen_nb_xmlAttributeTablePtr;n_table++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + table = gen_xmlAttributeTablePtr(n_table, 1); + + xmlDumpAttributeTable(buf, table); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlAttributeTablePtr(n_table, table, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpAttributeTable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_table); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlElementPtr 1 +static xmlElementPtr gen_xmlElementPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlElementPtr(int no ATTRIBUTE_UNUSED, xmlElementPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpElementDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlElementPtr elem; /* An element table */ + int n_elem; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_elem = 0;n_elem < gen_nb_xmlElementPtr;n_elem++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + elem = gen_xmlElementPtr(n_elem, 1); + + xmlDumpElementDecl(buf, elem); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlElementPtr(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpElementDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlElementTablePtr 1 +static xmlElementTablePtr gen_xmlElementTablePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlElementTablePtr(int no ATTRIBUTE_UNUSED, xmlElementTablePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpElementTable(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlElementTablePtr table; /* An element table */ + int n_table; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_table = 0;n_table < gen_nb_xmlElementTablePtr;n_table++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + table = gen_xmlElementTablePtr(n_table, 1); + + xmlDumpElementTable(buf, table); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlElementTablePtr(n_table, table, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpElementTable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_table); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlNotationPtr 1 +static xmlNotationPtr gen_xmlNotationPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlNotationPtr(int no ATTRIBUTE_UNUSED, xmlNotationPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpNotationDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlNotationPtr nota; /* A notation declaration */ + int n_nota; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_nota = 0;n_nota < gen_nb_xmlNotationPtr;n_nota++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + nota = gen_xmlNotationPtr(n_nota, 1); + + xmlDumpNotationDecl(buf, nota); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlNotationPtr(n_nota, nota, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpNotationDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_nota); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlNotationTablePtr 1 +static xmlNotationTablePtr gen_xmlNotationTablePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlNotationTablePtr(int no ATTRIBUTE_UNUSED, xmlNotationTablePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlDumpNotationTable(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlBufferPtr buf; /* the XML buffer output */ + int n_buf; + xmlNotationTablePtr table; /* A notation table */ + int n_table; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_table = 0;n_table < gen_nb_xmlNotationTablePtr;n_table++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + table = gen_xmlNotationTablePtr(n_table, 1); + + xmlDumpNotationTable(buf, table); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlNotationTablePtr(n_table, table, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlDumpNotationTable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_table); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlGetDtdAttrDesc(void) { + int test_ret = 0; + + int mem_base; + xmlAttributePtr ret_val; + xmlDtdPtr dtd; /* a pointer to the DtD to search */ + int n_dtd; + xmlChar * elem; /* the element name */ + int n_elem; + xmlChar * name; /* the attribute name */ + int n_name; + + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + for (n_elem = 0;n_elem < gen_nb_const_xmlChar_ptr;n_elem++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + dtd = gen_xmlDtdPtr(n_dtd, 0); + elem = gen_const_xmlChar_ptr(n_elem, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + + ret_val = xmlGetDtdAttrDesc(dtd, (const xmlChar *)elem, (const xmlChar *)name); + desret_xmlAttributePtr(ret_val); + call_tests++; + des_xmlDtdPtr(n_dtd, dtd, 0); + des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDtdAttrDesc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dtd); + printf(" %d", n_elem); + printf(" %d", n_name); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetDtdElementDesc(void) { + int test_ret = 0; + + int mem_base; + xmlElementPtr ret_val; + xmlDtdPtr dtd; /* a pointer to the DtD to search */ + int n_dtd; + xmlChar * name; /* the element name */ + int n_name; + + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + dtd = gen_xmlDtdPtr(n_dtd, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlGetDtdElementDesc(dtd, (const xmlChar *)name); + desret_xmlElementPtr(ret_val); + call_tests++; + des_xmlDtdPtr(n_dtd, dtd, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDtdElementDesc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dtd); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetDtdNotationDesc(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlGetDtdQAttrDesc(void) { + int test_ret = 0; + + int mem_base; + xmlAttributePtr ret_val; + xmlDtdPtr dtd; /* a pointer to the DtD to search */ + int n_dtd; + xmlChar * elem; /* the element name */ + int n_elem; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * prefix; /* the attribute namespace prefix */ + int n_prefix; + + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + for (n_elem = 0;n_elem < gen_nb_const_xmlChar_ptr;n_elem++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + dtd = gen_xmlDtdPtr(n_dtd, 0); + elem = gen_const_xmlChar_ptr(n_elem, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + prefix = gen_const_xmlChar_ptr(n_prefix, 3); + + ret_val = xmlGetDtdQAttrDesc(dtd, (const xmlChar *)elem, (const xmlChar *)name, (const xmlChar *)prefix); + desret_xmlAttributePtr(ret_val); + call_tests++; + des_xmlDtdPtr(n_dtd, dtd, 0); + des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDtdQAttrDesc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dtd); + printf(" %d", n_elem); + printf(" %d", n_name); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetDtdQElementDesc(void) { + int test_ret = 0; + + int mem_base; + xmlElementPtr ret_val; + xmlDtdPtr dtd; /* a pointer to the DtD to search */ + int n_dtd; + xmlChar * name; /* the element name */ + int n_name; + xmlChar * prefix; /* the element namespace prefix */ + int n_prefix; + + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + dtd = gen_xmlDtdPtr(n_dtd, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + prefix = gen_const_xmlChar_ptr(n_prefix, 2); + + ret_val = xmlGetDtdQElementDesc(dtd, (const xmlChar *)name, (const xmlChar *)prefix); + desret_xmlElementPtr(ret_val); + call_tests++; + des_xmlDtdPtr(n_dtd, dtd, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetDtdQElementDesc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_dtd); + printf(" %d", n_name); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetID(void) { + int test_ret = 0; + + int mem_base; + xmlAttrPtr ret_val; + xmlDocPtr doc; /* pointer to the document */ + int n_doc; + xmlChar * ID; /* the ID value */ + int n_ID; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_ID = 0;n_ID < gen_nb_const_xmlChar_ptr;n_ID++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + ID = gen_const_xmlChar_ptr(n_ID, 1); + + ret_val = xmlGetID(doc, (const xmlChar *)ID); + desret_xmlAttrPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetID", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_ID); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetRefs(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlIsID(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr elem; /* the element carrying the attribute */ + int n_elem; + xmlAttrPtr attr; /* the attribute */ + int n_attr; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + elem = gen_xmlNodePtr(n_elem, 1); + attr = gen_xmlAttrPtr(n_attr, 2); + + ret_val = xmlIsID(doc, elem, attr); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_elem, elem, 1); + des_xmlAttrPtr(n_attr, attr, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsID", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_attr); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsMixedElement(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the element name */ + int n_name; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlIsMixedElement(doc, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsMixedElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIsRef(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr elem; /* the element carrying the attribute */ + int n_elem; + xmlAttrPtr attr; /* the attribute */ + int n_attr; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + elem = gen_xmlNodePtr(n_elem, 1); + attr = gen_xmlAttrPtr(n_attr, 2); + + ret_val = xmlIsRef(doc, elem, attr); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_elem, elem, 1); + des_xmlAttrPtr(n_attr, attr, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIsRef", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_attr); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewDocElementContent(void) { + int test_ret = 0; + + int mem_base; + xmlElementContentPtr ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * name; /* the subelement name or NULL */ + int n_name; + xmlElementContentType type; /* the type of element content decl */ + int n_type; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_xmlElementContentType;n_type++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + type = gen_xmlElementContentType(n_type, 2); + + ret_val = xmlNewDocElementContent(doc, (const xmlChar *)name, type); + xmlFreeDocElementContent(doc, ret_val); ret_val = NULL; + desret_xmlElementContentPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_xmlElementContentType(n_type, type, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewDocElementContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_name); + printf(" %d", n_type); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewElementContent(void) { + int test_ret = 0; + + int mem_base; + xmlElementContentPtr ret_val; + xmlChar * name; /* the subelement name or NULL */ + int n_name; + xmlElementContentType type; /* the type of element content decl */ + int n_type; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_xmlElementContentType;n_type++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + type = gen_xmlElementContentType(n_type, 1); + + ret_val = xmlNewElementContent((const xmlChar *)name, type); + desret_xmlElementContentPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_xmlElementContentType(n_type, type, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewElementContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf(" %d", n_type); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNewValidCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRemoveID(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlAttrPtr attr; /* the attribute */ + int n_attr; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + attr = gen_xmlAttrPtr(n_attr, 1); + + ret_val = xmlRemoveID(doc, attr); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlAttrPtr(n_attr, attr, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRemoveID", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_attr); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlRemoveRef(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlAttrPtr attr; /* the attribute */ + int n_attr; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + attr = gen_xmlAttrPtr(n_attr, 1); + + ret_val = xmlRemoveRef(doc, attr); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlAttrPtr(n_attr, attr, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRemoveRef", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_attr); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSnprintfElementContent(void) { + int test_ret = 0; + + int mem_base; + char * buf; /* an output buffer */ + int n_buf; + int size; /* the buffer size */ + int n_size; + xmlElementContentPtr content; /* An element table */ + int n_content; + int englob; /* 1 if one must print the englobing parenthesis, 0 otherwise */ + int n_englob; + + for (n_buf = 0;n_buf < gen_nb_char_ptr;n_buf++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_content = 0;n_content < gen_nb_xmlElementContentPtr;n_content++) { + for (n_englob = 0;n_englob < gen_nb_int;n_englob++) { + mem_base = xmlMemBlocks(); + buf = gen_char_ptr(n_buf, 0); + size = gen_int(n_size, 1); + content = gen_xmlElementContentPtr(n_content, 2); + englob = gen_int(n_englob, 3); + + xmlSnprintfElementContent(buf, size, content, englob); + call_tests++; + des_char_ptr(n_buf, buf, 0); + des_int(n_size, size, 1); + des_xmlElementContentPtr(n_content, content, 2); + des_int(n_englob, englob, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSnprintfElementContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_size); + printf(" %d", n_content); + printf(" %d", n_englob); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSprintfElementContent(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) +#ifdef LIBXML_OUTPUT_ENABLED + int mem_base; + char * buf; /* an output buffer */ + int n_buf; + xmlElementContentPtr content; /* An element table */ + int n_content; + int englob; /* 1 if one must print the englobing parenthesis, 0 otherwise */ + int n_englob; + + for (n_buf = 0;n_buf < gen_nb_char_ptr;n_buf++) { + for (n_content = 0;n_content < gen_nb_xmlElementContentPtr;n_content++) { + for (n_englob = 0;n_englob < gen_nb_int;n_englob++) { + mem_base = xmlMemBlocks(); + buf = gen_char_ptr(n_buf, 0); + content = gen_xmlElementContentPtr(n_content, 1); + englob = gen_int(n_englob, 2); + + xmlSprintfElementContent(buf, content, englob); + call_tests++; + des_char_ptr(n_buf, buf, 0); + des_xmlElementContentPtr(n_content, content, 1); + des_int(n_englob, englob, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSprintfElementContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_content); + printf(" %d", n_englob); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlValidBuildContentModel(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* a validation context */ + int n_ctxt; + xmlElementPtr elem; /* an element declaration node */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_elem = 0;n_elem < gen_nb_xmlElementPtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + elem = gen_xmlElementPtr(n_elem, 1); + + ret_val = xmlValidBuildContentModel(ctxt, elem); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlElementPtr(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidBuildContentModel", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidCtxtNormalizeAttributeValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlValidCtxtPtr ctxt; /* the validation context or NULL */ + int n_ctxt; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr elem; /* the parent */ + int n_elem; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * value; /* the attribute value */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + name = gen_const_xmlChar_ptr(n_name, 3); + value = gen_const_xmlChar_ptr(n_value, 4); + + ret_val = xmlValidCtxtNormalizeAttributeValue(ctxt, doc, elem, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 3); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidCtxtNormalizeAttributeValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +#define gen_nb_xmlElementContent_ptr 1 +static xmlElementContent * gen_xmlElementContent_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlElementContent_ptr(int no ATTRIBUTE_UNUSED, xmlElementContent * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlValidGetPotentialChildren(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) +#ifdef LIBXML_VALID_ENABLED + int mem_base; + int ret_val; + xmlElementContent * ctree; /* an element content tree */ + int n_ctree; + xmlChar ** names; /* an array to store the list of child names */ + int n_names; + int * len; /* a pointer to the number of element in the list */ + int n_len; + int max; /* the size of the array */ + int n_max; + + for (n_ctree = 0;n_ctree < gen_nb_xmlElementContent_ptr;n_ctree++) { + for (n_names = 0;n_names < gen_nb_const_xmlChar_ptr_ptr;n_names++) { + for (n_len = 0;n_len < gen_nb_int_ptr;n_len++) { + for (n_max = 0;n_max < gen_nb_int;n_max++) { + mem_base = xmlMemBlocks(); + ctree = gen_xmlElementContent_ptr(n_ctree, 0); + names = gen_const_xmlChar_ptr_ptr(n_names, 1); + len = gen_int_ptr(n_len, 2); + max = gen_int(n_max, 3); + + ret_val = xmlValidGetPotentialChildren(ctree, (const xmlChar **)names, len, max); + desret_int(ret_val); + call_tests++; + des_xmlElementContent_ptr(n_ctree, ctree, 0); + des_const_xmlChar_ptr_ptr(n_names, (const xmlChar **)names, 1); + des_int_ptr(n_len, len, 2); + des_int(n_max, max, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidGetPotentialChildren", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctree); + printf(" %d", n_names); + printf(" %d", n_len); + printf(" %d", n_max); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlValidGetValidElements(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) +#ifdef LIBXML_VALID_ENABLED + int mem_base; + int ret_val; + xmlNode * prev; /* an element to insert after */ + int n_prev; + xmlNode * next; /* an element to insert next */ + int n_next; + xmlChar ** names; /* an array to store the list of child names */ + int n_names; + int max; /* the size of the array */ + int n_max; + + for (n_prev = 0;n_prev < gen_nb_xmlNodePtr;n_prev++) { + for (n_next = 0;n_next < gen_nb_xmlNodePtr;n_next++) { + for (n_names = 0;n_names < gen_nb_const_xmlChar_ptr_ptr;n_names++) { + for (n_max = 0;n_max < gen_nb_int;n_max++) { + mem_base = xmlMemBlocks(); + prev = gen_xmlNodePtr(n_prev, 0); + next = gen_xmlNodePtr(n_next, 1); + names = gen_const_xmlChar_ptr_ptr(n_names, 2); + max = gen_int(n_max, 3); + + ret_val = xmlValidGetValidElements(prev, next, (const xmlChar **)names, max); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_prev, prev, 0); + des_xmlNodePtr(n_next, next, 1); + des_const_xmlChar_ptr_ptr(n_names, (const xmlChar **)names, 2); + des_int(n_max, max, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidGetValidElements", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_prev); + printf(" %d", n_next); + printf(" %d", n_names); + printf(" %d", n_max); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlValidNormalizeAttributeValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlNodePtr elem; /* the parent */ + int n_elem; + xmlChar * name; /* the attribute name */ + int n_name; + xmlChar * value; /* the attribute value */ + int n_value; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + elem = gen_xmlNodePtr(n_elem, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + value = gen_const_xmlChar_ptr(n_value, 3); + + ret_val = xmlValidNormalizeAttributeValue(doc, elem, (const xmlChar *)name, (const xmlChar *)value); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_elem, elem, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidNormalizeAttributeValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateAttributeDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlAttributePtr attr; /* an attribute definition */ + int n_attr; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttributePtr;n_attr++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + attr = gen_xmlAttributePtr(n_attr, 2); + + ret_val = xmlValidateAttributeDecl(ctxt, doc, attr); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlAttributePtr(n_attr, attr, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateAttributeDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_attr); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateAttributeValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlAttributeType type; /* an attribute type */ + int n_type; + xmlChar * value; /* an attribute value */ + int n_value; + + for (n_type = 0;n_type < gen_nb_xmlAttributeType;n_type++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + type = gen_xmlAttributeType(n_type, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + + ret_val = xmlValidateAttributeValue(type, (const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_xmlAttributeType(n_type, type, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateAttributeValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlValidateDocument(ctxt, doc); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateDocumentFinal(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlValidateDocumentFinal(ctxt, doc); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateDocumentFinal", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateDtd(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlDtdPtr dtd; /* a dtd instance */ + int n_dtd; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + dtd = gen_xmlDtdPtr(n_dtd, 2); + + ret_val = xmlValidateDtd(ctxt, doc, dtd); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlDtdPtr(n_dtd, dtd, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateDtd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_dtd); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateDtdFinal(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlValidateDtdFinal(ctxt, doc); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateDtdFinal", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateElement(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + + ret_val = xmlValidateElement(ctxt, doc, elem); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateElementDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlElementPtr elem; /* an element definition */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlElementPtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlElementPtr(n_elem, 2); + + ret_val = xmlValidateElementDecl(ctxt, doc, elem); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlElementPtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateElementDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNameValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlChar * value; /* an Name value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlValidateNameValue((const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNameValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNamesValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlChar * value; /* an Names value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlValidateNamesValue((const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNamesValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNmtokenValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlChar * value; /* an Nmtoken value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlValidateNmtokenValue((const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNmtokenValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNmtokensValue(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlChar * value; /* an Nmtokens value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlValidateNmtokensValue((const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNmtokensValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNotationDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNotationPtr nota; /* a notation definition */ + int n_nota; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_nota = 0;n_nota < gen_nb_xmlNotationPtr;n_nota++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + nota = gen_xmlNotationPtr(n_nota, 2); + + ret_val = xmlValidateNotationDecl(ctxt, doc, nota); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNotationPtr(n_nota, nota, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNotationDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_nota); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateNotationUse(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* the document */ + int n_doc; + xmlChar * notationName; /* the notation name to check */ + int n_notationName; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_notationName = 0;n_notationName < gen_nb_const_xmlChar_ptr;n_notationName++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + notationName = gen_const_xmlChar_ptr(n_notationName, 2); + + ret_val = xmlValidateNotationUse(ctxt, doc, (const xmlChar *)notationName); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_const_xmlChar_ptr(n_notationName, (const xmlChar *)notationName, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateNotationUse", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_notationName); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateOneAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + xmlAttrPtr attr; /* an attribute instance */ + int n_attr; + xmlChar * value; /* the attribute value (without entities processing) */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + attr = gen_xmlAttrPtr(n_attr, 3); + value = gen_const_xmlChar_ptr(n_value, 4); + + ret_val = xmlValidateOneAttribute(ctxt, doc, elem, attr, (const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + des_xmlAttrPtr(n_attr, attr, 3); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateOneAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_attr); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateOneElement(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + + ret_val = xmlValidateOneElement(ctxt, doc, elem); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateOneElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateOneNamespace(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + xmlChar * prefix; /* the namespace prefix */ + int n_prefix; + xmlNsPtr ns; /* an namespace declaration instance */ + int n_ns; + xmlChar * value; /* the attribute value (without entities processing) */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + prefix = gen_const_xmlChar_ptr(n_prefix, 3); + ns = gen_xmlNsPtr(n_ns, 4); + value = gen_const_xmlChar_ptr(n_value, 5); + + ret_val = xmlValidateOneNamespace(ctxt, doc, elem, (const xmlChar *)prefix, ns, (const xmlChar *)value); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 3); + des_xmlNsPtr(n_ns, ns, 4); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateOneNamespace", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_prefix); + printf(" %d", n_ns); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidatePopElement(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + xmlChar * qname; /* the qualified name as appearing in the serialization */ + int n_qname; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_qname = 0;n_qname < gen_nb_const_xmlChar_ptr;n_qname++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + qname = gen_const_xmlChar_ptr(n_qname, 3); + + ret_val = xmlValidatePopElement(ctxt, doc, elem, (const xmlChar *)qname); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + des_const_xmlChar_ptr(n_qname, (const xmlChar *)qname, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidatePopElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_qname); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidatePushCData(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlChar * data; /* some character data read */ + int n_data; + int len; /* the length of the data */ + int n_len; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_data = 0;n_data < gen_nb_const_xmlChar_ptr;n_data++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + data = gen_const_xmlChar_ptr(n_data, 1); + len = gen_int(n_len, 2); + if ((data != NULL) && + (len > (int) strlen((const char *) data) + 1)) + continue; + + ret_val = xmlValidatePushCData(ctxt, (const xmlChar *)data, len); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_data, (const xmlChar *)data, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidatePushCData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_data); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidatePushElement(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + xmlNodePtr elem; /* an element instance */ + int n_elem; + xmlChar * qname; /* the qualified name as appearing in the serialization */ + int n_qname; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + for (n_qname = 0;n_qname < gen_nb_const_xmlChar_ptr;n_qname++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + elem = gen_xmlNodePtr(n_elem, 2); + qname = gen_const_xmlChar_ptr(n_qname, 3); + + ret_val = xmlValidatePushElement(ctxt, doc, elem, (const xmlChar *)qname); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + des_xmlNodePtr(n_elem, elem, 2); + des_const_xmlChar_ptr(n_qname, (const xmlChar *)qname, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidatePushElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf(" %d", n_elem); + printf(" %d", n_qname); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlValidateRoot(void) { + int test_ret = 0; + +#if defined(LIBXML_VALID_ENABLED) + int mem_base; + int ret_val; + xmlValidCtxtPtr ctxt; /* the validation context */ + int n_ctxt; + xmlDocPtr doc; /* a document instance */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlValidateRoot(ctxt, doc); + desret_int(ret_val); + call_tests++; + des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlValidateRoot", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_valid(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing valid : 50 of 70 functions ...\n"); + test_ret += test_xmlAddAttributeDecl(); + test_ret += test_xmlAddElementDecl(); + test_ret += test_xmlAddID(); + test_ret += test_xmlAddNotationDecl(); + test_ret += test_xmlAddRef(); + test_ret += test_xmlCopyAttributeTable(); + test_ret += test_xmlCopyDocElementContent(); + test_ret += test_xmlCopyElementContent(); + test_ret += test_xmlCopyElementTable(); + test_ret += test_xmlCopyEnumeration(); + test_ret += test_xmlCopyNotationTable(); + test_ret += test_xmlCreateEnumeration(); + test_ret += test_xmlDumpAttributeDecl(); + test_ret += test_xmlDumpAttributeTable(); + test_ret += test_xmlDumpElementDecl(); + test_ret += test_xmlDumpElementTable(); + test_ret += test_xmlDumpNotationDecl(); + test_ret += test_xmlDumpNotationTable(); + test_ret += test_xmlGetDtdAttrDesc(); + test_ret += test_xmlGetDtdElementDesc(); + test_ret += test_xmlGetDtdNotationDesc(); + test_ret += test_xmlGetDtdQAttrDesc(); + test_ret += test_xmlGetDtdQElementDesc(); + test_ret += test_xmlGetID(); + test_ret += test_xmlGetRefs(); + test_ret += test_xmlIsID(); + test_ret += test_xmlIsMixedElement(); + test_ret += test_xmlIsRef(); + test_ret += test_xmlNewDocElementContent(); + test_ret += test_xmlNewElementContent(); + test_ret += test_xmlNewValidCtxt(); + test_ret += test_xmlRemoveID(); + test_ret += test_xmlRemoveRef(); + test_ret += test_xmlSnprintfElementContent(); + test_ret += test_xmlSprintfElementContent(); + test_ret += test_xmlValidBuildContentModel(); + test_ret += test_xmlValidCtxtNormalizeAttributeValue(); + test_ret += test_xmlValidGetPotentialChildren(); + test_ret += test_xmlValidGetValidElements(); + test_ret += test_xmlValidNormalizeAttributeValue(); + test_ret += test_xmlValidateAttributeDecl(); + test_ret += test_xmlValidateAttributeValue(); + test_ret += test_xmlValidateDocument(); + test_ret += test_xmlValidateDocumentFinal(); + test_ret += test_xmlValidateDtd(); + test_ret += test_xmlValidateDtdFinal(); + test_ret += test_xmlValidateElement(); + test_ret += test_xmlValidateElementDecl(); + test_ret += test_xmlValidateNameValue(); + test_ret += test_xmlValidateNamesValue(); + test_ret += test_xmlValidateNmtokenValue(); + test_ret += test_xmlValidateNmtokensValue(); + test_ret += test_xmlValidateNotationDecl(); + test_ret += test_xmlValidateNotationUse(); + test_ret += test_xmlValidateOneAttribute(); + test_ret += test_xmlValidateOneElement(); + test_ret += test_xmlValidateOneNamespace(); + test_ret += test_xmlValidatePopElement(); + test_ret += test_xmlValidatePushCData(); + test_ret += test_xmlValidatePushElement(); + test_ret += test_xmlValidateRoot(); + + if (test_ret != 0) + printf("Module valid: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlXIncludeNewContext(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXIncludeProcess(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlDocPtr doc; /* an XML document */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + + ret_val = xmlXIncludeProcess(doc); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcess", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXIncludeProcessFlags(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlDocPtr doc; /* an XML document */ + int n_doc; + int flags; /* a set of xmlParserOption used for parsing XML includes */ + int n_flags; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + flags = gen_int(n_flags, 1); + + ret_val = xmlXIncludeProcessFlags(doc, flags); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_int(n_flags, flags, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessFlags", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_flags); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXIncludeProcessFlagsData(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlDocPtr doc; /* an XML document */ + int n_doc; + int flags; /* a set of xmlParserOption used for parsing XML includes */ + int n_flags; + void * data; /* application data that will be passed to the parser context in the _private field of the parser context(s) */ + int n_data; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + flags = gen_int(n_flags, 1); + data = gen_userdata(n_data, 2); + + ret_val = xmlXIncludeProcessFlagsData(doc, flags, data); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_int(n_flags, flags, 1); + des_userdata(n_data, data, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessFlagsData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_flags); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_XINCLUDE_ENABLED + +#define gen_nb_xmlXIncludeCtxtPtr 1 +static xmlXIncludeCtxtPtr gen_xmlXIncludeCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlXIncludeCtxtPtr(int no ATTRIBUTE_UNUSED, xmlXIncludeCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlXIncludeProcessNode(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlXIncludeCtxtPtr ctxt; /* an existing XInclude context */ + int n_ctxt; + xmlNodePtr node; /* a node in an XML document */ + int n_node; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXIncludeCtxtPtr;n_ctxt++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXIncludeCtxtPtr(n_ctxt, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlXIncludeProcessNode(ctxt, node); + desret_int(ret_val); + call_tests++; + des_xmlXIncludeCtxtPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXIncludeProcessTree(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr tree; /* a node in an XML document */ + int n_tree; + + for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) { + mem_base = xmlMemBlocks(); + tree = gen_xmlNodePtr(n_tree, 0); + + ret_val = xmlXIncludeProcessTree(tree); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_tree, tree, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessTree", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_tree); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXIncludeProcessTreeFlags(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr tree; /* a node in an XML document */ + int n_tree; + int flags; /* a set of xmlParserOption used for parsing XML includes */ + int n_flags; + + for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + mem_base = xmlMemBlocks(); + tree = gen_xmlNodePtr(n_tree, 0); + flags = gen_int(n_flags, 1); + + ret_val = xmlXIncludeProcessTreeFlags(tree, flags); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_tree, tree, 0); + des_int(n_flags, flags, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessTreeFlags", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_tree); + printf(" %d", n_flags); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXIncludeProcessTreeFlagsData(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr tree; /* an XML node */ + int n_tree; + int flags; /* a set of xmlParserOption used for parsing XML includes */ + int n_flags; + void * data; /* application data that will be passed to the parser context in the _private field of the parser context(s) */ + int n_data; + + for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + tree = gen_xmlNodePtr(n_tree, 0); + flags = gen_int(n_flags, 1); + data = gen_userdata(n_data, 2); + + ret_val = xmlXIncludeProcessTreeFlagsData(tree, flags, data); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_tree, tree, 0); + des_int(n_flags, flags, 1); + des_userdata(n_data, data, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeProcessTreeFlagsData", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_tree); + printf(" %d", n_flags); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXIncludeSetFlags(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlXIncludeCtxtPtr ctxt; /* an XInclude processing context */ + int n_ctxt; + int flags; /* a set of xmlParserOption used for parsing XML includes */ + int n_flags; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXIncludeCtxtPtr;n_ctxt++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXIncludeCtxtPtr(n_ctxt, 0); + flags = gen_int(n_flags, 1); + + ret_val = xmlXIncludeSetFlags(ctxt, flags); + desret_int(ret_val); + call_tests++; + des_xmlXIncludeCtxtPtr(n_ctxt, ctxt, 0); + des_int(n_flags, flags, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeSetFlags", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_flags); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xinclude(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xinclude : 8 of 10 functions ...\n"); + test_ret += test_xmlXIncludeNewContext(); + test_ret += test_xmlXIncludeProcess(); + test_ret += test_xmlXIncludeProcessFlags(); + test_ret += test_xmlXIncludeProcessFlagsData(); + test_ret += test_xmlXIncludeProcessNode(); + test_ret += test_xmlXIncludeProcessTree(); + test_ret += test_xmlXIncludeProcessTreeFlags(); + test_ret += test_xmlXIncludeProcessTreeFlagsData(); + test_ret += test_xmlXIncludeSetFlags(); + + if (test_ret != 0) + printf("Module xinclude: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlAllocOutputBuffer(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr ret_val; + xmlCharEncodingHandlerPtr encoder; /* the encoding converter or NULL */ + int n_encoder; + + for (n_encoder = 0;n_encoder < gen_nb_xmlCharEncodingHandlerPtr;n_encoder++) { + mem_base = xmlMemBlocks(); + encoder = gen_xmlCharEncodingHandlerPtr(n_encoder, 0); + + ret_val = xmlAllocOutputBuffer(encoder); + desret_xmlOutputBufferPtr(ret_val); + call_tests++; + des_xmlCharEncodingHandlerPtr(n_encoder, encoder, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAllocOutputBuffer", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_encoder); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlAllocParserInputBuffer(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputBufferPtr ret_val; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + enc = gen_xmlCharEncoding(n_enc, 0); + + ret_val = xmlAllocParserInputBuffer(enc); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_xmlCharEncoding(n_enc, enc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAllocParserInputBuffer", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_enc); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCheckFilename(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + char * path; /* the path to check */ + int n_path; + + for (n_path = 0;n_path < gen_nb_const_char_ptr;n_path++) { + mem_base = xmlMemBlocks(); + path = gen_const_char_ptr(n_path, 0); + + ret_val = xmlCheckFilename((const char *)path); + desret_int(ret_val); + call_tests++; + des_const_char_ptr(n_path, (const char *)path, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCheckFilename", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_path); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCheckHTTPInput(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlParserInputPtr ret; /* an XML parser input */ + int n_ret; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_ret = 0;n_ret < gen_nb_xmlParserInputPtr;n_ret++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + ret = gen_xmlParserInputPtr(n_ret, 1); + + ret_val = xmlCheckHTTPInput(ctxt, ret); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputPtr(n_ret, ret, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCheckHTTPInput", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_ret); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCleanupInputCallbacks(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlCleanupInputCallbacks(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCleanupInputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCleanupOutputCallbacks(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlCleanupOutputCallbacks(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCleanupOutputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlFileClose(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * context; /* the I/O context */ + int n_context; + + for (n_context = 0;n_context < gen_nb_void_ptr;n_context++) { + mem_base = xmlMemBlocks(); + context = gen_void_ptr(n_context, 0); + + ret_val = xmlFileClose(context); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_context, context, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlFileClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_context); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlFileMatch(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + const char * filename; /* the URI for matching */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlFileMatch(filename); + desret_int(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlFileMatch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlFileOpen(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + const char * filename; /* the URI for matching */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlFileOpen(filename); + desret_void_ptr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlFileOpen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlFileRead(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + void * context; /* the I/O context */ + int n_context; + char * buffer; /* where to drop data */ + int n_buffer; + int len; /* number of bytes to write */ + int n_len; + + for (n_context = 0;n_context < gen_nb_void_ptr;n_context++) { + for (n_buffer = 0;n_buffer < gen_nb_char_ptr;n_buffer++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + context = gen_void_ptr(n_context, 0); + buffer = gen_char_ptr(n_buffer, 1); + len = gen_int(n_len, 2); + + ret_val = xmlFileRead(context, buffer, len); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_context, context, 0); + des_char_ptr(n_buffer, buffer, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlFileRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_context); + printf(" %d", n_buffer); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlIOFTPClose(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * context; /* the I/O context */ + int n_context; + + for (n_context = 0;n_context < gen_nb_void_ptr;n_context++) { + mem_base = xmlMemBlocks(); + context = gen_void_ptr(n_context, 0); + + ret_val = xmlIOFTPClose(context); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_context, context, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOFTPClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_context); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOFTPMatch(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the URI for matching */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlIOFTPMatch(filename); + desret_int(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOFTPMatch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOFTPOpen(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + void * ret_val; + const char * filename; /* the URI for matching */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlIOFTPOpen(filename); + desret_void_ptr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOFTPOpen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOFTPRead(void) { + int test_ret = 0; + +#if defined(LIBXML_FTP_ENABLED) + int mem_base; + int ret_val; + void * context; /* the I/O context */ + int n_context; + char * buffer; /* where to drop data */ + int n_buffer; + int len; /* number of bytes to write */ + int n_len; + + for (n_context = 0;n_context < gen_nb_void_ptr;n_context++) { + for (n_buffer = 0;n_buffer < gen_nb_char_ptr;n_buffer++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + context = gen_void_ptr(n_context, 0); + buffer = gen_char_ptr(n_buffer, 1); + len = gen_int(n_len, 2); + + ret_val = xmlIOFTPRead(context, buffer, len); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_context, context, 0); + des_char_ptr(n_buffer, buffer, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOFTPRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_context); + printf(" %d", n_buffer); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOHTTPClose(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + void * context; /* the I/O context */ + int n_context; + + for (n_context = 0;n_context < gen_nb_void_ptr;n_context++) { + mem_base = xmlMemBlocks(); + context = gen_void_ptr(n_context, 0); + + ret_val = xmlIOHTTPClose(context); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_context, context, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOHTTPClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_context); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOHTTPMatch(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + const char * filename; /* the URI for matching */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlIOHTTPMatch(filename); + desret_int(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOHTTPMatch", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOHTTPOpen(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + void * ret_val; + const char * filename; /* the URI for matching */ + int n_filename; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + + ret_val = xmlIOHTTPOpen(filename); + desret_xmlNanoHTTPCtxtPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOHTTPOpen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlIOHTTPRead(void) { + int test_ret = 0; + +#if defined(LIBXML_HTTP_ENABLED) + int mem_base; + int ret_val; + void * context; /* the I/O context */ + int n_context; + char * buffer; /* where to drop data */ + int n_buffer; + int len; /* number of bytes to write */ + int n_len; + + for (n_context = 0;n_context < gen_nb_void_ptr;n_context++) { + for (n_buffer = 0;n_buffer < gen_nb_char_ptr;n_buffer++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + context = gen_void_ptr(n_context, 0); + buffer = gen_char_ptr(n_buffer, 1); + len = gen_int(n_len, 2); + + ret_val = xmlIOHTTPRead(context, buffer, len); + desret_int(ret_val); + call_tests++; + des_void_ptr(n_context, context, 0); + des_char_ptr(n_buffer, buffer, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlIOHTTPRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_context); + printf(" %d", n_buffer); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNoNetExternalEntityLoader(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr ret_val; + const char * URL; /* the URL for the entity to load */ + int n_URL; + char * ID; /* the System ID for the entity to load */ + int n_ID; + xmlParserCtxtPtr ctxt; /* the context in which the entity is called or NULL */ + int n_ctxt; + + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_ID = 0;n_ID < gen_nb_const_char_ptr;n_ID++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + URL = gen_filepath(n_URL, 0); + ID = gen_const_char_ptr(n_ID, 1); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 2); + + ret_val = xmlNoNetExternalEntityLoader(URL, (const char *)ID, ctxt); + desret_xmlParserInputPtr(ret_val); + call_tests++; + des_filepath(n_URL, URL, 0); + des_const_char_ptr(n_ID, (const char *)ID, 1); + des_xmlParserCtxtPtr(n_ctxt, ctxt, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNoNetExternalEntityLoader", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf(" %d", n_ID); + printf(" %d", n_ctxt); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlNormalizeWindowsPath(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * path; /* the input file path */ + int n_path; + + for (n_path = 0;n_path < gen_nb_const_xmlChar_ptr;n_path++) { + mem_base = xmlMemBlocks(); + path = gen_const_xmlChar_ptr(n_path, 0); + + ret_val = xmlNormalizeWindowsPath((const xmlChar *)path); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_path, (const xmlChar *)path, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNormalizeWindowsPath", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_path); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlOutputBufferCreateBuffer(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr ret_val; + xmlBufferPtr buffer; /* a xmlBufferPtr */ + int n_buffer; + xmlCharEncodingHandlerPtr encoder; /* the encoding converter or NULL */ + int n_encoder; + + for (n_buffer = 0;n_buffer < gen_nb_xmlBufferPtr;n_buffer++) { + for (n_encoder = 0;n_encoder < gen_nb_xmlCharEncodingHandlerPtr;n_encoder++) { + mem_base = xmlMemBlocks(); + buffer = gen_xmlBufferPtr(n_buffer, 0); + encoder = gen_xmlCharEncodingHandlerPtr(n_encoder, 1); + + ret_val = xmlOutputBufferCreateBuffer(buffer, encoder); + desret_xmlOutputBufferPtr(ret_val); + call_tests++; + des_xmlBufferPtr(n_buffer, buffer, 0); + des_xmlCharEncodingHandlerPtr(n_encoder, encoder, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferCreateBuffer", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_encoder); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferCreateFd(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr ret_val; + int fd; /* a file descriptor number */ + int n_fd; + xmlCharEncodingHandlerPtr encoder; /* the encoding converter or NULL */ + int n_encoder; + + for (n_fd = 0;n_fd < gen_nb_int;n_fd++) { + for (n_encoder = 0;n_encoder < gen_nb_xmlCharEncodingHandlerPtr;n_encoder++) { + mem_base = xmlMemBlocks(); + fd = gen_int(n_fd, 0); + encoder = gen_xmlCharEncodingHandlerPtr(n_encoder, 1); + + ret_val = xmlOutputBufferCreateFd(fd, encoder); + desret_xmlOutputBufferPtr(ret_val); + call_tests++; + des_int(n_fd, fd, 0); + des_xmlCharEncodingHandlerPtr(n_encoder, encoder, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferCreateFd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_fd); + printf(" %d", n_encoder); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferCreateFile(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr ret_val; + FILE * file; /* a FILE* */ + int n_file; + xmlCharEncodingHandlerPtr encoder; /* the encoding converter or NULL */ + int n_encoder; + + for (n_file = 0;n_file < gen_nb_FILE_ptr;n_file++) { + for (n_encoder = 0;n_encoder < gen_nb_xmlCharEncodingHandlerPtr;n_encoder++) { + mem_base = xmlMemBlocks(); + file = gen_FILE_ptr(n_file, 0); + encoder = gen_xmlCharEncodingHandlerPtr(n_encoder, 1); + + ret_val = xmlOutputBufferCreateFile(file, encoder); + desret_xmlOutputBufferPtr(ret_val); + call_tests++; + des_FILE_ptr(n_file, file, 0); + des_xmlCharEncodingHandlerPtr(n_encoder, encoder, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferCreateFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_file); + printf(" %d", n_encoder); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferCreateFilename(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + xmlOutputBufferPtr ret_val; + const char * URI; /* a C string containing the URI or filename */ + int n_URI; + xmlCharEncodingHandlerPtr encoder; /* the encoding converter or NULL */ + int n_encoder; + int compression; /* the compression ration (0 none, 9 max). */ + int n_compression; + + for (n_URI = 0;n_URI < gen_nb_fileoutput;n_URI++) { + for (n_encoder = 0;n_encoder < gen_nb_xmlCharEncodingHandlerPtr;n_encoder++) { + for (n_compression = 0;n_compression < gen_nb_int;n_compression++) { + mem_base = xmlMemBlocks(); + URI = gen_fileoutput(n_URI, 0); + encoder = gen_xmlCharEncodingHandlerPtr(n_encoder, 1); + compression = gen_int(n_compression, 2); + + ret_val = xmlOutputBufferCreateFilename(URI, encoder, compression); + desret_xmlOutputBufferPtr(ret_val); + call_tests++; + des_fileoutput(n_URI, URI, 0); + des_xmlCharEncodingHandlerPtr(n_encoder, encoder, 1); + des_int(n_compression, compression, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferCreateFilename", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_encoder); + printf(" %d", n_compression); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferFlush(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlOutputBufferPtr out; /* a buffered output */ + int n_out; + + for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { + mem_base = xmlMemBlocks(); + out = gen_xmlOutputBufferPtr(n_out, 0); + + ret_val = xmlOutputBufferFlush(out); + desret_int(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_out, out, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferFlush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferGetContent(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlOutputBufferPtr out; /* an xmlOutputBufferPtr */ + int n_out; + + for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { + mem_base = xmlMemBlocks(); + out = gen_xmlOutputBufferPtr(n_out, 0); + + ret_val = xmlOutputBufferGetContent(out); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_out, out, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferGetContent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferGetSize(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlOutputBufferWrite(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlOutputBufferPtr out; /* a buffered parser output */ + int n_out; + int len; /* the size in bytes of the array. */ + int n_len; + char * buf; /* an char array */ + int n_buf; + + for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + for (n_buf = 0;n_buf < gen_nb_const_char_ptr;n_buf++) { + mem_base = xmlMemBlocks(); + out = gen_xmlOutputBufferPtr(n_out, 0); + len = gen_int(n_len, 1); + buf = gen_const_char_ptr(n_buf, 2); + if ((buf != NULL) && + (len > (int) strlen((const char *) buf) + 1)) + continue; + + ret_val = xmlOutputBufferWrite(out, len, (const char *)buf); + desret_int(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_out, out, 0); + des_int(n_len, len, 1); + des_const_char_ptr(n_buf, (const char *)buf, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferWrite", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_len); + printf(" %d", n_buf); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlOutputBufferWriteEscape(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlOutputBufferWriteString(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlOutputBufferPtr out; /* a buffered parser output */ + int n_out; + char * str; /* a zero terminated C string */ + int n_str; + + for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { + for (n_str = 0;n_str < gen_nb_const_char_ptr;n_str++) { + mem_base = xmlMemBlocks(); + out = gen_xmlOutputBufferPtr(n_out, 0); + str = gen_const_char_ptr(n_str, 1); + + ret_val = xmlOutputBufferWriteString(out, (const char *)str); + desret_int(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_out, out, 0); + des_const_char_ptr(n_str, (const char *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlOutputBufferWriteString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlParserGetDirectory(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParserInputBufferCreateFd(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputBufferPtr ret_val; + int fd; /* a file descriptor number */ + int n_fd; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_fd = 0;n_fd < gen_nb_int;n_fd++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + fd = gen_int(n_fd, 0); + enc = gen_xmlCharEncoding(n_enc, 1); + if (fd >= 0) fd = -1; + + ret_val = xmlParserInputBufferCreateFd(fd, enc); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_int(n_fd, fd, 0); + des_xmlCharEncoding(n_enc, enc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferCreateFd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_fd); + printf(" %d", n_enc); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferCreateFile(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputBufferPtr ret_val; + FILE * file; /* a FILE* */ + int n_file; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_file = 0;n_file < gen_nb_FILE_ptr;n_file++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + file = gen_FILE_ptr(n_file, 0); + enc = gen_xmlCharEncoding(n_enc, 1); + + ret_val = xmlParserInputBufferCreateFile(file, enc); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_FILE_ptr(n_file, file, 0); + des_xmlCharEncoding(n_enc, enc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferCreateFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_file); + printf(" %d", n_enc); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferCreateFilename(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputBufferPtr ret_val; + const char * URI; /* a C string containing the URI or filename */ + int n_URI; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_URI = 0;n_URI < gen_nb_fileoutput;n_URI++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + URI = gen_fileoutput(n_URI, 0); + enc = gen_xmlCharEncoding(n_enc, 1); + + ret_val = xmlParserInputBufferCreateFilename(URI, enc); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_fileoutput(n_URI, URI, 0); + des_xmlCharEncoding(n_enc, enc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferCreateFilename", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_enc); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferCreateMem(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputBufferPtr ret_val; + char * mem; /* the memory input */ + int n_mem; + int size; /* the length of the memory block */ + int n_size; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_mem = 0;n_mem < gen_nb_const_char_ptr;n_mem++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + mem = gen_const_char_ptr(n_mem, 0); + size = gen_int(n_size, 1); + enc = gen_xmlCharEncoding(n_enc, 2); + if ((mem != NULL) && + (size > (int) strlen((const char *) mem) + 1)) + continue; + + ret_val = xmlParserInputBufferCreateMem((const char *)mem, size, enc); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_const_char_ptr(n_mem, (const char *)mem, 0); + des_int(n_size, size, 1); + des_xmlCharEncoding(n_enc, enc, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferCreateMem", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_mem); + printf(" %d", n_size); + printf(" %d", n_enc); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferCreateStatic(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputBufferPtr ret_val; + char * mem; /* the memory input */ + int n_mem; + int size; /* the length of the memory block */ + int n_size; + xmlCharEncoding enc; /* the charset encoding if known */ + int n_enc; + + for (n_mem = 0;n_mem < gen_nb_const_char_ptr;n_mem++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + mem_base = xmlMemBlocks(); + mem = gen_const_char_ptr(n_mem, 0); + size = gen_int(n_size, 1); + enc = gen_xmlCharEncoding(n_enc, 2); + if ((mem != NULL) && + (size > (int) strlen((const char *) mem) + 1)) + continue; + + ret_val = xmlParserInputBufferCreateStatic((const char *)mem, size, enc); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_const_char_ptr(n_mem, (const char *)mem, 0); + des_int(n_size, size, 1); + des_xmlCharEncoding(n_enc, enc, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferCreateStatic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_mem); + printf(" %d", n_size); + printf(" %d", n_enc); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferGrow(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserInputBufferPtr in; /* a buffered parser input */ + int n_in; + int len; /* indicative value of the amount of chars to read */ + int n_len; + + for (n_in = 0;n_in < gen_nb_xmlParserInputBufferPtr;n_in++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + in = gen_xmlParserInputBufferPtr(n_in, 0); + len = gen_int(n_len, 1); + + ret_val = xmlParserInputBufferGrow(in, len); + desret_int(ret_val); + call_tests++; + des_xmlParserInputBufferPtr(n_in, in, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferGrow", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferPush(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserInputBufferPtr in; /* a buffered parser input */ + int n_in; + int len; /* the size in bytes of the array. */ + int n_len; + char * buf; /* an char array */ + int n_buf; + + for (n_in = 0;n_in < gen_nb_xmlParserInputBufferPtr;n_in++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + for (n_buf = 0;n_buf < gen_nb_const_char_ptr;n_buf++) { + mem_base = xmlMemBlocks(); + in = gen_xmlParserInputBufferPtr(n_in, 0); + len = gen_int(n_len, 1); + buf = gen_const_char_ptr(n_buf, 2); + if ((buf != NULL) && + (len > (int) strlen((const char *) buf) + 1)) + continue; + + ret_val = xmlParserInputBufferPush(in, len, (const char *)buf); + desret_int(ret_val); + call_tests++; + des_xmlParserInputBufferPtr(n_in, in, 0); + des_int(n_len, len, 1); + des_const_char_ptr(n_buf, (const char *)buf, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferPush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf(" %d", n_len); + printf(" %d", n_buf); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserInputBufferRead(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserInputBufferPtr in; /* a buffered parser input */ + int n_in; + int len; /* indicative value of the amount of chars to read */ + int n_len; + + for (n_in = 0;n_in < gen_nb_xmlParserInputBufferPtr;n_in++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + in = gen_xmlParserInputBufferPtr(n_in, 0); + len = gen_int(n_len, 1); + + ret_val = xmlParserInputBufferRead(in, len); + desret_int(ret_val); + call_tests++; + des_xmlParserInputBufferPtr(n_in, in, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserInputBufferRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_in); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPopInputCallbacks(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlPopInputCallbacks(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPopInputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlPopOutputCallbacks(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + + mem_base = xmlMemBlocks(); + + ret_val = xmlPopOutputCallbacks(); + desret_int(ret_val); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPopOutputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegisterDefaultInputCallbacks(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlRegisterDefaultInputCallbacks(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegisterDefaultInputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlRegisterDefaultOutputCallbacks(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlRegisterDefaultOutputCallbacks(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegisterDefaultOutputCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegisterHTTPPostCallbacks(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTTP_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlRegisterHTTPPostCallbacks(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegisterHTTPPostCallbacks", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlIO(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlIO : 41 of 51 functions ...\n"); + test_ret += test_xmlAllocOutputBuffer(); + test_ret += test_xmlAllocParserInputBuffer(); + test_ret += test_xmlCheckFilename(); + test_ret += test_xmlCheckHTTPInput(); + test_ret += test_xmlCleanupInputCallbacks(); + test_ret += test_xmlCleanupOutputCallbacks(); + test_ret += test_xmlFileClose(); + test_ret += test_xmlFileMatch(); + test_ret += test_xmlFileOpen(); + test_ret += test_xmlFileRead(); + test_ret += test_xmlIOFTPClose(); + test_ret += test_xmlIOFTPMatch(); + test_ret += test_xmlIOFTPOpen(); + test_ret += test_xmlIOFTPRead(); + test_ret += test_xmlIOHTTPClose(); + test_ret += test_xmlIOHTTPMatch(); + test_ret += test_xmlIOHTTPOpen(); + test_ret += test_xmlIOHTTPRead(); + test_ret += test_xmlNoNetExternalEntityLoader(); + test_ret += test_xmlNormalizeWindowsPath(); + test_ret += test_xmlOutputBufferCreateBuffer(); + test_ret += test_xmlOutputBufferCreateFd(); + test_ret += test_xmlOutputBufferCreateFile(); + test_ret += test_xmlOutputBufferCreateFilename(); + test_ret += test_xmlOutputBufferFlush(); + test_ret += test_xmlOutputBufferGetContent(); + test_ret += test_xmlOutputBufferGetSize(); + test_ret += test_xmlOutputBufferWrite(); + test_ret += test_xmlOutputBufferWriteEscape(); + test_ret += test_xmlOutputBufferWriteString(); + test_ret += test_xmlParserGetDirectory(); + test_ret += test_xmlParserInputBufferCreateFd(); + test_ret += test_xmlParserInputBufferCreateFile(); + test_ret += test_xmlParserInputBufferCreateFilename(); + test_ret += test_xmlParserInputBufferCreateMem(); + test_ret += test_xmlParserInputBufferCreateStatic(); + test_ret += test_xmlParserInputBufferGrow(); + test_ret += test_xmlParserInputBufferPush(); + test_ret += test_xmlParserInputBufferRead(); + test_ret += test_xmlPopInputCallbacks(); + test_ret += test_xmlPopOutputCallbacks(); + test_ret += test_xmlRegisterDefaultInputCallbacks(); + test_ret += test_xmlRegisterDefaultOutputCallbacks(); + test_ret += test_xmlRegisterHTTPPostCallbacks(); + + if (test_ret != 0) + printf("Module xmlIO: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlAutomataCompile(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataGetInitState(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_AUTOMATA_ENABLED + +#define gen_nb_xmlAutomataPtr 1 +static xmlAutomataPtr gen_xmlAutomataPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlAutomataPtr(int no ATTRIBUTE_UNUSED, xmlAutomataPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlAutomataIsDeterminist(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) + int mem_base; + int ret_val; + xmlAutomataPtr am; /* an automata */ + int n_am; + + for (n_am = 0;n_am < gen_nb_xmlAutomataPtr;n_am++) { + mem_base = xmlMemBlocks(); + am = gen_xmlAutomataPtr(n_am, 0); + + ret_val = xmlAutomataIsDeterminist(am); + desret_int(ret_val); + call_tests++; + des_xmlAutomataPtr(n_am, am, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAutomataIsDeterminist", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_am); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlAutomataNewAllTrans(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewCountTrans(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewCountTrans2(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewCountedTrans(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewCounter(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) + int mem_base; + int ret_val; + xmlAutomataPtr am; /* an automata */ + int n_am; + int min; /* the minimal value on the counter */ + int n_min; + int max; /* the maximal value on the counter */ + int n_max; + + for (n_am = 0;n_am < gen_nb_xmlAutomataPtr;n_am++) { + for (n_min = 0;n_min < gen_nb_int;n_min++) { + for (n_max = 0;n_max < gen_nb_int;n_max++) { + mem_base = xmlMemBlocks(); + am = gen_xmlAutomataPtr(n_am, 0); + min = gen_int(n_min, 1); + max = gen_int(n_max, 2); + + ret_val = xmlAutomataNewCounter(am, min, max); + desret_int(ret_val); + call_tests++; + des_xmlAutomataPtr(n_am, am, 0); + des_int(n_min, min, 1); + des_int(n_max, max, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAutomataNewCounter", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_am); + printf(" %d", n_min); + printf(" %d", n_max); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlAutomataNewCounterTrans(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewEpsilon(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewNegTrans(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewOnceTrans(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewOnceTrans2(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewState(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewTransition(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlAutomataNewTransition2(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_AUTOMATA_ENABLED + +#define gen_nb_xmlAutomataStatePtr 1 +static xmlAutomataStatePtr gen_xmlAutomataStatePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlAutomataStatePtr(int no ATTRIBUTE_UNUSED, xmlAutomataStatePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlAutomataSetFinalState(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED) + int mem_base; + int ret_val; + xmlAutomataPtr am; /* an automata */ + int n_am; + xmlAutomataStatePtr state; /* a state in this automata */ + int n_state; + + for (n_am = 0;n_am < gen_nb_xmlAutomataPtr;n_am++) { + for (n_state = 0;n_state < gen_nb_xmlAutomataStatePtr;n_state++) { + mem_base = xmlMemBlocks(); + am = gen_xmlAutomataPtr(n_am, 0); + state = gen_xmlAutomataStatePtr(n_state, 1); + + ret_val = xmlAutomataSetFinalState(am, state); + desret_int(ret_val); + call_tests++; + des_xmlAutomataPtr(n_am, am, 0); + des_xmlAutomataStatePtr(n_state, state, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAutomataSetFinalState", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_am); + printf(" %d", n_state); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewAutomata(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_xmlautomata(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlautomata : 3 of 19 functions ...\n"); + test_ret += test_xmlAutomataCompile(); + test_ret += test_xmlAutomataGetInitState(); + test_ret += test_xmlAutomataIsDeterminist(); + test_ret += test_xmlAutomataNewAllTrans(); + test_ret += test_xmlAutomataNewCountTrans(); + test_ret += test_xmlAutomataNewCountTrans2(); + test_ret += test_xmlAutomataNewCountedTrans(); + test_ret += test_xmlAutomataNewCounter(); + test_ret += test_xmlAutomataNewCounterTrans(); + test_ret += test_xmlAutomataNewEpsilon(); + test_ret += test_xmlAutomataNewNegTrans(); + test_ret += test_xmlAutomataNewOnceTrans(); + test_ret += test_xmlAutomataNewOnceTrans2(); + test_ret += test_xmlAutomataNewState(); + test_ret += test_xmlAutomataNewTransition(); + test_ret += test_xmlAutomataNewTransition2(); + test_ret += test_xmlAutomataSetFinalState(); + test_ret += test_xmlNewAutomata(); + + if (test_ret != 0) + printf("Module xmlautomata: %d errors\n", test_ret); + return(test_ret); +} + +#define gen_nb_xmlGenericErrorFunc_ptr 1 +static xmlGenericErrorFunc * gen_xmlGenericErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlGenericErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlGenericErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_initGenericErrorDefaultFunc(void) { + int test_ret = 0; + + int mem_base; + xmlGenericErrorFunc * handler; /* the handler */ + int n_handler; + + for (n_handler = 0;n_handler < gen_nb_xmlGenericErrorFunc_ptr;n_handler++) { + mem_base = xmlMemBlocks(); + handler = gen_xmlGenericErrorFunc_ptr(n_handler, 0); + + initGenericErrorDefaultFunc(handler); + call_tests++; + des_xmlGenericErrorFunc_ptr(n_handler, handler, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in initGenericErrorDefaultFunc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_handler); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlErrorPtr 1 +static xmlErrorPtr gen_xmlErrorPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlErrorPtr(int no ATTRIBUTE_UNUSED, xmlErrorPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + +static int +test_xmlCopyError(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlErrorPtr from; /* a source error */ + int n_from; + xmlErrorPtr to; /* a target error */ + int n_to; + + for (n_from = 0;n_from < gen_nb_xmlErrorPtr;n_from++) { + for (n_to = 0;n_to < gen_nb_xmlErrorPtr;n_to++) { + mem_base = xmlMemBlocks(); + from = gen_xmlErrorPtr(n_from, 0); + to = gen_xmlErrorPtr(n_to, 1); + + ret_val = xmlCopyError(from, to); + desret_int(ret_val); + call_tests++; + des_xmlErrorPtr(n_from, from, 0); + des_xmlErrorPtr(n_to, to, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCopyError", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_from); + printf(" %d", n_to); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtGetLastError(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlCtxtResetLastError(void) { + int test_ret = 0; + + int mem_base; + void * ctx; /* an XML parser context */ + int n_ctx; + + for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctx = gen_void_ptr(n_ctx, 0); + + xmlCtxtResetLastError(ctx); + call_tests++; + des_void_ptr(n_ctx, ctx, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtResetLastError", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctx); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetLastError(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParserError(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParserPrintFileContext(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr input; /* an xmlParserInputPtr input */ + int n_input; + + for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) { + mem_base = xmlMemBlocks(); + input = gen_xmlParserInputPtr(n_input, 0); + + xmlParserPrintFileContext(input); + call_tests++; + des_xmlParserInputPtr(n_input, input, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserPrintFileContext", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_input); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserPrintFileInfo(void) { + int test_ret = 0; + + int mem_base; + xmlParserInputPtr input; /* an xmlParserInputPtr input */ + int n_input; + + for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) { + mem_base = xmlMemBlocks(); + input = gen_xmlParserInputPtr(n_input, 0); + + xmlParserPrintFileInfo(input); + call_tests++; + des_xmlParserInputPtr(n_input, input, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParserPrintFileInfo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_input); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlParserValidityError(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParserValidityWarning(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlParserWarning(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlResetError(void) { + int test_ret = 0; + + int mem_base; + xmlErrorPtr err; /* pointer to the error. */ + int n_err; + + for (n_err = 0;n_err < gen_nb_xmlErrorPtr;n_err++) { + mem_base = xmlMemBlocks(); + err = gen_xmlErrorPtr(n_err, 0); + + xmlResetError(err); + call_tests++; + des_xmlErrorPtr(n_err, err, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlResetError", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_err); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlResetLastError(void) { + int test_ret = 0; + + + + xmlResetLastError(); + call_tests++; + xmlResetLastError(); + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSetGenericErrorFunc(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSetStructuredErrorFunc(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_xmlerror(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlerror : 7 of 15 functions ...\n"); + test_ret += test_initGenericErrorDefaultFunc(); + test_ret += test_xmlCopyError(); + test_ret += test_xmlCtxtGetLastError(); + test_ret += test_xmlCtxtResetLastError(); + test_ret += test_xmlGetLastError(); + test_ret += test_xmlParserError(); + test_ret += test_xmlParserPrintFileContext(); + test_ret += test_xmlParserPrintFileInfo(); + test_ret += test_xmlParserValidityError(); + test_ret += test_xmlParserValidityWarning(); + test_ret += test_xmlParserWarning(); + test_ret += test_xmlResetError(); + test_ret += test_xmlResetLastError(); + test_ret += test_xmlSetGenericErrorFunc(); + test_ret += test_xmlSetStructuredErrorFunc(); + + if (test_ret != 0) + printf("Module xmlerror: %d errors\n", test_ret); + return(test_ret); +} +#ifdef LIBXML_MODULES_ENABLED + +#define gen_nb_xmlModulePtr 1 +static xmlModulePtr gen_xmlModulePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlModulePtr(int no ATTRIBUTE_UNUSED, xmlModulePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlModuleClose(void) { + int test_ret = 0; + +#if defined(LIBXML_MODULES_ENABLED) + int mem_base; + int ret_val; + xmlModulePtr module; /* the module handle */ + int n_module; + + for (n_module = 0;n_module < gen_nb_xmlModulePtr;n_module++) { + mem_base = xmlMemBlocks(); + module = gen_xmlModulePtr(n_module, 0); + + ret_val = xmlModuleClose(module); + desret_int(ret_val); + call_tests++; + des_xmlModulePtr(n_module, module, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlModuleClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_module); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlModuleOpen(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlModuleSymbol(void) { + int test_ret = 0; + +#if defined(LIBXML_MODULES_ENABLED) + int mem_base; + int ret_val; + xmlModulePtr module; /* the module */ + int n_module; + char * name; /* the name of the symbol */ + int n_name; + void ** symbol; /* the resulting symbol address */ + int n_symbol; + + for (n_module = 0;n_module < gen_nb_xmlModulePtr;n_module++) { + for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { + for (n_symbol = 0;n_symbol < gen_nb_void_ptr_ptr;n_symbol++) { + mem_base = xmlMemBlocks(); + module = gen_xmlModulePtr(n_module, 0); + name = gen_const_char_ptr(n_name, 1); + symbol = gen_void_ptr_ptr(n_symbol, 2); + + ret_val = xmlModuleSymbol(module, (const char *)name, symbol); + desret_int(ret_val); + call_tests++; + des_xmlModulePtr(n_module, module, 0); + des_const_char_ptr(n_name, (const char *)name, 1); + des_void_ptr_ptr(n_symbol, symbol, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlModuleSymbol", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_module); + printf(" %d", n_name); + printf(" %d", n_symbol); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlmodule(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlmodule : 2 of 4 functions ...\n"); + test_ret += test_xmlModuleClose(); + test_ret += test_xmlModuleOpen(); + test_ret += test_xmlModuleSymbol(); + + if (test_ret != 0) + printf("Module xmlmodule: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlNewTextReader(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr ret_val; + xmlParserInputBufferPtr input; /* the xmlParserInputBufferPtr used to read data */ + int n_input; + const char * URI; /* the URI information for the source if available */ + int n_URI; + + for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { + for (n_URI = 0;n_URI < gen_nb_filepath;n_URI++) { + mem_base = xmlMemBlocks(); + input = gen_xmlParserInputBufferPtr(n_input, 0); + URI = gen_filepath(n_URI, 1); + + ret_val = xmlNewTextReader(input, URI); + desret_xmlTextReaderPtr(ret_val); + call_tests++; + des_xmlParserInputBufferPtr(n_input, input, 0); + des_filepath(n_URI, URI, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextReader", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_input); + printf(" %d", n_URI); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewTextReaderFilename(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr ret_val; + const char * URI; /* the URI of the resource to process */ + int n_URI; + + for (n_URI = 0;n_URI < gen_nb_filepath;n_URI++) { + mem_base = xmlMemBlocks(); + URI = gen_filepath(n_URI, 0); + + ret_val = xmlNewTextReaderFilename(URI); + desret_xmlTextReaderPtr(ret_val); + call_tests++; + des_filepath(n_URI, URI, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextReaderFilename", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderForDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr ret_val; + xmlChar * cur; /* a pointer to a zero terminated string */ + int n_cur; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + URL = gen_filepath(n_URL, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + options = gen_parseroptions(n_options, 3); + + ret_val = xmlReaderForDoc((const xmlChar *)cur, URL, (const char *)encoding, options); + desret_xmlTextReaderPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_filepath(n_URL, URL, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_parseroptions(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderForDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderForFile(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr ret_val; + const char * filename; /* a file or URL */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + filename = gen_filepath(n_filename, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + options = gen_parseroptions(n_options, 2); + + ret_val = xmlReaderForFile(filename, (const char *)encoding, options); + desret_xmlTextReaderPtr(ret_val); + call_tests++; + des_filepath(n_filename, filename, 0); + des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_parseroptions(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderForFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderForMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr ret_val; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_parseroptions(n_options, 4); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlReaderForMemory((const char *)buffer, size, URL, (const char *)encoding, options); + desret_xmlTextReaderPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_parseroptions(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderForMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderNewDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* an XML reader */ + int n_reader; + xmlChar * cur; /* a pointer to a zero terminated string */ + int n_cur; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + cur = gen_const_xmlChar_ptr(n_cur, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_parseroptions(n_options, 4); + + ret_val = xmlReaderNewDoc(reader, (const xmlChar *)cur, URL, (const char *)encoding, options); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_parseroptions(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderNewDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_cur); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderNewFile(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* an XML reader */ + int n_reader; + const char * filename; /* a file or URL */ + int n_filename; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + filename = gen_filepath(n_filename, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + options = gen_parseroptions(n_options, 3); + + ret_val = xmlReaderNewFile(reader, filename, (const char *)encoding, options); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_filepath(n_filename, filename, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_parseroptions(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderNewFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_filename); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderNewMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* an XML reader */ + int n_reader; + char * buffer; /* a pointer to a char array */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + buffer = gen_const_char_ptr(n_buffer, 1); + size = gen_int(n_size, 2); + URL = gen_filepath(n_URL, 3); + encoding = gen_const_char_ptr(n_encoding, 4); + options = gen_parseroptions(n_options, 5); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlReaderNewMemory(reader, (const char *)buffer, size, URL, (const char *)encoding, options); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_int(n_size, size, 2); + des_filepath(n_URL, URL, 3); + des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_parseroptions(n_options, options, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderNewMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_buffer); + printf(" %d", n_size); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderNewWalker(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* an XML reader */ + int n_reader; + xmlDocPtr doc; /* a preparsed document */ + int n_doc; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlReaderNewWalker(reader, doc); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderNewWalker", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlReaderWalker(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr ret_val; + xmlDocPtr doc; /* a preparsed document */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + + ret_val = xmlReaderWalker(doc); + desret_xmlTextReaderPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlReaderWalker", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderAttributeCount(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderAttributeCount(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderAttributeCount", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderBaseUri(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderBaseUri(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderBaseUri", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderByteConsumed(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + long ret_val; + xmlTextReaderPtr reader; /* an XML reader */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderByteConsumed(reader); + desret_long(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderByteConsumed", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderClose(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderClose(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstBaseUri(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstBaseUri(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstBaseUri", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstEncoding(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstEncoding(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstLocalName(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstLocalName(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstLocalName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstName(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstName(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstNamespaceUri(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstNamespaceUri(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstNamespaceUri", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstPrefix(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstPrefix(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstPrefix", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstString(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * str; /* the string to intern. */ + int n_str; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + + ret_val = xmlTextReaderConstString(reader, (const xmlChar *)str); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstValue(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstValue(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstXmlLang(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstXmlLang(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstXmlLang", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderConstXmlVersion(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderConstXmlVersion(reader); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderConstXmlVersion", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderCurrentDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlDocPtr ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderCurrentDoc(reader); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderCurrentDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderCurrentNode(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderCurrentNode(reader); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderCurrentNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderDepth(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderDepth(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderDepth", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderExpand(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderExpand(reader); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderExpand", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * name; /* the qualified name of the attribute. */ + int n_name; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlTextReaderGetAttribute(reader, (const xmlChar *)name); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetAttributeNo(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + int no; /* the zero-based index of the attribute relative to the containing element */ + int n_no; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_no = 0;n_no < gen_nb_int;n_no++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + no = gen_int(n_no, 1); + + ret_val = xmlTextReaderGetAttributeNo(reader, no); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_int(n_no, no, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetAttributeNo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_no); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetAttributeNs(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * localName; /* the local name of the attribute. */ + int n_localName; + xmlChar * namespaceURI; /* the namespace URI of the attribute. */ + int n_namespaceURI; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_localName = 0;n_localName < gen_nb_const_xmlChar_ptr;n_localName++) { + for (n_namespaceURI = 0;n_namespaceURI < gen_nb_const_xmlChar_ptr;n_namespaceURI++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + localName = gen_const_xmlChar_ptr(n_localName, 1); + namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 2); + + ret_val = xmlTextReaderGetAttributeNs(reader, (const xmlChar *)localName, (const xmlChar *)namespaceURI); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_localName, (const xmlChar *)localName, 1); + des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetAttributeNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_localName); + printf(" %d", n_namespaceURI); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_READER_ENABLED + +#define gen_nb_xmlTextReaderErrorFunc_ptr 1 +static xmlTextReaderErrorFunc * gen_xmlTextReaderErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlTextReaderErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlTextReaderErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlTextReaderGetErrorHandler(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlTextReaderErrorFunc * f; /* the callback function or NULL is no callback has been registered */ + int n_f; + void ** arg; /* a user argument */ + int n_arg; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_f = 0;n_f < gen_nb_xmlTextReaderErrorFunc_ptr;n_f++) { + for (n_arg = 0;n_arg < gen_nb_void_ptr_ptr;n_arg++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + f = gen_xmlTextReaderErrorFunc_ptr(n_f, 1); + arg = gen_void_ptr_ptr(n_arg, 2); + + xmlTextReaderGetErrorHandler(reader, f, arg); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_xmlTextReaderErrorFunc_ptr(n_f, f, 1); + des_void_ptr_ptr(n_arg, arg, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetErrorHandler", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_f); + printf(" %d", n_arg); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetParserColumnNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the user data (XML reader context) */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderGetParserColumnNumber(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetParserColumnNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetParserLineNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the user data (XML reader context) */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderGetParserLineNumber(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetParserLineNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetParserProp(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + int prop; /* the xmlParserProperties to get */ + int n_prop; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_prop = 0;n_prop < gen_nb_int;n_prop++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + prop = gen_int(n_prop, 1); + + ret_val = xmlTextReaderGetParserProp(reader, prop); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_int(n_prop, prop, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetParserProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_prop); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderGetRemainder(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlParserInputBufferPtr ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderGetRemainder(reader); + desret_xmlParserInputBufferPtr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderGetRemainder", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderHasAttributes(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderHasAttributes(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderHasAttributes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderHasValue(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderHasValue(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderHasValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderIsDefault(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderIsDefault(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderIsDefault", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderIsEmptyElement(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderIsEmptyElement(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderIsEmptyElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderIsNamespaceDecl(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderIsNamespaceDecl(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderIsNamespaceDecl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderIsValid(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderIsValid(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderIsValid", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderLocalName(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderLocalName(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderLocalName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_READER_ENABLED + +#define gen_nb_xmlTextReaderLocatorPtr 1 +static xmlTextReaderLocatorPtr gen_xmlTextReaderLocatorPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlTextReaderLocatorPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderLocatorPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlTextReaderLocatorBaseURI(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderLocatorPtr locator; /* the xmlTextReaderLocatorPtr used */ + int n_locator; + + for (n_locator = 0;n_locator < gen_nb_xmlTextReaderLocatorPtr;n_locator++) { + mem_base = xmlMemBlocks(); + locator = gen_xmlTextReaderLocatorPtr(n_locator, 0); + + ret_val = xmlTextReaderLocatorBaseURI(locator); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderLocatorPtr(n_locator, locator, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderLocatorBaseURI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_locator); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderLocatorLineNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderLocatorPtr locator; /* the xmlTextReaderLocatorPtr used */ + int n_locator; + + for (n_locator = 0;n_locator < gen_nb_xmlTextReaderLocatorPtr;n_locator++) { + mem_base = xmlMemBlocks(); + locator = gen_xmlTextReaderLocatorPtr(n_locator, 0); + + ret_val = xmlTextReaderLocatorLineNumber(locator); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderLocatorPtr(n_locator, locator, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderLocatorLineNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_locator); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderLookupNamespace(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * prefix; /* the prefix whose namespace URI is to be resolved. To return the default namespace, specify NULL */ + int n_prefix; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + + ret_val = xmlTextReaderLookupNamespace(reader, (const xmlChar *)prefix); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderLookupNamespace", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderMoveToAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * name; /* the qualified name of the attribute. */ + int n_name; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlTextReaderMoveToAttribute(reader, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderMoveToAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderMoveToAttributeNo(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + int no; /* the zero-based index of the attribute relative to the containing element. */ + int n_no; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_no = 0;n_no < gen_nb_int;n_no++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + no = gen_int(n_no, 1); + + ret_val = xmlTextReaderMoveToAttributeNo(reader, no); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_int(n_no, no, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderMoveToAttributeNo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_no); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderMoveToAttributeNs(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * localName; /* the local name of the attribute. */ + int n_localName; + xmlChar * namespaceURI; /* the namespace URI of the attribute. */ + int n_namespaceURI; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_localName = 0;n_localName < gen_nb_const_xmlChar_ptr;n_localName++) { + for (n_namespaceURI = 0;n_namespaceURI < gen_nb_const_xmlChar_ptr;n_namespaceURI++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + localName = gen_const_xmlChar_ptr(n_localName, 1); + namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 2); + + ret_val = xmlTextReaderMoveToAttributeNs(reader, (const xmlChar *)localName, (const xmlChar *)namespaceURI); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_localName, (const xmlChar *)localName, 1); + des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderMoveToAttributeNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_localName); + printf(" %d", n_namespaceURI); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderMoveToElement(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderMoveToElement(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderMoveToElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderMoveToFirstAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderMoveToFirstAttribute(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderMoveToFirstAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderMoveToNextAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderMoveToNextAttribute(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderMoveToNextAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderName(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderName(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderNamespaceUri(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderNamespaceUri(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderNamespaceUri", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderNext(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderNext(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderNext", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderNextSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderNextSibling(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderNextSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderNodeType(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderNodeType(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderNodeType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderNormalization(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderNormalization(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderNormalization", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderPrefix(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderPrefix(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderPrefix", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderPreserve(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderPreserve(reader); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderPreserve", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderPreservePattern(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) +#ifdef LIBXML_PATTERN_ENABLED + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlChar * pattern; /* an XPath subset pattern */ + int n_pattern; + xmlChar ** namespaces; /* the prefix definitions, array of [URI, prefix] or NULL */ + int n_namespaces; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_pattern = 0;n_pattern < gen_nb_const_xmlChar_ptr;n_pattern++) { + for (n_namespaces = 0;n_namespaces < gen_nb_const_xmlChar_ptr_ptr;n_namespaces++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + pattern = gen_const_xmlChar_ptr(n_pattern, 1); + namespaces = gen_const_xmlChar_ptr_ptr(n_namespaces, 2); + + ret_val = xmlTextReaderPreservePattern(reader, (const xmlChar *)pattern, (const xmlChar **)namespaces); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_xmlChar_ptr(n_pattern, (const xmlChar *)pattern, 1); + des_const_xmlChar_ptr_ptr(n_namespaces, (const xmlChar **)namespaces, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderPreservePattern", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_pattern); + printf(" %d", n_namespaces); + printf("\n"); + } + } + } + } + function_tests++; +#endif +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderQuoteChar(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderQuoteChar(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderQuoteChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderRead(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderRead(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderRead", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderReadAttributeValue(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderReadAttributeValue(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderReadAttributeValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderReadState(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderReadState(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderReadState", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderRelaxNGSetSchema(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlRelaxNGPtr schema; /* a precompiled RelaxNG schema */ + int n_schema; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_schema = 0;n_schema < gen_nb_xmlRelaxNGPtr;n_schema++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + schema = gen_xmlRelaxNGPtr(n_schema, 1); + + ret_val = xmlTextReaderRelaxNGSetSchema(reader, schema); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_xmlRelaxNGPtr(n_schema, schema, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderRelaxNGSetSchema", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_schema); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderRelaxNGValidate(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + char * rng; /* the path to a RelaxNG schema or NULL */ + int n_rng; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_rng = 0;n_rng < gen_nb_const_char_ptr;n_rng++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + rng = gen_const_char_ptr(n_rng, 1); + + ret_val = xmlTextReaderRelaxNGValidate(reader, (const char *)rng); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_char_ptr(n_rng, (const char *)rng, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderRelaxNGValidate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_rng); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderRelaxNGValidateCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG schema validation context or NULL */ + int n_ctxt; + int options; /* options (not used yet) */ + int n_options; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 1); + options = gen_parseroptions(n_options, 2); + + ret_val = xmlTextReaderRelaxNGValidateCtxt(reader, ctxt, options); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 1); + des_parseroptions(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderRelaxNGValidateCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_ctxt); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderSchemaValidate(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + char * xsd; /* the path to a W3C XSD schema or NULL */ + int n_xsd; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_xsd = 0;n_xsd < gen_nb_const_char_ptr;n_xsd++) { + reader = gen_xmlTextReaderPtr(n_reader, 0); + xsd = gen_const_char_ptr(n_xsd, 1); + + ret_val = xmlTextReaderSchemaValidate(reader, (const char *)xsd); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_const_char_ptr(n_xsd, (const char *)xsd, 1); + xmlResetLastError(); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderSchemaValidateCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlSchemaValidCtxtPtr ctxt; /* the XML Schema validation context or NULL */ + int n_ctxt; + int options; /* options (not used yet) */ + int n_options; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 1); + options = gen_parseroptions(n_options, 2); + + ret_val = xmlTextReaderSchemaValidateCtxt(reader, ctxt, options); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 1); + des_parseroptions(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderSchemaValidateCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_ctxt); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderSetErrorHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextReaderSetParserProp(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + int prop; /* the xmlParserProperties to set */ + int n_prop; + int value; /* usually 0 or 1 to (de)activate it */ + int n_value; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_prop = 0;n_prop < gen_nb_int;n_prop++) { + for (n_value = 0;n_value < gen_nb_int;n_value++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + prop = gen_int(n_prop, 1); + value = gen_int(n_value, 2); + + ret_val = xmlTextReaderSetParserProp(reader, prop, value); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_int(n_prop, prop, 1); + des_int(n_value, value, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderSetParserProp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_prop); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderSetSchema(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + xmlSchemaPtr schema; /* a precompiled Schema schema */ + int n_schema; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_schema = 0;n_schema < gen_nb_xmlSchemaPtr;n_schema++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + schema = gen_xmlSchemaPtr(n_schema, 1); + + ret_val = xmlTextReaderSetSchema(reader, schema); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_xmlSchemaPtr(n_schema, schema, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderSetSchema", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_schema); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderSetStructuredErrorHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextReaderSetup(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* an XML reader */ + int n_reader; + xmlParserInputBufferPtr input; /* xmlParserInputBufferPtr used to feed the reader, will be destroyed with it. */ + int n_input; + const char * URL; /* the base URL to use for the document */ + int n_URL; + char * encoding; /* the document encoding, or NULL */ + int n_encoding; + int options; /* a combination of xmlParserOption */ + int n_options; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { + for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + input = gen_xmlParserInputBufferPtr(n_input, 1); + URL = gen_filepath(n_URL, 2); + encoding = gen_const_char_ptr(n_encoding, 3); + options = gen_parseroptions(n_options, 4); + + ret_val = xmlTextReaderSetup(reader, input, URL, (const char *)encoding, options); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_parseroptions(n_options, options, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderSetup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf(" %d", n_input); + printf(" %d", n_URL); + printf(" %d", n_encoding); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderStandalone(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + int ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderStandalone(reader); + desret_int(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderStandalone", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderValue(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderValue(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextReaderXmlLang(void) { + int test_ret = 0; + +#if defined(LIBXML_READER_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ + int n_reader; + + for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { + mem_base = xmlMemBlocks(); + reader = gen_xmlTextReaderPtr(n_reader, 0); + + ret_val = xmlTextReaderXmlLang(reader); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlTextReaderPtr(n_reader, reader, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextReaderXmlLang", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_reader); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlreader(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlreader : 76 of 86 functions ...\n"); + test_ret += test_xmlNewTextReader(); + test_ret += test_xmlNewTextReaderFilename(); + test_ret += test_xmlReaderForDoc(); + test_ret += test_xmlReaderForFile(); + test_ret += test_xmlReaderForMemory(); + test_ret += test_xmlReaderNewDoc(); + test_ret += test_xmlReaderNewFile(); + test_ret += test_xmlReaderNewMemory(); + test_ret += test_xmlReaderNewWalker(); + test_ret += test_xmlReaderWalker(); + test_ret += test_xmlTextReaderAttributeCount(); + test_ret += test_xmlTextReaderBaseUri(); + test_ret += test_xmlTextReaderByteConsumed(); + test_ret += test_xmlTextReaderClose(); + test_ret += test_xmlTextReaderConstBaseUri(); + test_ret += test_xmlTextReaderConstEncoding(); + test_ret += test_xmlTextReaderConstLocalName(); + test_ret += test_xmlTextReaderConstName(); + test_ret += test_xmlTextReaderConstNamespaceUri(); + test_ret += test_xmlTextReaderConstPrefix(); + test_ret += test_xmlTextReaderConstString(); + test_ret += test_xmlTextReaderConstValue(); + test_ret += test_xmlTextReaderConstXmlLang(); + test_ret += test_xmlTextReaderConstXmlVersion(); + test_ret += test_xmlTextReaderCurrentDoc(); + test_ret += test_xmlTextReaderCurrentNode(); + test_ret += test_xmlTextReaderDepth(); + test_ret += test_xmlTextReaderExpand(); + test_ret += test_xmlTextReaderGetAttribute(); + test_ret += test_xmlTextReaderGetAttributeNo(); + test_ret += test_xmlTextReaderGetAttributeNs(); + test_ret += test_xmlTextReaderGetErrorHandler(); + test_ret += test_xmlTextReaderGetParserColumnNumber(); + test_ret += test_xmlTextReaderGetParserLineNumber(); + test_ret += test_xmlTextReaderGetParserProp(); + test_ret += test_xmlTextReaderGetRemainder(); + test_ret += test_xmlTextReaderHasAttributes(); + test_ret += test_xmlTextReaderHasValue(); + test_ret += test_xmlTextReaderIsDefault(); + test_ret += test_xmlTextReaderIsEmptyElement(); + test_ret += test_xmlTextReaderIsNamespaceDecl(); + test_ret += test_xmlTextReaderIsValid(); + test_ret += test_xmlTextReaderLocalName(); + test_ret += test_xmlTextReaderLocatorBaseURI(); + test_ret += test_xmlTextReaderLocatorLineNumber(); + test_ret += test_xmlTextReaderLookupNamespace(); + test_ret += test_xmlTextReaderMoveToAttribute(); + test_ret += test_xmlTextReaderMoveToAttributeNo(); + test_ret += test_xmlTextReaderMoveToAttributeNs(); + test_ret += test_xmlTextReaderMoveToElement(); + test_ret += test_xmlTextReaderMoveToFirstAttribute(); + test_ret += test_xmlTextReaderMoveToNextAttribute(); + test_ret += test_xmlTextReaderName(); + test_ret += test_xmlTextReaderNamespaceUri(); + test_ret += test_xmlTextReaderNext(); + test_ret += test_xmlTextReaderNextSibling(); + test_ret += test_xmlTextReaderNodeType(); + test_ret += test_xmlTextReaderNormalization(); + test_ret += test_xmlTextReaderPrefix(); + test_ret += test_xmlTextReaderPreserve(); + test_ret += test_xmlTextReaderPreservePattern(); + test_ret += test_xmlTextReaderQuoteChar(); + test_ret += test_xmlTextReaderRead(); + test_ret += test_xmlTextReaderReadAttributeValue(); + test_ret += test_xmlTextReaderReadState(); + test_ret += test_xmlTextReaderRelaxNGSetSchema(); + test_ret += test_xmlTextReaderRelaxNGValidate(); + test_ret += test_xmlTextReaderRelaxNGValidateCtxt(); + test_ret += test_xmlTextReaderSchemaValidate(); + test_ret += test_xmlTextReaderSchemaValidateCtxt(); + test_ret += test_xmlTextReaderSetErrorHandler(); + test_ret += test_xmlTextReaderSetParserProp(); + test_ret += test_xmlTextReaderSetSchema(); + test_ret += test_xmlTextReaderSetStructuredErrorHandler(); + test_ret += test_xmlTextReaderSetup(); + test_ret += test_xmlTextReaderStandalone(); + test_ret += test_xmlTextReaderValue(); + test_ret += test_xmlTextReaderXmlLang(); + + if (test_ret != 0) + printf("Module xmlreader: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlExpCtxtNbCons(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpCtxtPtr ctxt; /* an expression context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0); + + ret_val = xmlExpCtxtNbCons(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpCtxtNbCons", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpCtxtNbNodes(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpCtxtPtr ctxt; /* an expression context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0); + + ret_val = xmlExpCtxtNbNodes(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpCtxtNbNodes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpDump(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + xmlBufferPtr buf; /* a buffer to receive the output */ + int n_buf; + xmlExpNodePtr expr; /* the compiled expression */ + int n_expr; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_expr = 0;n_expr < gen_nb_xmlExpNodePtr;n_expr++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + expr = gen_xmlExpNodePtr(n_expr, 1); + + xmlExpDump(buf, expr); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_xmlExpNodePtr(n_expr, expr, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_expr); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpExpDerive(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpGetLanguage(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpCtxtPtr ctxt; /* the expression context */ + int n_ctxt; + xmlExpNodePtr exp; /* the expression */ + int n_exp; + xmlChar ** langList; /* where to store the tokens */ + int n_langList; + int len; /* the allocated length of @list */ + int n_len; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) { + for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) { + for (n_langList = 0;n_langList < gen_nb_const_xmlChar_ptr_ptr;n_langList++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0); + exp = gen_xmlExpNodePtr(n_exp, 1); + langList = gen_const_xmlChar_ptr_ptr(n_langList, 2); + len = gen_int(n_len, 3); + + ret_val = xmlExpGetLanguage(ctxt, exp, (const xmlChar **)langList, len); + desret_int(ret_val); + call_tests++; + des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); + des_xmlExpNodePtr(n_exp, exp, 1); + des_const_xmlChar_ptr_ptr(n_langList, (const xmlChar **)langList, 2); + des_int(n_len, len, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpGetLanguage", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_exp); + printf(" %d", n_langList); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpGetStart(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpCtxtPtr ctxt; /* the expression context */ + int n_ctxt; + xmlExpNodePtr exp; /* the expression */ + int n_exp; + xmlChar ** tokList; /* where to store the tokens */ + int n_tokList; + int len; /* the allocated length of @list */ + int n_len; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) { + for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) { + for (n_tokList = 0;n_tokList < gen_nb_const_xmlChar_ptr_ptr;n_tokList++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0); + exp = gen_xmlExpNodePtr(n_exp, 1); + tokList = gen_const_xmlChar_ptr_ptr(n_tokList, 2); + len = gen_int(n_len, 3); + + ret_val = xmlExpGetStart(ctxt, exp, (const xmlChar **)tokList, len); + desret_int(ret_val); + call_tests++; + des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); + des_xmlExpNodePtr(n_exp, exp, 1); + des_const_xmlChar_ptr_ptr(n_tokList, (const xmlChar **)tokList, 2); + des_int(n_len, len, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpGetStart", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_exp); + printf(" %d", n_tokList); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpIsNillable(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpNodePtr exp; /* the expression */ + int n_exp; + + for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) { + mem_base = xmlMemBlocks(); + exp = gen_xmlExpNodePtr(n_exp, 0); + + ret_val = xmlExpIsNillable(exp); + desret_int(ret_val); + call_tests++; + des_xmlExpNodePtr(n_exp, exp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpIsNillable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_exp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpMaxToken(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpNodePtr expr; /* a compiled expression */ + int n_expr; + + for (n_expr = 0;n_expr < gen_nb_xmlExpNodePtr;n_expr++) { + mem_base = xmlMemBlocks(); + expr = gen_xmlExpNodePtr(n_expr, 0); + + ret_val = xmlExpMaxToken(expr); + desret_int(ret_val); + call_tests++; + des_xmlExpNodePtr(n_expr, expr, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpMaxToken", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_expr); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpNewAtom(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpNewCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpNewOr(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpNewRange(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpNewSeq(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpParse(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpRef(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + xmlExpNodePtr exp; /* the expression */ + int n_exp; + + for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) { + mem_base = xmlMemBlocks(); + exp = gen_xmlExpNodePtr(n_exp, 0); + + xmlExpRef(exp); + call_tests++; + des_xmlExpNodePtr(n_exp, exp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpRef", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_exp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlExpStringDerive(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlExpSubsume(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED) + int mem_base; + int ret_val; + xmlExpCtxtPtr ctxt; /* the expressions context */ + int n_ctxt; + xmlExpNodePtr exp; /* the englobing expression */ + int n_exp; + xmlExpNodePtr sub; /* the subexpression */ + int n_sub; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) { + for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) { + for (n_sub = 0;n_sub < gen_nb_xmlExpNodePtr;n_sub++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0); + exp = gen_xmlExpNodePtr(n_exp, 1); + sub = gen_xmlExpNodePtr(n_sub, 2); + + ret_val = xmlExpSubsume(ctxt, exp, sub); + desret_int(ret_val); + call_tests++; + des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); + des_xmlExpNodePtr(n_exp, exp, 1); + des_xmlExpNodePtr(n_sub, sub, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlExpSubsume", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_exp); + printf(" %d", n_sub); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_REGEXP_ENABLED + +#define gen_nb_xmlRegExecCtxtPtr 1 +static xmlRegExecCtxtPtr gen_xmlRegExecCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRegExecCtxtPtr(int no ATTRIBUTE_UNUSED, xmlRegExecCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlRegExecErrInfo(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlRegExecCtxtPtr exec; /* a regexp execution context generating an error */ + int n_exec; + xmlChar ** string; /* return value for the error string */ + int n_string; + int * nbval; /* pointer to the number of accepted values IN/OUT */ + int n_nbval; + int * nbneg; /* return number of negative transitions */ + int n_nbneg; + xmlChar ** values; /* pointer to the array of acceptable values */ + int n_values; + int * terminal; /* return value if this was a terminal state */ + int n_terminal; + + for (n_exec = 0;n_exec < gen_nb_xmlRegExecCtxtPtr;n_exec++) { + for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr_ptr;n_string++) { + for (n_nbval = 0;n_nbval < gen_nb_int_ptr;n_nbval++) { + for (n_nbneg = 0;n_nbneg < gen_nb_int_ptr;n_nbneg++) { + for (n_values = 0;n_values < gen_nb_xmlChar_ptr_ptr;n_values++) { + for (n_terminal = 0;n_terminal < gen_nb_int_ptr;n_terminal++) { + mem_base = xmlMemBlocks(); + exec = gen_xmlRegExecCtxtPtr(n_exec, 0); + string = gen_const_xmlChar_ptr_ptr(n_string, 1); + nbval = gen_int_ptr(n_nbval, 2); + nbneg = gen_int_ptr(n_nbneg, 3); + values = gen_xmlChar_ptr_ptr(n_values, 4); + terminal = gen_int_ptr(n_terminal, 5); + + ret_val = xmlRegExecErrInfo(exec, (const xmlChar **)string, nbval, nbneg, values, terminal); + desret_int(ret_val); + call_tests++; + des_xmlRegExecCtxtPtr(n_exec, exec, 0); + des_const_xmlChar_ptr_ptr(n_string, (const xmlChar **)string, 1); + des_int_ptr(n_nbval, nbval, 2); + des_int_ptr(n_nbneg, nbneg, 3); + des_xmlChar_ptr_ptr(n_values, values, 4); + des_int_ptr(n_terminal, terminal, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegExecErrInfo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_exec); + printf(" %d", n_string); + printf(" %d", n_nbval); + printf(" %d", n_nbneg); + printf(" %d", n_values); + printf(" %d", n_terminal); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegExecNextValues(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlRegExecCtxtPtr exec; /* a regexp execution context */ + int n_exec; + int * nbval; /* pointer to the number of accepted values IN/OUT */ + int n_nbval; + int * nbneg; /* return number of negative transitions */ + int n_nbneg; + xmlChar ** values; /* pointer to the array of acceptable values */ + int n_values; + int * terminal; /* return value if this was a terminal state */ + int n_terminal; + + for (n_exec = 0;n_exec < gen_nb_xmlRegExecCtxtPtr;n_exec++) { + for (n_nbval = 0;n_nbval < gen_nb_int_ptr;n_nbval++) { + for (n_nbneg = 0;n_nbneg < gen_nb_int_ptr;n_nbneg++) { + for (n_values = 0;n_values < gen_nb_xmlChar_ptr_ptr;n_values++) { + for (n_terminal = 0;n_terminal < gen_nb_int_ptr;n_terminal++) { + mem_base = xmlMemBlocks(); + exec = gen_xmlRegExecCtxtPtr(n_exec, 0); + nbval = gen_int_ptr(n_nbval, 1); + nbneg = gen_int_ptr(n_nbneg, 2); + values = gen_xmlChar_ptr_ptr(n_values, 3); + terminal = gen_int_ptr(n_terminal, 4); + + ret_val = xmlRegExecNextValues(exec, nbval, nbneg, values, terminal); + desret_int(ret_val); + call_tests++; + des_xmlRegExecCtxtPtr(n_exec, exec, 0); + des_int_ptr(n_nbval, nbval, 1); + des_int_ptr(n_nbneg, nbneg, 2); + des_xmlChar_ptr_ptr(n_values, values, 3); + des_int_ptr(n_terminal, terminal, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegExecNextValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_exec); + printf(" %d", n_nbval); + printf(" %d", n_nbneg); + printf(" %d", n_values); + printf(" %d", n_terminal); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegExecPushString(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlRegExecCtxtPtr exec; /* a regexp execution context or NULL to indicate the end */ + int n_exec; + xmlChar * value; /* a string token input */ + int n_value; + void * data; /* data associated to the token to reuse in callbacks */ + int n_data; + + for (n_exec = 0;n_exec < gen_nb_xmlRegExecCtxtPtr;n_exec++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + exec = gen_xmlRegExecCtxtPtr(n_exec, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + data = gen_userdata(n_data, 2); + + ret_val = xmlRegExecPushString(exec, (const xmlChar *)value, data); + desret_int(ret_val); + call_tests++; + des_xmlRegExecCtxtPtr(n_exec, exec, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_userdata(n_data, data, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegExecPushString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_exec); + printf(" %d", n_value); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegExecPushString2(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlRegExecCtxtPtr exec; /* a regexp execution context or NULL to indicate the end */ + int n_exec; + xmlChar * value; /* the first string token input */ + int n_value; + xmlChar * value2; /* the second string token input */ + int n_value2; + void * data; /* data associated to the token to reuse in callbacks */ + int n_data; + + for (n_exec = 0;n_exec < gen_nb_xmlRegExecCtxtPtr;n_exec++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_value2 = 0;n_value2 < gen_nb_const_xmlChar_ptr;n_value2++) { + for (n_data = 0;n_data < gen_nb_userdata;n_data++) { + mem_base = xmlMemBlocks(); + exec = gen_xmlRegExecCtxtPtr(n_exec, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + value2 = gen_const_xmlChar_ptr(n_value2, 2); + data = gen_userdata(n_data, 3); + + ret_val = xmlRegExecPushString2(exec, (const xmlChar *)value, (const xmlChar *)value2, data); + desret_int(ret_val); + call_tests++; + des_xmlRegExecCtxtPtr(n_exec, exec, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value2, (const xmlChar *)value2, 2); + des_userdata(n_data, data, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegExecPushString2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_exec); + printf(" %d", n_value); + printf(" %d", n_value2); + printf(" %d", n_data); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegNewExecCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlRegexpCompile(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_REGEXP_ENABLED + +#define gen_nb_xmlRegexpPtr 1 +static xmlRegexpPtr gen_xmlRegexpPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlRegexpPtr(int no ATTRIBUTE_UNUSED, xmlRegexpPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlRegexpExec(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlRegexpPtr comp; /* the compiled regular expression */ + int n_comp; + xmlChar * content; /* the value to check against the regular expression */ + int n_content; + + for (n_comp = 0;n_comp < gen_nb_xmlRegexpPtr;n_comp++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlRegexpPtr(n_comp, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlRegexpExec(comp, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlRegexpPtr(n_comp, comp, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegexpExec", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegexpIsDeterminist(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + int ret_val; + xmlRegexpPtr comp; /* the compiled regular expression */ + int n_comp; + + for (n_comp = 0;n_comp < gen_nb_xmlRegexpPtr;n_comp++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlRegexpPtr(n_comp, 0); + + ret_val = xmlRegexpIsDeterminist(comp); + desret_int(ret_val); + call_tests++; + des_xmlRegexpPtr(n_comp, comp, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegexpIsDeterminist", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlRegexpPrint(void) { + int test_ret = 0; + +#if defined(LIBXML_REGEXP_ENABLED) + int mem_base; + FILE * output; /* the file for the output debug */ + int n_output; + xmlRegexpPtr regexp; /* the compiled regexp */ + int n_regexp; + + for (n_output = 0;n_output < gen_nb_FILE_ptr;n_output++) { + for (n_regexp = 0;n_regexp < gen_nb_xmlRegexpPtr;n_regexp++) { + mem_base = xmlMemBlocks(); + output = gen_FILE_ptr(n_output, 0); + regexp = gen_xmlRegexpPtr(n_regexp, 1); + + xmlRegexpPrint(output, regexp); + call_tests++; + des_FILE_ptr(n_output, output, 0); + des_xmlRegexpPtr(n_regexp, regexp, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlRegexpPrint", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_regexp); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlregexp(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlregexp : 16 of 30 functions ...\n"); + test_ret += test_xmlExpCtxtNbCons(); + test_ret += test_xmlExpCtxtNbNodes(); + test_ret += test_xmlExpDump(); + test_ret += test_xmlExpExpDerive(); + test_ret += test_xmlExpGetLanguage(); + test_ret += test_xmlExpGetStart(); + test_ret += test_xmlExpIsNillable(); + test_ret += test_xmlExpMaxToken(); + test_ret += test_xmlExpNewAtom(); + test_ret += test_xmlExpNewCtxt(); + test_ret += test_xmlExpNewOr(); + test_ret += test_xmlExpNewRange(); + test_ret += test_xmlExpNewSeq(); + test_ret += test_xmlExpParse(); + test_ret += test_xmlExpRef(); + test_ret += test_xmlExpStringDerive(); + test_ret += test_xmlExpSubsume(); + test_ret += test_xmlRegExecErrInfo(); + test_ret += test_xmlRegExecNextValues(); + test_ret += test_xmlRegExecPushString(); + test_ret += test_xmlRegExecPushString2(); + test_ret += test_xmlRegNewExecCtxt(); + test_ret += test_xmlRegexpCompile(); + test_ret += test_xmlRegexpExec(); + test_ret += test_xmlRegexpIsDeterminist(); + test_ret += test_xmlRegexpPrint(); + + if (test_ret != 0) + printf("Module xmlregexp: %d errors\n", test_ret); + return(test_ret); +} +#ifdef LIBXML_OUTPUT_ENABLED + +#define gen_nb_xmlSaveCtxtPtr 1 +static xmlSaveCtxtPtr gen_xmlSaveCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSaveCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSaveCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSaveClose(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlSaveCtxtPtr ctxt; /* a document saving context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); + + ret_val = xmlSaveClose(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + long ret_val; + xmlSaveCtxtPtr ctxt; /* a document saving context */ + int n_ctxt; + xmlDocPtr doc; /* a document */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlSaveDoc(ctxt, doc); + desret_long(ret_val); + call_tests++; + des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveFlush(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlSaveCtxtPtr ctxt; /* a document saving context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); + + ret_val = xmlSaveFlush(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFlush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSaveSetAttrEscape(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSaveSetEscape(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSaveToBuffer(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSaveToFd(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSaveToFilename(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSaveTree(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + long ret_val; + xmlSaveCtxtPtr ctxt; /* a document saving context */ + int n_ctxt; + xmlNodePtr cur; /* */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlSaveTree(ctxt, cur); + desret_long(ret_val); + call_tests++; + des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveTree", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlsave(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlsave : 4 of 10 functions ...\n"); + test_ret += test_xmlSaveClose(); + test_ret += test_xmlSaveDoc(); + test_ret += test_xmlSaveFlush(); + test_ret += test_xmlSaveSetAttrEscape(); + test_ret += test_xmlSaveSetEscape(); + test_ret += test_xmlSaveToBuffer(); + test_ret += test_xmlSaveToFd(); + test_ret += test_xmlSaveToFilename(); + test_ret += test_xmlSaveTree(); + + if (test_ret != 0) + printf("Module xmlsave: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlSchemaDump(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + FILE * output; /* the file output */ + int n_output; + xmlSchemaPtr schema; /* a schema structure */ + int n_schema; + + for (n_output = 0;n_output < gen_nb_FILE_ptr;n_output++) { + for (n_schema = 0;n_schema < gen_nb_xmlSchemaPtr;n_schema++) { + mem_base = xmlMemBlocks(); + output = gen_FILE_ptr(n_output, 0); + schema = gen_xmlSchemaPtr(n_schema, 1); + + xmlSchemaDump(output, schema); + call_tests++; + des_FILE_ptr(n_output, output, 0); + des_xmlSchemaPtr(n_schema, schema, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaDump", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_schema); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaParserCtxtPtr 1 +static xmlSchemaParserCtxtPtr gen_xmlSchemaParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaValidityErrorFunc_ptr 1 +static xmlSchemaValidityErrorFunc * gen_xmlSchemaValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaValidityErrorFunc_ptr(int no ATTRIBUTE_UNUSED, xmlSchemaValidityErrorFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaValidityWarningFunc_ptr 1 +static xmlSchemaValidityWarningFunc * gen_xmlSchemaValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaValidityWarningFunc_ptr(int no ATTRIBUTE_UNUSED, xmlSchemaValidityWarningFunc * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSchemaGetParserErrors(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaParserCtxtPtr ctxt; /* a XMl-Schema parser context */ + int n_ctxt; + xmlSchemaValidityErrorFunc * err; /* the error callback result */ + int n_err; + xmlSchemaValidityWarningFunc * warn; /* the warning callback result */ + int n_warn; + void ** ctx; /* contextual data for the callbacks result */ + int n_ctx; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaParserCtxtPtr;n_ctxt++) { + for (n_err = 0;n_err < gen_nb_xmlSchemaValidityErrorFunc_ptr;n_err++) { + for (n_warn = 0;n_warn < gen_nb_xmlSchemaValidityWarningFunc_ptr;n_warn++) { + for (n_ctx = 0;n_ctx < gen_nb_void_ptr_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaParserCtxtPtr(n_ctxt, 0); + err = gen_xmlSchemaValidityErrorFunc_ptr(n_err, 1); + warn = gen_xmlSchemaValidityWarningFunc_ptr(n_warn, 2); + ctx = gen_void_ptr_ptr(n_ctx, 3); + + ret_val = xmlSchemaGetParserErrors(ctxt, err, warn, ctx); + desret_int(ret_val); + call_tests++; + des_xmlSchemaParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlSchemaValidityErrorFunc_ptr(n_err, err, 1); + des_xmlSchemaValidityWarningFunc_ptr(n_warn, warn, 2); + des_void_ptr_ptr(n_ctx, ctx, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetParserErrors", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_err); + printf(" %d", n_warn); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetValidErrors(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a XML-Schema validation context */ + int n_ctxt; + xmlSchemaValidityErrorFunc * err; /* the error function result */ + int n_err; + xmlSchemaValidityWarningFunc * warn; /* the warning function result */ + int n_warn; + void ** ctx; /* the functions context result */ + int n_ctx; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_err = 0;n_err < gen_nb_xmlSchemaValidityErrorFunc_ptr;n_err++) { + for (n_warn = 0;n_warn < gen_nb_xmlSchemaValidityWarningFunc_ptr;n_warn++) { + for (n_ctx = 0;n_ctx < gen_nb_void_ptr_ptr;n_ctx++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + err = gen_xmlSchemaValidityErrorFunc_ptr(n_err, 1); + warn = gen_xmlSchemaValidityWarningFunc_ptr(n_warn, 2); + ctx = gen_void_ptr_ptr(n_ctx, 3); + + ret_val = xmlSchemaGetValidErrors(ctxt, err, warn, ctx); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlSchemaValidityErrorFunc_ptr(n_err, err, 1); + des_xmlSchemaValidityWarningFunc_ptr(n_warn, warn, 2); + des_void_ptr_ptr(n_ctx, ctx, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetValidErrors", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_err); + printf(" %d", n_warn); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaIsValid(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* the schema validation context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + + ret_val = xmlSchemaIsValid(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaIsValid", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaNewDocParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaParserCtxtPtr ret_val; + xmlDocPtr doc; /* a preparsed document tree */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + + ret_val = xmlSchemaNewDocParserCtxt(doc); + desret_xmlSchemaParserCtxtPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaNewDocParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaNewMemParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaParserCtxtPtr ret_val; + char * buffer; /* a pointer to a char array containing the schemas */ + int n_buffer; + int size; /* the size of the array */ + int n_size; + + for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { + for (n_size = 0;n_size < gen_nb_int;n_size++) { + mem_base = xmlMemBlocks(); + buffer = gen_const_char_ptr(n_buffer, 0); + size = gen_int(n_size, 1); + if ((buffer != NULL) && + (size > (int) strlen((const char *) buffer) + 1)) + continue; + + ret_val = xmlSchemaNewMemParserCtxt((const char *)buffer, size); + desret_xmlSchemaParserCtxtPtr(ret_val); + call_tests++; + des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_int(n_size, size, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaNewMemParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buffer); + printf(" %d", n_size); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaNewParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaParserCtxtPtr ret_val; + char * URL; /* the location of the schema */ + int n_URL; + + for (n_URL = 0;n_URL < gen_nb_const_char_ptr;n_URL++) { + mem_base = xmlMemBlocks(); + URL = gen_const_char_ptr(n_URL, 0); + + ret_val = xmlSchemaNewParserCtxt((const char *)URL); + desret_xmlSchemaParserCtxtPtr(ret_val); + call_tests++; + des_const_char_ptr(n_URL, (const char *)URL, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaNewParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URL); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaNewValidCtxt(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaParse(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaSAXPlug(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaSAXPlugPtr 1 +static xmlSchemaSAXPlugPtr gen_xmlSchemaSAXPlugPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaSAXPlugPtr(int no ATTRIBUTE_UNUSED, xmlSchemaSAXPlugPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSchemaSAXUnplug(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaSAXPlugPtr plug; /* a data structure returned by xmlSchemaSAXPlug */ + int n_plug; + + for (n_plug = 0;n_plug < gen_nb_xmlSchemaSAXPlugPtr;n_plug++) { + mem_base = xmlMemBlocks(); + plug = gen_xmlSchemaSAXPlugPtr(n_plug, 0); + + ret_val = xmlSchemaSAXUnplug(plug); + desret_int(ret_val); + call_tests++; + des_xmlSchemaSAXPlugPtr(n_plug, plug, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaSAXUnplug", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_plug); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaSetParserErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaSetParserStructuredErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaSetValidErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaSetValidOptions(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + int options; /* a combination of xmlSchemaValidOption */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + options = gen_int(n_options, 1); + + ret_val = xmlSchemaSetValidOptions(ctxt, options); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + des_int(n_options, options, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaSetValidOptions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_options); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaSetValidStructuredErrors(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaValidCtxtGetOptions(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + + ret_val = xmlSchemaValidCtxtGetOptions(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidCtxtGetOptions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidCtxtGetParserCtxt(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlParserCtxtPtr ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + + ret_val = xmlSchemaValidCtxtGetParserCtxt(ctxt); + desret_xmlParserCtxtPtr(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidCtxtGetParserCtxt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateDoc(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + xmlDocPtr doc; /* a parsed document tree */ + int n_doc; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + doc = gen_xmlDocPtr(n_doc, 1); + + ret_val = xmlSchemaValidateDoc(ctxt, doc); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDocPtr(n_doc, doc, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateDoc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_doc); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateFile(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + const char * filename; /* the URI of the instance */ + int n_filename; + int options; /* a future set of options, currently unused */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + filename = gen_filepath(n_filename, 1); + options = gen_int(n_options, 2); + + ret_val = xmlSchemaValidateFile(ctxt, filename, options); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + des_filepath(n_filename, filename, 1); + des_int(n_options, options, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateFile", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_filename); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateOneElement(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + xmlNodePtr elem; /* an element node */ + int n_elem; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + elem = gen_xmlNodePtr(n_elem, 1); + + ret_val = xmlSchemaValidateOneElement(ctxt, elem); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_elem, elem, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateOneElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_elem); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateSetFilename(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaValidCtxtPtr vctxt; /* the schema validation context */ + int n_vctxt; + const char * filename; /* the file name */ + int n_filename; + + for (n_vctxt = 0;n_vctxt < gen_nb_xmlSchemaValidCtxtPtr;n_vctxt++) { + for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { + mem_base = xmlMemBlocks(); + vctxt = gen_xmlSchemaValidCtxtPtr(n_vctxt, 0); + filename = gen_filepath(n_filename, 1); + + xmlSchemaValidateSetFilename(vctxt, filename); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_vctxt, vctxt, 0); + des_filepath(n_filename, filename, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateSetFilename", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_vctxt); + printf(" %d", n_filename); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateSetLocator(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaValidateStream(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValidCtxtPtr ctxt; /* a schema validation context */ + int n_ctxt; + xmlParserInputBufferPtr input; /* the input to use for reading the data */ + int n_input; + xmlCharEncoding enc; /* an optional encoding information */ + int n_enc; + xmlSAXHandlerPtr sax; /* a SAX handler for the resulting events */ + int n_sax; + void * user_data; /* the context to provide to the SAX handler. */ + int n_user_data; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSchemaValidCtxtPtr;n_ctxt++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { + for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { + for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { + for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSchemaValidCtxtPtr(n_ctxt, 0); + input = gen_xmlParserInputBufferPtr(n_input, 1); + enc = gen_xmlCharEncoding(n_enc, 2); + sax = gen_xmlSAXHandlerPtr(n_sax, 3); + user_data = gen_userdata(n_user_data, 4); + + ret_val = xmlSchemaValidateStream(ctxt, input, enc, sax, user_data); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValidCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputBufferPtr(n_input, input, 1); + des_xmlCharEncoding(n_enc, enc, 2); + des_xmlSAXHandlerPtr(n_sax, sax, 3); + des_userdata(n_user_data, user_data, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateStream", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_input); + printf(" %d", n_enc); + printf(" %d", n_sax); + printf(" %d", n_user_data); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlschemas(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlschemas : 16 of 27 functions ...\n"); + test_ret += test_xmlSchemaDump(); + test_ret += test_xmlSchemaGetParserErrors(); + test_ret += test_xmlSchemaGetValidErrors(); + test_ret += test_xmlSchemaIsValid(); + test_ret += test_xmlSchemaNewDocParserCtxt(); + test_ret += test_xmlSchemaNewMemParserCtxt(); + test_ret += test_xmlSchemaNewParserCtxt(); + test_ret += test_xmlSchemaNewValidCtxt(); + test_ret += test_xmlSchemaParse(); + test_ret += test_xmlSchemaSAXPlug(); + test_ret += test_xmlSchemaSAXUnplug(); + test_ret += test_xmlSchemaSetParserErrors(); + test_ret += test_xmlSchemaSetParserStructuredErrors(); + test_ret += test_xmlSchemaSetValidErrors(); + test_ret += test_xmlSchemaSetValidOptions(); + test_ret += test_xmlSchemaSetValidStructuredErrors(); + test_ret += test_xmlSchemaValidCtxtGetOptions(); + test_ret += test_xmlSchemaValidCtxtGetParserCtxt(); + test_ret += test_xmlSchemaValidateDoc(); + test_ret += test_xmlSchemaValidateFile(); + test_ret += test_xmlSchemaValidateOneElement(); + test_ret += test_xmlSchemaValidateSetFilename(); + test_ret += test_xmlSchemaValidateSetLocator(); + test_ret += test_xmlSchemaValidateStream(); + + if (test_ret != 0) + printf("Module xmlschemas: %d errors\n", test_ret); + return(test_ret); +} +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaFacetPtr 1 +static xmlSchemaFacetPtr gen_xmlSchemaFacetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaFacetPtr(int no ATTRIBUTE_UNUSED, xmlSchemaFacetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaTypePtr 1 +static xmlSchemaTypePtr gen_xmlSchemaTypePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaTypePtr(int no ATTRIBUTE_UNUSED, xmlSchemaTypePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSchemaCheckFacet(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaFacetPtr facet; /* the facet */ + int n_facet; + xmlSchemaTypePtr typeDecl; /* the schema type definition */ + int n_typeDecl; + xmlSchemaParserCtxtPtr pctxt; /* the schema parser context or NULL */ + int n_pctxt; + xmlChar * name; /* the optional name of the type */ + int n_name; + + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + for (n_typeDecl = 0;n_typeDecl < gen_nb_xmlSchemaTypePtr;n_typeDecl++) { + for (n_pctxt = 0;n_pctxt < gen_nb_xmlSchemaParserCtxtPtr;n_pctxt++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + facet = gen_xmlSchemaFacetPtr(n_facet, 0); + typeDecl = gen_xmlSchemaTypePtr(n_typeDecl, 1); + pctxt = gen_xmlSchemaParserCtxtPtr(n_pctxt, 2); + name = gen_const_xmlChar_ptr(n_name, 3); + + ret_val = xmlSchemaCheckFacet(facet, typeDecl, pctxt, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlSchemaFacetPtr(n_facet, facet, 0); + des_xmlSchemaTypePtr(n_typeDecl, typeDecl, 1); + des_xmlSchemaParserCtxtPtr(n_pctxt, pctxt, 2); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaCheckFacet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_facet); + printf(" %d", n_typeDecl); + printf(" %d", n_pctxt); + printf(" %d", n_name); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaCleanupTypes(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + + + xmlSchemaCleanupTypes(); + call_tests++; + xmlResetLastError(); + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaCollapseString(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlChar * value; /* a value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlSchemaCollapseString((const xmlChar *)value); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaCollapseString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaValPtr 1 +static xmlSchemaValPtr gen_xmlSchemaValPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaValPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSchemaCompareValues(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValPtr x; /* a first value */ + int n_x; + xmlSchemaValPtr y; /* a second value */ + int n_y; + + for (n_x = 0;n_x < gen_nb_xmlSchemaValPtr;n_x++) { + for (n_y = 0;n_y < gen_nb_xmlSchemaValPtr;n_y++) { + mem_base = xmlMemBlocks(); + x = gen_xmlSchemaValPtr(n_x, 0); + y = gen_xmlSchemaValPtr(n_y, 1); + + ret_val = xmlSchemaCompareValues(x, y); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_x, x, 0); + des_xmlSchemaValPtr(n_y, y, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaCompareValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_x); + printf(" %d", n_y); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaCompareValuesWhtsp(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValPtr x; /* a first value */ + int n_x; + xmlSchemaWhitespaceValueType xws; /* the whitespace value of x */ + int n_xws; + xmlSchemaValPtr y; /* a second value */ + int n_y; + xmlSchemaWhitespaceValueType yws; /* the whitespace value of y */ + int n_yws; + + for (n_x = 0;n_x < gen_nb_xmlSchemaValPtr;n_x++) { + for (n_xws = 0;n_xws < gen_nb_xmlSchemaWhitespaceValueType;n_xws++) { + for (n_y = 0;n_y < gen_nb_xmlSchemaValPtr;n_y++) { + for (n_yws = 0;n_yws < gen_nb_xmlSchemaWhitespaceValueType;n_yws++) { + mem_base = xmlMemBlocks(); + x = gen_xmlSchemaValPtr(n_x, 0); + xws = gen_xmlSchemaWhitespaceValueType(n_xws, 1); + y = gen_xmlSchemaValPtr(n_y, 2); + yws = gen_xmlSchemaWhitespaceValueType(n_yws, 3); + + ret_val = xmlSchemaCompareValuesWhtsp(x, xws, y, yws); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_x, x, 0); + des_xmlSchemaWhitespaceValueType(n_xws, xws, 1); + des_xmlSchemaValPtr(n_y, y, 2); + des_xmlSchemaWhitespaceValueType(n_yws, yws, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaCompareValuesWhtsp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_x); + printf(" %d", n_xws); + printf(" %d", n_y); + printf(" %d", n_yws); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaCopyValue(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaGetBuiltInListSimpleTypeItemType(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaTypePtr ret_val; + xmlSchemaTypePtr type; /* the built-in simple type. */ + int n_type; + + for (n_type = 0;n_type < gen_nb_xmlSchemaTypePtr;n_type++) { + mem_base = xmlMemBlocks(); + type = gen_xmlSchemaTypePtr(n_type, 0); + + ret_val = xmlSchemaGetBuiltInListSimpleTypeItemType(type); + desret_xmlSchemaTypePtr(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_type, type, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetBuiltInListSimpleTypeItemType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetBuiltInType(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + xmlSchemaTypePtr ret_val; + xmlSchemaValType type; /* the type of the built in type */ + int n_type; + + for (n_type = 0;n_type < gen_nb_xmlSchemaValType;n_type++) { + type = gen_xmlSchemaValType(n_type, 0); + + ret_val = xmlSchemaGetBuiltInType(type); + desret_xmlSchemaTypePtr(ret_val); + call_tests++; + des_xmlSchemaValType(n_type, type, 0); + xmlResetLastError(); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetCanonValue(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValPtr val; /* the precomputed value */ + int n_val; + xmlChar ** retValue; /* the returned value */ + int n_retValue; + + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + for (n_retValue = 0;n_retValue < gen_nb_const_xmlChar_ptr_ptr;n_retValue++) { + mem_base = xmlMemBlocks(); + val = gen_xmlSchemaValPtr(n_val, 0); + retValue = gen_const_xmlChar_ptr_ptr(n_retValue, 1); + + ret_val = xmlSchemaGetCanonValue(val, (const xmlChar **)retValue); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_val, val, 0); + des_const_xmlChar_ptr_ptr(n_retValue, (const xmlChar **)retValue, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetCanonValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf(" %d", n_retValue); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetCanonValueWhtsp(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValPtr val; /* the precomputed value */ + int n_val; + xmlChar ** retValue; /* the returned value */ + int n_retValue; + xmlSchemaWhitespaceValueType ws; /* the whitespace type of the value */ + int n_ws; + + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + for (n_retValue = 0;n_retValue < gen_nb_const_xmlChar_ptr_ptr;n_retValue++) { + for (n_ws = 0;n_ws < gen_nb_xmlSchemaWhitespaceValueType;n_ws++) { + mem_base = xmlMemBlocks(); + val = gen_xmlSchemaValPtr(n_val, 0); + retValue = gen_const_xmlChar_ptr_ptr(n_retValue, 1); + ws = gen_xmlSchemaWhitespaceValueType(n_ws, 2); + + ret_val = xmlSchemaGetCanonValueWhtsp(val, (const xmlChar **)retValue, ws); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_val, val, 0); + des_const_xmlChar_ptr_ptr(n_retValue, (const xmlChar **)retValue, 1); + des_xmlSchemaWhitespaceValueType(n_ws, ws, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetCanonValueWhtsp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf(" %d", n_retValue); + printf(" %d", n_ws); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetFacetValueAsULong(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + unsigned long ret_val; + xmlSchemaFacetPtr facet; /* an schemas type facet */ + int n_facet; + + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + mem_base = xmlMemBlocks(); + facet = gen_xmlSchemaFacetPtr(n_facet, 0); + + ret_val = xmlSchemaGetFacetValueAsULong(facet); + desret_unsigned_long(ret_val); + call_tests++; + des_xmlSchemaFacetPtr(n_facet, facet, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetFacetValueAsULong", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_facet); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetPredefinedType(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaTypePtr ret_val; + xmlChar * name; /* the type name */ + int n_name; + xmlChar * ns; /* the URI of the namespace usually "http://www.w3.org/2001/XMLSchema" */ + int n_ns; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns = 0;n_ns < gen_nb_const_xmlChar_ptr;n_ns++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + ns = gen_const_xmlChar_ptr(n_ns, 1); + + ret_val = xmlSchemaGetPredefinedType((const xmlChar *)name, (const xmlChar *)ns); + desret_xmlSchemaTypePtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetPredefinedType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf(" %d", n_ns); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaGetValType(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlSchemaValType ret_val; + xmlSchemaValPtr val; /* a schemas value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlSchemaValPtr(n_val, 0); + + ret_val = xmlSchemaGetValType(val); + desret_xmlSchemaValType(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaGetValType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaInitTypes(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + + + xmlSchemaInitTypes(); + call_tests++; + xmlResetLastError(); + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaIsBuiltInTypeFacet(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaTypePtr type; /* the built-in type */ + int n_type; + int facetType; /* the facet type */ + int n_facetType; + + for (n_type = 0;n_type < gen_nb_xmlSchemaTypePtr;n_type++) { + for (n_facetType = 0;n_facetType < gen_nb_int;n_facetType++) { + mem_base = xmlMemBlocks(); + type = gen_xmlSchemaTypePtr(n_type, 0); + facetType = gen_int(n_facetType, 1); + + ret_val = xmlSchemaIsBuiltInTypeFacet(type, facetType); + desret_int(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_type, type, 0); + des_int(n_facetType, facetType, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaIsBuiltInTypeFacet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_facetType); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaNewFacet(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaNewNOTATIONValue(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaNewQNameValue(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaNewStringValue(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_SCHEMAS_ENABLED + +#define gen_nb_xmlSchemaValPtr_ptr 1 +static xmlSchemaValPtr * gen_xmlSchemaValPtr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlSchemaValPtr_ptr(int no ATTRIBUTE_UNUSED, xmlSchemaValPtr * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlSchemaValPredefTypeNode(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaTypePtr type; /* the predefined type */ + int n_type; + xmlChar * value; /* the value to check */ + int n_value; + xmlSchemaValPtr * val; /* the return computed value */ + int n_val; + xmlNodePtr node; /* the node containing the value */ + int n_node; + + for (n_type = 0;n_type < gen_nb_xmlSchemaTypePtr;n_type++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr_ptr;n_val++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + type = gen_xmlSchemaTypePtr(n_type, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + val = gen_xmlSchemaValPtr_ptr(n_val, 2); + node = gen_xmlNodePtr(n_node, 3); + + ret_val = xmlSchemaValPredefTypeNode(type, (const xmlChar *)value, val, node); + desret_int(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_type, type, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_xmlSchemaValPtr_ptr(n_val, val, 2); + des_xmlNodePtr(n_node, node, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValPredefTypeNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_value); + printf(" %d", n_val); + printf(" %d", n_node); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValPredefTypeNodeNoNorm(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaTypePtr type; /* the predefined type */ + int n_type; + xmlChar * value; /* the value to check */ + int n_value; + xmlSchemaValPtr * val; /* the return computed value */ + int n_val; + xmlNodePtr node; /* the node containing the value */ + int n_node; + + for (n_type = 0;n_type < gen_nb_xmlSchemaTypePtr;n_type++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr_ptr;n_val++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + type = gen_xmlSchemaTypePtr(n_type, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + val = gen_xmlSchemaValPtr_ptr(n_val, 2); + node = gen_xmlNodePtr(n_node, 3); + + ret_val = xmlSchemaValPredefTypeNodeNoNorm(type, (const xmlChar *)value, val, node); + desret_int(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_type, type, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_xmlSchemaValPtr_ptr(n_val, val, 2); + des_xmlNodePtr(n_node, node, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValPredefTypeNodeNoNorm", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_value); + printf(" %d", n_val); + printf(" %d", n_node); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateFacet(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaTypePtr base; /* the base type */ + int n_base; + xmlSchemaFacetPtr facet; /* the facet to check */ + int n_facet; + xmlChar * value; /* the lexical repr of the value to validate */ + int n_value; + xmlSchemaValPtr val; /* the precomputed value */ + int n_val; + + for (n_base = 0;n_base < gen_nb_xmlSchemaTypePtr;n_base++) { + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + mem_base = xmlMemBlocks(); + base = gen_xmlSchemaTypePtr(n_base, 0); + facet = gen_xmlSchemaFacetPtr(n_facet, 1); + value = gen_const_xmlChar_ptr(n_value, 2); + val = gen_xmlSchemaValPtr(n_val, 3); + + ret_val = xmlSchemaValidateFacet(base, facet, (const xmlChar *)value, val); + desret_int(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_base, base, 0); + des_xmlSchemaFacetPtr(n_facet, facet, 1); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_xmlSchemaValPtr(n_val, val, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateFacet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_base); + printf(" %d", n_facet); + printf(" %d", n_value); + printf(" %d", n_val); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateFacetWhtsp(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaFacetPtr facet; /* the facet to check */ + int n_facet; + xmlSchemaWhitespaceValueType fws; /* the whitespace type of the facet's value */ + int n_fws; + xmlSchemaValType valType; /* the built-in type of the value */ + int n_valType; + xmlChar * value; /* the lexical (or normalized for pattern) repr of the value to validate */ + int n_value; + xmlSchemaValPtr val; /* the precomputed value */ + int n_val; + xmlSchemaWhitespaceValueType ws; /* the whitespace type of the value */ + int n_ws; + + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + for (n_fws = 0;n_fws < gen_nb_xmlSchemaWhitespaceValueType;n_fws++) { + for (n_valType = 0;n_valType < gen_nb_xmlSchemaValType;n_valType++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + for (n_ws = 0;n_ws < gen_nb_xmlSchemaWhitespaceValueType;n_ws++) { + mem_base = xmlMemBlocks(); + facet = gen_xmlSchemaFacetPtr(n_facet, 0); + fws = gen_xmlSchemaWhitespaceValueType(n_fws, 1); + valType = gen_xmlSchemaValType(n_valType, 2); + value = gen_const_xmlChar_ptr(n_value, 3); + val = gen_xmlSchemaValPtr(n_val, 4); + ws = gen_xmlSchemaWhitespaceValueType(n_ws, 5); + + ret_val = xmlSchemaValidateFacetWhtsp(facet, fws, valType, (const xmlChar *)value, val, ws); + desret_int(ret_val); + call_tests++; + des_xmlSchemaFacetPtr(n_facet, facet, 0); + des_xmlSchemaWhitespaceValueType(n_fws, fws, 1); + des_xmlSchemaValType(n_valType, valType, 2); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + des_xmlSchemaValPtr(n_val, val, 4); + des_xmlSchemaWhitespaceValueType(n_ws, ws, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateFacetWhtsp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_facet); + printf(" %d", n_fws); + printf(" %d", n_valType); + printf(" %d", n_value); + printf(" %d", n_val); + printf(" %d", n_ws); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateLengthFacet(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaTypePtr type; /* the built-in type */ + int n_type; + xmlSchemaFacetPtr facet; /* the facet to check */ + int n_facet; + xmlChar * value; /* the lexical repr. of the value to be validated */ + int n_value; + xmlSchemaValPtr val; /* the precomputed value */ + int n_val; + unsigned long * length; /* the actual length of the value */ + int n_length; + + for (n_type = 0;n_type < gen_nb_xmlSchemaTypePtr;n_type++) { + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + for (n_length = 0;n_length < gen_nb_unsigned_long_ptr;n_length++) { + mem_base = xmlMemBlocks(); + type = gen_xmlSchemaTypePtr(n_type, 0); + facet = gen_xmlSchemaFacetPtr(n_facet, 1); + value = gen_const_xmlChar_ptr(n_value, 2); + val = gen_xmlSchemaValPtr(n_val, 3); + length = gen_unsigned_long_ptr(n_length, 4); + + ret_val = xmlSchemaValidateLengthFacet(type, facet, (const xmlChar *)value, val, length); + desret_int(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_type, type, 0); + des_xmlSchemaFacetPtr(n_facet, facet, 1); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_xmlSchemaValPtr(n_val, val, 3); + des_unsigned_long_ptr(n_length, length, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateLengthFacet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_facet); + printf(" %d", n_value); + printf(" %d", n_val); + printf(" %d", n_length); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateLengthFacetWhtsp(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaFacetPtr facet; /* the facet to check */ + int n_facet; + xmlSchemaValType valType; /* the built-in type */ + int n_valType; + xmlChar * value; /* the lexical repr. of the value to be validated */ + int n_value; + xmlSchemaValPtr val; /* the precomputed value */ + int n_val; + unsigned long * length; /* the actual length of the value */ + int n_length; + xmlSchemaWhitespaceValueType ws; /* the whitespace type of the value */ + int n_ws; + + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + for (n_valType = 0;n_valType < gen_nb_xmlSchemaValType;n_valType++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + for (n_length = 0;n_length < gen_nb_unsigned_long_ptr;n_length++) { + for (n_ws = 0;n_ws < gen_nb_xmlSchemaWhitespaceValueType;n_ws++) { + mem_base = xmlMemBlocks(); + facet = gen_xmlSchemaFacetPtr(n_facet, 0); + valType = gen_xmlSchemaValType(n_valType, 1); + value = gen_const_xmlChar_ptr(n_value, 2); + val = gen_xmlSchemaValPtr(n_val, 3); + length = gen_unsigned_long_ptr(n_length, 4); + ws = gen_xmlSchemaWhitespaceValueType(n_ws, 5); + + ret_val = xmlSchemaValidateLengthFacetWhtsp(facet, valType, (const xmlChar *)value, val, length, ws); + desret_int(ret_val); + call_tests++; + des_xmlSchemaFacetPtr(n_facet, facet, 0); + des_xmlSchemaValType(n_valType, valType, 1); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_xmlSchemaValPtr(n_val, val, 3); + des_unsigned_long_ptr(n_length, length, 4); + des_xmlSchemaWhitespaceValueType(n_ws, ws, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateLengthFacetWhtsp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_facet); + printf(" %d", n_valType); + printf(" %d", n_value); + printf(" %d", n_val); + printf(" %d", n_length); + printf(" %d", n_ws); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidateListSimpleTypeFacet(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaFacetPtr facet; /* the facet to check */ + int n_facet; + xmlChar * value; /* the lexical repr of the value to validate */ + int n_value; + unsigned long actualLen; /* the number of list items */ + int n_actualLen; + unsigned long * expectedLen; /* the resulting expected number of list items */ + int n_expectedLen; + + for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_actualLen = 0;n_actualLen < gen_nb_unsigned_long;n_actualLen++) { + for (n_expectedLen = 0;n_expectedLen < gen_nb_unsigned_long_ptr;n_expectedLen++) { + mem_base = xmlMemBlocks(); + facet = gen_xmlSchemaFacetPtr(n_facet, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + actualLen = gen_unsigned_long(n_actualLen, 2); + expectedLen = gen_unsigned_long_ptr(n_expectedLen, 3); + + ret_val = xmlSchemaValidateListSimpleTypeFacet(facet, (const xmlChar *)value, actualLen, expectedLen); + desret_int(ret_val); + call_tests++; + des_xmlSchemaFacetPtr(n_facet, facet, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_unsigned_long(n_actualLen, actualLen, 2); + des_unsigned_long_ptr(n_expectedLen, expectedLen, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidateListSimpleTypeFacet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_facet); + printf(" %d", n_value); + printf(" %d", n_actualLen); + printf(" %d", n_expectedLen); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValidatePredefinedType(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaTypePtr type; /* the predefined type */ + int n_type; + xmlChar * value; /* the value to check */ + int n_value; + xmlSchemaValPtr * val; /* the return computed value */ + int n_val; + + for (n_type = 0;n_type < gen_nb_xmlSchemaTypePtr;n_type++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr_ptr;n_val++) { + mem_base = xmlMemBlocks(); + type = gen_xmlSchemaTypePtr(n_type, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + val = gen_xmlSchemaValPtr_ptr(n_val, 2); + + ret_val = xmlSchemaValidatePredefinedType(type, (const xmlChar *)value, val); + desret_int(ret_val); + call_tests++; + des_xmlSchemaTypePtr(n_type, type, 0); + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_xmlSchemaValPtr_ptr(n_val, val, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValidatePredefinedType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_type); + printf(" %d", n_value); + printf(" %d", n_val); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValueAppend(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValPtr prev; /* the value */ + int n_prev; + xmlSchemaValPtr cur; /* the value to be appended */ + int n_cur; + + for (n_prev = 0;n_prev < gen_nb_xmlSchemaValPtr;n_prev++) { + for (n_cur = 0;n_cur < gen_nb_xmlSchemaValPtr;n_cur++) { + mem_base = xmlMemBlocks(); + prev = gen_xmlSchemaValPtr(n_prev, 0); + cur = gen_xmlSchemaValPtr(n_cur, 1); + + ret_val = xmlSchemaValueAppend(prev, cur); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_prev, prev, 0); + des_xmlSchemaValPtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValueAppend", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_prev); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValueGetAsBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + xmlSchemaValPtr val; /* the value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlSchemaValPtr(n_val, 0); + + ret_val = xmlSchemaValueGetAsBoolean(val); + desret_int(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValueGetAsBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValueGetAsString(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlSchemaValPtr val; /* the value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlSchemaValPtr(n_val, 0); + + ret_val = xmlSchemaValueGetAsString(val); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlSchemaValPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaValueGetAsString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlSchemaValueGetNext(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlSchemaWhiteSpaceReplace(void) { + int test_ret = 0; + +#if defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlChar * value; /* a value */ + int n_value; + + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + value = gen_const_xmlChar_ptr(n_value, 0); + + ret_val = xmlSchemaWhiteSpaceReplace((const xmlChar *)value); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSchemaWhiteSpaceReplace", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_value); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlschemastypes(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlschemastypes : 26 of 34 functions ...\n"); + test_ret += test_xmlSchemaCheckFacet(); + test_ret += test_xmlSchemaCleanupTypes(); + test_ret += test_xmlSchemaCollapseString(); + test_ret += test_xmlSchemaCompareValues(); + test_ret += test_xmlSchemaCompareValuesWhtsp(); + test_ret += test_xmlSchemaCopyValue(); + test_ret += test_xmlSchemaGetBuiltInListSimpleTypeItemType(); + test_ret += test_xmlSchemaGetBuiltInType(); + test_ret += test_xmlSchemaGetCanonValue(); + test_ret += test_xmlSchemaGetCanonValueWhtsp(); + test_ret += test_xmlSchemaGetFacetValueAsULong(); + test_ret += test_xmlSchemaGetPredefinedType(); + test_ret += test_xmlSchemaGetValType(); + test_ret += test_xmlSchemaInitTypes(); + test_ret += test_xmlSchemaIsBuiltInTypeFacet(); + test_ret += test_xmlSchemaNewFacet(); + test_ret += test_xmlSchemaNewNOTATIONValue(); + test_ret += test_xmlSchemaNewQNameValue(); + test_ret += test_xmlSchemaNewStringValue(); + test_ret += test_xmlSchemaValPredefTypeNode(); + test_ret += test_xmlSchemaValPredefTypeNodeNoNorm(); + test_ret += test_xmlSchemaValidateFacet(); + test_ret += test_xmlSchemaValidateFacetWhtsp(); + test_ret += test_xmlSchemaValidateLengthFacet(); + test_ret += test_xmlSchemaValidateLengthFacetWhtsp(); + test_ret += test_xmlSchemaValidateListSimpleTypeFacet(); + test_ret += test_xmlSchemaValidatePredefinedType(); + test_ret += test_xmlSchemaValueAppend(); + test_ret += test_xmlSchemaValueGetAsBoolean(); + test_ret += test_xmlSchemaValueGetAsString(); + test_ret += test_xmlSchemaValueGetNext(); + test_ret += test_xmlSchemaWhiteSpaceReplace(); + + if (test_ret != 0) + printf("Module xmlschemastypes: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlCharStrdup(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + char * cur; /* the input char * */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_char_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_char_ptr(n_cur, 0); + + ret_val = xmlCharStrdup((const char *)cur); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_char_ptr(n_cur, (const char *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharStrdup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCharStrndup(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + char * cur; /* the input char * */ + int n_cur; + int len; /* the len of @cur */ + int n_len; + + for (n_cur = 0;n_cur < gen_nb_const_char_ptr;n_cur++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + cur = gen_const_char_ptr(n_cur, 0); + len = gen_int(n_len, 1); + if ((cur != NULL) && + (len > (int) strlen((const char *) cur) + 1)) + continue; + + ret_val = xmlCharStrndup((const char *)cur, len); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_char_ptr(n_cur, (const char *)cur, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCharStrndup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCheckUTF8(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned char * utf; /* Pointer to putative UTF-8 encoded string. */ + int n_utf; + + for (n_utf = 0;n_utf < gen_nb_const_unsigned_char_ptr;n_utf++) { + mem_base = xmlMemBlocks(); + utf = gen_const_unsigned_char_ptr(n_utf, 0); + + ret_val = xmlCheckUTF8((const unsigned char *)utf); + desret_int(ret_val); + call_tests++; + des_const_unsigned_char_ptr(n_utf, (const unsigned char *)utf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCheckUTF8", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlGetUTF8Char(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + unsigned char * utf; /* a sequence of UTF-8 encoded bytes */ + int n_utf; + int * len; /* a pointer to the minimum number of bytes present in the sequence. This is used to assure the next character is completely contained within the sequence. */ + int n_len; + + for (n_utf = 0;n_utf < gen_nb_const_unsigned_char_ptr;n_utf++) { + for (n_len = 0;n_len < gen_nb_int_ptr;n_len++) { + mem_base = xmlMemBlocks(); + utf = gen_const_unsigned_char_ptr(n_utf, 0); + len = gen_int_ptr(n_len, 1); + + ret_val = xmlGetUTF8Char((const unsigned char *)utf, len); + desret_int(ret_val); + call_tests++; + des_const_unsigned_char_ptr(n_utf, (const unsigned char *)utf, 0); + des_int_ptr(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlGetUTF8Char", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrEqual(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * str1; /* the first xmlChar * */ + int n_str1; + xmlChar * str2; /* the second xmlChar * */ + int n_str2; + + for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { + for (n_str2 = 0;n_str2 < gen_nb_const_xmlChar_ptr;n_str2++) { + mem_base = xmlMemBlocks(); + str1 = gen_const_xmlChar_ptr(n_str1, 0); + str2 = gen_const_xmlChar_ptr(n_str2, 1); + + ret_val = xmlStrEqual((const xmlChar *)str1, (const xmlChar *)str2); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); + des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrEqual", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str1); + printf(" %d", n_str2); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrPrintf(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlStrQEqual(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * pref; /* the prefix of the QName */ + int n_pref; + xmlChar * name; /* the localname of the QName */ + int n_name; + xmlChar * str; /* the second xmlChar * */ + int n_str; + + for (n_pref = 0;n_pref < gen_nb_const_xmlChar_ptr;n_pref++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + pref = gen_const_xmlChar_ptr(n_pref, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + str = gen_const_xmlChar_ptr(n_str, 2); + + ret_val = xmlStrQEqual((const xmlChar *)pref, (const xmlChar *)name, (const xmlChar *)str); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_pref, (const xmlChar *)pref, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrQEqual", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_pref); + printf(" %d", n_name); + printf(" %d", n_str); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrVPrintf(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlStrcasecmp(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * str1; /* the first xmlChar * */ + int n_str1; + xmlChar * str2; /* the second xmlChar * */ + int n_str2; + + for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { + for (n_str2 = 0;n_str2 < gen_nb_const_xmlChar_ptr;n_str2++) { + mem_base = xmlMemBlocks(); + str1 = gen_const_xmlChar_ptr(n_str1, 0); + str2 = gen_const_xmlChar_ptr(n_str2, 1); + + ret_val = xmlStrcasecmp((const xmlChar *)str1, (const xmlChar *)str2); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); + des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrcasecmp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str1); + printf(" %d", n_str2); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrcasestr(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlChar * str; /* the xmlChar * array (haystack) */ + int n_str; + xmlChar * val; /* the xmlChar to search (needle) */ + int n_val; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + val = gen_const_xmlChar_ptr(n_val, 1); + + ret_val = xmlStrcasestr((const xmlChar *)str, (const xmlChar *)val); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrcasestr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrchr(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlChar * str; /* the xmlChar * array */ + int n_str; + xmlChar val; /* the xmlChar to search */ + int n_val; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_val = 0;n_val < gen_nb_xmlChar;n_val++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + val = gen_xmlChar(n_val, 1); + + ret_val = xmlStrchr((const xmlChar *)str, val); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_xmlChar(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrchr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrcmp(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * str1; /* the first xmlChar * */ + int n_str1; + xmlChar * str2; /* the second xmlChar * */ + int n_str2; + + for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { + for (n_str2 = 0;n_str2 < gen_nb_const_xmlChar_ptr;n_str2++) { + mem_base = xmlMemBlocks(); + str1 = gen_const_xmlChar_ptr(n_str1, 0); + str2 = gen_const_xmlChar_ptr(n_str2, 1); + + ret_val = xmlStrcmp((const xmlChar *)str1, (const xmlChar *)str2); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); + des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrcmp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str1); + printf(" %d", n_str2); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrdup(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * cur; /* the input xmlChar * */ + int n_cur; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + + ret_val = xmlStrdup((const xmlChar *)cur); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrdup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrlen(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * str; /* the xmlChar * array */ + int n_str; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + + ret_val = xmlStrlen((const xmlChar *)str); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrlen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrncasecmp(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * str1; /* the first xmlChar * */ + int n_str1; + xmlChar * str2; /* the second xmlChar * */ + int n_str2; + int len; /* the max comparison length */ + int n_len; + + for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { + for (n_str2 = 0;n_str2 < gen_nb_const_xmlChar_ptr;n_str2++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + str1 = gen_const_xmlChar_ptr(n_str1, 0); + str2 = gen_const_xmlChar_ptr(n_str2, 1); + len = gen_int(n_len, 2); + if ((str2 != NULL) && + (len > (int) strlen((const char *) str2) + 1)) + continue; + + ret_val = xmlStrncasecmp((const xmlChar *)str1, (const xmlChar *)str2, len); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); + des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrncasecmp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str1); + printf(" %d", n_str2); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrncatNew(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * str1; /* first xmlChar string */ + int n_str1; + xmlChar * str2; /* second xmlChar string */ + int n_str2; + int len; /* the len of @str2 or < 0 */ + int n_len; + + for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { + for (n_str2 = 0;n_str2 < gen_nb_const_xmlChar_ptr;n_str2++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + str1 = gen_const_xmlChar_ptr(n_str1, 0); + str2 = gen_const_xmlChar_ptr(n_str2, 1); + len = gen_int(n_len, 2); + if ((str2 != NULL) && + (len > (int) strlen((const char *) str2) + 1)) + continue; + + ret_val = xmlStrncatNew((const xmlChar *)str1, (const xmlChar *)str2, len); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); + des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrncatNew", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str1); + printf(" %d", n_str2); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrncmp(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * str1; /* the first xmlChar * */ + int n_str1; + xmlChar * str2; /* the second xmlChar * */ + int n_str2; + int len; /* the max comparison length */ + int n_len; + + for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { + for (n_str2 = 0;n_str2 < gen_nb_const_xmlChar_ptr;n_str2++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + str1 = gen_const_xmlChar_ptr(n_str1, 0); + str2 = gen_const_xmlChar_ptr(n_str2, 1); + len = gen_int(n_len, 2); + if ((str2 != NULL) && + (len > (int) strlen((const char *) str2) + 1)) + continue; + + ret_val = xmlStrncmp((const xmlChar *)str1, (const xmlChar *)str2, len); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); + des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrncmp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str1); + printf(" %d", n_str2); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrndup(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * cur; /* the input xmlChar * */ + int n_cur; + int len; /* the len of @cur */ + int n_len; + + for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + cur = gen_const_xmlChar_ptr(n_cur, 0); + len = gen_int(n_len, 1); + if ((cur != NULL) && + (len > (int) strlen((const char *) cur) + 1)) + continue; + + ret_val = xmlStrndup((const xmlChar *)cur, len); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrndup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrstr(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlChar * str; /* the xmlChar * array (haystack) */ + int n_str; + xmlChar * val; /* the xmlChar to search (needle) */ + int n_val; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + val = gen_const_xmlChar_ptr(n_val, 1); + + ret_val = xmlStrstr((const xmlChar *)str, (const xmlChar *)val); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrstr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlStrsub(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * str; /* the xmlChar * array (haystack) */ + int n_str; + int start; /* the index of the first char (zero based) */ + int n_start; + int len; /* the length of the substring */ + int n_len; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_start = 0;n_start < gen_nb_int;n_start++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + start = gen_int(n_start, 1); + len = gen_int(n_len, 2); + if ((str != NULL) && + (start > (int) strlen((const char *) str) + 1)) + continue; + if ((str != NULL) && + (len > (int) strlen((const char *) str) + 1)) + continue; + + ret_val = xmlStrsub((const xmlChar *)str, start, len); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_int(n_start, start, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlStrsub", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_start); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Charcmp(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * utf1; /* pointer to first UTF8 char */ + int n_utf1; + xmlChar * utf2; /* pointer to second UTF8 char */ + int n_utf2; + + for (n_utf1 = 0;n_utf1 < gen_nb_const_xmlChar_ptr;n_utf1++) { + for (n_utf2 = 0;n_utf2 < gen_nb_const_xmlChar_ptr;n_utf2++) { + mem_base = xmlMemBlocks(); + utf1 = gen_const_xmlChar_ptr(n_utf1, 0); + utf2 = gen_const_xmlChar_ptr(n_utf2, 1); + + ret_val = xmlUTF8Charcmp((const xmlChar *)utf1, (const xmlChar *)utf2); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf1, (const xmlChar *)utf1, 0); + des_const_xmlChar_ptr(n_utf2, (const xmlChar *)utf2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Charcmp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf1); + printf(" %d", n_utf2); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Size(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * utf; /* pointer to the UTF8 character */ + int n_utf; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + + ret_val = xmlUTF8Size((const xmlChar *)utf); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Size", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Strlen(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ + int n_utf; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + + ret_val = xmlUTF8Strlen((const xmlChar *)utf); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Strlen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Strloc(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * utf; /* the input UTF8 * */ + int n_utf; + xmlChar * utfchar; /* the UTF8 character to be found */ + int n_utfchar; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + for (n_utfchar = 0;n_utfchar < gen_nb_const_xmlChar_ptr;n_utfchar++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + utfchar = gen_const_xmlChar_ptr(n_utfchar, 1); + + ret_val = xmlUTF8Strloc((const xmlChar *)utf, (const xmlChar *)utfchar); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utfchar, (const xmlChar *)utfchar, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Strloc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf(" %d", n_utfchar); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Strndup(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * utf; /* the input UTF8 * */ + int n_utf; + int len; /* the len of @utf (in chars) */ + int n_len; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + len = gen_int(n_len, 1); + if ((utf != NULL) && + (len > (int) strlen((const char *) utf) + 1)) + continue; + + ret_val = xmlUTF8Strndup((const xmlChar *)utf, len); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Strndup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Strpos(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlChar * utf; /* the input UTF8 * */ + int n_utf; + int pos; /* the position of the desired UTF8 char (in chars) */ + int n_pos; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + for (n_pos = 0;n_pos < gen_nb_int;n_pos++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + pos = gen_int(n_pos, 1); + + ret_val = xmlUTF8Strpos((const xmlChar *)utf, pos); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_int(n_pos, pos, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Strpos", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf(" %d", n_pos); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Strsize(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ + int n_utf; + int len; /* the number of characters in the array */ + int n_len; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + len = gen_int(n_len, 1); + if ((utf != NULL) && + (len > (int) strlen((const char *) utf) + 1)) + continue; + + ret_val = xmlUTF8Strsize((const xmlChar *)utf, len); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_int(n_len, len, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Strsize", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf(" %d", n_len); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlUTF8Strsub(void) { + int test_ret = 0; + + int mem_base; + xmlChar * ret_val; + xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ + int n_utf; + int start; /* relative pos of first char */ + int n_start; + int len; /* total number to copy */ + int n_len; + + for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { + for (n_start = 0;n_start < gen_nb_int;n_start++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + utf = gen_const_xmlChar_ptr(n_utf, 0); + start = gen_int(n_start, 1); + len = gen_int(n_len, 2); + if ((utf != NULL) && + (start > (int) strlen((const char *) utf) + 1)) + continue; + if ((utf != NULL) && + (len > (int) strlen((const char *) utf) + 1)) + continue; + + ret_val = xmlUTF8Strsub((const xmlChar *)utf, start, len); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_int(n_start, start, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUTF8Strsub", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_utf); + printf(" %d", n_start); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + +static int +test_xmlstring(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlstring : 26 of 30 functions ...\n"); + test_ret += test_xmlCharStrdup(); + test_ret += test_xmlCharStrndup(); + test_ret += test_xmlCheckUTF8(); + test_ret += test_xmlGetUTF8Char(); + test_ret += test_xmlStrEqual(); + test_ret += test_xmlStrPrintf(); + test_ret += test_xmlStrQEqual(); + test_ret += test_xmlStrVPrintf(); + test_ret += test_xmlStrcasecmp(); + test_ret += test_xmlStrcasestr(); + test_ret += test_xmlStrchr(); + test_ret += test_xmlStrcmp(); + test_ret += test_xmlStrdup(); + test_ret += test_xmlStrlen(); + test_ret += test_xmlStrncasecmp(); + test_ret += test_xmlStrncatNew(); + test_ret += test_xmlStrncmp(); + test_ret += test_xmlStrndup(); + test_ret += test_xmlStrstr(); + test_ret += test_xmlStrsub(); + test_ret += test_xmlUTF8Charcmp(); + test_ret += test_xmlUTF8Size(); + test_ret += test_xmlUTF8Strlen(); + test_ret += test_xmlUTF8Strloc(); + test_ret += test_xmlUTF8Strndup(); + test_ret += test_xmlUTF8Strpos(); + test_ret += test_xmlUTF8Strsize(); + test_ret += test_xmlUTF8Strsub(); + + if (test_ret != 0) + printf("Module xmlstring: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlUCSIsAegeanNumbers(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsAegeanNumbers(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsAegeanNumbers", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsAlphabeticPresentationForms(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsAlphabeticPresentationForms(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsAlphabeticPresentationForms", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsArabic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsArabic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsArabic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsArabicPresentationFormsA(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsArabicPresentationFormsA(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsArabicPresentationFormsA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsArabicPresentationFormsB(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsArabicPresentationFormsB(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsArabicPresentationFormsB", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsArmenian(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsArmenian(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsArmenian", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsArrows(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsArrows(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsArrows", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBasicLatin(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBasicLatin(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBasicLatin", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBengali(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBengali(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBengali", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBlock(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + char * block; /* UCS block name */ + int n_block; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + for (n_block = 0;n_block < gen_nb_const_char_ptr;n_block++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + block = gen_const_char_ptr(n_block, 1); + + ret_val = xmlUCSIsBlock(code, (const char *)block); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + des_const_char_ptr(n_block, (const char *)block, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBlock", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf(" %d", n_block); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBlockElements(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBlockElements(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBlockElements", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBopomofo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBopomofo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBopomofo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBopomofoExtended(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBopomofoExtended(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBopomofoExtended", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBoxDrawing(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBoxDrawing(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBoxDrawing", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBraillePatterns(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBraillePatterns(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBraillePatterns", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsBuhid(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsBuhid(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsBuhid", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsByzantineMusicalSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsByzantineMusicalSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsByzantineMusicalSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKCompatibility(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKCompatibility(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKCompatibility", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKCompatibilityForms(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKCompatibilityForms(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKCompatibilityForms", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKCompatibilityIdeographs(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKCompatibilityIdeographs(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKCompatibilityIdeographs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKCompatibilityIdeographsSupplement(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKCompatibilityIdeographsSupplement(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKCompatibilityIdeographsSupplement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKRadicalsSupplement(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKRadicalsSupplement(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKRadicalsSupplement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKSymbolsandPunctuation(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKSymbolsandPunctuation(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKSymbolsandPunctuation", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKUnifiedIdeographs(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKUnifiedIdeographs(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKUnifiedIdeographs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKUnifiedIdeographsExtensionA(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKUnifiedIdeographsExtensionA(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKUnifiedIdeographsExtensionA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCJKUnifiedIdeographsExtensionB(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCJKUnifiedIdeographsExtensionB(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCJKUnifiedIdeographsExtensionB", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCat(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + char * cat; /* UCS Category name */ + int n_cat; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + for (n_cat = 0;n_cat < gen_nb_const_char_ptr;n_cat++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + cat = gen_const_char_ptr(n_cat, 1); + + ret_val = xmlUCSIsCat(code, (const char *)cat); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + des_const_char_ptr(n_cat, (const char *)cat, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf(" %d", n_cat); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatC(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatC(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatC", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatCc(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatCc(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatCc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatCf(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatCf(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatCf", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatCo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatCo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatCo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatCs(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatCs(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatCs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatL(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatL(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatL", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatLl(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatLl(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatLl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatLm(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatLm(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatLm", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatLo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatLo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatLo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatLt(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatLt(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatLt", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatLu(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatLu(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatLu", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatM(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatM(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatM", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatMc(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatMc(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatMc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatMe(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatMe(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatMe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatMn(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatMn(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatMn", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatN(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatN(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatN", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatNd(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatNd(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatNd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatNl(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatNl(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatNl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatNo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatNo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatNo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatP(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatP(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatP", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPc(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPc(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPd(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPd(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPe(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPe(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPf(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPf(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPf", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPi(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPi(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPi", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatPs(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatPs(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatPs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatS(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatS(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatSc(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatSc(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatSc", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatSk(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatSk(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatSk", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatSm(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatSm(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatSm", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatSo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatSo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatSo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatZ(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatZ(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatZ", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatZl(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatZl(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatZl", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatZp(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatZp(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatZp", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCatZs(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCatZs(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCatZs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCherokee(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCherokee(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCherokee", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCombiningDiacriticalMarks(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCombiningDiacriticalMarks(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCombiningDiacriticalMarks", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCombiningDiacriticalMarksforSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCombiningDiacriticalMarksforSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCombiningDiacriticalMarksforSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCombiningHalfMarks(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCombiningHalfMarks(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCombiningHalfMarks", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCombiningMarksforSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCombiningMarksforSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCombiningMarksforSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsControlPictures(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsControlPictures(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsControlPictures", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCurrencySymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCurrencySymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCurrencySymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCypriotSyllabary(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCypriotSyllabary(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCypriotSyllabary", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCyrillic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCyrillic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCyrillic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsCyrillicSupplement(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsCyrillicSupplement(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsCyrillicSupplement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsDeseret(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsDeseret(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsDeseret", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsDevanagari(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsDevanagari(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsDevanagari", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsDingbats(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsDingbats(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsDingbats", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsEnclosedAlphanumerics(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsEnclosedAlphanumerics(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsEnclosedAlphanumerics", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsEnclosedCJKLettersandMonths(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsEnclosedCJKLettersandMonths(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsEnclosedCJKLettersandMonths", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsEthiopic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsEthiopic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsEthiopic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGeneralPunctuation(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGeneralPunctuation(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGeneralPunctuation", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGeometricShapes(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGeometricShapes(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGeometricShapes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGeorgian(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGeorgian(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGeorgian", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGothic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGothic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGothic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGreek(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGreek(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGreek", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGreekExtended(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGreekExtended(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGreekExtended", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGreekandCoptic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGreekandCoptic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGreekandCoptic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGujarati(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGujarati(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGujarati", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsGurmukhi(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsGurmukhi(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsGurmukhi", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHalfwidthandFullwidthForms(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHalfwidthandFullwidthForms(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHalfwidthandFullwidthForms", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHangulCompatibilityJamo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHangulCompatibilityJamo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHangulCompatibilityJamo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHangulJamo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHangulJamo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHangulJamo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHangulSyllables(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHangulSyllables(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHangulSyllables", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHanunoo(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHanunoo(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHanunoo", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHebrew(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHebrew(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHebrew", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHighPrivateUseSurrogates(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHighPrivateUseSurrogates(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHighPrivateUseSurrogates", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHighSurrogates(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHighSurrogates(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHighSurrogates", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsHiragana(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsHiragana(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsHiragana", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsIPAExtensions(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsIPAExtensions(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsIPAExtensions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsIdeographicDescriptionCharacters(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsIdeographicDescriptionCharacters(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsIdeographicDescriptionCharacters", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKanbun(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKanbun(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKanbun", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKangxiRadicals(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKangxiRadicals(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKangxiRadicals", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKannada(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKannada(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKannada", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKatakana(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKatakana(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKatakana", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKatakanaPhoneticExtensions(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKatakanaPhoneticExtensions(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKatakanaPhoneticExtensions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKhmer(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKhmer(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKhmer", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsKhmerSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsKhmerSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsKhmerSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLao(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLao(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLao", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLatin1Supplement(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLatin1Supplement(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLatin1Supplement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLatinExtendedA(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLatinExtendedA(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLatinExtendedA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLatinExtendedAdditional(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLatinExtendedAdditional(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLatinExtendedAdditional", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLatinExtendedB(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLatinExtendedB(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLatinExtendedB", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLetterlikeSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLetterlikeSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLetterlikeSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLimbu(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLimbu(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLimbu", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLinearBIdeograms(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLinearBIdeograms(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLinearBIdeograms", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLinearBSyllabary(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLinearBSyllabary(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLinearBSyllabary", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsLowSurrogates(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsLowSurrogates(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsLowSurrogates", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMalayalam(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMalayalam(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMalayalam", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMathematicalAlphanumericSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMathematicalAlphanumericSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMathematicalAlphanumericSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMathematicalOperators(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMathematicalOperators(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMathematicalOperators", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMiscellaneousMathematicalSymbolsA(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMiscellaneousMathematicalSymbolsA(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMiscellaneousMathematicalSymbolsA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMiscellaneousMathematicalSymbolsB(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMiscellaneousMathematicalSymbolsB(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMiscellaneousMathematicalSymbolsB", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMiscellaneousSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMiscellaneousSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMiscellaneousSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMiscellaneousSymbolsandArrows(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMiscellaneousSymbolsandArrows(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMiscellaneousSymbolsandArrows", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMiscellaneousTechnical(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMiscellaneousTechnical(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMiscellaneousTechnical", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMongolian(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMongolian(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMongolian", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMusicalSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMusicalSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMusicalSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsMyanmar(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsMyanmar(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsMyanmar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsNumberForms(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsNumberForms(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsNumberForms", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsOgham(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsOgham(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsOgham", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsOldItalic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsOldItalic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsOldItalic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsOpticalCharacterRecognition(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsOpticalCharacterRecognition(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsOpticalCharacterRecognition", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsOriya(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsOriya(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsOriya", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsOsmanya(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsOsmanya(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsOsmanya", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsPhoneticExtensions(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsPhoneticExtensions(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsPhoneticExtensions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsPrivateUse(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsPrivateUse(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsPrivateUse", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsPrivateUseArea(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsPrivateUseArea(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsPrivateUseArea", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsRunic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsRunic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsRunic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsShavian(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsShavian(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsShavian", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSinhala(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSinhala(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSinhala", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSmallFormVariants(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSmallFormVariants(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSmallFormVariants", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSpacingModifierLetters(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSpacingModifierLetters(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSpacingModifierLetters", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSpecials(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSpecials(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSpecials", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSuperscriptsandSubscripts(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSuperscriptsandSubscripts(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSuperscriptsandSubscripts", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSupplementalArrowsA(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSupplementalArrowsA(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSupplementalArrowsA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSupplementalArrowsB(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSupplementalArrowsB(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSupplementalArrowsB", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSupplementalMathematicalOperators(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSupplementalMathematicalOperators(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSupplementalMathematicalOperators", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSupplementaryPrivateUseAreaA(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSupplementaryPrivateUseAreaA(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSupplementaryPrivateUseAreaA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSupplementaryPrivateUseAreaB(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSupplementaryPrivateUseAreaB(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSupplementaryPrivateUseAreaB", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsSyriac(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsSyriac(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsSyriac", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTagalog(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTagalog(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTagalog", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTagbanwa(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTagbanwa(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTagbanwa", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTags(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTags(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTags", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTaiLe(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTaiLe(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTaiLe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTaiXuanJingSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTaiXuanJingSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTaiXuanJingSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTamil(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTamil(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTamil", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTelugu(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTelugu(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTelugu", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsThaana(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsThaana(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsThaana", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsThai(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsThai(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsThai", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsTibetan(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsTibetan(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsTibetan", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsUgaritic(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsUgaritic(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsUgaritic", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsUnifiedCanadianAboriginalSyllabics(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsUnifiedCanadianAboriginalSyllabics(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsUnifiedCanadianAboriginalSyllabics", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsVariationSelectors(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsVariationSelectors(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsVariationSelectors", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsVariationSelectorsSupplement(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsVariationSelectorsSupplement(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsVariationSelectorsSupplement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsYiRadicals(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsYiRadicals(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsYiRadicals", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsYiSyllables(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsYiSyllables(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsYiSyllables", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlUCSIsYijingHexagramSymbols(void) { + int test_ret = 0; + +#if defined(LIBXML_UNICODE_ENABLED) + int mem_base; + int ret_val; + int code; /* UCS code point */ + int n_code; + + for (n_code = 0;n_code < gen_nb_int;n_code++) { + mem_base = xmlMemBlocks(); + code = gen_int(n_code, 0); + + ret_val = xmlUCSIsYijingHexagramSymbols(code); + desret_int(ret_val); + call_tests++; + des_int(n_code, code, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlUCSIsYijingHexagramSymbols", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_code); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xmlunicode(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlunicode : 166 of 166 functions ...\n"); + test_ret += test_xmlUCSIsAegeanNumbers(); + test_ret += test_xmlUCSIsAlphabeticPresentationForms(); + test_ret += test_xmlUCSIsArabic(); + test_ret += test_xmlUCSIsArabicPresentationFormsA(); + test_ret += test_xmlUCSIsArabicPresentationFormsB(); + test_ret += test_xmlUCSIsArmenian(); + test_ret += test_xmlUCSIsArrows(); + test_ret += test_xmlUCSIsBasicLatin(); + test_ret += test_xmlUCSIsBengali(); + test_ret += test_xmlUCSIsBlock(); + test_ret += test_xmlUCSIsBlockElements(); + test_ret += test_xmlUCSIsBopomofo(); + test_ret += test_xmlUCSIsBopomofoExtended(); + test_ret += test_xmlUCSIsBoxDrawing(); + test_ret += test_xmlUCSIsBraillePatterns(); + test_ret += test_xmlUCSIsBuhid(); + test_ret += test_xmlUCSIsByzantineMusicalSymbols(); + test_ret += test_xmlUCSIsCJKCompatibility(); + test_ret += test_xmlUCSIsCJKCompatibilityForms(); + test_ret += test_xmlUCSIsCJKCompatibilityIdeographs(); + test_ret += test_xmlUCSIsCJKCompatibilityIdeographsSupplement(); + test_ret += test_xmlUCSIsCJKRadicalsSupplement(); + test_ret += test_xmlUCSIsCJKSymbolsandPunctuation(); + test_ret += test_xmlUCSIsCJKUnifiedIdeographs(); + test_ret += test_xmlUCSIsCJKUnifiedIdeographsExtensionA(); + test_ret += test_xmlUCSIsCJKUnifiedIdeographsExtensionB(); + test_ret += test_xmlUCSIsCat(); + test_ret += test_xmlUCSIsCatC(); + test_ret += test_xmlUCSIsCatCc(); + test_ret += test_xmlUCSIsCatCf(); + test_ret += test_xmlUCSIsCatCo(); + test_ret += test_xmlUCSIsCatCs(); + test_ret += test_xmlUCSIsCatL(); + test_ret += test_xmlUCSIsCatLl(); + test_ret += test_xmlUCSIsCatLm(); + test_ret += test_xmlUCSIsCatLo(); + test_ret += test_xmlUCSIsCatLt(); + test_ret += test_xmlUCSIsCatLu(); + test_ret += test_xmlUCSIsCatM(); + test_ret += test_xmlUCSIsCatMc(); + test_ret += test_xmlUCSIsCatMe(); + test_ret += test_xmlUCSIsCatMn(); + test_ret += test_xmlUCSIsCatN(); + test_ret += test_xmlUCSIsCatNd(); + test_ret += test_xmlUCSIsCatNl(); + test_ret += test_xmlUCSIsCatNo(); + test_ret += test_xmlUCSIsCatP(); + test_ret += test_xmlUCSIsCatPc(); + test_ret += test_xmlUCSIsCatPd(); + test_ret += test_xmlUCSIsCatPe(); + test_ret += test_xmlUCSIsCatPf(); + test_ret += test_xmlUCSIsCatPi(); + test_ret += test_xmlUCSIsCatPo(); + test_ret += test_xmlUCSIsCatPs(); + test_ret += test_xmlUCSIsCatS(); + test_ret += test_xmlUCSIsCatSc(); + test_ret += test_xmlUCSIsCatSk(); + test_ret += test_xmlUCSIsCatSm(); + test_ret += test_xmlUCSIsCatSo(); + test_ret += test_xmlUCSIsCatZ(); + test_ret += test_xmlUCSIsCatZl(); + test_ret += test_xmlUCSIsCatZp(); + test_ret += test_xmlUCSIsCatZs(); + test_ret += test_xmlUCSIsCherokee(); + test_ret += test_xmlUCSIsCombiningDiacriticalMarks(); + test_ret += test_xmlUCSIsCombiningDiacriticalMarksforSymbols(); + test_ret += test_xmlUCSIsCombiningHalfMarks(); + test_ret += test_xmlUCSIsCombiningMarksforSymbols(); + test_ret += test_xmlUCSIsControlPictures(); + test_ret += test_xmlUCSIsCurrencySymbols(); + test_ret += test_xmlUCSIsCypriotSyllabary(); + test_ret += test_xmlUCSIsCyrillic(); + test_ret += test_xmlUCSIsCyrillicSupplement(); + test_ret += test_xmlUCSIsDeseret(); + test_ret += test_xmlUCSIsDevanagari(); + test_ret += test_xmlUCSIsDingbats(); + test_ret += test_xmlUCSIsEnclosedAlphanumerics(); + test_ret += test_xmlUCSIsEnclosedCJKLettersandMonths(); + test_ret += test_xmlUCSIsEthiopic(); + test_ret += test_xmlUCSIsGeneralPunctuation(); + test_ret += test_xmlUCSIsGeometricShapes(); + test_ret += test_xmlUCSIsGeorgian(); + test_ret += test_xmlUCSIsGothic(); + test_ret += test_xmlUCSIsGreek(); + test_ret += test_xmlUCSIsGreekExtended(); + test_ret += test_xmlUCSIsGreekandCoptic(); + test_ret += test_xmlUCSIsGujarati(); + test_ret += test_xmlUCSIsGurmukhi(); + test_ret += test_xmlUCSIsHalfwidthandFullwidthForms(); + test_ret += test_xmlUCSIsHangulCompatibilityJamo(); + test_ret += test_xmlUCSIsHangulJamo(); + test_ret += test_xmlUCSIsHangulSyllables(); + test_ret += test_xmlUCSIsHanunoo(); + test_ret += test_xmlUCSIsHebrew(); + test_ret += test_xmlUCSIsHighPrivateUseSurrogates(); + test_ret += test_xmlUCSIsHighSurrogates(); + test_ret += test_xmlUCSIsHiragana(); + test_ret += test_xmlUCSIsIPAExtensions(); + test_ret += test_xmlUCSIsIdeographicDescriptionCharacters(); + test_ret += test_xmlUCSIsKanbun(); + test_ret += test_xmlUCSIsKangxiRadicals(); + test_ret += test_xmlUCSIsKannada(); + test_ret += test_xmlUCSIsKatakana(); + test_ret += test_xmlUCSIsKatakanaPhoneticExtensions(); + test_ret += test_xmlUCSIsKhmer(); + test_ret += test_xmlUCSIsKhmerSymbols(); + test_ret += test_xmlUCSIsLao(); + test_ret += test_xmlUCSIsLatin1Supplement(); + test_ret += test_xmlUCSIsLatinExtendedA(); + test_ret += test_xmlUCSIsLatinExtendedAdditional(); + test_ret += test_xmlUCSIsLatinExtendedB(); + test_ret += test_xmlUCSIsLetterlikeSymbols(); + test_ret += test_xmlUCSIsLimbu(); + test_ret += test_xmlUCSIsLinearBIdeograms(); + test_ret += test_xmlUCSIsLinearBSyllabary(); + test_ret += test_xmlUCSIsLowSurrogates(); + test_ret += test_xmlUCSIsMalayalam(); + test_ret += test_xmlUCSIsMathematicalAlphanumericSymbols(); + test_ret += test_xmlUCSIsMathematicalOperators(); + test_ret += test_xmlUCSIsMiscellaneousMathematicalSymbolsA(); + test_ret += test_xmlUCSIsMiscellaneousMathematicalSymbolsB(); + test_ret += test_xmlUCSIsMiscellaneousSymbols(); + test_ret += test_xmlUCSIsMiscellaneousSymbolsandArrows(); + test_ret += test_xmlUCSIsMiscellaneousTechnical(); + test_ret += test_xmlUCSIsMongolian(); + test_ret += test_xmlUCSIsMusicalSymbols(); + test_ret += test_xmlUCSIsMyanmar(); + test_ret += test_xmlUCSIsNumberForms(); + test_ret += test_xmlUCSIsOgham(); + test_ret += test_xmlUCSIsOldItalic(); + test_ret += test_xmlUCSIsOpticalCharacterRecognition(); + test_ret += test_xmlUCSIsOriya(); + test_ret += test_xmlUCSIsOsmanya(); + test_ret += test_xmlUCSIsPhoneticExtensions(); + test_ret += test_xmlUCSIsPrivateUse(); + test_ret += test_xmlUCSIsPrivateUseArea(); + test_ret += test_xmlUCSIsRunic(); + test_ret += test_xmlUCSIsShavian(); + test_ret += test_xmlUCSIsSinhala(); + test_ret += test_xmlUCSIsSmallFormVariants(); + test_ret += test_xmlUCSIsSpacingModifierLetters(); + test_ret += test_xmlUCSIsSpecials(); + test_ret += test_xmlUCSIsSuperscriptsandSubscripts(); + test_ret += test_xmlUCSIsSupplementalArrowsA(); + test_ret += test_xmlUCSIsSupplementalArrowsB(); + test_ret += test_xmlUCSIsSupplementalMathematicalOperators(); + test_ret += test_xmlUCSIsSupplementaryPrivateUseAreaA(); + test_ret += test_xmlUCSIsSupplementaryPrivateUseAreaB(); + test_ret += test_xmlUCSIsSyriac(); + test_ret += test_xmlUCSIsTagalog(); + test_ret += test_xmlUCSIsTagbanwa(); + test_ret += test_xmlUCSIsTags(); + test_ret += test_xmlUCSIsTaiLe(); + test_ret += test_xmlUCSIsTaiXuanJingSymbols(); + test_ret += test_xmlUCSIsTamil(); + test_ret += test_xmlUCSIsTelugu(); + test_ret += test_xmlUCSIsThaana(); + test_ret += test_xmlUCSIsThai(); + test_ret += test_xmlUCSIsTibetan(); + test_ret += test_xmlUCSIsUgaritic(); + test_ret += test_xmlUCSIsUnifiedCanadianAboriginalSyllabics(); + test_ret += test_xmlUCSIsVariationSelectors(); + test_ret += test_xmlUCSIsVariationSelectorsSupplement(); + test_ret += test_xmlUCSIsYiRadicals(); + test_ret += test_xmlUCSIsYiSyllables(); + test_ret += test_xmlUCSIsYijingHexagramSymbols(); + + if (test_ret != 0) + printf("Module xmlunicode: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlNewTextWriter(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlTextWriterPtr ret_val; + xmlOutputBufferPtr out; /* an xmlOutputBufferPtr */ + int n_out; + + for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { + mem_base = xmlMemBlocks(); + out = gen_xmlOutputBufferPtr(n_out, 0); + + ret_val = xmlNewTextWriter(out); + if (ret_val != NULL) out = NULL; + desret_xmlTextWriterPtr(ret_val); + call_tests++; + des_xmlOutputBufferPtr(n_out, out, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextWriter", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_out); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewTextWriterFilename(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlTextWriterPtr ret_val; + const char * uri; /* the URI of the resource for the output */ + int n_uri; + int compression; /* compress the output? */ + int n_compression; + + for (n_uri = 0;n_uri < gen_nb_fileoutput;n_uri++) { + for (n_compression = 0;n_compression < gen_nb_int;n_compression++) { + mem_base = xmlMemBlocks(); + uri = gen_fileoutput(n_uri, 0); + compression = gen_int(n_compression, 1); + + ret_val = xmlNewTextWriterFilename(uri, compression); + desret_xmlTextWriterPtr(ret_val); + call_tests++; + des_fileoutput(n_uri, uri, 0); + des_int(n_compression, compression, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextWriterFilename", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_uri); + printf(" %d", n_compression); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewTextWriterMemory(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlTextWriterPtr ret_val; + xmlBufferPtr buf; /* xmlBufferPtr */ + int n_buf; + int compression; /* compress the output? */ + int n_compression; + + for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { + for (n_compression = 0;n_compression < gen_nb_int;n_compression++) { + mem_base = xmlMemBlocks(); + buf = gen_xmlBufferPtr(n_buf, 0); + compression = gen_int(n_compression, 1); + + ret_val = xmlNewTextWriterMemory(buf, compression); + desret_xmlTextWriterPtr(ret_val); + call_tests++; + des_xmlBufferPtr(n_buf, buf, 0); + des_int(n_compression, compression, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextWriterMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_buf); + printf(" %d", n_compression); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewTextWriterPushParser(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlTextWriterPtr ret_val; + xmlParserCtxtPtr ctxt; /* xmlParserCtxtPtr to hold the new XML document tree */ + int n_ctxt; + int compression; /* compress the output? */ + int n_compression; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_compression = 0;n_compression < gen_nb_int;n_compression++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + compression = gen_int(n_compression, 1); + + ret_val = xmlNewTextWriterPushParser(ctxt, compression); + if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} if (ret_val != NULL) ctxt = NULL; + desret_xmlTextWriterPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_int(n_compression, compression, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextWriterPushParser", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_compression); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlNewTextWriterTree(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + xmlTextWriterPtr ret_val; + xmlDocPtr doc; /* xmlDocPtr */ + int n_doc; + xmlNodePtr node; /* xmlNodePtr or NULL for doc->children */ + int n_node; + int compression; /* compress the output? */ + int n_compression; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_compression = 0;n_compression < gen_nb_int;n_compression++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + node = gen_xmlNodePtr(n_node, 1); + compression = gen_int(n_compression, 2); + + ret_val = xmlNewTextWriterTree(doc, node, compression); + desret_xmlTextWriterPtr(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_xmlNodePtr(n_node, node, 1); + des_int(n_compression, compression, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNewTextWriterTree", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_node); + printf(" %d", n_compression); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndAttribute(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndCDATA(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndCDATA(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndCDATA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndComment(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndComment(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndComment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndDTD(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndDTD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndDTDAttlist(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndDTDAttlist(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndDTDAttlist", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndDTDElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndDTDElement(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndDTDElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndDTDEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndDTDEntity(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndDTDEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndDocument(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndElement(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterEndPI(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterEndPI(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterEndPI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterFlush(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterFlush(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterFlush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterFullEndElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterFullEndElement(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterFullEndElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterSetIndent(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + int indent; /* do indentation? */ + int n_indent; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_indent = 0;n_indent < gen_nb_int;n_indent++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + indent = gen_int(n_indent, 1); + + ret_val = xmlTextWriterSetIndent(writer, indent); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_int(n_indent, indent, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterSetIndent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_indent); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterSetIndentString(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * str; /* the xmlChar string */ + int n_str; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + + ret_val = xmlTextWriterSetIndentString(writer, (const xmlChar *)str); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterSetIndentString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_str); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterSetQuoteChar(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar quotechar; /* the quote character */ + int n_quotechar; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_quotechar = 0;n_quotechar < gen_nb_xmlChar;n_quotechar++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + quotechar = gen_xmlChar(n_quotechar, 1); + + ret_val = xmlTextWriterSetQuoteChar(writer, quotechar); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_xmlChar(n_quotechar, quotechar, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterSetQuoteChar", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_quotechar); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* element name */ + int n_name; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlTextWriterStartAttribute(writer, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartAttributeNS(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * prefix; /* namespace prefix or NULL */ + int n_prefix; + xmlChar * name; /* element local name */ + int n_name; + xmlChar * namespaceURI; /* namespace URI or NULL */ + int n_namespaceURI; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_namespaceURI = 0;n_namespaceURI < gen_nb_const_xmlChar_ptr;n_namespaceURI++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); + + ret_val = xmlTextWriterStartAttributeNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartAttributeNS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf(" %d", n_namespaceURI); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartCDATA(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterStartCDATA(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartCDATA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartComment(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterStartComment(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartComment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the DTD */ + int n_name; + xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + int n_pubid; + xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + int n_sysid; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_pubid = 0;n_pubid < gen_nb_const_xmlChar_ptr;n_pubid++) { + for (n_sysid = 0;n_sysid < gen_nb_const_xmlChar_ptr;n_sysid++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + pubid = gen_const_xmlChar_ptr(n_pubid, 2); + sysid = gen_const_xmlChar_ptr(n_sysid, 3); + + ret_val = xmlTextWriterStartDTD(writer, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 2); + des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartDTD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_pubid); + printf(" %d", n_sysid); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartDTDAttlist(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the DTD ATTLIST */ + int n_name; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlTextWriterStartDTDAttlist(writer, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartDTDAttlist", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartDTDElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the DTD element */ + int n_name; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlTextWriterStartDTDElement(writer, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartDTDElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartDTDEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + int pe; /* TRUE if this is a parameter entity, FALSE if not */ + int n_pe; + xmlChar * name; /* the name of the DTD ATTLIST */ + int n_name; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_pe = 0;n_pe < gen_nb_int;n_pe++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + pe = gen_int(n_pe, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + + ret_val = xmlTextWriterStartDTDEntity(writer, pe, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_int(n_pe, pe, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartDTDEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_pe); + printf(" %d", n_name); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + char * version; /* the xml version ("1.0") or NULL for default ("1.0") */ + int n_version; + char * encoding; /* the encoding or NULL for default */ + int n_encoding; + char * standalone; /* "yes" or "no" or NULL for default */ + int n_standalone; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_version = 0;n_version < gen_nb_const_char_ptr;n_version++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + for (n_standalone = 0;n_standalone < gen_nb_const_char_ptr;n_standalone++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + version = gen_const_char_ptr(n_version, 1); + encoding = gen_const_char_ptr(n_encoding, 2); + standalone = gen_const_char_ptr(n_standalone, 3); + + ret_val = xmlTextWriterStartDocument(writer, (const char *)version, (const char *)encoding, (const char *)standalone); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_char_ptr(n_version, (const char *)version, 1); + des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_standalone, (const char *)standalone, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_version); + printf(" %d", n_encoding); + printf(" %d", n_standalone); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* element name */ + int n_name; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlTextWriterStartElement(writer, (const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartElementNS(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * prefix; /* namespace prefix or NULL */ + int n_prefix; + xmlChar * name; /* element local name */ + int n_name; + xmlChar * namespaceURI; /* namespace URI or NULL */ + int n_namespaceURI; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_namespaceURI = 0;n_namespaceURI < gen_nb_const_xmlChar_ptr;n_namespaceURI++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); + + ret_val = xmlTextWriterStartElementNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartElementNS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf(" %d", n_namespaceURI); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterStartPI(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * target; /* PI target */ + int n_target; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_target = 0;n_target < gen_nb_const_xmlChar_ptr;n_target++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + target = gen_const_xmlChar_ptr(n_target, 1); + + ret_val = xmlTextWriterStartPI(writer, (const xmlChar *)target); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_target, (const xmlChar *)target, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterStartPI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_target); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* attribute name */ + int n_name; + xmlChar * content; /* attribute content */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + content = gen_const_xmlChar_ptr(n_content, 2); + + ret_val = xmlTextWriterWriteAttribute(writer, (const xmlChar *)name, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteAttributeNS(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * prefix; /* namespace prefix */ + int n_prefix; + xmlChar * name; /* attribute local name */ + int n_name; + xmlChar * namespaceURI; /* namespace URI */ + int n_namespaceURI; + xmlChar * content; /* attribute content */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_namespaceURI = 0;n_namespaceURI < gen_nb_const_xmlChar_ptr;n_namespaceURI++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); + content = gen_const_xmlChar_ptr(n_content, 4); + + ret_val = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteAttributeNS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf(" %d", n_namespaceURI); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteBase64(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + char * data; /* binary data */ + int n_data; + int start; /* the position within the data of the first byte to encode */ + int n_start; + int len; /* the number of bytes to encode */ + int n_len; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_data = 0;n_data < gen_nb_const_char_ptr;n_data++) { + for (n_start = 0;n_start < gen_nb_int;n_start++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + data = gen_const_char_ptr(n_data, 1); + start = gen_int(n_start, 2); + len = gen_int(n_len, 3); + if ((data != NULL) && + (start > (int) strlen((const char *) data) + 1)) + continue; + if ((data != NULL) && + (len > (int) strlen((const char *) data) + 1)) + continue; + + ret_val = xmlTextWriterWriteBase64(writer, (const char *)data, start, len); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_char_ptr(n_data, (const char *)data, 1); + des_int(n_start, start, 2); + des_int(n_len, len, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteBase64", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_data); + printf(" %d", n_start); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteBinHex(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + char * data; /* binary data */ + int n_data; + int start; /* the position within the data of the first byte to encode */ + int n_start; + int len; /* the number of bytes to encode */ + int n_len; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_data = 0;n_data < gen_nb_const_char_ptr;n_data++) { + for (n_start = 0;n_start < gen_nb_int;n_start++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + data = gen_const_char_ptr(n_data, 1); + start = gen_int(n_start, 2); + len = gen_int(n_len, 3); + if ((data != NULL) && + (start > (int) strlen((const char *) data) + 1)) + continue; + if ((data != NULL) && + (len > (int) strlen((const char *) data) + 1)) + continue; + + ret_val = xmlTextWriterWriteBinHex(writer, (const char *)data, start, len); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_char_ptr(n_data, (const char *)data, 1); + des_int(n_start, start, 2); + des_int(n_len, len, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteBinHex", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_data); + printf(" %d", n_start); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteCDATA(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * content; /* CDATA content */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlTextWriterWriteCDATA(writer, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteCDATA", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteComment(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * content; /* comment string */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlTextWriterWriteComment(writer, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteComment", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTD(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the DTD */ + int n_name; + xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + int n_pubid; + xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + int n_sysid; + xmlChar * subset; /* string content of the DTD */ + int n_subset; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_pubid = 0;n_pubid < gen_nb_const_xmlChar_ptr;n_pubid++) { + for (n_sysid = 0;n_sysid < gen_nb_const_xmlChar_ptr;n_sysid++) { + for (n_subset = 0;n_subset < gen_nb_const_xmlChar_ptr;n_subset++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + pubid = gen_const_xmlChar_ptr(n_pubid, 2); + sysid = gen_const_xmlChar_ptr(n_sysid, 3); + subset = gen_const_xmlChar_ptr(n_subset, 4); + + ret_val = xmlTextWriterWriteDTD(writer, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)subset); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 2); + des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 3); + des_const_xmlChar_ptr(n_subset, (const xmlChar *)subset, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTD", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_pubid); + printf(" %d", n_sysid); + printf(" %d", n_subset); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDAttlist(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the DTD ATTLIST */ + int n_name; + xmlChar * content; /* content of the ATTLIST */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + content = gen_const_xmlChar_ptr(n_content, 2); + + ret_val = xmlTextWriterWriteDTDAttlist(writer, (const xmlChar *)name, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDAttlist", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the DTD element */ + int n_name; + xmlChar * content; /* content of the element */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + content = gen_const_xmlChar_ptr(n_content, 2); + + ret_val = xmlTextWriterWriteDTDElement(writer, (const xmlChar *)name, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + int pe; /* TRUE if this is a parameter entity, FALSE if not */ + int n_pe; + xmlChar * name; /* the name of the DTD entity */ + int n_name; + xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + int n_pubid; + xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + int n_sysid; + xmlChar * ndataid; /* the xml notation name. */ + int n_ndataid; + xmlChar * content; /* content of the entity */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_pe = 0;n_pe < gen_nb_int;n_pe++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_pubid = 0;n_pubid < gen_nb_const_xmlChar_ptr;n_pubid++) { + for (n_sysid = 0;n_sysid < gen_nb_const_xmlChar_ptr;n_sysid++) { + for (n_ndataid = 0;n_ndataid < gen_nb_const_xmlChar_ptr;n_ndataid++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + pe = gen_int(n_pe, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + pubid = gen_const_xmlChar_ptr(n_pubid, 3); + sysid = gen_const_xmlChar_ptr(n_sysid, 4); + ndataid = gen_const_xmlChar_ptr(n_ndataid, 5); + content = gen_const_xmlChar_ptr(n_content, 6); + + ret_val = xmlTextWriterWriteDTDEntity(writer, pe, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)ndataid, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_int(n_pe, pe, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 3); + des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 4); + des_const_xmlChar_ptr(n_ndataid, (const xmlChar *)ndataid, 5); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 6); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_pe); + printf(" %d", n_name); + printf(" %d", n_pubid); + printf(" %d", n_sysid); + printf(" %d", n_ndataid); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDExternalEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + int pe; /* TRUE if this is a parameter entity, FALSE if not */ + int n_pe; + xmlChar * name; /* the name of the DTD entity */ + int n_name; + xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + int n_pubid; + xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + int n_sysid; + xmlChar * ndataid; /* the xml notation name. */ + int n_ndataid; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_pe = 0;n_pe < gen_nb_int;n_pe++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_pubid = 0;n_pubid < gen_nb_const_xmlChar_ptr;n_pubid++) { + for (n_sysid = 0;n_sysid < gen_nb_const_xmlChar_ptr;n_sysid++) { + for (n_ndataid = 0;n_ndataid < gen_nb_const_xmlChar_ptr;n_ndataid++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + pe = gen_int(n_pe, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + pubid = gen_const_xmlChar_ptr(n_pubid, 3); + sysid = gen_const_xmlChar_ptr(n_sysid, 4); + ndataid = gen_const_xmlChar_ptr(n_ndataid, 5); + + ret_val = xmlTextWriterWriteDTDExternalEntity(writer, pe, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)ndataid); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_int(n_pe, pe, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 3); + des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 4); + des_const_xmlChar_ptr(n_ndataid, (const xmlChar *)ndataid, 5); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDExternalEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_pe); + printf(" %d", n_name); + printf(" %d", n_pubid); + printf(" %d", n_sysid); + printf(" %d", n_ndataid); + printf("\n"); + } + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDExternalEntityContents(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + int n_pubid; + xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + int n_sysid; + xmlChar * ndataid; /* the xml notation name. */ + int n_ndataid; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_pubid = 0;n_pubid < gen_nb_const_xmlChar_ptr;n_pubid++) { + for (n_sysid = 0;n_sysid < gen_nb_const_xmlChar_ptr;n_sysid++) { + for (n_ndataid = 0;n_ndataid < gen_nb_const_xmlChar_ptr;n_ndataid++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + pubid = gen_const_xmlChar_ptr(n_pubid, 1); + sysid = gen_const_xmlChar_ptr(n_sysid, 2); + ndataid = gen_const_xmlChar_ptr(n_ndataid, 3); + + ret_val = xmlTextWriterWriteDTDExternalEntityContents(writer, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)ndataid); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 1); + des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 2); + des_const_xmlChar_ptr(n_ndataid, (const xmlChar *)ndataid, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDExternalEntityContents", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_pubid); + printf(" %d", n_sysid); + printf(" %d", n_ndataid); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDInternalEntity(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + int pe; /* TRUE if this is a parameter entity, FALSE if not */ + int n_pe; + xmlChar * name; /* the name of the DTD entity */ + int n_name; + xmlChar * content; /* content of the entity */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_pe = 0;n_pe < gen_nb_int;n_pe++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + pe = gen_int(n_pe, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + content = gen_const_xmlChar_ptr(n_content, 3); + + ret_val = xmlTextWriterWriteDTDInternalEntity(writer, pe, (const xmlChar *)name, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_int(n_pe, pe, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDInternalEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_pe); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteDTDNotation(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* the name of the xml notation */ + int n_name; + xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + int n_pubid; + xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + int n_sysid; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_pubid = 0;n_pubid < gen_nb_const_xmlChar_ptr;n_pubid++) { + for (n_sysid = 0;n_sysid < gen_nb_const_xmlChar_ptr;n_sysid++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + pubid = gen_const_xmlChar_ptr(n_pubid, 2); + sysid = gen_const_xmlChar_ptr(n_sysid, 3); + + ret_val = xmlTextWriterWriteDTDNotation(writer, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 2); + des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteDTDNotation", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_pubid); + printf(" %d", n_sysid); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteElement(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * name; /* element name */ + int n_name; + xmlChar * content; /* element content */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + content = gen_const_xmlChar_ptr(n_content, 2); + + ret_val = xmlTextWriterWriteElement(writer, (const xmlChar *)name, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteElement", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_name); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteElementNS(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * prefix; /* namespace prefix */ + int n_prefix; + xmlChar * name; /* element local name */ + int n_name; + xmlChar * namespaceURI; /* namespace URI */ + int n_namespaceURI; + xmlChar * content; /* element content */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_namespaceURI = 0;n_namespaceURI < gen_nb_const_xmlChar_ptr;n_namespaceURI++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); + content = gen_const_xmlChar_ptr(n_content, 4); + + ret_val = xmlTextWriterWriteElementNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteElementNS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_prefix); + printf(" %d", n_name); + printf(" %d", n_namespaceURI); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatAttribute(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatAttributeNS(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatCDATA(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatComment(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatDTD(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatDTDAttlist(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatDTDElement(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatDTDInternalEntity(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatElement(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatElementNS(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatPI(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatRaw(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteFormatString(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWritePI(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * target; /* PI target */ + int n_target; + xmlChar * content; /* PI content */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_target = 0;n_target < gen_nb_const_xmlChar_ptr;n_target++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + target = gen_const_xmlChar_ptr(n_target, 1); + content = gen_const_xmlChar_ptr(n_content, 2); + + ret_val = xmlTextWriterWritePI(writer, (const xmlChar *)target, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_target, (const xmlChar *)target, 1); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWritePI", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_target); + printf(" %d", n_content); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteRaw(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * content; /* text string */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlTextWriterWriteRaw(writer, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteRaw", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteRawLen(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * content; /* text string */ + int n_content; + int len; /* length of the text string */ + int n_len; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_len = 0;n_len < gen_nb_int;n_len++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + len = gen_int(n_len, 2); + if ((content != NULL) && + (len > (int) strlen((const char *) content) + 1)) + continue; + + ret_val = xmlTextWriterWriteRawLen(writer, (const xmlChar *)content, len); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_int(n_len, len, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteRawLen", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_content); + printf(" %d", n_len); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteString(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + xmlChar * content; /* text string */ + int n_content; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + content = gen_const_xmlChar_ptr(n_content, 1); + + ret_val = xmlTextWriterWriteString(writer, (const xmlChar *)content); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterWriteString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf(" %d", n_content); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatAttribute(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatAttributeNS(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatCDATA(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatComment(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatDTD(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatDTDAttlist(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatDTDElement(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatDTDInternalEntity(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatElement(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatElementNS(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatPI(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatRaw(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlTextWriterWriteVFormatString(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +static int +test_xmlwriter(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xmlwriter : 52 of 80 functions ...\n"); + test_ret += test_xmlNewTextWriter(); + test_ret += test_xmlNewTextWriterFilename(); + test_ret += test_xmlNewTextWriterMemory(); + test_ret += test_xmlNewTextWriterPushParser(); + test_ret += test_xmlNewTextWriterTree(); + test_ret += test_xmlTextWriterEndAttribute(); + test_ret += test_xmlTextWriterEndCDATA(); + test_ret += test_xmlTextWriterEndComment(); + test_ret += test_xmlTextWriterEndDTD(); + test_ret += test_xmlTextWriterEndDTDAttlist(); + test_ret += test_xmlTextWriterEndDTDElement(); + test_ret += test_xmlTextWriterEndDTDEntity(); + test_ret += test_xmlTextWriterEndDocument(); + test_ret += test_xmlTextWriterEndElement(); + test_ret += test_xmlTextWriterEndPI(); + test_ret += test_xmlTextWriterFlush(); + test_ret += test_xmlTextWriterFullEndElement(); + test_ret += test_xmlTextWriterSetIndent(); + test_ret += test_xmlTextWriterSetIndentString(); + test_ret += test_xmlTextWriterSetQuoteChar(); + test_ret += test_xmlTextWriterStartAttribute(); + test_ret += test_xmlTextWriterStartAttributeNS(); + test_ret += test_xmlTextWriterStartCDATA(); + test_ret += test_xmlTextWriterStartComment(); + test_ret += test_xmlTextWriterStartDTD(); + test_ret += test_xmlTextWriterStartDTDAttlist(); + test_ret += test_xmlTextWriterStartDTDElement(); + test_ret += test_xmlTextWriterStartDTDEntity(); + test_ret += test_xmlTextWriterStartDocument(); + test_ret += test_xmlTextWriterStartElement(); + test_ret += test_xmlTextWriterStartElementNS(); + test_ret += test_xmlTextWriterStartPI(); + test_ret += test_xmlTextWriterWriteAttribute(); + test_ret += test_xmlTextWriterWriteAttributeNS(); + test_ret += test_xmlTextWriterWriteBase64(); + test_ret += test_xmlTextWriterWriteBinHex(); + test_ret += test_xmlTextWriterWriteCDATA(); + test_ret += test_xmlTextWriterWriteComment(); + test_ret += test_xmlTextWriterWriteDTD(); + test_ret += test_xmlTextWriterWriteDTDAttlist(); + test_ret += test_xmlTextWriterWriteDTDElement(); + test_ret += test_xmlTextWriterWriteDTDEntity(); + test_ret += test_xmlTextWriterWriteDTDExternalEntity(); + test_ret += test_xmlTextWriterWriteDTDExternalEntityContents(); + test_ret += test_xmlTextWriterWriteDTDInternalEntity(); + test_ret += test_xmlTextWriterWriteDTDNotation(); + test_ret += test_xmlTextWriterWriteElement(); + test_ret += test_xmlTextWriterWriteElementNS(); + test_ret += test_xmlTextWriterWriteFormatAttribute(); + test_ret += test_xmlTextWriterWriteFormatAttributeNS(); + test_ret += test_xmlTextWriterWriteFormatCDATA(); + test_ret += test_xmlTextWriterWriteFormatComment(); + test_ret += test_xmlTextWriterWriteFormatDTD(); + test_ret += test_xmlTextWriterWriteFormatDTDAttlist(); + test_ret += test_xmlTextWriterWriteFormatDTDElement(); + test_ret += test_xmlTextWriterWriteFormatDTDInternalEntity(); + test_ret += test_xmlTextWriterWriteFormatElement(); + test_ret += test_xmlTextWriterWriteFormatElementNS(); + test_ret += test_xmlTextWriterWriteFormatPI(); + test_ret += test_xmlTextWriterWriteFormatRaw(); + test_ret += test_xmlTextWriterWriteFormatString(); + test_ret += test_xmlTextWriterWritePI(); + test_ret += test_xmlTextWriterWriteRaw(); + test_ret += test_xmlTextWriterWriteRawLen(); + test_ret += test_xmlTextWriterWriteString(); + test_ret += test_xmlTextWriterWriteVFormatAttribute(); + test_ret += test_xmlTextWriterWriteVFormatAttributeNS(); + test_ret += test_xmlTextWriterWriteVFormatCDATA(); + test_ret += test_xmlTextWriterWriteVFormatComment(); + test_ret += test_xmlTextWriterWriteVFormatDTD(); + test_ret += test_xmlTextWriterWriteVFormatDTDAttlist(); + test_ret += test_xmlTextWriterWriteVFormatDTDElement(); + test_ret += test_xmlTextWriterWriteVFormatDTDInternalEntity(); + test_ret += test_xmlTextWriterWriteVFormatElement(); + test_ret += test_xmlTextWriterWriteVFormatElementNS(); + test_ret += test_xmlTextWriterWriteVFormatPI(); + test_ret += test_xmlTextWriterWriteVFormatRaw(); + test_ret += test_xmlTextWriterWriteVFormatString(); + + if (test_ret != 0) + printf("Module xmlwriter: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlXPathCastBooleanToNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + int val; /* a boolean */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlXPathCastBooleanToNumber(val); + desret_double(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastBooleanToNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastBooleanToString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + int val; /* a boolean */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlXPathCastBooleanToString(val); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastBooleanToString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNodeSetToBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodeSetPtr ns; /* a node-set */ + int n_ns; + + for (n_ns = 0;n_ns < gen_nb_xmlNodeSetPtr;n_ns++) { + mem_base = xmlMemBlocks(); + ns = gen_xmlNodeSetPtr(n_ns, 0); + + ret_val = xmlXPathCastNodeSetToBoolean(ns); + desret_int(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_ns, ns, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNodeSetToBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ns); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNodeSetToNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + xmlNodeSetPtr ns; /* a node-set */ + int n_ns; + + for (n_ns = 0;n_ns < gen_nb_xmlNodeSetPtr;n_ns++) { + mem_base = xmlMemBlocks(); + ns = gen_xmlNodeSetPtr(n_ns, 0); + + ret_val = xmlXPathCastNodeSetToNumber(ns); + desret_double(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_ns, ns, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNodeSetToNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ns); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNodeSetToString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlNodeSetPtr ns; /* a node-set */ + int n_ns; + + for (n_ns = 0;n_ns < gen_nb_xmlNodeSetPtr;n_ns++) { + mem_base = xmlMemBlocks(); + ns = gen_xmlNodeSetPtr(n_ns, 0); + + ret_val = xmlXPathCastNodeSetToString(ns); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_ns, ns, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNodeSetToString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ns); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNodeToNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlXPathCastNodeToNumber(node); + desret_double(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNodeToNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNodeToString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + + ret_val = xmlXPathCastNodeToString(node); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNodeToString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNumberToBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + double val; /* a number */ + int n_val; + + for (n_val = 0;n_val < gen_nb_double;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_double(n_val, 0); + + ret_val = xmlXPathCastNumberToBoolean(val); + desret_int(ret_val); + call_tests++; + des_double(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNumberToBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastNumberToString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + double val; /* a number */ + int n_val; + + for (n_val = 0;n_val < gen_nb_double;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_double(n_val, 0); + + ret_val = xmlXPathCastNumberToString(val); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_double(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastNumberToString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastStringToBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlChar * val; /* a string */ + int n_val; + + for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_const_xmlChar_ptr(n_val, 0); + + ret_val = xmlXPathCastStringToBoolean((const xmlChar *)val); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastStringToBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastStringToNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + xmlChar * val; /* a string */ + int n_val; + + for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_const_xmlChar_ptr(n_val, 0); + + ret_val = xmlXPathCastStringToNumber((const xmlChar *)val); + desret_double(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastStringToNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastToBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathObjectPtr val; /* an XPath object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathCastToBoolean(val); + desret_int(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastToBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastToNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + xmlXPathObjectPtr val; /* an XPath object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathCastToNumber(val); + desret_double(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastToNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCastToString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlXPathObjectPtr val; /* an XPath object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathCastToString(val); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCastToString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCmpNodes(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr node1; /* the first node */ + int n_node1; + xmlNodePtr node2; /* the second node */ + int n_node2; + + for (n_node1 = 0;n_node1 < gen_nb_xmlNodePtr;n_node1++) { + for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) { + mem_base = xmlMemBlocks(); + node1 = gen_xmlNodePtr(n_node1, 0); + node2 = gen_xmlNodePtr(n_node2, 1); + + ret_val = xmlXPathCmpNodes(node1, node2); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_node1, node1, 0); + des_xmlNodePtr(n_node2, node2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCmpNodes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node1); + printf(" %d", n_node2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCompile(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + +#ifdef LIBXML_XPATH_ENABLED + +#define gen_nb_xmlXPathCompExprPtr 1 +static xmlXPathCompExprPtr gen_xmlXPathCompExprPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlXPathCompExprPtr(int no ATTRIBUTE_UNUSED, xmlXPathCompExprPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + +#ifdef LIBXML_XPATH_ENABLED + +#define gen_nb_xmlXPathContextPtr 1 +static xmlXPathContextPtr gen_xmlXPathContextPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlXPathContextPtr(int no ATTRIBUTE_UNUSED, xmlXPathContextPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlXPathCompiledEval(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathCompExprPtr comp; /* the compiled XPath expression */ + int n_comp; + xmlXPathContextPtr ctx; /* the XPath context */ + int n_ctx; + + for (n_comp = 0;n_comp < gen_nb_xmlXPathCompExprPtr;n_comp++) { + for (n_ctx = 0;n_ctx < gen_nb_xmlXPathContextPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlXPathCompExprPtr(n_comp, 0); + ctx = gen_xmlXPathContextPtr(n_ctx, 1); + + ret_val = xmlXPathCompiledEval(comp, ctx); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathCompExprPtr(n_comp, comp, 0); + des_xmlXPathContextPtr(n_ctx, ctx, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCompiledEval", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCompiledEvalToBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathCompExprPtr comp; /* the compiled XPath expression */ + int n_comp; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + + for (n_comp = 0;n_comp < gen_nb_xmlXPathCompExprPtr;n_comp++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + comp = gen_xmlXPathCompExprPtr(n_comp, 0); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 1); + + ret_val = xmlXPathCompiledEvalToBoolean(comp, ctxt); + desret_int(ret_val); + call_tests++; + des_xmlXPathCompExprPtr(n_comp, comp, 0); + des_xmlXPathContextPtr(n_ctxt, ctxt, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCompiledEvalToBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_comp); + printf(" %d", n_ctxt); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathContextSetCache(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + int active; /* enables/disables (creates/frees) the cache */ + int n_active; + int value; /* a value with semantics dependent on @options */ + int n_value; + int options; /* options (currently only the value 0 is used) */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_active = 0;n_active < gen_nb_int;n_active++) { + for (n_value = 0;n_value < gen_nb_int;n_value++) { + for (n_options = 0;n_options < gen_nb_int;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + active = gen_int(n_active, 1); + value = gen_int(n_value, 2); + options = gen_int(n_options, 3); + + ret_val = xmlXPathContextSetCache(ctxt, active, value, options); + desret_int(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_int(n_active, active, 1); + des_int(n_value, value, 2); + des_int(n_options, options, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathContextSetCache", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_active); + printf(" %d", n_value); + printf(" %d", n_options); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathConvertBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathObjectPtr val; /* an XPath object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathConvertBoolean(val); + val = NULL; + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathConvertBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathConvertNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathObjectPtr val; /* an XPath object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathConvertNumber(val); + val = NULL; + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathConvertNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathConvertString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathObjectPtr val; /* an XPath object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathConvertString(val); + val = NULL; + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathConvertString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCtxtCompile(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathEval(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlChar * str; /* the XPath expression */ + int n_str; + xmlXPathContextPtr ctx; /* the XPath context */ + int n_ctx; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_ctx = 0;n_ctx < gen_nb_xmlXPathContextPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + ctx = gen_xmlXPathContextPtr(n_ctx, 1); + + ret_val = xmlXPathEval((const xmlChar *)str, ctx); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_xmlXPathContextPtr(n_ctx, ctx, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathEval", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathEvalExpression(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlChar * str; /* the XPath expression */ + int n_str; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 1); + + ret_val = xmlXPathEvalExpression((const xmlChar *)str, ctxt); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_xmlXPathContextPtr(n_ctxt, ctxt, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathEvalExpression", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_ctxt); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathEvalPredicate(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlXPathObjectPtr res; /* the Predicate Expression evaluation result */ + int n_res; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_res = 0;n_res < gen_nb_xmlXPathObjectPtr;n_res++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + res = gen_xmlXPathObjectPtr(n_res, 1); + + ret_val = xmlXPathEvalPredicate(ctxt, res); + desret_int(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_xmlXPathObjectPtr(n_res, res, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathEvalPredicate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_res); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathInit(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlXPathInit(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathInit", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathIsInf(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + double val; /* a double value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_double;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_double(n_val, 0); + + ret_val = xmlXPathIsInf(val); + desret_int(ret_val); + call_tests++; + des_double(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathIsInf", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathIsNaN(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + int mem_base; + int ret_val; + double val; /* a double value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_double;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_double(n_val, 0); + + ret_val = xmlXPathIsNaN(val); + desret_int(ret_val); + call_tests++; + des_double(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathIsNaN", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewContext(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathNodeEval(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr node; /* the node to to use as the context node */ + int n_node; + xmlChar * str; /* the XPath expression */ + int n_str; + xmlXPathContextPtr ctx; /* the XPath context */ + int n_ctx; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_ctx = 0;n_ctx < gen_nb_xmlXPathContextPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + str = gen_const_xmlChar_ptr(n_str, 1); + ctx = gen_xmlXPathContextPtr(n_ctx, 2); + + ret_val = xmlXPathNodeEval(node, (const xmlChar *)str, ctx); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_xmlXPathContextPtr(n_ctx, ctx, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeEval", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_str); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetCreate(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodePtr val; /* an initial xmlNodePtr, or NULL */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlNodePtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlNodePtr(n_val, 0); + + ret_val = xmlXPathNodeSetCreate(val); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetCreate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathObjectCopy(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathObjectPtr val; /* the original object */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlXPathObjectPtr(n_val, 0); + + ret_val = xmlXPathObjectCopy(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathObjectCopy", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathOrderDocElems(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + long ret_val; + xmlDocPtr doc; /* an input document */ + int n_doc; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + + ret_val = xmlXPathOrderDocElems(doc); + desret_long(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathOrderDocElems", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathSetContextNode(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodePtr node; /* the node to to use as the context node */ + int n_node; + xmlXPathContextPtr ctx; /* the XPath context */ + int n_ctx; + + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ctx = 0;n_ctx < gen_nb_xmlXPathContextPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + node = gen_xmlNodePtr(n_node, 0); + ctx = gen_xmlXPathContextPtr(n_ctx, 1); + + ret_val = xmlXPathSetContextNode(node, ctx); + desret_int(ret_val); + call_tests++; + des_xmlNodePtr(n_node, node, 0); + des_xmlXPathContextPtr(n_ctx, ctx, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathSetContextNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xpath(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xpath : 32 of 40 functions ...\n"); + test_ret += test_xmlXPathCastBooleanToNumber(); + test_ret += test_xmlXPathCastBooleanToString(); + test_ret += test_xmlXPathCastNodeSetToBoolean(); + test_ret += test_xmlXPathCastNodeSetToNumber(); + test_ret += test_xmlXPathCastNodeSetToString(); + test_ret += test_xmlXPathCastNodeToNumber(); + test_ret += test_xmlXPathCastNodeToString(); + test_ret += test_xmlXPathCastNumberToBoolean(); + test_ret += test_xmlXPathCastNumberToString(); + test_ret += test_xmlXPathCastStringToBoolean(); + test_ret += test_xmlXPathCastStringToNumber(); + test_ret += test_xmlXPathCastToBoolean(); + test_ret += test_xmlXPathCastToNumber(); + test_ret += test_xmlXPathCastToString(); + test_ret += test_xmlXPathCmpNodes(); + test_ret += test_xmlXPathCompile(); + test_ret += test_xmlXPathCompiledEval(); + test_ret += test_xmlXPathCompiledEvalToBoolean(); + test_ret += test_xmlXPathContextSetCache(); + test_ret += test_xmlXPathConvertBoolean(); + test_ret += test_xmlXPathConvertNumber(); + test_ret += test_xmlXPathConvertString(); + test_ret += test_xmlXPathCtxtCompile(); + test_ret += test_xmlXPathEval(); + test_ret += test_xmlXPathEvalExpression(); + test_ret += test_xmlXPathEvalPredicate(); + test_ret += test_xmlXPathInit(); + test_ret += test_xmlXPathIsInf(); + test_ret += test_xmlXPathIsNaN(); + test_ret += test_xmlXPathNewContext(); + test_ret += test_xmlXPathNodeEval(); + test_ret += test_xmlXPathNodeSetCreate(); + test_ret += test_xmlXPathObjectCopy(); + test_ret += test_xmlXPathOrderDocElems(); + test_ret += test_xmlXPathSetContextNode(); + + if (test_ret != 0) + printf("Module xpath: %d errors\n", test_ret); + return(test_ret); +} +#ifdef LIBXML_XPATH_ENABLED + +#define gen_nb_xmlXPathParserContextPtr 1 +static xmlXPathParserContextPtr gen_xmlXPathParserContextPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlXPathParserContextPtr(int no ATTRIBUTE_UNUSED, xmlXPathParserContextPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_valuePop(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath evaluation context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = valuePop(ctxt); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in valuePop", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_valuePush(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath evaluation context */ + int n_ctxt; + xmlXPathObjectPtr value; /* the XPath object */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_value = 0;n_value < gen_nb_xmlXPathObjectPtr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + value = gen_xmlXPathObjectPtr(n_value, 1); + + ret_val = valuePush(ctxt, value); + desret_int(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlXPathObjectPtr(n_value, value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in valuePush", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathAddValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathAddValues(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathAddValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathBooleanFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathBooleanFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathBooleanFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCeilingFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathCeilingFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCeilingFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCompareValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int inf; /* less than (1) or greater than (0) */ + int n_inf; + int strict; /* is the comparison strict */ + int n_strict; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_inf = 0;n_inf < gen_nb_int;n_inf++) { + for (n_strict = 0;n_strict < gen_nb_int;n_strict++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + inf = gen_int(n_inf, 1); + strict = gen_int(n_strict, 2); + + ret_val = xmlXPathCompareValues(ctxt, inf, strict); + desret_int(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_inf, inf, 1); + des_int(n_strict, strict, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCompareValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_inf); + printf(" %d", n_strict); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathConcatFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathConcatFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathConcatFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathContainsFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathContainsFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathContainsFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathCountFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathCountFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathCountFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathDebugDumpCompExpr(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * for the output */ + int n_output; + xmlXPathCompExprPtr comp; /* the precompiled XPath expression */ + int n_comp; + int depth; /* the indentation level. */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_FILE_ptr;n_output++) { + for (n_comp = 0;n_comp < gen_nb_xmlXPathCompExprPtr;n_comp++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_FILE_ptr(n_output, 0); + comp = gen_xmlXPathCompExprPtr(n_comp, 1); + depth = gen_int(n_depth, 2); + + xmlXPathDebugDumpCompExpr(output, comp, depth); + call_tests++; + des_FILE_ptr(n_output, output, 0); + des_xmlXPathCompExprPtr(n_comp, comp, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathDebugDumpCompExpr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_comp); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathDebugDumpObject(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) + int mem_base; + FILE * output; /* the FILE * to dump the output */ + int n_output; + xmlXPathObjectPtr cur; /* the object to inspect */ + int n_cur; + int depth; /* indentation level */ + int n_depth; + + for (n_output = 0;n_output < gen_nb_FILE_ptr;n_output++) { + for (n_cur = 0;n_cur < gen_nb_xmlXPathObjectPtr;n_cur++) { + for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { + mem_base = xmlMemBlocks(); + output = gen_FILE_ptr(n_output, 0); + cur = gen_xmlXPathObjectPtr(n_cur, 1); + depth = gen_int(n_depth, 2); + + xmlXPathDebugDumpObject(output, cur, depth); + call_tests++; + des_FILE_ptr(n_output, output, 0); + des_xmlXPathObjectPtr(n_cur, cur, 1); + des_int(n_depth, depth, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathDebugDumpObject", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_output); + printf(" %d", n_cur); + printf(" %d", n_depth); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathDifference(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes1; /* a node-set */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathDifference(nodes1, nodes2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathDifference", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathDistinct(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes; /* a node-set */ + int n_nodes; + + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + mem_base = xmlMemBlocks(); + nodes = gen_xmlNodeSetPtr(n_nodes, 0); + + ret_val = xmlXPathDistinct(nodes); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes, nodes, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathDistinct", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathDistinctSorted(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes; /* a node-set, sorted by document order */ + int n_nodes; + + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + mem_base = xmlMemBlocks(); + nodes = gen_xmlNodeSetPtr(n_nodes, 0); + + ret_val = xmlXPathDistinctSorted(nodes); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes, nodes, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathDistinctSorted", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathDivValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathDivValues(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathDivValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathEqualValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathEqualValues(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathEqualValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathErr(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* a XPath parser context */ + int n_ctxt; + int error; /* the error code */ + int n_error; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_error = 0;n_error < gen_nb_int;n_error++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + error = gen_int(n_error, 1); + + xmlXPathErr(ctxt, error); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_error, error, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathErr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_error); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathEvalExpr(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathEvalExpr(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathEvalExpr", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathEvaluatePredicateResult(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlXPathObjectPtr res; /* the Predicate Expression evaluation result */ + int n_res; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_res = 0;n_res < gen_nb_xmlXPathObjectPtr;n_res++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + res = gen_xmlXPathObjectPtr(n_res, 1); + + ret_val = xmlXPathEvaluatePredicateResult(ctxt, res); + desret_int(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlXPathObjectPtr(n_res, res, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathEvaluatePredicateResult", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_res); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathFalseFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathFalseFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathFalseFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathFloorFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathFloorFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathFloorFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathFunctionLookup(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathFunctionLookupNS(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathHasSameNodes(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodeSetPtr nodes1; /* a node-set */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathHasSameNodes(nodes1, nodes2); + desret_int(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathHasSameNodes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathIdFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathIdFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathIdFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathIntersection(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes1; /* a node-set */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathIntersection(nodes1, nodes2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathIntersection", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathIsNodeType(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlChar * name; /* a name string */ + int n_name; + + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + name = gen_const_xmlChar_ptr(n_name, 0); + + ret_val = xmlXPathIsNodeType((const xmlChar *)name); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathIsNodeType", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_name); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathLangFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathLangFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathLangFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathLastFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathLastFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathLastFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathLeading(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes1; /* a node-set */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathLeading(nodes1, nodes2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathLeading", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathLeadingSorted(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes1; /* a node-set, sorted by document order */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set, sorted by document order */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathLeadingSorted(nodes1, nodes2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathLeadingSorted", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathLocalNameFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathLocalNameFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathLocalNameFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathModValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathModValues(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathModValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathMultValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathMultValues(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathMultValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNamespaceURIFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathNamespaceURIFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNamespaceURIFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + int val; /* the boolean value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_int(n_val, 0); + + ret_val = xmlXPathNewBoolean(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_int(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNewBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewCString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + char * val; /* the char * value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_const_char_ptr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_const_char_ptr(n_val, 0); + + ret_val = xmlXPathNewCString((const char *)val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_const_char_ptr(n_val, (const char *)val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNewCString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewFloat(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + double val; /* the double value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_double;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_double(n_val, 0); + + ret_val = xmlXPathNewFloat(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_double(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNewFloat", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewNodeSet(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr val; /* the NodePtr value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlNodePtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlNodePtr(n_val, 0); + + ret_val = xmlXPathNewNodeSet(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNewNodeSet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewNodeSetList(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodeSetPtr val; /* an existing NodeSet */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlNodeSetPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlNodeSetPtr(n_val, 0); + + ret_val = xmlXPathNewNodeSetList(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNewNodeSetList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNewParserContext(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathNewString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlChar * val; /* the xmlChar * value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_const_xmlChar_ptr(n_val, 0); + + ret_val = xmlXPathNewString((const xmlChar *)val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNewString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextAncestor(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextAncestor(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextAncestor", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextAncestorOrSelf(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextAncestorOrSelf(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextAncestorOrSelf", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextAttribute(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current attribute in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextAttribute(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextAttribute", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextChild(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextChild(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextChild", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextDescendant(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextDescendant(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextDescendant", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextDescendantOrSelf(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextDescendantOrSelf(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextDescendantOrSelf", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextFollowing(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextFollowing(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextFollowing", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextFollowingSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextFollowingSibling(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextFollowingSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextNamespace(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current attribute in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextNamespace(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextNamespace", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextParent(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextParent(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextParent", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextPreceding(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextPreceding(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextPreceding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextPrecedingSibling(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextPrecedingSibling(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextPrecedingSibling", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNextSelf(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + xmlNodePtr cur; /* the current node in the traversal */ + int n_cur; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + cur = gen_xmlNodePtr(n_cur, 1); + + ret_val = xmlXPathNextSelf(ctxt, cur); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_xmlNodePtr(n_cur, cur, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNextSelf", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_cur); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeLeading(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes; /* a node-set */ + int n_nodes; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + nodes = gen_xmlNodeSetPtr(n_nodes, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlXPathNodeLeading(nodes, node); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes, nodes, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeLeading", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeLeadingSorted(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes; /* a node-set, sorted by document order */ + int n_nodes; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + nodes = gen_xmlNodeSetPtr(n_nodes, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlXPathNodeLeadingSorted(nodes, node); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes, nodes, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeLeadingSorted", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetAdd(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodeSetPtr cur; /* the initial node set */ + int n_cur; + xmlNodePtr val; /* a new xmlNodePtr */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlNodeSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_xmlNodePtr;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodeSetPtr(n_cur, 0); + val = gen_xmlNodePtr(n_val, 1); + + ret_val = xmlXPathNodeSetAdd(cur, val); + desret_int(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_cur, cur, 0); + des_xmlNodePtr(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetAdd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetAddNs(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodeSetPtr cur; /* the initial node set */ + int n_cur; + xmlNodePtr node; /* the hosting node */ + int n_node; + xmlNsPtr ns; /* a the namespace node */ + int n_ns; + + for (n_cur = 0;n_cur < gen_nb_xmlNodeSetPtr;n_cur++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodeSetPtr(n_cur, 0); + node = gen_xmlNodePtr(n_node, 1); + ns = gen_xmlNsPtr(n_ns, 2); + + ret_val = xmlXPathNodeSetAddNs(cur, node, ns); + desret_int(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_cur, cur, 0); + des_xmlNodePtr(n_node, node, 1); + des_xmlNsPtr(n_ns, ns, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetAddNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_node); + printf(" %d", n_ns); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetAddUnique(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodeSetPtr cur; /* the initial node set */ + int n_cur; + xmlNodePtr val; /* a new xmlNodePtr */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlNodeSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_xmlNodePtr;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodeSetPtr(n_cur, 0); + val = gen_xmlNodePtr(n_val, 1); + + ret_val = xmlXPathNodeSetAddUnique(cur, val); + desret_int(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_cur, cur, 0); + des_xmlNodePtr(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetAddUnique", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetContains(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlNodeSetPtr cur; /* the node-set */ + int n_cur; + xmlNodePtr val; /* the node */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlNodeSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_xmlNodePtr;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodeSetPtr(n_cur, 0); + val = gen_xmlNodePtr(n_val, 1); + + ret_val = xmlXPathNodeSetContains(cur, val); + desret_int(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_cur, cur, 0); + des_xmlNodePtr(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetContains", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetDel(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr cur; /* the initial node set */ + int n_cur; + xmlNodePtr val; /* an xmlNodePtr */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlNodeSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_xmlNodePtr;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodeSetPtr(n_cur, 0); + val = gen_xmlNodePtr(n_val, 1); + + xmlXPathNodeSetDel(cur, val); + call_tests++; + des_xmlNodeSetPtr(n_cur, cur, 0); + des_xmlNodePtr(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetDel", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetMerge(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr val1; /* the first NodeSet or NULL */ + int n_val1; + xmlNodeSetPtr val2; /* the second NodeSet */ + int n_val2; + + for (n_val1 = 0;n_val1 < gen_nb_xmlNodeSetPtr;n_val1++) { + for (n_val2 = 0;n_val2 < gen_nb_xmlNodeSetPtr;n_val2++) { + mem_base = xmlMemBlocks(); + val1 = gen_xmlNodeSetPtr(n_val1, 0); + val2 = gen_xmlNodeSetPtr(n_val2, 1); + + ret_val = xmlXPathNodeSetMerge(val1, val2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_val1, val1, 0); + des_xmlNodeSetPtr(n_val2, val2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetMerge", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val1); + printf(" %d", n_val2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetRemove(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr cur; /* the initial node set */ + int n_cur; + int val; /* the index to remove */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlNodeSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlNodeSetPtr(n_cur, 0); + val = gen_int(n_val, 1); + + xmlXPathNodeSetRemove(cur, val); + call_tests++; + des_xmlNodeSetPtr(n_cur, cur, 0); + des_int(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetRemove", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeSetSort(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr set; /* the node set */ + int n_set; + + for (n_set = 0;n_set < gen_nb_xmlNodeSetPtr;n_set++) { + mem_base = xmlMemBlocks(); + set = gen_xmlNodeSetPtr(n_set, 0); + + xmlXPathNodeSetSort(set); + call_tests++; + des_xmlNodeSetPtr(n_set, set, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeSetSort", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_set); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeTrailing(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes; /* a node-set */ + int n_nodes; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + nodes = gen_xmlNodeSetPtr(n_nodes, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlXPathNodeTrailing(nodes, node); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes, nodes, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeTrailing", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNodeTrailingSorted(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes; /* a node-set, sorted by document order */ + int n_nodes; + xmlNodePtr node; /* a node */ + int n_node; + + for (n_nodes = 0;n_nodes < gen_nb_xmlNodeSetPtr;n_nodes++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + mem_base = xmlMemBlocks(); + nodes = gen_xmlNodeSetPtr(n_nodes, 0); + node = gen_xmlNodePtr(n_node, 1); + + ret_val = xmlXPathNodeTrailingSorted(nodes, node); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes, nodes, 0); + des_xmlNodePtr(n_node, node, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNodeTrailingSorted", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes); + printf(" %d", n_node); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNormalizeFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathNormalizeFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNormalizeFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNotEqualValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathNotEqualValues(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNotEqualValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNotFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathNotFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNotFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNsLookup(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + const xmlChar * ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlChar * prefix; /* the namespace prefix value */ + int n_prefix; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + + ret_val = xmlXPathNsLookup(ctxt, (const xmlChar *)prefix); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNsLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_prefix); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathNumberFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathNumberFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathNumberFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathParseNCName(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathParseNCName(ctxt); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathParseNCName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathParseName(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathParseName(ctxt); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathParseName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathPopBoolean(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathPopBoolean(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathPopBoolean", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathPopExternal(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + void * ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathPopExternal(ctxt); + desret_void_ptr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathPopExternal", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathPopNodeSet(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathPopNodeSet(ctxt); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathPopNodeSet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathPopNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathPopNumber(ctxt); + desret_double(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathPopNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathPopString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlChar * ret_val; + xmlXPathParserContextPtr ctxt; /* an XPath parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + ret_val = xmlXPathPopString(ctxt); + desret_xmlChar_ptr(ret_val); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathPopString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathPositionFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathPositionFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathPositionFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisterAllFunctions(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + + xmlXPathRegisterAllFunctions(ctxt); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisterAllFunctions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisterFunc(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathRegisterFuncLookup(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathRegisterFuncNS(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathRegisterNs(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlChar * prefix; /* the namespace prefix cannot be NULL or empty string */ + int n_prefix; + xmlChar * ns_uri; /* the namespace name */ + int n_ns_uri; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_prefix = 0;n_prefix < gen_nb_const_xmlChar_ptr;n_prefix++) { + for (n_ns_uri = 0;n_ns_uri < gen_nb_const_xmlChar_ptr;n_ns_uri++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + prefix = gen_const_xmlChar_ptr(n_prefix, 1); + ns_uri = gen_const_xmlChar_ptr(n_ns_uri, 2); + + ret_val = xmlXPathRegisterNs(ctxt, (const xmlChar *)prefix, (const xmlChar *)ns_uri); + desret_int(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_ns_uri, (const xmlChar *)ns_uri, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisterNs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_prefix); + printf(" %d", n_ns_uri); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisterVariable(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlChar * name; /* the variable name */ + int n_name; + xmlXPathObjectPtr value; /* the variable value or NULL */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_value = 0;n_value < gen_nb_xmlXPathObjectPtr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + value = gen_xmlXPathObjectPtr(n_value, 2); + + ret_val = xmlXPathRegisterVariable(ctxt, (const xmlChar *)name, value); + desret_int(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_xmlXPathObjectPtr(n_value, value, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisterVariable", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisterVariableLookup(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPathRegisterVariableNS(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + int ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlChar * name; /* the variable name */ + int n_name; + xmlChar * ns_uri; /* the variable namespace URI */ + int n_ns_uri; + xmlXPathObjectPtr value; /* the variable value or NULL */ + int n_value; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns_uri = 0;n_ns_uri < gen_nb_const_xmlChar_ptr;n_ns_uri++) { + for (n_value = 0;n_value < gen_nb_xmlXPathObjectPtr;n_value++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ns_uri = gen_const_xmlChar_ptr(n_ns_uri, 2); + value = gen_xmlXPathObjectPtr(n_value, 3); + + ret_val = xmlXPathRegisterVariableNS(ctxt, (const xmlChar *)name, (const xmlChar *)ns_uri, value); + desret_int(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ns_uri, (const xmlChar *)ns_uri, 2); + des_xmlXPathObjectPtr(n_value, value, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisterVariableNS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf(" %d", n_ns_uri); + printf(" %d", n_value); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisteredFuncsCleanup(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + + xmlXPathRegisteredFuncsCleanup(ctxt); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisteredFuncsCleanup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisteredNsCleanup(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + + xmlXPathRegisteredNsCleanup(ctxt); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisteredNsCleanup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRegisteredVariablesCleanup(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + + xmlXPathRegisteredVariablesCleanup(ctxt); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRegisteredVariablesCleanup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRoot(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathRoot(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRoot", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathRoundFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathRoundFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathRoundFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathStartsWithFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathStartsWithFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathStartsWithFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathStringEvalNumber(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + double ret_val; + xmlChar * str; /* A string to scan */ + int n_str; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + + ret_val = xmlXPathStringEvalNumber((const xmlChar *)str); + desret_double(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathStringEvalNumber", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathStringFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathStringFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathStringFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathStringLengthFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathStringLengthFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathStringLengthFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathSubValues(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathSubValues(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathSubValues", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathSubstringAfterFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathSubstringAfterFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathSubstringAfterFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathSubstringBeforeFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathSubstringBeforeFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathSubstringBeforeFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathSubstringFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathSubstringFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathSubstringFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathSumFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathSumFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathSumFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathTrailing(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes1; /* a node-set */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathTrailing(nodes1, nodes2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathTrailing", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathTrailingSorted(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlNodeSetPtr ret_val; + xmlNodeSetPtr nodes1; /* a node-set, sorted by document order */ + int n_nodes1; + xmlNodeSetPtr nodes2; /* a node-set, sorted by document order */ + int n_nodes2; + + for (n_nodes1 = 0;n_nodes1 < gen_nb_xmlNodeSetPtr;n_nodes1++) { + for (n_nodes2 = 0;n_nodes2 < gen_nb_xmlNodeSetPtr;n_nodes2++) { + mem_base = xmlMemBlocks(); + nodes1 = gen_xmlNodeSetPtr(n_nodes1, 0); + nodes2 = gen_xmlNodeSetPtr(n_nodes2, 1); + + ret_val = xmlXPathTrailingSorted(nodes1, nodes2); + desret_xmlNodeSetPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_nodes1, nodes1, 0); + des_xmlNodeSetPtr(n_nodes2, nodes2, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathTrailingSorted", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_nodes1); + printf(" %d", n_nodes2); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathTranslateFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathTranslateFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathTranslateFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathTrueFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + int nargs; /* the number of arguments */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPathTrueFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathTrueFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathValueFlipSign(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPathValueFlipSign(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathValueFlipSign", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathVariableLookup(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlChar * name; /* the variable name */ + int n_name; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + + ret_val = xmlXPathVariableLookup(ctxt, (const xmlChar *)name); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathVariableLookup", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathVariableLookupNS(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathContextPtr ctxt; /* the XPath context */ + int n_ctxt; + xmlChar * name; /* the variable name */ + int n_name; + xmlChar * ns_uri; /* the variable namespace URI */ + int n_ns_uri; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_ns_uri = 0;n_ns_uri < gen_nb_const_xmlChar_ptr;n_ns_uri++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + ns_uri = gen_const_xmlChar_ptr(n_ns_uri, 2); + + ret_val = xmlXPathVariableLookupNS(ctxt, (const xmlChar *)name, (const xmlChar *)ns_uri); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathContextPtr(n_ctxt, ctxt, 0); + des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_ns_uri, (const xmlChar *)ns_uri, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathVariableLookupNS", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_name); + printf(" %d", n_ns_uri); + printf("\n"); + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathWrapCString(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + char * val; /* the char * value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_char_ptr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_char_ptr(n_val, 0); + + ret_val = xmlXPathWrapCString(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_char_ptr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathWrapCString", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathWrapExternal(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + void * val; /* the user data */ + int n_val; + + for (n_val = 0;n_val < gen_nb_void_ptr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_void_ptr(n_val, 0); + + ret_val = xmlXPathWrapExternal(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_void_ptr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathWrapExternal", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPathWrapNodeSet(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodeSetPtr val; /* the NodePtr value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlNodeSetPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlNodeSetPtr(n_val, 0); + + ret_val = xmlXPathWrapNodeSet(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPathWrapNodeSet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPatherror(void) { + int test_ret = 0; + +#if defined(LIBXML_XPATH_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPath Parser context */ + int n_ctxt; + const char * file; /* the file name */ + int n_file; + int line; /* the line number */ + int n_line; + int no; /* the error number */ + int n_no; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_file = 0;n_file < gen_nb_filepath;n_file++) { + for (n_line = 0;n_line < gen_nb_int;n_line++) { + for (n_no = 0;n_no < gen_nb_int;n_no++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + file = gen_filepath(n_file, 1); + line = gen_int(n_line, 2); + no = gen_int(n_no, 3); + + xmlXPatherror(ctxt, file, line, no); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_filepath(n_file, file, 1); + des_int(n_line, line, 2); + des_int(n_no, no, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPatherror", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_file); + printf(" %d", n_line); + printf(" %d", n_no); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xpathInternals(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xpathInternals : 106 of 117 functions ...\n"); + test_ret += test_valuePop(); + test_ret += test_valuePush(); + test_ret += test_xmlXPathAddValues(); + test_ret += test_xmlXPathBooleanFunction(); + test_ret += test_xmlXPathCeilingFunction(); + test_ret += test_xmlXPathCompareValues(); + test_ret += test_xmlXPathConcatFunction(); + test_ret += test_xmlXPathContainsFunction(); + test_ret += test_xmlXPathCountFunction(); + test_ret += test_xmlXPathDebugDumpCompExpr(); + test_ret += test_xmlXPathDebugDumpObject(); + test_ret += test_xmlXPathDifference(); + test_ret += test_xmlXPathDistinct(); + test_ret += test_xmlXPathDistinctSorted(); + test_ret += test_xmlXPathDivValues(); + test_ret += test_xmlXPathEqualValues(); + test_ret += test_xmlXPathErr(); + test_ret += test_xmlXPathEvalExpr(); + test_ret += test_xmlXPathEvaluatePredicateResult(); + test_ret += test_xmlXPathFalseFunction(); + test_ret += test_xmlXPathFloorFunction(); + test_ret += test_xmlXPathFunctionLookup(); + test_ret += test_xmlXPathFunctionLookupNS(); + test_ret += test_xmlXPathHasSameNodes(); + test_ret += test_xmlXPathIdFunction(); + test_ret += test_xmlXPathIntersection(); + test_ret += test_xmlXPathIsNodeType(); + test_ret += test_xmlXPathLangFunction(); + test_ret += test_xmlXPathLastFunction(); + test_ret += test_xmlXPathLeading(); + test_ret += test_xmlXPathLeadingSorted(); + test_ret += test_xmlXPathLocalNameFunction(); + test_ret += test_xmlXPathModValues(); + test_ret += test_xmlXPathMultValues(); + test_ret += test_xmlXPathNamespaceURIFunction(); + test_ret += test_xmlXPathNewBoolean(); + test_ret += test_xmlXPathNewCString(); + test_ret += test_xmlXPathNewFloat(); + test_ret += test_xmlXPathNewNodeSet(); + test_ret += test_xmlXPathNewNodeSetList(); + test_ret += test_xmlXPathNewParserContext(); + test_ret += test_xmlXPathNewString(); + test_ret += test_xmlXPathNextAncestor(); + test_ret += test_xmlXPathNextAncestorOrSelf(); + test_ret += test_xmlXPathNextAttribute(); + test_ret += test_xmlXPathNextChild(); + test_ret += test_xmlXPathNextDescendant(); + test_ret += test_xmlXPathNextDescendantOrSelf(); + test_ret += test_xmlXPathNextFollowing(); + test_ret += test_xmlXPathNextFollowingSibling(); + test_ret += test_xmlXPathNextNamespace(); + test_ret += test_xmlXPathNextParent(); + test_ret += test_xmlXPathNextPreceding(); + test_ret += test_xmlXPathNextPrecedingSibling(); + test_ret += test_xmlXPathNextSelf(); + test_ret += test_xmlXPathNodeLeading(); + test_ret += test_xmlXPathNodeLeadingSorted(); + test_ret += test_xmlXPathNodeSetAdd(); + test_ret += test_xmlXPathNodeSetAddNs(); + test_ret += test_xmlXPathNodeSetAddUnique(); + test_ret += test_xmlXPathNodeSetContains(); + test_ret += test_xmlXPathNodeSetDel(); + test_ret += test_xmlXPathNodeSetMerge(); + test_ret += test_xmlXPathNodeSetRemove(); + test_ret += test_xmlXPathNodeSetSort(); + test_ret += test_xmlXPathNodeTrailing(); + test_ret += test_xmlXPathNodeTrailingSorted(); + test_ret += test_xmlXPathNormalizeFunction(); + test_ret += test_xmlXPathNotEqualValues(); + test_ret += test_xmlXPathNotFunction(); + test_ret += test_xmlXPathNsLookup(); + test_ret += test_xmlXPathNumberFunction(); + test_ret += test_xmlXPathParseNCName(); + test_ret += test_xmlXPathParseName(); + test_ret += test_xmlXPathPopBoolean(); + test_ret += test_xmlXPathPopExternal(); + test_ret += test_xmlXPathPopNodeSet(); + test_ret += test_xmlXPathPopNumber(); + test_ret += test_xmlXPathPopString(); + test_ret += test_xmlXPathPositionFunction(); + test_ret += test_xmlXPathRegisterAllFunctions(); + test_ret += test_xmlXPathRegisterFunc(); + test_ret += test_xmlXPathRegisterFuncLookup(); + test_ret += test_xmlXPathRegisterFuncNS(); + test_ret += test_xmlXPathRegisterNs(); + test_ret += test_xmlXPathRegisterVariable(); + test_ret += test_xmlXPathRegisterVariableLookup(); + test_ret += test_xmlXPathRegisterVariableNS(); + test_ret += test_xmlXPathRegisteredFuncsCleanup(); + test_ret += test_xmlXPathRegisteredNsCleanup(); + test_ret += test_xmlXPathRegisteredVariablesCleanup(); + test_ret += test_xmlXPathRoot(); + test_ret += test_xmlXPathRoundFunction(); + test_ret += test_xmlXPathStartsWithFunction(); + test_ret += test_xmlXPathStringEvalNumber(); + test_ret += test_xmlXPathStringFunction(); + test_ret += test_xmlXPathStringLengthFunction(); + test_ret += test_xmlXPathSubValues(); + test_ret += test_xmlXPathSubstringAfterFunction(); + test_ret += test_xmlXPathSubstringBeforeFunction(); + test_ret += test_xmlXPathSubstringFunction(); + test_ret += test_xmlXPathSumFunction(); + test_ret += test_xmlXPathTrailing(); + test_ret += test_xmlXPathTrailingSorted(); + test_ret += test_xmlXPathTranslateFunction(); + test_ret += test_xmlXPathTrueFunction(); + test_ret += test_xmlXPathValueFlipSign(); + test_ret += test_xmlXPathVariableLookup(); + test_ret += test_xmlXPathVariableLookupNS(); + test_ret += test_xmlXPathWrapCString(); + test_ret += test_xmlXPathWrapExternal(); + test_ret += test_xmlXPathWrapNodeSet(); + test_ret += test_xmlXPatherror(); + + if (test_ret != 0) + printf("Module xpathInternals: %d errors\n", test_ret); + return(test_ret); +} + +static int +test_xmlXPtrBuildNodeList(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlNodePtr ret_val; + xmlXPathObjectPtr obj; /* the XPointer result from the evaluation. */ + int n_obj; + + for (n_obj = 0;n_obj < gen_nb_xmlXPathObjectPtr;n_obj++) { + mem_base = xmlMemBlocks(); + obj = gen_xmlXPathObjectPtr(n_obj, 0); + + ret_val = xmlXPtrBuildNodeList(obj); + desret_xmlNodePtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_obj, obj, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrBuildNodeList", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_obj); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrEval(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlChar * str; /* the XPointer expression */ + int n_str; + xmlXPathContextPtr ctx; /* the XPointer context */ + int n_ctx; + + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_ctx = 0;n_ctx < gen_nb_xmlXPathContextPtr;n_ctx++) { + mem_base = xmlMemBlocks(); + str = gen_const_xmlChar_ptr(n_str, 0); + ctx = gen_xmlXPathContextPtr(n_ctx, 1); + + ret_val = xmlXPtrEval((const xmlChar *)str, ctx); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_xmlXPathContextPtr(n_ctx, ctx, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrEval", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_ctx); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrEvalRangePredicate(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + + xmlXPtrEvalRangePredicate(ctxt); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrEvalRangePredicate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +#ifdef LIBXML_XPTR_ENABLED + +#define gen_nb_xmlLocationSetPtr 1 +static xmlLocationSetPtr gen_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, xmlLocationSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} +#endif + + +static int +test_xmlXPtrLocationSetAdd(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlLocationSetPtr cur; /* the initial range set */ + int n_cur; + xmlXPathObjectPtr val; /* a new xmlXPathObjectPtr */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlLocationSetPtr(n_cur, 0); + val = gen_xmlXPathObjectPtr(n_val, 1); + + xmlXPtrLocationSetAdd(cur, val); + call_tests++; + des_xmlLocationSetPtr(n_cur, cur, 0); + des_xmlXPathObjectPtr(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrLocationSetAdd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrLocationSetCreate(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPtrLocationSetDel(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlLocationSetPtr cur; /* the initial range set */ + int n_cur; + xmlXPathObjectPtr val; /* an xmlXPathObjectPtr */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlLocationSetPtr(n_cur, 0); + val = gen_xmlXPathObjectPtr(n_val, 1); + + xmlXPtrLocationSetDel(cur, val); + call_tests++; + des_xmlLocationSetPtr(n_cur, cur, 0); + des_xmlXPathObjectPtr(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrLocationSetDel", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrLocationSetMerge(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPtrLocationSetRemove(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlLocationSetPtr cur; /* the initial range set */ + int n_cur; + int val; /* the index to remove */ + int n_val; + + for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) { + for (n_val = 0;n_val < gen_nb_int;n_val++) { + mem_base = xmlMemBlocks(); + cur = gen_xmlLocationSetPtr(n_cur, 0); + val = gen_int(n_val, 1); + + xmlXPtrLocationSetRemove(cur, val); + call_tests++; + des_xmlLocationSetPtr(n_cur, cur, 0); + des_int(n_val, val, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrLocationSetRemove", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_cur); + printf(" %d", n_val); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewCollapsedRange(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr start; /* the starting and ending node */ + int n_start; + + for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) { + mem_base = xmlMemBlocks(); + start = gen_xmlNodePtr(n_start, 0); + + ret_val = xmlXPtrNewCollapsedRange(start); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_start, start, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewCollapsedRange", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewContext(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + +static int +test_xmlXPtrNewLocationSetNodeSet(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodeSetPtr set; /* a node set */ + int n_set; + + for (n_set = 0;n_set < gen_nb_xmlNodeSetPtr;n_set++) { + mem_base = xmlMemBlocks(); + set = gen_xmlNodeSetPtr(n_set, 0); + + ret_val = xmlXPtrNewLocationSetNodeSet(set); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodeSetPtr(n_set, set, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewLocationSetNodeSet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_set); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewLocationSetNodes(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr start; /* the start NodePtr value */ + int n_start; + xmlNodePtr end; /* the end NodePtr value or NULL */ + int n_end; + + for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) { + for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) { + mem_base = xmlMemBlocks(); + start = gen_xmlNodePtr(n_start, 0); + end = gen_xmlNodePtr(n_end, 1); + + ret_val = xmlXPtrNewLocationSetNodes(start, end); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_start, start, 0); + des_xmlNodePtr(n_end, end, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewLocationSetNodes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_end); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewRange(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr start; /* the starting node */ + int n_start; + int startindex; /* the start index */ + int n_startindex; + xmlNodePtr end; /* the ending point */ + int n_end; + int endindex; /* the ending index */ + int n_endindex; + + for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) { + for (n_startindex = 0;n_startindex < gen_nb_int;n_startindex++) { + for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) { + for (n_endindex = 0;n_endindex < gen_nb_int;n_endindex++) { + mem_base = xmlMemBlocks(); + start = gen_xmlNodePtr(n_start, 0); + startindex = gen_int(n_startindex, 1); + end = gen_xmlNodePtr(n_end, 2); + endindex = gen_int(n_endindex, 3); + + ret_val = xmlXPtrNewRange(start, startindex, end, endindex); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_start, start, 0); + des_int(n_startindex, startindex, 1); + des_xmlNodePtr(n_end, end, 2); + des_int(n_endindex, endindex, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewRange", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_startindex); + printf(" %d", n_end); + printf(" %d", n_endindex); + printf("\n"); + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewRangeNodeObject(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr start; /* the starting node */ + int n_start; + xmlXPathObjectPtr end; /* the ending object */ + int n_end; + + for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) { + for (n_end = 0;n_end < gen_nb_xmlXPathObjectPtr;n_end++) { + mem_base = xmlMemBlocks(); + start = gen_xmlNodePtr(n_start, 0); + end = gen_xmlXPathObjectPtr(n_end, 1); + + ret_val = xmlXPtrNewRangeNodeObject(start, end); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_start, start, 0); + des_xmlXPathObjectPtr(n_end, end, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewRangeNodeObject", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_end); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewRangeNodePoint(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr start; /* the starting node */ + int n_start; + xmlXPathObjectPtr end; /* the ending point */ + int n_end; + + for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) { + for (n_end = 0;n_end < gen_nb_xmlXPathObjectPtr;n_end++) { + mem_base = xmlMemBlocks(); + start = gen_xmlNodePtr(n_start, 0); + end = gen_xmlXPathObjectPtr(n_end, 1); + + ret_val = xmlXPtrNewRangeNodePoint(start, end); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_start, start, 0); + des_xmlXPathObjectPtr(n_end, end, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewRangeNodePoint", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_end); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewRangeNodes(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlNodePtr start; /* the starting node */ + int n_start; + xmlNodePtr end; /* the ending node */ + int n_end; + + for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) { + for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) { + mem_base = xmlMemBlocks(); + start = gen_xmlNodePtr(n_start, 0); + end = gen_xmlNodePtr(n_end, 1); + + ret_val = xmlXPtrNewRangeNodes(start, end); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlNodePtr(n_start, start, 0); + des_xmlNodePtr(n_end, end, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewRangeNodes", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_end); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewRangePointNode(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathObjectPtr start; /* the starting point */ + int n_start; + xmlNodePtr end; /* the ending node */ + int n_end; + + for (n_start = 0;n_start < gen_nb_xmlXPathObjectPtr;n_start++) { + for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) { + mem_base = xmlMemBlocks(); + start = gen_xmlXPathObjectPtr(n_start, 0); + end = gen_xmlNodePtr(n_end, 1); + + ret_val = xmlXPtrNewRangePointNode(start, end); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_start, start, 0); + des_xmlNodePtr(n_end, end, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewRangePointNode", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_end); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrNewRangePoints(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlXPathObjectPtr start; /* the starting point */ + int n_start; + xmlXPathObjectPtr end; /* the ending point */ + int n_end; + + for (n_start = 0;n_start < gen_nb_xmlXPathObjectPtr;n_start++) { + for (n_end = 0;n_end < gen_nb_xmlXPathObjectPtr;n_end++) { + mem_base = xmlMemBlocks(); + start = gen_xmlXPathObjectPtr(n_start, 0); + end = gen_xmlXPathObjectPtr(n_end, 1); + + ret_val = xmlXPtrNewRangePoints(start, end); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlXPathObjectPtr(n_start, start, 0); + des_xmlXPathObjectPtr(n_end, end, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrNewRangePoints", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_start); + printf(" %d", n_end); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrRangeToFunction(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */ + int n_ctxt; + int nargs; /* the number of args */ + int n_nargs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { + for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); + nargs = gen_int(n_nargs, 1); + + xmlXPtrRangeToFunction(ctxt, nargs); + call_tests++; + des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); + des_int(n_nargs, nargs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrRangeToFunction", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_nargs); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + +static int +test_xmlXPtrWrapLocationSet(void) { + int test_ret = 0; + +#if defined(LIBXML_XPTR_ENABLED) + int mem_base; + xmlXPathObjectPtr ret_val; + xmlLocationSetPtr val; /* the LocationSet value */ + int n_val; + + for (n_val = 0;n_val < gen_nb_xmlLocationSetPtr;n_val++) { + mem_base = xmlMemBlocks(); + val = gen_xmlLocationSetPtr(n_val, 0); + + ret_val = xmlXPtrWrapLocationSet(val); + desret_xmlXPathObjectPtr(ret_val); + call_tests++; + des_xmlLocationSetPtr(n_val, val, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXPtrWrapLocationSet", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_val); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + +static int +test_xpointer(void) { + int test_ret = 0; + + if (quiet == 0) printf("Testing xpointer : 17 of 21 functions ...\n"); + test_ret += test_xmlXPtrBuildNodeList(); + test_ret += test_xmlXPtrEval(); + test_ret += test_xmlXPtrEvalRangePredicate(); + test_ret += test_xmlXPtrLocationSetAdd(); + test_ret += test_xmlXPtrLocationSetCreate(); + test_ret += test_xmlXPtrLocationSetDel(); + test_ret += test_xmlXPtrLocationSetMerge(); + test_ret += test_xmlXPtrLocationSetRemove(); + test_ret += test_xmlXPtrNewCollapsedRange(); + test_ret += test_xmlXPtrNewContext(); + test_ret += test_xmlXPtrNewLocationSetNodeSet(); + test_ret += test_xmlXPtrNewLocationSetNodes(); + test_ret += test_xmlXPtrNewRange(); + test_ret += test_xmlXPtrNewRangeNodeObject(); + test_ret += test_xmlXPtrNewRangeNodePoint(); + test_ret += test_xmlXPtrNewRangeNodes(); + test_ret += test_xmlXPtrNewRangePointNode(); + test_ret += test_xmlXPtrNewRangePoints(); + test_ret += test_xmlXPtrRangeToFunction(); + test_ret += test_xmlXPtrWrapLocationSet(); + + if (test_ret != 0) + printf("Module xpointer: %d errors\n", test_ret); + return(test_ret); +} +static int +test_module(const char *module) { + if (!strcmp(module, "HTMLparser")) return(test_HTMLparser()); + if (!strcmp(module, "HTMLtree")) return(test_HTMLtree()); + if (!strcmp(module, "SAX2")) return(test_SAX2()); + if (!strcmp(module, "c14n")) return(test_c14n()); + if (!strcmp(module, "catalog")) return(test_catalog()); + if (!strcmp(module, "chvalid")) return(test_chvalid()); + if (!strcmp(module, "debugXML")) return(test_debugXML()); + if (!strcmp(module, "dict")) return(test_dict()); + if (!strcmp(module, "encoding")) return(test_encoding()); + if (!strcmp(module, "entities")) return(test_entities()); + if (!strcmp(module, "hash")) return(test_hash()); + if (!strcmp(module, "list")) return(test_list()); + if (!strcmp(module, "nanoftp")) return(test_nanoftp()); + if (!strcmp(module, "nanohttp")) return(test_nanohttp()); + if (!strcmp(module, "parser")) return(test_parser()); + if (!strcmp(module, "parserInternals")) return(test_parserInternals()); + if (!strcmp(module, "pattern")) return(test_pattern()); + if (!strcmp(module, "relaxng")) return(test_relaxng()); + if (!strcmp(module, "schemasInternals")) return(test_schemasInternals()); + if (!strcmp(module, "schematron")) return(test_schematron()); + if (!strcmp(module, "tree")) return(test_tree()); + if (!strcmp(module, "uri")) return(test_uri()); + if (!strcmp(module, "valid")) return(test_valid()); + if (!strcmp(module, "xinclude")) return(test_xinclude()); + if (!strcmp(module, "xmlIO")) return(test_xmlIO()); + if (!strcmp(module, "xmlautomata")) return(test_xmlautomata()); + if (!strcmp(module, "xmlerror")) return(test_xmlerror()); + if (!strcmp(module, "xmlmodule")) return(test_xmlmodule()); + if (!strcmp(module, "xmlreader")) return(test_xmlreader()); + if (!strcmp(module, "xmlregexp")) return(test_xmlregexp()); + if (!strcmp(module, "xmlsave")) return(test_xmlsave()); + if (!strcmp(module, "xmlschemas")) return(test_xmlschemas()); + if (!strcmp(module, "xmlschemastypes")) return(test_xmlschemastypes()); + if (!strcmp(module, "xmlstring")) return(test_xmlstring()); + if (!strcmp(module, "xmlunicode")) return(test_xmlunicode()); + if (!strcmp(module, "xmlwriter")) return(test_xmlwriter()); + if (!strcmp(module, "xpath")) return(test_xpath()); + if (!strcmp(module, "xpathInternals")) return(test_xpathInternals()); + if (!strcmp(module, "xpointer")) return(test_xpointer()); + return(0); +} diff --git a/src/testchar.c b/src/testchar.c new file mode 100644 index 000000000000..6866a175d6a3 --- /dev/null +++ b/src/testchar.c @@ -0,0 +1,617 @@ +/** + * Test the UTF-8 decoding routines + * + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include +#include +#include + +#include "buf.h" + +int lastError; + +static void errorHandler(void *unused, xmlErrorPtr err) { + if ((unused == NULL) && (err != NULL) && (lastError == 0)) { + lastError = err->code; + } +} + +char document1[100] = "XXXX"; +char document2[100] = ""; + +static void testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document, + int len, char *data, int forbid1, int forbid2) { + int i; + xmlDocPtr res; + + for (i = 0;i <= 0xFF;i++) { + lastError = 0; + xmlCtxtReset(ctxt); + + data[0] = i; + + res = xmlReadMemory(document, len, "test", NULL, 0); + + if ((i == forbid1) || (i == forbid2)) { + if ((lastError == 0) || (res != NULL)) + fprintf(stderr, + "Failed to detect invalid char for Byte 0x%02X: %c\n", + i, i); + } + + else if ((i == '<') || (i == '&')) { + if ((lastError == 0) || (res != NULL)) + fprintf(stderr, + "Failed to detect illegal char %c for Byte 0x%02X\n", i, i); + } + else if (((i < 0x20) || (i >= 0x80)) && + (i != 0x9) && (i != 0xA) && (i != 0xD)) { + if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) + fprintf(stderr, + "Failed to detect invalid char for Byte 0x%02X\n", i); + } + else if (res == NULL) { + fprintf(stderr, + "Failed to parse valid char for Byte 0x%02X : %c\n", i, i); + } + if (res != NULL) + xmlFreeDoc(res); + } +} + +static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, + int len, char *data) { + int i, j; + xmlDocPtr res; + + for (i = 0x80;i <= 0xFF;i++) { + for (j = 0;j <= 0xFF;j++) { + lastError = 0; + xmlCtxtReset(ctxt); + + data[0] = i; + data[1] = j; + + res = xmlReadMemory(document, len, "test", NULL, 0); + + /* if first bit of first char is set, then second bit must too */ + if ((i & 0x80) && ((i & 0x40) == 0)) { + if ((lastError == 0) || (res != NULL)) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", + i, j); + } + + /* + * if first bit of first char is set, then second char first + * bits must be 10 + */ + else if ((i & 0x80) && ((j & 0xC0) != 0x80)) { + if ((lastError == 0) || (res != NULL)) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", + i, j); + } + + /* + * if using a 2 byte encoding then the value must be greater + * than 0x80, i.e. one of bits 5 to 1 of i must be set + */ + else if ((i & 0x80) && ((i & 0x1E) == 0)) { + if ((lastError == 0) || (res != NULL)) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", + i, j); + } + + /* + * if third bit of first char is set, then the sequence would need + * at least 3 bytes, but we give only 2 ! + */ + else if ((i & 0xE0) == 0xE0) { + if ((lastError == 0) || (res != NULL)) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n", + i, j); + } + + /* + * We should see no error in remaining cases + */ + else if ((lastError != 0) || (res == NULL)) { + fprintf(stderr, + "Failed to parse document for Bytes 0x%02X 0x%02X\n", i, j); + } + if (res != NULL) + xmlFreeDoc(res); + } + } +} + +/** + * testDocumentRanges: + * + * Test the correct UTF8 character parsing in context of XML documents + * Those are in-context injection tests checking the parser behaviour on + * edge case values at different point in content, beginning and end of + * CDATA in text or in attribute values. + */ + +static void testDocumentRanges(void) { + xmlParserCtxtPtr ctxt; + char *data; + + /* + * Set up a parsing context using the first document as + * the current input source. + */ + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + fprintf(stderr, "Failed to allocate parser context\n"); + return; + } + + printf("testing 1 byte char in document: 1"); + fflush(stdout); + data = &document1[5]; + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 1 byte injection at beginning of area */ + testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), + data, -1, -1); + printf(" 2"); + fflush(stdout); + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 1 byte injection at end of area */ + testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), + data + 3, -1, -1); + + printf(" 3"); + fflush(stdout); + data = &document2[10]; + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 1 byte injection at beginning of area */ + testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), + data, '\'', -1); + printf(" 4"); + fflush(stdout); + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 1 byte injection at end of area */ + testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), + data + 3, '\'', -1); + printf(" done\n"); + + printf("testing 2 byte char in document: 1"); + fflush(stdout); + data = &document1[5]; + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 2 byte injection at beginning of area */ + testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), + data); + printf(" 2"); + fflush(stdout); + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 2 byte injection at end of area */ + testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), + data + 2); + + printf(" 3"); + fflush(stdout); + data = &document2[10]; + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 2 byte injection at beginning of area */ + testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), + data); + printf(" 4"); + fflush(stdout); + data[0] = ' '; + data[1] = ' '; + data[2] = ' '; + data[3] = ' '; + /* test 2 byte injection at end of area */ + testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), + data + 2); + printf(" done\n"); + + xmlFreeParserCtxt(ctxt); +} + +static void testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) { + int i = 0; + int len, c; + + data[1] = 0; + data[2] = 0; + data[3] = 0; + for (i = 0;i <= 0xFF;i++) { + data[0] = i; + ctxt->charset = XML_CHAR_ENCODING_UTF8; + + lastError = 0; + c = xmlCurrentChar(ctxt, &len); + if ((i == 0) || (i >= 0x80)) { + /* we must see an error there */ + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Byte 0x%02X\n", i); + } else if (i == 0xD) { + if ((c != 0xA) || (len != 1)) + fprintf(stderr, "Failed to convert char for Byte 0x%02X\n", i); + } else if ((c != i) || (len != 1)) { + fprintf(stderr, "Failed to parse char for Byte 0x%02X\n", i); + } + } +} + +static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { + int i, j; + int len, c; + + data[2] = 0; + data[3] = 0; + for (i = 0x80;i <= 0xFF;i++) { + for (j = 0;j <= 0xFF;j++) { + data[0] = i; + data[1] = j; + ctxt->charset = XML_CHAR_ENCODING_UTF8; + + lastError = 0; + c = xmlCurrentChar(ctxt, &len); + + /* if first bit of first char is set, then second bit must too */ + if ((i & 0x80) && ((i & 0x40) == 0)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", + i, j); + } + + /* + * if first bit of first char is set, then second char first + * bits must be 10 + */ + else if ((i & 0x80) && ((j & 0xC0) != 0x80)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n", + i, j, c); + } + + /* + * if using a 2 byte encoding then the value must be greater + * than 0x80, i.e. one of bits 5 to 1 of i must be set + */ + else if ((i & 0x80) && ((i & 0x1E) == 0)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n", + i, j, c); + } + + /* + * if third bit of first char is set, then the sequence would need + * at least 3 bytes, but we give only 2 ! + */ + else if ((i & 0xE0) == 0xE0) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n", + i, j); + } + + /* + * We should see no error in remaining cases + */ + else if ((lastError != 0) || (len != 2)) { + fprintf(stderr, + "Failed to parse char for Bytes 0x%02X 0x%02X\n", i, j); + } + + /* + * Finally check the value is right + */ + else if (c != (j & 0x3F) + ((i & 0x1F) << 6)) { + fprintf(stderr, + "Failed to parse char for Bytes 0x%02X 0x%02X: expect %d got %d\n", + i, j, ((j & 0x3F) + ((i & 0x1F) << 6)), c); + } + } + } +} + +static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { + int i, j, k, K; + int len, c; + unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF}; + int value; + + data[3] = 0; + for (i = 0xE0;i <= 0xFF;i++) { + for (j = 0;j <= 0xFF;j++) { + for (k = 0;k < 6;k++) { + data[0] = i; + data[1] = j; + K = lows[k]; + data[2] = (char) K; + value = (K & 0x3F) + ((j & 0x3F) << 6) + ((i & 0xF) << 12); + ctxt->charset = XML_CHAR_ENCODING_UTF8; + + lastError = 0; + c = xmlCurrentChar(ctxt, &len); + + /* + * if fourth bit of first char is set, then the sequence would need + * at least 4 bytes, but we give only 3 ! + */ + if ((i & 0xF0) == 0xF0) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", + i, j, K, data[3]); + } + + /* + * The second and the third bytes must start with 10 + */ + else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n", + i, j, K); + } + + /* + * if using a 3 byte encoding then the value must be greater + * than 0x800, i.e. one of bits 4 to 0 of i must be set or + * the 6th byte of data[1] must be set + */ + else if (((i & 0xF) == 0) && ((j & 0x20) == 0)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n", + i, j, K); + } + + /* + * There are values in that range that are not allowed in XML-1.0 + */ + else if (((value > 0xD7FF) && (value <0xE000)) || + ((value > 0xFFFD) && (value <0x10000))) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n", + value, i, j, K); + } + + /* + * We should see no error in remaining cases + */ + else if ((lastError != 0) || (len != 3)) { + fprintf(stderr, + "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n", + i, j, K); + } + + /* + * Finally check the value is right + */ + else if (c != value) { + fprintf(stderr, + "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n", + i, j, data[2], value, c); + } + } + } + } +} + +static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { + int i, j, k, K, l, L; + int len, c; + unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF}; + int value; + + data[4] = 0; + for (i = 0xF0;i <= 0xFF;i++) { + for (j = 0;j <= 0xFF;j++) { + for (k = 0;k < 6;k++) { + for (l = 0;l < 6;l++) { + data[0] = i; + data[1] = j; + K = lows[k]; + data[2] = (char) K; + L = lows[l]; + data[3] = (char) L; + value = (L & 0x3F) + ((K & 0x3F) << 6) + ((j & 0x3F) << 12) + + ((i & 0x7) << 18); + ctxt->charset = XML_CHAR_ENCODING_UTF8; + + lastError = 0; + c = xmlCurrentChar(ctxt, &len); + + /* + * if fifth bit of first char is set, then the sequence would need + * at least 5 bytes, but we give only 4 ! + */ + if ((i & 0xF8) == 0xF8) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", + i, j, K, data[3]); + } + + /* + * The second, third and fourth bytes must start with 10 + */ + else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) || + ((L & 0xC0) != 0x80)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", + i, j, K, L); + } + + /* + * if using a 3 byte encoding then the value must be greater + * than 0x10000, i.e. one of bits 3 to 0 of i must be set or + * the 6 or 5th byte of j must be set + */ + else if (((i & 0x7) == 0) && ((j & 0x30) == 0)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, + "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", + i, j, K, L); + } + + /* + * There are values in that range that are not allowed in XML-1.0 + */ + else if (((value > 0xD7FF) && (value <0xE000)) || + ((value > 0xFFFD) && (value <0x10000)) || + (value > 0x10FFFF)) { + if (lastError != XML_ERR_INVALID_CHAR) + fprintf(stderr, +"Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", + value, i, j, K, L); + } + + /* + * We should see no error in remaining cases + */ + else if ((lastError != 0) || (len != 4)) { + fprintf(stderr, + "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n", + i, j, K); + } + + /* + * Finally check the value is right + */ + else if (c != value) { + fprintf(stderr, + "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n", + i, j, data[2], value, c); + } + } + } + } + } +} + +/** + * testCharRanges: + * + * Test the correct UTF8 character parsing in isolation i.e. + * not when parsing a full document, this is less expensive and we can + * cover the full range of UTF-8 chars accepted by XML-1.0 + */ + +static void testCharRanges(void) { + char data[5]; + xmlParserCtxtPtr ctxt; + xmlParserInputBufferPtr buf; + xmlParserInputPtr input; + + memset(data, 0, 5); + + /* + * Set up a parsing context using the above data buffer as + * the current input source. + */ + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + fprintf(stderr, "Failed to allocate parser context\n"); + return; + } + buf = xmlParserInputBufferCreateStatic(data, sizeof(data), + XML_CHAR_ENCODING_NONE); + if (buf == NULL) { + fprintf(stderr, "Failed to allocate input buffer\n"); + goto error; + } + input = xmlNewInputStream(ctxt); + if (input == NULL) { + xmlFreeParserInputBuffer(buf); + goto error; + } + input->filename = NULL; + input->buf = buf; + input->cur = + input->base = xmlBufContent(input->buf->buffer); + input->end = input->base + 4; + inputPush(ctxt, input); + + printf("testing char range: 1"); + fflush(stdout); + testCharRangeByte1(ctxt, data); + printf(" 2"); + fflush(stdout); + testCharRangeByte2(ctxt, data); + printf(" 3"); + fflush(stdout); + testCharRangeByte3(ctxt, data); + printf(" 4"); + fflush(stdout); + testCharRangeByte4(ctxt, data); + printf(" done\n"); + fflush(stdout); + +error: + xmlFreeParserCtxt(ctxt); +} + +int main(void) { + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + /* + * Catch errors separately + */ + + xmlSetStructuredErrorFunc(NULL, errorHandler); + + /* + * Run the tests + */ + testCharRanges(); + testDocumentRanges(); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} diff --git a/src/testdict.c b/src/testdict.c new file mode 100644 index 000000000000..40bebd0582b6 --- /dev/null +++ b/src/testdict.c @@ -0,0 +1,444 @@ +#include +#include +#include + +/* #define WITH_PRINT */ + +static const char *seeds1[] = { + "a", "b", "c", + "d", "e", "f", + "g", "h", "i", + "j", "k", "l", + + NULL +}; + +static const char *seeds2[] = { + "m", "n", "o", + "p", "q", "r", + "s", "t", "u", + "v", "w", "x", + + NULL +}; + +#define NB_STRINGS_NS 100 +#define NB_STRINGS_MAX 10000 +#define NB_STRINGS_MIN 10 + +static xmlChar *strings1[NB_STRINGS_MAX]; +static xmlChar *strings2[NB_STRINGS_MAX]; +static const xmlChar *test1[NB_STRINGS_MAX]; +static const xmlChar *test2[NB_STRINGS_MAX]; +static int nbErrors = 0; + +static void fill_strings(void) { + int i, j, k; + + /* + * That's a bit nasty but the output is fine and it doesn't take hours + * there is a small but sufficient number of duplicates, and we have + * ":xxx" and full QNames in the last NB_STRINGS_NS values + */ + for (i = 0; seeds1[i] != NULL; i++) { + strings1[i] = xmlStrdup((const xmlChar *) seeds1[i]); + if (strings1[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings1\n"); + exit(1); + } + } + for (j = 0, k = 0;i < NB_STRINGS_MAX - NB_STRINGS_NS;i++,j++) { + strings1[i] = xmlStrncatNew(strings1[j], strings1[k], -1); + if (strings1[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings1\n"); + exit(1); + } + if (j >= 50) { + j = 0; + k++; + } + } + for (j = 0; (j < 50) && (i < NB_STRINGS_MAX); i++, j+=2) { + strings1[i] = xmlStrncatNew(strings1[j], (const xmlChar *) ":", -1); + if (strings1[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings1\n"); + exit(1); + } + } + for (j = NB_STRINGS_MAX - NB_STRINGS_NS, k = 0; + i < NB_STRINGS_MAX;i++,j++) { + strings1[i] = xmlStrncatNew(strings1[j], strings1[k], -1); + if (strings1[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings1\n"); + exit(1); + } + k += 3; + if (k >= 50) k = 0; + } + + /* + * Now do the same with the second pool of strings + */ + for (i = 0; seeds2[i] != NULL; i++) { + strings2[i] = xmlStrdup((const xmlChar *) seeds2[i]); + if (strings2[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings2\n"); + exit(1); + } + } + for (j = 0, k = 0;i < NB_STRINGS_MAX - NB_STRINGS_NS;i++,j++) { + strings2[i] = xmlStrncatNew(strings2[j], strings2[k], -1); + if (strings2[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings2\n"); + exit(1); + } + if (j >= 50) { + j = 0; + k++; + } + } + for (j = 0; (j < 50) && (i < NB_STRINGS_MAX); i++, j+=2) { + strings2[i] = xmlStrncatNew(strings2[j], (const xmlChar *) ":", -1); + if (strings2[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings2\n"); + exit(1); + } + } + for (j = NB_STRINGS_MAX - NB_STRINGS_NS, k = 0; + i < NB_STRINGS_MAX;i++,j++) { + strings2[i] = xmlStrncatNew(strings2[j], strings2[k], -1); + if (strings2[i] == NULL) { + fprintf(stderr, "Out of memory while generating strings2\n"); + exit(1); + } + k += 3; + if (k >= 50) k = 0; + } + +} + +#ifdef WITH_PRINT +static void print_strings(void) { + int i; + + for (i = 0; i < NB_STRINGS_MAX;i++) { + printf("%s\n", strings1[i]); + } + for (i = 0; i < NB_STRINGS_MAX;i++) { + printf("%s\n", strings2[i]); + } +} +#endif + +static void clean_strings(void) { + int i; + + for (i = 0; i < NB_STRINGS_MAX; i++) { + if (strings1[i] != NULL) /* really should not happen */ + xmlFree(strings1[i]); + } + for (i = 0; i < NB_STRINGS_MAX; i++) { + if (strings2[i] != NULL) /* really should not happen */ + xmlFree(strings2[i]); + } +} + +/* + * This tests the sub-dictionary support + */ +static int run_test2(xmlDictPtr parent) { + int i, j; + xmlDictPtr dict; + int ret = 0; + xmlChar prefix[40]; + xmlChar *cur, *pref; + const xmlChar *tmp; + + dict = xmlDictCreateSub(parent); + if (dict == NULL) { + fprintf(stderr, "Out of memory while creating sub-dictionary\n"); + exit(1); + } + memset(test2, 0, sizeof(test2)); + + /* + * Fill in NB_STRINGS_MIN, at this point the dictionary should not grow + * and we allocate all those doing the fast key computations + * All the strings are based on a different seeds subset so we know + * they are allocated in the main dictionary, not coming from the parent + */ + for (i = 0;i < NB_STRINGS_MIN;i++) { + test2[i] = xmlDictLookup(dict, strings2[i], -1); + if (test2[i] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings2[i]); + ret = 1; + nbErrors++; + } + } + j = NB_STRINGS_MAX - NB_STRINGS_NS; + /* ":foo" like strings2 */ + for (i = 0;i < NB_STRINGS_MIN;i++, j++) { + test2[j] = xmlDictLookup(dict, strings2[j], xmlStrlen(strings2[j])); + if (test2[j] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings2[j]); + ret = 1; + nbErrors++; + } + } + /* "a:foo" like strings2 */ + j = NB_STRINGS_MAX - NB_STRINGS_MIN; + for (i = 0;i < NB_STRINGS_MIN;i++, j++) { + test2[j] = xmlDictLookup(dict, strings2[j], xmlStrlen(strings2[j])); + if (test2[j] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings2[j]); + ret = 1; + nbErrors++; + } + } + + /* + * At this point allocate all the strings + * the dictionary will grow in the process, reallocate more string tables + * and switch to the better key generator + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (test2[i] != NULL) + continue; + test2[i] = xmlDictLookup(dict, strings2[i], -1); + if (test2[i] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings2[i]); + ret = 1; + nbErrors++; + } + } + + /* + * Now we can start to test things, first that all strings2 belongs to + * the dict, and that none of them was actually allocated in the parent + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (!xmlDictOwns(dict, test2[i])) { + fprintf(stderr, "Failed ownership failure for '%s'\n", + strings2[i]); + ret = 1; + nbErrors++; + } + if (xmlDictOwns(parent, test2[i])) { + fprintf(stderr, "Failed parent ownership failure for '%s'\n", + strings2[i]); + ret = 1; + nbErrors++; + } + } + + /* + * Also verify that all strings from the parent are seen from the subdict + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (!xmlDictOwns(dict, test1[i])) { + fprintf(stderr, "Failed sub-ownership failure for '%s'\n", + strings1[i]); + ret = 1; + nbErrors++; + } + } + + /* + * Then that another lookup to the string in sub will return the same + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (xmlDictLookup(dict, strings2[i], -1) != test2[i]) { + fprintf(stderr, "Failed re-lookup check for %d, '%s'\n", + i, strings2[i]); + ret = 1; + nbErrors++; + } + } + /* + * But also that any lookup for a string in the parent will be provided + * as in the parent + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (xmlDictLookup(dict, strings1[i], -1) != test1[i]) { + fprintf(stderr, "Failed parent string lookup check for %d, '%s'\n", + i, strings1[i]); + ret = 1; + nbErrors++; + } + } + + /* + * check the QName lookups + */ + for (i = NB_STRINGS_MAX - NB_STRINGS_NS;i < NB_STRINGS_MAX;i++) { + cur = strings2[i]; + pref = &prefix[0]; + while (*cur != ':') *pref++ = *cur++; + cur++; + *pref = 0; + tmp = xmlDictQLookup(dict, &prefix[0], cur); + if (tmp != test2[i]) { + fprintf(stderr, "Failed lookup check for '%s':'%s'\n", + &prefix[0], cur); + ret = 1; + nbErrors++; + } + } + /* + * check the QName lookups for strings from the parent + */ + for (i = NB_STRINGS_MAX - NB_STRINGS_NS;i < NB_STRINGS_MAX;i++) { + cur = strings1[i]; + pref = &prefix[0]; + while (*cur != ':') *pref++ = *cur++; + cur++; + *pref = 0; + tmp = xmlDictQLookup(dict, &prefix[0], cur); + if (xmlDictQLookup(dict, &prefix[0], cur) != test1[i]) { + fprintf(stderr, "Failed parent lookup check for '%s':'%s'\n", + &prefix[0], cur); + ret = 1; + nbErrors++; + } + } + + xmlDictFree(dict); + return(ret); +} + +/* + * Test a single dictionary + */ +static int run_test1(void) { + int i, j; + xmlDictPtr dict; + int ret = 0; + xmlChar prefix[40]; + xmlChar *cur, *pref; + const xmlChar *tmp; + + dict = xmlDictCreate(); + if (dict == NULL) { + fprintf(stderr, "Out of memory while creating dictionary\n"); + exit(1); + } + memset(test1, 0, sizeof(test1)); + + /* + * Fill in NB_STRINGS_MIN, at this point the dictionary should not grow + * and we allocate all those doing the fast key computations + */ + for (i = 0;i < NB_STRINGS_MIN;i++) { + test1[i] = xmlDictLookup(dict, strings1[i], -1); + if (test1[i] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings1[i]); + ret = 1; + nbErrors++; + } + } + j = NB_STRINGS_MAX - NB_STRINGS_NS; + /* ":foo" like strings1 */ + for (i = 0;i < NB_STRINGS_MIN;i++, j++) { + test1[j] = xmlDictLookup(dict, strings1[j], xmlStrlen(strings1[j])); + if (test1[j] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings1[j]); + ret = 1; + nbErrors++; + } + } + /* "a:foo" like strings1 */ + j = NB_STRINGS_MAX - NB_STRINGS_MIN; + for (i = 0;i < NB_STRINGS_MIN;i++, j++) { + test1[j] = xmlDictLookup(dict, strings1[j], xmlStrlen(strings1[j])); + if (test1[j] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings1[j]); + ret = 1; + nbErrors++; + } + } + + /* + * At this point allocate all the strings + * the dictionary will grow in the process, reallocate more string tables + * and switch to the better key generator + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (test1[i] != NULL) + continue; + test1[i] = xmlDictLookup(dict, strings1[i], -1); + if (test1[i] == NULL) { + fprintf(stderr, "Failed lookup for '%s'\n", strings1[i]); + ret = 1; + nbErrors++; + } + } + + /* + * Now we can start to test things, first that all strings1 belongs to + * the dict + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (!xmlDictOwns(dict, test1[i])) { + fprintf(stderr, "Failed ownership failure for '%s'\n", + strings1[i]); + ret = 1; + nbErrors++; + } + } + + /* + * Then that another lookup to the string will return the same + */ + for (i = 0;i < NB_STRINGS_MAX;i++) { + if (xmlDictLookup(dict, strings1[i], -1) != test1[i]) { + fprintf(stderr, "Failed re-lookup check for %d, '%s'\n", + i, strings1[i]); + ret = 1; + nbErrors++; + } + } + + /* + * More complex, check the QName lookups + */ + for (i = NB_STRINGS_MAX - NB_STRINGS_NS;i < NB_STRINGS_MAX;i++) { + cur = strings1[i]; + pref = &prefix[0]; + while (*cur != ':') *pref++ = *cur++; + cur++; + *pref = 0; + tmp = xmlDictQLookup(dict, &prefix[0], cur); + if (tmp != test1[i]) { + fprintf(stderr, "Failed lookup check for '%s':'%s'\n", + &prefix[0], cur); + ret = 1; + nbErrors++; + } + } + + run_test2(dict); + + xmlDictFree(dict); + return(ret); +} + +int main(void) +{ + int ret; + + LIBXML_TEST_VERSION + fill_strings(); +#ifdef WITH_PRINT + print_strings(); +#endif + ret = run_test1(); + if (ret == 0) { + printf("dictionary tests succeeded %d strings\n", 2 * NB_STRINGS_MAX); + } else { + printf("dictionary tests failed with %d errors\n", nbErrors); + } + clean_strings(); + xmlCleanupParser(); + xmlMemoryDump(); + return(ret); +} diff --git a/src/testdso.c b/src/testdso.c new file mode 100644 index 000000000000..bd4ff0865d99 --- /dev/null +++ b/src/testdso.c @@ -0,0 +1,12 @@ +#include + +#define IN_LIBXML +#include "libxml/xmlexports.h" + +XMLPUBFUN int hello_world(void); + +int hello_world(void) +{ + printf("Success!\n"); + return 0; +} diff --git a/src/testlimits.c b/src/testlimits.c new file mode 100644 index 000000000000..059116a69478 --- /dev/null +++ b/src/testlimits.c @@ -0,0 +1,1638 @@ +/* + * testlimits.c: C program to run libxml2 regression tests checking various + * limits in document size. Will consume a lot of RAM and CPU cycles + * + * To compile on Unixes: + * cc -o testlimits `xml2-config --cflags` testlimits.c `xml2-config --libs` -lpthread + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#include + +#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#endif +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef LIBXML_READER_ENABLED +#include +#endif + +static int verbose = 0; +static int tests_quiet = 0; + +/************************************************************************ + * * + * time handling * + * * + ************************************************************************/ + +/* maximum time for one parsing before declaring a timeout */ +#define MAX_TIME 2 /* seconds */ + +static clock_t t0; +int timeout = 0; + +static void reset_timout(void) { + timeout = 0; + t0 = clock(); +} + +static int check_time(void) { + clock_t tnow = clock(); + if (((tnow - t0) / CLOCKS_PER_SEC) > MAX_TIME) { + timeout = 1; + return(0); + } + return(1); +} + +/************************************************************************ + * * + * Huge document generator * + * * + ************************************************************************/ + +#include + +/* + * Huge documents are built using fixed start and end chunks + * and filling between the two an unconventional amount of char data + */ +typedef struct hugeTest hugeTest; +typedef hugeTest *hugeTestPtr; +struct hugeTest { + const char *description; + const char *name; + const char *start; + const char *end; +}; + +static struct hugeTest hugeTests[] = { + { "Huge text node", "huge:textNode", "", "" }, + { "Huge attribute node", "huge:attrNode", "" }, + { "Huge comment node", "huge:commentNode", "" }, + { "Huge PI node", "huge:piNode", "" }, +}; + +static const char *current; +static int rlen; +static unsigned int currentTest = 0; +static int instate = 0; + +/** + * hugeMatch: + * @URI: an URI to test + * + * Check for an huge: query + * + * Returns 1 if yes and 0 if another Input module should be used + */ +static int +hugeMatch(const char * URI) { + if ((URI != NULL) && (!strncmp(URI, "huge:", 5))) + return(1); + return(0); +} + +/** + * hugeOpen: + * @URI: an URI to test + * + * Return a pointer to the huge: query handler, in this example simply + * the current pointer... + * + * Returns an Input context or NULL in case or error + */ +static void * +hugeOpen(const char * URI) { + if ((URI == NULL) || (strncmp(URI, "huge:", 5))) + return(NULL); + + for (currentTest = 0;currentTest < sizeof(hugeTests)/sizeof(hugeTests[0]); + currentTest++) + if (!strcmp(hugeTests[currentTest].name, URI)) + goto found; + + return(NULL); + +found: + rlen = strlen(hugeTests[currentTest].start); + current = hugeTests[currentTest].start; + instate = 0; + return((void *) current); +} + +/** + * hugeClose: + * @context: the read context + * + * Close the huge: query handler + * + * Returns 0 or -1 in case of error + */ +static int +hugeClose(void * context) { + if (context == NULL) return(-1); + fprintf(stderr, "\n"); + return(0); +} + +#define CHUNK 4096 + +char filling[CHUNK + 1]; + +static void fillFilling(void) { + int i; + + for (i = 0;i < CHUNK;i++) { + filling[i] = 'a'; + } + filling[CHUNK] = 0; +} + +size_t maxlen = 64 * 1024 * 1024; +size_t curlen = 0; +size_t dotlen; + +/** + * hugeRead: + * @context: the read context + * @buffer: where to store data + * @len: number of bytes to read + * + * Implement an huge: query read. + * + * Returns the number of bytes read or -1 in case of error + */ +static int +hugeRead(void *context, char *buffer, int len) +{ + if ((context == NULL) || (buffer == NULL) || (len < 0)) + return (-1); + + if (instate == 0) { + if (len >= rlen) { + len = rlen; + rlen = 0; + memcpy(buffer, current, len); + instate = 1; + curlen = 0; + dotlen = maxlen / 10; + } else { + memcpy(buffer, current, len); + rlen -= len; + current += len; + } + } else if (instate == 2) { + if (len >= rlen) { + len = rlen; + rlen = 0; + memcpy(buffer, current, len); + instate = 3; + curlen = 0; + } else { + memcpy(buffer, current, len); + rlen -= len; + current += len; + } + } else if (instate == 1) { + if (len > CHUNK) len = CHUNK; + memcpy(buffer, &filling[0], len); + curlen += len; + if (curlen >= maxlen) { + rlen = strlen(hugeTests[currentTest].end); + current = hugeTests[currentTest].end; + instate = 2; + } else { + if (curlen > dotlen) { + fprintf(stderr, "."); + dotlen += maxlen / 10; + } + } + } else + len = 0; + return (len); +} + +/************************************************************************ + * * + * Crazy document generator * + * * + ************************************************************************/ + +unsigned int crazy_indx = 0; + +const char *crazy = "\ +\ +\ +\ +\ +\ +\ +]>\ +\ +\ +\ +\ +\ +foo\ +\ +\ +\ +"; + +/** + * crazyMatch: + * @URI: an URI to test + * + * Check for a crazy: query + * + * Returns 1 if yes and 0 if another Input module should be used + */ +static int +crazyMatch(const char * URI) { + if ((URI != NULL) && (!strncmp(URI, "crazy:", 6))) + return(1); + return(0); +} + +/** + * crazyOpen: + * @URI: an URI to test + * + * Return a pointer to the crazy: query handler, in this example simply + * the current pointer... + * + * Returns an Input context or NULL in case or error + */ +static void * +crazyOpen(const char * URI) { + if ((URI == NULL) || (strncmp(URI, "crazy:", 6))) + return(NULL); + + if (crazy_indx > strlen(crazy)) + return(NULL); + reset_timout(); + rlen = crazy_indx; + current = &crazy[0]; + instate = 0; + return((void *) current); +} + +/** + * crazyClose: + * @context: the read context + * + * Close the crazy: query handler + * + * Returns 0 or -1 in case of error + */ +static int +crazyClose(void * context) { + if (context == NULL) return(-1); + return(0); +} + + +/** + * crazyRead: + * @context: the read context + * @buffer: where to store data + * @len: number of bytes to read + * + * Implement an crazy: query read. + * + * Returns the number of bytes read or -1 in case of error + */ +static int +crazyRead(void *context, char *buffer, int len) +{ + if ((context == NULL) || (buffer == NULL) || (len < 0)) + return (-1); + + if ((check_time() <= 0) && (instate == 1)) { + fprintf(stderr, "\ntimeout in crazy(%d)\n", crazy_indx); + rlen = strlen(crazy) - crazy_indx; + current = &crazy[crazy_indx]; + instate = 2; + } + if (instate == 0) { + if (len >= rlen) { + len = rlen; + rlen = 0; + memcpy(buffer, current, len); + instate = 1; + curlen = 0; + } else { + memcpy(buffer, current, len); + rlen -= len; + current += len; + } + } else if (instate == 2) { + if (len >= rlen) { + len = rlen; + rlen = 0; + memcpy(buffer, current, len); + instate = 3; + curlen = 0; + } else { + memcpy(buffer, current, len); + rlen -= len; + current += len; + } + } else if (instate == 1) { + if (len > CHUNK) len = CHUNK; + memcpy(buffer, &filling[0], len); + curlen += len; + if (curlen >= maxlen) { + rlen = strlen(crazy) - crazy_indx; + current = &crazy[crazy_indx]; + instate = 2; + } + } else + len = 0; + return (len); +} +/************************************************************************ + * * + * Libxml2 specific routines * + * * + ************************************************************************/ + +static int nb_tests = 0; +static int nb_errors = 0; +static int nb_leaks = 0; +static int extraMemoryFromResolver = 0; + +/* + * We need to trap calls to the resolver to not account memory for the catalog + * which is shared to the current running test. We also don't want to have + * network downloads modifying tests. + */ +static xmlParserInputPtr +testExternalEntityLoader(const char *URL, const char *ID, + xmlParserCtxtPtr ctxt) { + xmlParserInputPtr ret; + int memused = xmlMemUsed(); + + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + extraMemoryFromResolver += xmlMemUsed() - memused; + + return(ret); +} + +/* + * Trapping the error messages at the generic level to grab the equivalent of + * stderr messages on CLI tools. + */ +static char testErrors[32769]; +static int testErrorsSize = 0; + +static void XMLCDECL +channel(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { + va_list args; + int res; + + if (testErrorsSize >= 32768) + return; + va_start(args, msg); + res = vsnprintf(&testErrors[testErrorsSize], + 32768 - testErrorsSize, + msg, args); + va_end(args); + if (testErrorsSize + res >= 32768) { + /* buffer is full */ + testErrorsSize = 32768; + testErrors[testErrorsSize] = 0; + } else { + testErrorsSize += res; + } + testErrors[testErrorsSize] = 0; +} + +/** + * xmlParserPrintFileContext: + * @input: an xmlParserInputPtr input + * + * Displays current context within the input content for error tracking + */ + +static void +xmlParserPrintFileContextInternal(xmlParserInputPtr input , + xmlGenericErrorFunc chanl, void *data ) { + const xmlChar *cur, *base; + unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */ + xmlChar content[81]; /* space for 80 chars + line terminator */ + xmlChar *ctnt; + + if (input == NULL) return; + cur = input->cur; + base = input->base; + /* skip backwards over any end-of-lines */ + while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { + cur--; + } + n = 0; + /* search backwards for beginning-of-line (to max buff size) */ + while ((n++ < (sizeof(content)-1)) && (cur > base) && + (*(cur) != '\n') && (*(cur) != '\r')) + cur--; + if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; + /* calculate the error position in terms of the current position */ + col = input->cur - cur; + /* search forward for end-of-line (to max buff size) */ + n = 0; + ctnt = content; + /* copy selected text to our buffer */ + while ((*cur != 0) && (*(cur) != '\n') && + (*(cur) != '\r') && (n < sizeof(content)-1)) { + *ctnt++ = *cur++; + n++; + } + *ctnt = 0; + /* print out the selected text */ + chanl(data ,"%s\n", content); + /* create blank line with problem pointer */ + n = 0; + ctnt = content; + /* (leave buffer space for pointer + line terminator) */ + while ((nfile; + line = err->line; + code = err->code; + domain = err->domain; + level = err->level; + node = err->node; + if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || + (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || + (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { + ctxt = err->ctxt; + } + str = err->message; + + if (code == XML_ERR_OK) + return; + + if ((node != NULL) && (node->type == XML_ELEMENT_NODE)) + name = node->name; + + /* + * Maintain the compatibility with the legacy error handling + */ + if (ctxt != NULL) { + input = ctxt->input; + if ((input != NULL) && (input->filename == NULL) && + (ctxt->inputNr > 1)) { + cur = input; + input = ctxt->inputTab[ctxt->inputNr - 2]; + } + if (input != NULL) { + if (input->filename) + channel(data, "%s:%d: ", input->filename, input->line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: ", input->line); + } + } else { + if (file != NULL) + channel(data, "%s:%d: ", file, line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: ", line); + } + if (name != NULL) { + channel(data, "element %s: ", name); + } + if (code == XML_ERR_OK) + return; + switch (domain) { + case XML_FROM_PARSER: + channel(data, "parser "); + break; + case XML_FROM_NAMESPACE: + channel(data, "namespace "); + break; + case XML_FROM_DTD: + case XML_FROM_VALID: + channel(data, "validity "); + break; + case XML_FROM_HTML: + channel(data, "HTML parser "); + break; + case XML_FROM_MEMORY: + channel(data, "memory "); + break; + case XML_FROM_OUTPUT: + channel(data, "output "); + break; + case XML_FROM_IO: + channel(data, "I/O "); + break; + case XML_FROM_XINCLUDE: + channel(data, "XInclude "); + break; + case XML_FROM_XPATH: + channel(data, "XPath "); + break; + case XML_FROM_XPOINTER: + channel(data, "parser "); + break; + case XML_FROM_REGEXP: + channel(data, "regexp "); + break; + case XML_FROM_MODULE: + channel(data, "module "); + break; + case XML_FROM_SCHEMASV: + channel(data, "Schemas validity "); + break; + case XML_FROM_SCHEMASP: + channel(data, "Schemas parser "); + break; + case XML_FROM_RELAXNGP: + channel(data, "Relax-NG parser "); + break; + case XML_FROM_RELAXNGV: + channel(data, "Relax-NG validity "); + break; + case XML_FROM_CATALOG: + channel(data, "Catalog "); + break; + case XML_FROM_C14N: + channel(data, "C14N "); + break; + case XML_FROM_XSLT: + channel(data, "XSLT "); + break; + default: + break; + } + if (code == XML_ERR_OK) + return; + switch (level) { + case XML_ERR_NONE: + channel(data, ": "); + break; + case XML_ERR_WARNING: + channel(data, "warning : "); + break; + case XML_ERR_ERROR: + channel(data, "error : "); + break; + case XML_ERR_FATAL: + channel(data, "error : "); + break; + } + if (code == XML_ERR_OK) + return; + if (str != NULL) { + int len; + len = xmlStrlen((const xmlChar *)str); + if ((len > 0) && (str[len - 1] != '\n')) + channel(data, "%s\n", str); + else + channel(data, "%s", str); + } else { + channel(data, "%s\n", "out of memory error"); + } + if (code == XML_ERR_OK) + return; + + if (ctxt != NULL) { + xmlParserPrintFileContextInternal(input, channel, data); + if (cur != NULL) { + if (cur->filename) + channel(data, "%s:%d: \n", cur->filename, cur->line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: \n", cur->line); + xmlParserPrintFileContextInternal(cur, channel, data); + } + } + if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) && + (err->int1 < 100) && + (err->int1 < xmlStrlen((const xmlChar *)err->str1))) { + xmlChar buf[150]; + int i; + + channel(data, "%s\n", err->str1); + for (i=0;i < err->int1;i++) + buf[i] = ' '; + buf[i++] = '^'; + buf[i] = 0; + channel(data, "%s\n", buf); + } +} + +static void +initializeLibxml2(void) { + xmlGetWarningsDefaultValue = 0; + xmlPedanticParserDefault(0); + + xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); + xmlInitParser(); + xmlSetExternalEntityLoader(testExternalEntityLoader); + xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); + /* + * register the new I/O handlers + */ + if (xmlRegisterInputCallbacks(hugeMatch, hugeOpen, + hugeRead, hugeClose) < 0) { + fprintf(stderr, "failed to register Huge handlers\n"); + exit(1); + } + if (xmlRegisterInputCallbacks(crazyMatch, crazyOpen, + crazyRead, crazyClose) < 0) { + fprintf(stderr, "failed to register Crazy handlers\n"); + exit(1); + } +} + +/************************************************************************ + * * + * SAX empty callbacks * + * * + ************************************************************************/ + +unsigned long callbacks = 0; + +/** + * isStandaloneCallback: + * @ctxt: An XML parser context + * + * Is this document tagged standalone ? + * + * Returns 1 if true + */ +static int +isStandaloneCallback(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + return (0); +} + +/** + * hasInternalSubsetCallback: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + * + * Returns 1 if true + */ +static int +hasInternalSubsetCallback(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + return (0); +} + +/** + * hasExternalSubsetCallback: + * @ctxt: An XML parser context + * + * Does this document has an external subset + * + * Returns 1 if true + */ +static int +hasExternalSubsetCallback(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + return (0); +} + +/** + * internalSubsetCallback: + * @ctxt: An XML parser context + * + * Does this document has an internal subset + */ +static void +internalSubsetCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + const xmlChar * ExternalID ATTRIBUTE_UNUSED, + const xmlChar * SystemID ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * externalSubsetCallback: + * @ctxt: An XML parser context + * + * Does this document has an external subset + */ +static void +externalSubsetCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + const xmlChar * ExternalID ATTRIBUTE_UNUSED, + const xmlChar * SystemID ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * resolveEntityCallback: + * @ctxt: An XML parser context + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Special entity resolver, better left to the parser, it has + * more context than the application layer. + * The default behaviour is to NOT resolve the entities, in that case + * the ENTITY_REF nodes are built in the structure (and the parameter + * values). + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlParserInputPtr +resolveEntityCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * publicId ATTRIBUTE_UNUSED, + const xmlChar * systemId ATTRIBUTE_UNUSED) +{ + callbacks++; + return (NULL); +} + +/** + * getEntityCallback: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get an entity by name + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +static xmlEntityPtr +getEntityCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED) +{ + callbacks++; + return (NULL); +} + +/** + * getParameterEntityCallback: + * @ctxt: An XML parser context + * @name: The entity name + * + * Get a parameter entity by name + * + * Returns the xmlParserInputPtr + */ +static xmlEntityPtr +getParameterEntityCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED) +{ + callbacks++; + return (NULL); +} + + +/** + * entityDeclCallback: + * @ctxt: An XML parser context + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed + */ +static void +entityDeclCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + const xmlChar * publicId ATTRIBUTE_UNUSED, + const xmlChar * systemId ATTRIBUTE_UNUSED, + xmlChar * content ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * attributeDeclCallback: + * @ctxt: An XML parser context + * @name: the attribute name + * @type: the attribute type + * + * An attribute definition has been parsed + */ +static void +attributeDeclCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * elem ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, int def ATTRIBUTE_UNUSED, + const xmlChar * defaultValue ATTRIBUTE_UNUSED, + xmlEnumerationPtr tree ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * elementDeclCallback: + * @ctxt: An XML parser context + * @name: the element name + * @type: the element type + * @content: the element value (without processing). + * + * An element definition has been parsed + */ +static void +elementDeclCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + xmlElementContentPtr content ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * notationDeclCallback: + * @ctxt: An XML parser context + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +static void +notationDeclCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + const xmlChar * publicId ATTRIBUTE_UNUSED, + const xmlChar * systemId ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * unparsedEntityDeclCallback: + * @ctxt: An XML parser context + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed + */ +static void +unparsedEntityDeclCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + const xmlChar * publicId ATTRIBUTE_UNUSED, + const xmlChar * systemId ATTRIBUTE_UNUSED, + const xmlChar * notationName ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * setDocumentLocatorCallback: + * @ctxt: An XML parser context + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator + * Everything is available on the context, so this is useless in our case. + */ +static void +setDocumentLocatorCallback(void *ctx ATTRIBUTE_UNUSED, + xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * startDocumentCallback: + * @ctxt: An XML parser context + * + * called when the document start being processed. + */ +static void +startDocumentCallback(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * endDocumentCallback: + * @ctxt: An XML parser context + * + * called when the document end has been detected. + */ +static void +endDocumentCallback(void *ctx ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +#if 0 +/** + * startElementCallback: + * @ctxt: An XML parser context + * @name: The element name + * + * called when an opening tag has been processed. + */ +static void +startElementCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED, + const xmlChar ** atts ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * endElementCallback: + * @ctxt: An XML parser context + * @name: The element name + * + * called when the end of an element has been detected. + */ +static void +endElementCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} +#endif + +/** + * charactersCallback: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * receiving some chars from the parser. + * Question: how much at a time ??? + */ +static void +charactersCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * ch ATTRIBUTE_UNUSED, + int len ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * referenceCallback: + * @ctxt: An XML parser context + * @name: The entity name + * + * called when an entity reference is detected. + */ +static void +referenceCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * name ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * ignorableWhitespaceCallback: + * @ctxt: An XML parser context + * @ch: a xmlChar string + * @start: the first char in the string + * @len: the number of xmlChar + * + * receiving some ignorable whitespaces from the parser. + * Question: how much at a time ??? + */ +static void +ignorableWhitespaceCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * ch ATTRIBUTE_UNUSED, + int len ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * processingInstructionCallback: + * @ctxt: An XML parser context + * @target: the target name + * @data: the PI data's + * @len: the number of xmlChar + * + * A processing instruction has been parsed. + */ +static void +processingInstructionCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * target ATTRIBUTE_UNUSED, + const xmlChar * data ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * cdataBlockCallback: + * @ctx: the user data (XML parser context) + * @value: The pcdata content + * @len: the block length + * + * called when a pcdata block has been parsed + */ +static void +cdataBlockCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * value ATTRIBUTE_UNUSED, + int len ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * commentCallback: + * @ctxt: An XML parser context + * @value: the comment content + * + * A comment has been parsed. + */ +static void +commentCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * value ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * warningCallback: + * @ctxt: An XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a warning messages, gives file, line, position and + * extra parameters. + */ +static void XMLCDECL +warningCallback(void *ctx ATTRIBUTE_UNUSED, + const char *msg ATTRIBUTE_UNUSED, ...) +{ + callbacks++; + return; +} + +/** + * errorCallback: + * @ctxt: An XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a error messages, gives file, line, position and + * extra parameters. + */ +static void XMLCDECL +errorCallback(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED, + ...) +{ + callbacks++; + return; +} + +/** + * fatalErrorCallback: + * @ctxt: An XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a fatalError messages, gives file, line, position and + * extra parameters. + */ +static void XMLCDECL +fatalErrorCallback(void *ctx ATTRIBUTE_UNUSED, + const char *msg ATTRIBUTE_UNUSED, ...) +{ + return; +} + + +/* + * SAX2 specific callbacks + */ + +/** + * startElementNsCallback: + * @ctxt: An XML parser context + * @name: The element name + * + * called when an opening tag has been processed. + */ +static void +startElementNsCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * localname ATTRIBUTE_UNUSED, + const xmlChar * prefix ATTRIBUTE_UNUSED, + const xmlChar * URI ATTRIBUTE_UNUSED, + int nb_namespaces ATTRIBUTE_UNUSED, + const xmlChar ** namespaces ATTRIBUTE_UNUSED, + int nb_attributes ATTRIBUTE_UNUSED, + int nb_defaulted ATTRIBUTE_UNUSED, + const xmlChar ** attributes ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +/** + * endElementCallback: + * @ctxt: An XML parser context + * @name: The element name + * + * called when the end of an element has been detected. + */ +static void +endElementNsCallback(void *ctx ATTRIBUTE_UNUSED, + const xmlChar * localname ATTRIBUTE_UNUSED, + const xmlChar * prefix ATTRIBUTE_UNUSED, + const xmlChar * URI ATTRIBUTE_UNUSED) +{ + callbacks++; + return; +} + +static xmlSAXHandler callbackSAX2HandlerStruct = { + internalSubsetCallback, + isStandaloneCallback, + hasInternalSubsetCallback, + hasExternalSubsetCallback, + resolveEntityCallback, + getEntityCallback, + entityDeclCallback, + notationDeclCallback, + attributeDeclCallback, + elementDeclCallback, + unparsedEntityDeclCallback, + setDocumentLocatorCallback, + startDocumentCallback, + endDocumentCallback, + NULL, + NULL, + referenceCallback, + charactersCallback, + ignorableWhitespaceCallback, + processingInstructionCallback, + commentCallback, + warningCallback, + errorCallback, + fatalErrorCallback, + getParameterEntityCallback, + cdataBlockCallback, + externalSubsetCallback, + XML_SAX2_MAGIC, + NULL, + startElementNsCallback, + endElementNsCallback, + NULL +}; + +static xmlSAXHandlerPtr callbackSAX2Handler = &callbackSAX2HandlerStruct; + +/************************************************************************ + * * + * The tests front-ends * + * * + ************************************************************************/ + +/** + * readerTest: + * @filename: the file to parse + * @max_size: size of the limit to test + * @options: parsing options + * @fail: should a failure be reported + * + * Parse a memory generated file using SAX + * + * Returns 0 in case of success, an error code otherwise + */ +static int +saxTest(const char *filename, size_t limit, int options, int fail) { + int res = 0; + xmlParserCtxtPtr ctxt; + xmlDocPtr doc; + xmlSAXHandlerPtr old_sax; + + nb_tests++; + + maxlen = limit; + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + fprintf(stderr, "Failed to create parser context\n"); + return(1); + } + old_sax = ctxt->sax; + ctxt->sax = callbackSAX2Handler; + ctxt->userData = NULL; + doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + + if (doc != NULL) { + fprintf(stderr, "SAX parsing generated a document !\n"); + xmlFreeDoc(doc); + res = 0; + } else if (ctxt->wellFormed == 0) { + if (fail) + res = 0; + else { + fprintf(stderr, "Failed to parse '%s' %lu\n", filename, + (unsigned long) limit); + res = 1; + } + } else { + if (fail) { + fprintf(stderr, "Failed to get failure for '%s' %lu\n", + filename, (unsigned long) limit); + res = 1; + } else + res = 0; + } + ctxt->sax = old_sax; + xmlFreeParserCtxt(ctxt); + + return(res); +} +#ifdef LIBXML_READER_ENABLED +/** + * readerTest: + * @filename: the file to parse + * @max_size: size of the limit to test + * @options: parsing options + * @fail: should a failure be reported + * + * Parse a memory generated file using the xmlReader + * + * Returns 0 in case of success, an error code otherwise + */ +static int +readerTest(const char *filename, size_t limit, int options, int fail) { + xmlTextReaderPtr reader; + int res = 0; + int ret; + + nb_tests++; + + maxlen = limit; + reader = xmlReaderForFile(filename , NULL, options); + if (reader == NULL) { + fprintf(stderr, "Failed to open '%s' test\n", filename); + return(1); + } + ret = xmlTextReaderRead(reader); + while (ret == 1) { + ret = xmlTextReaderRead(reader); + } + if (ret != 0) { + if (fail) + res = 0; + else { + if (strncmp(filename, "crazy:", 6) == 0) + fprintf(stderr, "Failed to parse '%s' %u\n", + filename, crazy_indx); + else + fprintf(stderr, "Failed to parse '%s' %lu\n", + filename, (unsigned long) limit); + res = 1; + } + } else { + if (fail) { + if (strncmp(filename, "crazy:", 6) == 0) + fprintf(stderr, "Failed to get failure for '%s' %u\n", + filename, crazy_indx); + else + fprintf(stderr, "Failed to get failure for '%s' %lu\n", + filename, (unsigned long) limit); + res = 1; + } else + res = 0; + } + if (timeout) + res = 1; + xmlFreeTextReader(reader); + + return(res); +} +#endif + +/************************************************************************ + * * + * Tests descriptions * + * * + ************************************************************************/ + +typedef int (*functest) (const char *filename, size_t limit, int options, + int fail); + +typedef struct limitDesc limitDesc; +typedef limitDesc *limitDescPtr; +struct limitDesc { + const char *name; /* the huge generator name */ + size_t limit; /* the limit to test */ + int options; /* extra parser options */ + int fail; /* whether the test should fail */ +}; + +static limitDesc limitDescriptions[] = { + /* max length of a text node in content */ + {"huge:textNode", XML_MAX_TEXT_LENGTH - CHUNK, 0, 0}, + {"huge:textNode", XML_MAX_TEXT_LENGTH + CHUNK, 0, 1}, + {"huge:textNode", XML_MAX_TEXT_LENGTH + CHUNK, XML_PARSE_HUGE, 0}, + /* max length of a text node in content */ + {"huge:attrNode", XML_MAX_TEXT_LENGTH - CHUNK, 0, 0}, + {"huge:attrNode", XML_MAX_TEXT_LENGTH + CHUNK, 0, 1}, + {"huge:attrNode", XML_MAX_TEXT_LENGTH + CHUNK, XML_PARSE_HUGE, 0}, + /* max length of a comment node */ + {"huge:commentNode", XML_MAX_TEXT_LENGTH - CHUNK, 0, 0}, + {"huge:commentNode", XML_MAX_TEXT_LENGTH + CHUNK, 0, 1}, + {"huge:commentNode", XML_MAX_TEXT_LENGTH + CHUNK, XML_PARSE_HUGE, 0}, + /* max length of a PI node */ + {"huge:piNode", XML_MAX_TEXT_LENGTH - CHUNK, 0, 0}, + {"huge:piNode", XML_MAX_TEXT_LENGTH + CHUNK, 0, 1}, + {"huge:piNode", XML_MAX_TEXT_LENGTH + CHUNK, XML_PARSE_HUGE, 0}, +}; + +typedef struct testDesc testDesc; +typedef testDesc *testDescPtr; +struct testDesc { + const char *desc; /* description of the test */ + functest func; /* function implementing the test */ +}; + +static +testDesc testDescriptions[] = { + { "Parsing of huge files with the sax parser", saxTest}, +/* { "Parsing of huge files with the tree parser", treeTest}, */ +#ifdef LIBXML_READER_ENABLED + { "Parsing of huge files with the reader", readerTest}, +#endif + {NULL, NULL} +}; + +typedef struct testException testException; +typedef testException *testExceptionPtr; +struct testException { + unsigned int test; /* the parser test number */ + unsigned int limit; /* the limit test number */ + int fail; /* new fail value or -1*/ + size_t size; /* new limit value or 0 */ +}; + +static +testException testExceptions[] = { + /* the SAX parser doesn't hit a limit of XML_MAX_TEXT_LENGTH text nodes */ + { 0, 1, 0, 0}, +}; + +static int +launchTests(testDescPtr tst, unsigned int test) { + int res = 0, err = 0; + unsigned int i, j; + size_t limit; + int fail; + + if (tst == NULL) return(-1); + + for (i = 0;i < sizeof(limitDescriptions)/sizeof(limitDescriptions[0]);i++) { + limit = limitDescriptions[i].limit; + fail = limitDescriptions[i].fail; + /* + * Handle exceptions if any + */ + for (j = 0;j < sizeof(testExceptions)/sizeof(testExceptions[0]);j++) { + if ((testExceptions[j].test == test) && + (testExceptions[j].limit == i)) { + if (testExceptions[j].fail != -1) + fail = testExceptions[j].fail; + if (testExceptions[j].size != 0) + limit = testExceptions[j].size; + break; + } + } + res = tst->func(limitDescriptions[i].name, limit, + limitDescriptions[i].options, fail); + if (res != 0) { + nb_errors++; + err++; + } + } + return(err); +} + + +static int +runtest(unsigned int i) { + int ret = 0, res; + int old_errors, old_tests, old_leaks; + + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + if ((tests_quiet == 0) && (testDescriptions[i].desc != NULL)) + printf("## %s\n", testDescriptions[i].desc); + res = launchTests(&testDescriptions[i], i); + if (res != 0) + ret++; + if (verbose) { + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + } + return(ret); +} + +static int +launchCrazySAX(unsigned int test, int fail) { + int res = 0, err = 0; + + crazy_indx = test; + + res = saxTest("crazy::test", XML_MAX_LOOKUP_LIMIT - CHUNK, 0, fail); + if (res != 0) { + nb_errors++; + err++; + } + if (tests_quiet == 0) + fprintf(stderr, "%c", crazy[test]); + + return(err); +} + +#ifdef LIBXML_READER_ENABLED +static int +launchCrazy(unsigned int test, int fail) { + int res = 0, err = 0; + + crazy_indx = test; + + res = readerTest("crazy::test", XML_MAX_LOOKUP_LIMIT - CHUNK, 0, fail); + if (res != 0) { + nb_errors++; + err++; + } + if (tests_quiet == 0) + fprintf(stderr, "%c", crazy[test]); + + return(err); +} +#endif + +static int get_crazy_fail(int test) { + /* + * adding 1000000 of character 'a' leads to parser failure mostly + * everywhere except in those special spots. Need to be updated + * each time crazy is updated + */ + int fail = 1; + if ((test == 44) || /* PI in Misc */ + ((test >= 50) && (test <= 55)) || /* Comment in Misc */ + (test == 79) || /* PI in DTD */ + ((test >= 85) && (test <= 90)) || /* Comment in DTD */ + (test == 154) || /* PI in Misc */ + ((test >= 160) && (test <= 165)) || /* Comment in Misc */ + ((test >= 178) && (test <= 181)) || /* attribute value */ + (test == 183) || /* Text */ + (test == 189) || /* PI in Content */ + (test == 191) || /* Text */ + ((test >= 195) && (test <= 200)) || /* Comment in Content */ + ((test >= 203) && (test <= 206)) || /* Text */ + (test == 215) || (test == 216) || /* in CDATA */ + (test == 219) || /* Text */ + (test == 231) || /* PI in Misc */ + ((test >= 237) && (test <= 242))) /* Comment in Misc */ + fail = 0; + return(fail); +} + +static int +runcrazy(void) { + int ret = 0, res = 0; + int old_errors, old_tests, old_leaks; + unsigned int i; + + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + +#ifdef LIBXML_READER_ENABLED + if (tests_quiet == 0) { + printf("## Crazy tests on reader\n"); + } + for (i = 0;i < strlen(crazy);i++) { + res += launchCrazy(i, get_crazy_fail(i)); + if (res != 0) + ret++; + } +#endif + + if (tests_quiet == 0) { + printf("\n## Crazy tests on SAX\n"); + } + for (i = 0;i < strlen(crazy);i++) { + res += launchCrazySAX(i, get_crazy_fail(i)); + if (res != 0) + ret++; + } + if (tests_quiet == 0) + fprintf(stderr, "\n"); + if (verbose) { + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + } + return(ret); +} + + +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + int i, a, ret = 0; + int subset = 0; + + fillFilling(); + initializeLibxml2(); + + for (a = 1; a < argc;a++) { + if (!strcmp(argv[a], "-v")) + verbose = 1; + else if (!strcmp(argv[a], "-quiet")) + tests_quiet = 1; + else if (!strcmp(argv[a], "-crazy")) + subset = 1; + } + if (subset == 0) { + for (i = 0; testDescriptions[i].func != NULL; i++) { + ret += runtest(i); + } + } + ret += runcrazy(); + if ((nb_errors == 0) && (nb_leaks == 0)) { + ret = 0; + printf("Total %d tests, no errors\n", + nb_tests); + } else { + ret = 1; + printf("Total %d tests, %d errors, %d leaks\n", + nb_tests, nb_errors, nb_leaks); + } + xmlCleanupParser(); + xmlMemoryDump(); + + return(ret); +} diff --git a/src/testrecurse.c b/src/testrecurse.c new file mode 100644 index 000000000000..0cbe25a62f06 --- /dev/null +++ b/src/testrecurse.c @@ -0,0 +1,965 @@ +/* + * testrecurse.c: C program to run libxml2 regression tests checking entities + * recursions + * + * To compile on Unixes: + * cc -o testrecurse `xml2-config --cflags` testrecurse.c `xml2-config --libs` -lpthread + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#include "libxml.h" +#include + +#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#endif +#include +#include +#include +#include + +#include +#include +#include +#ifdef LIBXML_READER_ENABLED +#include +#endif + +/* + * O_BINARY is just for Windows compatibility - if it isn't defined + * on this system, avoid any compilation error + */ +#ifdef O_BINARY +#define RD_FLAGS O_RDONLY | O_BINARY +#else +#define RD_FLAGS O_RDONLY +#endif + +typedef int (*functest) (const char *filename, const char *result, + const char *error, int options); + +typedef struct testDesc testDesc; +typedef testDesc *testDescPtr; +struct testDesc { + const char *desc; /* description of the test */ + functest func; /* function implementing the test */ + const char *in; /* glob to path for input files */ + const char *out; /* output directory */ + const char *suffix;/* suffix for output files */ + const char *err; /* suffix for error output files */ + int options; /* parser options for the test */ +}; + +static int checkTestFile(const char *filename); + + +#if defined(_WIN32) && !defined(__CYGWIN__) + +#include +#include + +typedef struct +{ + size_t gl_pathc; /* Count of paths matched so far */ + char **gl_pathv; /* List of matched pathnames. */ + size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */ +} glob_t; + +#define GLOB_DOOFFS 0 +static int glob(const char *pattern, ATTRIBUTE_UNUSED int flags, + ATTRIBUTE_UNUSED int errfunc(const char *epath, int eerrno), + glob_t *pglob) { + glob_t *ret; + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + unsigned int nb_paths = 0; + char directory[500]; + int len; + + if ((pattern == NULL) || (pglob == NULL)) return(-1); + + strncpy(directory, pattern, 499); + for (len = strlen(directory);len >= 0;len--) { + if (directory[len] == '/') { + len++; + directory[len] = 0; + break; + } + } + if (len <= 0) + len = 0; + + + ret = pglob; + memset(ret, 0, sizeof(glob_t)); + + hFind = FindFirstFileA(pattern, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) + return(0); + nb_paths = 20; + ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *)); + if (ret->gl_pathv == NULL) { + FindClose(hFind); + return(-1); + } + strncpy(directory + len, FindFileData.cFileName, 499 - len); + ret->gl_pathv[ret->gl_pathc] = strdup(directory); + if (ret->gl_pathv[ret->gl_pathc] == NULL) + goto done; + ret->gl_pathc++; + while(FindNextFileA(hFind, &FindFileData)) { + if (FindFileData.cFileName[0] == '.') + continue; + if (ret->gl_pathc + 2 > nb_paths) { + char **tmp = realloc(ret->gl_pathv, nb_paths * 2 * sizeof(char *)); + if (tmp == NULL) + break; + ret->gl_pathv = tmp; + nb_paths *= 2; + } + strncpy(directory + len, FindFileData.cFileName, 499 - len); + ret->gl_pathv[ret->gl_pathc] = strdup(directory); + if (ret->gl_pathv[ret->gl_pathc] == NULL) + break; + ret->gl_pathc++; + } + ret->gl_pathv[ret->gl_pathc] = NULL; + +done: + FindClose(hFind); + return(0); +} + + + +static void globfree(glob_t *pglob) { + unsigned int i; + if (pglob == NULL) + return; + + for (i = 0;i < pglob->gl_pathc;i++) { + if (pglob->gl_pathv[i] != NULL) + free(pglob->gl_pathv[i]); + } +} + +#else +#include +#endif + +/************************************************************************ + * * + * Huge document generator * + * * + ************************************************************************/ + +#include + + +static const char *start = " \ + \ + \ +]> \ +"; + +static const char *segment = " &e; &f; &d;\n"; +static const char *finish = ""; + +static int curseg = 0; +static const char *current; +static int rlen; + +/** + * hugeMatch: + * @URI: an URI to test + * + * Check for an huge: query + * + * Returns 1 if yes and 0 if another Input module should be used + */ +static int +hugeMatch(const char * URI) { + if ((URI != NULL) && (!strncmp(URI, "huge:", 4))) + return(1); + return(0); +} + +/** + * hugeOpen: + * @URI: an URI to test + * + * Return a pointer to the huge: query handler, in this example simply + * the current pointer... + * + * Returns an Input context or NULL in case or error + */ +static void * +hugeOpen(const char * URI) { + if ((URI == NULL) || (strncmp(URI, "huge:", 4))) + return(NULL); + rlen = strlen(start); + current = start; + return((void *) current); +} + +/** + * hugeClose: + * @context: the read context + * + * Close the huge: query handler + * + * Returns 0 or -1 in case of error + */ +static int +hugeClose(void * context) { + if (context == NULL) return(-1); + return(0); +} + +#define MAX_NODES 1000000 + +/** + * hugeRead: + * @context: the read context + * @buffer: where to store data + * @len: number of bytes to read + * + * Implement an huge: query read. + * + * Returns the number of bytes read or -1 in case of error + */ +static int +hugeRead(void *context, char *buffer, int len) +{ + if ((context == NULL) || (buffer == NULL) || (len < 0)) + return (-1); + + if (len >= rlen) { + if (curseg >= MAX_NODES + 1) { + rlen = 0; + return(0); + } + len = rlen; + rlen = 0; + memcpy(buffer, current, len); + curseg ++; + if (curseg == MAX_NODES) { + fprintf(stderr, "\n"); + rlen = strlen(finish); + current = finish; + } else { + if (curseg % (MAX_NODES / 10) == 0) + fprintf(stderr, "."); + rlen = strlen(segment); + current = segment; + } + } else { + memcpy(buffer, current, len); + rlen -= len; + current += len; + } + return (len); +} + +/************************************************************************ + * * + * Libxml2 specific routines * + * * + ************************************************************************/ + +static int nb_tests = 0; +static int nb_errors = 0; +static int nb_leaks = 0; +static int extraMemoryFromResolver = 0; + +static int +fatalError(void) { + fprintf(stderr, "Exitting tests on fatal error\n"); + exit(1); +} + +/* + * We need to trap calls to the resolver to not account memory for the catalog + * which is shared to the current running test. We also don't want to have + * network downloads modifying tests. + */ +static xmlParserInputPtr +testExternalEntityLoader(const char *URL, const char *ID, + xmlParserCtxtPtr ctxt) { + xmlParserInputPtr ret; + + if (checkTestFile(URL)) { + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + } else { + int memused = xmlMemUsed(); + ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt); + extraMemoryFromResolver += xmlMemUsed() - memused; + } + + return(ret); +} + +/* + * Trapping the error messages at the generic level to grab the equivalent of + * stderr messages on CLI tools. + */ +static char testErrors[32769]; +static int testErrorsSize = 0; + +static void XMLCDECL +channel(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { + va_list args; + int res; + + if (testErrorsSize >= 32768) + return; + va_start(args, msg); + res = vsnprintf(&testErrors[testErrorsSize], + 32768 - testErrorsSize, + msg, args); + va_end(args); + if (testErrorsSize + res >= 32768) { + /* buffer is full */ + testErrorsSize = 32768; + testErrors[testErrorsSize] = 0; + } else { + testErrorsSize += res; + } + testErrors[testErrorsSize] = 0; +} + +/** + * xmlParserPrintFileContext: + * @input: an xmlParserInputPtr input + * + * Displays current context within the input content for error tracking + */ + +static void +xmlParserPrintFileContextInternal(xmlParserInputPtr input , + xmlGenericErrorFunc chanl, void *data ) { + const xmlChar *cur, *base; + unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */ + xmlChar content[81]; /* space for 80 chars + line terminator */ + xmlChar *ctnt; + + if (input == NULL) return; + cur = input->cur; + base = input->base; + /* skip backwards over any end-of-lines */ + while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { + cur--; + } + n = 0; + /* search backwards for beginning-of-line (to max buff size) */ + while ((n++ < (sizeof(content)-1)) && (cur > base) && + (*(cur) != '\n') && (*(cur) != '\r')) + cur--; + if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; + /* calculate the error position in terms of the current position */ + col = input->cur - cur; + /* search forward for end-of-line (to max buff size) */ + n = 0; + ctnt = content; + /* copy selected text to our buffer */ + while ((*cur != 0) && (*(cur) != '\n') && + (*(cur) != '\r') && (n < sizeof(content)-1)) { + *ctnt++ = *cur++; + n++; + } + *ctnt = 0; + /* print out the selected text */ + chanl(data ,"%s\n", content); + /* create blank line with problem pointer */ + n = 0; + ctnt = content; + /* (leave buffer space for pointer + line terminator) */ + while ((nfile; + line = err->line; + code = err->code; + domain = err->domain; + level = err->level; + node = err->node; + if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || + (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || + (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { + ctxt = err->ctxt; + } + str = err->message; + + if (code == XML_ERR_OK) + return; + + if ((node != NULL) && (node->type == XML_ELEMENT_NODE)) + name = node->name; + + /* + * Maintain the compatibility with the legacy error handling + */ + if (ctxt != NULL) { + input = ctxt->input; + if ((input != NULL) && (input->filename == NULL) && + (ctxt->inputNr > 1)) { + cur = input; + input = ctxt->inputTab[ctxt->inputNr - 2]; + } + if (input != NULL) { + if (input->filename) + channel(data, "%s:%d: ", input->filename, input->line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: ", input->line); + } + } else { + if (file != NULL) + channel(data, "%s:%d: ", file, line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: ", line); + } + if (name != NULL) { + channel(data, "element %s: ", name); + } + if (code == XML_ERR_OK) + return; + switch (domain) { + case XML_FROM_PARSER: + channel(data, "parser "); + break; + case XML_FROM_NAMESPACE: + channel(data, "namespace "); + break; + case XML_FROM_DTD: + case XML_FROM_VALID: + channel(data, "validity "); + break; + case XML_FROM_HTML: + channel(data, "HTML parser "); + break; + case XML_FROM_MEMORY: + channel(data, "memory "); + break; + case XML_FROM_OUTPUT: + channel(data, "output "); + break; + case XML_FROM_IO: + channel(data, "I/O "); + break; + case XML_FROM_XINCLUDE: + channel(data, "XInclude "); + break; + case XML_FROM_XPATH: + channel(data, "XPath "); + break; + case XML_FROM_XPOINTER: + channel(data, "parser "); + break; + case XML_FROM_REGEXP: + channel(data, "regexp "); + break; + case XML_FROM_MODULE: + channel(data, "module "); + break; + case XML_FROM_SCHEMASV: + channel(data, "Schemas validity "); + break; + case XML_FROM_SCHEMASP: + channel(data, "Schemas parser "); + break; + case XML_FROM_RELAXNGP: + channel(data, "Relax-NG parser "); + break; + case XML_FROM_RELAXNGV: + channel(data, "Relax-NG validity "); + break; + case XML_FROM_CATALOG: + channel(data, "Catalog "); + break; + case XML_FROM_C14N: + channel(data, "C14N "); + break; + case XML_FROM_XSLT: + channel(data, "XSLT "); + break; + default: + break; + } + if (code == XML_ERR_OK) + return; + switch (level) { + case XML_ERR_NONE: + channel(data, ": "); + break; + case XML_ERR_WARNING: + channel(data, "warning : "); + break; + case XML_ERR_ERROR: + channel(data, "error : "); + break; + case XML_ERR_FATAL: + channel(data, "error : "); + break; + } + if (code == XML_ERR_OK) + return; + if (str != NULL) { + int len; + len = xmlStrlen((const xmlChar *)str); + if ((len > 0) && (str[len - 1] != '\n')) + channel(data, "%s\n", str); + else + channel(data, "%s", str); + } else { + channel(data, "%s\n", "out of memory error"); + } + if (code == XML_ERR_OK) + return; + + if (ctxt != NULL) { + xmlParserPrintFileContextInternal(input, channel, data); + if (cur != NULL) { + if (cur->filename) + channel(data, "%s:%d: \n", cur->filename, cur->line); + else if ((line != 0) && (domain == XML_FROM_PARSER)) + channel(data, "Entity: line %d: \n", cur->line); + xmlParserPrintFileContextInternal(cur, channel, data); + } + } + if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) && + (err->int1 < 100) && + (err->int1 < xmlStrlen((const xmlChar *)err->str1))) { + xmlChar buf[150]; + int i; + + channel(data, "%s\n", err->str1); + for (i=0;i < err->int1;i++) + buf[i] = ' '; + buf[i++] = '^'; + buf[i] = 0; + channel(data, "%s\n", buf); + } +} + +static void +initializeLibxml2(void) { + xmlGetWarningsDefaultValue = 0; + xmlPedanticParserDefault(0); + + xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup); + xmlInitParser(); + xmlSetExternalEntityLoader(testExternalEntityLoader); + xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler); + /* + * register the new I/O handlers + */ + if (xmlRegisterInputCallbacks(hugeMatch, hugeOpen, + hugeRead, hugeClose) < 0) { + fprintf(stderr, "failed to register Huge handler\n"); + exit(1); + } +} + +/************************************************************************ + * * + * File name and path utilities * + * * + ************************************************************************/ + +static const char *baseFilename(const char *filename) { + const char *cur; + if (filename == NULL) + return(NULL); + cur = &filename[strlen(filename)]; + while ((cur > filename) && (*cur != '/')) + cur--; + if (*cur == '/') + return(cur + 1); + return(cur); +} + +static char *resultFilename(const char *filename, const char *out, + const char *suffix) { + const char *base; + char res[500]; + char suffixbuff[500]; + +/************* + if ((filename[0] == 't') && (filename[1] == 'e') && + (filename[2] == 's') && (filename[3] == 't') && + (filename[4] == '/')) + filename = &filename[5]; + *************/ + + base = baseFilename(filename); + if (suffix == NULL) + suffix = ".tmp"; + if (out == NULL) + out = ""; + + strncpy(suffixbuff,suffix,499); +#ifdef VMS + if(strstr(base,".") && suffixbuff[0]=='.') + suffixbuff[0]='_'; +#endif + + if (snprintf(res, 499, "%s%s%s", out, base, suffixbuff) >= 499) + res[499] = 0; + return(strdup(res)); +} + +static int checkTestFile(const char *filename) { + struct stat buf; + + if (stat(filename, &buf) == -1) + return(0); + +#if defined(_WIN32) && !defined(__CYGWIN__) + if (!(buf.st_mode & _S_IFREG)) + return(0); +#else + if (!S_ISREG(buf.st_mode)) + return(0); +#endif + + return(1); +} + + + +/************************************************************************ + * * + * Test to detect or not recursive entities * + * * + ************************************************************************/ +/** + * recursiveDetectTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a file loading DTD and replacing entities check it fails for + * lol cases + * + * Returns 0 in case of success, an error code otherwise + */ +static int +recursiveDetectTest(const char *filename, + const char *result ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + xmlDocPtr doc; + xmlParserCtxtPtr ctxt; + int res = 0; + + nb_tests++; + + ctxt = xmlNewParserCtxt(); + /* + * base of the test, parse with the old API + */ + doc = xmlCtxtReadFile(ctxt, filename, NULL, + XML_PARSE_NOENT | XML_PARSE_DTDLOAD); + if ((doc != NULL) || (ctxt->lastError.code != XML_ERR_ENTITY_LOOP)) { + fprintf(stderr, "Failed to detect recursion in %s\n", filename); + xmlFreeParserCtxt(ctxt); + xmlFreeDoc(doc); + return(1); + } + xmlFreeParserCtxt(ctxt); + + return(res); +} + +/** + * notRecursiveDetectTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a file loading DTD and replacing entities check it works for + * good cases + * + * Returns 0 in case of success, an error code otherwise + */ +static int +notRecursiveDetectTest(const char *filename, + const char *result ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + xmlDocPtr doc; + xmlParserCtxtPtr ctxt; + int res = 0; + + nb_tests++; + + ctxt = xmlNewParserCtxt(); + /* + * base of the test, parse with the old API + */ + doc = xmlCtxtReadFile(ctxt, filename, NULL, + XML_PARSE_NOENT | XML_PARSE_DTDLOAD); + if (doc == NULL) { + fprintf(stderr, "Failed to parse correct file %s\n", filename); + xmlFreeParserCtxt(ctxt); + return(1); + } + xmlFreeDoc(doc); + xmlFreeParserCtxt(ctxt); + + return(res); +} + +#ifdef LIBXML_READER_ENABLED +/** + * notRecursiveHugeTest: + * @filename: the file to parse + * @result: the file with expected result + * @err: the file with error messages: unused + * + * Parse a memory generated file + * good cases + * + * Returns 0 in case of success, an error code otherwise + */ +static int +notRecursiveHugeTest(const char *filename ATTRIBUTE_UNUSED, + const char *result ATTRIBUTE_UNUSED, + const char *err ATTRIBUTE_UNUSED, + int options ATTRIBUTE_UNUSED) { + xmlTextReaderPtr reader; + int res = 0; + int ret; + + nb_tests++; + + reader = xmlReaderForFile("huge:test" , NULL, + XML_PARSE_NOENT | XML_PARSE_DTDLOAD); + if (reader == NULL) { + fprintf(stderr, "Failed to open huge:test\n"); + return(1); + } + ret = xmlTextReaderRead(reader); + while (ret == 1) { + ret = xmlTextReaderRead(reader); + } + if (ret != 0) { + fprintf(stderr, "Failed to parser huge:test with entities\n"); + res = 1; + } + xmlFreeTextReader(reader); + + return(res); +} +#endif + +/************************************************************************ + * * + * Tests Descriptions * + * * + ************************************************************************/ + +static +testDesc testDescriptions[] = { + { "Parsing recursive test cases" , + recursiveDetectTest, "./test/recurse/lol*.xml", NULL, NULL, NULL, + 0 }, + { "Parsing non-recursive test cases" , + notRecursiveDetectTest, "./test/recurse/good*.xml", NULL, NULL, NULL, + 0 }, +#ifdef LIBXML_READER_ENABLED + { "Parsing non-recursive huge case" , + notRecursiveHugeTest, NULL, NULL, NULL, NULL, + 0 }, +#endif + {NULL, NULL, NULL, NULL, NULL, NULL, 0} +}; + +/************************************************************************ + * * + * The main code driving the tests * + * * + ************************************************************************/ + +static int +launchTests(testDescPtr tst) { + int res = 0, err = 0; + size_t i; + char *result; + char *error; + int mem; + + if (tst == NULL) return(-1); + if (tst->in != NULL) { + glob_t globbuf; + + globbuf.gl_offs = 0; + glob(tst->in, GLOB_DOOFFS, NULL, &globbuf); + for (i = 0;i < globbuf.gl_pathc;i++) { + if (!checkTestFile(globbuf.gl_pathv[i])) + continue; + if (tst->suffix != NULL) { + result = resultFilename(globbuf.gl_pathv[i], tst->out, + tst->suffix); + if (result == NULL) { + fprintf(stderr, "Out of memory !\n"); + fatalError(); + } + } else { + result = NULL; + } + if (tst->err != NULL) { + error = resultFilename(globbuf.gl_pathv[i], tst->out, + tst->err); + if (error == NULL) { + fprintf(stderr, "Out of memory !\n"); + fatalError(); + } + } else { + error = NULL; + } + if ((result) &&(!checkTestFile(result))) { + fprintf(stderr, "Missing result file %s\n", result); + } else if ((error) &&(!checkTestFile(error))) { + fprintf(stderr, "Missing error file %s\n", error); + } else { + mem = xmlMemUsed(); + extraMemoryFromResolver = 0; + testErrorsSize = 0; + testErrors[0] = 0; + res = tst->func(globbuf.gl_pathv[i], result, error, + tst->options | XML_PARSE_COMPACT); + xmlResetLastError(); + if (res != 0) { + fprintf(stderr, "File %s generated an error\n", + globbuf.gl_pathv[i]); + nb_errors++; + err++; + } + else if (xmlMemUsed() != mem) { + if ((xmlMemUsed() != mem) && + (extraMemoryFromResolver == 0)) { + fprintf(stderr, "File %s leaked %d bytes\n", + globbuf.gl_pathv[i], xmlMemUsed() - mem); + nb_leaks++; + err++; + } + } + testErrorsSize = 0; + } + if (result) + free(result); + if (error) + free(error); + } + globfree(&globbuf); + } else { + testErrorsSize = 0; + testErrors[0] = 0; + extraMemoryFromResolver = 0; + res = tst->func(NULL, NULL, NULL, tst->options); + if (res != 0) { + nb_errors++; + err++; + } + } + return(err); +} + +static int verbose = 0; +static int tests_quiet = 0; + +static int +runtest(int i) { + int ret = 0, res; + int old_errors, old_tests, old_leaks; + + old_errors = nb_errors; + old_tests = nb_tests; + old_leaks = nb_leaks; + if ((tests_quiet == 0) && (testDescriptions[i].desc != NULL)) + printf("## %s\n", testDescriptions[i].desc); + res = launchTests(&testDescriptions[i]); + if (res != 0) + ret++; + if (verbose) { + if ((nb_errors == old_errors) && (nb_leaks == old_leaks)) + printf("Ran %d tests, no errors\n", nb_tests - old_tests); + else + printf("Ran %d tests, %d errors, %d leaks\n", + nb_tests - old_tests, + nb_errors - old_errors, + nb_leaks - old_leaks); + } + return(ret); +} + +int +main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { + int i, a, ret = 0; + int subset = 0; + + initializeLibxml2(); + + for (a = 1; a < argc;a++) { + if (!strcmp(argv[a], "-v")) + verbose = 1; + else if (!strcmp(argv[a], "-quiet")) + tests_quiet = 1; + else { + for (i = 0; testDescriptions[i].func != NULL; i++) { + if (strstr(testDescriptions[i].desc, argv[a])) { + ret += runtest(i); + subset++; + } + } + } + } + if (subset == 0) { + for (i = 0; testDescriptions[i].func != NULL; i++) { + ret += runtest(i); + } + } + if ((nb_errors == 0) && (nb_leaks == 0)) { + ret = 0; + printf("Total %d tests, no errors\n", + nb_tests); + } else { + ret = 1; + printf("Total %d tests, %d errors, %d leaks\n", + nb_tests, nb_errors, nb_leaks); + } + xmlCleanupParser(); + xmlMemoryDump(); + + return(ret); +} diff --git a/src/threads.c b/src/threads.c new file mode 100644 index 000000000000..503d2bfbec0c --- /dev/null +++ b/src/threads.c @@ -0,0 +1,1049 @@ +/** + * threads.c: set of generic threading related routines + * + * See Copyright for the status of this software. + * + * Gary Pennington + * daniel@veillard.com + */ + +#define IN_LIBXML +#include "libxml.h" + +#include + +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_PTHREAD_H +#include +#elif defined HAVE_WIN32_THREADS +#define WIN32_LEAN_AND_MEAN +#include +#ifndef HAVE_COMPILER_TLS +#include +#endif +#endif + +#ifdef HAVE_BEOS_THREADS +#include +#include +#endif + +#if defined(SOLARIS) +#include +#endif + +/* #define DEBUG_THREADS */ + +#ifdef HAVE_PTHREAD_H + +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 303) && \ + defined(__GLIBC__) && defined(__linux__) + +static int libxml_is_threaded = -1; + +#define XML_PTHREAD_WEAK + +#pragma weak pthread_once +#pragma weak pthread_getspecific +#pragma weak pthread_setspecific +#pragma weak pthread_key_create +#pragma weak pthread_key_delete +#pragma weak pthread_mutex_init +#pragma weak pthread_mutex_destroy +#pragma weak pthread_mutex_lock +#pragma weak pthread_mutex_unlock +#pragma weak pthread_cond_init +#pragma weak pthread_cond_destroy +#pragma weak pthread_cond_wait +#pragma weak pthread_equal +#pragma weak pthread_self +#pragma weak pthread_key_create +#pragma weak pthread_key_delete +#pragma weak pthread_cond_signal + +#else /* __GNUC__, __GLIBC__, __linux__ */ + +static int libxml_is_threaded = 1; + +#endif /* __GNUC__, __GLIBC__, __linux__ */ + +#endif /* HAVE_PTHREAD_H */ + +/* + * TODO: this module still uses malloc/free and not xmlMalloc/xmlFree + * to avoid some craziness since xmlMalloc/xmlFree may actually + * be hosted on allocated blocks needing them for the allocation ... + */ + +/* + * xmlMutex are a simple mutual exception locks + */ +struct _xmlMutex { +#ifdef HAVE_PTHREAD_H + pthread_mutex_t lock; +#elif defined HAVE_WIN32_THREADS + HANDLE mutex; +#elif defined HAVE_BEOS_THREADS + sem_id sem; + thread_id tid; +#else + int empty; +#endif +}; + +/* + * xmlRMutex are reentrant mutual exception locks + */ +struct _xmlRMutex { +#ifdef HAVE_PTHREAD_H + pthread_mutex_t lock; + unsigned int held; + unsigned int waiters; + pthread_t tid; + pthread_cond_t cv; +#elif defined HAVE_WIN32_THREADS + CRITICAL_SECTION cs; + unsigned int count; +#elif defined HAVE_BEOS_THREADS + xmlMutexPtr lock; + thread_id tid; + int32 count; +#else + int empty; +#endif +}; + +/* + * This module still has some internal static data. + * - xmlLibraryLock a global lock + * - globalkey used for per-thread data + */ + +#ifdef HAVE_PTHREAD_H +static pthread_key_t globalkey; +static pthread_t mainthread; +static pthread_once_t once_control = PTHREAD_ONCE_INIT; +static pthread_once_t once_control_init = PTHREAD_ONCE_INIT; +static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER; +#elif defined HAVE_WIN32_THREADS +#if defined(HAVE_COMPILER_TLS) +static __declspec(thread) xmlGlobalState tlstate; +static __declspec(thread) int tlstate_inited = 0; +#else /* HAVE_COMPILER_TLS */ +static DWORD globalkey = TLS_OUT_OF_INDEXES; +#endif /* HAVE_COMPILER_TLS */ +static DWORD mainthread; +static struct { + DWORD done; + LONG control; +} run_once = { 0, 0}; +static volatile LPCRITICAL_SECTION global_init_lock = NULL; + +/* endif HAVE_WIN32_THREADS */ +#elif defined HAVE_BEOS_THREADS +int32 globalkey = 0; +thread_id mainthread = 0; +int32 run_once_init = 0; +static int32 global_init_lock = -1; +static vint32 global_init_count = 0; +#endif + +static xmlRMutexPtr xmlLibraryLock = NULL; + +#ifdef LIBXML_THREAD_ENABLED +static void xmlOnceInit(void); +#endif + +/** + * xmlNewMutex: + * + * xmlNewMutex() is used to allocate a libxml2 token struct for use in + * synchronizing access to data. + * + * Returns a new simple mutex pointer or NULL in case of error + */ +xmlMutexPtr +xmlNewMutex(void) +{ + xmlMutexPtr tok; + + if ((tok = malloc(sizeof(xmlMutex))) == NULL) + return (NULL); +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) + pthread_mutex_init(&tok->lock, NULL); +#elif defined HAVE_WIN32_THREADS + tok->mutex = CreateMutex(NULL, FALSE, NULL); +#elif defined HAVE_BEOS_THREADS + if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) { + free(tok); + return NULL; + } + tok->tid = -1; +#endif + return (tok); +} + +/** + * xmlFreeMutex: + * @tok: the simple mutex + * + * xmlFreeMutex() is used to reclaim resources associated with a libxml2 token + * struct. + */ +void +xmlFreeMutex(xmlMutexPtr tok) +{ + if (tok == NULL) + return; + +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) + pthread_mutex_destroy(&tok->lock); +#elif defined HAVE_WIN32_THREADS + CloseHandle(tok->mutex); +#elif defined HAVE_BEOS_THREADS + delete_sem(tok->sem); +#endif + free(tok); +} + +/** + * xmlMutexLock: + * @tok: the simple mutex + * + * xmlMutexLock() is used to lock a libxml2 token. + */ +void +xmlMutexLock(xmlMutexPtr tok) +{ + if (tok == NULL) + return; +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) + pthread_mutex_lock(&tok->lock); +#elif defined HAVE_WIN32_THREADS + WaitForSingleObject(tok->mutex, INFINITE); +#elif defined HAVE_BEOS_THREADS + if (acquire_sem(tok->sem) != B_NO_ERROR) { +#ifdef DEBUG_THREADS + xmlGenericError(xmlGenericErrorContext, + "xmlMutexLock():BeOS:Couldn't acquire semaphore\n"); +#endif + } + tok->tid = find_thread(NULL); +#endif + +} + +/** + * xmlMutexUnlock: + * @tok: the simple mutex + * + * xmlMutexUnlock() is used to unlock a libxml2 token. + */ +void +xmlMutexUnlock(xmlMutexPtr tok) +{ + if (tok == NULL) + return; +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) + pthread_mutex_unlock(&tok->lock); +#elif defined HAVE_WIN32_THREADS + ReleaseMutex(tok->mutex); +#elif defined HAVE_BEOS_THREADS + if (tok->tid == find_thread(NULL)) { + tok->tid = -1; + release_sem(tok->sem); + } +#endif +} + +/** + * xmlNewRMutex: + * + * xmlRNewMutex() is used to allocate a reentrant mutex for use in + * synchronizing access to data. token_r is a re-entrant lock and thus useful + * for synchronizing access to data structures that may be manipulated in a + * recursive fashion. + * + * Returns the new reentrant mutex pointer or NULL in case of error + */ +xmlRMutexPtr +xmlNewRMutex(void) +{ + xmlRMutexPtr tok; + + if ((tok = malloc(sizeof(xmlRMutex))) == NULL) + return (NULL); +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) { + pthread_mutex_init(&tok->lock, NULL); + tok->held = 0; + tok->waiters = 0; + pthread_cond_init(&tok->cv, NULL); + } +#elif defined HAVE_WIN32_THREADS + InitializeCriticalSection(&tok->cs); + tok->count = 0; +#elif defined HAVE_BEOS_THREADS + if ((tok->lock = xmlNewMutex()) == NULL) { + free(tok); + return NULL; + } + tok->count = 0; +#endif + return (tok); +} + +/** + * xmlFreeRMutex: + * @tok: the reentrant mutex + * + * xmlRFreeMutex() is used to reclaim resources associated with a + * reentrant mutex. + */ +void +xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED) +{ + if (tok == NULL) + return; +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) { + pthread_mutex_destroy(&tok->lock); + pthread_cond_destroy(&tok->cv); + } +#elif defined HAVE_WIN32_THREADS + DeleteCriticalSection(&tok->cs); +#elif defined HAVE_BEOS_THREADS + xmlFreeMutex(tok->lock); +#endif + free(tok); +} + +/** + * xmlRMutexLock: + * @tok: the reentrant mutex + * + * xmlRMutexLock() is used to lock a libxml2 token_r. + */ +void +xmlRMutexLock(xmlRMutexPtr tok) +{ + if (tok == NULL) + return; +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded == 0) + return; + + pthread_mutex_lock(&tok->lock); + if (tok->held) { + if (pthread_equal(tok->tid, pthread_self())) { + tok->held++; + pthread_mutex_unlock(&tok->lock); + return; + } else { + tok->waiters++; + while (tok->held) + pthread_cond_wait(&tok->cv, &tok->lock); + tok->waiters--; + } + } + tok->tid = pthread_self(); + tok->held = 1; + pthread_mutex_unlock(&tok->lock); +#elif defined HAVE_WIN32_THREADS + EnterCriticalSection(&tok->cs); + tok->count++; +#elif defined HAVE_BEOS_THREADS + if (tok->lock->tid == find_thread(NULL)) { + tok->count++; + return; + } else { + xmlMutexLock(tok->lock); + tok->count = 1; + } +#endif +} + +/** + * xmlRMutexUnlock: + * @tok: the reentrant mutex + * + * xmlRMutexUnlock() is used to unlock a libxml2 token_r. + */ +void +xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED) +{ + if (tok == NULL) + return; +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded == 0) + return; + + pthread_mutex_lock(&tok->lock); + tok->held--; + if (tok->held == 0) { + if (tok->waiters) + pthread_cond_signal(&tok->cv); + memset(&tok->tid, 0, sizeof(tok->tid)); + } + pthread_mutex_unlock(&tok->lock); +#elif defined HAVE_WIN32_THREADS + if (tok->count > 0) { + tok->count--; + LeaveCriticalSection(&tok->cs); + } +#elif defined HAVE_BEOS_THREADS + if (tok->lock->tid == find_thread(NULL)) { + tok->count--; + if (tok->count == 0) { + xmlMutexUnlock(tok->lock); + } + return; + } +#endif +} + +/** + * xmlGlobalInitMutexLock + * + * Makes sure that the global initialization mutex is initialized and + * locks it. + */ +void +__xmlGlobalInitMutexLock(void) +{ + /* Make sure the global init lock is initialized and then lock it. */ +#ifdef HAVE_PTHREAD_H + /* The mutex is statically initialized, so we just lock it. */ +#ifdef XML_PTHREAD_WEAK + if (pthread_mutex_lock == NULL) + return; +#endif /* XML_PTHREAD_WEAK */ + pthread_mutex_lock(&global_init_lock); +#elif defined HAVE_WIN32_THREADS + LPCRITICAL_SECTION cs; + + /* Create a new critical section */ + if (global_init_lock == NULL) { + cs = malloc(sizeof(CRITICAL_SECTION)); + if (cs == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlGlobalInitMutexLock: out of memory\n"); + return; + } + InitializeCriticalSection(cs); + + /* Swap it into the global_init_lock */ +#ifdef InterlockedCompareExchangePointer + InterlockedCompareExchangePointer((void **) &global_init_lock, + cs, NULL); +#else /* Use older void* version */ + InterlockedCompareExchange((void **) &global_init_lock, + (void *) cs, NULL); +#endif /* InterlockedCompareExchangePointer */ + + /* If another thread successfully recorded its critical + * section in the global_init_lock then discard the one + * allocated by this thread. */ + if (global_init_lock != cs) { + DeleteCriticalSection(cs); + free(cs); + } + } + + /* Lock the chosen critical section */ + EnterCriticalSection(global_init_lock); +#elif defined HAVE_BEOS_THREADS + int32 sem; + + /* Allocate a new semaphore */ + sem = create_sem(1, "xmlGlobalinitMutex"); + + while (global_init_lock == -1) { + if (atomic_add(&global_init_count, 1) == 0) { + global_init_lock = sem; + } else { + snooze(1); + atomic_add(&global_init_count, -1); + } + } + + /* If another thread successfully recorded its critical + * section in the global_init_lock then discard the one + * allocated by this thread. */ + if (global_init_lock != sem) + delete_sem(sem); + + /* Acquire the chosen semaphore */ + if (acquire_sem(global_init_lock) != B_NO_ERROR) { +#ifdef DEBUG_THREADS + xmlGenericError(xmlGenericErrorContext, + "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n"); +#endif + } +#endif +} + +void +__xmlGlobalInitMutexUnlock(void) +{ +#ifdef HAVE_PTHREAD_H +#ifdef XML_PTHREAD_WEAK + if (pthread_mutex_unlock == NULL) + return; +#endif /* XML_PTHREAD_WEAK */ + pthread_mutex_unlock(&global_init_lock); +#elif defined HAVE_WIN32_THREADS + if (global_init_lock != NULL) { + LeaveCriticalSection(global_init_lock); + } +#elif defined HAVE_BEOS_THREADS + release_sem(global_init_lock); +#endif +} + +/** + * xmlGlobalInitMutexDestroy + * + * Makes sure that the global initialization mutex is destroyed before + * application termination. + */ +void +__xmlGlobalInitMutexDestroy(void) +{ +#ifdef HAVE_PTHREAD_H +#elif defined HAVE_WIN32_THREADS + if (global_init_lock != NULL) { + DeleteCriticalSection(global_init_lock); + free(global_init_lock); + global_init_lock = NULL; + } +#endif +} + +/************************************************************************ + * * + * Per thread global state handling * + * * + ************************************************************************/ + +#ifdef LIBXML_THREAD_ENABLED +#ifdef xmlLastError +#undef xmlLastError +#endif + +/** + * xmlFreeGlobalState: + * @state: a thread global state + * + * xmlFreeGlobalState() is called when a thread terminates with a non-NULL + * global state. It is is used here to reclaim memory resources. + */ +static void +xmlFreeGlobalState(void *state) +{ + xmlGlobalState *gs = (xmlGlobalState *) state; + + /* free any memory allocated in the thread's xmlLastError */ + xmlResetError(&(gs->xmlLastError)); + free(state); +} + +/** + * xmlNewGlobalState: + * + * xmlNewGlobalState() allocates a global state. This structure is used to + * hold all data for use by a thread when supporting backwards compatibility + * of libxml2 to pre-thread-safe behaviour. + * + * Returns the newly allocated xmlGlobalStatePtr or NULL in case of error + */ +static xmlGlobalStatePtr +xmlNewGlobalState(void) +{ + xmlGlobalState *gs; + + gs = malloc(sizeof(xmlGlobalState)); + if (gs == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlGetGlobalState: out of memory\n"); + return (NULL); + } + + memset(gs, 0, sizeof(xmlGlobalState)); + xmlInitializeGlobalState(gs); + return (gs); +} +#endif /* LIBXML_THREAD_ENABLED */ + +#ifdef HAVE_PTHREAD_H +#elif defined HAVE_WIN32_THREADS +#if !defined(HAVE_COMPILER_TLS) +#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL) +typedef struct _xmlGlobalStateCleanupHelperParams { + HANDLE thread; + void *memory; +} xmlGlobalStateCleanupHelperParams; + +static void XMLCDECL +xmlGlobalStateCleanupHelper(void *p) +{ + xmlGlobalStateCleanupHelperParams *params = + (xmlGlobalStateCleanupHelperParams *) p; + WaitForSingleObject(params->thread, INFINITE); + CloseHandle(params->thread); + xmlFreeGlobalState(params->memory); + free(params); + _endthread(); +} +#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */ + +typedef struct _xmlGlobalStateCleanupHelperParams { + void *memory; + struct _xmlGlobalStateCleanupHelperParams *prev; + struct _xmlGlobalStateCleanupHelperParams *next; +} xmlGlobalStateCleanupHelperParams; + +static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL; +static CRITICAL_SECTION cleanup_helpers_cs; + +#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */ +#endif /* HAVE_COMPILER_TLS */ +#endif /* HAVE_WIN32_THREADS */ + +#if defined HAVE_BEOS_THREADS + +/** + * xmlGlobalStateCleanup: + * @data: unused parameter + * + * Used for Beos only + */ +void +xmlGlobalStateCleanup(void *data) +{ + void *globalval = tls_get(globalkey); + + if (globalval != NULL) + xmlFreeGlobalState(globalval); +} +#endif + +/** + * xmlGetGlobalState: + * + * xmlGetGlobalState() is called to retrieve the global state for a thread. + * + * Returns the thread global state or NULL in case of error + */ +xmlGlobalStatePtr +xmlGetGlobalState(void) +{ +#ifdef HAVE_PTHREAD_H + xmlGlobalState *globalval; + + if (libxml_is_threaded == 0) + return (NULL); + + pthread_once(&once_control, xmlOnceInit); + + if ((globalval = (xmlGlobalState *) + pthread_getspecific(globalkey)) == NULL) { + xmlGlobalState *tsd = xmlNewGlobalState(); + if (tsd == NULL) + return(NULL); + + pthread_setspecific(globalkey, tsd); + return (tsd); + } + return (globalval); +#elif defined HAVE_WIN32_THREADS +#if defined(HAVE_COMPILER_TLS) + if (!tlstate_inited) { + tlstate_inited = 1; + xmlInitializeGlobalState(&tlstate); + } + return &tlstate; +#else /* HAVE_COMPILER_TLS */ + xmlGlobalState *globalval; + xmlGlobalStateCleanupHelperParams *p; + + xmlOnceInit(); +#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL) + globalval = (xmlGlobalState *) TlsGetValue(globalkey); +#else + p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey); + globalval = (xmlGlobalState *) (p ? p->memory : NULL); +#endif + if (globalval == NULL) { + xmlGlobalState *tsd = xmlNewGlobalState(); + + if (tsd == NULL) + return(NULL); + p = (xmlGlobalStateCleanupHelperParams *) + malloc(sizeof(xmlGlobalStateCleanupHelperParams)); + if (p == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlGetGlobalState: out of memory\n"); + xmlFreeGlobalState(tsd); + return(NULL); + } + p->memory = tsd; +#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL) + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), + GetCurrentProcess(), &p->thread, 0, TRUE, + DUPLICATE_SAME_ACCESS); + TlsSetValue(globalkey, tsd); + _beginthread(xmlGlobalStateCleanupHelper, 0, p); +#else + EnterCriticalSection(&cleanup_helpers_cs); + if (cleanup_helpers_head != NULL) { + cleanup_helpers_head->prev = p; + } + p->next = cleanup_helpers_head; + p->prev = NULL; + cleanup_helpers_head = p; + TlsSetValue(globalkey, p); + LeaveCriticalSection(&cleanup_helpers_cs); +#endif + + return (tsd); + } + return (globalval); +#endif /* HAVE_COMPILER_TLS */ +#elif defined HAVE_BEOS_THREADS + xmlGlobalState *globalval; + + xmlOnceInit(); + + if ((globalval = (xmlGlobalState *) tls_get(globalkey)) == NULL) { + xmlGlobalState *tsd = xmlNewGlobalState(); + if (tsd == NULL) + return (NULL); + + tls_set(globalkey, tsd); + on_exit_thread(xmlGlobalStateCleanup, NULL); + return (tsd); + } + return (globalval); +#else + return (NULL); +#endif +} + +/************************************************************************ + * * + * Library wide thread interfaces * + * * + ************************************************************************/ + +/** + * xmlGetThreadId: + * + * xmlGetThreadId() find the current thread ID number + * Note that this is likely to be broken on some platforms using pthreads + * as the specification doesn't mandate pthread_t to be an integer type + * + * Returns the current thread ID number + */ +int +xmlGetThreadId(void) +{ +#ifdef HAVE_PTHREAD_H + pthread_t id; + int ret; + + if (libxml_is_threaded == 0) + return (0); + id = pthread_self(); + /* horrible but preserves compat, see warning above */ + memcpy(&ret, &id, sizeof(ret)); + return (ret); +#elif defined HAVE_WIN32_THREADS + return GetCurrentThreadId(); +#elif defined HAVE_BEOS_THREADS + return find_thread(NULL); +#else + return ((int) 0); +#endif +} + +/** + * xmlIsMainThread: + * + * xmlIsMainThread() check whether the current thread is the main thread. + * + * Returns 1 if the current thread is the main thread, 0 otherwise + */ +int +xmlIsMainThread(void) +{ +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded == -1) + xmlInitThreads(); + if (libxml_is_threaded == 0) + return (1); + pthread_once(&once_control, xmlOnceInit); +#elif defined HAVE_WIN32_THREADS + xmlOnceInit(); +#elif defined HAVE_BEOS_THREADS + xmlOnceInit(); +#endif + +#ifdef DEBUG_THREADS + xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n"); +#endif +#ifdef HAVE_PTHREAD_H + return (pthread_equal(mainthread,pthread_self())); +#elif defined HAVE_WIN32_THREADS + return (mainthread == GetCurrentThreadId()); +#elif defined HAVE_BEOS_THREADS + return (mainthread == find_thread(NULL)); +#else + return (1); +#endif +} + +/** + * xmlLockLibrary: + * + * xmlLockLibrary() is used to take out a re-entrant lock on the libxml2 + * library. + */ +void +xmlLockLibrary(void) +{ +#ifdef DEBUG_THREADS + xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n"); +#endif + xmlRMutexLock(xmlLibraryLock); +} + +/** + * xmlUnlockLibrary: + * + * xmlUnlockLibrary() is used to release a re-entrant lock on the libxml2 + * library. + */ +void +xmlUnlockLibrary(void) +{ +#ifdef DEBUG_THREADS + xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n"); +#endif + xmlRMutexUnlock(xmlLibraryLock); +} + +/** + * xmlInitThreads: + * + * xmlInitThreads() is used to to initialize all the thread related + * data of the libxml2 library. + */ +void +xmlInitThreads(void) +{ +#ifdef HAVE_PTHREAD_H +#ifdef XML_PTHREAD_WEAK + if (libxml_is_threaded == -1) { + if ((pthread_once != NULL) && + (pthread_getspecific != NULL) && + (pthread_setspecific != NULL) && + (pthread_key_create != NULL) && + (pthread_key_delete != NULL) && + (pthread_mutex_init != NULL) && + (pthread_mutex_destroy != NULL) && + (pthread_mutex_lock != NULL) && + (pthread_mutex_unlock != NULL) && + (pthread_cond_init != NULL) && + (pthread_cond_destroy != NULL) && + (pthread_cond_wait != NULL) && + (pthread_equal != NULL) && + (pthread_self != NULL) && + (pthread_cond_signal != NULL)) { + libxml_is_threaded = 1; + +/* fprintf(stderr, "Running multithreaded\n"); */ + } else { + +/* fprintf(stderr, "Running without multithread\n"); */ + libxml_is_threaded = 0; + } + } +#endif /* XML_PTHREAD_WEAK */ +#endif +} + +/** + * xmlCleanupThreads: + * + * xmlCleanupThreads() is used to to cleanup all the thread related + * data of the libxml2 library once processing has ended. + * + * WARNING: if your application is multithreaded or has plugin support + * calling this may crash the application if another thread or + * a plugin is still using libxml2. It's sometimes very hard to + * guess if libxml2 is in use in the application, some libraries + * or plugins may use it without notice. In case of doubt abstain + * from calling this function or do it just before calling exit() + * to avoid leak reports from valgrind ! + */ +void +xmlCleanupThreads(void) +{ +#ifdef DEBUG_THREADS + xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n"); +#endif +#ifdef HAVE_PTHREAD_H + if (libxml_is_threaded != 0) + pthread_key_delete(globalkey); + once_control = once_control_init; +#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) + if (globalkey != TLS_OUT_OF_INDEXES) { + xmlGlobalStateCleanupHelperParams *p; + + EnterCriticalSection(&cleanup_helpers_cs); + p = cleanup_helpers_head; + while (p != NULL) { + xmlGlobalStateCleanupHelperParams *temp = p; + + p = p->next; + xmlFreeGlobalState(temp->memory); + free(temp); + } + cleanup_helpers_head = 0; + LeaveCriticalSection(&cleanup_helpers_cs); + TlsFree(globalkey); + globalkey = TLS_OUT_OF_INDEXES; + } + DeleteCriticalSection(&cleanup_helpers_cs); +#endif +} + +#ifdef LIBXML_THREAD_ENABLED + +/** + * xmlOnceInit + * + * xmlOnceInit() is used to initialize the value of mainthread for use + * in other routines. This function should only be called using + * pthread_once() in association with the once_control variable to ensure + * that the function is only called once. See man pthread_once for more + * details. + */ +static void +xmlOnceInit(void) +{ +#ifdef HAVE_PTHREAD_H + (void) pthread_key_create(&globalkey, xmlFreeGlobalState); + mainthread = pthread_self(); + __xmlInitializeDict(); +#elif defined(HAVE_WIN32_THREADS) + if (!run_once.done) { + if (InterlockedIncrement(&run_once.control) == 1) { +#if !defined(HAVE_COMPILER_TLS) +#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL) + InitializeCriticalSection(&cleanup_helpers_cs); +#endif + globalkey = TlsAlloc(); +#endif + mainthread = GetCurrentThreadId(); + __xmlInitializeDict(); + run_once.done = 1; + } else { + /* Another thread is working; give up our slice and + * wait until they're done. */ + while (!run_once.done) + Sleep(0); + } + } +#elif defined HAVE_BEOS_THREADS + if (atomic_add(&run_once_init, 1) == 0) { + globalkey = tls_allocate(); + tls_set(globalkey, NULL); + mainthread = find_thread(NULL); + __xmlInitializeDict(); + } else + atomic_add(&run_once_init, -1); +#endif +} +#endif + +/** + * DllMain: + * @hinstDLL: handle to DLL instance + * @fdwReason: Reason code for entry + * @lpvReserved: generic pointer (depends upon reason code) + * + * Entry point for Windows library. It is being used to free thread-specific + * storage. + * + * Returns TRUE always + */ +#ifdef HAVE_PTHREAD_H +#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) +#if defined(LIBXML_STATIC_FOR_DLL) +int XMLCALL +xmlDllMain(ATTRIBUTE_UNUSED void *hinstDLL, unsigned long fdwReason, + ATTRIBUTE_UNUSED void *lpvReserved) +#else +/* declare to avoid "no previous prototype for 'DllMain'" warning */ +/* Note that we do NOT want to include this function declaration in + a public header because it's meant to be called by Windows itself, + not a program that uses this library. This also has to be exported. */ + +XMLPUBFUN BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved); + +BOOL WINAPI +DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason, + ATTRIBUTE_UNUSED LPVOID lpvReserved) +#endif +{ + switch (fdwReason) { + case DLL_THREAD_DETACH: + if (globalkey != TLS_OUT_OF_INDEXES) { + xmlGlobalState *globalval = NULL; + xmlGlobalStateCleanupHelperParams *p = + (xmlGlobalStateCleanupHelperParams *) + TlsGetValue(globalkey); + globalval = (xmlGlobalState *) (p ? p->memory : NULL); + if (globalval) { + xmlFreeGlobalState(globalval); + TlsSetValue(globalkey, NULL); + } + if (p) { + EnterCriticalSection(&cleanup_helpers_cs); + if (p == cleanup_helpers_head) + cleanup_helpers_head = p->next; + else + p->prev->next = p->next; + if (p->next != NULL) + p->next->prev = p->prev; + LeaveCriticalSection(&cleanup_helpers_cs); + free(p); + } + } + break; + } + return TRUE; +} +#endif +#define bottom_threads +#include "elfgcchack.h" diff --git a/src/timsort.h b/src/timsort.h new file mode 100644 index 000000000000..383584fb35fd --- /dev/null +++ b/src/timsort.h @@ -0,0 +1,601 @@ +/* + * Taken from https://github.com/swenson/sort + * Revision: 05fd77bfec049ce8b7c408c4d3dd2d51ee061a15 + * Removed all code unrelated to Timsort and made minor adjustments for + * cross-platform compatibility. + */ + +/* + * The MIT License (MIT) + * + * Copyright (c) 2010-2017 Christopher Swenson. + * Copyright (c) 2012 Vojtech Fried. + * Copyright (c) 2012 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#ifdef HAVE_STDINT_H +#include +#elif defined(_WIN32) +typedef unsigned __int64 uint64_t; +#endif + +#ifndef SORT_NAME +#error "Must declare SORT_NAME" +#endif + +#ifndef SORT_TYPE +#error "Must declare SORT_TYPE" +#endif + +#ifndef SORT_CMP +#define SORT_CMP(x, y) ((x) < (y) ? -1 : ((x) == (y) ? 0 : 1)) +#endif + +#ifndef TIM_SORT_STACK_SIZE +#define TIM_SORT_STACK_SIZE 128 +#endif + +#define SORT_SWAP(x,y) {SORT_TYPE __SORT_SWAP_t = (x); (x) = (y); (y) = __SORT_SWAP_t;} + + +/* Common, type-agnostic functions and constants that we don't want to declare twice. */ +#ifndef SORT_COMMON_H +#define SORT_COMMON_H + +#ifndef MAX +#define MAX(x,y) (((x) > (y) ? (x) : (y))) +#endif + +#ifndef MIN +#define MIN(x,y) (((x) < (y) ? (x) : (y))) +#endif + +static int compute_minrun(const uint64_t); + +#ifndef CLZ +#if defined(__GNUC__) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3)) +#define CLZ __builtin_clzll +#else + +static int clzll(uint64_t); + +/* adapted from Hacker's Delight */ +static int clzll(uint64_t x) { + int n; + + if (x == 0) { + return 64; + } + + n = 0; + + if (x <= 0x00000000FFFFFFFFL) { + n = n + 32; + x = x << 32; + } + + if (x <= 0x0000FFFFFFFFFFFFL) { + n = n + 16; + x = x << 16; + } + + if (x <= 0x00FFFFFFFFFFFFFFL) { + n = n + 8; + x = x << 8; + } + + if (x <= 0x0FFFFFFFFFFFFFFFL) { + n = n + 4; + x = x << 4; + } + + if (x <= 0x3FFFFFFFFFFFFFFFL) { + n = n + 2; + x = x << 2; + } + + if (x <= 0x7FFFFFFFFFFFFFFFL) { + n = n + 1; + } + + return n; +} + +#define CLZ clzll +#endif +#endif + +static __inline int compute_minrun(const uint64_t size) { + const int top_bit = 64 - CLZ(size); + const int shift = MAX(top_bit, 6) - 6; + const int minrun = size >> shift; + const uint64_t mask = (1ULL << shift) - 1; + + if (mask & size) { + return minrun + 1; + } + + return minrun; +} + +#endif /* SORT_COMMON_H */ + +#define SORT_CONCAT(x, y) x ## _ ## y +#define SORT_MAKE_STR1(x, y) SORT_CONCAT(x,y) +#define SORT_MAKE_STR(x) SORT_MAKE_STR1(SORT_NAME,x) + +#define BINARY_INSERTION_FIND SORT_MAKE_STR(binary_insertion_find) +#define BINARY_INSERTION_SORT_START SORT_MAKE_STR(binary_insertion_sort_start) +#define BINARY_INSERTION_SORT SORT_MAKE_STR(binary_insertion_sort) +#define REVERSE_ELEMENTS SORT_MAKE_STR(reverse_elements) +#define COUNT_RUN SORT_MAKE_STR(count_run) +#define CHECK_INVARIANT SORT_MAKE_STR(check_invariant) +#define TIM_SORT SORT_MAKE_STR(tim_sort) +#define TIM_SORT_RESIZE SORT_MAKE_STR(tim_sort_resize) +#define TIM_SORT_MERGE SORT_MAKE_STR(tim_sort_merge) +#define TIM_SORT_COLLAPSE SORT_MAKE_STR(tim_sort_collapse) + +#ifndef MAX +#define MAX(x,y) (((x) > (y) ? (x) : (y))) +#endif +#ifndef MIN +#define MIN(x,y) (((x) < (y) ? (x) : (y))) +#endif + +typedef struct { + size_t start; + size_t length; +} TIM_SORT_RUN_T; + + +void BINARY_INSERTION_SORT(SORT_TYPE *dst, const size_t size); +void TIM_SORT(SORT_TYPE *dst, const size_t size); + + +/* Function used to do a binary search for binary insertion sort */ +static __inline size_t BINARY_INSERTION_FIND(SORT_TYPE *dst, const SORT_TYPE x, + const size_t size) { + size_t l, c, r; + SORT_TYPE cx; + l = 0; + r = size - 1; + c = r >> 1; + + /* check for out of bounds at the beginning. */ + if (SORT_CMP(x, dst[0]) < 0) { + return 0; + } else if (SORT_CMP(x, dst[r]) > 0) { + return r; + } + + cx = dst[c]; + + while (1) { + const int val = SORT_CMP(x, cx); + + if (val < 0) { + if (c - l <= 1) { + return c; + } + + r = c; + } else { /* allow = for stability. The binary search favors the right. */ + if (r - c <= 1) { + return c + 1; + } + + l = c; + } + + c = l + ((r - l) >> 1); + cx = dst[c]; + } +} + +/* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */ +static void BINARY_INSERTION_SORT_START(SORT_TYPE *dst, const size_t start, const size_t size) { + size_t i; + + for (i = start; i < size; i++) { + size_t j; + SORT_TYPE x; + size_t location; + + /* If this entry is already correct, just move along */ + if (SORT_CMP(dst[i - 1], dst[i]) <= 0) { + continue; + } + + /* Else we need to find the right place, shift everything over, and squeeze in */ + x = dst[i]; + location = BINARY_INSERTION_FIND(dst, x, i); + + for (j = i - 1; j >= location; j--) { + dst[j + 1] = dst[j]; + + if (j == 0) { /* check edge case because j is unsigned */ + break; + } + } + + dst[location] = x; + } +} + +/* Binary insertion sort */ +void BINARY_INSERTION_SORT(SORT_TYPE *dst, const size_t size) { + /* don't bother sorting an array of size <= 1 */ + if (size <= 1) { + return; + } + + BINARY_INSERTION_SORT_START(dst, 1, size); +} + +/* timsort implementation, based on timsort.txt */ + +static __inline void REVERSE_ELEMENTS(SORT_TYPE *dst, size_t start, size_t end) { + while (1) { + if (start >= end) { + return; + } + + SORT_SWAP(dst[start], dst[end]); + start++; + end--; + } +} + +static size_t COUNT_RUN(SORT_TYPE *dst, const size_t start, const size_t size) { + size_t curr; + + if (size - start == 1) { + return 1; + } + + if (start >= size - 2) { + if (SORT_CMP(dst[size - 2], dst[size - 1]) > 0) { + SORT_SWAP(dst[size - 2], dst[size - 1]); + } + + return 2; + } + + curr = start + 2; + + if (SORT_CMP(dst[start], dst[start + 1]) <= 0) { + /* increasing run */ + while (1) { + if (curr == size - 1) { + break; + } + + if (SORT_CMP(dst[curr - 1], dst[curr]) > 0) { + break; + } + + curr++; + } + + return curr - start; + } else { + /* decreasing run */ + while (1) { + if (curr == size - 1) { + break; + } + + if (SORT_CMP(dst[curr - 1], dst[curr]) <= 0) { + break; + } + + curr++; + } + + /* reverse in-place */ + REVERSE_ELEMENTS(dst, start, curr - 1); + return curr - start; + } +} + +static int CHECK_INVARIANT(TIM_SORT_RUN_T *stack, const int stack_curr) { + size_t A, B, C; + + if (stack_curr < 2) { + return 1; + } + + if (stack_curr == 2) { + const size_t A1 = stack[stack_curr - 2].length; + const size_t B1 = stack[stack_curr - 1].length; + + if (A1 <= B1) { + return 0; + } + + return 1; + } + + A = stack[stack_curr - 3].length; + B = stack[stack_curr - 2].length; + C = stack[stack_curr - 1].length; + + if ((A <= B + C) || (B <= C)) { + return 0; + } + + return 1; +} + +typedef struct { + size_t alloc; + SORT_TYPE *storage; +} TEMP_STORAGE_T; + +static void TIM_SORT_RESIZE(TEMP_STORAGE_T *store, const size_t new_size) { + if (store->alloc < new_size) { + SORT_TYPE *tempstore = (SORT_TYPE *)realloc(store->storage, new_size * sizeof(SORT_TYPE)); + + if (tempstore == NULL) { + fprintf(stderr, "Error allocating temporary storage for tim sort: need %lu bytes", + (unsigned long)(sizeof(SORT_TYPE) * new_size)); + exit(1); + } + + store->storage = tempstore; + store->alloc = new_size; + } +} + +static void TIM_SORT_MERGE(SORT_TYPE *dst, const TIM_SORT_RUN_T *stack, const int stack_curr, + TEMP_STORAGE_T *store) { + const size_t A = stack[stack_curr - 2].length; + const size_t B = stack[stack_curr - 1].length; + const size_t curr = stack[stack_curr - 2].start; + SORT_TYPE *storage; + size_t i, j, k; + TIM_SORT_RESIZE(store, MIN(A, B)); + storage = store->storage; + + /* left merge */ + if (A < B) { + memcpy(storage, &dst[curr], A * sizeof(SORT_TYPE)); + i = 0; + j = curr + A; + + for (k = curr; k < curr + A + B; k++) { + if ((i < A) && (j < curr + A + B)) { + if (SORT_CMP(storage[i], dst[j]) <= 0) { + dst[k] = storage[i++]; + } else { + dst[k] = dst[j++]; + } + } else if (i < A) { + dst[k] = storage[i++]; + } else { + break; + } + } + } else { + /* right merge */ + memcpy(storage, &dst[curr + A], B * sizeof(SORT_TYPE)); + i = B; + j = curr + A; + k = curr + A + B; + + while (k > curr) { + k--; + if ((i > 0) && (j > curr)) { + if (SORT_CMP(dst[j - 1], storage[i - 1]) > 0) { + dst[k] = dst[--j]; + } else { + dst[k] = storage[--i]; + } + } else if (i > 0) { + dst[k] = storage[--i]; + } else { + break; + } + } + } +} + +static int TIM_SORT_COLLAPSE(SORT_TYPE *dst, TIM_SORT_RUN_T *stack, int stack_curr, + TEMP_STORAGE_T *store, const size_t size) { + while (1) { + size_t A, B, C, D; + int ABC, BCD, CD; + + /* if the stack only has one thing on it, we are done with the collapse */ + if (stack_curr <= 1) { + break; + } + + /* if this is the last merge, just do it */ + if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) { + TIM_SORT_MERGE(dst, stack, stack_curr, store); + stack[0].length += stack[1].length; + stack_curr--; + break; + } + /* check if the invariant is off for a stack of 2 elements */ + else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) { + TIM_SORT_MERGE(dst, stack, stack_curr, store); + stack[0].length += stack[1].length; + stack_curr--; + break; + } else if (stack_curr == 2) { + break; + } + + B = stack[stack_curr - 3].length; + C = stack[stack_curr - 2].length; + D = stack[stack_curr - 1].length; + + if (stack_curr >= 4) { + A = stack[stack_curr - 4].length; + ABC = (A <= B + C); + } else { + ABC = 0; + } + + BCD = (B <= C + D) || ABC; + CD = (C <= D); + + /* Both invariants are good */ + if (!BCD && !CD) { + break; + } + + /* left merge */ + if (BCD && !CD) { + TIM_SORT_MERGE(dst, stack, stack_curr - 1, store); + stack[stack_curr - 3].length += stack[stack_curr - 2].length; + stack[stack_curr - 2] = stack[stack_curr - 1]; + stack_curr--; + } else { + /* right merge */ + TIM_SORT_MERGE(dst, stack, stack_curr, store); + stack[stack_curr - 2].length += stack[stack_curr - 1].length; + stack_curr--; + } + } + + return stack_curr; +} + +static __inline int PUSH_NEXT(SORT_TYPE *dst, + const size_t size, + TEMP_STORAGE_T *store, + const size_t minrun, + TIM_SORT_RUN_T *run_stack, + size_t *stack_curr, + size_t *curr) { + size_t len = COUNT_RUN(dst, *curr, size); + size_t run = minrun; + + if (run > size - *curr) { + run = size - *curr; + } + + if (run > len) { + BINARY_INSERTION_SORT_START(&dst[*curr], len, run); + len = run; + } + + run_stack[*stack_curr].start = *curr; + run_stack[*stack_curr].length = len; + (*stack_curr)++; + *curr += len; + + if (*curr == size) { + /* finish up */ + while (*stack_curr > 1) { + TIM_SORT_MERGE(dst, run_stack, *stack_curr, store); + run_stack[*stack_curr - 2].length += run_stack[*stack_curr - 1].length; + (*stack_curr)--; + } + + if (store->storage != NULL) { + free(store->storage); + store->storage = NULL; + } + + return 0; + } + + return 1; +} + +void TIM_SORT(SORT_TYPE *dst, const size_t size) { + size_t minrun; + TEMP_STORAGE_T _store, *store; + TIM_SORT_RUN_T run_stack[TIM_SORT_STACK_SIZE]; + size_t stack_curr = 0; + size_t curr = 0; + + /* don't bother sorting an array of size 1 */ + if (size <= 1) { + return; + } + + if (size < 64) { + BINARY_INSERTION_SORT(dst, size); + return; + } + + /* compute the minimum run length */ + minrun = compute_minrun(size); + /* temporary storage for merges */ + store = &_store; + store->alloc = 0; + store->storage = NULL; + + if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { + return; + } + + if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { + return; + } + + if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { + return; + } + + while (1) { + if (!CHECK_INVARIANT(run_stack, stack_curr)) { + stack_curr = TIM_SORT_COLLAPSE(dst, run_stack, stack_curr, store, size); + continue; + } + + if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { + return; + } + } +} + +#undef SORT_CONCAT +#undef SORT_MAKE_STR1 +#undef SORT_MAKE_STR +#undef SORT_NAME +#undef SORT_TYPE +#undef SORT_CMP +#undef TEMP_STORAGE_T +#undef TIM_SORT_RUN_T +#undef PUSH_NEXT +#undef SORT_SWAP +#undef SORT_CONCAT +#undef SORT_MAKE_STR1 +#undef SORT_MAKE_STR +#undef BINARY_INSERTION_FIND +#undef BINARY_INSERTION_SORT_START +#undef BINARY_INSERTION_SORT +#undef REVERSE_ELEMENTS +#undef COUNT_RUN +#undef TIM_SORT +#undef TIM_SORT_RESIZE +#undef TIM_SORT_COLLAPSE +#undef TIM_SORT_RUN_T +#undef TEMP_STORAGE_T diff --git a/src/tree.c b/src/tree.c new file mode 100644 index 000000000000..c707f598e8d5 --- /dev/null +++ b/src/tree.c @@ -0,0 +1,10183 @@ +/* + * tree.c : implementation of access function for an XML tree. + * + * References: + * XHTML 1.0 W3C REC: http://www.w3.org/TR/2002/REC-xhtml1-20020801/ + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + * + */ + +/* To avoid EBCDIC trouble when parsing on zOS */ +#if defined(__MVS__) +#pragma convert("ISO8859-1") +#endif + +#define IN_LIBXML +#include "libxml.h" + +#include /* for memset() only ! */ +#include +#include +#ifdef HAVE_CTYPE_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef LIBXML_ZLIB_ENABLED +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef LIBXML_HTML_ENABLED +#include +#endif +#ifdef LIBXML_DEBUG_ENABLED +#include +#endif + +#include "buf.h" +#include "save.h" + +int __xmlRegisterCallbacks = 0; + +/************************************************************************ + * * + * Forward declarations * + * * + ************************************************************************/ + +static xmlNsPtr +xmlNewReconciledNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns); + +static xmlChar* xmlGetPropNodeValueInternal(const xmlAttr *prop); + +/************************************************************************ + * * + * Tree memory error handler * + * * + ************************************************************************/ +/** + * xmlTreeErrMemory: + * @extra: extra information + * + * Handle an out of memory condition + */ +static void +xmlTreeErrMemory(const char *extra) +{ + __xmlSimpleError(XML_FROM_TREE, XML_ERR_NO_MEMORY, NULL, NULL, extra); +} + +/** + * xmlTreeErr: + * @code: the error number + * @extra: extra information + * + * Handle an out of memory condition + */ +static void +xmlTreeErr(int code, xmlNodePtr node, const char *extra) +{ + const char *msg = NULL; + + switch(code) { + case XML_TREE_INVALID_HEX: + msg = "invalid hexadecimal character value\n"; + break; + case XML_TREE_INVALID_DEC: + msg = "invalid decimal character value\n"; + break; + case XML_TREE_UNTERMINATED_ENTITY: + msg = "unterminated entity reference %15s\n"; + break; + case XML_TREE_NOT_UTF8: + msg = "string is not in UTF-8\n"; + break; + default: + msg = "unexpected error number\n"; + } + __xmlSimpleError(XML_FROM_TREE, code, node, msg, extra); +} + +/************************************************************************ + * * + * A few static variables and macros * + * * + ************************************************************************/ +/* #undef xmlStringText */ +const xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; +/* #undef xmlStringTextNoenc */ +const xmlChar xmlStringTextNoenc[] = + { 't', 'e', 'x', 't', 'n', 'o', 'e', 'n', 'c', 0 }; +/* #undef xmlStringComment */ +const xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 }; + +static int xmlCompressMode = 0; +static int xmlCheckDTD = 1; + +#define UPDATE_LAST_CHILD_AND_PARENT(n) if ((n) != NULL) { \ + xmlNodePtr ulccur = (n)->children; \ + if (ulccur == NULL) { \ + (n)->last = NULL; \ + } else { \ + while (ulccur->next != NULL) { \ + ulccur->parent = (n); \ + ulccur = ulccur->next; \ + } \ + ulccur->parent = (n); \ + (n)->last = ulccur; \ +}} + +#define IS_STR_XML(str) ((str != NULL) && (str[0] == 'x') && \ + (str[1] == 'm') && (str[2] == 'l') && (str[3] == 0)) + +/* #define DEBUG_BUFFER */ +/* #define DEBUG_TREE */ + +/************************************************************************ + * * + * Functions to move to entities.c once the * + * API freeze is smoothen and they can be made public. * + * * + ************************************************************************/ +#include + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlGetEntityFromDtd: + * @dtd: A pointer to the DTD to search + * @name: The entity name + * + * Do an entity lookup in the DTD entity hash table and + * return the corresponding entity, if found. + * + * Returns A pointer to the entity structure or NULL if not found. + */ +static xmlEntityPtr +xmlGetEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) { + xmlEntitiesTablePtr table; + + if((dtd != NULL) && (dtd->entities != NULL)) { + table = (xmlEntitiesTablePtr) dtd->entities; + return((xmlEntityPtr) xmlHashLookup(table, name)); + /* return(xmlGetEntityFromTable(table, name)); */ + } + return(NULL); +} +/** + * xmlGetParameterEntityFromDtd: + * @dtd: A pointer to the DTD to search + * @name: The entity name + * + * Do an entity lookup in the DTD parameter entity hash table and + * return the corresponding entity, if found. + * + * Returns A pointer to the entity structure or NULL if not found. + */ +static xmlEntityPtr +xmlGetParameterEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) { + xmlEntitiesTablePtr table; + + if ((dtd != NULL) && (dtd->pentities != NULL)) { + table = (xmlEntitiesTablePtr) dtd->pentities; + return((xmlEntityPtr) xmlHashLookup(table, name)); + /* return(xmlGetEntityFromTable(table, name)); */ + } + return(NULL); +} +#endif /* LIBXML_TREE_ENABLED */ + +/************************************************************************ + * * + * QName handling helper * + * * + ************************************************************************/ + +/** + * xmlBuildQName: + * @ncname: the Name + * @prefix: the prefix + * @memory: preallocated memory + * @len: preallocated memory length + * + * Builds the QName @prefix:@ncname in @memory if there is enough space + * and prefix is not NULL nor empty, otherwise allocate a new string. + * If prefix is NULL or empty it returns ncname. + * + * Returns the new string which must be freed by the caller if different from + * @memory and @ncname or NULL in case of error + */ +xmlChar * +xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, + xmlChar *memory, int len) { + int lenn, lenp; + xmlChar *ret; + + if (ncname == NULL) return(NULL); + if (prefix == NULL) return((xmlChar *) ncname); + + lenn = strlen((char *) ncname); + lenp = strlen((char *) prefix); + + if ((memory == NULL) || (len < lenn + lenp + 2)) { + ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); + if (ret == NULL) { + xmlTreeErrMemory("building QName"); + return(NULL); + } + } else { + ret = memory; + } + memcpy(&ret[0], prefix, lenp); + ret[lenp] = ':'; + memcpy(&ret[lenp + 1], ncname, lenn); + ret[lenn + lenp + 1] = 0; + return(ret); +} + +/** + * xmlSplitQName2: + * @name: the full QName + * @prefix: a xmlChar ** + * + * parse an XML qualified name string + * + * [NS 5] QName ::= (Prefix ':')? LocalPart + * + * [NS 6] Prefix ::= NCName + * + * [NS 7] LocalPart ::= NCName + * + * Returns NULL if the name doesn't have a prefix. Otherwise, returns the + * local part, and prefix is updated to get the Prefix. Both the return value + * and the prefix must be freed by the caller. + */ +xmlChar * +xmlSplitQName2(const xmlChar *name, xmlChar **prefix) { + int len = 0; + xmlChar *ret = NULL; + + if (prefix == NULL) return(NULL); + *prefix = NULL; + if (name == NULL) return(NULL); + +#ifndef XML_XML_NAMESPACE + /* xml: prefix is not really a namespace */ + if ((name[0] == 'x') && (name[1] == 'm') && + (name[2] == 'l') && (name[3] == ':')) + return(NULL); +#endif + + /* nasty but valid */ + if (name[0] == ':') + return(NULL); + + /* + * we are not trying to validate but just to cut, and yes it will + * work even if this is as set of UTF-8 encoded chars + */ + while ((name[len] != 0) && (name[len] != ':')) + len++; + + if (name[len] == 0) + return(NULL); + + *prefix = xmlStrndup(name, len); + if (*prefix == NULL) { + xmlTreeErrMemory("QName split"); + return(NULL); + } + ret = xmlStrdup(&name[len + 1]); + if (ret == NULL) { + xmlTreeErrMemory("QName split"); + if (*prefix != NULL) { + xmlFree(*prefix); + *prefix = NULL; + } + return(NULL); + } + + return(ret); +} + +/** + * xmlSplitQName3: + * @name: the full QName + * @len: an int * + * + * parse an XML qualified name string,i + * + * returns NULL if it is not a Qualified Name, otherwise, update len + * with the length in byte of the prefix and return a pointer + * to the start of the name without the prefix + */ + +const xmlChar * +xmlSplitQName3(const xmlChar *name, int *len) { + int l = 0; + + if (name == NULL) return(NULL); + if (len == NULL) return(NULL); + + /* nasty but valid */ + if (name[0] == ':') + return(NULL); + + /* + * we are not trying to validate but just to cut, and yes it will + * work even if this is as set of UTF-8 encoded chars + */ + while ((name[l] != 0) && (name[l] != ':')) + l++; + + if (name[l] == 0) + return(NULL); + + *len = l; + + return(&name[l+1]); +} + +/************************************************************************ + * * + * Check Name, NCName and QName strings * + * * + ************************************************************************/ + +#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l) + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED) +/** + * xmlValidateNCName: + * @value: the value to check + * @space: allow spaces in front and end of the string + * + * Check that a value conforms to the lexical space of NCName + * + * Returns 0 if this validates, a positive error code number otherwise + * and -1 in case of internal or API error. + */ +int +xmlValidateNCName(const xmlChar *value, int space) { + const xmlChar *cur = value; + int c,l; + + if (value == NULL) + return(-1); + + /* + * First quick algorithm for ASCII range + */ + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || + (*cur == '_')) + cur++; + else + goto try_complex; + while (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + ((*cur >= '0') && (*cur <= '9')) || + (*cur == '_') || (*cur == '-') || (*cur == '.')) + cur++; + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (*cur == 0) + return(0); + +try_complex: + /* + * Second check for chars outside the ASCII range + */ + cur = value; + c = CUR_SCHAR(cur, l); + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if ((!IS_LETTER(c)) && (c != '_')) + return(1); + cur += l; + c = CUR_SCHAR(cur, l); + while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || + (c == '-') || (c == '_') || IS_COMBINING(c) || + IS_EXTENDER(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if (c != 0) + return(1); + + return(0); +} +#endif + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlValidateQName: + * @value: the value to check + * @space: allow spaces in front and end of the string + * + * Check that a value conforms to the lexical space of QName + * + * Returns 0 if this validates, a positive error code number otherwise + * and -1 in case of internal or API error. + */ +int +xmlValidateQName(const xmlChar *value, int space) { + const xmlChar *cur = value; + int c,l; + + if (value == NULL) + return(-1); + /* + * First quick algorithm for ASCII range + */ + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || + (*cur == '_')) + cur++; + else + goto try_complex; + while (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + ((*cur >= '0') && (*cur <= '9')) || + (*cur == '_') || (*cur == '-') || (*cur == '.')) + cur++; + if (*cur == ':') { + cur++; + if (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + (*cur == '_')) + cur++; + else + goto try_complex; + while (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + ((*cur >= '0') && (*cur <= '9')) || + (*cur == '_') || (*cur == '-') || (*cur == '.')) + cur++; + } + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (*cur == 0) + return(0); + +try_complex: + /* + * Second check for chars outside the ASCII range + */ + cur = value; + c = CUR_SCHAR(cur, l); + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if ((!IS_LETTER(c)) && (c != '_')) + return(1); + cur += l; + c = CUR_SCHAR(cur, l); + while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || + (c == '-') || (c == '_') || IS_COMBINING(c) || + IS_EXTENDER(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + if (c == ':') { + cur += l; + c = CUR_SCHAR(cur, l); + if ((!IS_LETTER(c)) && (c != '_')) + return(1); + cur += l; + c = CUR_SCHAR(cur, l); + while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || + (c == '-') || (c == '_') || IS_COMBINING(c) || + IS_EXTENDER(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if (c != 0) + return(1); + return(0); +} + +/** + * xmlValidateName: + * @value: the value to check + * @space: allow spaces in front and end of the string + * + * Check that a value conforms to the lexical space of Name + * + * Returns 0 if this validates, a positive error code number otherwise + * and -1 in case of internal or API error. + */ +int +xmlValidateName(const xmlChar *value, int space) { + const xmlChar *cur = value; + int c,l; + + if (value == NULL) + return(-1); + /* + * First quick algorithm for ASCII range + */ + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) || + (*cur == '_') || (*cur == ':')) + cur++; + else + goto try_complex; + while (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + ((*cur >= '0') && (*cur <= '9')) || + (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) + cur++; + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (*cur == 0) + return(0); + +try_complex: + /* + * Second check for chars outside the ASCII range + */ + cur = value; + c = CUR_SCHAR(cur, l); + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if ((!IS_LETTER(c)) && (c != '_') && (c != ':')) + return(1); + cur += l; + c = CUR_SCHAR(cur, l); + while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || + (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if (c != 0) + return(1); + return(0); +} + +/** + * xmlValidateNMToken: + * @value: the value to check + * @space: allow spaces in front and end of the string + * + * Check that a value conforms to the lexical space of NMToken + * + * Returns 0 if this validates, a positive error code number otherwise + * and -1 in case of internal or API error. + */ +int +xmlValidateNMToken(const xmlChar *value, int space) { + const xmlChar *cur = value; + int c,l; + + if (value == NULL) + return(-1); + /* + * First quick algorithm for ASCII range + */ + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + ((*cur >= '0') && (*cur <= '9')) || + (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) + cur++; + else + goto try_complex; + while (((*cur >= 'a') && (*cur <= 'z')) || + ((*cur >= 'A') && (*cur <= 'Z')) || + ((*cur >= '0') && (*cur <= '9')) || + (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) + cur++; + if (space) + while (IS_BLANK_CH(*cur)) cur++; + if (*cur == 0) + return(0); + +try_complex: + /* + * Second check for chars outside the ASCII range + */ + cur = value; + c = CUR_SCHAR(cur, l); + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if (!(IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || + (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c))) + return(1); + cur += l; + c = CUR_SCHAR(cur, l); + while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || + (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + if (space) { + while (IS_BLANK(c)) { + cur += l; + c = CUR_SCHAR(cur, l); + } + } + if (c != 0) + return(1); + return(0); +} +#endif /* LIBXML_TREE_ENABLED */ + +/************************************************************************ + * * + * Allocation and deallocation of basic structures * + * * + ************************************************************************/ + +/** + * xmlSetBufferAllocationScheme: + * @scheme: allocation method to use + * + * Set the buffer allocation method. Types are + * XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down + * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, + * improves performance + */ +void +xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) { + if ((scheme == XML_BUFFER_ALLOC_EXACT) || + (scheme == XML_BUFFER_ALLOC_DOUBLEIT) || + (scheme == XML_BUFFER_ALLOC_HYBRID)) + xmlBufferAllocScheme = scheme; +} + +/** + * xmlGetBufferAllocationScheme: + * + * Types are + * XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down + * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, + * improves performance + * XML_BUFFER_ALLOC_HYBRID - use exact sizes on small strings to keep memory usage tight + * in normal usage, and doubleit on large strings to avoid + * pathological performance. + * + * Returns the current allocation scheme + */ +xmlBufferAllocationScheme +xmlGetBufferAllocationScheme(void) { + return(xmlBufferAllocScheme); +} + +/** + * xmlNewNs: + * @node: the element carrying the namespace + * @href: the URI associated + * @prefix: the prefix for the namespace + * + * Creation of a new Namespace. This function will refuse to create + * a namespace with a similar prefix than an existing one present on this + * node. + * Note that for a default namespace, @prefix should be NULL. + * + * We use href==NULL in the case of an element creation where the namespace + * was not defined. + * + * Returns a new namespace pointer or NULL + */ +xmlNsPtr +xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) { + xmlNsPtr cur; + + if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) + return(NULL); + + if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) { + /* xml namespace is predefined, no need to add it */ + if (xmlStrEqual(href, XML_XML_NAMESPACE)) + return(NULL); + + /* + * Problem, this is an attempt to bind xml prefix to a wrong + * namespace, which breaks + * Namespace constraint: Reserved Prefixes and Namespace Names + * from XML namespace. But documents authors may not care in + * their context so let's proceed. + */ + } + + /* + * Allocate a new Namespace and fill the fields. + */ + cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); + if (cur == NULL) { + xmlTreeErrMemory("building namespace"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNs)); + cur->type = XML_LOCAL_NAMESPACE; + + if (href != NULL) + cur->href = xmlStrdup(href); + if (prefix != NULL) + cur->prefix = xmlStrdup(prefix); + + /* + * Add it at the end to preserve parsing order ... + * and checks for existing use of the prefix + */ + if (node != NULL) { + if (node->nsDef == NULL) { + node->nsDef = cur; + } else { + xmlNsPtr prev = node->nsDef; + + if (((prev->prefix == NULL) && (cur->prefix == NULL)) || + (xmlStrEqual(prev->prefix, cur->prefix))) { + xmlFreeNs(cur); + return(NULL); + } + while (prev->next != NULL) { + prev = prev->next; + if (((prev->prefix == NULL) && (cur->prefix == NULL)) || + (xmlStrEqual(prev->prefix, cur->prefix))) { + xmlFreeNs(cur); + return(NULL); + } + } + prev->next = cur; + } + } + return(cur); +} + +/** + * xmlSetNs: + * @node: a node in the document + * @ns: a namespace pointer + * + * Associate a namespace to a node, a posteriori. + */ +void +xmlSetNs(xmlNodePtr node, xmlNsPtr ns) { + if (node == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlSetNs: node == NULL\n"); +#endif + return; + } + if ((node->type == XML_ELEMENT_NODE) || + (node->type == XML_ATTRIBUTE_NODE)) + node->ns = ns; +} + +/** + * xmlFreeNs: + * @cur: the namespace pointer + * + * Free up the structures associated to a namespace + */ +void +xmlFreeNs(xmlNsPtr cur) { + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlFreeNs : ns == NULL\n"); +#endif + return; + } + if (cur->href != NULL) xmlFree((char *) cur->href); + if (cur->prefix != NULL) xmlFree((char *) cur->prefix); + xmlFree(cur); +} + +/** + * xmlFreeNsList: + * @cur: the first namespace pointer + * + * Free up all the structures associated to the chained namespaces. + */ +void +xmlFreeNsList(xmlNsPtr cur) { + xmlNsPtr next; + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlFreeNsList : ns == NULL\n"); +#endif + return; + } + while (cur != NULL) { + next = cur->next; + xmlFreeNs(cur); + cur = next; + } +} + +/** + * xmlNewDtd: + * @doc: the document pointer + * @name: the DTD name + * @ExternalID: the external ID + * @SystemID: the system ID + * + * Creation of a new DTD for the external subset. To create an + * internal subset, use xmlCreateIntSubset(). + * + * Returns a pointer to the new DTD structure + */ +xmlDtdPtr +xmlNewDtd(xmlDocPtr doc, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) { + xmlDtdPtr cur; + + if ((doc != NULL) && (doc->extSubset != NULL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewDtd(%s): document %s already have a DTD %s\n", + /* !!! */ (char *) name, doc->name, + /* !!! */ (char *)doc->extSubset->name); +#endif + return(NULL); + } + + /* + * Allocate a new DTD and fill the fields. + */ + cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd)); + if (cur == NULL) { + xmlTreeErrMemory("building DTD"); + return(NULL); + } + memset(cur, 0 , sizeof(xmlDtd)); + cur->type = XML_DTD_NODE; + + if (name != NULL) + cur->name = xmlStrdup(name); + if (ExternalID != NULL) + cur->ExternalID = xmlStrdup(ExternalID); + if (SystemID != NULL) + cur->SystemID = xmlStrdup(SystemID); + if (doc != NULL) + doc->extSubset = cur; + cur->doc = doc; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)cur); + return(cur); +} + +/** + * xmlGetIntSubset: + * @doc: the document pointer + * + * Get the internal subset of a document + * Returns a pointer to the DTD structure or NULL if not found + */ + +xmlDtdPtr +xmlGetIntSubset(const xmlDoc *doc) { + xmlNodePtr cur; + + if (doc == NULL) + return(NULL); + cur = doc->children; + while (cur != NULL) { + if (cur->type == XML_DTD_NODE) + return((xmlDtdPtr) cur); + cur = cur->next; + } + return((xmlDtdPtr) doc->intSubset); +} + +/** + * xmlCreateIntSubset: + * @doc: the document pointer + * @name: the DTD name + * @ExternalID: the external (PUBLIC) ID + * @SystemID: the system ID + * + * Create the internal subset of a document + * Returns a pointer to the new DTD structure + */ +xmlDtdPtr +xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, + const xmlChar *ExternalID, const xmlChar *SystemID) { + xmlDtdPtr cur; + + if ((doc != NULL) && (xmlGetIntSubset(doc) != NULL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + + "xmlCreateIntSubset(): document %s already have an internal subset\n", + doc->name); +#endif + return(NULL); + } + + /* + * Allocate a new DTD and fill the fields. + */ + cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd)); + if (cur == NULL) { + xmlTreeErrMemory("building internal subset"); + return(NULL); + } + memset(cur, 0, sizeof(xmlDtd)); + cur->type = XML_DTD_NODE; + + if (name != NULL) { + cur->name = xmlStrdup(name); + if (cur->name == NULL) { + xmlTreeErrMemory("building internal subset"); + xmlFree(cur); + return(NULL); + } + } + if (ExternalID != NULL) { + cur->ExternalID = xmlStrdup(ExternalID); + if (cur->ExternalID == NULL) { + xmlTreeErrMemory("building internal subset"); + if (cur->name != NULL) + xmlFree((char *)cur->name); + xmlFree(cur); + return(NULL); + } + } + if (SystemID != NULL) { + cur->SystemID = xmlStrdup(SystemID); + if (cur->SystemID == NULL) { + xmlTreeErrMemory("building internal subset"); + if (cur->name != NULL) + xmlFree((char *)cur->name); + if (cur->ExternalID != NULL) + xmlFree((char *)cur->ExternalID); + xmlFree(cur); + return(NULL); + } + } + if (doc != NULL) { + doc->intSubset = cur; + cur->parent = doc; + cur->doc = doc; + if (doc->children == NULL) { + doc->children = (xmlNodePtr) cur; + doc->last = (xmlNodePtr) cur; + } else { + if (doc->type == XML_HTML_DOCUMENT_NODE) { + xmlNodePtr prev; + + prev = doc->children; + prev->prev = (xmlNodePtr) cur; + cur->next = prev; + doc->children = (xmlNodePtr) cur; + } else { + xmlNodePtr next; + + next = doc->children; + while ((next != NULL) && (next->type != XML_ELEMENT_NODE)) + next = next->next; + if (next == NULL) { + cur->prev = doc->last; + cur->prev->next = (xmlNodePtr) cur; + cur->next = NULL; + doc->last = (xmlNodePtr) cur; + } else { + cur->next = next; + cur->prev = next->prev; + if (cur->prev == NULL) + doc->children = (xmlNodePtr) cur; + else + cur->prev->next = (xmlNodePtr) cur; + next->prev = (xmlNodePtr) cur; + } + } + } + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)cur); + return(cur); +} + +/** + * DICT_FREE: + * @str: a string + * + * Free a string if it is not owned by the "dict" dictionary in the + * current scope + */ +#define DICT_FREE(str) \ + if ((str) && ((!dict) || \ + (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \ + xmlFree((char *)(str)); + + +/** + * DICT_COPY: + * @str: a string + * + * Copy a string using a "dict" dictionary in the current scope, + * if available. + */ +#define DICT_COPY(str, cpy) \ + if (str) { \ + if (dict) { \ + if (xmlDictOwns(dict, (const xmlChar *)(str))) \ + cpy = (xmlChar *) (str); \ + else \ + cpy = (xmlChar *) xmlDictLookup((dict), (const xmlChar *)(str), -1); \ + } else \ + cpy = xmlStrdup((const xmlChar *)(str)); } + +/** + * DICT_CONST_COPY: + * @str: a string + * + * Copy a string using a "dict" dictionary in the current scope, + * if available. + */ +#define DICT_CONST_COPY(str, cpy) \ + if (str) { \ + if (dict) { \ + if (xmlDictOwns(dict, (const xmlChar *)(str))) \ + cpy = (const xmlChar *) (str); \ + else \ + cpy = xmlDictLookup((dict), (const xmlChar *)(str), -1); \ + } else \ + cpy = (const xmlChar *) xmlStrdup((const xmlChar *)(str)); } + + +/** + * xmlFreeDtd: + * @cur: the DTD structure to free up + * + * Free a DTD structure. + */ +void +xmlFreeDtd(xmlDtdPtr cur) { + xmlDictPtr dict = NULL; + + if (cur == NULL) { + return; + } + if (cur->doc != NULL) dict = cur->doc->dict; + + if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) + xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); + + if (cur->children != NULL) { + xmlNodePtr next, c = cur->children; + + /* + * Cleanup all nodes which are not part of the specific lists + * of notations, elements, attributes and entities. + */ + while (c != NULL) { + next = c->next; + if ((c->type != XML_NOTATION_NODE) && + (c->type != XML_ELEMENT_DECL) && + (c->type != XML_ATTRIBUTE_DECL) && + (c->type != XML_ENTITY_DECL)) { + xmlUnlinkNode(c); + xmlFreeNode(c); + } + c = next; + } + } + DICT_FREE(cur->name) + DICT_FREE(cur->SystemID) + DICT_FREE(cur->ExternalID) + /* TODO !!! */ + if (cur->notations != NULL) + xmlFreeNotationTable((xmlNotationTablePtr) cur->notations); + + if (cur->elements != NULL) + xmlFreeElementTable((xmlElementTablePtr) cur->elements); + if (cur->attributes != NULL) + xmlFreeAttributeTable((xmlAttributeTablePtr) cur->attributes); + if (cur->entities != NULL) + xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->entities); + if (cur->pentities != NULL) + xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->pentities); + + xmlFree(cur); +} + +/** + * xmlNewDoc: + * @version: xmlChar string giving the version of XML "1.0" + * + * Creates a new XML document + * + * Returns a new document + */ +xmlDocPtr +xmlNewDoc(const xmlChar *version) { + xmlDocPtr cur; + + if (version == NULL) + version = (const xmlChar *) "1.0"; + + /* + * Allocate a new document and fill the fields. + */ + cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc)); + if (cur == NULL) { + xmlTreeErrMemory("building doc"); + return(NULL); + } + memset(cur, 0, sizeof(xmlDoc)); + cur->type = XML_DOCUMENT_NODE; + + cur->version = xmlStrdup(version); + if (cur->version == NULL) { + xmlTreeErrMemory("building doc"); + xmlFree(cur); + return(NULL); + } + cur->standalone = -1; + cur->compression = -1; /* not initialized */ + cur->doc = cur; + cur->parseFlags = 0; + cur->properties = XML_DOC_USERBUILT; + /* + * The in memory encoding is always UTF8 + * This field will never change and would + * be obsolete if not for binary compatibility. + */ + cur->charset = XML_CHAR_ENCODING_UTF8; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)cur); + return(cur); +} + +/** + * xmlFreeDoc: + * @cur: pointer to the document + * + * Free up all the structures used by a document, tree included. + */ +void +xmlFreeDoc(xmlDocPtr cur) { + xmlDtdPtr extSubset, intSubset; + xmlDictPtr dict = NULL; + + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlFreeDoc : document == NULL\n"); +#endif + return; + } +#ifdef LIBXML_DEBUG_RUNTIME +#ifdef LIBXML_DEBUG_ENABLED + xmlDebugCheckDocument(stderr, cur); +#endif +#endif + + if (cur != NULL) dict = cur->dict; + + if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) + xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); + + /* + * Do this before freeing the children list to avoid ID lookups + */ + if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids); + cur->ids = NULL; + if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs); + cur->refs = NULL; + extSubset = cur->extSubset; + intSubset = cur->intSubset; + if (intSubset == extSubset) + extSubset = NULL; + if (extSubset != NULL) { + xmlUnlinkNode((xmlNodePtr) cur->extSubset); + cur->extSubset = NULL; + xmlFreeDtd(extSubset); + } + if (intSubset != NULL) { + xmlUnlinkNode((xmlNodePtr) cur->intSubset); + cur->intSubset = NULL; + xmlFreeDtd(intSubset); + } + + if (cur->children != NULL) xmlFreeNodeList(cur->children); + if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs); + + DICT_FREE(cur->version) + DICT_FREE(cur->name) + DICT_FREE(cur->encoding) + DICT_FREE(cur->URL) + xmlFree(cur); + if (dict) xmlDictFree(dict); +} + +/** + * xmlStringLenGetNodeList: + * @doc: the document + * @value: the value of the text + * @len: the length of the string value + * + * Parse the value string and build the node list associated. Should + * produce a flat tree with only TEXTs and ENTITY_REFs. + * Returns a pointer to the first child + */ +xmlNodePtr +xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) { + xmlNodePtr ret = NULL, last = NULL; + xmlNodePtr node; + xmlChar *val; + const xmlChar *cur, *end; + const xmlChar *q; + xmlEntityPtr ent; + xmlBufPtr buf; + + if (value == NULL) return(NULL); + cur = value; + end = cur + len; + + buf = xmlBufCreateSize(0); + if (buf == NULL) return(NULL); + xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID); + + q = cur; + while ((cur < end) && (*cur != 0)) { + if (cur[0] == '&') { + int charval = 0; + xmlChar tmp; + + /* + * Save the current text. + */ + if (cur != q) { + if (xmlBufAdd(buf, q, cur - q)) + goto out; + } + q = cur; + if ((cur + 2 < end) && (cur[1] == '#') && (cur[2] == 'x')) { + cur += 3; + if (cur < end) + tmp = *cur; + else + tmp = 0; + while (tmp != ';') { /* Non input consuming loop */ + /* + * If you find an integer overflow here when fuzzing, + * the bug is probably elsewhere. This function should + * only receive entities that were already validated by + * the parser, typically by xmlParseAttValueComplex + * calling xmlStringDecodeEntities. + * + * So it's better *not* to check for overflow to + * potentially discover new bugs. + */ + if ((tmp >= '0') && (tmp <= '9')) + charval = charval * 16 + (tmp - '0'); + else if ((tmp >= 'a') && (tmp <= 'f')) + charval = charval * 16 + (tmp - 'a') + 10; + else if ((tmp >= 'A') && (tmp <= 'F')) + charval = charval * 16 + (tmp - 'A') + 10; + else { + xmlTreeErr(XML_TREE_INVALID_HEX, (xmlNodePtr) doc, + NULL); + charval = 0; + break; + } + cur++; + if (cur < end) + tmp = *cur; + else + tmp = 0; + } + if (tmp == ';') + cur++; + q = cur; + } else if ((cur + 1 < end) && (cur[1] == '#')) { + cur += 2; + if (cur < end) + tmp = *cur; + else + tmp = 0; + while (tmp != ';') { /* Non input consuming loops */ + /* Don't check for integer overflow, see above. */ + if ((tmp >= '0') && (tmp <= '9')) + charval = charval * 10 + (tmp - '0'); + else { + xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc, + NULL); + charval = 0; + break; + } + cur++; + if (cur < end) + tmp = *cur; + else + tmp = 0; + } + if (tmp == ';') + cur++; + q = cur; + } else { + /* + * Read the entity string + */ + cur++; + q = cur; + while ((cur < end) && (*cur != 0) && (*cur != ';')) cur++; + if ((cur >= end) || (*cur == 0)) { + xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc, + (const char *) q); + goto out; + } + if (cur != q) { + /* + * Predefined entities don't generate nodes + */ + val = xmlStrndup(q, cur - q); + ent = xmlGetDocEntity(doc, val); + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + + if (xmlBufCat(buf, ent->content)) + goto out; + + } else { + /* + * Flush buffer so far + */ + if (!xmlBufIsEmpty(buf)) { + node = xmlNewDocText(doc, NULL); + if (node == NULL) { + if (val != NULL) xmlFree(val); + goto out; + } + node->content = xmlBufDetach(buf); + + if (last == NULL) { + last = ret = node; + } else { + last = xmlAddNextSibling(last, node); + } + } + + /* + * Create a new REFERENCE_REF node + */ + node = xmlNewReference(doc, val); + if (node == NULL) { + if (val != NULL) xmlFree(val); + goto out; + } + else if ((ent != NULL) && (ent->children == NULL)) { + xmlNodePtr temp; + + /* Set to non-NULL value to avoid recursion. */ + ent->children = (xmlNodePtr) -1; + ent->children = xmlStringGetNodeList(doc, + (const xmlChar*)node->content); + ent->owner = 1; + temp = ent->children; + while (temp) { + temp->parent = (xmlNodePtr)ent; + ent->last = temp; + temp = temp->next; + } + } + if (last == NULL) { + last = ret = node; + } else { + last = xmlAddNextSibling(last, node); + } + } + xmlFree(val); + } + cur++; + q = cur; + } + if (charval != 0) { + xmlChar buffer[10]; + int l; + + l = xmlCopyCharMultiByte(buffer, charval); + buffer[l] = 0; + + if (xmlBufCat(buf, buffer)) + goto out; + charval = 0; + } + } else + cur++; + } + + if (cur != q) { + /* + * Handle the last piece of text. + */ + if (xmlBufAdd(buf, q, cur - q)) + goto out; + } + + if (!xmlBufIsEmpty(buf)) { + node = xmlNewDocText(doc, NULL); + if (node == NULL) goto out; + node->content = xmlBufDetach(buf); + + if (last == NULL) { + ret = node; + } else { + xmlAddNextSibling(last, node); + } + } else if (ret == NULL) { + ret = xmlNewDocText(doc, BAD_CAST ""); + } + +out: + xmlBufFree(buf); + return(ret); +} + +/** + * xmlStringGetNodeList: + * @doc: the document + * @value: the value of the attribute + * + * Parse the value string and build the node list associated. Should + * produce a flat tree with only TEXTs and ENTITY_REFs. + * Returns a pointer to the first child + */ +xmlNodePtr +xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) { + xmlNodePtr ret = NULL, last = NULL; + xmlNodePtr node; + xmlChar *val; + const xmlChar *cur = value; + const xmlChar *q; + xmlEntityPtr ent; + xmlBufPtr buf; + + if (value == NULL) return(NULL); + + buf = xmlBufCreateSize(0); + if (buf == NULL) return(NULL); + xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID); + + q = cur; + while (*cur != 0) { + if (cur[0] == '&') { + int charval = 0; + xmlChar tmp; + + /* + * Save the current text. + */ + if (cur != q) { + if (xmlBufAdd(buf, q, cur - q)) + goto out; + } + q = cur; + if ((cur[1] == '#') && (cur[2] == 'x')) { + cur += 3; + tmp = *cur; + while (tmp != ';') { /* Non input consuming loop */ + /* Don't check for integer overflow, see above. */ + if ((tmp >= '0') && (tmp <= '9')) + charval = charval * 16 + (tmp - '0'); + else if ((tmp >= 'a') && (tmp <= 'f')) + charval = charval * 16 + (tmp - 'a') + 10; + else if ((tmp >= 'A') && (tmp <= 'F')) + charval = charval * 16 + (tmp - 'A') + 10; + else { + xmlTreeErr(XML_TREE_INVALID_HEX, (xmlNodePtr) doc, + NULL); + charval = 0; + break; + } + cur++; + tmp = *cur; + } + if (tmp == ';') + cur++; + q = cur; + } else if (cur[1] == '#') { + cur += 2; + tmp = *cur; + while (tmp != ';') { /* Non input consuming loops */ + /* Don't check for integer overflow, see above. */ + if ((tmp >= '0') && (tmp <= '9')) + charval = charval * 10 + (tmp - '0'); + else { + xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc, + NULL); + charval = 0; + break; + } + cur++; + tmp = *cur; + } + if (tmp == ';') + cur++; + q = cur; + } else { + /* + * Read the entity string + */ + cur++; + q = cur; + while ((*cur != 0) && (*cur != ';')) cur++; + if (*cur == 0) { + xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, + (xmlNodePtr) doc, (const char *) q); + goto out; + } + if (cur != q) { + /* + * Predefined entities don't generate nodes + */ + val = xmlStrndup(q, cur - q); + ent = xmlGetDocEntity(doc, val); + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + + if (xmlBufCat(buf, ent->content)) + goto out; + + } else { + /* + * Flush buffer so far + */ + if (!xmlBufIsEmpty(buf)) { + node = xmlNewDocText(doc, NULL); + node->content = xmlBufDetach(buf); + + if (last == NULL) { + last = ret = node; + } else { + last = xmlAddNextSibling(last, node); + } + } + + /* + * Create a new REFERENCE_REF node + */ + node = xmlNewReference(doc, val); + if (node == NULL) { + if (val != NULL) xmlFree(val); + goto out; + } + else if ((ent != NULL) && (ent->children == NULL)) { + xmlNodePtr temp; + + /* Set to non-NULL value to avoid recursion. */ + ent->children = (xmlNodePtr) -1; + ent->children = xmlStringGetNodeList(doc, + (const xmlChar*)node->content); + ent->owner = 1; + temp = ent->children; + while (temp) { + temp->parent = (xmlNodePtr)ent; + ent->last = temp; + temp = temp->next; + } + } + if (last == NULL) { + last = ret = node; + } else { + last = xmlAddNextSibling(last, node); + } + } + xmlFree(val); + } + cur++; + q = cur; + } + if (charval != 0) { + xmlChar buffer[10]; + int len; + + len = xmlCopyCharMultiByte(buffer, charval); + buffer[len] = 0; + + if (xmlBufCat(buf, buffer)) + goto out; + charval = 0; + } + } else + cur++; + } + if ((cur != q) || (ret == NULL)) { + /* + * Handle the last piece of text. + */ + xmlBufAdd(buf, q, cur - q); + } + + if (!xmlBufIsEmpty(buf)) { + node = xmlNewDocText(doc, NULL); + if (node == NULL) { + xmlBufFree(buf); + return(NULL); + } + node->content = xmlBufDetach(buf); + + if (last == NULL) { + ret = node; + } else { + xmlAddNextSibling(last, node); + } + } + +out: + xmlBufFree(buf); + return(ret); +} + +/** + * xmlNodeListGetString: + * @doc: the document + * @list: a Node list + * @inLine: should we replace entity contents or show their external form + * + * Build the string equivalent to the text contained in the Node list + * made of TEXTs and ENTITY_REFs + * + * Returns a pointer to the string copy, the caller must free it with xmlFree(). + */ +xmlChar * +xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine) +{ + const xmlNode *node = list; + xmlChar *ret = NULL; + xmlEntityPtr ent; + int attr; + + if (list == NULL) + return (NULL); + if ((list->parent != NULL) && (list->parent->type == XML_ATTRIBUTE_NODE)) + attr = 1; + else + attr = 0; + + while (node != NULL) { + if ((node->type == XML_TEXT_NODE) || + (node->type == XML_CDATA_SECTION_NODE)) { + if (inLine) { + ret = xmlStrcat(ret, node->content); + } else { + xmlChar *buffer; + + if (attr) + buffer = xmlEncodeAttributeEntities(doc, node->content); + else + buffer = xmlEncodeEntitiesReentrant(doc, node->content); + if (buffer != NULL) { + ret = xmlStrcat(ret, buffer); + xmlFree(buffer); + } + } + } else if (node->type == XML_ENTITY_REF_NODE) { + if (inLine) { + ent = xmlGetDocEntity(doc, node->name); + if (ent != NULL) { + xmlChar *buffer; + + /* an entity content can be any "well balanced chunk", + * i.e. the result of the content [43] production: + * http://www.w3.org/TR/REC-xml#NT-content. + * So it can contain text, CDATA section or nested + * entity reference nodes (among others). + * -> we recursive call xmlNodeListGetString() + * which handles these types */ + buffer = xmlNodeListGetString(doc, ent->children, 1); + if (buffer != NULL) { + ret = xmlStrcat(ret, buffer); + xmlFree(buffer); + } + } else { + ret = xmlStrcat(ret, node->content); + } + } else { + xmlChar buf[2]; + + buf[0] = '&'; + buf[1] = 0; + ret = xmlStrncat(ret, buf, 1); + ret = xmlStrcat(ret, node->name); + buf[0] = ';'; + buf[1] = 0; + ret = xmlStrncat(ret, buf, 1); + } + } +#if 0 + else { + xmlGenericError(xmlGenericErrorContext, + "xmlGetNodeListString : invalid node type %d\n", + node->type); + } +#endif + node = node->next; + } + return (ret); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlNodeListGetRawString: + * @doc: the document + * @list: a Node list + * @inLine: should we replace entity contents or show their external form + * + * Builds the string equivalent to the text contained in the Node list + * made of TEXTs and ENTITY_REFs, contrary to xmlNodeListGetString() + * this function doesn't do any character encoding handling. + * + * Returns a pointer to the string copy, the caller must free it with xmlFree(). + */ +xmlChar * +xmlNodeListGetRawString(const xmlDoc *doc, const xmlNode *list, int inLine) +{ + const xmlNode *node = list; + xmlChar *ret = NULL; + xmlEntityPtr ent; + + if (list == NULL) + return (NULL); + + while (node != NULL) { + if ((node->type == XML_TEXT_NODE) || + (node->type == XML_CDATA_SECTION_NODE)) { + if (inLine) { + ret = xmlStrcat(ret, node->content); + } else { + xmlChar *buffer; + + buffer = xmlEncodeSpecialChars(doc, node->content); + if (buffer != NULL) { + ret = xmlStrcat(ret, buffer); + xmlFree(buffer); + } + } + } else if (node->type == XML_ENTITY_REF_NODE) { + if (inLine) { + ent = xmlGetDocEntity(doc, node->name); + if (ent != NULL) { + xmlChar *buffer; + + /* an entity content can be any "well balanced chunk", + * i.e. the result of the content [43] production: + * http://www.w3.org/TR/REC-xml#NT-content. + * So it can contain text, CDATA section or nested + * entity reference nodes (among others). + * -> we recursive call xmlNodeListGetRawString() + * which handles these types */ + buffer = + xmlNodeListGetRawString(doc, ent->children, 1); + if (buffer != NULL) { + ret = xmlStrcat(ret, buffer); + xmlFree(buffer); + } + } else { + ret = xmlStrcat(ret, node->content); + } + } else { + xmlChar buf[2]; + + buf[0] = '&'; + buf[1] = 0; + ret = xmlStrncat(ret, buf, 1); + ret = xmlStrcat(ret, node->name); + buf[0] = ';'; + buf[1] = 0; + ret = xmlStrncat(ret, buf, 1); + } + } +#if 0 + else { + xmlGenericError(xmlGenericErrorContext, + "xmlGetNodeListString : invalid node type %d\n", + node->type); + } +#endif + node = node->next; + } + return (ret); +} +#endif /* LIBXML_TREE_ENABLED */ + +static xmlAttrPtr +xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns, + const xmlChar * name, const xmlChar * value, + int eatname) +{ + xmlAttrPtr cur; + xmlDocPtr doc = NULL; + + if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) { + if ((eatname == 1) && + ((node->doc == NULL) || + (!(xmlDictOwns(node->doc->dict, name))))) + xmlFree((xmlChar *) name); + return (NULL); + } + + /* + * Allocate a new property and fill the fields. + */ + cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr)); + if (cur == NULL) { + if ((eatname == 1) && + ((node == NULL) || (node->doc == NULL) || + (!(xmlDictOwns(node->doc->dict, name))))) + xmlFree((xmlChar *) name); + xmlTreeErrMemory("building attribute"); + return (NULL); + } + memset(cur, 0, sizeof(xmlAttr)); + cur->type = XML_ATTRIBUTE_NODE; + + cur->parent = node; + if (node != NULL) { + doc = node->doc; + cur->doc = doc; + } + cur->ns = ns; + + if (eatname == 0) { + if ((doc != NULL) && (doc->dict != NULL)) + cur->name = (xmlChar *) xmlDictLookup(doc->dict, name, -1); + else + cur->name = xmlStrdup(name); + } else + cur->name = name; + + if (value != NULL) { + xmlNodePtr tmp; + + cur->children = xmlNewDocText(doc, value); + cur->last = NULL; + tmp = cur->children; + while (tmp != NULL) { + tmp->parent = (xmlNodePtr) cur; + if (tmp->next == NULL) + cur->last = tmp; + tmp = tmp->next; + } + } + + /* + * Add it at the end to preserve parsing order ... + */ + if (node != NULL) { + if (node->properties == NULL) { + node->properties = cur; + } else { + xmlAttrPtr prev = node->properties; + + while (prev->next != NULL) + prev = prev->next; + prev->next = cur; + cur->prev = prev; + } + } + + if ((value != NULL) && (node != NULL) && + (xmlIsID(node->doc, node, cur) == 1)) + xmlAddID(NULL, node->doc, value, cur); + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr) cur); + return (cur); +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlNewProp: + * @node: the holding node + * @name: the name of the attribute + * @value: the value of the attribute + * + * Create a new property carried by a node. + * Returns a pointer to the attribute + */ +xmlAttrPtr +xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) { + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewProp : name == NULL\n"); +#endif + return(NULL); + } + + return xmlNewPropInternal(node, NULL, name, value, 0); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNewNsProp: + * @node: the holding node + * @ns: the namespace + * @name: the name of the attribute + * @value: the value of the attribute + * + * Create a new property tagged with a namespace and carried by a node. + * Returns a pointer to the attribute + */ +xmlAttrPtr +xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, + const xmlChar *value) { + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewNsProp : name == NULL\n"); +#endif + return(NULL); + } + + return xmlNewPropInternal(node, ns, name, value, 0); +} + +/** + * xmlNewNsPropEatName: + * @node: the holding node + * @ns: the namespace + * @name: the name of the attribute + * @value: the value of the attribute + * + * Create a new property tagged with a namespace and carried by a node. + * Returns a pointer to the attribute + */ +xmlAttrPtr +xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name, + const xmlChar *value) { + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewNsPropEatName : name == NULL\n"); +#endif + return(NULL); + } + + return xmlNewPropInternal(node, ns, name, value, 1); +} + +/** + * xmlNewDocProp: + * @doc: the document + * @name: the name of the attribute + * @value: the value of the attribute + * + * Create a new property carried by a document. + * NOTE: @value is supposed to be a piece of XML CDATA, so it allows entity + * references, but XML special chars need to be escaped first by using + * xmlEncodeEntitiesReentrant(). Use xmlNewProp() if you don't need + * entities support. + * + * Returns a pointer to the attribute + */ +xmlAttrPtr +xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) { + xmlAttrPtr cur; + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewDocProp : name == NULL\n"); +#endif + return(NULL); + } + + /* + * Allocate a new property and fill the fields. + */ + cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr)); + if (cur == NULL) { + xmlTreeErrMemory("building attribute"); + return(NULL); + } + memset(cur, 0, sizeof(xmlAttr)); + cur->type = XML_ATTRIBUTE_NODE; + + if ((doc != NULL) && (doc->dict != NULL)) + cur->name = xmlDictLookup(doc->dict, name, -1); + else + cur->name = xmlStrdup(name); + cur->doc = doc; + if (value != NULL) { + xmlNodePtr tmp; + + cur->children = xmlStringGetNodeList(doc, value); + cur->last = NULL; + + tmp = cur->children; + while (tmp != NULL) { + tmp->parent = (xmlNodePtr) cur; + if (tmp->next == NULL) + cur->last = tmp; + tmp = tmp->next; + } + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)cur); + return(cur); +} + +/** + * xmlFreePropList: + * @cur: the first property in the list + * + * Free a property and all its siblings, all the children are freed too. + */ +void +xmlFreePropList(xmlAttrPtr cur) { + xmlAttrPtr next; + if (cur == NULL) return; + while (cur != NULL) { + next = cur->next; + xmlFreeProp(cur); + cur = next; + } +} + +/** + * xmlFreeProp: + * @cur: an attribute + * + * Free one attribute, all the content is freed too + */ +void +xmlFreeProp(xmlAttrPtr cur) { + xmlDictPtr dict = NULL; + if (cur == NULL) return; + + if (cur->doc != NULL) dict = cur->doc->dict; + + if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) + xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); + + /* Check for ID removal -> leading to invalid references ! */ + if ((cur->doc != NULL) && (cur->atype == XML_ATTRIBUTE_ID)) { + xmlRemoveID(cur->doc, cur); + } + if (cur->children != NULL) xmlFreeNodeList(cur->children); + DICT_FREE(cur->name) + xmlFree(cur); +} + +/** + * xmlRemoveProp: + * @cur: an attribute + * + * Unlink and free one attribute, all the content is freed too + * Note this doesn't work for namespace definition attributes + * + * Returns 0 if success and -1 in case of error. + */ +int +xmlRemoveProp(xmlAttrPtr cur) { + xmlAttrPtr tmp; + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlRemoveProp : cur == NULL\n"); +#endif + return(-1); + } + if (cur->parent == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlRemoveProp : cur->parent == NULL\n"); +#endif + return(-1); + } + tmp = cur->parent->properties; + if (tmp == cur) { + cur->parent->properties = cur->next; + if (cur->next != NULL) + cur->next->prev = NULL; + xmlFreeProp(cur); + return(0); + } + while (tmp != NULL) { + if (tmp->next == cur) { + tmp->next = cur->next; + if (tmp->next != NULL) + tmp->next->prev = tmp; + xmlFreeProp(cur); + return(0); + } + tmp = tmp->next; + } +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlRemoveProp : attribute not owned by its node\n"); +#endif + return(-1); +} + +/** + * xmlNewDocPI: + * @doc: the target document + * @name: the processing instruction name + * @content: the PI content + * + * Creation of a processing instruction element. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content) { + xmlNodePtr cur; + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewPI : name == NULL\n"); +#endif + return(NULL); + } + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building PI"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_PI_NODE; + + if ((doc != NULL) && (doc->dict != NULL)) + cur->name = xmlDictLookup(doc->dict, name, -1); + else + cur->name = xmlStrdup(name); + if (content != NULL) { + cur->content = xmlStrdup(content); + } + cur->doc = doc; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)cur); + return(cur); +} + +/** + * xmlNewPI: + * @name: the processing instruction name + * @content: the PI content + * + * Creation of a processing instruction element. + * Use xmlDocNewPI preferably to get string interning + * + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewPI(const xmlChar *name, const xmlChar *content) { + return(xmlNewDocPI(NULL, name, content)); +} + +/** + * xmlNewNode: + * @ns: namespace if any + * @name: the node name + * + * Creation of a new node element. @ns is optional (NULL). + * + * Returns a pointer to the new node object. Uses xmlStrdup() to make + * copy of @name. + */ +xmlNodePtr +xmlNewNode(xmlNsPtr ns, const xmlChar *name) { + xmlNodePtr cur; + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewNode : name == NULL\n"); +#endif + return(NULL); + } + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building node"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_ELEMENT_NODE; + + cur->name = xmlStrdup(name); + cur->ns = ns; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +/** + * xmlNewNodeEatName: + * @ns: namespace if any + * @name: the node name + * + * Creation of a new node element. @ns is optional (NULL). + * + * Returns a pointer to the new node object, with pointer @name as + * new node's name. Use xmlNewNode() if a copy of @name string is + * is needed as new node's name. + */ +xmlNodePtr +xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) { + xmlNodePtr cur; + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewNode : name == NULL\n"); +#endif + return(NULL); + } + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building node"); + /* we can't check here that name comes from the doc dictionary */ + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_ELEMENT_NODE; + + cur->name = name; + cur->ns = ns; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)cur); + return(cur); +} + +/** + * xmlNewDocNode: + * @doc: the document + * @ns: namespace if any + * @name: the node name + * @content: the XML text content if any + * + * Creation of a new node element within a document. @ns and @content + * are optional (NULL). + * NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities + * references, but XML special chars need to be escaped first by using + * xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't + * need entities support. + * + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, + const xmlChar *name, const xmlChar *content) { + xmlNodePtr cur; + + if ((doc != NULL) && (doc->dict != NULL)) + cur = xmlNewNodeEatName(ns, (xmlChar *) + xmlDictLookup(doc->dict, name, -1)); + else + cur = xmlNewNode(ns, name); + if (cur != NULL) { + cur->doc = doc; + if (content != NULL) { + cur->children = xmlStringGetNodeList(doc, content); + UPDATE_LAST_CHILD_AND_PARENT(cur) + } + } + + return(cur); +} + +/** + * xmlNewDocNodeEatName: + * @doc: the document + * @ns: namespace if any + * @name: the node name + * @content: the XML text content if any + * + * Creation of a new node element within a document. @ns and @content + * are optional (NULL). + * NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities + * references, but XML special chars need to be escaped first by using + * xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't + * need entities support. + * + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns, + xmlChar *name, const xmlChar *content) { + xmlNodePtr cur; + + cur = xmlNewNodeEatName(ns, name); + if (cur != NULL) { + cur->doc = doc; + if (content != NULL) { + cur->children = xmlStringGetNodeList(doc, content); + UPDATE_LAST_CHILD_AND_PARENT(cur) + } + } else { + /* if name don't come from the doc dictionary free it here */ + if ((name != NULL) && (doc != NULL) && + (!(xmlDictOwns(doc->dict, name)))) + xmlFree(name); + } + return(cur); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlNewDocRawNode: + * @doc: the document + * @ns: namespace if any + * @name: the node name + * @content: the text content if any + * + * Creation of a new node element within a document. @ns and @content + * are optional (NULL). + * + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocRawNode(xmlDocPtr doc, xmlNsPtr ns, + const xmlChar *name, const xmlChar *content) { + xmlNodePtr cur; + + cur = xmlNewDocNode(doc, ns, name, NULL); + if (cur != NULL) { + cur->doc = doc; + if (content != NULL) { + cur->children = xmlNewDocText(doc, content); + UPDATE_LAST_CHILD_AND_PARENT(cur) + } + } + return(cur); +} + +/** + * xmlNewDocFragment: + * @doc: the document owning the fragment + * + * Creation of a new Fragment node. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocFragment(xmlDocPtr doc) { + xmlNodePtr cur; + + /* + * Allocate a new DocumentFragment node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building fragment"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_DOCUMENT_FRAG_NODE; + + cur->doc = doc; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNewText: + * @content: the text content + * + * Creation of a new text node. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewText(const xmlChar *content) { + xmlNodePtr cur; + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building text"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_TEXT_NODE; + + cur->name = xmlStringText; + if (content != NULL) { + cur->content = xmlStrdup(content); + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlNewTextChild: + * @parent: the parent node + * @ns: a namespace if any + * @name: the name of the child + * @content: the text content of the child if any. + * + * Creation of a new child element, added at the end of @parent children list. + * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly + * created element inherits the namespace of @parent. If @content is non NULL, + * a child TEXT node will be created containing the string @content. + * NOTE: Use xmlNewChild() if @content will contain entities that need to be + * preserved. Use this function, xmlNewTextChild(), if you need to ensure that + * reserved XML chars that might appear in @content, such as the ampersand, + * greater-than or less-than signs, are automatically replaced by their XML + * escaped entity representations. + * + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns, + const xmlChar *name, const xmlChar *content) { + xmlNodePtr cur, prev; + + if (parent == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewTextChild : parent == NULL\n"); +#endif + return(NULL); + } + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewTextChild : name == NULL\n"); +#endif + return(NULL); + } + + /* + * Allocate a new node + */ + if (parent->type == XML_ELEMENT_NODE) { + if (ns == NULL) + cur = xmlNewDocRawNode(parent->doc, parent->ns, name, content); + else + cur = xmlNewDocRawNode(parent->doc, ns, name, content); + } else if ((parent->type == XML_DOCUMENT_NODE) || + (parent->type == XML_HTML_DOCUMENT_NODE)) { + if (ns == NULL) + cur = xmlNewDocRawNode((xmlDocPtr) parent, NULL, name, content); + else + cur = xmlNewDocRawNode((xmlDocPtr) parent, ns, name, content); + } else if (parent->type == XML_DOCUMENT_FRAG_NODE) { + cur = xmlNewDocRawNode( parent->doc, ns, name, content); + } else { + return(NULL); + } + if (cur == NULL) return(NULL); + + /* + * add the new element at the end of the children list. + */ + cur->type = XML_ELEMENT_NODE; + cur->parent = parent; + cur->doc = parent->doc; + if (parent->children == NULL) { + parent->children = cur; + parent->last = cur; + } else { + prev = parent->last; + prev->next = cur; + cur->prev = prev; + parent->last = cur; + } + + return(cur); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNewCharRef: + * @doc: the document + * @name: the char ref string, starting with # or "&# ... ;" + * + * Creation of a new character reference node. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) { + xmlNodePtr cur; + + if (name == NULL) + return(NULL); + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building character reference"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_ENTITY_REF_NODE; + + cur->doc = doc; + if (name[0] == '&') { + int len; + name++; + len = xmlStrlen(name); + if (name[len - 1] == ';') + cur->name = xmlStrndup(name, len - 1); + else + cur->name = xmlStrndup(name, len); + } else + cur->name = xmlStrdup(name); + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +/** + * xmlNewReference: + * @doc: the document + * @name: the reference name, or the reference string with & and ; + * + * Creation of a new reference node. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewReference(const xmlDoc *doc, const xmlChar *name) { + xmlNodePtr cur; + xmlEntityPtr ent; + + if (name == NULL) + return(NULL); + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building reference"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_ENTITY_REF_NODE; + + cur->doc = (xmlDoc *)doc; + if (name[0] == '&') { + int len; + name++; + len = xmlStrlen(name); + if (name[len - 1] == ';') + cur->name = xmlStrndup(name, len - 1); + else + cur->name = xmlStrndup(name, len); + } else + cur->name = xmlStrdup(name); + + ent = xmlGetDocEntity(doc, cur->name); + if (ent != NULL) { + cur->content = ent->content; + /* + * The parent pointer in entity is a DTD pointer and thus is NOT + * updated. Not sure if this is 100% correct. + * -George + */ + cur->children = (xmlNodePtr) ent; + cur->last = (xmlNodePtr) ent; + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +/** + * xmlNewDocText: + * @doc: the document + * @content: the text content + * + * Creation of a new text node within a document. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocText(const xmlDoc *doc, const xmlChar *content) { + xmlNodePtr cur; + + cur = xmlNewText(content); + if (cur != NULL) cur->doc = (xmlDoc *)doc; + return(cur); +} + +/** + * xmlNewTextLen: + * @content: the text content + * @len: the text len. + * + * Creation of a new text node with an extra parameter for the content's length + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewTextLen(const xmlChar *content, int len) { + xmlNodePtr cur; + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building text"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_TEXT_NODE; + + cur->name = xmlStringText; + if (content != NULL) { + cur->content = xmlStrndup(content, len); + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +/** + * xmlNewDocTextLen: + * @doc: the document + * @content: the text content + * @len: the text len. + * + * Creation of a new text node with an extra content length parameter. The + * text node pertain to a given document. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocTextLen(xmlDocPtr doc, const xmlChar *content, int len) { + xmlNodePtr cur; + + cur = xmlNewTextLen(content, len); + if (cur != NULL) cur->doc = doc; + return(cur); +} + +/** + * xmlNewComment: + * @content: the comment content + * + * Creation of a new node containing a comment. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewComment(const xmlChar *content) { + xmlNodePtr cur; + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building comment"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_COMMENT_NODE; + + cur->name = xmlStringComment; + if (content != NULL) { + cur->content = xmlStrdup(content); + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +/** + * xmlNewCDataBlock: + * @doc: the document + * @content: the CDATA block content content + * @len: the length of the block + * + * Creation of a new node containing a CDATA block. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len) { + xmlNodePtr cur; + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlTreeErrMemory("building CDATA"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_CDATA_SECTION_NODE; + cur->doc = doc; + + if (content != NULL) { + cur->content = xmlStrndup(content, len); + } + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + return(cur); +} + +/** + * xmlNewDocComment: + * @doc: the document + * @content: the comment content + * + * Creation of a new node containing a comment within a document. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocComment(xmlDocPtr doc, const xmlChar *content) { + xmlNodePtr cur; + + cur = xmlNewComment(content); + if (cur != NULL) cur->doc = doc; + return(cur); +} + +/** + * xmlSetTreeDoc: + * @tree: the top element + * @doc: the document + * + * update all nodes under the tree to point to the right document + */ +void +xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) { + xmlAttrPtr prop; + + if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL)) + return; + if (tree->doc != doc) { + if(tree->type == XML_ELEMENT_NODE) { + prop = tree->properties; + while (prop != NULL) { + if (prop->atype == XML_ATTRIBUTE_ID) { + xmlRemoveID(tree->doc, prop); + } + + prop->doc = doc; + xmlSetListDoc(prop->children, doc); + + /* + * TODO: ID attributes should be also added to the new + * document, but this breaks things like xmlReplaceNode. + * The underlying problem is that xmlRemoveID is only called + * if a node is destroyed, not if it's unlinked. + */ +#if 0 + if (xmlIsID(doc, tree, prop)) { + xmlChar *idVal = xmlNodeListGetString(doc, prop->children, + 1); + xmlAddID(NULL, doc, idVal, prop); + } +#endif + + prop = prop->next; + } + } + if (tree->children != NULL) + xmlSetListDoc(tree->children, doc); + tree->doc = doc; + } +} + +/** + * xmlSetListDoc: + * @list: the first element + * @doc: the document + * + * update all nodes in the list to point to the right document + */ +void +xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc) { + xmlNodePtr cur; + + if ((list == NULL) || (list->type == XML_NAMESPACE_DECL)) + return; + cur = list; + while (cur != NULL) { + if (cur->doc != doc) + xmlSetTreeDoc(cur, doc); + cur = cur->next; + } +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlNewChild: + * @parent: the parent node + * @ns: a namespace if any + * @name: the name of the child + * @content: the XML content of the child if any. + * + * Creation of a new child element, added at the end of @parent children list. + * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly + * created element inherits the namespace of @parent. If @content is non NULL, + * a child list containing the TEXTs and ENTITY_REFs node will be created. + * NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity + * references. XML special chars must be escaped first by using + * xmlEncodeEntitiesReentrant(), or xmlNewTextChild() should be used. + * + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewChild(xmlNodePtr parent, xmlNsPtr ns, + const xmlChar *name, const xmlChar *content) { + xmlNodePtr cur, prev; + + if (parent == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewChild : parent == NULL\n"); +#endif + return(NULL); + } + + if (name == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewChild : name == NULL\n"); +#endif + return(NULL); + } + + /* + * Allocate a new node + */ + if (parent->type == XML_ELEMENT_NODE) { + if (ns == NULL) + cur = xmlNewDocNode(parent->doc, parent->ns, name, content); + else + cur = xmlNewDocNode(parent->doc, ns, name, content); + } else if ((parent->type == XML_DOCUMENT_NODE) || + (parent->type == XML_HTML_DOCUMENT_NODE)) { + if (ns == NULL) + cur = xmlNewDocNode((xmlDocPtr) parent, NULL, name, content); + else + cur = xmlNewDocNode((xmlDocPtr) parent, ns, name, content); + } else if (parent->type == XML_DOCUMENT_FRAG_NODE) { + cur = xmlNewDocNode( parent->doc, ns, name, content); + } else { + return(NULL); + } + if (cur == NULL) return(NULL); + + /* + * add the new element at the end of the children list. + */ + cur->type = XML_ELEMENT_NODE; + cur->parent = parent; + cur->doc = parent->doc; + if (parent->children == NULL) { + parent->children = cur; + parent->last = cur; + } else { + prev = parent->last; + prev->next = cur; + cur->prev = prev; + parent->last = cur; + } + + return(cur); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlAddPropSibling: + * @prev: the attribute to which @prop is added after + * @cur: the base attribute passed to calling function + * @prop: the new attribute + * + * Add a new attribute after @prev using @cur as base attribute. + * When inserting before @cur, @prev is passed as @cur->prev. + * When inserting after @cur, @prev is passed as @cur. + * If an existing attribute is found it is destroyed prior to adding @prop. + * + * Returns the attribute being inserted or NULL in case of error. + */ +static xmlNodePtr +xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) { + xmlAttrPtr attr; + + if ((cur == NULL) || (cur->type != XML_ATTRIBUTE_NODE) || + (prop == NULL) || (prop->type != XML_ATTRIBUTE_NODE) || + ((prev != NULL) && (prev->type != XML_ATTRIBUTE_NODE))) + return(NULL); + + /* check if an attribute with the same name exists */ + if (prop->ns == NULL) + attr = xmlHasNsProp(cur->parent, prop->name, NULL); + else + attr = xmlHasNsProp(cur->parent, prop->name, prop->ns->href); + + if (prop->doc != cur->doc) { + xmlSetTreeDoc(prop, cur->doc); + } + prop->parent = cur->parent; + prop->prev = prev; + if (prev != NULL) { + prop->next = prev->next; + prev->next = prop; + if (prop->next) + prop->next->prev = prop; + } else { + prop->next = cur; + cur->prev = prop; + } + if (prop->prev == NULL && prop->parent != NULL) + prop->parent->properties = (xmlAttrPtr) prop; + if ((attr != NULL) && (attr->type != XML_ATTRIBUTE_DECL)) { + /* different instance, destroy it (attributes must be unique) */ + xmlRemoveProp((xmlAttrPtr) attr); + } + return prop; +} + +/** + * xmlAddNextSibling: + * @cur: the child node + * @elem: the new node + * + * Add a new node @elem as the next sibling of @cur + * If the new node was already inserted in a document it is + * first unlinked from its existing context. + * As a result of text merging @elem may be freed. + * If the new node is ATTRIBUTE, it is added into properties instead of children. + * If there is an attribute with equal name, it is first destroyed. + * + * Returns the new node or NULL in case of error. + */ +xmlNodePtr +xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) { + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddNextSibling : cur == NULL\n"); +#endif + return(NULL); + } + if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddNextSibling : elem == NULL\n"); +#endif + return(NULL); + } + + if (cur == elem) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddNextSibling : cur == elem\n"); +#endif + return(NULL); + } + + xmlUnlinkNode(elem); + + if (elem->type == XML_TEXT_NODE) { + if (cur->type == XML_TEXT_NODE) { + xmlNodeAddContent(cur, elem->content); + xmlFreeNode(elem); + return(cur); + } + if ((cur->next != NULL) && (cur->next->type == XML_TEXT_NODE) && + (cur->name == cur->next->name)) { + xmlChar *tmp; + + tmp = xmlStrdup(elem->content); + tmp = xmlStrcat(tmp, cur->next->content); + xmlNodeSetContent(cur->next, tmp); + xmlFree(tmp); + xmlFreeNode(elem); + return(cur->next); + } + } else if (elem->type == XML_ATTRIBUTE_NODE) { + return xmlAddPropSibling(cur, cur, elem); + } + + if (elem->doc != cur->doc) { + xmlSetTreeDoc(elem, cur->doc); + } + elem->parent = cur->parent; + elem->prev = cur; + elem->next = cur->next; + cur->next = elem; + if (elem->next != NULL) + elem->next->prev = elem; + if ((elem->parent != NULL) && (elem->parent->last == cur)) + elem->parent->last = elem; + return(elem); +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) +/** + * xmlAddPrevSibling: + * @cur: the child node + * @elem: the new node + * + * Add a new node @elem as the previous sibling of @cur + * merging adjacent TEXT nodes (@elem may be freed) + * If the new node was already inserted in a document it is + * first unlinked from its existing context. + * If the new node is ATTRIBUTE, it is added into properties instead of children. + * If there is an attribute with equal name, it is first destroyed. + * + * Returns the new node or NULL in case of error. + */ +xmlNodePtr +xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) { + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddPrevSibling : cur == NULL\n"); +#endif + return(NULL); + } + if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddPrevSibling : elem == NULL\n"); +#endif + return(NULL); + } + + if (cur == elem) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddPrevSibling : cur == elem\n"); +#endif + return(NULL); + } + + xmlUnlinkNode(elem); + + if (elem->type == XML_TEXT_NODE) { + if (cur->type == XML_TEXT_NODE) { + xmlChar *tmp; + + tmp = xmlStrdup(elem->content); + tmp = xmlStrcat(tmp, cur->content); + xmlNodeSetContent(cur, tmp); + xmlFree(tmp); + xmlFreeNode(elem); + return(cur); + } + if ((cur->prev != NULL) && (cur->prev->type == XML_TEXT_NODE) && + (cur->name == cur->prev->name)) { + xmlNodeAddContent(cur->prev, elem->content); + xmlFreeNode(elem); + return(cur->prev); + } + } else if (elem->type == XML_ATTRIBUTE_NODE) { + return xmlAddPropSibling(cur->prev, cur, elem); + } + + if (elem->doc != cur->doc) { + xmlSetTreeDoc(elem, cur->doc); + } + elem->parent = cur->parent; + elem->next = cur; + elem->prev = cur->prev; + cur->prev = elem; + if (elem->prev != NULL) + elem->prev->next = elem; + if ((elem->parent != NULL) && (elem->parent->children == cur)) { + elem->parent->children = elem; + } + return(elem); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlAddSibling: + * @cur: the child node + * @elem: the new node + * + * Add a new element @elem to the list of siblings of @cur + * merging adjacent TEXT nodes (@elem may be freed) + * If the new element was already inserted in a document it is + * first unlinked from its existing context. + * + * Returns the new element or NULL in case of error. + */ +xmlNodePtr +xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) { + xmlNodePtr parent; + + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddSibling : cur == NULL\n"); +#endif + return(NULL); + } + + if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddSibling : elem == NULL\n"); +#endif + return(NULL); + } + + if (cur == elem) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddSibling : cur == elem\n"); +#endif + return(NULL); + } + + /* + * Constant time is we can rely on the ->parent->last to find + * the last sibling. + */ + if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) && + (cur->parent->children != NULL) && + (cur->parent->last != NULL) && + (cur->parent->last->next == NULL)) { + cur = cur->parent->last; + } else { + while (cur->next != NULL) cur = cur->next; + } + + xmlUnlinkNode(elem); + + if ((cur->type == XML_TEXT_NODE) && (elem->type == XML_TEXT_NODE) && + (cur->name == elem->name)) { + xmlNodeAddContent(cur, elem->content); + xmlFreeNode(elem); + return(cur); + } else if (elem->type == XML_ATTRIBUTE_NODE) { + return xmlAddPropSibling(cur, cur, elem); + } + + if (elem->doc != cur->doc) { + xmlSetTreeDoc(elem, cur->doc); + } + parent = cur->parent; + elem->prev = cur; + elem->next = NULL; + elem->parent = parent; + cur->next = elem; + if (parent != NULL) + parent->last = elem; + + return(elem); +} + +/** + * xmlAddChildList: + * @parent: the parent node + * @cur: the first node in the list + * + * Add a list of node at the end of the child list of the parent + * merging adjacent TEXT nodes (@cur may be freed) + * + * Returns the last child or NULL in case of error. + */ +xmlNodePtr +xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) { + xmlNodePtr prev; + + if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddChildList : parent == NULL\n"); +#endif + return(NULL); + } + + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddChildList : child == NULL\n"); +#endif + return(NULL); + } + + if ((cur->doc != NULL) && (parent->doc != NULL) && + (cur->doc != parent->doc)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "Elements moved to a different document\n"); +#endif + } + + /* + * add the first element at the end of the children list. + */ + + if (parent->children == NULL) { + parent->children = cur; + } else { + /* + * If cur and parent->last both are TEXT nodes, then merge them. + */ + if ((cur->type == XML_TEXT_NODE) && + (parent->last->type == XML_TEXT_NODE) && + (cur->name == parent->last->name)) { + xmlNodeAddContent(parent->last, cur->content); + /* + * if it's the only child, nothing more to be done. + */ + if (cur->next == NULL) { + xmlFreeNode(cur); + return(parent->last); + } + prev = cur; + cur = cur->next; + xmlFreeNode(prev); + } + prev = parent->last; + prev->next = cur; + cur->prev = prev; + } + while (cur->next != NULL) { + cur->parent = parent; + if (cur->doc != parent->doc) { + xmlSetTreeDoc(cur, parent->doc); + } + cur = cur->next; + } + cur->parent = parent; + /* the parent may not be linked to a doc ! */ + if (cur->doc != parent->doc) { + xmlSetTreeDoc(cur, parent->doc); + } + parent->last = cur; + + return(cur); +} + +/** + * xmlAddChild: + * @parent: the parent node + * @cur: the child node + * + * Add a new node to @parent, at the end of the child (or property) list + * merging adjacent TEXT nodes (in which case @cur is freed) + * If the new node is ATTRIBUTE, it is added into properties instead of children. + * If there is an attribute with equal name, it is first destroyed. + * + * Returns the child or NULL in case of error. + */ +xmlNodePtr +xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) { + xmlNodePtr prev; + + if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddChild : parent == NULL\n"); +#endif + return(NULL); + } + + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddChild : child == NULL\n"); +#endif + return(NULL); + } + + if (parent == cur) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlAddChild : parent == cur\n"); +#endif + return(NULL); + } + /* + * If cur is a TEXT node, merge its content with adjacent TEXT nodes + * cur is then freed. + */ + if (cur->type == XML_TEXT_NODE) { + if ((parent->type == XML_TEXT_NODE) && + (parent->content != NULL) && + (parent->name == cur->name)) { + xmlNodeAddContent(parent, cur->content); + xmlFreeNode(cur); + return(parent); + } + if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE) && + (parent->last->name == cur->name) && + (parent->last != cur)) { + xmlNodeAddContent(parent->last, cur->content); + xmlFreeNode(cur); + return(parent->last); + } + } + + /* + * add the new element at the end of the children list. + */ + prev = cur->parent; + cur->parent = parent; + if (cur->doc != parent->doc) { + xmlSetTreeDoc(cur, parent->doc); + } + /* this check prevents a loop on tree-traversions if a developer + * tries to add a node to its parent multiple times + */ + if (prev == parent) + return(cur); + + /* + * Coalescing + */ + if ((parent->type == XML_TEXT_NODE) && + (parent->content != NULL) && + (parent != cur)) { + xmlNodeAddContent(parent, cur->content); + xmlFreeNode(cur); + return(parent); + } + if (cur->type == XML_ATTRIBUTE_NODE) { + if (parent->type != XML_ELEMENT_NODE) + return(NULL); + if (parent->properties != NULL) { + /* check if an attribute with the same name exists */ + xmlAttrPtr lastattr; + + if (cur->ns == NULL) + lastattr = xmlHasNsProp(parent, cur->name, NULL); + else + lastattr = xmlHasNsProp(parent, cur->name, cur->ns->href); + if ((lastattr != NULL) && (lastattr != (xmlAttrPtr) cur) && (lastattr->type != XML_ATTRIBUTE_DECL)) { + /* different instance, destroy it (attributes must be unique) */ + xmlUnlinkNode((xmlNodePtr) lastattr); + xmlFreeProp(lastattr); + } + if (lastattr == (xmlAttrPtr) cur) + return(cur); + + } + if (parent->properties == NULL) { + parent->properties = (xmlAttrPtr) cur; + } else { + /* find the end */ + xmlAttrPtr lastattr = parent->properties; + while (lastattr->next != NULL) { + lastattr = lastattr->next; + } + lastattr->next = (xmlAttrPtr) cur; + ((xmlAttrPtr) cur)->prev = lastattr; + } + } else { + if (parent->children == NULL) { + parent->children = cur; + parent->last = cur; + } else { + prev = parent->last; + prev->next = cur; + cur->prev = prev; + parent->last = cur; + } + } + return(cur); +} + +/** + * xmlGetLastChild: + * @parent: the parent node + * + * Search the last child of a node. + * Returns the last child or NULL if none. + */ +xmlNodePtr +xmlGetLastChild(const xmlNode *parent) { + if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlGetLastChild : parent == NULL\n"); +#endif + return(NULL); + } + return(parent->last); +} + +#ifdef LIBXML_TREE_ENABLED +/* + * 5 interfaces from DOM ElementTraversal + */ + +/** + * xmlChildElementCount: + * @parent: the parent node + * + * Finds the current number of child nodes of that element which are + * element nodes. + * Note the handling of entities references is different than in + * the W3C DOM element traversal spec since we don't have back reference + * from entities content to entities references. + * + * Returns the count of element child or 0 if not available + */ +unsigned long +xmlChildElementCount(xmlNodePtr parent) { + unsigned long ret = 0; + xmlNodePtr cur = NULL; + + if (parent == NULL) + return(0); + switch (parent->type) { + case XML_ELEMENT_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_HTML_DOCUMENT_NODE: + cur = parent->children; + break; + default: + return(0); + } + while (cur != NULL) { + if (cur->type == XML_ELEMENT_NODE) + ret++; + cur = cur->next; + } + return(ret); +} + +/** + * xmlFirstElementChild: + * @parent: the parent node + * + * Finds the first child node of that element which is a Element node + * Note the handling of entities references is different than in + * the W3C DOM element traversal spec since we don't have back reference + * from entities content to entities references. + * + * Returns the first element child or NULL if not available + */ +xmlNodePtr +xmlFirstElementChild(xmlNodePtr parent) { + xmlNodePtr cur = NULL; + + if (parent == NULL) + return(NULL); + switch (parent->type) { + case XML_ELEMENT_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_HTML_DOCUMENT_NODE: + cur = parent->children; + break; + default: + return(NULL); + } + while (cur != NULL) { + if (cur->type == XML_ELEMENT_NODE) + return(cur); + cur = cur->next; + } + return(NULL); +} + +/** + * xmlLastElementChild: + * @parent: the parent node + * + * Finds the last child node of that element which is a Element node + * Note the handling of entities references is different than in + * the W3C DOM element traversal spec since we don't have back reference + * from entities content to entities references. + * + * Returns the last element child or NULL if not available + */ +xmlNodePtr +xmlLastElementChild(xmlNodePtr parent) { + xmlNodePtr cur = NULL; + + if (parent == NULL) + return(NULL); + switch (parent->type) { + case XML_ELEMENT_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_HTML_DOCUMENT_NODE: + cur = parent->last; + break; + default: + return(NULL); + } + while (cur != NULL) { + if (cur->type == XML_ELEMENT_NODE) + return(cur); + cur = cur->prev; + } + return(NULL); +} + +/** + * xmlPreviousElementSibling: + * @node: the current node + * + * Finds the first closest previous sibling of the node which is an + * element node. + * Note the handling of entities references is different than in + * the W3C DOM element traversal spec since we don't have back reference + * from entities content to entities references. + * + * Returns the previous element sibling or NULL if not available + */ +xmlNodePtr +xmlPreviousElementSibling(xmlNodePtr node) { + if (node == NULL) + return(NULL); + switch (node->type) { + case XML_ELEMENT_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + node = node->prev; + break; + default: + return(NULL); + } + while (node != NULL) { + if (node->type == XML_ELEMENT_NODE) + return(node); + node = node->prev; + } + return(NULL); +} + +/** + * xmlNextElementSibling: + * @node: the current node + * + * Finds the first closest next sibling of the node which is an + * element node. + * Note the handling of entities references is different than in + * the W3C DOM element traversal spec since we don't have back reference + * from entities content to entities references. + * + * Returns the next element sibling or NULL if not available + */ +xmlNodePtr +xmlNextElementSibling(xmlNodePtr node) { + if (node == NULL) + return(NULL); + switch (node->type) { + case XML_ELEMENT_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_DTD_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + node = node->next; + break; + default: + return(NULL); + } + while (node != NULL) { + if (node->type == XML_ELEMENT_NODE) + return(node); + node = node->next; + } + return(NULL); +} + +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlFreeNodeList: + * @cur: the first node in the list + * + * Free a node and all its siblings, this is a recursive behaviour, all + * the children are freed too. + */ +void +xmlFreeNodeList(xmlNodePtr cur) { + xmlNodePtr next; + xmlNodePtr parent; + xmlDictPtr dict = NULL; + size_t depth = 0; + + if (cur == NULL) return; + if (cur->type == XML_NAMESPACE_DECL) { + xmlFreeNsList((xmlNsPtr) cur); + return; + } + if ((cur->type == XML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (cur->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (cur->type == XML_HTML_DOCUMENT_NODE)) { + xmlFreeDoc((xmlDocPtr) cur); + return; + } + if (cur->doc != NULL) dict = cur->doc->dict; + while (1) { + while ((cur->children != NULL) && + (cur->type != XML_DTD_NODE) && + (cur->type != XML_ENTITY_REF_NODE)) { + cur = cur->children; + depth += 1; + } + + next = cur->next; + parent = cur->parent; + if (cur->type != XML_DTD_NODE) { + + if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) + xmlDeregisterNodeDefaultValue(cur); + + if (((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_XINCLUDE_START) || + (cur->type == XML_XINCLUDE_END)) && + (cur->properties != NULL)) + xmlFreePropList(cur->properties); + if ((cur->type != XML_ELEMENT_NODE) && + (cur->type != XML_XINCLUDE_START) && + (cur->type != XML_XINCLUDE_END) && + (cur->type != XML_ENTITY_REF_NODE) && + (cur->type != XML_DOCUMENT_NODE) && +#ifdef LIBXML_DOCB_ENABLED + (cur->type != XML_DOCB_DOCUMENT_NODE) && +#endif + (cur->type != XML_HTML_DOCUMENT_NODE) && + (cur->content != (xmlChar *) &(cur->properties))) { + DICT_FREE(cur->content) + } + if (((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_XINCLUDE_START) || + (cur->type == XML_XINCLUDE_END)) && + (cur->nsDef != NULL)) + xmlFreeNsList(cur->nsDef); + + /* + * When a node is a text node or a comment, it uses a global static + * variable for the name of the node. + * Otherwise the node name might come from the document's + * dictionary + */ + if ((cur->name != NULL) && + (cur->type != XML_TEXT_NODE) && + (cur->type != XML_COMMENT_NODE)) + DICT_FREE(cur->name) + xmlFree(cur); + } + + if (next != NULL) { + cur = next; + } else { + if ((depth == 0) || (parent == NULL)) + break; + depth -= 1; + cur = parent; + cur->children = NULL; + } + } +} + +/** + * xmlFreeNode: + * @cur: the node + * + * Free a node, this is a recursive behaviour, all the children are freed too. + * This doesn't unlink the child from the list, use xmlUnlinkNode() first. + */ +void +xmlFreeNode(xmlNodePtr cur) { + xmlDictPtr dict = NULL; + + if (cur == NULL) return; + + /* use xmlFreeDtd for DTD nodes */ + if (cur->type == XML_DTD_NODE) { + xmlFreeDtd((xmlDtdPtr) cur); + return; + } + if (cur->type == XML_NAMESPACE_DECL) { + xmlFreeNs((xmlNsPtr) cur); + return; + } + if (cur->type == XML_ATTRIBUTE_NODE) { + xmlFreeProp((xmlAttrPtr) cur); + return; + } + + if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) + xmlDeregisterNodeDefaultValue(cur); + + if (cur->doc != NULL) dict = cur->doc->dict; + + if (cur->type == XML_ENTITY_DECL) { + xmlEntityPtr ent = (xmlEntityPtr) cur; + DICT_FREE(ent->SystemID); + DICT_FREE(ent->ExternalID); + } + if ((cur->children != NULL) && + (cur->type != XML_ENTITY_REF_NODE)) + xmlFreeNodeList(cur->children); + if (((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_XINCLUDE_START) || + (cur->type == XML_XINCLUDE_END)) && + (cur->properties != NULL)) + xmlFreePropList(cur->properties); + if ((cur->type != XML_ELEMENT_NODE) && + (cur->content != NULL) && + (cur->type != XML_ENTITY_REF_NODE) && + (cur->type != XML_XINCLUDE_END) && + (cur->type != XML_XINCLUDE_START) && + (cur->content != (xmlChar *) &(cur->properties))) { + DICT_FREE(cur->content) + } + + /* + * When a node is a text node or a comment, it uses a global static + * variable for the name of the node. + * Otherwise the node name might come from the document's dictionary + */ + if ((cur->name != NULL) && + (cur->type != XML_TEXT_NODE) && + (cur->type != XML_COMMENT_NODE)) + DICT_FREE(cur->name) + + if (((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_XINCLUDE_START) || + (cur->type == XML_XINCLUDE_END)) && + (cur->nsDef != NULL)) + xmlFreeNsList(cur->nsDef); + xmlFree(cur); +} + +/** + * xmlUnlinkNode: + * @cur: the node + * + * Unlink a node from it's current context, the node is not freed + * If one need to free the node, use xmlFreeNode() routine after the + * unlink to discard it. + * Note that namespace nodes can't be unlinked as they do not have + * pointer to their parent. + */ +void +xmlUnlinkNode(xmlNodePtr cur) { + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlUnlinkNode : node == NULL\n"); +#endif + return; + } + if (cur->type == XML_NAMESPACE_DECL) + return; + if (cur->type == XML_DTD_NODE) { + xmlDocPtr doc; + doc = cur->doc; + if (doc != NULL) { + if (doc->intSubset == (xmlDtdPtr) cur) + doc->intSubset = NULL; + if (doc->extSubset == (xmlDtdPtr) cur) + doc->extSubset = NULL; + } + } + if (cur->type == XML_ENTITY_DECL) { + xmlDocPtr doc; + doc = cur->doc; + if (doc != NULL) { + if (doc->intSubset != NULL) { + if (xmlHashLookup(doc->intSubset->entities, cur->name) == cur) + xmlHashRemoveEntry(doc->intSubset->entities, cur->name, + NULL); + if (xmlHashLookup(doc->intSubset->pentities, cur->name) == cur) + xmlHashRemoveEntry(doc->intSubset->pentities, cur->name, + NULL); + } + if (doc->extSubset != NULL) { + if (xmlHashLookup(doc->extSubset->entities, cur->name) == cur) + xmlHashRemoveEntry(doc->extSubset->entities, cur->name, + NULL); + if (xmlHashLookup(doc->extSubset->pentities, cur->name) == cur) + xmlHashRemoveEntry(doc->extSubset->pentities, cur->name, + NULL); + } + } + } + if (cur->parent != NULL) { + xmlNodePtr parent; + parent = cur->parent; + if (cur->type == XML_ATTRIBUTE_NODE) { + if (parent->properties == (xmlAttrPtr) cur) + parent->properties = ((xmlAttrPtr) cur)->next; + } else { + if (parent->children == cur) + parent->children = cur->next; + if (parent->last == cur) + parent->last = cur->prev; + } + cur->parent = NULL; + } + if (cur->next != NULL) + cur->next->prev = cur->prev; + if (cur->prev != NULL) + cur->prev->next = cur->next; + cur->next = cur->prev = NULL; +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +/** + * xmlReplaceNode: + * @old: the old node + * @cur: the node + * + * Unlink the old node from its current context, prune the new one + * at the same place. If @cur was already inserted in a document it is + * first unlinked from its existing context. + * + * Returns the @old node + */ +xmlNodePtr +xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) { + if (old == cur) return(NULL); + if ((old == NULL) || (old->type == XML_NAMESPACE_DECL) || + (old->parent == NULL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlReplaceNode : old == NULL or without parent\n"); +#endif + return(NULL); + } + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) { + xmlUnlinkNode(old); + return(old); + } + if (cur == old) { + return(old); + } + if ((old->type==XML_ATTRIBUTE_NODE) && (cur->type!=XML_ATTRIBUTE_NODE)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlReplaceNode : Trying to replace attribute node with other node type\n"); +#endif + return(old); + } + if ((cur->type==XML_ATTRIBUTE_NODE) && (old->type!=XML_ATTRIBUTE_NODE)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlReplaceNode : Trying to replace a non-attribute node with attribute node\n"); +#endif + return(old); + } + xmlUnlinkNode(cur); + xmlSetTreeDoc(cur, old->doc); + cur->parent = old->parent; + cur->next = old->next; + if (cur->next != NULL) + cur->next->prev = cur; + cur->prev = old->prev; + if (cur->prev != NULL) + cur->prev->next = cur; + if (cur->parent != NULL) { + if (cur->type == XML_ATTRIBUTE_NODE) { + if (cur->parent->properties == (xmlAttrPtr)old) + cur->parent->properties = ((xmlAttrPtr) cur); + } else { + if (cur->parent->children == old) + cur->parent->children = cur; + if (cur->parent->last == old) + cur->parent->last = cur; + } + } + old->next = old->prev = NULL; + old->parent = NULL; + return(old); +} +#endif /* LIBXML_TREE_ENABLED */ + +/************************************************************************ + * * + * Copy operations * + * * + ************************************************************************/ + +/** + * xmlCopyNamespace: + * @cur: the namespace + * + * Do a copy of the namespace. + * + * Returns: a new #xmlNsPtr, or NULL in case of error. + */ +xmlNsPtr +xmlCopyNamespace(xmlNsPtr cur) { + xmlNsPtr ret; + + if (cur == NULL) return(NULL); + switch (cur->type) { + case XML_LOCAL_NAMESPACE: + ret = xmlNewNs(NULL, cur->href, cur->prefix); + break; + default: +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlCopyNamespace: invalid type %d\n", cur->type); +#endif + return(NULL); + } + return(ret); +} + +/** + * xmlCopyNamespaceList: + * @cur: the first namespace + * + * Do a copy of an namespace list. + * + * Returns: a new #xmlNsPtr, or NULL in case of error. + */ +xmlNsPtr +xmlCopyNamespaceList(xmlNsPtr cur) { + xmlNsPtr ret = NULL; + xmlNsPtr p = NULL,q; + + while (cur != NULL) { + q = xmlCopyNamespace(cur); + if (p == NULL) { + ret = p = q; + } else { + p->next = q; + p = q; + } + cur = cur->next; + } + return(ret); +} + +static xmlNodePtr +xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent); + +static xmlAttrPtr +xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) { + xmlAttrPtr ret; + + if (cur == NULL) return(NULL); + if ((target != NULL) && (target->type != XML_ELEMENT_NODE)) + return(NULL); + if (target != NULL) + ret = xmlNewDocProp(target->doc, cur->name, NULL); + else if (doc != NULL) + ret = xmlNewDocProp(doc, cur->name, NULL); + else if (cur->parent != NULL) + ret = xmlNewDocProp(cur->parent->doc, cur->name, NULL); + else if (cur->children != NULL) + ret = xmlNewDocProp(cur->children->doc, cur->name, NULL); + else + ret = xmlNewDocProp(NULL, cur->name, NULL); + if (ret == NULL) return(NULL); + ret->parent = target; + + if ((cur->ns != NULL) && (target != NULL)) { + xmlNsPtr ns; + + ns = xmlSearchNs(target->doc, target, cur->ns->prefix); + if (ns == NULL) { + /* + * Humm, we are copying an element whose namespace is defined + * out of the new tree scope. Search it in the original tree + * and add it at the top of the new tree + */ + ns = xmlSearchNs(cur->doc, cur->parent, cur->ns->prefix); + if (ns != NULL) { + xmlNodePtr root = target; + xmlNodePtr pred = NULL; + + while (root->parent != NULL) { + pred = root; + root = root->parent; + } + if (root == (xmlNodePtr) target->doc) { + /* correct possibly cycling above the document elt */ + root = pred; + } + ret->ns = xmlNewNs(root, ns->href, ns->prefix); + } + } else { + /* + * we have to find something appropriate here since + * we can't be sure, that the namespace we found is identified + * by the prefix + */ + if (xmlStrEqual(ns->href, cur->ns->href)) { + /* this is the nice case */ + ret->ns = ns; + } else { + /* + * we are in trouble: we need a new reconciled namespace. + * This is expensive + */ + ret->ns = xmlNewReconciledNs(target->doc, target, cur->ns); + } + } + + } else + ret->ns = NULL; + + if (cur->children != NULL) { + xmlNodePtr tmp; + + ret->children = xmlStaticCopyNodeList(cur->children, ret->doc, (xmlNodePtr) ret); + ret->last = NULL; + tmp = ret->children; + while (tmp != NULL) { + /* tmp->parent = (xmlNodePtr)ret; */ + if (tmp->next == NULL) + ret->last = tmp; + tmp = tmp->next; + } + } + /* + * Try to handle IDs + */ + if ((target!= NULL) && (cur!= NULL) && + (target->doc != NULL) && (cur->doc != NULL) && + (cur->doc->ids != NULL) && (cur->parent != NULL)) { + if (xmlIsID(cur->doc, cur->parent, cur)) { + xmlChar *id; + + id = xmlNodeListGetString(cur->doc, cur->children, 1); + if (id != NULL) { + xmlAddID(NULL, target->doc, id, ret); + xmlFree(id); + } + } + } + return(ret); +} + +/** + * xmlCopyProp: + * @target: the element where the attribute will be grafted + * @cur: the attribute + * + * Do a copy of the attribute. + * + * Returns: a new #xmlAttrPtr, or NULL in case of error. + */ +xmlAttrPtr +xmlCopyProp(xmlNodePtr target, xmlAttrPtr cur) { + return xmlCopyPropInternal(NULL, target, cur); +} + +/** + * xmlCopyPropList: + * @target: the element where the attributes will be grafted + * @cur: the first attribute + * + * Do a copy of an attribute list. + * + * Returns: a new #xmlAttrPtr, or NULL in case of error. + */ +xmlAttrPtr +xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) { + xmlAttrPtr ret = NULL; + xmlAttrPtr p = NULL,q; + + if ((target != NULL) && (target->type != XML_ELEMENT_NODE)) + return(NULL); + while (cur != NULL) { + q = xmlCopyProp(target, cur); + if (q == NULL) + return(NULL); + if (p == NULL) { + ret = p = q; + } else { + p->next = q; + q->prev = p; + p = q; + } + cur = cur->next; + } + return(ret); +} + +/* + * NOTE about the CopyNode operations ! + * + * They are split into external and internal parts for one + * tricky reason: namespaces. Doing a direct copy of a node + * say RPM:Copyright without changing the namespace pointer to + * something else can produce stale links. One way to do it is + * to keep a reference counter but this doesn't work as soon + * as one moves the element or the subtree out of the scope of + * the existing namespace. The actual solution seems to be to add + * a copy of the namespace at the top of the copied tree if + * not available in the subtree. + * Hence two functions, the public front-end call the inner ones + * The argument "recursive" normally indicates a recursive copy + * of the node with values 0 (no) and 1 (yes). For XInclude, + * however, we allow a value of 2 to indicate copy properties and + * namespace info, but don't recurse on children. + */ + +static xmlNodePtr +xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, + int extended) { + xmlNodePtr ret; + + if (node == NULL) return(NULL); + switch (node->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ELEMENT_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + case XML_ATTRIBUTE_NODE: + return((xmlNodePtr) xmlCopyPropInternal(doc, parent, (xmlAttrPtr) node)); + case XML_NAMESPACE_DECL: + return((xmlNodePtr) xmlCopyNamespaceList((xmlNsPtr) node)); + + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif +#ifdef LIBXML_TREE_ENABLED + return((xmlNodePtr) xmlCopyDoc((xmlDocPtr) node, extended)); +#endif /* LIBXML_TREE_ENABLED */ + case XML_DOCUMENT_TYPE_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + return(NULL); + } + + /* + * Allocate a new node and fill the fields. + */ + ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (ret == NULL) { + xmlTreeErrMemory("copying node"); + return(NULL); + } + memset(ret, 0, sizeof(xmlNode)); + ret->type = node->type; + + ret->doc = doc; + ret->parent = parent; + if (node->name == xmlStringText) + ret->name = xmlStringText; + else if (node->name == xmlStringTextNoenc) + ret->name = xmlStringTextNoenc; + else if (node->name == xmlStringComment) + ret->name = xmlStringComment; + else if (node->name != NULL) { + if ((doc != NULL) && (doc->dict != NULL)) + ret->name = xmlDictLookup(doc->dict, node->name, -1); + else + ret->name = xmlStrdup(node->name); + } + if ((node->type != XML_ELEMENT_NODE) && + (node->content != NULL) && + (node->type != XML_ENTITY_REF_NODE) && + (node->type != XML_XINCLUDE_END) && + (node->type != XML_XINCLUDE_START)) { + ret->content = xmlStrdup(node->content); + }else{ + if (node->type == XML_ELEMENT_NODE) + ret->line = node->line; + } + if (parent != NULL) { + xmlNodePtr tmp; + + /* + * this is a tricky part for the node register thing: + * in case ret does get coalesced in xmlAddChild + * the deregister-node callback is called; so we register ret now already + */ + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue((xmlNodePtr)ret); + + tmp = xmlAddChild(parent, ret); + /* node could have coalesced */ + if (tmp != ret) + return(tmp); + } + + if (!extended) + goto out; + if (((node->type == XML_ELEMENT_NODE) || + (node->type == XML_XINCLUDE_START)) && (node->nsDef != NULL)) + ret->nsDef = xmlCopyNamespaceList(node->nsDef); + + if (node->ns != NULL) { + xmlNsPtr ns; + + ns = xmlSearchNs(doc, ret, node->ns->prefix); + if (ns == NULL) { + /* + * Humm, we are copying an element whose namespace is defined + * out of the new tree scope. Search it in the original tree + * and add it at the top of the new tree + */ + ns = xmlSearchNs(node->doc, node, node->ns->prefix); + if (ns != NULL) { + xmlNodePtr root = ret; + + while (root->parent != NULL) root = root->parent; + ret->ns = xmlNewNs(root, ns->href, ns->prefix); + } else { + ret->ns = xmlNewReconciledNs(doc, ret, node->ns); + } + } else { + /* + * reference the existing namespace definition in our own tree. + */ + ret->ns = ns; + } + } + if (((node->type == XML_ELEMENT_NODE) || + (node->type == XML_XINCLUDE_START)) && (node->properties != NULL)) + ret->properties = xmlCopyPropList(ret, node->properties); + if (node->type == XML_ENTITY_REF_NODE) { + if ((doc == NULL) || (node->doc != doc)) { + /* + * The copied node will go into a separate document, so + * to avoid dangling references to the ENTITY_DECL node + * we cannot keep the reference. Try to find it in the + * target document. + */ + ret->children = (xmlNodePtr) xmlGetDocEntity(doc, ret->name); + } else { + ret->children = node->children; + } + ret->last = ret->children; + } else if ((node->children != NULL) && (extended != 2)) { + ret->children = xmlStaticCopyNodeList(node->children, doc, ret); + UPDATE_LAST_CHILD_AND_PARENT(ret) + } + +out: + /* if parent != NULL we already registered the node above */ + if ((parent == NULL) && + ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))) + xmlRegisterNodeDefaultValue((xmlNodePtr)ret); + return(ret); +} + +static xmlNodePtr +xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) { + xmlNodePtr ret = NULL; + xmlNodePtr p = NULL,q; + + while (node != NULL) { +#ifdef LIBXML_TREE_ENABLED + if (node->type == XML_DTD_NODE ) { + if (doc == NULL) { + node = node->next; + continue; + } + if (doc->intSubset == NULL) { + q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node ); + if (q == NULL) return(NULL); + q->doc = doc; + q->parent = parent; + doc->intSubset = (xmlDtdPtr) q; + xmlAddChild(parent, q); + } else { + q = (xmlNodePtr) doc->intSubset; + xmlAddChild(parent, q); + } + } else +#endif /* LIBXML_TREE_ENABLED */ + q = xmlStaticCopyNode(node, doc, parent, 1); + if (q == NULL) return(NULL); + if (ret == NULL) { + q->prev = NULL; + ret = p = q; + } else if (p != q) { + /* the test is required if xmlStaticCopyNode coalesced 2 text nodes */ + p->next = q; + q->prev = p; + p = q; + } + node = node->next; + } + return(ret); +} + +/** + * xmlCopyNode: + * @node: the node + * @extended: if 1 do a recursive copy (properties, namespaces and children + * when applicable) + * if 2 copy properties and namespaces (when applicable) + * + * Do a copy of the node. + * + * Returns: a new #xmlNodePtr, or NULL in case of error. + */ +xmlNodePtr +xmlCopyNode(xmlNodePtr node, int extended) { + xmlNodePtr ret; + + ret = xmlStaticCopyNode(node, NULL, NULL, extended); + return(ret); +} + +/** + * xmlDocCopyNode: + * @node: the node + * @doc: the document + * @extended: if 1 do a recursive copy (properties, namespaces and children + * when applicable) + * if 2 copy properties and namespaces (when applicable) + * + * Do a copy of the node to a given document. + * + * Returns: a new #xmlNodePtr, or NULL in case of error. + */ +xmlNodePtr +xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int extended) { + xmlNodePtr ret; + + ret = xmlStaticCopyNode(node, doc, NULL, extended); + return(ret); +} + +/** + * xmlDocCopyNodeList: + * @doc: the target document + * @node: the first node in the list. + * + * Do a recursive copy of the node list. + * + * Returns: a new #xmlNodePtr, or NULL in case of error. + */ +xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, xmlNodePtr node) { + xmlNodePtr ret = xmlStaticCopyNodeList(node, doc, NULL); + return(ret); +} + +/** + * xmlCopyNodeList: + * @node: the first node in the list. + * + * Do a recursive copy of the node list. + * Use xmlDocCopyNodeList() if possible to ensure string interning. + * + * Returns: a new #xmlNodePtr, or NULL in case of error. + */ +xmlNodePtr xmlCopyNodeList(xmlNodePtr node) { + xmlNodePtr ret = xmlStaticCopyNodeList(node, NULL, NULL); + return(ret); +} + +#if defined(LIBXML_TREE_ENABLED) +/** + * xmlCopyDtd: + * @dtd: the dtd + * + * Do a copy of the dtd. + * + * Returns: a new #xmlDtdPtr, or NULL in case of error. + */ +xmlDtdPtr +xmlCopyDtd(xmlDtdPtr dtd) { + xmlDtdPtr ret; + xmlNodePtr cur, p = NULL, q; + + if (dtd == NULL) return(NULL); + ret = xmlNewDtd(NULL, dtd->name, dtd->ExternalID, dtd->SystemID); + if (ret == NULL) return(NULL); + if (dtd->entities != NULL) + ret->entities = (void *) xmlCopyEntitiesTable( + (xmlEntitiesTablePtr) dtd->entities); + if (dtd->notations != NULL) + ret->notations = (void *) xmlCopyNotationTable( + (xmlNotationTablePtr) dtd->notations); + if (dtd->elements != NULL) + ret->elements = (void *) xmlCopyElementTable( + (xmlElementTablePtr) dtd->elements); + if (dtd->attributes != NULL) + ret->attributes = (void *) xmlCopyAttributeTable( + (xmlAttributeTablePtr) dtd->attributes); + if (dtd->pentities != NULL) + ret->pentities = (void *) xmlCopyEntitiesTable( + (xmlEntitiesTablePtr) dtd->pentities); + + cur = dtd->children; + while (cur != NULL) { + q = NULL; + + if (cur->type == XML_ENTITY_DECL) { + xmlEntityPtr tmp = (xmlEntityPtr) cur; + switch (tmp->etype) { + case XML_INTERNAL_GENERAL_ENTITY: + case XML_EXTERNAL_GENERAL_PARSED_ENTITY: + case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: + q = (xmlNodePtr) xmlGetEntityFromDtd(ret, tmp->name); + break; + case XML_INTERNAL_PARAMETER_ENTITY: + case XML_EXTERNAL_PARAMETER_ENTITY: + q = (xmlNodePtr) + xmlGetParameterEntityFromDtd(ret, tmp->name); + break; + case XML_INTERNAL_PREDEFINED_ENTITY: + break; + } + } else if (cur->type == XML_ELEMENT_DECL) { + xmlElementPtr tmp = (xmlElementPtr) cur; + q = (xmlNodePtr) + xmlGetDtdQElementDesc(ret, tmp->name, tmp->prefix); + } else if (cur->type == XML_ATTRIBUTE_DECL) { + xmlAttributePtr tmp = (xmlAttributePtr) cur; + q = (xmlNodePtr) + xmlGetDtdQAttrDesc(ret, tmp->elem, tmp->name, tmp->prefix); + } else if (cur->type == XML_COMMENT_NODE) { + q = xmlCopyNode(cur, 0); + } + + if (q == NULL) { + cur = cur->next; + continue; + } + + if (p == NULL) + ret->children = q; + else + p->next = q; + + q->prev = p; + q->parent = (xmlNodePtr) ret; + q->next = NULL; + ret->last = q; + p = q; + cur = cur->next; + } + + return(ret); +} +#endif + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlCopyDoc: + * @doc: the document + * @recursive: if not zero do a recursive copy. + * + * Do a copy of the document info. If recursive, the content tree will + * be copied too as well as DTD, namespaces and entities. + * + * Returns: a new #xmlDocPtr, or NULL in case of error. + */ +xmlDocPtr +xmlCopyDoc(xmlDocPtr doc, int recursive) { + xmlDocPtr ret; + + if (doc == NULL) return(NULL); + ret = xmlNewDoc(doc->version); + if (ret == NULL) return(NULL); + ret->type = doc->type; + if (doc->name != NULL) + ret->name = xmlMemStrdup(doc->name); + if (doc->encoding != NULL) + ret->encoding = xmlStrdup(doc->encoding); + if (doc->URL != NULL) + ret->URL = xmlStrdup(doc->URL); + ret->charset = doc->charset; + ret->compression = doc->compression; + ret->standalone = doc->standalone; + if (!recursive) return(ret); + + ret->last = NULL; + ret->children = NULL; +#ifdef LIBXML_TREE_ENABLED + if (doc->intSubset != NULL) { + ret->intSubset = xmlCopyDtd(doc->intSubset); + if (ret->intSubset == NULL) { + xmlFreeDoc(ret); + return(NULL); + } + xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret); + ret->intSubset->parent = ret; + } +#endif + if (doc->oldNs != NULL) + ret->oldNs = xmlCopyNamespaceList(doc->oldNs); + if (doc->children != NULL) { + xmlNodePtr tmp; + + ret->children = xmlStaticCopyNodeList(doc->children, ret, + (xmlNodePtr)ret); + ret->last = NULL; + tmp = ret->children; + while (tmp != NULL) { + if (tmp->next == NULL) + ret->last = tmp; + tmp = tmp->next; + } + } + return(ret); +} +#endif /* LIBXML_TREE_ENABLED */ + +/************************************************************************ + * * + * Content access functions * + * * + ************************************************************************/ + +/** + * xmlGetLineNoInternal: + * @node: valid node + * @depth: used to limit any risk of recursion + * + * Get line number of @node. + * Try to override the limitation of lines being store in 16 bits ints + * + * Returns the line number if successful, -1 otherwise + */ +static long +xmlGetLineNoInternal(const xmlNode *node, int depth) +{ + long result = -1; + + if (depth >= 5) + return(-1); + + if (!node) + return result; + if ((node->type == XML_ELEMENT_NODE) || + (node->type == XML_TEXT_NODE) || + (node->type == XML_COMMENT_NODE) || + (node->type == XML_PI_NODE)) { + if (node->line == 65535) { + if ((node->type == XML_TEXT_NODE) && (node->psvi != NULL)) + result = (long) (ptrdiff_t) node->psvi; + else if ((node->type == XML_ELEMENT_NODE) && + (node->children != NULL)) + result = xmlGetLineNoInternal(node->children, depth + 1); + else if (node->next != NULL) + result = xmlGetLineNoInternal(node->next, depth + 1); + else if (node->prev != NULL) + result = xmlGetLineNoInternal(node->prev, depth + 1); + } + if ((result == -1) || (result == 65535)) + result = (long) node->line; + } else if ((node->prev != NULL) && + ((node->prev->type == XML_ELEMENT_NODE) || + (node->prev->type == XML_TEXT_NODE) || + (node->prev->type == XML_COMMENT_NODE) || + (node->prev->type == XML_PI_NODE))) + result = xmlGetLineNoInternal(node->prev, depth + 1); + else if ((node->parent != NULL) && + (node->parent->type == XML_ELEMENT_NODE)) + result = xmlGetLineNoInternal(node->parent, depth + 1); + + return result; +} + +/** + * xmlGetLineNo: + * @node: valid node + * + * Get line number of @node. + * Try to override the limitation of lines being store in 16 bits ints + * if XML_PARSE_BIG_LINES parser option was used + * + * Returns the line number if successful, -1 otherwise + */ +long +xmlGetLineNo(const xmlNode *node) +{ + return(xmlGetLineNoInternal(node, 0)); +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) +/** + * xmlGetNodePath: + * @node: a node + * + * Build a structure based Path for the given node + * + * Returns the new path or NULL in case of error. The caller must free + * the returned string + */ +xmlChar * +xmlGetNodePath(const xmlNode *node) +{ + const xmlNode *cur, *tmp, *next; + xmlChar *buffer = NULL, *temp; + size_t buf_len; + xmlChar *buf; + const char *sep; + const char *name; + char nametemp[100]; + int occur = 0, generic; + + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) + return (NULL); + + buf_len = 500; + buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar)); + if (buffer == NULL) { + xmlTreeErrMemory("getting node path"); + return (NULL); + } + buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar)); + if (buf == NULL) { + xmlTreeErrMemory("getting node path"); + xmlFree(buffer); + return (NULL); + } + + buffer[0] = 0; + cur = node; + do { + name = ""; + sep = "?"; + occur = 0; + if ((cur->type == XML_DOCUMENT_NODE) || + (cur->type == XML_HTML_DOCUMENT_NODE)) { + if (buffer[0] == '/') + break; + sep = "/"; + next = NULL; + } else if (cur->type == XML_ELEMENT_NODE) { + generic = 0; + sep = "/"; + name = (const char *) cur->name; + if (cur->ns) { + if (cur->ns->prefix != NULL) { + snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s", + (char *)cur->ns->prefix, (char *)cur->name); + nametemp[sizeof(nametemp) - 1] = 0; + name = nametemp; + } else { + /* + * We cannot express named elements in the default + * namespace, so use "*". + */ + generic = 1; + name = "*"; + } + } + next = cur->parent; + + /* + * Thumbler index computation + * TODO: the occurrence test seems bogus for namespaced names + */ + tmp = cur->prev; + while (tmp != NULL) { + if ((tmp->type == XML_ELEMENT_NODE) && + (generic || + (xmlStrEqual(cur->name, tmp->name) && + ((tmp->ns == cur->ns) || + ((tmp->ns != NULL) && (cur->ns != NULL) && + (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix))))))) + occur++; + tmp = tmp->prev; + } + if (occur == 0) { + tmp = cur->next; + while (tmp != NULL && occur == 0) { + if ((tmp->type == XML_ELEMENT_NODE) && + (generic || + (xmlStrEqual(cur->name, tmp->name) && + ((tmp->ns == cur->ns) || + ((tmp->ns != NULL) && (cur->ns != NULL) && + (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix))))))) + occur++; + tmp = tmp->next; + } + if (occur != 0) + occur = 1; + } else + occur++; + } else if (cur->type == XML_COMMENT_NODE) { + sep = "/"; + name = "comment()"; + next = cur->parent; + + /* + * Thumbler index computation + */ + tmp = cur->prev; + while (tmp != NULL) { + if (tmp->type == XML_COMMENT_NODE) + occur++; + tmp = tmp->prev; + } + if (occur == 0) { + tmp = cur->next; + while (tmp != NULL && occur == 0) { + if (tmp->type == XML_COMMENT_NODE) + occur++; + tmp = tmp->next; + } + if (occur != 0) + occur = 1; + } else + occur++; + } else if ((cur->type == XML_TEXT_NODE) || + (cur->type == XML_CDATA_SECTION_NODE)) { + sep = "/"; + name = "text()"; + next = cur->parent; + + /* + * Thumbler index computation + */ + tmp = cur->prev; + while (tmp != NULL) { + if ((tmp->type == XML_TEXT_NODE) || + (tmp->type == XML_CDATA_SECTION_NODE)) + occur++; + tmp = tmp->prev; + } + /* + * Evaluate if this is the only text- or CDATA-section-node; + * if yes, then we'll get "text()", otherwise "text()[1]". + */ + if (occur == 0) { + tmp = cur->next; + while (tmp != NULL) { + if ((tmp->type == XML_TEXT_NODE) || + (tmp->type == XML_CDATA_SECTION_NODE)) + { + occur = 1; + break; + } + tmp = tmp->next; + } + } else + occur++; + } else if (cur->type == XML_PI_NODE) { + sep = "/"; + snprintf(nametemp, sizeof(nametemp) - 1, + "processing-instruction('%s')", (char *)cur->name); + nametemp[sizeof(nametemp) - 1] = 0; + name = nametemp; + + next = cur->parent; + + /* + * Thumbler index computation + */ + tmp = cur->prev; + while (tmp != NULL) { + if ((tmp->type == XML_PI_NODE) && + (xmlStrEqual(cur->name, tmp->name))) + occur++; + tmp = tmp->prev; + } + if (occur == 0) { + tmp = cur->next; + while (tmp != NULL && occur == 0) { + if ((tmp->type == XML_PI_NODE) && + (xmlStrEqual(cur->name, tmp->name))) + occur++; + tmp = tmp->next; + } + if (occur != 0) + occur = 1; + } else + occur++; + + } else if (cur->type == XML_ATTRIBUTE_NODE) { + sep = "/@"; + name = (const char *) (((xmlAttrPtr) cur)->name); + if (cur->ns) { + if (cur->ns->prefix != NULL) + snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s", + (char *)cur->ns->prefix, (char *)cur->name); + else + snprintf(nametemp, sizeof(nametemp) - 1, "%s", + (char *)cur->name); + nametemp[sizeof(nametemp) - 1] = 0; + name = nametemp; + } + next = ((xmlAttrPtr) cur)->parent; + } else { + xmlFree(buf); + xmlFree(buffer); + return (NULL); + } + + /* + * Make sure there is enough room + */ + if (xmlStrlen(buffer) + sizeof(nametemp) + 20 > buf_len) { + buf_len = + 2 * buf_len + xmlStrlen(buffer) + sizeof(nametemp) + 20; + temp = (xmlChar *) xmlRealloc(buffer, buf_len); + if (temp == NULL) { + xmlTreeErrMemory("getting node path"); + xmlFree(buf); + xmlFree(buffer); + return (NULL); + } + buffer = temp; + temp = (xmlChar *) xmlRealloc(buf, buf_len); + if (temp == NULL) { + xmlTreeErrMemory("getting node path"); + xmlFree(buf); + xmlFree(buffer); + return (NULL); + } + buf = temp; + } + if (occur == 0) + snprintf((char *) buf, buf_len, "%s%s%s", + sep, name, (char *) buffer); + else + snprintf((char *) buf, buf_len, "%s%s[%d]%s", + sep, name, occur, (char *) buffer); + snprintf((char *) buffer, buf_len, "%s", (char *)buf); + cur = next; + } while (cur != NULL); + xmlFree(buf); + return (buffer); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlDocGetRootElement: + * @doc: the document + * + * Get the root element of the document (doc->children is a list + * containing possibly comments, PIs, etc ...). + * + * Returns the #xmlNodePtr for the root or NULL + */ +xmlNodePtr +xmlDocGetRootElement(const xmlDoc *doc) { + xmlNodePtr ret; + + if (doc == NULL) return(NULL); + ret = doc->children; + while (ret != NULL) { + if (ret->type == XML_ELEMENT_NODE) + return(ret); + ret = ret->next; + } + return(ret); +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +/** + * xmlDocSetRootElement: + * @doc: the document + * @root: the new document root element, if root is NULL no action is taken, + * to remove a node from a document use xmlUnlinkNode(root) instead. + * + * Set the root element of the document (doc->children is a list + * containing possibly comments, PIs, etc ...). + * + * Returns the old root element if any was found, NULL if root was NULL + */ +xmlNodePtr +xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) { + xmlNodePtr old = NULL; + + if (doc == NULL) return(NULL); + if ((root == NULL) || (root->type == XML_NAMESPACE_DECL)) + return(NULL); + xmlUnlinkNode(root); + xmlSetTreeDoc(root, doc); + root->parent = (xmlNodePtr) doc; + old = doc->children; + while (old != NULL) { + if (old->type == XML_ELEMENT_NODE) + break; + old = old->next; + } + if (old == NULL) { + if (doc->children == NULL) { + doc->children = root; + doc->last = root; + } else { + xmlAddSibling(doc->children, root); + } + } else { + xmlReplaceNode(old, root); + } + return(old); +} +#endif + +#if defined(LIBXML_TREE_ENABLED) +/** + * xmlNodeSetLang: + * @cur: the node being changed + * @lang: the language description + * + * Set the language of a node, i.e. the values of the xml:lang + * attribute. + */ +void +xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) { + xmlNsPtr ns; + + if (cur == NULL) return; + switch(cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_PI_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_NAMESPACE_DECL: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + return; + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + break; + } + ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); + if (ns == NULL) + return; + xmlSetNsProp(cur, ns, BAD_CAST "lang", lang); +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNodeGetLang: + * @cur: the node being checked + * + * Searches the language of a node, i.e. the values of the xml:lang + * attribute or the one carried by the nearest ancestor. + * + * Returns a pointer to the lang value, or NULL if not found + * It's up to the caller to free the memory with xmlFree(). + */ +xmlChar * +xmlNodeGetLang(const xmlNode *cur) { + xmlChar *lang; + + if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) + return(NULL); + while (cur != NULL) { + lang = xmlGetNsProp(cur, BAD_CAST "lang", XML_XML_NAMESPACE); + if (lang != NULL) + return(lang); + cur = cur->parent; + } + return(NULL); +} + + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlNodeSetSpacePreserve: + * @cur: the node being changed + * @val: the xml:space value ("0": default, 1: "preserve") + * + * Set (or reset) the space preserving behaviour of a node, i.e. the + * value of the xml:space attribute. + */ +void +xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) { + xmlNsPtr ns; + + if (cur == NULL) return; + switch(cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_PI_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + return; + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + break; + } + ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); + if (ns == NULL) + return; + switch (val) { + case 0: + xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default"); + break; + case 1: + xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve"); + break; + } +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNodeGetSpacePreserve: + * @cur: the node being checked + * + * Searches the space preserving behaviour of a node, i.e. the values + * of the xml:space attribute or the one carried by the nearest + * ancestor. + * + * Returns -1 if xml:space is not inherited, 0 if "default", 1 if "preserve" + */ +int +xmlNodeGetSpacePreserve(const xmlNode *cur) { + xmlChar *space; + + if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE)) + return(-1); + while (cur != NULL) { + space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE); + if (space != NULL) { + if (xmlStrEqual(space, BAD_CAST "preserve")) { + xmlFree(space); + return(1); + } + if (xmlStrEqual(space, BAD_CAST "default")) { + xmlFree(space); + return(0); + } + xmlFree(space); + } + cur = cur->parent; + } + return(-1); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlNodeSetName: + * @cur: the node being changed + * @name: the new tag name + * + * Set (or reset) the name of a node. + */ +void +xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) { + xmlDocPtr doc; + xmlDictPtr dict; + const xmlChar *freeme = NULL; + + if (cur == NULL) return; + if (name == NULL) return; + switch(cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + return; + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_DTD_NODE: + case XML_DOCUMENT_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + break; + } + doc = cur->doc; + if (doc != NULL) + dict = doc->dict; + else + dict = NULL; + if (dict != NULL) { + if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name))) + freeme = cur->name; + cur->name = xmlDictLookup(dict, name, -1); + } else { + if (cur->name != NULL) + freeme = cur->name; + cur->name = xmlStrdup(name); + } + + if (freeme) + xmlFree((xmlChar *) freeme); +} +#endif + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) +/** + * xmlNodeSetBase: + * @cur: the node being changed + * @uri: the new base URI + * + * Set (or reset) the base URI of a node, i.e. the value of the + * xml:base attribute. + */ +void +xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) { + xmlNsPtr ns; + xmlChar* fixed; + + if (cur == NULL) return; + switch(cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_PI_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + return; + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + break; + case XML_DOCUMENT_NODE: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + case XML_HTML_DOCUMENT_NODE: { + xmlDocPtr doc = (xmlDocPtr) cur; + + if (doc->URL != NULL) + xmlFree((xmlChar *) doc->URL); + if (uri == NULL) + doc->URL = NULL; + else + doc->URL = xmlPathToURI(uri); + return; + } + } + + ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); + if (ns == NULL) + return; + fixed = xmlPathToURI(uri); + if (fixed != NULL) { + xmlSetNsProp(cur, ns, BAD_CAST "base", fixed); + xmlFree(fixed); + } else { + xmlSetNsProp(cur, ns, BAD_CAST "base", uri); + } +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNodeGetBase: + * @doc: the document the node pertains to + * @cur: the node being checked + * + * Searches for the BASE URL. The code should work on both XML + * and HTML document even if base mechanisms are completely different. + * It returns the base as defined in RFC 2396 sections + * 5.1.1. Base URI within Document Content + * and + * 5.1.2. Base URI from the Encapsulating Entity + * However it does not return the document base (5.1.3), use + * doc->URL in this case + * + * Returns a pointer to the base URL, or NULL if not found + * It's up to the caller to free the memory with xmlFree(). + */ +xmlChar * +xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur) { + xmlChar *oldbase = NULL; + xmlChar *base, *newbase; + + if ((cur == NULL) && (doc == NULL)) + return(NULL); + if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL)) + return(NULL); + if (doc == NULL) doc = cur->doc; + if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { + cur = doc->children; + while ((cur != NULL) && (cur->name != NULL)) { + if (cur->type != XML_ELEMENT_NODE) { + cur = cur->next; + continue; + } + if (!xmlStrcasecmp(cur->name, BAD_CAST "html")) { + cur = cur->children; + continue; + } + if (!xmlStrcasecmp(cur->name, BAD_CAST "head")) { + cur = cur->children; + continue; + } + if (!xmlStrcasecmp(cur->name, BAD_CAST "base")) { + return(xmlGetProp(cur, BAD_CAST "href")); + } + cur = cur->next; + } + return(NULL); + } + while (cur != NULL) { + if (cur->type == XML_ENTITY_DECL) { + xmlEntityPtr ent = (xmlEntityPtr) cur; + return(xmlStrdup(ent->URI)); + } + if (cur->type == XML_ELEMENT_NODE) { + base = xmlGetNsProp(cur, BAD_CAST "base", XML_XML_NAMESPACE); + if (base != NULL) { + if (oldbase != NULL) { + newbase = xmlBuildURI(oldbase, base); + if (newbase != NULL) { + xmlFree(oldbase); + xmlFree(base); + oldbase = newbase; + } else { + xmlFree(oldbase); + xmlFree(base); + return(NULL); + } + } else { + oldbase = base; + } + if ((!xmlStrncmp(oldbase, BAD_CAST "http://", 7)) || + (!xmlStrncmp(oldbase, BAD_CAST "ftp://", 6)) || + (!xmlStrncmp(oldbase, BAD_CAST "urn:", 4))) + return(oldbase); + } + } + cur = cur->parent; + } + if ((doc != NULL) && (doc->URL != NULL)) { + if (oldbase == NULL) + return(xmlStrdup(doc->URL)); + newbase = xmlBuildURI(oldbase, doc->URL); + xmlFree(oldbase); + return(newbase); + } + return(oldbase); +} + +/** + * xmlNodeBufGetContent: + * @buffer: a buffer + * @cur: the node being read + * + * Read the value of a node @cur, this can be either the text carried + * directly by this node if it's a TEXT node or the aggregate string + * of the values carried by this node child's (TEXT and ENTITY_REF). + * Entity references are substituted. + * Fills up the buffer @buffer with this value + * + * Returns 0 in case of success and -1 in case of error. + */ +int +xmlNodeBufGetContent(xmlBufferPtr buffer, const xmlNode *cur) +{ + xmlBufPtr buf; + int ret; + + if ((cur == NULL) || (buffer == NULL)) return(-1); + buf = xmlBufFromBuffer(buffer); + ret = xmlBufGetNodeContent(buf, cur); + buffer = xmlBufBackToBuffer(buf); + if ((ret < 0) || (buffer == NULL)) + return(-1); + return(0); +} + +/** + * xmlBufGetNodeContent: + * @buf: a buffer xmlBufPtr + * @cur: the node being read + * + * Read the value of a node @cur, this can be either the text carried + * directly by this node if it's a TEXT node or the aggregate string + * of the values carried by this node child's (TEXT and ENTITY_REF). + * Entity references are substituted. + * Fills up the buffer @buf with this value + * + * Returns 0 in case of success and -1 in case of error. + */ +int +xmlBufGetNodeContent(xmlBufPtr buf, const xmlNode *cur) +{ + if ((cur == NULL) || (buf == NULL)) return(-1); + switch (cur->type) { + case XML_CDATA_SECTION_NODE: + case XML_TEXT_NODE: + xmlBufCat(buf, cur->content); + break; + case XML_DOCUMENT_FRAG_NODE: + case XML_ELEMENT_NODE:{ + const xmlNode *tmp = cur; + + while (tmp != NULL) { + switch (tmp->type) { + case XML_CDATA_SECTION_NODE: + case XML_TEXT_NODE: + if (tmp->content != NULL) + xmlBufCat(buf, tmp->content); + break; + case XML_ENTITY_REF_NODE: + xmlBufGetNodeContent(buf, tmp); + break; + default: + break; + } + /* + * Skip to next node + */ + if (tmp->children != NULL) { + if (tmp->children->type != XML_ENTITY_DECL) { + tmp = tmp->children; + continue; + } + } + if (tmp == cur) + break; + + if (tmp->next != NULL) { + tmp = tmp->next; + continue; + } + + do { + tmp = tmp->parent; + if (tmp == NULL) + break; + if (tmp == cur) { + tmp = NULL; + break; + } + if (tmp->next != NULL) { + tmp = tmp->next; + break; + } + } while (tmp != NULL); + } + break; + } + case XML_ATTRIBUTE_NODE:{ + xmlAttrPtr attr = (xmlAttrPtr) cur; + xmlNodePtr tmp = attr->children; + + while (tmp != NULL) { + if (tmp->type == XML_TEXT_NODE) + xmlBufCat(buf, tmp->content); + else + xmlBufGetNodeContent(buf, tmp); + tmp = tmp->next; + } + break; + } + case XML_COMMENT_NODE: + case XML_PI_NODE: + xmlBufCat(buf, cur->content); + break; + case XML_ENTITY_REF_NODE:{ + xmlEntityPtr ent; + xmlNodePtr tmp; + + /* lookup entity declaration */ + ent = xmlGetDocEntity(cur->doc, cur->name); + if (ent == NULL) + return(-1); + + /* an entity content can be any "well balanced chunk", + * i.e. the result of the content [43] production: + * http://www.w3.org/TR/REC-xml#NT-content + * -> we iterate through child nodes and recursive call + * xmlNodeGetContent() which handles all possible node types */ + tmp = ent->children; + while (tmp) { + xmlBufGetNodeContent(buf, tmp); + tmp = tmp->next; + } + break; + } + case XML_ENTITY_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + case XML_DOCUMENT_NODE: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + case XML_HTML_DOCUMENT_NODE: + cur = cur->children; + while (cur!= NULL) { + if ((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_TEXT_NODE) || + (cur->type == XML_CDATA_SECTION_NODE)) { + xmlBufGetNodeContent(buf, cur); + } + cur = cur->next; + } + break; + case XML_NAMESPACE_DECL: + xmlBufCat(buf, ((xmlNsPtr) cur)->href); + break; + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + break; + } + return(0); +} + +/** + * xmlNodeGetContent: + * @cur: the node being read + * + * Read the value of a node, this can be either the text carried + * directly by this node if it's a TEXT node or the aggregate string + * of the values carried by this node child's (TEXT and ENTITY_REF). + * Entity references are substituted. + * Returns a new #xmlChar * or NULL if no content is available. + * It's up to the caller to free the memory with xmlFree(). + */ +xmlChar * +xmlNodeGetContent(const xmlNode *cur) +{ + if (cur == NULL) + return (NULL); + switch (cur->type) { + case XML_DOCUMENT_FRAG_NODE: + case XML_ELEMENT_NODE:{ + xmlBufPtr buf; + xmlChar *ret; + + buf = xmlBufCreateSize(64); + if (buf == NULL) + return (NULL); + xmlBufGetNodeContent(buf, cur); + ret = xmlBufDetach(buf); + xmlBufFree(buf); + return (ret); + } + case XML_ATTRIBUTE_NODE: + return(xmlGetPropNodeValueInternal((xmlAttrPtr) cur)); + case XML_COMMENT_NODE: + case XML_PI_NODE: + if (cur->content != NULL) + return (xmlStrdup(cur->content)); + return (NULL); + case XML_ENTITY_REF_NODE:{ + xmlEntityPtr ent; + xmlBufPtr buf; + xmlChar *ret; + + /* lookup entity declaration */ + ent = xmlGetDocEntity(cur->doc, cur->name); + if (ent == NULL) + return (NULL); + + buf = xmlBufCreate(); + if (buf == NULL) + return (NULL); + + xmlBufGetNodeContent(buf, cur); + + ret = xmlBufDetach(buf); + xmlBufFree(buf); + return (ret); + } + case XML_ENTITY_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + return (NULL); + case XML_DOCUMENT_NODE: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + case XML_HTML_DOCUMENT_NODE: { + xmlBufPtr buf; + xmlChar *ret; + + buf = xmlBufCreate(); + if (buf == NULL) + return (NULL); + + xmlBufGetNodeContent(buf, (xmlNodePtr) cur); + + ret = xmlBufDetach(buf); + xmlBufFree(buf); + return (ret); + } + case XML_NAMESPACE_DECL: { + xmlChar *tmp; + + tmp = xmlStrdup(((xmlNsPtr) cur)->href); + return (tmp); + } + case XML_ELEMENT_DECL: + /* TODO !!! */ + return (NULL); + case XML_ATTRIBUTE_DECL: + /* TODO !!! */ + return (NULL); + case XML_ENTITY_DECL: + /* TODO !!! */ + return (NULL); + case XML_CDATA_SECTION_NODE: + case XML_TEXT_NODE: + if (cur->content != NULL) + return (xmlStrdup(cur->content)); + return (NULL); + } + return (NULL); +} + +/** + * xmlNodeSetContent: + * @cur: the node being modified + * @content: the new value of the content + * + * Replace the content of a node. + * NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity + * references, but XML special chars need to be escaped first by using + * xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars(). + */ +void +xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) { + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNodeSetContent : node == NULL\n"); +#endif + return; + } + switch (cur->type) { + case XML_DOCUMENT_FRAG_NODE: + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + if (cur->children != NULL) xmlFreeNodeList(cur->children); + cur->children = xmlStringGetNodeList(cur->doc, content); + UPDATE_LAST_CHILD_AND_PARENT(cur) + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + if ((cur->content != NULL) && + (cur->content != (xmlChar *) &(cur->properties))) { + if (!((cur->doc != NULL) && (cur->doc->dict != NULL) && + (xmlDictOwns(cur->doc->dict, cur->content)))) + xmlFree(cur->content); + } + if (cur->children != NULL) xmlFreeNodeList(cur->children); + cur->last = cur->children = NULL; + if (content != NULL) { + cur->content = xmlStrdup(content); + } else + cur->content = NULL; + cur->properties = NULL; + cur->nsDef = NULL; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + break; + case XML_NOTATION_NODE: + break; + case XML_DTD_NODE: + break; + case XML_NAMESPACE_DECL: + break; + case XML_ELEMENT_DECL: + /* TODO !!! */ + break; + case XML_ATTRIBUTE_DECL: + /* TODO !!! */ + break; + case XML_ENTITY_DECL: + /* TODO !!! */ + break; + } +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlNodeSetContentLen: + * @cur: the node being modified + * @content: the new value of the content + * @len: the size of @content + * + * Replace the content of a node. + * NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity + * references, but XML special chars need to be escaped first by using + * xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars(). + */ +void +xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) { + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNodeSetContentLen : node == NULL\n"); +#endif + return; + } + switch (cur->type) { + case XML_DOCUMENT_FRAG_NODE: + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + if (cur->children != NULL) xmlFreeNodeList(cur->children); + cur->children = xmlStringLenGetNodeList(cur->doc, content, len); + UPDATE_LAST_CHILD_AND_PARENT(cur) + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_NOTATION_NODE: + if ((cur->content != NULL) && + (cur->content != (xmlChar *) &(cur->properties))) { + if (!((cur->doc != NULL) && (cur->doc->dict != NULL) && + (xmlDictOwns(cur->doc->dict, cur->content)))) + xmlFree(cur->content); + } + if (cur->children != NULL) xmlFreeNodeList(cur->children); + cur->children = cur->last = NULL; + if (content != NULL) { + cur->content = xmlStrndup(content, len); + } else + cur->content = NULL; + cur->properties = NULL; + cur->nsDef = NULL; + break; + case XML_DOCUMENT_NODE: + case XML_DTD_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + break; + case XML_ELEMENT_DECL: + /* TODO !!! */ + break; + case XML_ATTRIBUTE_DECL: + /* TODO !!! */ + break; + case XML_ENTITY_DECL: + /* TODO !!! */ + break; + } +} +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNodeAddContentLen: + * @cur: the node being modified + * @content: extra content + * @len: the size of @content + * + * Append the extra substring to the node content. + * NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be + * raw text, so unescaped XML special chars are allowed, entity + * references are not supported. + */ +void +xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) { + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNodeAddContentLen : node == NULL\n"); +#endif + return; + } + if (len <= 0) return; + switch (cur->type) { + case XML_DOCUMENT_FRAG_NODE: + case XML_ELEMENT_NODE: { + xmlNodePtr last, newNode, tmp; + + last = cur->last; + newNode = xmlNewTextLen(content, len); + if (newNode != NULL) { + tmp = xmlAddChild(cur, newNode); + if (tmp != newNode) + return; + if ((last != NULL) && (last->next == newNode)) { + xmlTextMerge(last, newNode); + } + } + break; + } + case XML_ATTRIBUTE_NODE: + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_NOTATION_NODE: + if (content != NULL) { + if ((cur->content == (xmlChar *) &(cur->properties)) || + ((cur->doc != NULL) && (cur->doc->dict != NULL) && + xmlDictOwns(cur->doc->dict, cur->content))) { + cur->content = xmlStrncatNew(cur->content, content, len); + cur->properties = NULL; + cur->nsDef = NULL; + break; + } + cur->content = xmlStrncat(cur->content, content, len); + } + case XML_DOCUMENT_NODE: + case XML_DTD_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + break; + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + break; + } +} + +/** + * xmlNodeAddContent: + * @cur: the node being modified + * @content: extra content + * + * Append the extra substring to the node content. + * NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be + * raw text, so unescaped XML special chars are allowed, entity + * references are not supported. + */ +void +xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) { + int len; + + if (cur == NULL) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNodeAddContent : node == NULL\n"); +#endif + return; + } + if (content == NULL) return; + len = xmlStrlen(content); + xmlNodeAddContentLen(cur, content, len); +} + +/** + * xmlTextMerge: + * @first: the first text node + * @second: the second text node being merged + * + * Merge two text nodes into one + * Returns the first text node augmented + */ +xmlNodePtr +xmlTextMerge(xmlNodePtr first, xmlNodePtr second) { + if (first == NULL) return(second); + if (second == NULL) return(first); + if (first->type != XML_TEXT_NODE) return(first); + if (second->type != XML_TEXT_NODE) return(first); + if (second->name != first->name) + return(first); + xmlNodeAddContent(first, second->content); + xmlUnlinkNode(second); + xmlFreeNode(second); + return(first); +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlGetNsList: + * @doc: the document + * @node: the current node + * + * Search all the namespace applying to a given element. + * Returns an NULL terminated array of all the #xmlNsPtr found + * that need to be freed by the caller or NULL if no + * namespace if defined + */ +xmlNsPtr * +xmlGetNsList(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlNode *node) +{ + xmlNsPtr cur; + xmlNsPtr *ret = NULL; + int nbns = 0; + int maxns = 10; + int i; + + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) + return(NULL); + + while (node != NULL) { + if (node->type == XML_ELEMENT_NODE) { + cur = node->nsDef; + while (cur != NULL) { + if (ret == NULL) { + ret = + (xmlNsPtr *) xmlMalloc((maxns + 1) * + sizeof(xmlNsPtr)); + if (ret == NULL) { + xmlTreeErrMemory("getting namespace list"); + return (NULL); + } + ret[nbns] = NULL; + } + for (i = 0; i < nbns; i++) { + if ((cur->prefix == ret[i]->prefix) || + (xmlStrEqual(cur->prefix, ret[i]->prefix))) + break; + } + if (i >= nbns) { + if (nbns >= maxns) { + maxns *= 2; + ret = (xmlNsPtr *) xmlRealloc(ret, + (maxns + + 1) * + sizeof(xmlNsPtr)); + if (ret == NULL) { + xmlTreeErrMemory("getting namespace list"); + return (NULL); + } + } + ret[nbns++] = cur; + ret[nbns] = NULL; + } + + cur = cur->next; + } + } + node = node->parent; + } + return (ret); +} +#endif /* LIBXML_TREE_ENABLED */ + +/* +* xmlTreeEnsureXMLDecl: +* @doc: the doc +* +* Ensures that there is an XML namespace declaration on the doc. +* +* Returns the XML ns-struct or NULL on API and internal errors. +*/ +static xmlNsPtr +xmlTreeEnsureXMLDecl(xmlDocPtr doc) +{ + if (doc == NULL) + return (NULL); + if (doc->oldNs != NULL) + return (doc->oldNs); + { + xmlNsPtr ns; + ns = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); + if (ns == NULL) { + xmlTreeErrMemory( + "allocating the XML namespace"); + return (NULL); + } + memset(ns, 0, sizeof(xmlNs)); + ns->type = XML_LOCAL_NAMESPACE; + ns->href = xmlStrdup(XML_XML_NAMESPACE); + ns->prefix = xmlStrdup((const xmlChar *)"xml"); + doc->oldNs = ns; + return (ns); + } +} + +/** + * xmlSearchNs: + * @doc: the document + * @node: the current node + * @nameSpace: the namespace prefix + * + * Search a Ns registered under a given name space for a document. + * recurse on the parents until it finds the defined namespace + * or return NULL otherwise. + * @nameSpace can be NULL, this is a search for the default namespace. + * We don't allow to cross entities boundaries. If you don't declare + * the namespace within those you will be in troubles !!! A warning + * is generated to cover this case. + * + * Returns the namespace pointer or NULL. + */ +xmlNsPtr +xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) { + + xmlNsPtr cur; + const xmlNode *orig = node; + + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) return(NULL); + if ((nameSpace != NULL) && + (xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) { + if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) { + /* + * The XML-1.0 namespace is normally held on the root + * element. In this case exceptionally create it on the + * node element. + */ + cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); + if (cur == NULL) { + xmlTreeErrMemory("searching namespace"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNs)); + cur->type = XML_LOCAL_NAMESPACE; + cur->href = xmlStrdup(XML_XML_NAMESPACE); + cur->prefix = xmlStrdup((const xmlChar *)"xml"); + cur->next = node->nsDef; + node->nsDef = cur; + return(cur); + } + if (doc == NULL) { + doc = node->doc; + if (doc == NULL) + return(NULL); + } + /* + * Return the XML namespace declaration held by the doc. + */ + if (doc->oldNs == NULL) + return(xmlTreeEnsureXMLDecl(doc)); + else + return(doc->oldNs); + } + while (node != NULL) { + if ((node->type == XML_ENTITY_REF_NODE) || + (node->type == XML_ENTITY_NODE) || + (node->type == XML_ENTITY_DECL)) + return(NULL); + if (node->type == XML_ELEMENT_NODE) { + cur = node->nsDef; + while (cur != NULL) { + if ((cur->prefix == NULL) && (nameSpace == NULL) && + (cur->href != NULL)) + return(cur); + if ((cur->prefix != NULL) && (nameSpace != NULL) && + (cur->href != NULL) && + (xmlStrEqual(cur->prefix, nameSpace))) + return(cur); + cur = cur->next; + } + if (orig != node) { + cur = node->ns; + if (cur != NULL) { + if ((cur->prefix == NULL) && (nameSpace == NULL) && + (cur->href != NULL)) + return(cur); + if ((cur->prefix != NULL) && (nameSpace != NULL) && + (cur->href != NULL) && + (xmlStrEqual(cur->prefix, nameSpace))) + return(cur); + } + } + } + node = node->parent; + } + return(NULL); +} + +/** + * xmlNsInScope: + * @doc: the document + * @node: the current node + * @ancestor: the ancestor carrying the namespace + * @prefix: the namespace prefix + * + * Verify that the given namespace held on @ancestor is still in scope + * on node. + * + * Returns 1 if true, 0 if false and -1 in case of error. + */ +static int +xmlNsInScope(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node, + xmlNodePtr ancestor, const xmlChar * prefix) +{ + xmlNsPtr tst; + + while ((node != NULL) && (node != ancestor)) { + if ((node->type == XML_ENTITY_REF_NODE) || + (node->type == XML_ENTITY_NODE) || + (node->type == XML_ENTITY_DECL)) + return (-1); + if (node->type == XML_ELEMENT_NODE) { + tst = node->nsDef; + while (tst != NULL) { + if ((tst->prefix == NULL) + && (prefix == NULL)) + return (0); + if ((tst->prefix != NULL) + && (prefix != NULL) + && (xmlStrEqual(tst->prefix, prefix))) + return (0); + tst = tst->next; + } + } + node = node->parent; + } + if (node != ancestor) + return (-1); + return (1); +} + +/** + * xmlSearchNsByHref: + * @doc: the document + * @node: the current node + * @href: the namespace value + * + * Search a Ns aliasing a given URI. Recurse on the parents until it finds + * the defined namespace or return NULL otherwise. + * Returns the namespace pointer or NULL. + */ +xmlNsPtr +xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href) +{ + xmlNsPtr cur; + xmlNodePtr orig = node; + int is_attr; + + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) || (href == NULL)) + return (NULL); + if (xmlStrEqual(href, XML_XML_NAMESPACE)) { + /* + * Only the document can hold the XML spec namespace. + */ + if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) { + /* + * The XML-1.0 namespace is normally held on the root + * element. In this case exceptionally create it on the + * node element. + */ + cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); + if (cur == NULL) { + xmlTreeErrMemory("searching namespace"); + return (NULL); + } + memset(cur, 0, sizeof(xmlNs)); + cur->type = XML_LOCAL_NAMESPACE; + cur->href = xmlStrdup(XML_XML_NAMESPACE); + cur->prefix = xmlStrdup((const xmlChar *) "xml"); + cur->next = node->nsDef; + node->nsDef = cur; + return (cur); + } + if (doc == NULL) { + doc = node->doc; + if (doc == NULL) + return(NULL); + } + /* + * Return the XML namespace declaration held by the doc. + */ + if (doc->oldNs == NULL) + return(xmlTreeEnsureXMLDecl(doc)); + else + return(doc->oldNs); + } + is_attr = (node->type == XML_ATTRIBUTE_NODE); + while (node != NULL) { + if ((node->type == XML_ENTITY_REF_NODE) || + (node->type == XML_ENTITY_NODE) || + (node->type == XML_ENTITY_DECL)) + return (NULL); + if (node->type == XML_ELEMENT_NODE) { + cur = node->nsDef; + while (cur != NULL) { + if ((cur->href != NULL) && (href != NULL) && + (xmlStrEqual(cur->href, href))) { + if (((!is_attr) || (cur->prefix != NULL)) && + (xmlNsInScope(doc, orig, node, cur->prefix) == 1)) + return (cur); + } + cur = cur->next; + } + if (orig != node) { + cur = node->ns; + if (cur != NULL) { + if ((cur->href != NULL) && (href != NULL) && + (xmlStrEqual(cur->href, href))) { + if (((!is_attr) || (cur->prefix != NULL)) && + (xmlNsInScope(doc, orig, node, cur->prefix) == 1)) + return (cur); + } + } + } + } + node = node->parent; + } + return (NULL); +} + +/** + * xmlNewReconciledNs: + * @doc: the document + * @tree: a node expected to hold the new namespace + * @ns: the original namespace + * + * This function tries to locate a namespace definition in a tree + * ancestors, or create a new namespace definition node similar to + * @ns trying to reuse the same prefix. However if the given prefix is + * null (default namespace) or reused within the subtree defined by + * @tree or on one of its ancestors then a new prefix is generated. + * Returns the (new) namespace definition or NULL in case of error + */ +static xmlNsPtr +xmlNewReconciledNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) { + xmlNsPtr def; + xmlChar prefix[50]; + int counter = 1; + + if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewReconciledNs : tree == NULL\n"); +#endif + return(NULL); + } + if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlNewReconciledNs : ns == NULL\n"); +#endif + return(NULL); + } + /* + * Search an existing namespace definition inherited. + */ + def = xmlSearchNsByHref(doc, tree, ns->href); + if (def != NULL) + return(def); + + /* + * Find a close prefix which is not already in use. + * Let's strip namespace prefixes longer than 20 chars ! + */ + if (ns->prefix == NULL) + snprintf((char *) prefix, sizeof(prefix), "default"); + else + snprintf((char *) prefix, sizeof(prefix), "%.20s", (char *)ns->prefix); + + def = xmlSearchNs(doc, tree, prefix); + while (def != NULL) { + if (counter > 1000) return(NULL); + if (ns->prefix == NULL) + snprintf((char *) prefix, sizeof(prefix), "default%d", counter++); + else + snprintf((char *) prefix, sizeof(prefix), "%.20s%d", + (char *)ns->prefix, counter++); + def = xmlSearchNs(doc, tree, prefix); + } + + /* + * OK, now we are ready to create a new one. + */ + def = xmlNewNs(tree, ns->href, prefix); + return(def); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlReconciliateNs: + * @doc: the document + * @tree: a node defining the subtree to reconciliate + * + * This function checks that all the namespaces declared within the given + * tree are properly declared. This is needed for example after Copy or Cut + * and then paste operations. The subtree may still hold pointers to + * namespace declarations outside the subtree or invalid/masked. As much + * as possible the function try to reuse the existing namespaces found in + * the new environment. If not possible the new namespaces are redeclared + * on @tree at the top of the given subtree. + * Returns the number of namespace declarations created or -1 in case of error. + */ +int +xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) { + xmlNsPtr *oldNs = NULL; + xmlNsPtr *newNs = NULL; + int sizeCache = 0; + int nbCache = 0; + + xmlNsPtr n; + xmlNodePtr node = tree; + xmlAttrPtr attr; + int ret = 0, i; + + if ((node == NULL) || (node->type != XML_ELEMENT_NODE)) return(-1); + if ((doc == NULL) || (doc->type != XML_DOCUMENT_NODE)) return(-1); + if (node->doc != doc) return(-1); + while (node != NULL) { + /* + * Reconciliate the node namespace + */ + if (node->ns != NULL) { + /* + * initialize the cache if needed + */ + if (sizeCache == 0) { + sizeCache = 10; + oldNs = (xmlNsPtr *) xmlMalloc(sizeCache * + sizeof(xmlNsPtr)); + if (oldNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + return(-1); + } + newNs = (xmlNsPtr *) xmlMalloc(sizeCache * + sizeof(xmlNsPtr)); + if (newNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + xmlFree(oldNs); + return(-1); + } + } + for (i = 0;i < nbCache;i++) { + if (oldNs[i] == node->ns) { + node->ns = newNs[i]; + break; + } + } + if (i == nbCache) { + /* + * OK we need to recreate a new namespace definition + */ + n = xmlNewReconciledNs(doc, tree, node->ns); + if (n != NULL) { /* :-( what if else ??? */ + /* + * check if we need to grow the cache buffers. + */ + if (sizeCache <= nbCache) { + sizeCache *= 2; + oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache * + sizeof(xmlNsPtr)); + if (oldNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + xmlFree(newNs); + return(-1); + } + newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache * + sizeof(xmlNsPtr)); + if (newNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + xmlFree(oldNs); + return(-1); + } + } + newNs[nbCache] = n; + oldNs[nbCache++] = node->ns; + node->ns = n; + } + } + } + /* + * now check for namespace held by attributes on the node. + */ + if (node->type == XML_ELEMENT_NODE) { + attr = node->properties; + while (attr != NULL) { + if (attr->ns != NULL) { + /* + * initialize the cache if needed + */ + if (sizeCache == 0) { + sizeCache = 10; + oldNs = (xmlNsPtr *) xmlMalloc(sizeCache * + sizeof(xmlNsPtr)); + if (oldNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + return(-1); + } + newNs = (xmlNsPtr *) xmlMalloc(sizeCache * + sizeof(xmlNsPtr)); + if (newNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + xmlFree(oldNs); + return(-1); + } + } + for (i = 0;i < nbCache;i++) { + if (oldNs[i] == attr->ns) { + attr->ns = newNs[i]; + break; + } + } + if (i == nbCache) { + /* + * OK we need to recreate a new namespace definition + */ + n = xmlNewReconciledNs(doc, tree, attr->ns); + if (n != NULL) { /* :-( what if else ??? */ + /* + * check if we need to grow the cache buffers. + */ + if (sizeCache <= nbCache) { + sizeCache *= 2; + oldNs = (xmlNsPtr *) xmlRealloc(oldNs, + sizeCache * sizeof(xmlNsPtr)); + if (oldNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + xmlFree(newNs); + return(-1); + } + newNs = (xmlNsPtr *) xmlRealloc(newNs, + sizeCache * sizeof(xmlNsPtr)); + if (newNs == NULL) { + xmlTreeErrMemory("fixing namespaces"); + xmlFree(oldNs); + return(-1); + } + } + newNs[nbCache] = n; + oldNs[nbCache++] = attr->ns; + attr->ns = n; + } + } + } + attr = attr->next; + } + } + + /* + * Browse the full subtree, deep first + */ + if ((node->children != NULL) && (node->type != XML_ENTITY_REF_NODE)) { + /* deep first */ + node = node->children; + } else if ((node != tree) && (node->next != NULL)) { + /* then siblings */ + node = node->next; + } else if (node != tree) { + /* go up to parents->next if needed */ + while (node != tree) { + if (node->parent != NULL) + node = node->parent; + if ((node != tree) && (node->next != NULL)) { + node = node->next; + break; + } + if (node->parent == NULL) { + node = NULL; + break; + } + } + /* exit condition */ + if (node == tree) + node = NULL; + } else + break; + } + if (oldNs != NULL) + xmlFree(oldNs); + if (newNs != NULL) + xmlFree(newNs); + return(ret); +} +#endif /* LIBXML_TREE_ENABLED */ + +static xmlAttrPtr +xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name, + const xmlChar *nsName, int useDTD) +{ + xmlAttrPtr prop; + + if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL)) + return(NULL); + + if (node->properties != NULL) { + prop = node->properties; + if (nsName == NULL) { + /* + * We want the attr to be in no namespace. + */ + do { + if ((prop->ns == NULL) && xmlStrEqual(prop->name, name)) { + return(prop); + } + prop = prop->next; + } while (prop != NULL); + } else { + /* + * We want the attr to be in the specified namespace. + */ + do { + if ((prop->ns != NULL) && xmlStrEqual(prop->name, name) && + ((prop->ns->href == nsName) || + xmlStrEqual(prop->ns->href, nsName))) + { + return(prop); + } + prop = prop->next; + } while (prop != NULL); + } + } + +#ifdef LIBXML_TREE_ENABLED + if (! useDTD) + return(NULL); + /* + * Check if there is a default/fixed attribute declaration in + * the internal or external subset. + */ + if ((node->doc != NULL) && (node->doc->intSubset != NULL)) { + xmlDocPtr doc = node->doc; + xmlAttributePtr attrDecl = NULL; + xmlChar *elemQName, *tmpstr = NULL; + + /* + * We need the QName of the element for the DTD-lookup. + */ + if ((node->ns != NULL) && (node->ns->prefix != NULL)) { + tmpstr = xmlStrdup(node->ns->prefix); + tmpstr = xmlStrcat(tmpstr, BAD_CAST ":"); + tmpstr = xmlStrcat(tmpstr, node->name); + if (tmpstr == NULL) + return(NULL); + elemQName = tmpstr; + } else + elemQName = (xmlChar *) node->name; + if (nsName == NULL) { + /* + * The common and nice case: Attr in no namespace. + */ + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, + elemQName, name, NULL); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) { + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, + elemQName, name, NULL); + } + } else if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) { + /* + * The XML namespace must be bound to prefix 'xml'. + */ + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, + elemQName, name, BAD_CAST "xml"); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) { + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, + elemQName, name, BAD_CAST "xml"); + } + } else { + xmlNsPtr *nsList, *cur; + + /* + * The ugly case: Search using the prefixes of in-scope + * ns-decls corresponding to @nsName. + */ + nsList = xmlGetNsList(node->doc, node); + if (nsList == NULL) { + if (tmpstr != NULL) + xmlFree(tmpstr); + return(NULL); + } + cur = nsList; + while (*cur != NULL) { + if (xmlStrEqual((*cur)->href, nsName)) { + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elemQName, + name, (*cur)->prefix); + if (attrDecl) + break; + if (doc->extSubset != NULL) { + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elemQName, + name, (*cur)->prefix); + if (attrDecl) + break; + } + } + cur++; + } + xmlFree(nsList); + } + if (tmpstr != NULL) + xmlFree(tmpstr); + /* + * Only default/fixed attrs are relevant. + */ + if ((attrDecl != NULL) && (attrDecl->defaultValue != NULL)) + return((xmlAttrPtr) attrDecl); + } +#endif /* LIBXML_TREE_ENABLED */ + return(NULL); +} + +static xmlChar* +xmlGetPropNodeValueInternal(const xmlAttr *prop) +{ + if (prop == NULL) + return(NULL); + if (prop->type == XML_ATTRIBUTE_NODE) { + /* + * Note that we return at least the empty string. + * TODO: Do we really always want that? + */ + if (prop->children != NULL) { + if ((prop->children->next == NULL) && + ((prop->children->type == XML_TEXT_NODE) || + (prop->children->type == XML_CDATA_SECTION_NODE))) + { + /* + * Optimization for the common case: only 1 text node. + */ + return(xmlStrdup(prop->children->content)); + } else { + xmlChar *ret; + + ret = xmlNodeListGetString(prop->doc, prop->children, 1); + if (ret != NULL) + return(ret); + } + } + return(xmlStrdup((xmlChar *)"")); + } else if (prop->type == XML_ATTRIBUTE_DECL) { + return(xmlStrdup(((xmlAttributePtr)prop)->defaultValue)); + } + return(NULL); +} + +/** + * xmlHasProp: + * @node: the node + * @name: the attribute name + * + * Search an attribute associated to a node + * This function also looks in DTD attribute declaration for #FIXED or + * default declaration values unless DTD use has been turned off. + * + * Returns the attribute or the attribute declaration or NULL if + * neither was found. + */ +xmlAttrPtr +xmlHasProp(const xmlNode *node, const xmlChar *name) { + xmlAttrPtr prop; + xmlDocPtr doc; + + if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL)) + return(NULL); + /* + * Check on the properties attached to the node + */ + prop = node->properties; + while (prop != NULL) { + if (xmlStrEqual(prop->name, name)) { + return(prop); + } + prop = prop->next; + } + if (!xmlCheckDTD) return(NULL); + + /* + * Check if there is a default declaration in the internal + * or external subsets + */ + doc = node->doc; + if (doc != NULL) { + xmlAttributePtr attrDecl; + if (doc->intSubset != NULL) { + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name); + if ((attrDecl != NULL) && (attrDecl->defaultValue != NULL)) + /* return attribute declaration only if a default value is given + (that includes #FIXED declarations) */ + return((xmlAttrPtr) attrDecl); + } + } + return(NULL); +} + +/** + * xmlHasNsProp: + * @node: the node + * @name: the attribute name + * @nameSpace: the URI of the namespace + * + * Search for an attribute associated to a node + * This attribute has to be anchored in the namespace specified. + * This does the entity substitution. + * This function looks in DTD attribute declaration for #FIXED or + * default declaration values unless DTD use has been turned off. + * Note that a namespace of NULL indicates to use the default namespace. + * + * Returns the attribute or the attribute declaration or NULL + * if neither was found. + */ +xmlAttrPtr +xmlHasNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) { + + return(xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD)); +} + +/** + * xmlGetProp: + * @node: the node + * @name: the attribute name + * + * Search and get the value of an attribute associated to a node + * This does the entity substitution. + * This function looks in DTD attribute declaration for #FIXED or + * default declaration values unless DTD use has been turned off. + * NOTE: this function acts independently of namespaces associated + * to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() + * for namespace aware processing. + * + * Returns the attribute value or NULL if not found. + * It's up to the caller to free the memory with xmlFree(). + */ +xmlChar * +xmlGetProp(const xmlNode *node, const xmlChar *name) { + xmlAttrPtr prop; + + prop = xmlHasProp(node, name); + if (prop == NULL) + return(NULL); + return(xmlGetPropNodeValueInternal(prop)); +} + +/** + * xmlGetNoNsProp: + * @node: the node + * @name: the attribute name + * + * Search and get the value of an attribute associated to a node + * This does the entity substitution. + * This function looks in DTD attribute declaration for #FIXED or + * default declaration values unless DTD use has been turned off. + * This function is similar to xmlGetProp except it will accept only + * an attribute in no namespace. + * + * Returns the attribute value or NULL if not found. + * It's up to the caller to free the memory with xmlFree(). + */ +xmlChar * +xmlGetNoNsProp(const xmlNode *node, const xmlChar *name) { + xmlAttrPtr prop; + + prop = xmlGetPropNodeInternal(node, name, NULL, xmlCheckDTD); + if (prop == NULL) + return(NULL); + return(xmlGetPropNodeValueInternal(prop)); +} + +/** + * xmlGetNsProp: + * @node: the node + * @name: the attribute name + * @nameSpace: the URI of the namespace + * + * Search and get the value of an attribute associated to a node + * This attribute has to be anchored in the namespace specified. + * This does the entity substitution. + * This function looks in DTD attribute declaration for #FIXED or + * default declaration values unless DTD use has been turned off. + * + * Returns the attribute value or NULL if not found. + * It's up to the caller to free the memory with xmlFree(). + */ +xmlChar * +xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) { + xmlAttrPtr prop; + + prop = xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD); + if (prop == NULL) + return(NULL); + return(xmlGetPropNodeValueInternal(prop)); +} + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlUnsetProp: + * @node: the node + * @name: the attribute name + * + * Remove an attribute carried by a node. + * This handles only attributes in no namespace. + * Returns 0 if successful, -1 if not found + */ +int +xmlUnsetProp(xmlNodePtr node, const xmlChar *name) { + xmlAttrPtr prop; + + prop = xmlGetPropNodeInternal(node, name, NULL, 0); + if (prop == NULL) + return(-1); + xmlUnlinkNode((xmlNodePtr) prop); + xmlFreeProp(prop); + return(0); +} + +/** + * xmlUnsetNsProp: + * @node: the node + * @ns: the namespace definition + * @name: the attribute name + * + * Remove an attribute carried by a node. + * Returns 0 if successful, -1 if not found + */ +int +xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) { + xmlAttrPtr prop; + + prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0); + if (prop == NULL) + return(-1); + xmlUnlinkNode((xmlNodePtr) prop); + xmlFreeProp(prop); + return(0); +} +#endif + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) +/** + * xmlSetProp: + * @node: the node + * @name: the attribute name (a QName) + * @value: the attribute value + * + * Set (or reset) an attribute carried by a node. + * If @name has a prefix, then the corresponding + * namespace-binding will be used, if in scope; it is an + * error it there's no such ns-binding for the prefix in + * scope. + * Returns the attribute pointer. + * + */ +xmlAttrPtr +xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) { + int len; + const xmlChar *nqname; + + if ((node == NULL) || (name == NULL) || (node->type != XML_ELEMENT_NODE)) + return(NULL); + + /* + * handle QNames + */ + nqname = xmlSplitQName3(name, &len); + if (nqname != NULL) { + xmlNsPtr ns; + xmlChar *prefix = xmlStrndup(name, len); + ns = xmlSearchNs(node->doc, node, prefix); + if (prefix != NULL) + xmlFree(prefix); + if (ns != NULL) + return(xmlSetNsProp(node, ns, nqname, value)); + } + return(xmlSetNsProp(node, NULL, name, value)); +} + +/** + * xmlSetNsProp: + * @node: the node + * @ns: the namespace definition + * @name: the attribute name + * @value: the attribute value + * + * Set (or reset) an attribute carried by a node. + * The ns structure must be in scope, this is not checked + * + * Returns the attribute pointer. + */ +xmlAttrPtr +xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, + const xmlChar *value) +{ + xmlAttrPtr prop; + + if (ns && (ns->href == NULL)) + return(NULL); + prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0); + if (prop != NULL) { + /* + * Modify the attribute's value. + */ + if (prop->atype == XML_ATTRIBUTE_ID) { + xmlRemoveID(node->doc, prop); + prop->atype = XML_ATTRIBUTE_ID; + } + if (prop->children != NULL) + xmlFreeNodeList(prop->children); + prop->children = NULL; + prop->last = NULL; + prop->ns = ns; + if (value != NULL) { + xmlNodePtr tmp; + + prop->children = xmlNewDocText(node->doc, value); + prop->last = NULL; + tmp = prop->children; + while (tmp != NULL) { + tmp->parent = (xmlNodePtr) prop; + if (tmp->next == NULL) + prop->last = tmp; + tmp = tmp->next; + } + } + if (prop->atype == XML_ATTRIBUTE_ID) + xmlAddID(NULL, node->doc, value, prop); + return(prop); + } + /* + * No equal attr found; create a new one. + */ + return(xmlNewPropInternal(node, ns, name, value, 0)); +} + +#endif /* LIBXML_TREE_ENABLED */ + +/** + * xmlNodeIsText: + * @node: the node + * + * Is this node a Text node ? + * Returns 1 yes, 0 no + */ +int +xmlNodeIsText(const xmlNode *node) { + if (node == NULL) return(0); + + if (node->type == XML_TEXT_NODE) return(1); + return(0); +} + +/** + * xmlIsBlankNode: + * @node: the node + * + * Checks whether this node is an empty or whitespace only + * (and possibly ignorable) text-node. + * + * Returns 1 yes, 0 no + */ +int +xmlIsBlankNode(const xmlNode *node) { + const xmlChar *cur; + if (node == NULL) return(0); + + if ((node->type != XML_TEXT_NODE) && + (node->type != XML_CDATA_SECTION_NODE)) + return(0); + if (node->content == NULL) return(1); + cur = node->content; + while (*cur != 0) { + if (!IS_BLANK_CH(*cur)) return(0); + cur++; + } + + return(1); +} + +/** + * xmlTextConcat: + * @node: the node + * @content: the content + * @len: @content length + * + * Concat the given string at the end of the existing node content + * + * Returns -1 in case of error, 0 otherwise + */ + +int +xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) { + if (node == NULL) return(-1); + + if ((node->type != XML_TEXT_NODE) && + (node->type != XML_CDATA_SECTION_NODE) && + (node->type != XML_COMMENT_NODE) && + (node->type != XML_PI_NODE)) { +#ifdef DEBUG_TREE + xmlGenericError(xmlGenericErrorContext, + "xmlTextConcat: node is not text nor CDATA\n"); +#endif + return(-1); + } + /* need to check if content is currently in the dictionary */ + if ((node->content == (xmlChar *) &(node->properties)) || + ((node->doc != NULL) && (node->doc->dict != NULL) && + xmlDictOwns(node->doc->dict, node->content))) { + node->content = xmlStrncatNew(node->content, content, len); + } else { + node->content = xmlStrncat(node->content, content, len); + } + node->properties = NULL; + if (node->content == NULL) + return(-1); + return(0); +} + +/************************************************************************ + * * + * Output : to a FILE or in memory * + * * + ************************************************************************/ + +/** + * xmlBufferCreate: + * + * routine to create an XML buffer. + * returns the new structure. + */ +xmlBufferPtr +xmlBufferCreate(void) { + xmlBufferPtr ret; + + ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); + if (ret == NULL) { + xmlTreeErrMemory("creating buffer"); + return(NULL); + } + ret->use = 0; + ret->size = xmlDefaultBufferSize; + ret->alloc = xmlBufferAllocScheme; + ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); + if (ret->content == NULL) { + xmlTreeErrMemory("creating buffer"); + xmlFree(ret); + return(NULL); + } + ret->content[0] = 0; + ret->contentIO = NULL; + return(ret); +} + +/** + * xmlBufferCreateSize: + * @size: initial size of buffer + * + * routine to create an XML buffer. + * returns the new structure. + */ +xmlBufferPtr +xmlBufferCreateSize(size_t size) { + xmlBufferPtr ret; + + ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); + if (ret == NULL) { + xmlTreeErrMemory("creating buffer"); + return(NULL); + } + ret->use = 0; + ret->alloc = xmlBufferAllocScheme; + ret->size = (size ? size+2 : 0); /* +1 for ending null */ + if (ret->size){ + ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); + if (ret->content == NULL) { + xmlTreeErrMemory("creating buffer"); + xmlFree(ret); + return(NULL); + } + ret->content[0] = 0; + } else + ret->content = NULL; + ret->contentIO = NULL; + return(ret); +} + +/** + * xmlBufferDetach: + * @buf: the buffer + * + * Remove the string contained in a buffer and gie it back to the + * caller. The buffer is reset to an empty content. + * This doesn't work with immutable buffers as they can't be reset. + * + * Returns the previous string contained by the buffer. + */ +xmlChar * +xmlBufferDetach(xmlBufferPtr buf) { + xmlChar *ret; + + if (buf == NULL) + return(NULL); + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) + return(NULL); + + ret = buf->content; + buf->content = NULL; + buf->size = 0; + buf->use = 0; + + return ret; +} + + +/** + * xmlBufferCreateStatic: + * @mem: the memory area + * @size: the size in byte + * + * routine to create an XML buffer from an immutable memory area. + * The area won't be modified nor copied, and is expected to be + * present until the end of the buffer lifetime. + * + * returns the new structure. + */ +xmlBufferPtr +xmlBufferCreateStatic(void *mem, size_t size) { + xmlBufferPtr ret; + + if ((mem == NULL) || (size == 0)) + return(NULL); + + ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer)); + if (ret == NULL) { + xmlTreeErrMemory("creating buffer"); + return(NULL); + } + ret->use = size; + ret->size = size; + ret->alloc = XML_BUFFER_ALLOC_IMMUTABLE; + ret->content = (xmlChar *) mem; + return(ret); +} + +/** + * xmlBufferSetAllocationScheme: + * @buf: the buffer to tune + * @scheme: allocation scheme to use + * + * Sets the allocation scheme for this buffer + */ +void +xmlBufferSetAllocationScheme(xmlBufferPtr buf, + xmlBufferAllocationScheme scheme) { + if (buf == NULL) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferSetAllocationScheme: buf == NULL\n"); +#endif + return; + } + if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) || + (buf->alloc == XML_BUFFER_ALLOC_IO)) return; + if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) || + (scheme == XML_BUFFER_ALLOC_EXACT) || + (scheme == XML_BUFFER_ALLOC_HYBRID) || + (scheme == XML_BUFFER_ALLOC_IMMUTABLE)) + buf->alloc = scheme; +} + +/** + * xmlBufferFree: + * @buf: the buffer to free + * + * Frees an XML buffer. It frees both the content and the structure which + * encapsulate it. + */ +void +xmlBufferFree(xmlBufferPtr buf) { + if (buf == NULL) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferFree: buf == NULL\n"); +#endif + return; + } + + if ((buf->alloc == XML_BUFFER_ALLOC_IO) && + (buf->contentIO != NULL)) { + xmlFree(buf->contentIO); + } else if ((buf->content != NULL) && + (buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) { + xmlFree(buf->content); + } + xmlFree(buf); +} + +/** + * xmlBufferEmpty: + * @buf: the buffer + * + * empty a buffer. + */ +void +xmlBufferEmpty(xmlBufferPtr buf) { + if (buf == NULL) return; + if (buf->content == NULL) return; + buf->use = 0; + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) { + buf->content = BAD_CAST ""; + } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) && + (buf->contentIO != NULL)) { + size_t start_buf = buf->content - buf->contentIO; + + buf->size += start_buf; + buf->content = buf->contentIO; + buf->content[0] = 0; + } else { + buf->content[0] = 0; + } +} + +/** + * xmlBufferShrink: + * @buf: the buffer to dump + * @len: the number of xmlChar to remove + * + * Remove the beginning of an XML buffer. + * + * Returns the number of #xmlChar removed, or -1 in case of failure. + */ +int +xmlBufferShrink(xmlBufferPtr buf, unsigned int len) { + if (buf == NULL) return(-1); + if (len == 0) return(0); + if (len > buf->use) return(-1); + + buf->use -= len; + if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) || + ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) { + /* + * we just move the content pointer, but also make sure + * the perceived buffer size has shrunk accordingly + */ + buf->content += len; + buf->size -= len; + + /* + * sometimes though it maybe be better to really shrink + * on IO buffers + */ + if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { + size_t start_buf = buf->content - buf->contentIO; + if (start_buf >= buf->size) { + memmove(buf->contentIO, &buf->content[0], buf->use); + buf->content = buf->contentIO; + buf->content[buf->use] = 0; + buf->size += start_buf; + } + } + } else { + memmove(buf->content, &buf->content[len], buf->use); + buf->content[buf->use] = 0; + } + return(len); +} + +/** + * xmlBufferGrow: + * @buf: the buffer + * @len: the minimum free size to allocate + * + * Grow the available space of an XML buffer. + * + * Returns the new available space or -1 in case of error + */ +int +xmlBufferGrow(xmlBufferPtr buf, unsigned int len) { + int size; + xmlChar *newbuf; + + if (buf == NULL) return(-1); + + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); + if (len + buf->use < buf->size) return(0); + + /* + * Windows has a BIG problem on realloc timing, so we try to double + * the buffer size (if that's enough) (bug 146697) + * Apparently BSD too, and it's probably best for linux too + * On an embedded system this may be something to change + */ +#if 1 + if (buf->size > len) + size = buf->size * 2; + else + size = buf->use + len + 100; +#else + size = buf->use + len + 100; +#endif + + if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { + size_t start_buf = buf->content - buf->contentIO; + + newbuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + size); + if (newbuf == NULL) { + xmlTreeErrMemory("growing buffer"); + return(-1); + } + buf->contentIO = newbuf; + buf->content = newbuf + start_buf; + } else { + newbuf = (xmlChar *) xmlRealloc(buf->content, size); + if (newbuf == NULL) { + xmlTreeErrMemory("growing buffer"); + return(-1); + } + buf->content = newbuf; + } + buf->size = size; + return(buf->size - buf->use); +} + +/** + * xmlBufferDump: + * @file: the file output + * @buf: the buffer to dump + * + * Dumps an XML buffer to a FILE *. + * Returns the number of #xmlChar written + */ +int +xmlBufferDump(FILE *file, xmlBufferPtr buf) { + int ret; + + if (buf == NULL) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferDump: buf == NULL\n"); +#endif + return(0); + } + if (buf->content == NULL) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferDump: buf->content == NULL\n"); +#endif + return(0); + } + if (file == NULL) + file = stdout; + ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file); + return(ret); +} + +/** + * xmlBufferContent: + * @buf: the buffer + * + * Function to extract the content of a buffer + * + * Returns the internal content + */ + +const xmlChar * +xmlBufferContent(const xmlBuffer *buf) +{ + if(!buf) + return NULL; + + return buf->content; +} + +/** + * xmlBufferLength: + * @buf: the buffer + * + * Function to get the length of a buffer + * + * Returns the length of data in the internal content + */ + +int +xmlBufferLength(const xmlBuffer *buf) +{ + if(!buf) + return 0; + + return buf->use; +} + +/** + * xmlBufferResize: + * @buf: the buffer to resize + * @size: the desired size + * + * Resize a buffer to accommodate minimum size of @size. + * + * Returns 0 in case of problems, 1 otherwise + */ +int +xmlBufferResize(xmlBufferPtr buf, unsigned int size) +{ + unsigned int newSize; + xmlChar* rebuf = NULL; + size_t start_buf; + + if (buf == NULL) + return(0); + + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); + + /* Don't resize if we don't have to */ + if (size < buf->size) + return 1; + + if (size > UINT_MAX - 10) { + xmlTreeErrMemory("growing buffer"); + return 0; + } + + /* figure out new size */ + switch (buf->alloc){ + case XML_BUFFER_ALLOC_IO: + case XML_BUFFER_ALLOC_DOUBLEIT: + /*take care of empty case*/ + newSize = (buf->size ? buf->size : size + 10); + while (size > newSize) { + if (newSize > UINT_MAX / 2) { + xmlTreeErrMemory("growing buffer"); + return 0; + } + newSize *= 2; + } + break; + case XML_BUFFER_ALLOC_EXACT: + newSize = size+10; + break; + case XML_BUFFER_ALLOC_HYBRID: + if (buf->use < BASE_BUFFER_SIZE) + newSize = size; + else { + newSize = buf->size; + while (size > newSize) { + if (newSize > UINT_MAX / 2) { + xmlTreeErrMemory("growing buffer"); + return 0; + } + newSize *= 2; + } + } + break; + + default: + newSize = size+10; + break; + } + + if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { + start_buf = buf->content - buf->contentIO; + + if (start_buf > newSize) { + /* move data back to start */ + memmove(buf->contentIO, buf->content, buf->use); + buf->content = buf->contentIO; + buf->content[buf->use] = 0; + buf->size += start_buf; + } else { + rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize); + if (rebuf == NULL) { + xmlTreeErrMemory("growing buffer"); + return 0; + } + buf->contentIO = rebuf; + buf->content = rebuf + start_buf; + } + } else { + if (buf->content == NULL) { + rebuf = (xmlChar *) xmlMallocAtomic(newSize); + } else if (buf->size - buf->use < 100) { + rebuf = (xmlChar *) xmlRealloc(buf->content, newSize); + } else { + /* + * if we are reallocating a buffer far from being full, it's + * better to make a new allocation and copy only the used range + * and free the old one. + */ + rebuf = (xmlChar *) xmlMallocAtomic(newSize); + if (rebuf != NULL) { + memcpy(rebuf, buf->content, buf->use); + xmlFree(buf->content); + rebuf[buf->use] = 0; + } + } + if (rebuf == NULL) { + xmlTreeErrMemory("growing buffer"); + return 0; + } + buf->content = rebuf; + } + buf->size = newSize; + + return 1; +} + +/** + * xmlBufferAdd: + * @buf: the buffer to dump + * @str: the #xmlChar string + * @len: the number of #xmlChar to add + * + * Add a string range to 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 +xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { + unsigned int needSize; + + if ((str == NULL) || (buf == NULL)) { + return -1; + } + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; + if (len < -1) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferAdd: len < 0\n"); +#endif + return -1; + } + if (len == 0) return 0; + + if (len < 0) + len = xmlStrlen(str); + + if (len < 0) return -1; + if (len == 0) return 0; + + needSize = buf->use + len + 2; + if (needSize > buf->size){ + if (!xmlBufferResize(buf, needSize)){ + xmlTreeErrMemory("growing buffer"); + return XML_ERR_NO_MEMORY; + } + } + + memmove(&buf->content[buf->use], str, len*sizeof(xmlChar)); + buf->use += len; + buf->content[buf->use] = 0; + return 0; +} + +/** + * xmlBufferAddHead: + * @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 +xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) { + unsigned int needSize; + + if (buf == NULL) + return(-1); + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; + if (str == NULL) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferAddHead: str == NULL\n"); +#endif + return -1; + } + if (len < -1) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferAddHead: 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 shrunk + */ + buf->content -= len; + memmove(&buf->content[0], str, len); + buf->use += len; + buf->size += len; + return(0); + } + } + needSize = buf->use + len + 2; + if (needSize > buf->size){ + if (!xmlBufferResize(buf, needSize)){ + xmlTreeErrMemory("growing buffer"); + return XML_ERR_NO_MEMORY; + } + } + + memmove(&buf->content[len], &buf->content[0], buf->use); + memmove(&buf->content[0], str, len); + buf->use += len; + buf->content[buf->use] = 0; + return 0; +} + +/** + * xmlBufferCat: + * @buf: the buffer to add to + * @str: the #xmlChar string + * + * Append a zero terminated string to an XML buffer. + * + * Returns 0 successful, a positive error code number otherwise + * and -1 in case of internal or API error. + */ +int +xmlBufferCat(xmlBufferPtr buf, const xmlChar *str) { + if (buf == NULL) + return(-1); + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; + if (str == NULL) return -1; + return xmlBufferAdd(buf, str, -1); +} + +/** + * xmlBufferCCat: + * @buf: the buffer to dump + * @str: the C char string + * + * Append a zero terminated C string to an XML buffer. + * + * Returns 0 successful, a positive error code number otherwise + * and -1 in case of internal or API error. + */ +int +xmlBufferCCat(xmlBufferPtr buf, const char *str) { + const char *cur; + + if (buf == NULL) + return(-1); + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1; + if (str == NULL) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferCCat: str == NULL\n"); +#endif + return -1; + } + for (cur = str;*cur != 0;cur++) { + if (buf->use + 10 >= buf->size) { + if (!xmlBufferResize(buf, buf->use+10)){ + xmlTreeErrMemory("growing buffer"); + return XML_ERR_NO_MEMORY; + } + } + buf->content[buf->use++] = *cur; + } + buf->content[buf->use] = 0; + return 0; +} + +/** + * xmlBufferWriteCHAR: + * @buf: the XML buffer + * @string: the string to add + * + * routine which manages and grows an output buffer. This one adds + * xmlChars at the end of the buffer. + */ +void +xmlBufferWriteCHAR(xmlBufferPtr buf, const xmlChar *string) { + if (buf == NULL) + return; + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; + xmlBufferCat(buf, string); +} + +/** + * xmlBufferWriteChar: + * @buf: the XML buffer output + * @string: the string to add + * + * routine which manage and grows an output buffer. This one add + * C chars at the end of the array. + */ +void +xmlBufferWriteChar(xmlBufferPtr buf, const char *string) { + if (buf == NULL) + return; + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; + xmlBufferCCat(buf, string); +} + + +/** + * xmlBufferWriteQuotedString: + * @buf: the XML buffer output + * @string: the string to add + * + * routine which manage and grows an output buffer. This one writes + * a quoted or double quoted #xmlChar string, checking first if it holds + * quote or double-quotes internally + */ +void +xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) { + const xmlChar *cur, *base; + if (buf == NULL) + return; + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return; + if (xmlStrchr(string, '\"')) { + if (xmlStrchr(string, '\'')) { +#ifdef DEBUG_BUFFER + xmlGenericError(xmlGenericErrorContext, + "xmlBufferWriteQuotedString: string contains quote and double-quotes !\n"); +#endif + xmlBufferCCat(buf, "\""); + base = cur = string; + while(*cur != 0){ + if(*cur == '"'){ + if (base != cur) + xmlBufferAdd(buf, base, cur - base); + xmlBufferAdd(buf, BAD_CAST """, 6); + cur++; + base = cur; + } + else { + cur++; + } + } + if (base != cur) + xmlBufferAdd(buf, base, cur - base); + xmlBufferCCat(buf, "\""); + } + else{ + xmlBufferCCat(buf, "\'"); + xmlBufferCat(buf, string); + xmlBufferCCat(buf, "\'"); + } + } else { + xmlBufferCCat(buf, "\""); + xmlBufferCat(buf, string); + xmlBufferCCat(buf, "\""); + } +} + + +/** + * xmlGetDocCompressMode: + * @doc: the document + * + * get the compression ratio for a document, ZLIB based + * Returns 0 (uncompressed) to 9 (max compression) + */ +int +xmlGetDocCompressMode (const xmlDoc *doc) { + if (doc == NULL) return(-1); + return(doc->compression); +} + +/** + * xmlSetDocCompressMode: + * @doc: the document + * @mode: the compression ratio + * + * set the compression ratio for a document, ZLIB based + * Correct values: 0 (uncompressed) to 9 (max compression) + */ +void +xmlSetDocCompressMode (xmlDocPtr doc, int mode) { + if (doc == NULL) return; + if (mode < 0) doc->compression = 0; + else if (mode > 9) doc->compression = 9; + else doc->compression = mode; +} + +/** + * xmlGetCompressMode: + * + * get the default compression mode used, ZLIB based. + * Returns 0 (uncompressed) to 9 (max compression) + */ +int +xmlGetCompressMode(void) +{ + return (xmlCompressMode); +} + +/** + * xmlSetCompressMode: + * @mode: the compression ratio + * + * set the default compression mode used, ZLIB based + * Correct values: 0 (uncompressed) to 9 (max compression) + */ +void +xmlSetCompressMode(int mode) { + if (mode < 0) xmlCompressMode = 0; + else if (mode > 9) xmlCompressMode = 9; + else xmlCompressMode = mode; +} + +#define XML_TREE_NSMAP_PARENT -1 +#define XML_TREE_NSMAP_XML -2 +#define XML_TREE_NSMAP_DOC -3 +#define XML_TREE_NSMAP_CUSTOM -4 + +typedef struct xmlNsMapItem *xmlNsMapItemPtr; +struct xmlNsMapItem { + xmlNsMapItemPtr next; + xmlNsMapItemPtr prev; + xmlNsPtr oldNs; /* old ns decl reference */ + xmlNsPtr newNs; /* new ns decl reference */ + int shadowDepth; /* Shadowed at this depth */ + /* + * depth: + * >= 0 == @node's ns-decls + * -1 == @parent's ns-decls + * -2 == the doc->oldNs XML ns-decl + * -3 == the doc->oldNs storage ns-decls + * -4 == ns-decls provided via custom ns-handling + */ + int depth; +}; + +typedef struct xmlNsMap *xmlNsMapPtr; +struct xmlNsMap { + xmlNsMapItemPtr first; + xmlNsMapItemPtr last; + xmlNsMapItemPtr pool; +}; + +#define XML_NSMAP_NOTEMPTY(m) (((m) != NULL) && ((m)->first != NULL)) +#define XML_NSMAP_FOREACH(m, i) for (i = (m)->first; i != NULL; i = (i)->next) +#define XML_NSMAP_POP(m, i) \ + i = (m)->last; \ + (m)->last = (i)->prev; \ + if ((m)->last == NULL) \ + (m)->first = NULL; \ + else \ + (m)->last->next = NULL; \ + (i)->next = (m)->pool; \ + (m)->pool = i; + +/* +* xmlDOMWrapNsMapFree: +* @map: the ns-map +* +* Frees the ns-map +*/ +static void +xmlDOMWrapNsMapFree(xmlNsMapPtr nsmap) +{ + xmlNsMapItemPtr cur, tmp; + + if (nsmap == NULL) + return; + cur = nsmap->pool; + while (cur != NULL) { + tmp = cur; + cur = cur->next; + xmlFree(tmp); + } + cur = nsmap->first; + while (cur != NULL) { + tmp = cur; + cur = cur->next; + xmlFree(tmp); + } + xmlFree(nsmap); +} + +/* +* xmlDOMWrapNsMapAddItem: +* @map: the ns-map +* @oldNs: the old ns-struct +* @newNs: the new ns-struct +* @depth: depth and ns-kind information +* +* Adds an ns-mapping item. +*/ +static xmlNsMapItemPtr +xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position, + xmlNsPtr oldNs, xmlNsPtr newNs, int depth) +{ + xmlNsMapItemPtr ret; + xmlNsMapPtr map; + + if (nsmap == NULL) + return(NULL); + if ((position != -1) && (position != 0)) + return(NULL); + map = *nsmap; + + if (map == NULL) { + /* + * Create the ns-map. + */ + map = (xmlNsMapPtr) xmlMalloc(sizeof(struct xmlNsMap)); + if (map == NULL) { + xmlTreeErrMemory("allocating namespace map"); + return (NULL); + } + memset(map, 0, sizeof(struct xmlNsMap)); + *nsmap = map; + } + + if (map->pool != NULL) { + /* + * Reuse an item from the pool. + */ + ret = map->pool; + map->pool = ret->next; + memset(ret, 0, sizeof(struct xmlNsMapItem)); + } else { + /* + * Create a new item. + */ + ret = (xmlNsMapItemPtr) xmlMalloc(sizeof(struct xmlNsMapItem)); + if (ret == NULL) { + xmlTreeErrMemory("allocating namespace map item"); + return (NULL); + } + memset(ret, 0, sizeof(struct xmlNsMapItem)); + } + + if (map->first == NULL) { + /* + * First ever. + */ + map->first = ret; + map->last = ret; + } else if (position == -1) { + /* + * Append. + */ + ret->prev = map->last; + map->last->next = ret; + map->last = ret; + } else if (position == 0) { + /* + * Set on first position. + */ + map->first->prev = ret; + ret->next = map->first; + map->first = ret; + } + + ret->oldNs = oldNs; + ret->newNs = newNs; + ret->shadowDepth = -1; + ret->depth = depth; + return (ret); +} + +/* +* xmlDOMWrapStoreNs: +* @doc: the doc +* @nsName: the namespace name +* @prefix: the prefix +* +* Creates or reuses an xmlNs struct on doc->oldNs with +* the given prefix and namespace name. +* +* Returns the acquired ns struct or NULL in case of an API +* or internal error. +*/ +static xmlNsPtr +xmlDOMWrapStoreNs(xmlDocPtr doc, + const xmlChar *nsName, + const xmlChar *prefix) +{ + xmlNsPtr ns; + + if (doc == NULL) + return (NULL); + ns = xmlTreeEnsureXMLDecl(doc); + if (ns == NULL) + return (NULL); + if (ns->next != NULL) { + /* Reuse. */ + ns = ns->next; + while (ns != NULL) { + if (((ns->prefix == prefix) || + xmlStrEqual(ns->prefix, prefix)) && + xmlStrEqual(ns->href, nsName)) { + return (ns); + } + if (ns->next == NULL) + break; + ns = ns->next; + } + } + /* Create. */ + if (ns != NULL) { + ns->next = xmlNewNs(NULL, nsName, prefix); + return (ns->next); + } + return(NULL); +} + +/* +* xmlDOMWrapNewCtxt: +* +* Allocates and initializes a new DOM-wrapper context. +* +* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal error. +*/ +xmlDOMWrapCtxtPtr +xmlDOMWrapNewCtxt(void) +{ + xmlDOMWrapCtxtPtr ret; + + ret = xmlMalloc(sizeof(xmlDOMWrapCtxt)); + if (ret == NULL) { + xmlTreeErrMemory("allocating DOM-wrapper context"); + return (NULL); + } + memset(ret, 0, sizeof(xmlDOMWrapCtxt)); + return (ret); +} + +/* +* xmlDOMWrapFreeCtxt: +* @ctxt: the DOM-wrapper context +* +* Frees the DOM-wrapper context. +*/ +void +xmlDOMWrapFreeCtxt(xmlDOMWrapCtxtPtr ctxt) +{ + if (ctxt == NULL) + return; + if (ctxt->namespaceMap != NULL) + xmlDOMWrapNsMapFree((xmlNsMapPtr) ctxt->namespaceMap); + /* + * TODO: Store the namespace map in the context. + */ + xmlFree(ctxt); +} + +/* +* xmlTreeLookupNsListByPrefix: +* @nsList: a list of ns-structs +* @prefix: the searched prefix +* +* Searches for a ns-decl with the given prefix in @nsList. +* +* Returns the ns-decl if found, NULL if not found and on +* API errors. +*/ +static xmlNsPtr +xmlTreeNSListLookupByPrefix(xmlNsPtr nsList, const xmlChar *prefix) +{ + if (nsList == NULL) + return (NULL); + { + xmlNsPtr ns; + ns = nsList; + do { + if ((prefix == ns->prefix) || + xmlStrEqual(prefix, ns->prefix)) { + return (ns); + } + ns = ns->next; + } while (ns != NULL); + } + return (NULL); +} + +/* +* +* xmlDOMWrapNSNormGatherInScopeNs: +* @map: the namespace map +* @node: the node to start with +* +* Puts in-scope namespaces into the ns-map. +* +* Returns 0 on success, -1 on API or internal errors. +*/ +static int +xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map, + xmlNodePtr node) +{ + xmlNodePtr cur; + xmlNsPtr ns; + xmlNsMapItemPtr mi; + int shadowed; + + if ((map == NULL) || (*map != NULL)) + return (-1); + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) + return (-1); + /* + * Get in-scope ns-decls of @parent. + */ + cur = node; + while ((cur != NULL) && (cur != (xmlNodePtr) cur->doc)) { + if (cur->type == XML_ELEMENT_NODE) { + if (cur->nsDef != NULL) { + ns = cur->nsDef; + do { + shadowed = 0; + if (XML_NSMAP_NOTEMPTY(*map)) { + /* + * Skip shadowed prefixes. + */ + XML_NSMAP_FOREACH(*map, mi) { + if ((ns->prefix == mi->newNs->prefix) || + xmlStrEqual(ns->prefix, mi->newNs->prefix)) { + shadowed = 1; + break; + } + } + } + /* + * Insert mapping. + */ + mi = xmlDOMWrapNsMapAddItem(map, 0, NULL, + ns, XML_TREE_NSMAP_PARENT); + if (mi == NULL) + return (-1); + if (shadowed) + mi->shadowDepth = 0; + ns = ns->next; + } while (ns != NULL); + } + } + cur = cur->parent; + } + return (0); +} + +/* +* XML_TREE_ADOPT_STR: If we have a dest-dict, put @str in the dict; +* otherwise copy it, when it was in the source-dict. +*/ +#define XML_TREE_ADOPT_STR(str) \ + if (adoptStr && (str != NULL)) { \ + if (destDoc->dict) { \ + const xmlChar *old = str; \ + str = xmlDictLookup(destDoc->dict, str, -1); \ + if ((sourceDoc == NULL) || (sourceDoc->dict == NULL) || \ + (!xmlDictOwns(sourceDoc->dict, old))) \ + xmlFree((char *)old); \ + } else if ((sourceDoc) && (sourceDoc->dict) && \ + xmlDictOwns(sourceDoc->dict, str)) { \ + str = BAD_CAST xmlStrdup(str); \ + } \ + } + +/* +* XML_TREE_ADOPT_STR_2: If @str was in the source-dict, then +* put it in dest-dict or copy it. +*/ +#define XML_TREE_ADOPT_STR_2(str) \ + if (adoptStr && (str != NULL) && (sourceDoc != NULL) && \ + (sourceDoc->dict != NULL) && \ + xmlDictOwns(sourceDoc->dict, cur->content)) { \ + if (destDoc->dict) \ + cur->content = (xmlChar *) \ + xmlDictLookup(destDoc->dict, cur->content, -1); \ + else \ + cur->content = xmlStrdup(BAD_CAST cur->content); \ + } + +/* +* xmlDOMWrapNSNormAddNsMapItem2: +* +* For internal use. Adds a ns-decl mapping. +* +* Returns 0 on success, -1 on internal errors. +*/ +static int +xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number, + xmlNsPtr oldNs, xmlNsPtr newNs) +{ + if (*list == NULL) { + *list = (xmlNsPtr *) xmlMalloc(6 * sizeof(xmlNsPtr)); + if (*list == NULL) { + xmlTreeErrMemory("alloc ns map item"); + return(-1); + } + *size = 3; + *number = 0; + } else if ((*number) >= (*size)) { + *size *= 2; + *list = (xmlNsPtr *) xmlRealloc(*list, + (*size) * 2 * sizeof(xmlNsPtr)); + if (*list == NULL) { + xmlTreeErrMemory("realloc ns map item"); + return(-1); + } + } + (*list)[2 * (*number)] = oldNs; + (*list)[2 * (*number) +1] = newNs; + (*number)++; + return (0); +} + +/* +* xmlDOMWrapRemoveNode: +* @ctxt: a DOM wrapper context +* @doc: the doc +* @node: the node to be removed. +* @options: set of options, unused at the moment +* +* Unlinks the given node from its owner. +* This will substitute ns-references to node->nsDef for +* ns-references to doc->oldNs, thus ensuring the removed +* branch to be autark wrt ns-references. +* +* NOTE: This function was not intensively tested. +* +* Returns 0 on success, 1 if the node is not supported, +* -1 on API and internal errors. +*/ +int +xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr node, int options ATTRIBUTE_UNUSED) +{ + xmlNsPtr *list = NULL; + int sizeList, nbList, i, j; + xmlNsPtr ns; + + if ((node == NULL) || (doc == NULL) || (node->doc != doc)) + return (-1); + + /* TODO: 0 or -1 ? */ + if (node->parent == NULL) + return (0); + + switch (node->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + xmlUnlinkNode(node); + return (0); + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + break; + default: + return (1); + } + xmlUnlinkNode(node); + /* + * Save out-of-scope ns-references in doc->oldNs. + */ + do { + switch (node->type) { + case XML_ELEMENT_NODE: + if ((ctxt == NULL) && (node->nsDef != NULL)) { + ns = node->nsDef; + do { + if (xmlDOMWrapNSNormAddNsMapItem2(&list, &sizeList, + &nbList, ns, ns) == -1) + goto internal_error; + ns = ns->next; + } while (ns != NULL); + } + /* Falls through. */ + case XML_ATTRIBUTE_NODE: + if (node->ns != NULL) { + /* + * Find a mapping. + */ + if (list != NULL) { + for (i = 0, j = 0; i < nbList; i++, j += 2) { + if (node->ns == list[j]) { + node->ns = list[++j]; + goto next_node; + } + } + } + ns = NULL; + if (ctxt != NULL) { + /* + * User defined. + */ + } else { + /* + * Add to doc's oldNs. + */ + ns = xmlDOMWrapStoreNs(doc, node->ns->href, + node->ns->prefix); + if (ns == NULL) + goto internal_error; + } + if (ns != NULL) { + /* + * Add mapping. + */ + if (xmlDOMWrapNSNormAddNsMapItem2(&list, &sizeList, + &nbList, node->ns, ns) == -1) + goto internal_error; + } + node->ns = ns; + } + if ((node->type == XML_ELEMENT_NODE) && + (node->properties != NULL)) { + node = (xmlNodePtr) node->properties; + continue; + } + break; + default: + goto next_sibling; + } +next_node: + if ((node->type == XML_ELEMENT_NODE) && + (node->children != NULL)) { + node = node->children; + continue; + } +next_sibling: + if (node == NULL) + break; + if (node->next != NULL) + node = node->next; + else { + node = node->parent; + goto next_sibling; + } + } while (node != NULL); + + if (list != NULL) + xmlFree(list); + return (0); + +internal_error: + if (list != NULL) + xmlFree(list); + return (-1); +} + +/* +* xmlSearchNsByNamespaceStrict: +* @doc: the document +* @node: the start node +* @nsName: the searched namespace name +* @retNs: the resulting ns-decl +* @prefixed: if the found ns-decl must have a prefix (for attributes) +* +* Dynamically searches for a ns-declaration which matches +* the given @nsName in the ancestor-or-self axis of @node. +* +* Returns 1 if a ns-decl was found, 0 if not and -1 on API +* and internal errors. +*/ +static int +xmlSearchNsByNamespaceStrict(xmlDocPtr doc, xmlNodePtr node, + const xmlChar* nsName, + xmlNsPtr *retNs, int prefixed) +{ + xmlNodePtr cur, prev = NULL, out = NULL; + xmlNsPtr ns, prevns; + + if ((doc == NULL) || (nsName == NULL) || (retNs == NULL)) + return (-1); + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) + return(-1); + + *retNs = NULL; + if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) { + *retNs = xmlTreeEnsureXMLDecl(doc); + if (*retNs == NULL) + return (-1); + return (1); + } + cur = node; + do { + if (cur->type == XML_ELEMENT_NODE) { + if (cur->nsDef != NULL) { + for (ns = cur->nsDef; ns != NULL; ns = ns->next) { + if (prefixed && (ns->prefix == NULL)) + continue; + if (prev != NULL) { + /* + * Check the last level of ns-decls for a + * shadowing prefix. + */ + prevns = prev->nsDef; + do { + if ((prevns->prefix == ns->prefix) || + ((prevns->prefix != NULL) && + (ns->prefix != NULL) && + xmlStrEqual(prevns->prefix, ns->prefix))) { + /* + * Shadowed. + */ + break; + } + prevns = prevns->next; + } while (prevns != NULL); + if (prevns != NULL) + continue; + } + /* + * Ns-name comparison. + */ + if ((nsName == ns->href) || + xmlStrEqual(nsName, ns->href)) { + /* + * At this point the prefix can only be shadowed, + * if we are the the (at least) 3rd level of + * ns-decls. + */ + if (out) { + int ret; + + ret = xmlNsInScope(doc, node, prev, ns->prefix); + if (ret < 0) + return (-1); + /* + * TODO: Should we try to find a matching ns-name + * only once? This here keeps on searching. + * I think we should try further since, there might + * be an other matching ns-decl with an unshadowed + * prefix. + */ + if (! ret) + continue; + } + *retNs = ns; + return (1); + } + } + out = prev; + prev = cur; + } + } else if ((cur->type == XML_ENTITY_NODE) || + (cur->type == XML_ENTITY_DECL)) + return (0); + cur = cur->parent; + } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur)); + return (0); +} + +/* +* xmlSearchNsByPrefixStrict: +* @doc: the document +* @node: the start node +* @prefix: the searched namespace prefix +* @retNs: the resulting ns-decl +* +* Dynamically searches for a ns-declaration which matches +* the given @nsName in the ancestor-or-self axis of @node. +* +* Returns 1 if a ns-decl was found, 0 if not and -1 on API +* and internal errors. +*/ +static int +xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node, + const xmlChar* prefix, + xmlNsPtr *retNs) +{ + xmlNodePtr cur; + xmlNsPtr ns; + + if ((doc == NULL) || (node == NULL) || (node->type == XML_NAMESPACE_DECL)) + return(-1); + + if (retNs) + *retNs = NULL; + if (IS_STR_XML(prefix)) { + if (retNs) { + *retNs = xmlTreeEnsureXMLDecl(doc); + if (*retNs == NULL) + return (-1); + } + return (1); + } + cur = node; + do { + if (cur->type == XML_ELEMENT_NODE) { + if (cur->nsDef != NULL) { + ns = cur->nsDef; + do { + if ((prefix == ns->prefix) || + xmlStrEqual(prefix, ns->prefix)) + { + /* + * Disabled namespaces, e.g. xmlns:abc="". + */ + if (ns->href == NULL) + return(0); + if (retNs) + *retNs = ns; + return (1); + } + ns = ns->next; + } while (ns != NULL); + } + } else if ((cur->type == XML_ENTITY_NODE) || + (cur->type == XML_ENTITY_DECL)) + return (0); + cur = cur->parent; + } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur)); + return (0); +} + +/* +* xmlDOMWrapNSNormDeclareNsForced: +* @doc: the doc +* @elem: the element-node to declare on +* @nsName: the namespace-name of the ns-decl +* @prefix: the preferred prefix of the ns-decl +* @checkShadow: ensure that the new ns-decl doesn't shadow ancestor ns-decls +* +* Declares a new namespace on @elem. It tries to use the +* given @prefix; if a ns-decl with the given prefix is already existent +* on @elem, it will generate an other prefix. +* +* Returns 1 if a ns-decl was found, 0 if not and -1 on API +* and internal errors. +*/ +static xmlNsPtr +xmlDOMWrapNSNormDeclareNsForced(xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *nsName, + const xmlChar *prefix, + int checkShadow) +{ + + xmlNsPtr ret; + char buf[50]; + const xmlChar *pref; + int counter = 0; + + if ((doc == NULL) || (elem == NULL) || (elem->type != XML_ELEMENT_NODE)) + return(NULL); + /* + * Create a ns-decl on @anchor. + */ + pref = prefix; + while (1) { + /* + * Lookup whether the prefix is unused in elem's ns-decls. + */ + if ((elem->nsDef != NULL) && + (xmlTreeNSListLookupByPrefix(elem->nsDef, pref) != NULL)) + goto ns_next_prefix; + if (checkShadow && elem->parent && + ((xmlNodePtr) elem->parent->doc != elem->parent)) { + /* + * Does it shadow ancestor ns-decls? + */ + if (xmlSearchNsByPrefixStrict(doc, elem->parent, pref, NULL) == 1) + goto ns_next_prefix; + } + ret = xmlNewNs(NULL, nsName, pref); + if (ret == NULL) + return (NULL); + if (elem->nsDef == NULL) + elem->nsDef = ret; + else { + xmlNsPtr ns2 = elem->nsDef; + while (ns2->next != NULL) + ns2 = ns2->next; + ns2->next = ret; + } + return (ret); +ns_next_prefix: + counter++; + if (counter > 1000) + return (NULL); + if (prefix == NULL) { + snprintf((char *) buf, sizeof(buf), + "ns_%d", counter); + } else + snprintf((char *) buf, sizeof(buf), + "%.30s_%d", (char *)prefix, counter); + pref = BAD_CAST buf; + } +} + +/* +* xmlDOMWrapNSNormAcquireNormalizedNs: +* @doc: the doc +* @elem: the element-node to declare namespaces on +* @ns: the ns-struct to use for the search +* @retNs: the found/created ns-struct +* @nsMap: the ns-map +* @depth: the current tree depth +* @ancestorsOnly: search in ancestor ns-decls only +* @prefixed: if the searched ns-decl must have a prefix (for attributes) +* +* Searches for a matching ns-name in the ns-decls of @nsMap, if not +* found it will either declare it on @elem, or store it in doc->oldNs. +* If a new ns-decl needs to be declared on @elem, it tries to use the +* @ns->prefix for it, if this prefix is already in use on @elem, it will +* change the prefix or the new ns-decl. +* +* Returns 0 if succeeded, -1 otherwise and on API/internal errors. +*/ +static int +xmlDOMWrapNSNormAcquireNormalizedNs(xmlDocPtr doc, + xmlNodePtr elem, + xmlNsPtr ns, + xmlNsPtr *retNs, + xmlNsMapPtr *nsMap, + + int depth, + int ancestorsOnly, + int prefixed) +{ + xmlNsMapItemPtr mi; + + if ((doc == NULL) || (ns == NULL) || (retNs == NULL) || + (nsMap == NULL)) + return (-1); + + *retNs = NULL; + /* + * Handle XML namespace. + */ + if (IS_STR_XML(ns->prefix)) { + /* + * Insert XML namespace mapping. + */ + *retNs = xmlTreeEnsureXMLDecl(doc); + if (*retNs == NULL) + return (-1); + return (0); + } + /* + * If the search should be done in ancestors only and no + * @elem (the first ancestor) was specified, then skip the search. + */ + if ((XML_NSMAP_NOTEMPTY(*nsMap)) && + (! (ancestorsOnly && (elem == NULL)))) + { + /* + * Try to find an equal ns-name in in-scope ns-decls. + */ + XML_NSMAP_FOREACH(*nsMap, mi) { + if ((mi->depth >= XML_TREE_NSMAP_PARENT) && + /* + * ancestorsOnly: This should be turned on to gain speed, + * if one knows that the branch itself was already + * ns-wellformed and no stale references existed. + * I.e. it searches in the ancestor axis only. + */ + ((! ancestorsOnly) || (mi->depth == XML_TREE_NSMAP_PARENT)) && + /* Skip shadowed prefixes. */ + (mi->shadowDepth == -1) && + /* Skip xmlns="" or xmlns:foo="". */ + ((mi->newNs->href != NULL) && + (mi->newNs->href[0] != 0)) && + /* Ensure a prefix if wanted. */ + ((! prefixed) || (mi->newNs->prefix != NULL)) && + /* Equal ns name */ + ((mi->newNs->href == ns->href) || + xmlStrEqual(mi->newNs->href, ns->href))) { + /* Set the mapping. */ + mi->oldNs = ns; + *retNs = mi->newNs; + return (0); + } + } + } + /* + * No luck, the namespace is out of scope or shadowed. + */ + if (elem == NULL) { + xmlNsPtr tmpns; + + /* + * Store ns-decls in "oldNs" of the document-node. + */ + tmpns = xmlDOMWrapStoreNs(doc, ns->href, ns->prefix); + if (tmpns == NULL) + return (-1); + /* + * Insert mapping. + */ + if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns, + tmpns, XML_TREE_NSMAP_DOC) == NULL) { + xmlFreeNs(tmpns); + return (-1); + } + *retNs = tmpns; + } else { + xmlNsPtr tmpns; + + tmpns = xmlDOMWrapNSNormDeclareNsForced(doc, elem, ns->href, + ns->prefix, 0); + if (tmpns == NULL) + return (-1); + + if (*nsMap != NULL) { + /* + * Does it shadow ancestor ns-decls? + */ + XML_NSMAP_FOREACH(*nsMap, mi) { + if ((mi->depth < depth) && + (mi->shadowDepth == -1) && + ((ns->prefix == mi->newNs->prefix) || + xmlStrEqual(ns->prefix, mi->newNs->prefix))) { + /* + * Shadows. + */ + mi->shadowDepth = depth; + break; + } + } + } + if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns, tmpns, depth) == NULL) { + xmlFreeNs(tmpns); + return (-1); + } + *retNs = tmpns; + } + return (0); +} + +typedef enum { + XML_DOM_RECONNS_REMOVEREDUND = 1<<0 +} xmlDOMReconcileNSOptions; + +/* +* xmlDOMWrapReconcileNamespaces: +* @ctxt: DOM wrapper context, unused at the moment +* @elem: the element-node +* @options: option flags +* +* Ensures that ns-references point to ns-decls hold on element-nodes. +* Ensures that the tree is namespace wellformed by creating additional +* ns-decls where needed. Note that, since prefixes of already existent +* ns-decls can be shadowed by this process, it could break QNames in +* attribute values or element content. +* +* NOTE: This function was not intensively tested. +* +* Returns 0 if succeeded, -1 otherwise and on API/internal errors. +*/ + +int +xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED, + xmlNodePtr elem, + int options) +{ + int depth = -1, adoptns = 0, parnsdone = 0; + xmlNsPtr ns, prevns; + xmlDocPtr doc; + xmlNodePtr cur, curElem = NULL; + xmlNsMapPtr nsMap = NULL; + xmlNsMapItemPtr /* topmi = NULL, */ mi; + /* @ancestorsOnly should be set by an option flag. */ + int ancestorsOnly = 0; + int optRemoveRedundantNS = + ((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0; + xmlNsPtr *listRedund = NULL; + int sizeRedund = 0, nbRedund = 0, ret, i, j; + + if ((elem == NULL) || (elem->doc == NULL) || + (elem->type != XML_ELEMENT_NODE)) + return (-1); + + doc = elem->doc; + cur = elem; + do { + switch (cur->type) { + case XML_ELEMENT_NODE: + adoptns = 1; + curElem = cur; + depth++; + /* + * Namespace declarations. + */ + if (cur->nsDef != NULL) { + prevns = NULL; + ns = cur->nsDef; + while (ns != NULL) { + if (! parnsdone) { + if ((elem->parent) && + ((xmlNodePtr) elem->parent->doc != elem->parent)) { + /* + * Gather ancestor in-scope ns-decls. + */ + if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, + elem->parent) == -1) + goto internal_error; + } + parnsdone = 1; + } + + /* + * Lookup the ns ancestor-axis for equal ns-decls in scope. + */ + if (optRemoveRedundantNS && XML_NSMAP_NOTEMPTY(nsMap)) { + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->depth >= XML_TREE_NSMAP_PARENT) && + (mi->shadowDepth == -1) && + ((ns->prefix == mi->newNs->prefix) || + xmlStrEqual(ns->prefix, mi->newNs->prefix)) && + ((ns->href == mi->newNs->href) || + xmlStrEqual(ns->href, mi->newNs->href))) + { + /* + * A redundant ns-decl was found. + * Add it to the list of redundant ns-decls. + */ + if (xmlDOMWrapNSNormAddNsMapItem2(&listRedund, + &sizeRedund, &nbRedund, ns, mi->newNs) == -1) + goto internal_error; + /* + * Remove the ns-decl from the element-node. + */ + if (prevns) + prevns->next = ns->next; + else + cur->nsDef = ns->next; + goto next_ns_decl; + } + } + } + + /* + * Skip ns-references handling if the referenced + * ns-decl is declared on the same element. + */ + if ((cur->ns != NULL) && adoptns && (cur->ns == ns)) + adoptns = 0; + /* + * Does it shadow any ns-decl? + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->depth >= XML_TREE_NSMAP_PARENT) && + (mi->shadowDepth == -1) && + ((ns->prefix == mi->newNs->prefix) || + xmlStrEqual(ns->prefix, mi->newNs->prefix))) { + + mi->shadowDepth = depth; + } + } + } + /* + * Push mapping. + */ + if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns, + depth) == NULL) + goto internal_error; + + prevns = ns; +next_ns_decl: + ns = ns->next; + } + } + if (! adoptns) + goto ns_end; + /* Falls through. */ + case XML_ATTRIBUTE_NODE: + /* No ns, no fun. */ + if (cur->ns == NULL) + goto ns_end; + + if (! parnsdone) { + if ((elem->parent) && + ((xmlNodePtr) elem->parent->doc != elem->parent)) { + if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, + elem->parent) == -1) + goto internal_error; + } + parnsdone = 1; + } + /* + * Adjust the reference if this was a redundant ns-decl. + */ + if (listRedund) { + for (i = 0, j = 0; i < nbRedund; i++, j += 2) { + if (cur->ns == listRedund[j]) { + cur->ns = listRedund[++j]; + break; + } + } + } + /* + * Adopt ns-references. + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + /* + * Search for a mapping. + */ + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->shadowDepth == -1) && + (cur->ns == mi->oldNs)) { + + cur->ns = mi->newNs; + goto ns_end; + } + } + } + /* + * Acquire a normalized ns-decl and add it to the map. + */ + if (xmlDOMWrapNSNormAcquireNormalizedNs(doc, curElem, + cur->ns, &ns, + &nsMap, depth, + ancestorsOnly, + (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1) + goto internal_error; + cur->ns = ns; + +ns_end: + if ((cur->type == XML_ELEMENT_NODE) && + (cur->properties != NULL)) { + /* + * Process attributes. + */ + cur = (xmlNodePtr) cur->properties; + continue; + } + break; + default: + goto next_sibling; + } +into_content: + if ((cur->type == XML_ELEMENT_NODE) && + (cur->children != NULL)) { + /* + * Process content of element-nodes only. + */ + cur = cur->children; + continue; + } +next_sibling: + if (cur == elem) + break; + if (cur->type == XML_ELEMENT_NODE) { + if (XML_NSMAP_NOTEMPTY(nsMap)) { + /* + * Pop mappings. + */ + while ((nsMap->last != NULL) && + (nsMap->last->depth >= depth)) + { + XML_NSMAP_POP(nsMap, mi) + } + /* + * Unshadow. + */ + XML_NSMAP_FOREACH(nsMap, mi) { + if (mi->shadowDepth >= depth) + mi->shadowDepth = -1; + } + } + depth--; + } + if (cur->next != NULL) + cur = cur->next; + else { + if (cur->type == XML_ATTRIBUTE_NODE) { + cur = cur->parent; + goto into_content; + } + cur = cur->parent; + goto next_sibling; + } + } while (cur != NULL); + + ret = 0; + goto exit; +internal_error: + ret = -1; +exit: + if (listRedund) { + for (i = 0, j = 0; i < nbRedund; i++, j += 2) { + xmlFreeNs(listRedund[j]); + } + xmlFree(listRedund); + } + if (nsMap != NULL) + xmlDOMWrapNsMapFree(nsMap); + return (ret); +} + +/* +* xmlDOMWrapAdoptBranch: +* @ctxt: the optional context for custom processing +* @sourceDoc: the optional sourceDoc +* @node: the element-node to start with +* @destDoc: the destination doc for adoption +* @destParent: the optional new parent of @node in @destDoc +* @options: option flags +* +* Ensures that ns-references point to @destDoc: either to +* elements->nsDef entries if @destParent is given, or to +* @destDoc->oldNs otherwise. +* If @destParent is given, it ensures that the tree is namespace +* wellformed by creating additional ns-decls where needed. +* Note that, since prefixes of already existent ns-decls can be +* shadowed by this process, it could break QNames in attribute +* values or element content. +* +* NOTE: This function was not intensively tested. +* +* Returns 0 if succeeded, -1 otherwise and on API/internal errors. +*/ +static int +xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int options ATTRIBUTE_UNUSED) +{ + int ret = 0; + xmlNodePtr cur, curElem = NULL; + xmlNsMapPtr nsMap = NULL; + xmlNsMapItemPtr mi; + xmlNsPtr ns = NULL; + int depth = -1, adoptStr = 1; + /* gather @parent's ns-decls. */ + int parnsdone; + /* @ancestorsOnly should be set per option. */ + int ancestorsOnly = 0; + + /* + * Optimize string adoption for equal or none dicts. + */ + if ((sourceDoc != NULL) && + (sourceDoc->dict == destDoc->dict)) + adoptStr = 0; + else + adoptStr = 1; + + /* + * Get the ns-map from the context if available. + */ + if (ctxt) + nsMap = (xmlNsMapPtr) ctxt->namespaceMap; + /* + * Disable search for ns-decls in the parent-axis of the + * destination element, if: + * 1) there's no destination parent + * 2) custom ns-reference handling is used + */ + if ((destParent == NULL) || + (ctxt && ctxt->getNsForNodeFunc)) + { + parnsdone = 1; + } else + parnsdone = 0; + + cur = node; + if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL)) + goto internal_error; + + while (cur != NULL) { + /* + * Paranoid source-doc sanity check. + */ + if (cur->doc != sourceDoc) { + /* + * We'll assume XIncluded nodes if the doc differs. + * TODO: Do we need to reconciliate XIncluded nodes? + * This here skips XIncluded nodes and tries to handle + * broken sequences. + */ + if (cur->next == NULL) + goto leave_node; + do { + cur = cur->next; + if ((cur->type == XML_XINCLUDE_END) || + (cur->doc == node->doc)) + break; + } while (cur->next != NULL); + + if (cur->doc != node->doc) + goto leave_node; + } + cur->doc = destDoc; + switch (cur->type) { + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + /* + * TODO + */ + return (-1); + case XML_ELEMENT_NODE: + curElem = cur; + depth++; + /* + * Namespace declarations. + * - ns->href and ns->prefix are never in the dict, so + * we need not move the values over to the destination dict. + * - Note that for custom handling of ns-references, + * the ns-decls need not be stored in the ns-map, + * since they won't be referenced by node->ns. + */ + if ((cur->nsDef) && + ((ctxt == NULL) || (ctxt->getNsForNodeFunc == NULL))) + { + if (! parnsdone) { + /* + * Gather @parent's in-scope ns-decls. + */ + if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, + destParent) == -1) + goto internal_error; + parnsdone = 1; + } + for (ns = cur->nsDef; ns != NULL; ns = ns->next) { + /* + * NOTE: ns->prefix and ns->href are never in the dict. + * XML_TREE_ADOPT_STR(ns->prefix) + * XML_TREE_ADOPT_STR(ns->href) + */ + /* + * Does it shadow any ns-decl? + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->depth >= XML_TREE_NSMAP_PARENT) && + (mi->shadowDepth == -1) && + ((ns->prefix == mi->newNs->prefix) || + xmlStrEqual(ns->prefix, + mi->newNs->prefix))) { + + mi->shadowDepth = depth; + } + } + } + /* + * Push mapping. + */ + if (xmlDOMWrapNsMapAddItem(&nsMap, -1, + ns, ns, depth) == NULL) + goto internal_error; + } + } + /* Falls through. */ + case XML_ATTRIBUTE_NODE: + /* No namespace, no fun. */ + if (cur->ns == NULL) + goto ns_end; + + if (! parnsdone) { + if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, + destParent) == -1) + goto internal_error; + parnsdone = 1; + } + /* + * Adopt ns-references. + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + /* + * Search for a mapping. + */ + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->shadowDepth == -1) && + (cur->ns == mi->oldNs)) { + + cur->ns = mi->newNs; + goto ns_end; + } + } + } + /* + * No matching namespace in scope. We need a new one. + */ + if ((ctxt) && (ctxt->getNsForNodeFunc)) { + /* + * User-defined behaviour. + */ + ns = ctxt->getNsForNodeFunc(ctxt, cur, + cur->ns->href, cur->ns->prefix); + /* + * Insert mapping if ns is available; it's the users fault + * if not. + */ + if (xmlDOMWrapNsMapAddItem(&nsMap, -1, + cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL) + goto internal_error; + cur->ns = ns; + } else { + /* + * Acquire a normalized ns-decl and add it to the map. + */ + if (xmlDOMWrapNSNormAcquireNormalizedNs(destDoc, + /* ns-decls on curElem or on destDoc->oldNs */ + destParent ? curElem : NULL, + cur->ns, &ns, + &nsMap, depth, + ancestorsOnly, + /* ns-decls must be prefixed for attributes. */ + (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1) + goto internal_error; + cur->ns = ns; + } +ns_end: + /* + * Further node properties. + * TODO: Is this all? + */ + XML_TREE_ADOPT_STR(cur->name) + if (cur->type == XML_ELEMENT_NODE) { + cur->psvi = NULL; + cur->line = 0; + cur->extra = 0; + /* + * Walk attributes. + */ + if (cur->properties != NULL) { + /* + * Process first attribute node. + */ + cur = (xmlNodePtr) cur->properties; + continue; + } + } else { + /* + * Attributes. + */ + if ((sourceDoc != NULL) && + (((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID)) + { + xmlRemoveID(sourceDoc, (xmlAttrPtr) cur); + } + ((xmlAttrPtr) cur)->atype = 0; + ((xmlAttrPtr) cur)->psvi = NULL; + } + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + /* + * This puts the content in the dest dict, only if + * it was previously in the source dict. + */ + XML_TREE_ADOPT_STR_2(cur->content) + goto leave_node; + case XML_ENTITY_REF_NODE: + /* + * Remove reference to the entity-node. + */ + cur->content = NULL; + cur->children = NULL; + cur->last = NULL; + if ((destDoc->intSubset) || (destDoc->extSubset)) { + xmlEntityPtr ent; + /* + * Assign new entity-node if available. + */ + ent = xmlGetDocEntity(destDoc, cur->name); + if (ent != NULL) { + cur->content = ent->content; + cur->children = (xmlNodePtr) ent; + cur->last = (xmlNodePtr) ent; + } + } + goto leave_node; + case XML_PI_NODE: + XML_TREE_ADOPT_STR(cur->name) + XML_TREE_ADOPT_STR_2(cur->content) + break; + case XML_COMMENT_NODE: + break; + default: + goto internal_error; + } + /* + * Walk the tree. + */ + if (cur->children != NULL) { + cur = cur->children; + continue; + } + +leave_node: + if (cur == node) + break; + if ((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_XINCLUDE_START) || + (cur->type == XML_XINCLUDE_END)) + { + /* + * TODO: Do we expect nsDefs on XML_XINCLUDE_START? + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + /* + * Pop mappings. + */ + while ((nsMap->last != NULL) && + (nsMap->last->depth >= depth)) + { + XML_NSMAP_POP(nsMap, mi) + } + /* + * Unshadow. + */ + XML_NSMAP_FOREACH(nsMap, mi) { + if (mi->shadowDepth >= depth) + mi->shadowDepth = -1; + } + } + depth--; + } + if (cur->next != NULL) + cur = cur->next; + else if ((cur->type == XML_ATTRIBUTE_NODE) && + (cur->parent->children != NULL)) + { + cur = cur->parent->children; + } else { + cur = cur->parent; + goto leave_node; + } + } + + goto exit; + +internal_error: + ret = -1; + +exit: + /* + * Cleanup. + */ + if (nsMap != NULL) { + if ((ctxt) && (ctxt->namespaceMap == nsMap)) { + /* + * Just cleanup the map but don't free. + */ + if (nsMap->first) { + if (nsMap->pool) + nsMap->last->next = nsMap->pool; + nsMap->pool = nsMap->first; + nsMap->first = NULL; + } + } else + xmlDOMWrapNsMapFree(nsMap); + } + return(ret); +} + +/* +* xmlDOMWrapCloneNode: +* @ctxt: the optional context for custom processing +* @sourceDoc: the optional sourceDoc +* @node: the node to start with +* @resNode: the clone of the given @node +* @destDoc: the destination doc +* @destParent: the optional new parent of @node in @destDoc +* @deep: descend into child if set +* @options: option flags +* +* References of out-of scope ns-decls are remapped to point to @destDoc: +* 1) If @destParent is given, then nsDef entries on element-nodes are used +* 2) If *no* @destParent is given, then @destDoc->oldNs entries are used. +* This is the case when you don't know already where the cloned branch +* will be added to. +* +* If @destParent is given, it ensures that the tree is namespace +* wellformed by creating additional ns-decls where needed. +* Note that, since prefixes of already existent ns-decls can be +* shadowed by this process, it could break QNames in attribute +* values or element content. +* TODO: +* 1) What to do with XInclude? Currently this returns an error for XInclude. +* +* Returns 0 if the operation succeeded, +* 1 if a node of unsupported (or not yet supported) type was given, +* -1 on API/internal errors. +*/ + +int +xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlNodePtr *resNode, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int deep, + int options ATTRIBUTE_UNUSED) +{ + int ret = 0; + xmlNodePtr cur, curElem = NULL; + xmlNsMapPtr nsMap = NULL; + xmlNsMapItemPtr mi; + xmlNsPtr ns; + int depth = -1; + /* int adoptStr = 1; */ + /* gather @parent's ns-decls. */ + int parnsdone = 0; + /* + * @ancestorsOnly: + * TODO: @ancestorsOnly should be set per option. + * + */ + int ancestorsOnly = 0; + xmlNodePtr resultClone = NULL, clone = NULL, parentClone = NULL, prevClone = NULL; + xmlNsPtr cloneNs = NULL, *cloneNsDefSlot = NULL; + xmlDictPtr dict; /* The destination dict */ + + if ((node == NULL) || (resNode == NULL) || (destDoc == NULL)) + return(-1); + /* + * TODO: Initially we support only element-nodes. + */ + if (node->type != XML_ELEMENT_NODE) + return(1); + /* + * Check node->doc sanity. + */ + if ((node->doc != NULL) && (sourceDoc != NULL) && + (node->doc != sourceDoc)) { + /* + * Might be an XIncluded node. + */ + return (-1); + } + if (sourceDoc == NULL) + sourceDoc = node->doc; + if (sourceDoc == NULL) + return (-1); + + dict = destDoc->dict; + /* + * Reuse the namespace map of the context. + */ + if (ctxt) + nsMap = (xmlNsMapPtr) ctxt->namespaceMap; + + *resNode = NULL; + + cur = node; + if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL)) + return(-1); + + while (cur != NULL) { + if (cur->doc != sourceDoc) { + /* + * We'll assume XIncluded nodes if the doc differs. + * TODO: Do we need to reconciliate XIncluded nodes? + * TODO: This here returns -1 in this case. + */ + goto internal_error; + } + /* + * Create a new node. + */ + switch (cur->type) { + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + /* + * TODO: What to do with XInclude? + */ + goto internal_error; + break; + case XML_ELEMENT_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_PI_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + /* + * Nodes of xmlNode structure. + */ + clone = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (clone == NULL) { + xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating a node"); + goto internal_error; + } + memset(clone, 0, sizeof(xmlNode)); + /* + * Set hierarchical links. + */ + if (resultClone != NULL) { + clone->parent = parentClone; + if (prevClone) { + prevClone->next = clone; + clone->prev = prevClone; + } else + parentClone->children = clone; + } else + resultClone = clone; + + break; + case XML_ATTRIBUTE_NODE: + /* + * Attributes (xmlAttr). + */ + clone = (xmlNodePtr) xmlMalloc(sizeof(xmlAttr)); + if (clone == NULL) { + xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating an attr-node"); + goto internal_error; + } + memset(clone, 0, sizeof(xmlAttr)); + /* + * Set hierarchical links. + * TODO: Change this to add to the end of attributes. + */ + if (resultClone != NULL) { + clone->parent = parentClone; + if (prevClone) { + prevClone->next = clone; + clone->prev = prevClone; + } else + parentClone->properties = (xmlAttrPtr) clone; + } else + resultClone = clone; + break; + default: + /* + * TODO QUESTION: Any other nodes expected? + */ + goto internal_error; + } + + clone->type = cur->type; + clone->doc = destDoc; + + /* + * Clone the name of the node if any. + */ + if (cur->name == xmlStringText) + clone->name = xmlStringText; + else if (cur->name == xmlStringTextNoenc) + /* + * NOTE: Although xmlStringTextNoenc is never assigned to a node + * in tree.c, it might be set in Libxslt via + * "xsl:disable-output-escaping". + */ + clone->name = xmlStringTextNoenc; + else if (cur->name == xmlStringComment) + clone->name = xmlStringComment; + else if (cur->name != NULL) { + DICT_CONST_COPY(cur->name, clone->name); + } + + switch (cur->type) { + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + /* + * TODO + */ + return (-1); + case XML_ELEMENT_NODE: + curElem = cur; + depth++; + /* + * Namespace declarations. + */ + if (cur->nsDef != NULL) { + if (! parnsdone) { + if (destParent && (ctxt == NULL)) { + /* + * Gather @parent's in-scope ns-decls. + */ + if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, + destParent) == -1) + goto internal_error; + } + parnsdone = 1; + } + /* + * Clone namespace declarations. + */ + cloneNsDefSlot = &(clone->nsDef); + for (ns = cur->nsDef; ns != NULL; ns = ns->next) { + /* + * Create a new xmlNs. + */ + cloneNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); + if (cloneNs == NULL) { + xmlTreeErrMemory("xmlDOMWrapCloneNode(): " + "allocating namespace"); + return(-1); + } + memset(cloneNs, 0, sizeof(xmlNs)); + cloneNs->type = XML_LOCAL_NAMESPACE; + + if (ns->href != NULL) + cloneNs->href = xmlStrdup(ns->href); + if (ns->prefix != NULL) + cloneNs->prefix = xmlStrdup(ns->prefix); + + *cloneNsDefSlot = cloneNs; + cloneNsDefSlot = &(cloneNs->next); + + /* + * Note that for custom handling of ns-references, + * the ns-decls need not be stored in the ns-map, + * since they won't be referenced by node->ns. + */ + if ((ctxt == NULL) || + (ctxt->getNsForNodeFunc == NULL)) + { + /* + * Does it shadow any ns-decl? + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->depth >= XML_TREE_NSMAP_PARENT) && + (mi->shadowDepth == -1) && + ((ns->prefix == mi->newNs->prefix) || + xmlStrEqual(ns->prefix, + mi->newNs->prefix))) { + /* + * Mark as shadowed at the current + * depth. + */ + mi->shadowDepth = depth; + } + } + } + /* + * Push mapping. + */ + if (xmlDOMWrapNsMapAddItem(&nsMap, -1, + ns, cloneNs, depth) == NULL) + goto internal_error; + } + } + } + /* cur->ns will be processed further down. */ + break; + case XML_ATTRIBUTE_NODE: + /* IDs will be processed further down. */ + /* cur->ns will be processed further down. */ + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + /* + * Note that this will also cover the values of attributes. + */ + DICT_COPY(cur->content, clone->content); + goto leave_node; + case XML_ENTITY_NODE: + /* TODO: What to do here? */ + goto leave_node; + case XML_ENTITY_REF_NODE: + if (sourceDoc != destDoc) { + if ((destDoc->intSubset) || (destDoc->extSubset)) { + xmlEntityPtr ent; + /* + * Different doc: Assign new entity-node if available. + */ + ent = xmlGetDocEntity(destDoc, cur->name); + if (ent != NULL) { + clone->content = ent->content; + clone->children = (xmlNodePtr) ent; + clone->last = (xmlNodePtr) ent; + } + } + } else { + /* + * Same doc: Use the current node's entity declaration + * and value. + */ + clone->content = cur->content; + clone->children = cur->children; + clone->last = cur->last; + } + goto leave_node; + case XML_PI_NODE: + DICT_COPY(cur->content, clone->content); + goto leave_node; + case XML_COMMENT_NODE: + DICT_COPY(cur->content, clone->content); + goto leave_node; + default: + goto internal_error; + } + + if (cur->ns == NULL) + goto end_ns_reference; + +/* handle_ns_reference: */ + /* + ** The following will take care of references to ns-decls ******** + ** and is intended only for element- and attribute-nodes. + ** + */ + if (! parnsdone) { + if (destParent && (ctxt == NULL)) { + if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1) + goto internal_error; + } + parnsdone = 1; + } + /* + * Adopt ns-references. + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + /* + * Search for a mapping. + */ + XML_NSMAP_FOREACH(nsMap, mi) { + if ((mi->shadowDepth == -1) && + (cur->ns == mi->oldNs)) { + /* + * This is the nice case: a mapping was found. + */ + clone->ns = mi->newNs; + goto end_ns_reference; + } + } + } + /* + * No matching namespace in scope. We need a new one. + */ + if ((ctxt != NULL) && (ctxt->getNsForNodeFunc != NULL)) { + /* + * User-defined behaviour. + */ + ns = ctxt->getNsForNodeFunc(ctxt, cur, + cur->ns->href, cur->ns->prefix); + /* + * Add user's mapping. + */ + if (xmlDOMWrapNsMapAddItem(&nsMap, -1, + cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL) + goto internal_error; + clone->ns = ns; + } else { + /* + * Acquire a normalized ns-decl and add it to the map. + */ + if (xmlDOMWrapNSNormAcquireNormalizedNs(destDoc, + /* ns-decls on curElem or on destDoc->oldNs */ + destParent ? curElem : NULL, + cur->ns, &ns, + &nsMap, depth, + /* if we need to search only in the ancestor-axis */ + ancestorsOnly, + /* ns-decls must be prefixed for attributes. */ + (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1) + goto internal_error; + clone->ns = ns; + } + +end_ns_reference: + + /* + * Some post-processing. + * + * Handle ID attributes. + */ + if ((clone->type == XML_ATTRIBUTE_NODE) && + (clone->parent != NULL)) + { + if (xmlIsID(destDoc, clone->parent, (xmlAttrPtr) clone)) { + + xmlChar *idVal; + + idVal = xmlNodeListGetString(cur->doc, cur->children, 1); + if (idVal != NULL) { + if (xmlAddID(NULL, destDoc, idVal, (xmlAttrPtr) cur) == NULL) { + /* TODO: error message. */ + xmlFree(idVal); + goto internal_error; + } + xmlFree(idVal); + } + } + } + /* + ** + ** The following will traverse the tree ************************** + ** + * + * Walk the element's attributes before descending into child-nodes. + */ + if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) { + prevClone = NULL; + parentClone = clone; + cur = (xmlNodePtr) cur->properties; + continue; + } +into_content: + /* + * Descend into child-nodes. + */ + if (cur->children != NULL) { + if (deep || (cur->type == XML_ATTRIBUTE_NODE)) { + prevClone = NULL; + parentClone = clone; + cur = cur->children; + continue; + } + } + +leave_node: + /* + * At this point we are done with the node, its content + * and an element-nodes's attribute-nodes. + */ + if (cur == node) + break; + if ((cur->type == XML_ELEMENT_NODE) || + (cur->type == XML_XINCLUDE_START) || + (cur->type == XML_XINCLUDE_END)) { + /* + * TODO: Do we expect nsDefs on XML_XINCLUDE_START? + */ + if (XML_NSMAP_NOTEMPTY(nsMap)) { + /* + * Pop mappings. + */ + while ((nsMap->last != NULL) && + (nsMap->last->depth >= depth)) + { + XML_NSMAP_POP(nsMap, mi) + } + /* + * Unshadow. + */ + XML_NSMAP_FOREACH(nsMap, mi) { + if (mi->shadowDepth >= depth) + mi->shadowDepth = -1; + } + } + depth--; + } + if (cur->next != NULL) { + prevClone = clone; + cur = cur->next; + } else if (cur->type != XML_ATTRIBUTE_NODE) { + /* + * Set clone->last. + */ + if (clone->parent != NULL) + clone->parent->last = clone; + clone = clone->parent; + if (clone != NULL) + parentClone = clone->parent; + /* + * Process parent --> next; + */ + cur = cur->parent; + goto leave_node; + } else { + /* This is for attributes only. */ + clone = clone->parent; + parentClone = clone->parent; + /* + * Process parent-element --> children. + */ + cur = cur->parent; + goto into_content; + } + } + goto exit; + +internal_error: + ret = -1; + +exit: + /* + * Cleanup. + */ + if (nsMap != NULL) { + if ((ctxt) && (ctxt->namespaceMap == nsMap)) { + /* + * Just cleanup the map but don't free. + */ + if (nsMap->first) { + if (nsMap->pool) + nsMap->last->next = nsMap->pool; + nsMap->pool = nsMap->first; + nsMap->first = NULL; + } + } else + xmlDOMWrapNsMapFree(nsMap); + } + /* + * TODO: Should we try a cleanup of the cloned node in case of a + * fatal error? + */ + *resNode = resultClone; + return (ret); +} + +/* +* xmlDOMWrapAdoptAttr: +* @ctxt: the optional context for custom processing +* @sourceDoc: the optional source document of attr +* @attr: the attribute-node to be adopted +* @destDoc: the destination doc for adoption +* @destParent: the optional new parent of @attr in @destDoc +* @options: option flags +* +* @attr is adopted by @destDoc. +* Ensures that ns-references point to @destDoc: either to +* elements->nsDef entries if @destParent is given, or to +* @destDoc->oldNs otherwise. +* +* Returns 0 if succeeded, -1 otherwise and on API/internal errors. +*/ +static int +xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlAttrPtr attr, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int options ATTRIBUTE_UNUSED) +{ + xmlNodePtr cur; + int adoptStr = 1; + + if ((attr == NULL) || (destDoc == NULL)) + return (-1); + + attr->doc = destDoc; + if (attr->ns != NULL) { + xmlNsPtr ns = NULL; + + if (ctxt != NULL) { + /* TODO: User defined. */ + } + /* XML Namespace. */ + if (IS_STR_XML(attr->ns->prefix)) { + ns = xmlTreeEnsureXMLDecl(destDoc); + } else if (destParent == NULL) { + /* + * Store in @destDoc->oldNs. + */ + ns = xmlDOMWrapStoreNs(destDoc, attr->ns->href, attr->ns->prefix); + } else { + /* + * Declare on @destParent. + */ + if (xmlSearchNsByNamespaceStrict(destDoc, destParent, attr->ns->href, + &ns, 1) == -1) + goto internal_error; + if (ns == NULL) { + ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent, + attr->ns->href, attr->ns->prefix, 1); + } + } + if (ns == NULL) + goto internal_error; + attr->ns = ns; + } + + XML_TREE_ADOPT_STR(attr->name); + attr->atype = 0; + attr->psvi = NULL; + /* + * Walk content. + */ + if (attr->children == NULL) + return (0); + cur = attr->children; + if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL)) + goto internal_error; + while (cur != NULL) { + cur->doc = destDoc; + switch (cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + XML_TREE_ADOPT_STR_2(cur->content) + break; + case XML_ENTITY_REF_NODE: + /* + * Remove reference to the entity-node. + */ + cur->content = NULL; + cur->children = NULL; + cur->last = NULL; + if ((destDoc->intSubset) || (destDoc->extSubset)) { + xmlEntityPtr ent; + /* + * Assign new entity-node if available. + */ + ent = xmlGetDocEntity(destDoc, cur->name); + if (ent != NULL) { + cur->content = ent->content; + cur->children = (xmlNodePtr) ent; + cur->last = (xmlNodePtr) ent; + } + } + break; + default: + break; + } + if (cur->children != NULL) { + cur = cur->children; + continue; + } +next_sibling: + if (cur == (xmlNodePtr) attr) + break; + if (cur->next != NULL) + cur = cur->next; + else { + cur = cur->parent; + goto next_sibling; + } + } + return (0); +internal_error: + return (-1); +} + +/* +* xmlDOMWrapAdoptNode: +* @ctxt: the optional context for custom processing +* @sourceDoc: the optional sourceDoc +* @node: the node to start with +* @destDoc: the destination doc +* @destParent: the optional new parent of @node in @destDoc +* @options: option flags +* +* References of out-of scope ns-decls are remapped to point to @destDoc: +* 1) If @destParent is given, then nsDef entries on element-nodes are used +* 2) If *no* @destParent is given, then @destDoc->oldNs entries are used +* This is the case when you have an unlinked node and just want to move it +* to the context of +* +* If @destParent is given, it ensures that the tree is namespace +* wellformed by creating additional ns-decls where needed. +* Note that, since prefixes of already existent ns-decls can be +* shadowed by this process, it could break QNames in attribute +* values or element content. +* NOTE: This function was not intensively tested. +* +* Returns 0 if the operation succeeded, +* 1 if a node of unsupported type was given, +* 2 if a node of not yet supported type was given and +* -1 on API/internal errors. +*/ +int +xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int options) +{ + if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) || + (destDoc == NULL) || + ((destParent != NULL) && (destParent->doc != destDoc))) + return(-1); + /* + * Check node->doc sanity. + */ + if ((node->doc != NULL) && (sourceDoc != NULL) && + (node->doc != sourceDoc)) { + /* + * Might be an XIncluded node. + */ + return (-1); + } + if (sourceDoc == NULL) + sourceDoc = node->doc; + if (sourceDoc == destDoc) + return (-1); + switch (node->type) { + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + break; + case XML_DOCUMENT_FRAG_NODE: + /* TODO: Support document-fragment-nodes. */ + return (2); + default: + return (1); + } + /* + * Unlink only if @node was not already added to @destParent. + */ + if ((node->parent != NULL) && (destParent != node->parent)) + xmlUnlinkNode(node); + + if (node->type == XML_ELEMENT_NODE) { + return (xmlDOMWrapAdoptBranch(ctxt, sourceDoc, node, + destDoc, destParent, options)); + } else if (node->type == XML_ATTRIBUTE_NODE) { + return (xmlDOMWrapAdoptAttr(ctxt, sourceDoc, + (xmlAttrPtr) node, destDoc, destParent, options)); + } else { + xmlNodePtr cur = node; + int adoptStr = 1; + + cur->doc = destDoc; + /* + * Optimize string adoption. + */ + if ((sourceDoc != NULL) && + (sourceDoc->dict == destDoc->dict)) + adoptStr = 0; + switch (node->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + XML_TREE_ADOPT_STR_2(node->content) + break; + case XML_ENTITY_REF_NODE: + /* + * Remove reference to the entity-node. + */ + node->content = NULL; + node->children = NULL; + node->last = NULL; + if ((destDoc->intSubset) || (destDoc->extSubset)) { + xmlEntityPtr ent; + /* + * Assign new entity-node if available. + */ + ent = xmlGetDocEntity(destDoc, node->name); + if (ent != NULL) { + node->content = ent->content; + node->children = (xmlNodePtr) ent; + node->last = (xmlNodePtr) ent; + } + } + XML_TREE_ADOPT_STR(node->name) + break; + case XML_PI_NODE: { + XML_TREE_ADOPT_STR(node->name) + XML_TREE_ADOPT_STR_2(node->content) + break; + } + default: + break; + } + } + return (0); +} + +#define bottom_tree +#include "elfgcchack.h" diff --git a/src/triodef.h b/src/triodef.h new file mode 100644 index 000000000000..e101f6df5607 --- /dev/null +++ b/src/triodef.h @@ -0,0 +1,228 @@ +/************************************************************************* + * + * $Id$ + * + * Copyright (C) 2001 Bjorn Reese + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + * + ************************************************************************/ + +#ifndef TRIO_TRIODEF_H +#define TRIO_TRIODEF_H + +/************************************************************************* + * Platform and compiler support detection + */ +#if defined(__GNUC__) +# define TRIO_COMPILER_GCC +#elif defined(__SUNPRO_C) +# define TRIO_COMPILER_SUNPRO +#elif defined(__SUNPRO_CC) +# define TRIO_COMPILER_SUNPRO +# define __SUNPRO_C __SUNPRO_CC +#elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) +# define TRIO_COMPILER_XLC +#elif defined(_AIX) && !defined(__GNUC__) +# define TRIO_COMPILER_XLC /* Workaround for old xlc */ +#elif defined(__DECC) || defined(__DECCXX) +# define TRIO_COMPILER_DECC +#elif defined(__osf__) && defined(__LANGUAGE_C__) +# define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ +#elif defined(_MSC_VER) +# define TRIO_COMPILER_MSVC +#elif defined(__BORLANDC__) +# define TRIO_COMPILER_BCB +#endif + +#if defined(VMS) || defined(__VMS) +/* + * VMS is placed first to avoid identifying the platform as Unix + * based on the DECC compiler later on. + */ +# define TRIO_PLATFORM_VMS +#elif defined(__OS400__) +# define TRIO_PLATFORM_OS400 +#elif defined(unix) || defined(__unix) || defined(__unix__) +# define TRIO_PLATFORM_UNIX +#elif defined(TRIO_COMPILER_XLC) || defined(_AIX) +# define TRIO_PLATFORM_UNIX +#elif defined(TRIO_COMPILER_DECC) || defined(__osf___) +# define TRIO_PLATFORM_UNIX +#elif defined(__NetBSD__) +# define TRIO_PLATFORM_UNIX +#elif defined(__Lynx__) +# define TRIO_PLATFORM_UNIX +#elif defined(__QNX__) +# define TRIO_PLATFORM_UNIX +# define TRIO_PLATFORM_QNX +#elif defined(__CYGWIN__) +# define TRIO_PLATFORM_UNIX +#elif defined(AMIGA) && defined(TRIO_COMPILER_GCC) +# define TRIO_PLATFORM_UNIX +#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) +# define TRIO_PLATFORM_WIN32 +#elif defined(mpeix) || defined(__mpexl) +# define TRIO_PLATFORM_MPEIX +#endif + +#if defined(_AIX) +# define TRIO_PLATFORM_AIX +#elif defined(__hpux) +# define TRIO_PLATFORM_HPUX +#elif defined(sun) || defined(__sun__) +# if defined(__SVR4) || defined(__svr4__) +# define TRIO_PLATFORM_SOLARIS +# else +# define TRIO_PLATFORM_SUNOS +# endif +#endif + +#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) +# define TRIO_COMPILER_SUPPORTS_C89 +# if defined(__STDC_VERSION__) +# define TRIO_COMPILER_SUPPORTS_C90 +# if (__STDC_VERSION__ >= 199409L) +# define TRIO_COMPILER_SUPPORTS_C94 +# endif +# if (__STDC_VERSION__ >= 199901L) +# define TRIO_COMPILER_SUPPORTS_C99 +# endif +# elif defined(TRIO_COMPILER_SUNPRO) +# if (__SUNPRO_C >= 0x420) +# define TRIO_COMPILER_SUPPORTS_C94 +# endif +# endif +#elif defined(TRIO_COMPILER_XLC) && defined(__EXTENDED__) +# define TRIO_COMPILER_SUPPORTS_C89 +# define TRIO_COMPILER_SUPPORTS_C90 +# define TRIO_COMPILER_SUPPORTS_C94 +#endif + +#if defined(_XOPEN_SOURCE) +# if defined(_XOPEN_SOURCE_EXTENDED) +# define TRIO_COMPILER_SUPPORTS_UNIX95 +# endif +# if (_XOPEN_VERSION >= 500) +# define TRIO_COMPILER_SUPPORTS_UNIX98 +# endif +# if (_XOPEN_VERSION >= 600) +# define TRIO_COMPILER_SUPPORTS_UNIX01 +# endif +#endif + +/************************************************************************* + * Generic defines + */ + +#if !defined(TRIO_PUBLIC) +# define TRIO_PUBLIC +#endif +#if !defined(TRIO_PRIVATE) +# define TRIO_PRIVATE static +#endif + +#if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) +# define TRIO_COMPILER_ANCIENT +#endif + +#if defined(TRIO_COMPILER_ANCIENT) +# define TRIO_CONST +# define TRIO_VOLATILE +# define TRIO_SIGNED +typedef double trio_long_double_t; +typedef char * trio_pointer_t; +# define TRIO_SUFFIX_LONG(x) x +# define TRIO_PROTO(x) () +# define TRIO_NOARGS +# define TRIO_ARGS1(list,a1) list a1; +# define TRIO_ARGS2(list,a1,a2) list a1; a2; +# define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; +# define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; +# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; +# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; +# define TRIO_VARGS2(list,a1,a2) list a1; a2 +# define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 +# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 +# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 +# define TRIO_VA_DECL va_dcl +# define TRIO_VA_START(x,y) va_start(x) +# define TRIO_VA_END(x) va_end(x) +#else /* ANSI C */ +# define TRIO_CONST const +# define TRIO_VOLATILE volatile +# define TRIO_SIGNED signed +typedef long double trio_long_double_t; +typedef void * trio_pointer_t; +# define TRIO_SUFFIX_LONG(x) x ## L +# define TRIO_PROTO(x) x +# define TRIO_NOARGS void +# define TRIO_ARGS1(list,a1) (a1) +# define TRIO_ARGS2(list,a1,a2) (a1,a2) +# define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) +# define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) +# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) +# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) +# define TRIO_VARGS2 TRIO_ARGS2 +# define TRIO_VARGS3 TRIO_ARGS3 +# define TRIO_VARGS4 TRIO_ARGS4 +# define TRIO_VARGS5 TRIO_ARGS5 +# define TRIO_VA_DECL ... +# define TRIO_VA_START(x,y) va_start(x,y) +# define TRIO_VA_END(x) va_end(x) +#endif + +#if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) +# define TRIO_INLINE inline +#elif defined(TRIO_COMPILER_GCC) +# define TRIO_INLINE __inline__ +#elif defined(TRIO_COMPILER_MSVC) +# define TRIO_INLINE _inline +#elif defined(TRIO_COMPILER_BCB) +# define TRIO_INLINE __inline +#else +# define TRIO_INLINE +#endif + +/************************************************************************* + * Workarounds + */ + +#if defined(TRIO_PLATFORM_VMS) +/* + * Computations done with constants at compile time can trigger these + * even when compiling with IEEE enabled. + */ +# pragma message disable (UNDERFLOW, FLOATOVERFL) + +# if (__CRTL_VER < 80000000) +/* + * Although the compiler supports C99 language constructs, the C + * run-time library does not contain all C99 functions. + * + * This was the case for 70300022. Update the 80000000 value when + * it has been accurately determined what version of the library + * supports C99. + */ +# if defined(TRIO_COMPILER_SUPPORTS_C99) +# undef TRIO_COMPILER_SUPPORTS_C99 +# endif +# endif +#endif + +/* + * Not all preprocessors supports the LL token. + */ +#if defined(TRIO_COMPILER_BCB) +#else +# define TRIO_COMPILER_SUPPORTS_LL +#endif + +#endif /* TRIO_TRIODEF_H */ diff --git a/src/trionan.c b/src/trionan.c new file mode 100644 index 000000000000..8767a9fe6485 --- /dev/null +++ b/src/trionan.c @@ -0,0 +1,914 @@ +/************************************************************************* + * + * $Id$ + * + * Copyright (C) 2001 Bjorn Reese + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + * + ************************************************************************ + * + * Functions to handle special quantities in floating-point numbers + * (that is, NaNs and infinity). They provide the capability to detect + * and fabricate special quantities. + * + * Although written to be as portable as possible, it can never be + * guaranteed to work on all platforms, as not all hardware supports + * special quantities. + * + * The approach used here (approximately) is to: + * + * 1. Use C99 functionality when available. + * 2. Use IEEE 754 bit-patterns if possible. + * 3. Use platform-specific techniques. + * + ************************************************************************/ + +/* + * TODO: + * o Put all the magic into trio_fpclassify_and_signbit(), and use this from + * trio_isnan() etc. + */ + +/************************************************************************* + * Include files + */ +#include "triodef.h" +#include "trionan.h" + +#include +#include +#include +#include +#if defined(TRIO_PLATFORM_UNIX) +# include +#endif +#if defined(TRIO_COMPILER_DECC) +# if defined(__linux__) +# include +# else +# include +# endif +#endif +#include + +#if defined(TRIO_DOCUMENTATION) +# include "doc/doc_nan.h" +#endif +/** @addtogroup SpecialQuantities + @{ +*/ + +/************************************************************************* + * Definitions + */ + +#define TRIO_TRUE (1 == 1) +#define TRIO_FALSE (0 == 1) + +/* + * We must enable IEEE floating-point on Alpha + */ +#if defined(__alpha) && !defined(_IEEE_FP) +# if defined(TRIO_COMPILER_DECC) +# if defined(TRIO_PLATFORM_VMS) +# error "Must be compiled with option /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE" +# else +# if !defined(_CFE) +# error "Must be compiled with option -ieee" +# endif +# endif +# elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__)) +# error "Must be compiled with option -mieee" +# endif +#endif /* __alpha && ! _IEEE_FP */ + +/* + * In ANSI/IEEE 754-1985 64-bits double format numbers have the + * following properties (amongst others) + * + * o FLT_RADIX == 2: binary encoding + * o DBL_MAX_EXP == 1024: 11 bits exponent, where one bit is used + * to indicate special numbers (e.g. NaN and Infinity), so the + * maximum exponent is 10 bits wide (2^10 == 1024). + * o DBL_MANT_DIG == 53: The mantissa is 52 bits wide, but because + * numbers are normalized the initial binary 1 is represented + * implicitly (the so-called "hidden bit"), which leaves us with + * the ability to represent 53 bits wide mantissa. + */ +#if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53) +# define USE_IEEE_754 +#endif + + +/************************************************************************* + * Constants + */ + +static TRIO_CONST char rcsid[] = "@(#)$Id$"; + +#if defined(USE_IEEE_754) + +/* + * Endian-agnostic indexing macro. + * + * The value of internalEndianMagic, when converted into a 64-bit + * integer, becomes 0x0706050403020100 (we could have used a 64-bit + * integer value instead of a double, but not all platforms supports + * that type). The value is automatically encoded with the correct + * endianness by the compiler, which means that we can support any + * kind of endianness. The individual bytes are then used as an index + * for the IEEE 754 bit-patterns and masks. + */ +#define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)]) + +#if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0590) +static TRIO_CONST double internalEndianMagic = 7.949928895127362e-275; +#else +static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275; +#endif + +/* Mask for the exponent */ +static TRIO_CONST unsigned char ieee_754_exponent_mask[] = { + 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* Mask for the mantissa */ +static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = { + 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +/* Mask for the sign bit */ +static TRIO_CONST unsigned char ieee_754_sign_mask[] = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* Bit-pattern for negative zero */ +static TRIO_CONST unsigned char ieee_754_negzero_array[] = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* Bit-pattern for infinity */ +static TRIO_CONST unsigned char ieee_754_infinity_array[] = { + 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* Bit-pattern for quiet NaN */ +static TRIO_CONST unsigned char ieee_754_qnan_array[] = { + 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + + +/************************************************************************* + * Functions + */ + +/* + * trio_make_double + */ +TRIO_PRIVATE double +trio_make_double +TRIO_ARGS1((values), + TRIO_CONST unsigned char *values) +{ + TRIO_VOLATILE double result; + int i; + + for (i = 0; i < (int)sizeof(double); i++) { + ((TRIO_VOLATILE unsigned char *)&result)[TRIO_DOUBLE_INDEX(i)] = values[i]; + } + return result; +} + +/* + * trio_is_special_quantity + */ +TRIO_PRIVATE int +trio_is_special_quantity +TRIO_ARGS2((number, has_mantissa), + double number, + int *has_mantissa) +{ + unsigned int i; + unsigned char current; + int is_special_quantity = TRIO_TRUE; + + *has_mantissa = 0; + + for (i = 0; i < (unsigned int)sizeof(double); i++) { + current = ((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)]; + is_special_quantity + &= ((current & ieee_754_exponent_mask[i]) == ieee_754_exponent_mask[i]); + *has_mantissa |= (current & ieee_754_mantissa_mask[i]); + } + return is_special_quantity; +} + +/* + * trio_is_negative + */ +TRIO_PRIVATE int +trio_is_negative +TRIO_ARGS1((number), + double number) +{ + unsigned int i; + int is_negative = TRIO_FALSE; + + for (i = 0; i < (unsigned int)sizeof(double); i++) { + is_negative |= (((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)] + & ieee_754_sign_mask[i]); + } + return is_negative; +} + +#endif /* USE_IEEE_754 */ + + +/** + Generate negative zero. + + @return Floating-point representation of negative zero. +*/ +TRIO_PUBLIC double +trio_nzero(TRIO_NOARGS) +{ +#if defined(USE_IEEE_754) + return trio_make_double(ieee_754_negzero_array); +#else + TRIO_VOLATILE double zero = 0.0; + + return -zero; +#endif +} + +/** + Generate positive infinity. + + @return Floating-point representation of positive infinity. +*/ +TRIO_PUBLIC double +trio_pinf(TRIO_NOARGS) +{ + /* Cache the result */ + static double result = 0.0; + + if (result == 0.0) { + +#if defined(INFINITY) && defined(__STDC_IEC_559__) + result = (double)INFINITY; + +#elif defined(USE_IEEE_754) + result = trio_make_double(ieee_754_infinity_array); + +#else + /* + * If HUGE_VAL is different from DBL_MAX, then HUGE_VAL is used + * as infinity. Otherwise we have to resort to an overflow + * operation to generate infinity. + */ +# if defined(TRIO_PLATFORM_UNIX) + void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); +# endif + + result = HUGE_VAL; + if (HUGE_VAL == DBL_MAX) { + /* Force overflow */ + result += HUGE_VAL; + } + +# if defined(TRIO_PLATFORM_UNIX) + signal(SIGFPE, signal_handler); +# endif + +#endif + } + return result; +} + +/** + Generate negative infinity. + + @return Floating-point value of negative infinity. +*/ +TRIO_PUBLIC double +trio_ninf(TRIO_NOARGS) +{ + static double result = 0.0; + + if (result == 0.0) { + /* + * Negative infinity is calculated by negating positive infinity, + * which can be done because it is legal to do calculations on + * infinity (for example, 1 / infinity == 0). + */ + result = -trio_pinf(); + } + return result; +} + +/** + Generate NaN. + + @return Floating-point representation of NaN. +*/ +TRIO_PUBLIC double +trio_nan(TRIO_NOARGS) +{ + /* Cache the result */ + static double result = 0.0; + + if (result == 0.0) { + +#if defined(TRIO_COMPILER_SUPPORTS_C99) + result = nan(""); + +#elif defined(NAN) && defined(__STDC_IEC_559__) + result = (double)NAN; + +#elif defined(USE_IEEE_754) + result = trio_make_double(ieee_754_qnan_array); + +#else + /* + * There are several ways to generate NaN. The one used here is + * to divide infinity by infinity. I would have preferred to add + * negative infinity to positive infinity, but that yields wrong + * result (infinity) on FreeBSD. + * + * This may fail if the hardware does not support NaN, or if + * the Invalid Operation floating-point exception is unmasked. + */ +# if defined(TRIO_PLATFORM_UNIX) + void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); +# endif + + result = trio_pinf() / trio_pinf(); + +# if defined(TRIO_PLATFORM_UNIX) + signal(SIGFPE, signal_handler); +# endif + +#endif + } + return result; +} + +/** + Check for NaN. + + @param number An arbitrary floating-point number. + @return Boolean value indicating whether or not the number is a NaN. +*/ +TRIO_PUBLIC int +trio_isnan +TRIO_ARGS1((number), + double number) +{ +#if (defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isnan)) \ + || defined(TRIO_COMPILER_SUPPORTS_UNIX95) + /* + * C99 defines isnan() as a macro. UNIX95 defines isnan() as a + * function. This function was already present in XPG4, but this + * is a bit tricky to detect with compiler defines, so we choose + * the conservative approach and only use it for UNIX95. + */ + return isnan(number); + +#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) + /* + * Microsoft Visual C++ and Borland C++ Builder have an _isnan() + * function. + */ + return _isnan(number) ? TRIO_TRUE : TRIO_FALSE; + +#elif defined(USE_IEEE_754) + /* + * Examine IEEE 754 bit-pattern. A NaN must have a special exponent + * pattern, and a non-empty mantissa. + */ + int has_mantissa; + int is_special_quantity; + + is_special_quantity = trio_is_special_quantity(number, &has_mantissa); + + return (is_special_quantity && has_mantissa); + +#else + /* + * Fallback solution + */ + int status; + double integral, fraction; + +# if defined(TRIO_PLATFORM_UNIX) + void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); +# endif + + status = (/* + * NaN is the only number which does not compare to itself + */ + ((TRIO_VOLATILE double)number != (TRIO_VOLATILE double)number) || + /* + * Fallback solution if NaN compares to NaN + */ + ((number != 0.0) && + (fraction = modf(number, &integral), + integral == fraction))); + +# if defined(TRIO_PLATFORM_UNIX) + signal(SIGFPE, signal_handler); +# endif + + return status; + +#endif +} + +/** + Check for infinity. + + @param number An arbitrary floating-point number. + @return 1 if positive infinity, -1 if negative infinity, 0 otherwise. +*/ +TRIO_PUBLIC int +trio_isinf +TRIO_ARGS1((number), + double number) +{ +#if defined(TRIO_COMPILER_DECC) && !defined(__linux__) + /* + * DECC has an isinf() macro, but it works differently than that + * of C99, so we use the fp_class() function instead. + */ + return ((fp_class(number) == FP_POS_INF) + ? 1 + : ((fp_class(number) == FP_NEG_INF) ? -1 : 0)); + +#elif defined(isinf) + /* + * C99 defines isinf() as a macro. + */ + return isinf(number) + ? ((number > 0.0) ? 1 : -1) + : 0; + +#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) + /* + * Microsoft Visual C++ and Borland C++ Builder have an _fpclass() + * function that can be used to detect infinity. + */ + return ((_fpclass(number) == _FPCLASS_PINF) + ? 1 + : ((_fpclass(number) == _FPCLASS_NINF) ? -1 : 0)); + +#elif defined(USE_IEEE_754) + /* + * Examine IEEE 754 bit-pattern. Infinity must have a special exponent + * pattern, and an empty mantissa. + */ + int has_mantissa; + int is_special_quantity; + + is_special_quantity = trio_is_special_quantity(number, &has_mantissa); + + return (is_special_quantity && !has_mantissa) + ? ((number < 0.0) ? -1 : 1) + : 0; + +#else + /* + * Fallback solution. + */ + int status; + +# if defined(TRIO_PLATFORM_UNIX) + void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); +# endif + + double infinity = trio_pinf(); + + status = ((number == infinity) + ? 1 + : ((number == -infinity) ? -1 : 0)); + +# if defined(TRIO_PLATFORM_UNIX) + signal(SIGFPE, signal_handler); +# endif + + return status; + +#endif +} + +#if 0 + /* Temporary fix - this routine is not used anywhere */ +/** + Check for finity. + + @param number An arbitrary floating-point number. + @return Boolean value indicating whether or not the number is a finite. +*/ +TRIO_PUBLIC int +trio_isfinite +TRIO_ARGS1((number), + double number) +{ +#if defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isfinite) + /* + * C99 defines isfinite() as a macro. + */ + return isfinite(number); + +#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) + /* + * Microsoft Visual C++ and Borland C++ Builder use _finite(). + */ + return _finite(number); + +#elif defined(USE_IEEE_754) + /* + * Examine IEEE 754 bit-pattern. For finity we do not care about the + * mantissa. + */ + int dummy; + + return (! trio_is_special_quantity(number, &dummy)); + +#else + /* + * Fallback solution. + */ + return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0)); + +#endif +} + +#endif + +/* + * The sign of NaN is always false + */ +TRIO_PUBLIC int +trio_fpclassify_and_signbit +TRIO_ARGS2((number, is_negative), + double number, + int *is_negative) +{ +#if defined(fpclassify) && defined(signbit) + /* + * C99 defines fpclassify() and signbit() as a macros + */ + *is_negative = signbit(number); + switch (fpclassify(number)) { + case FP_NAN: + return TRIO_FP_NAN; + case FP_INFINITE: + return TRIO_FP_INFINITE; + case FP_SUBNORMAL: + return TRIO_FP_SUBNORMAL; + case FP_ZERO: + return TRIO_FP_ZERO; + default: + return TRIO_FP_NORMAL; + } + +#else +# if defined(TRIO_COMPILER_DECC) + /* + * DECC has an fp_class() function. + */ +# define TRIO_FPCLASSIFY(n) fp_class(n) +# define TRIO_QUIET_NAN FP_QNAN +# define TRIO_SIGNALLING_NAN FP_SNAN +# define TRIO_POSITIVE_INFINITY FP_POS_INF +# define TRIO_NEGATIVE_INFINITY FP_NEG_INF +# define TRIO_POSITIVE_SUBNORMAL FP_POS_DENORM +# define TRIO_NEGATIVE_SUBNORMAL FP_NEG_DENORM +# define TRIO_POSITIVE_ZERO FP_POS_ZERO +# define TRIO_NEGATIVE_ZERO FP_NEG_ZERO +# define TRIO_POSITIVE_NORMAL FP_POS_NORM +# define TRIO_NEGATIVE_NORMAL FP_NEG_NORM + +# elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) + /* + * Microsoft Visual C++ and Borland C++ Builder have an _fpclass() + * function. + */ +# define TRIO_FPCLASSIFY(n) _fpclass(n) +# define TRIO_QUIET_NAN _FPCLASS_QNAN +# define TRIO_SIGNALLING_NAN _FPCLASS_SNAN +# define TRIO_POSITIVE_INFINITY _FPCLASS_PINF +# define TRIO_NEGATIVE_INFINITY _FPCLASS_NINF +# define TRIO_POSITIVE_SUBNORMAL _FPCLASS_PD +# define TRIO_NEGATIVE_SUBNORMAL _FPCLASS_ND +# define TRIO_POSITIVE_ZERO _FPCLASS_PZ +# define TRIO_NEGATIVE_ZERO _FPCLASS_NZ +# define TRIO_POSITIVE_NORMAL _FPCLASS_PN +# define TRIO_NEGATIVE_NORMAL _FPCLASS_NN + +# elif defined(FP_PLUS_NORM) + /* + * HP-UX 9.x and 10.x have an fpclassify() function, that is different + * from the C99 fpclassify() macro supported on HP-UX 11.x. + * + * AIX has class() for C, and _class() for C++, which returns the + * same values as the HP-UX fpclassify() function. + */ +# if defined(TRIO_PLATFORM_AIX) +# if defined(__cplusplus) +# define TRIO_FPCLASSIFY(n) _class(n) +# else +# define TRIO_FPCLASSIFY(n) class(n) +# endif +# else +# define TRIO_FPCLASSIFY(n) fpclassify(n) +# endif +# define TRIO_QUIET_NAN FP_QNAN +# define TRIO_SIGNALLING_NAN FP_SNAN +# define TRIO_POSITIVE_INFINITY FP_PLUS_INF +# define TRIO_NEGATIVE_INFINITY FP_MINUS_INF +# define TRIO_POSITIVE_SUBNORMAL FP_PLUS_DENORM +# define TRIO_NEGATIVE_SUBNORMAL FP_MINUS_DENORM +# define TRIO_POSITIVE_ZERO FP_PLUS_ZERO +# define TRIO_NEGATIVE_ZERO FP_MINUS_ZERO +# define TRIO_POSITIVE_NORMAL FP_PLUS_NORM +# define TRIO_NEGATIVE_NORMAL FP_MINUS_NORM +# endif + +# if defined(TRIO_FPCLASSIFY) + switch (TRIO_FPCLASSIFY(number)) { + case TRIO_QUIET_NAN: + case TRIO_SIGNALLING_NAN: + *is_negative = TRIO_FALSE; /* NaN has no sign */ + return TRIO_FP_NAN; + case TRIO_POSITIVE_INFINITY: + *is_negative = TRIO_FALSE; + return TRIO_FP_INFINITE; + case TRIO_NEGATIVE_INFINITY: + *is_negative = TRIO_TRUE; + return TRIO_FP_INFINITE; + case TRIO_POSITIVE_SUBNORMAL: + *is_negative = TRIO_FALSE; + return TRIO_FP_SUBNORMAL; + case TRIO_NEGATIVE_SUBNORMAL: + *is_negative = TRIO_TRUE; + return TRIO_FP_SUBNORMAL; + case TRIO_POSITIVE_ZERO: + *is_negative = TRIO_FALSE; + return TRIO_FP_ZERO; + case TRIO_NEGATIVE_ZERO: + *is_negative = TRIO_TRUE; + return TRIO_FP_ZERO; + case TRIO_POSITIVE_NORMAL: + *is_negative = TRIO_FALSE; + return TRIO_FP_NORMAL; + case TRIO_NEGATIVE_NORMAL: + *is_negative = TRIO_TRUE; + return TRIO_FP_NORMAL; + default: + /* Just in case... */ + *is_negative = (number < 0.0); + return TRIO_FP_NORMAL; + } + +# else + /* + * Fallback solution. + */ + int rc; + + if (number == 0.0) { + /* + * In IEEE 754 the sign of zero is ignored in comparisons, so we + * have to handle this as a special case by examining the sign bit + * directly. + */ +# if defined(USE_IEEE_754) + *is_negative = trio_is_negative(number); +# else + *is_negative = TRIO_FALSE; /* FIXME */ +# endif + return TRIO_FP_ZERO; + } + if (trio_isnan(number)) { + *is_negative = TRIO_FALSE; + return TRIO_FP_NAN; + } + if ((rc = trio_isinf(number))) { + *is_negative = (rc == -1); + return TRIO_FP_INFINITE; + } + if ((number > 0.0) && (number < DBL_MIN)) { + *is_negative = TRIO_FALSE; + return TRIO_FP_SUBNORMAL; + } + if ((number < 0.0) && (number > -DBL_MIN)) { + *is_negative = TRIO_TRUE; + return TRIO_FP_SUBNORMAL; + } + *is_negative = (number < 0.0); + return TRIO_FP_NORMAL; + +# endif +#endif +} + +/** + Examine the sign of a number. + + @param number An arbitrary floating-point number. + @return Boolean value indicating whether or not the number has the + sign bit set (i.e. is negative). +*/ +TRIO_PUBLIC int +trio_signbit +TRIO_ARGS1((number), + double number) +{ + int is_negative; + + (void)trio_fpclassify_and_signbit(number, &is_negative); + return is_negative; +} + +#if 0 + /* Temporary fix - this routine is not used in libxml */ +/** + Examine the class of a number. + + @param number An arbitrary floating-point number. + @return Enumerable value indicating the class of @p number +*/ +TRIO_PUBLIC int +trio_fpclassify +TRIO_ARGS1((number), + double number) +{ + int dummy; + + return trio_fpclassify_and_signbit(number, &dummy); +} + +#endif + +/** @} SpecialQuantities */ + +/************************************************************************* + * For test purposes. + * + * Add the following compiler option to include this test code. + * + * Unix : -DSTANDALONE + * VMS : /DEFINE=(STANDALONE) + */ +#if defined(STANDALONE) +# include + +static TRIO_CONST char * +getClassification +TRIO_ARGS1((type), + int type) +{ + switch (type) { + case TRIO_FP_INFINITE: + return "FP_INFINITE"; + case TRIO_FP_NAN: + return "FP_NAN"; + case TRIO_FP_NORMAL: + return "FP_NORMAL"; + case TRIO_FP_SUBNORMAL: + return "FP_SUBNORMAL"; + case TRIO_FP_ZERO: + return "FP_ZERO"; + default: + return "FP_UNKNOWN"; + } +} + +static void +print_class +TRIO_ARGS2((prefix, number), + TRIO_CONST char *prefix, + double number) +{ + printf("%-6s: %s %-15s %g\n", + prefix, + trio_signbit(number) ? "-" : "+", + getClassification(TRIO_FPCLASSIFY(number)), + number); +} + +int main(TRIO_NOARGS) +{ + double my_nan; + double my_pinf; + double my_ninf; +# if defined(TRIO_PLATFORM_UNIX) + void (*signal_handler) TRIO_PROTO((int)); +# endif + + my_nan = trio_nan(); + my_pinf = trio_pinf(); + my_ninf = trio_ninf(); + + print_class("Nan", my_nan); + print_class("PInf", my_pinf); + print_class("NInf", my_ninf); + print_class("PZero", 0.0); + print_class("NZero", -0.0); + print_class("PNorm", 1.0); + print_class("NNorm", -1.0); + print_class("PSub", 1.01e-307 - 1.00e-307); + print_class("NSub", 1.00e-307 - 1.01e-307); + + printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", + my_nan, + ((unsigned char *)&my_nan)[0], + ((unsigned char *)&my_nan)[1], + ((unsigned char *)&my_nan)[2], + ((unsigned char *)&my_nan)[3], + ((unsigned char *)&my_nan)[4], + ((unsigned char *)&my_nan)[5], + ((unsigned char *)&my_nan)[6], + ((unsigned char *)&my_nan)[7], + trio_isnan(my_nan), trio_isinf(my_nan)); + printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", + my_pinf, + ((unsigned char *)&my_pinf)[0], + ((unsigned char *)&my_pinf)[1], + ((unsigned char *)&my_pinf)[2], + ((unsigned char *)&my_pinf)[3], + ((unsigned char *)&my_pinf)[4], + ((unsigned char *)&my_pinf)[5], + ((unsigned char *)&my_pinf)[6], + ((unsigned char *)&my_pinf)[7], + trio_isnan(my_pinf), trio_isinf(my_pinf)); + printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", + my_ninf, + ((unsigned char *)&my_ninf)[0], + ((unsigned char *)&my_ninf)[1], + ((unsigned char *)&my_ninf)[2], + ((unsigned char *)&my_ninf)[3], + ((unsigned char *)&my_ninf)[4], + ((unsigned char *)&my_ninf)[5], + ((unsigned char *)&my_ninf)[6], + ((unsigned char *)&my_ninf)[7], + trio_isnan(my_ninf), trio_isinf(my_ninf)); + +# if defined(TRIO_PLATFORM_UNIX) + signal_handler = signal(SIGFPE, SIG_IGN); +# endif + + my_pinf = DBL_MAX + DBL_MAX; + my_ninf = -my_pinf; + my_nan = my_pinf / my_pinf; + +# if defined(TRIO_PLATFORM_UNIX) + signal(SIGFPE, signal_handler); +# endif + + printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", + my_nan, + ((unsigned char *)&my_nan)[0], + ((unsigned char *)&my_nan)[1], + ((unsigned char *)&my_nan)[2], + ((unsigned char *)&my_nan)[3], + ((unsigned char *)&my_nan)[4], + ((unsigned char *)&my_nan)[5], + ((unsigned char *)&my_nan)[6], + ((unsigned char *)&my_nan)[7], + trio_isnan(my_nan), trio_isinf(my_nan)); + printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", + my_pinf, + ((unsigned char *)&my_pinf)[0], + ((unsigned char *)&my_pinf)[1], + ((unsigned char *)&my_pinf)[2], + ((unsigned char *)&my_pinf)[3], + ((unsigned char *)&my_pinf)[4], + ((unsigned char *)&my_pinf)[5], + ((unsigned char *)&my_pinf)[6], + ((unsigned char *)&my_pinf)[7], + trio_isnan(my_pinf), trio_isinf(my_pinf)); + printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", + my_ninf, + ((unsigned char *)&my_ninf)[0], + ((unsigned char *)&my_ninf)[1], + ((unsigned char *)&my_ninf)[2], + ((unsigned char *)&my_ninf)[3], + ((unsigned char *)&my_ninf)[4], + ((unsigned char *)&my_ninf)[5], + ((unsigned char *)&my_ninf)[6], + ((unsigned char *)&my_ninf)[7], + trio_isnan(my_ninf), trio_isinf(my_ninf)); + + return 0; +} +#endif diff --git a/src/trionan.h b/src/trionan.h new file mode 100644 index 000000000000..eac0e6f16862 --- /dev/null +++ b/src/trionan.h @@ -0,0 +1,84 @@ +/************************************************************************* + * + * $Id$ + * + * Copyright (C) 2001 Bjorn Reese + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + * + ************************************************************************/ + +#ifndef TRIO_NAN_H +#define TRIO_NAN_H + +#include "triodef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + TRIO_FP_INFINITE, + TRIO_FP_NAN, + TRIO_FP_NORMAL, + TRIO_FP_SUBNORMAL, + TRIO_FP_ZERO +}; + +/* + * Return NaN (Not-a-Number). + */ +TRIO_PUBLIC double trio_nan TRIO_PROTO((void)); + +/* + * Return positive infinity. + */ +TRIO_PUBLIC double trio_pinf TRIO_PROTO((void)); + +/* + * Return negative infinity. + */ +TRIO_PUBLIC double trio_ninf TRIO_PROTO((void)); + +/* + * Return negative zero. + */ +TRIO_PUBLIC double trio_nzero TRIO_PROTO((TRIO_NOARGS)); + +/* + * If number is a NaN return non-zero, otherwise return zero. + */ +TRIO_PUBLIC int trio_isnan TRIO_PROTO((double number)); + +/* + * If number is positive infinity return 1, if number is negative + * infinity return -1, otherwise return 0. + */ +TRIO_PUBLIC int trio_isinf TRIO_PROTO((double number)); + +/* + * If number is finite return non-zero, otherwise return zero. + */ +#if 0 + /* Temporary fix - these 2 routines not used in libxml */ +TRIO_PUBLIC int trio_isfinite TRIO_PROTO((double number)); + +TRIO_PUBLIC int trio_fpclassify TRIO_PROTO((double number)); +#endif + +TRIO_PUBLIC int trio_signbit TRIO_PROTO((double number)); + +TRIO_PUBLIC int trio_fpclassify_and_signbit TRIO_PROTO((double number, int *is_negative)); + +#ifdef __cplusplus +} +#endif + +#endif /* TRIO_NAN_H */ diff --git a/src/uri.c b/src/uri.c new file mode 100644 index 000000000000..8204825f18f0 --- /dev/null +++ b/src/uri.c @@ -0,0 +1,2561 @@ +/** + * uri.c: set of generic URI related routines + * + * Reference: RFCs 3986, 2732 and 2373 + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#define IN_LIBXML +#include "libxml.h" + +#include +#include + +#include +#include +#include +#include + +/** + * MAX_URI_LENGTH: + * + * The definition of the URI regexp in the above RFC has no size limit + * In practice they are usually relatively short except for the + * data URI scheme as defined in RFC 2397. Even for data URI the usual + * maximum size before hitting random practical limits is around 64 KB + * and 4KB is usually a maximum admitted limit for proper operations. + * The value below is more a security limit than anything else and + * really should never be hit by 'normal' operations + * Set to 1 MByte in 2012, this is only enforced on output + */ +#define MAX_URI_LENGTH 1024 * 1024 + +static void +xmlURIErrMemory(const char *extra) +{ + if (extra) + __xmlRaiseError(NULL, NULL, NULL, + NULL, NULL, XML_FROM_URI, + XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, + extra, NULL, NULL, 0, 0, + "Memory allocation failed : %s\n", extra); + else + __xmlRaiseError(NULL, NULL, NULL, + NULL, NULL, XML_FROM_URI, + XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, + NULL, NULL, NULL, 0, 0, + "Memory allocation failed\n"); +} + +static void xmlCleanURI(xmlURIPtr uri); + +/* + * Old rule from 2396 used in legacy handling code + * alpha = lowalpha | upalpha + */ +#define IS_ALPHA(x) (IS_LOWALPHA(x) || IS_UPALPHA(x)) + + +/* + * lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | + * "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | + * "u" | "v" | "w" | "x" | "y" | "z" + */ + +#define IS_LOWALPHA(x) (((x) >= 'a') && ((x) <= 'z')) + +/* + * upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | + * "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | + * "U" | "V" | "W" | "X" | "Y" | "Z" + */ +#define IS_UPALPHA(x) (((x) >= 'A') && ((x) <= 'Z')) + +#ifdef IS_DIGIT +#undef IS_DIGIT +#endif +/* + * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + */ +#define IS_DIGIT(x) (((x) >= '0') && ((x) <= '9')) + +/* + * alphanum = alpha | digit + */ + +#define IS_ALPHANUM(x) (IS_ALPHA(x) || IS_DIGIT(x)) + +/* + * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" + */ + +#define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') || \ + ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') || \ + ((x) == '(') || ((x) == ')')) + +/* + * unwise = "{" | "}" | "|" | "\" | "^" | "`" + */ + +#define IS_UNWISE(p) \ + (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) || \ + ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) || \ + ((*(p) == ']')) || ((*(p) == '`'))) +/* + * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," | + * "[" | "]" + */ + +#define IS_RESERVED(x) (((x) == ';') || ((x) == '/') || ((x) == '?') || \ + ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \ + ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \ + ((x) == ']')) + +/* + * unreserved = alphanum | mark + */ + +#define IS_UNRESERVED(x) (IS_ALPHANUM(x) || IS_MARK(x)) + +/* + * Skip to next pointer char, handle escaped sequences + */ + +#define NEXT(p) ((*p == '%')? p += 3 : p++) + +/* + * Productions from the spec. + * + * authority = server | reg_name + * reg_name = 1*( unreserved | escaped | "$" | "," | + * ";" | ":" | "@" | "&" | "=" | "+" ) + * + * path = [ abs_path | opaque_part ] + */ + +#define STRNDUP(s, n) (char *) xmlStrndup((const xmlChar *)(s), (n)) + +/************************************************************************ + * * + * RFC 3986 parser * + * * + ************************************************************************/ + +#define ISA_DIGIT(p) ((*(p) >= '0') && (*(p) <= '9')) +#define ISA_ALPHA(p) (((*(p) >= 'a') && (*(p) <= 'z')) || \ + ((*(p) >= 'A') && (*(p) <= 'Z'))) +#define ISA_HEXDIG(p) \ + (ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) || \ + ((*(p) >= 'A') && (*(p) <= 'F'))) + +/* + * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" + * / "*" / "+" / "," / ";" / "=" + */ +#define ISA_SUB_DELIM(p) \ + (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) || \ + ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) || \ + ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) || \ + ((*(p) == '=')) || ((*(p) == '\''))) + +/* + * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" + */ +#define ISA_GEN_DELIM(p) \ + (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) || \ + ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) || \ + ((*(p) == '@'))) + +/* + * reserved = gen-delims / sub-delims + */ +#define ISA_RESERVED(p) (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p))) + +/* + * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + */ +#define ISA_UNRESERVED(p) \ + ((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) || \ + ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~'))) + +/* + * pct-encoded = "%" HEXDIG HEXDIG + */ +#define ISA_PCT_ENCODED(p) \ + ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2))) + +/* + * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" + */ +#define ISA_PCHAR(p) \ + (ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) || \ + ((*(p) == ':')) || ((*(p) == '@'))) + +/** + * xmlParse3986Scheme: + * @uri: pointer to an URI structure + * @str: pointer to the string to analyze + * + * Parse an URI scheme + * + * ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) + * + * Returns 0 or the error code + */ +static int +xmlParse3986Scheme(xmlURIPtr uri, const char **str) { + const char *cur; + + if (str == NULL) + return(-1); + + cur = *str; + if (!ISA_ALPHA(cur)) + return(2); + cur++; + while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || + (*cur == '+') || (*cur == '-') || (*cur == '.')) cur++; + if (uri != NULL) { + if (uri->scheme != NULL) xmlFree(uri->scheme); + uri->scheme = STRNDUP(*str, cur - *str); + } + *str = cur; + return(0); +} + +/** + * xmlParse3986Fragment: + * @uri: pointer to an URI structure + * @str: pointer to the string to analyze + * + * Parse the query part of an URI + * + * fragment = *( pchar / "/" / "?" ) + * NOTE: the strict syntax as defined by 3986 does not allow '[' and ']' + * in the fragment identifier but this is used very broadly for + * xpointer scheme selection, so we are allowing it here to not break + * for example all the DocBook processing chains. + * + * Returns 0 or the error code + */ +static int +xmlParse3986Fragment(xmlURIPtr uri, const char **str) +{ + const char *cur; + + if (str == NULL) + return (-1); + + cur = *str; + + while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') || + (*cur == '[') || (*cur == ']') || + ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) + NEXT(cur); + if (uri != NULL) { + if (uri->fragment != NULL) + xmlFree(uri->fragment); + if (uri->cleanup & 2) + uri->fragment = STRNDUP(*str, cur - *str); + else + uri->fragment = xmlURIUnescapeString(*str, cur - *str, NULL); + } + *str = cur; + return (0); +} + +/** + * xmlParse3986Query: + * @uri: pointer to an URI structure + * @str: pointer to the string to analyze + * + * Parse the query part of an URI + * + * query = *uric + * + * Returns 0 or the error code + */ +static int +xmlParse3986Query(xmlURIPtr uri, const char **str) +{ + const char *cur; + + if (str == NULL) + return (-1); + + cur = *str; + + while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') || + ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) + NEXT(cur); + if (uri != NULL) { + if (uri->query != NULL) + xmlFree(uri->query); + if (uri->cleanup & 2) + uri->query = STRNDUP(*str, cur - *str); + else + uri->query = xmlURIUnescapeString(*str, cur - *str, NULL); + + /* Save the raw bytes of the query as well. + * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00114 + */ + if (uri->query_raw != NULL) + xmlFree (uri->query_raw); + uri->query_raw = STRNDUP (*str, cur - *str); + } + *str = cur; + return (0); +} + +/** + * xmlParse3986Port: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse a port part and fills in the appropriate fields + * of the @uri structure + * + * port = *DIGIT + * + * Returns 0 or the error code + */ +static int +xmlParse3986Port(xmlURIPtr uri, const char **str) +{ + const char *cur = *str; + int port = 0; + + if (ISA_DIGIT(cur)) { + while (ISA_DIGIT(cur)) { + int digit = *cur - '0'; + + if (port > INT_MAX / 10) + return(1); + port *= 10; + if (port > INT_MAX - digit) + return(1); + port += digit; + + cur++; + } + if (uri != NULL) + uri->port = port; + *str = cur; + return(0); + } + return(1); +} + +/** + * xmlParse3986Userinfo: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an user information part and fills in the appropriate fields + * of the @uri structure + * + * userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) + * + * Returns 0 or the error code + */ +static int +xmlParse3986Userinfo(xmlURIPtr uri, const char **str) +{ + const char *cur; + + cur = *str; + while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || + ISA_SUB_DELIM(cur) || (*cur == ':')) + NEXT(cur); + if (*cur == '@') { + if (uri != NULL) { + if (uri->user != NULL) xmlFree(uri->user); + if (uri->cleanup & 2) + uri->user = STRNDUP(*str, cur - *str); + else + uri->user = xmlURIUnescapeString(*str, cur - *str, NULL); + } + *str = cur; + return(0); + } + return(1); +} + +/** + * xmlParse3986DecOctet: + * @str: the string to analyze + * + * dec-octet = DIGIT ; 0-9 + * / %x31-39 DIGIT ; 10-99 + * / "1" 2DIGIT ; 100-199 + * / "2" %x30-34 DIGIT ; 200-249 + * / "25" %x30-35 ; 250-255 + * + * Skip a dec-octet. + * + * Returns 0 if found and skipped, 1 otherwise + */ +static int +xmlParse3986DecOctet(const char **str) { + const char *cur = *str; + + if (!(ISA_DIGIT(cur))) + return(1); + if (!ISA_DIGIT(cur+1)) + cur++; + else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur+2))) + cur += 2; + else if ((*cur == '1') && (ISA_DIGIT(cur + 1)) && (ISA_DIGIT(cur + 2))) + cur += 3; + else if ((*cur == '2') && (*(cur + 1) >= '0') && + (*(cur + 1) <= '4') && (ISA_DIGIT(cur + 2))) + cur += 3; + else if ((*cur == '2') && (*(cur + 1) == '5') && + (*(cur + 2) >= '0') && (*(cur + 1) <= '5')) + cur += 3; + else + return(1); + *str = cur; + return(0); +} +/** + * xmlParse3986Host: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an host part and fills in the appropriate fields + * of the @uri structure + * + * host = IP-literal / IPv4address / reg-name + * IP-literal = "[" ( IPv6address / IPvFuture ) "]" + * IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet + * reg-name = *( unreserved / pct-encoded / sub-delims ) + * + * Returns 0 or the error code + */ +static int +xmlParse3986Host(xmlURIPtr uri, const char **str) +{ + const char *cur = *str; + const char *host; + + host = cur; + /* + * IPv6 and future addressing scheme are enclosed between brackets + */ + if (*cur == '[') { + cur++; + while ((*cur != ']') && (*cur != 0)) + cur++; + if (*cur != ']') + return(1); + cur++; + goto found; + } + /* + * try to parse an IPv4 + */ + if (ISA_DIGIT(cur)) { + if (xmlParse3986DecOctet(&cur) != 0) + goto not_ipv4; + if (*cur != '.') + goto not_ipv4; + cur++; + if (xmlParse3986DecOctet(&cur) != 0) + goto not_ipv4; + if (*cur != '.') + goto not_ipv4; + if (xmlParse3986DecOctet(&cur) != 0) + goto not_ipv4; + if (*cur != '.') + goto not_ipv4; + if (xmlParse3986DecOctet(&cur) != 0) + goto not_ipv4; + goto found; +not_ipv4: + cur = *str; + } + /* + * then this should be a hostname which can be empty + */ + while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || ISA_SUB_DELIM(cur)) + NEXT(cur); +found: + if (uri != NULL) { + if (uri->authority != NULL) xmlFree(uri->authority); + uri->authority = NULL; + if (uri->server != NULL) xmlFree(uri->server); + if (cur != host) { + if (uri->cleanup & 2) + uri->server = STRNDUP(host, cur - host); + else + uri->server = xmlURIUnescapeString(host, cur - host, NULL); + } else + uri->server = NULL; + } + *str = cur; + return(0); +} + +/** + * xmlParse3986Authority: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an authority part and fills in the appropriate fields + * of the @uri structure + * + * authority = [ userinfo "@" ] host [ ":" port ] + * + * Returns 0 or the error code + */ +static int +xmlParse3986Authority(xmlURIPtr uri, const char **str) +{ + const char *cur; + int ret; + + cur = *str; + /* + * try to parse an userinfo and check for the trailing @ + */ + ret = xmlParse3986Userinfo(uri, &cur); + if ((ret != 0) || (*cur != '@')) + cur = *str; + else + cur++; + ret = xmlParse3986Host(uri, &cur); + if (ret != 0) return(ret); + if (*cur == ':') { + cur++; + ret = xmlParse3986Port(uri, &cur); + if (ret != 0) return(ret); + } + *str = cur; + return(0); +} + +/** + * xmlParse3986Segment: + * @str: the string to analyze + * @forbid: an optional forbidden character + * @empty: allow an empty segment + * + * Parse a segment and fills in the appropriate fields + * of the @uri structure + * + * segment = *pchar + * segment-nz = 1*pchar + * segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) + * ; non-zero-length segment without any colon ":" + * + * Returns 0 or the error code + */ +static int +xmlParse3986Segment(const char **str, char forbid, int empty) +{ + const char *cur; + + cur = *str; + if (!ISA_PCHAR(cur)) { + if (empty) + return(0); + return(1); + } + while (ISA_PCHAR(cur) && (*cur != forbid)) + NEXT(cur); + *str = cur; + return (0); +} + +/** + * xmlParse3986PathAbEmpty: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an path absolute or empty and fills in the appropriate fields + * of the @uri structure + * + * path-abempty = *( "/" segment ) + * + * Returns 0 or the error code + */ +static int +xmlParse3986PathAbEmpty(xmlURIPtr uri, const char **str) +{ + const char *cur; + int ret; + + cur = *str; + + while (*cur == '/') { + cur++; + ret = xmlParse3986Segment(&cur, 0, 1); + if (ret != 0) return(ret); + } + if (uri != NULL) { + if (uri->path != NULL) xmlFree(uri->path); + if (*str != cur) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } + } + *str = cur; + return (0); +} + +/** + * xmlParse3986PathAbsolute: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an path absolute and fills in the appropriate fields + * of the @uri structure + * + * path-absolute = "/" [ segment-nz *( "/" segment ) ] + * + * Returns 0 or the error code + */ +static int +xmlParse3986PathAbsolute(xmlURIPtr uri, const char **str) +{ + const char *cur; + int ret; + + cur = *str; + + if (*cur != '/') + return(1); + cur++; + ret = xmlParse3986Segment(&cur, 0, 0); + if (ret == 0) { + while (*cur == '/') { + cur++; + ret = xmlParse3986Segment(&cur, 0, 1); + if (ret != 0) return(ret); + } + } + if (uri != NULL) { + if (uri->path != NULL) xmlFree(uri->path); + if (cur != *str) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } + } + *str = cur; + return (0); +} + +/** + * xmlParse3986PathRootless: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an path without root and fills in the appropriate fields + * of the @uri structure + * + * path-rootless = segment-nz *( "/" segment ) + * + * Returns 0 or the error code + */ +static int +xmlParse3986PathRootless(xmlURIPtr uri, const char **str) +{ + const char *cur; + int ret; + + cur = *str; + + ret = xmlParse3986Segment(&cur, 0, 0); + if (ret != 0) return(ret); + while (*cur == '/') { + cur++; + ret = xmlParse3986Segment(&cur, 0, 1); + if (ret != 0) return(ret); + } + if (uri != NULL) { + if (uri->path != NULL) xmlFree(uri->path); + if (cur != *str) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } + } + *str = cur; + return (0); +} + +/** + * xmlParse3986PathNoScheme: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an path which is not a scheme and fills in the appropriate fields + * of the @uri structure + * + * path-noscheme = segment-nz-nc *( "/" segment ) + * + * Returns 0 or the error code + */ +static int +xmlParse3986PathNoScheme(xmlURIPtr uri, const char **str) +{ + const char *cur; + int ret; + + cur = *str; + + ret = xmlParse3986Segment(&cur, ':', 0); + if (ret != 0) return(ret); + while (*cur == '/') { + cur++; + ret = xmlParse3986Segment(&cur, 0, 1); + if (ret != 0) return(ret); + } + if (uri != NULL) { + if (uri->path != NULL) xmlFree(uri->path); + if (cur != *str) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } + } + *str = cur; + return (0); +} + +/** + * xmlParse3986HierPart: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an hierarchical part and fills in the appropriate fields + * of the @uri structure + * + * hier-part = "//" authority path-abempty + * / path-absolute + * / path-rootless + * / path-empty + * + * Returns 0 or the error code + */ +static int +xmlParse3986HierPart(xmlURIPtr uri, const char **str) +{ + const char *cur; + int ret; + + cur = *str; + + if ((*cur == '/') && (*(cur + 1) == '/')) { + cur += 2; + ret = xmlParse3986Authority(uri, &cur); + if (ret != 0) return(ret); + if (uri->server == NULL) + uri->port = -1; + ret = xmlParse3986PathAbEmpty(uri, &cur); + if (ret != 0) return(ret); + *str = cur; + return(0); + } else if (*cur == '/') { + ret = xmlParse3986PathAbsolute(uri, &cur); + if (ret != 0) return(ret); + } else if (ISA_PCHAR(cur)) { + ret = xmlParse3986PathRootless(uri, &cur); + if (ret != 0) return(ret); + } else { + /* path-empty is effectively empty */ + if (uri != NULL) { + if (uri->path != NULL) xmlFree(uri->path); + uri->path = NULL; + } + } + *str = cur; + return (0); +} + +/** + * xmlParse3986RelativeRef: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an URI string and fills in the appropriate fields + * of the @uri structure + * + * relative-ref = relative-part [ "?" query ] [ "#" fragment ] + * relative-part = "//" authority path-abempty + * / path-absolute + * / path-noscheme + * / path-empty + * + * Returns 0 or the error code + */ +static int +xmlParse3986RelativeRef(xmlURIPtr uri, const char *str) { + int ret; + + if ((*str == '/') && (*(str + 1) == '/')) { + str += 2; + ret = xmlParse3986Authority(uri, &str); + if (ret != 0) return(ret); + ret = xmlParse3986PathAbEmpty(uri, &str); + if (ret != 0) return(ret); + } else if (*str == '/') { + ret = xmlParse3986PathAbsolute(uri, &str); + if (ret != 0) return(ret); + } else if (ISA_PCHAR(str)) { + ret = xmlParse3986PathNoScheme(uri, &str); + if (ret != 0) return(ret); + } else { + /* path-empty is effectively empty */ + if (uri != NULL) { + if (uri->path != NULL) xmlFree(uri->path); + uri->path = NULL; + } + } + + if (*str == '?') { + str++; + ret = xmlParse3986Query(uri, &str); + if (ret != 0) return(ret); + } + if (*str == '#') { + str++; + ret = xmlParse3986Fragment(uri, &str); + if (ret != 0) return(ret); + } + if (*str != 0) { + xmlCleanURI(uri); + return(1); + } + return(0); +} + + +/** + * xmlParse3986URI: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an URI string and fills in the appropriate fields + * of the @uri structure + * + * scheme ":" hier-part [ "?" query ] [ "#" fragment ] + * + * Returns 0 or the error code + */ +static int +xmlParse3986URI(xmlURIPtr uri, const char *str) { + int ret; + + ret = xmlParse3986Scheme(uri, &str); + if (ret != 0) return(ret); + if (*str != ':') { + return(1); + } + str++; + ret = xmlParse3986HierPart(uri, &str); + if (ret != 0) return(ret); + if (*str == '?') { + str++; + ret = xmlParse3986Query(uri, &str); + if (ret != 0) return(ret); + } + if (*str == '#') { + str++; + ret = xmlParse3986Fragment(uri, &str); + if (ret != 0) return(ret); + } + if (*str != 0) { + xmlCleanURI(uri); + return(1); + } + return(0); +} + +/** + * xmlParse3986URIReference: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an URI reference string and fills in the appropriate fields + * of the @uri structure + * + * URI-reference = URI / relative-ref + * + * Returns 0 or the error code + */ +static int +xmlParse3986URIReference(xmlURIPtr uri, const char *str) { + int ret; + + if (str == NULL) + return(-1); + xmlCleanURI(uri); + + /* + * Try first to parse absolute refs, then fallback to relative if + * it fails. + */ + ret = xmlParse3986URI(uri, str); + if (ret != 0) { + xmlCleanURI(uri); + ret = xmlParse3986RelativeRef(uri, str); + if (ret != 0) { + xmlCleanURI(uri); + return(ret); + } + } + return(0); +} + +/** + * xmlParseURI: + * @str: the URI string to analyze + * + * Parse an URI based on RFC 3986 + * + * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] + * + * Returns a newly built xmlURIPtr or NULL in case of error + */ +xmlURIPtr +xmlParseURI(const char *str) { + xmlURIPtr uri; + int ret; + + if (str == NULL) + return(NULL); + uri = xmlCreateURI(); + if (uri != NULL) { + ret = xmlParse3986URIReference(uri, str); + if (ret) { + xmlFreeURI(uri); + return(NULL); + } + } + return(uri); +} + +/** + * xmlParseURIReference: + * @uri: pointer to an URI structure + * @str: the string to analyze + * + * Parse an URI reference string based on RFC 3986 and fills in the + * appropriate fields of the @uri structure + * + * URI-reference = URI / relative-ref + * + * Returns 0 or the error code + */ +int +xmlParseURIReference(xmlURIPtr uri, const char *str) { + return(xmlParse3986URIReference(uri, str)); +} + +/** + * xmlParseURIRaw: + * @str: the URI string to analyze + * @raw: if 1 unescaping of URI pieces are disabled + * + * Parse an URI but allows to keep intact the original fragments. + * + * URI-reference = URI / relative-ref + * + * Returns a newly built xmlURIPtr or NULL in case of error + */ +xmlURIPtr +xmlParseURIRaw(const char *str, int raw) { + xmlURIPtr uri; + int ret; + + if (str == NULL) + return(NULL); + uri = xmlCreateURI(); + if (uri != NULL) { + if (raw) { + uri->cleanup |= 2; + } + ret = xmlParseURIReference(uri, str); + if (ret) { + xmlFreeURI(uri); + return(NULL); + } + } + return(uri); +} + +/************************************************************************ + * * + * Generic URI structure functions * + * * + ************************************************************************/ + +/** + * xmlCreateURI: + * + * Simply creates an empty xmlURI + * + * Returns the new structure or NULL in case of error + */ +xmlURIPtr +xmlCreateURI(void) { + xmlURIPtr ret; + + ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI)); + if (ret == NULL) { + xmlURIErrMemory("creating URI structure\n"); + return(NULL); + } + memset(ret, 0, sizeof(xmlURI)); + return(ret); +} + +/** + * xmlSaveUriRealloc: + * + * Function to handle properly a reallocation when saving an URI + * Also imposes some limit on the length of an URI string output + */ +static xmlChar * +xmlSaveUriRealloc(xmlChar *ret, int *max) { + xmlChar *temp; + int tmp; + + if (*max > MAX_URI_LENGTH) { + xmlURIErrMemory("reaching arbitrary MAX_URI_LENGTH limit\n"); + return(NULL); + } + tmp = *max * 2; + temp = (xmlChar *) xmlRealloc(ret, (tmp + 1)); + if (temp == NULL) { + xmlURIErrMemory("saving URI\n"); + return(NULL); + } + *max = tmp; + return(temp); +} + +/** + * xmlSaveUri: + * @uri: pointer to an xmlURI + * + * Save the URI as an escaped string + * + * Returns a new string (to be deallocated by caller) + */ +xmlChar * +xmlSaveUri(xmlURIPtr uri) { + xmlChar *ret = NULL; + xmlChar *temp; + const char *p; + int len; + int max; + + if (uri == NULL) return(NULL); + + + max = 80; + ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar)); + if (ret == NULL) { + xmlURIErrMemory("saving URI\n"); + return(NULL); + } + len = 0; + + if (uri->scheme != NULL) { + p = uri->scheme; + while (*p != 0) { + if (len >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = *p++; + } + if (len >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = ':'; + } + if (uri->opaque != NULL) { + p = uri->opaque; + while (*p != 0) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p))) + ret[len++] = *p++; + else { + int val = *(unsigned char *)p++; + int hi = val / 0x10, lo = val % 0x10; + ret[len++] = '%'; + ret[len++] = hi + (hi > 9? 'A'-10 : '0'); + ret[len++] = lo + (lo > 9? 'A'-10 : '0'); + } + } + } else { + if ((uri->server != NULL) || (uri->port == -1)) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = '/'; + ret[len++] = '/'; + if (uri->user != NULL) { + p = uri->user; + while (*p != 0) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + if ((IS_UNRESERVED(*(p))) || + ((*(p) == ';')) || ((*(p) == ':')) || + ((*(p) == '&')) || ((*(p) == '=')) || + ((*(p) == '+')) || ((*(p) == '$')) || + ((*(p) == ','))) + ret[len++] = *p++; + else { + int val = *(unsigned char *)p++; + int hi = val / 0x10, lo = val % 0x10; + ret[len++] = '%'; + ret[len++] = hi + (hi > 9? 'A'-10 : '0'); + ret[len++] = lo + (lo > 9? 'A'-10 : '0'); + } + } + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = '@'; + } + if (uri->server != NULL) { + p = uri->server; + while (*p != 0) { + if (len >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = *p++; + } + if (uri->port > 0) { + if (len + 10 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + len += snprintf((char *) &ret[len], max - len, ":%d", uri->port); + } + } + } else if (uri->authority != NULL) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = '/'; + ret[len++] = '/'; + p = uri->authority; + while (*p != 0) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + if ((IS_UNRESERVED(*(p))) || + ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) || + ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) || + ((*(p) == '=')) || ((*(p) == '+'))) + ret[len++] = *p++; + else { + int val = *(unsigned char *)p++; + int hi = val / 0x10, lo = val % 0x10; + ret[len++] = '%'; + ret[len++] = hi + (hi > 9? 'A'-10 : '0'); + ret[len++] = lo + (lo > 9? 'A'-10 : '0'); + } + } + } else if (uri->scheme != NULL) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + } + if (uri->path != NULL) { + p = uri->path; + /* + * the colon in file:///d: should not be escaped or + * Windows accesses fail later. + */ + if ((uri->scheme != NULL) && + (p[0] == '/') && + (((p[1] >= 'a') && (p[1] <= 'z')) || + ((p[1] >= 'A') && (p[1] <= 'Z'))) && + (p[2] == ':') && + (xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = *p++; + ret[len++] = *p++; + ret[len++] = *p++; + } + while (*p != 0) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) || + ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) || + ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || + ((*(p) == ','))) + ret[len++] = *p++; + else { + int val = *(unsigned char *)p++; + int hi = val / 0x10, lo = val % 0x10; + ret[len++] = '%'; + ret[len++] = hi + (hi > 9? 'A'-10 : '0'); + ret[len++] = lo + (lo > 9? 'A'-10 : '0'); + } + } + } + if (uri->query_raw != NULL) { + if (len + 1 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = '?'; + p = uri->query_raw; + while (*p != 0) { + if (len + 1 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = *p++; + } + } else if (uri->query != NULL) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = '?'; + p = uri->query; + while (*p != 0) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p)))) + ret[len++] = *p++; + else { + int val = *(unsigned char *)p++; + int hi = val / 0x10, lo = val % 0x10; + ret[len++] = '%'; + ret[len++] = hi + (hi > 9? 'A'-10 : '0'); + ret[len++] = lo + (lo > 9? 'A'-10 : '0'); + } + } + } + } + if (uri->fragment != NULL) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len++] = '#'; + p = uri->fragment; + while (*p != 0) { + if (len + 3 >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p)))) + ret[len++] = *p++; + else { + int val = *(unsigned char *)p++; + int hi = val / 0x10, lo = val % 0x10; + ret[len++] = '%'; + ret[len++] = hi + (hi > 9? 'A'-10 : '0'); + ret[len++] = lo + (lo > 9? 'A'-10 : '0'); + } + } + } + if (len >= max) { + temp = xmlSaveUriRealloc(ret, &max); + if (temp == NULL) goto mem_error; + ret = temp; + } + ret[len] = 0; + return(ret); + +mem_error: + xmlFree(ret); + return(NULL); +} + +/** + * xmlPrintURI: + * @stream: a FILE* for the output + * @uri: pointer to an xmlURI + * + * Prints the URI in the stream @stream. + */ +void +xmlPrintURI(FILE *stream, xmlURIPtr uri) { + xmlChar *out; + + out = xmlSaveUri(uri); + if (out != NULL) { + fprintf(stream, "%s", (char *) out); + xmlFree(out); + } +} + +/** + * xmlCleanURI: + * @uri: pointer to an xmlURI + * + * Make sure the xmlURI struct is free of content + */ +static void +xmlCleanURI(xmlURIPtr uri) { + if (uri == NULL) return; + + if (uri->scheme != NULL) xmlFree(uri->scheme); + uri->scheme = NULL; + if (uri->server != NULL) xmlFree(uri->server); + uri->server = NULL; + if (uri->user != NULL) xmlFree(uri->user); + uri->user = NULL; + if (uri->path != NULL) xmlFree(uri->path); + uri->path = NULL; + if (uri->fragment != NULL) xmlFree(uri->fragment); + uri->fragment = NULL; + if (uri->opaque != NULL) xmlFree(uri->opaque); + uri->opaque = NULL; + if (uri->authority != NULL) xmlFree(uri->authority); + uri->authority = NULL; + if (uri->query != NULL) xmlFree(uri->query); + uri->query = NULL; + if (uri->query_raw != NULL) xmlFree(uri->query_raw); + uri->query_raw = NULL; +} + +/** + * xmlFreeURI: + * @uri: pointer to an xmlURI + * + * Free up the xmlURI struct + */ +void +xmlFreeURI(xmlURIPtr uri) { + if (uri == NULL) return; + + if (uri->scheme != NULL) xmlFree(uri->scheme); + if (uri->server != NULL) xmlFree(uri->server); + if (uri->user != NULL) xmlFree(uri->user); + if (uri->path != NULL) xmlFree(uri->path); + if (uri->fragment != NULL) xmlFree(uri->fragment); + if (uri->opaque != NULL) xmlFree(uri->opaque); + if (uri->authority != NULL) xmlFree(uri->authority); + if (uri->query != NULL) xmlFree(uri->query); + if (uri->query_raw != NULL) xmlFree(uri->query_raw); + xmlFree(uri); +} + +/************************************************************************ + * * + * Helper functions * + * * + ************************************************************************/ + +/** + * xmlNormalizeURIPath: + * @path: pointer to the path string + * + * Applies the 5 normalization steps to a path string--that is, RFC 2396 + * Section 5.2, steps 6.c through 6.g. + * + * Normalization occurs directly on the string, no new allocation is done + * + * Returns 0 or an error code + */ +int +xmlNormalizeURIPath(char *path) { + char *cur, *out; + + if (path == NULL) + return(-1); + + /* Skip all initial "/" chars. We want to get to the beginning of the + * first non-empty segment. + */ + cur = path; + while (cur[0] == '/') + ++cur; + if (cur[0] == '\0') + return(0); + + /* Keep everything we've seen so far. */ + out = cur; + + /* + * Analyze each segment in sequence for cases (c) and (d). + */ + while (cur[0] != '\0') { + /* + * c) All occurrences of "./", where "." is a complete path segment, + * are removed from the buffer string. + */ + if ((cur[0] == '.') && (cur[1] == '/')) { + cur += 2; + /* '//' normalization should be done at this point too */ + while (cur[0] == '/') + cur++; + continue; + } + + /* + * d) If the buffer string ends with "." as a complete path segment, + * that "." is removed. + */ + if ((cur[0] == '.') && (cur[1] == '\0')) + break; + + /* Otherwise keep the segment. */ + while (cur[0] != '/') { + if (cur[0] == '\0') + goto done_cd; + (out++)[0] = (cur++)[0]; + } + /* normalize // */ + while ((cur[0] == '/') && (cur[1] == '/')) + cur++; + + (out++)[0] = (cur++)[0]; + } + done_cd: + out[0] = '\0'; + + /* Reset to the beginning of the first segment for the next sequence. */ + cur = path; + while (cur[0] == '/') + ++cur; + if (cur[0] == '\0') + return(0); + + /* + * Analyze each segment in sequence for cases (e) and (f). + * + * e) All occurrences of "/../", where is a + * complete path segment not equal to "..", are removed from the + * buffer string. Removal of these path segments is performed + * iteratively, removing the leftmost matching pattern on each + * iteration, until no matching pattern remains. + * + * f) If the buffer string ends with "/..", where + * is a complete path segment not equal to "..", that + * "/.." is removed. + * + * To satisfy the "iterative" clause in (e), we need to collapse the + * string every time we find something that needs to be removed. Thus, + * we don't need to keep two pointers into the string: we only need a + * "current position" pointer. + */ + while (1) { + char *segp, *tmp; + + /* At the beginning of each iteration of this loop, "cur" points to + * the first character of the segment we want to examine. + */ + + /* Find the end of the current segment. */ + segp = cur; + while ((segp[0] != '/') && (segp[0] != '\0')) + ++segp; + + /* If this is the last segment, we're done (we need at least two + * segments to meet the criteria for the (e) and (f) cases). + */ + if (segp[0] == '\0') + break; + + /* If the first segment is "..", or if the next segment _isn't_ "..", + * keep this segment and try the next one. + */ + ++segp; + if (((cur[0] == '.') && (cur[1] == '.') && (segp == cur+3)) + || ((segp[0] != '.') || (segp[1] != '.') + || ((segp[2] != '/') && (segp[2] != '\0')))) { + cur = segp; + continue; + } + + /* If we get here, remove this segment and the next one and back up + * to the previous segment (if there is one), to implement the + * "iteratively" clause. It's pretty much impossible to back up + * while maintaining two pointers into the buffer, so just compact + * the whole buffer now. + */ + + /* If this is the end of the buffer, we're done. */ + if (segp[2] == '\0') { + cur[0] = '\0'; + break; + } + /* Valgrind complained, strcpy(cur, segp + 3); */ + /* string will overlap, do not use strcpy */ + tmp = cur; + segp += 3; + while ((*tmp++ = *segp++) != 0) + ; + + /* If there are no previous segments, then keep going from here. */ + segp = cur; + while ((segp > path) && ((--segp)[0] == '/')) + ; + if (segp == path) + continue; + + /* "segp" is pointing to the end of a previous segment; find it's + * start. We need to back up to the previous segment and start + * over with that to handle things like "foo/bar/../..". If we + * don't do this, then on the first pass we'll remove the "bar/..", + * but be pointing at the second ".." so we won't realize we can also + * remove the "foo/..". + */ + cur = segp; + while ((cur > path) && (cur[-1] != '/')) + --cur; + } + out[0] = '\0'; + + /* + * g) If the resulting buffer string still begins with one or more + * complete path segments of "..", then the reference is + * considered to be in error. Implementations may handle this + * error by retaining these components in the resolved path (i.e., + * treating them as part of the final URI), by removing them from + * the resolved path (i.e., discarding relative levels above the + * root), or by avoiding traversal of the reference. + * + * We discard them from the final path. + */ + if (path[0] == '/') { + cur = path; + while ((cur[0] == '/') && (cur[1] == '.') && (cur[2] == '.') + && ((cur[3] == '/') || (cur[3] == '\0'))) + cur += 3; + + if (cur != path) { + out = path; + while (cur[0] != '\0') + (out++)[0] = (cur++)[0]; + out[0] = 0; + } + } + + return(0); +} + +static int is_hex(char c) { + if (((c >= '0') && (c <= '9')) || + ((c >= 'a') && (c <= 'f')) || + ((c >= 'A') && (c <= 'F'))) + return(1); + return(0); +} + +/** + * xmlURIUnescapeString: + * @str: the string to unescape + * @len: the length in bytes to unescape (or <= 0 to indicate full string) + * @target: optional destination buffer + * + * Unescaping routine, but does not check that the string is an URI. The + * output is a direct unsigned char translation of %XX values (no encoding) + * Note that the length of the result can only be smaller or same size as + * the input string. + * + * Returns a copy of the string, but unescaped, will return NULL only in case + * of error + */ +char * +xmlURIUnescapeString(const char *str, int len, char *target) { + char *ret, *out; + const char *in; + + if (str == NULL) + return(NULL); + if (len <= 0) len = strlen(str); + if (len < 0) return(NULL); + + if (target == NULL) { + ret = (char *) xmlMallocAtomic(len + 1); + if (ret == NULL) { + xmlURIErrMemory("unescaping URI value\n"); + return(NULL); + } + } else + ret = target; + in = str; + out = ret; + while(len > 0) { + if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) { + in++; + if ((*in >= '0') && (*in <= '9')) + *out = (*in - '0'); + else if ((*in >= 'a') && (*in <= 'f')) + *out = (*in - 'a') + 10; + else if ((*in >= 'A') && (*in <= 'F')) + *out = (*in - 'A') + 10; + in++; + if ((*in >= '0') && (*in <= '9')) + *out = *out * 16 + (*in - '0'); + else if ((*in >= 'a') && (*in <= 'f')) + *out = *out * 16 + (*in - 'a') + 10; + else if ((*in >= 'A') && (*in <= 'F')) + *out = *out * 16 + (*in - 'A') + 10; + in++; + len -= 3; + out++; + } else { + *out++ = *in++; + len--; + } + } + *out = 0; + return(ret); +} + +/** + * xmlURIEscapeStr: + * @str: string to escape + * @list: exception list string of chars not to escape + * + * This routine escapes a string to hex, ignoring reserved characters (a-z) + * and the characters in the exception list. + * + * Returns a new escaped string or NULL in case of error. + */ +xmlChar * +xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) { + xmlChar *ret, ch; + xmlChar *temp; + const xmlChar *in; + int len, out; + + if (str == NULL) + return(NULL); + if (str[0] == 0) + return(xmlStrdup(str)); + len = xmlStrlen(str); + if (!(len > 0)) return(NULL); + + len += 20; + ret = (xmlChar *) xmlMallocAtomic(len); + if (ret == NULL) { + xmlURIErrMemory("escaping URI value\n"); + return(NULL); + } + in = (const xmlChar *) str; + out = 0; + while(*in != 0) { + if (len - out <= 3) { + temp = xmlSaveUriRealloc(ret, &len); + if (temp == NULL) { + xmlURIErrMemory("escaping URI value\n"); + xmlFree(ret); + return(NULL); + } + ret = temp; + } + + ch = *in; + + if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!xmlStrchr(list, ch))) { + unsigned char val; + ret[out++] = '%'; + val = ch >> 4; + if (val <= 9) + ret[out++] = '0' + val; + else + ret[out++] = 'A' + val - 0xA; + val = ch & 0xF; + if (val <= 9) + ret[out++] = '0' + val; + else + ret[out++] = 'A' + val - 0xA; + in++; + } else { + ret[out++] = *in++; + } + + } + ret[out] = 0; + return(ret); +} + +/** + * xmlURIEscape: + * @str: the string of the URI to escape + * + * Escaping routine, does not do validity checks ! + * It will try to escape the chars needing this, but this is heuristic + * based it's impossible to be sure. + * + * Returns an copy of the string, but escaped + * + * 25 May 2001 + * Uses xmlParseURI and xmlURIEscapeStr to try to escape correctly + * according to RFC2396. + * - Carl Douglas + */ +xmlChar * +xmlURIEscape(const xmlChar * str) +{ + xmlChar *ret, *segment = NULL; + xmlURIPtr uri; + int ret2; + + if (str == NULL) + return (NULL); + + uri = xmlCreateURI(); + if (uri != NULL) { + /* + * Allow escaping errors in the unescaped form + */ + uri->cleanup = 1; + ret2 = xmlParseURIReference(uri, (const char *)str); + if (ret2) { + xmlFreeURI(uri); + return (NULL); + } + } + + if (!uri) + return NULL; + + ret = NULL; + +#define NULLCHK(p) if(!p) { \ + xmlURIErrMemory("escaping URI value\n"); \ + xmlFreeURI(uri); \ + xmlFree(ret); \ + return NULL; } \ + + if (uri->scheme) { + segment = xmlURIEscapeStr(BAD_CAST uri->scheme, BAD_CAST "+-."); + NULLCHK(segment) + ret = xmlStrcat(ret, segment); + ret = xmlStrcat(ret, BAD_CAST ":"); + xmlFree(segment); + } + + if (uri->authority) { + segment = + xmlURIEscapeStr(BAD_CAST uri->authority, BAD_CAST "/?;:@"); + NULLCHK(segment) + ret = xmlStrcat(ret, BAD_CAST "//"); + ret = xmlStrcat(ret, segment); + xmlFree(segment); + } + + if (uri->user) { + segment = xmlURIEscapeStr(BAD_CAST uri->user, BAD_CAST ";:&=+$,"); + NULLCHK(segment) + ret = xmlStrcat(ret,BAD_CAST "//"); + ret = xmlStrcat(ret, segment); + ret = xmlStrcat(ret, BAD_CAST "@"); + xmlFree(segment); + } + + if (uri->server) { + segment = xmlURIEscapeStr(BAD_CAST uri->server, BAD_CAST "/?;:@"); + NULLCHK(segment) + if (uri->user == NULL) + ret = xmlStrcat(ret, BAD_CAST "//"); + ret = xmlStrcat(ret, segment); + xmlFree(segment); + } + + if (uri->port) { + xmlChar port[10]; + + snprintf((char *) port, 10, "%d", uri->port); + ret = xmlStrcat(ret, BAD_CAST ":"); + ret = xmlStrcat(ret, port); + } + + if (uri->path) { + segment = + xmlURIEscapeStr(BAD_CAST uri->path, BAD_CAST ":@&=+$,/?;"); + NULLCHK(segment) + ret = xmlStrcat(ret, segment); + xmlFree(segment); + } + + if (uri->query_raw) { + ret = xmlStrcat(ret, BAD_CAST "?"); + ret = xmlStrcat(ret, BAD_CAST uri->query_raw); + } + else if (uri->query) { + segment = + xmlURIEscapeStr(BAD_CAST uri->query, BAD_CAST ";/?:@&=+,$"); + NULLCHK(segment) + ret = xmlStrcat(ret, BAD_CAST "?"); + ret = xmlStrcat(ret, segment); + xmlFree(segment); + } + + if (uri->opaque) { + segment = xmlURIEscapeStr(BAD_CAST uri->opaque, BAD_CAST ""); + NULLCHK(segment) + ret = xmlStrcat(ret, segment); + xmlFree(segment); + } + + if (uri->fragment) { + segment = xmlURIEscapeStr(BAD_CAST uri->fragment, BAD_CAST "#"); + NULLCHK(segment) + ret = xmlStrcat(ret, BAD_CAST "#"); + ret = xmlStrcat(ret, segment); + xmlFree(segment); + } + + xmlFreeURI(uri); +#undef NULLCHK + + return (ret); +} + +/************************************************************************ + * * + * Public functions * + * * + ************************************************************************/ + +/** + * xmlBuildURI: + * @URI: the URI instance found in the document + * @base: the base value + * + * Computes he final URI of the reference done by checking that + * the given URI is valid, and building the final URI using the + * base URI. This is processed according to section 5.2 of the + * RFC 2396 + * + * 5.2. Resolving Relative References to Absolute Form + * + * Returns a new URI string (to be freed by the caller) or NULL in case + * of error. + */ +xmlChar * +xmlBuildURI(const xmlChar *URI, const xmlChar *base) { + xmlChar *val = NULL; + int ret, len, indx, cur, out; + xmlURIPtr ref = NULL; + xmlURIPtr bas = NULL; + xmlURIPtr res = NULL; + + /* + * 1) The URI reference is parsed into the potential four components and + * fragment identifier, as described in Section 4.3. + * + * NOTE that a completely empty URI is treated by modern browsers + * as a reference to "." rather than as a synonym for the current + * URI. Should we do that here? + */ + if (URI == NULL) + ret = -1; + else { + if (*URI) { + ref = xmlCreateURI(); + if (ref == NULL) + goto done; + ret = xmlParseURIReference(ref, (const char *) URI); + } + else + ret = 0; + } + if (ret != 0) + goto done; + if ((ref != NULL) && (ref->scheme != NULL)) { + /* + * The URI is absolute don't modify. + */ + val = xmlStrdup(URI); + goto done; + } + if (base == NULL) + ret = -1; + else { + bas = xmlCreateURI(); + if (bas == NULL) + goto done; + ret = xmlParseURIReference(bas, (const char *) base); + } + if (ret != 0) { + if (ref) + val = xmlSaveUri(ref); + goto done; + } + if (ref == NULL) { + /* + * the base fragment must be ignored + */ + if (bas->fragment != NULL) { + xmlFree(bas->fragment); + bas->fragment = NULL; + } + val = xmlSaveUri(bas); + goto done; + } + + /* + * 2) If the path component is empty and the scheme, authority, and + * query components are undefined, then it is a reference to the + * current document and we are done. Otherwise, the reference URI's + * query and fragment components are defined as found (or not found) + * within the URI reference and not inherited from the base URI. + * + * NOTE that in modern browsers, the parsing differs from the above + * in the following aspect: the query component is allowed to be + * defined while still treating this as a reference to the current + * document. + */ + res = xmlCreateURI(); + if (res == NULL) + goto done; + if ((ref->scheme == NULL) && (ref->path == NULL) && + ((ref->authority == NULL) && (ref->server == NULL))) { + if (bas->scheme != NULL) + res->scheme = xmlMemStrdup(bas->scheme); + if (bas->authority != NULL) + res->authority = xmlMemStrdup(bas->authority); + else if ((bas->server != NULL) || (bas->port == -1)) { + if (bas->server != NULL) + res->server = xmlMemStrdup(bas->server); + if (bas->user != NULL) + res->user = xmlMemStrdup(bas->user); + res->port = bas->port; + } + if (bas->path != NULL) + res->path = xmlMemStrdup(bas->path); + if (ref->query_raw != NULL) + res->query_raw = xmlMemStrdup (ref->query_raw); + else if (ref->query != NULL) + res->query = xmlMemStrdup(ref->query); + else if (bas->query_raw != NULL) + res->query_raw = xmlMemStrdup(bas->query_raw); + else if (bas->query != NULL) + res->query = xmlMemStrdup(bas->query); + if (ref->fragment != NULL) + res->fragment = xmlMemStrdup(ref->fragment); + goto step_7; + } + + /* + * 3) If the scheme component is defined, indicating that the reference + * starts with a scheme name, then the reference is interpreted as an + * absolute URI and we are done. Otherwise, the reference URI's + * scheme is inherited from the base URI's scheme component. + */ + if (ref->scheme != NULL) { + val = xmlSaveUri(ref); + goto done; + } + if (bas->scheme != NULL) + res->scheme = xmlMemStrdup(bas->scheme); + + if (ref->query_raw != NULL) + res->query_raw = xmlMemStrdup(ref->query_raw); + else if (ref->query != NULL) + res->query = xmlMemStrdup(ref->query); + if (ref->fragment != NULL) + res->fragment = xmlMemStrdup(ref->fragment); + + /* + * 4) If the authority component is defined, then the reference is a + * network-path and we skip to step 7. Otherwise, the reference + * URI's authority is inherited from the base URI's authority + * component, which will also be undefined if the URI scheme does not + * use an authority component. + */ + if ((ref->authority != NULL) || (ref->server != NULL)) { + if (ref->authority != NULL) + res->authority = xmlMemStrdup(ref->authority); + else { + res->server = xmlMemStrdup(ref->server); + if (ref->user != NULL) + res->user = xmlMemStrdup(ref->user); + res->port = ref->port; + } + if (ref->path != NULL) + res->path = xmlMemStrdup(ref->path); + goto step_7; + } + if (bas->authority != NULL) + res->authority = xmlMemStrdup(bas->authority); + else if ((bas->server != NULL) || (bas->port == -1)) { + if (bas->server != NULL) + res->server = xmlMemStrdup(bas->server); + if (bas->user != NULL) + res->user = xmlMemStrdup(bas->user); + res->port = bas->port; + } + + /* + * 5) If the path component begins with a slash character ("/"), then + * the reference is an absolute-path and we skip to step 7. + */ + if ((ref->path != NULL) && (ref->path[0] == '/')) { + res->path = xmlMemStrdup(ref->path); + goto step_7; + } + + + /* + * 6) If this step is reached, then we are resolving a relative-path + * reference. The relative path needs to be merged with the base + * URI's path. Although there are many ways to do this, we will + * describe a simple method using a separate string buffer. + * + * Allocate a buffer large enough for the result string. + */ + len = 2; /* extra / and 0 */ + if (ref->path != NULL) + len += strlen(ref->path); + if (bas->path != NULL) + len += strlen(bas->path); + res->path = (char *) xmlMallocAtomic(len); + if (res->path == NULL) { + xmlURIErrMemory("resolving URI against base\n"); + goto done; + } + res->path[0] = 0; + + /* + * a) All but the last segment of the base URI's path component is + * copied to the buffer. In other words, any characters after the + * last (right-most) slash character, if any, are excluded. + */ + cur = 0; + out = 0; + if (bas->path != NULL) { + while (bas->path[cur] != 0) { + while ((bas->path[cur] != 0) && (bas->path[cur] != '/')) + cur++; + if (bas->path[cur] == 0) + break; + + cur++; + while (out < cur) { + res->path[out] = bas->path[out]; + out++; + } + } + } + res->path[out] = 0; + + /* + * b) The reference's path component is appended to the buffer + * string. + */ + if (ref->path != NULL && ref->path[0] != 0) { + indx = 0; + /* + * Ensure the path includes a '/' + */ + if ((out == 0) && (bas->server != NULL)) + res->path[out++] = '/'; + while (ref->path[indx] != 0) { + res->path[out++] = ref->path[indx++]; + } + } + res->path[out] = 0; + + /* + * Steps c) to h) are really path normalization steps + */ + xmlNormalizeURIPath(res->path); + +step_7: + + /* + * 7) The resulting URI components, including any inherited from the + * base URI, are recombined to give the absolute form of the URI + * reference. + */ + val = xmlSaveUri(res); + +done: + if (ref != NULL) + xmlFreeURI(ref); + if (bas != NULL) + xmlFreeURI(bas); + if (res != NULL) + xmlFreeURI(res); + return(val); +} + +/** + * xmlBuildRelativeURI: + * @URI: the URI reference under consideration + * @base: the base value + * + * Expresses the URI of the reference in terms relative to the + * base. Some examples of this operation include: + * base = "http://site1.com/docs/book1.html" + * URI input URI returned + * docs/pic1.gif pic1.gif + * docs/img/pic1.gif img/pic1.gif + * img/pic1.gif ../img/pic1.gif + * http://site1.com/docs/pic1.gif pic1.gif + * http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif + * + * base = "docs/book1.html" + * URI input URI returned + * docs/pic1.gif pic1.gif + * docs/img/pic1.gif img/pic1.gif + * img/pic1.gif ../img/pic1.gif + * http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif + * + * + * Note: if the URI reference is really weird or complicated, it may be + * worthwhile to first convert it into a "nice" one by calling + * xmlBuildURI (using 'base') before calling this routine, + * since this routine (for reasonable efficiency) assumes URI has + * already been through some validation. + * + * Returns a new URI string (to be freed by the caller) or NULL in case + * error. + */ +xmlChar * +xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base) +{ + xmlChar *val = NULL; + int ret; + int ix; + int nbslash = 0; + int len; + xmlURIPtr ref = NULL; + xmlURIPtr bas = NULL; + xmlChar *bptr, *uptr, *vptr; + int remove_path = 0; + + if ((URI == NULL) || (*URI == 0)) + return NULL; + + /* + * First parse URI into a standard form + */ + ref = xmlCreateURI (); + if (ref == NULL) + return NULL; + /* If URI not already in "relative" form */ + if (URI[0] != '.') { + ret = xmlParseURIReference (ref, (const char *) URI); + if (ret != 0) + goto done; /* Error in URI, return NULL */ + } else + ref->path = (char *)xmlStrdup(URI); + + /* + * Next parse base into the same standard form + */ + if ((base == NULL) || (*base == 0)) { + val = xmlStrdup (URI); + goto done; + } + bas = xmlCreateURI (); + if (bas == NULL) + goto done; + if (base[0] != '.') { + ret = xmlParseURIReference (bas, (const char *) base); + if (ret != 0) + goto done; /* Error in base, return NULL */ + } else + bas->path = (char *)xmlStrdup(base); + + /* + * If the scheme / server on the URI differs from the base, + * just return the URI + */ + if ((ref->scheme != NULL) && + ((bas->scheme == NULL) || + (xmlStrcmp ((xmlChar *)bas->scheme, (xmlChar *)ref->scheme)) || + (xmlStrcmp ((xmlChar *)bas->server, (xmlChar *)ref->server)))) { + val = xmlStrdup (URI); + goto done; + } + if (xmlStrEqual((xmlChar *)bas->path, (xmlChar *)ref->path)) { + val = xmlStrdup(BAD_CAST ""); + goto done; + } + if (bas->path == NULL) { + val = xmlStrdup((xmlChar *)ref->path); + goto done; + } + if (ref->path == NULL) { + ref->path = (char *) "/"; + remove_path = 1; + } + + /* + * At this point (at last!) we can compare the two paths + * + * First we take care of the special case where either of the + * two path components may be missing (bug 316224) + */ + bptr = (xmlChar *)bas->path; + { + xmlChar *rptr = (xmlChar *) ref->path; + int pos = 0; + + /* + * Next we compare the two strings and find where they first differ + */ + if ((*rptr == '.') && (rptr[1] == '/')) + rptr += 2; + if ((*bptr == '.') && (bptr[1] == '/')) + bptr += 2; + else if ((*bptr == '/') && (*rptr != '/')) + bptr++; + while ((bptr[pos] == rptr[pos]) && (bptr[pos] != 0)) + pos++; + + if (bptr[pos] == rptr[pos]) { + val = xmlStrdup(BAD_CAST ""); + goto done; /* (I can't imagine why anyone would do this) */ + } + + /* + * In URI, "back up" to the last '/' encountered. This will be the + * beginning of the "unique" suffix of URI + */ + ix = pos; + for (; ix > 0; ix--) { + if (rptr[ix - 1] == '/') + break; + } + uptr = (xmlChar *)&rptr[ix]; + + /* + * In base, count the number of '/' from the differing point + */ + for (; bptr[ix] != 0; ix++) { + if (bptr[ix] == '/') + nbslash++; + } + + /* + * e.g: URI="foo/" base="foo/bar" -> "./" + */ + if (nbslash == 0 && !uptr[0]) { + val = xmlStrdup(BAD_CAST "./"); + goto done; + } + + len = xmlStrlen (uptr) + 1; + } + + if (nbslash == 0) { + if (uptr != NULL) + /* exception characters from xmlSaveUri */ + val = xmlURIEscapeStr(uptr, BAD_CAST "/;&=+$,"); + goto done; + } + + /* + * Allocate just enough space for the returned string - + * length of the remainder of the URI, plus enough space + * for the "../" groups, plus one for the terminator + */ + val = (xmlChar *) xmlMalloc (len + 3 * nbslash); + if (val == NULL) { + xmlURIErrMemory("building relative URI\n"); + goto done; + } + vptr = val; + /* + * Put in as many "../" as needed + */ + for (; nbslash>0; nbslash--) { + *vptr++ = '.'; + *vptr++ = '.'; + *vptr++ = '/'; + } + /* + * Finish up with the end of the URI + */ + if (uptr != NULL) { + if ((vptr > val) && (len > 0) && + (uptr[0] == '/') && (vptr[-1] == '/')) { + memcpy (vptr, uptr + 1, len - 1); + vptr[len - 2] = 0; + } else { + memcpy (vptr, uptr, len); + vptr[len - 1] = 0; + } + } else { + vptr[len - 1] = 0; + } + + /* escape the freshly-built path */ + vptr = val; + /* exception characters from xmlSaveUri */ + val = xmlURIEscapeStr(vptr, BAD_CAST "/;&=+$,"); + xmlFree(vptr); + +done: + /* + * Free the working variables + */ + if (remove_path != 0) + ref->path = NULL; + if (ref != NULL) + xmlFreeURI (ref); + if (bas != NULL) + xmlFreeURI (bas); + + return val; +} + +/** + * xmlCanonicPath: + * @path: the resource locator in a filesystem notation + * + * Constructs a canonic path from the specified path. + * + * Returns a new canonic path, or a duplicate of the path parameter if the + * construction fails. The caller is responsible for freeing the memory occupied + * by the returned string. If there is insufficient memory available, or the + * argument is NULL, the function returns NULL. + */ +#define IS_WINDOWS_PATH(p) \ + ((p != NULL) && \ + (((p[0] >= 'a') && (p[0] <= 'z')) || \ + ((p[0] >= 'A') && (p[0] <= 'Z'))) && \ + (p[1] == ':') && ((p[2] == '/') || (p[2] == '\\'))) +xmlChar * +xmlCanonicPath(const xmlChar *path) +{ +/* + * For Windows implementations, additional work needs to be done to + * replace backslashes in pathnames with "forward slashes" + */ +#if defined(_WIN32) && !defined(__CYGWIN__) + int len = 0; + char *p = NULL; +#endif + xmlURIPtr uri; + xmlChar *ret; + const xmlChar *absuri; + + if (path == NULL) + return(NULL); + +#if defined(_WIN32) + /* + * We must not change the backslashes to slashes if the the path + * starts with \\?\ + * Those paths can be up to 32k characters long. + * Was added specifically for OpenOffice, those paths can't be converted + * to URIs anyway. + */ + if ((path[0] == '\\') && (path[1] == '\\') && (path[2] == '?') && + (path[3] == '\\') ) + return xmlStrdup((const xmlChar *) path); +#endif + + /* sanitize filename starting with // so it can be used as URI */ + if ((path[0] == '/') && (path[1] == '/') && (path[2] != '/')) + path++; + + if ((uri = xmlParseURI((const char *) path)) != NULL) { + xmlFreeURI(uri); + return xmlStrdup(path); + } + + /* Check if this is an "absolute uri" */ + absuri = xmlStrstr(path, BAD_CAST "://"); + if (absuri != NULL) { + int l, j; + unsigned char c; + xmlChar *escURI; + + /* + * this looks like an URI where some parts have not been + * escaped leading to a parsing problem. Check that the first + * part matches a protocol. + */ + l = absuri - path; + /* Bypass if first part (part before the '://') is > 20 chars */ + if ((l <= 0) || (l > 20)) + goto path_processing; + /* Bypass if any non-alpha characters are present in first part */ + for (j = 0;j < l;j++) { + c = path[j]; + if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))) + goto path_processing; + } + + /* Escape all except the characters specified in the supplied path */ + escURI = xmlURIEscapeStr(path, BAD_CAST ":/?_.#&;="); + if (escURI != NULL) { + /* Try parsing the escaped path */ + uri = xmlParseURI((const char *) escURI); + /* If successful, return the escaped string */ + if (uri != NULL) { + xmlFreeURI(uri); + return escURI; + } + xmlFree(escURI); + } + } + +path_processing: +/* For Windows implementations, replace backslashes with 'forward slashes' */ +#if defined(_WIN32) && !defined(__CYGWIN__) + /* + * Create a URI structure + */ + uri = xmlCreateURI(); + if (uri == NULL) { /* Guard against 'out of memory' */ + return(NULL); + } + + len = xmlStrlen(path); + if ((len > 2) && IS_WINDOWS_PATH(path)) { + /* make the scheme 'file' */ + uri->scheme = (char *) xmlStrdup(BAD_CAST "file"); + /* allocate space for leading '/' + path + string terminator */ + uri->path = xmlMallocAtomic(len + 2); + if (uri->path == NULL) { + xmlFreeURI(uri); /* Guard against 'out of memory' */ + return(NULL); + } + /* Put in leading '/' plus path */ + uri->path[0] = '/'; + p = uri->path + 1; + strncpy(p, (char *) path, len + 1); + } else { + uri->path = (char *) xmlStrdup(path); + if (uri->path == NULL) { + xmlFreeURI(uri); + return(NULL); + } + p = uri->path; + } + /* Now change all occurrences of '\' to '/' */ + while (*p != '\0') { + if (*p == '\\') + *p = '/'; + p++; + } + + if (uri->scheme == NULL) { + ret = xmlStrdup((const xmlChar *) uri->path); + } else { + ret = xmlSaveUri(uri); + } + + xmlFreeURI(uri); +#else + ret = xmlStrdup((const xmlChar *) path); +#endif + return(ret); +} + +/** + * xmlPathToURI: + * @path: the resource locator in a filesystem notation + * + * Constructs an URI expressing the existing path + * + * Returns a new URI, or a duplicate of the path parameter if the + * construction fails. The caller is responsible for freeing the memory + * occupied by the returned string. If there is insufficient memory available, + * or the argument is NULL, the function returns NULL. + */ +xmlChar * +xmlPathToURI(const xmlChar *path) +{ + xmlURIPtr uri; + xmlURI temp; + xmlChar *ret, *cal; + + if (path == NULL) + return(NULL); + + if ((uri = xmlParseURI((const char *) path)) != NULL) { + xmlFreeURI(uri); + return xmlStrdup(path); + } + cal = xmlCanonicPath(path); + if (cal == NULL) + return(NULL); +#if defined(_WIN32) && !defined(__CYGWIN__) + /* xmlCanonicPath can return an URI on Windows (is that the intended behaviour?) + If 'cal' is a valid URI already then we are done here, as continuing would make + it invalid. */ + if ((uri = xmlParseURI((const char *) cal)) != NULL) { + xmlFreeURI(uri); + return cal; + } + /* 'cal' can contain a relative path with backslashes. If that is processed + by xmlSaveURI, they will be escaped and the external entity loader machinery + will fail. So convert them to slashes. Misuse 'ret' for walking. */ + ret = cal; + while (*ret != '\0') { + if (*ret == '\\') + *ret = '/'; + ret++; + } +#endif + memset(&temp, 0, sizeof(temp)); + temp.path = (char *) cal; + ret = xmlSaveUri(&temp); + xmlFree(cal); + return(ret); +} +#define bottom_uri +#include "elfgcchack.h" diff --git a/src/valid.c b/src/valid.c new file mode 100644 index 000000000000..5ee391c04183 --- /dev/null +++ b/src/valid.c @@ -0,0 +1,7138 @@ +/* + * valid.c : part of the code use to do the DTD handling and the validity + * checking + * + * See Copyright for the status of this software. + * + * daniel@veillard.com + */ + +#define IN_LIBXML +#include "libxml.h" + +#include + +#ifdef HAVE_STDLIB_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, + int create); +/* #define DEBUG_VALID_ALGO */ +/* #define DEBUG_REGEXP_ALGO */ + +#define TODO \ + xmlGenericError(xmlGenericErrorContext, \ + "Unimplemented block at %s:%d\n", \ + __FILE__, __LINE__); + +#ifdef LIBXML_VALID_ENABLED +static int +xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type, + const xmlChar *value); +#endif +/************************************************************************ + * * + * Error handling routines * + * * + ************************************************************************/ + +/** + * xmlVErrMemory: + * @ctxt: an XML validation parser context + * @extra: extra information + * + * Handle an out of memory error + */ +static void +xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra) +{ + xmlGenericErrorFunc channel = NULL; + xmlParserCtxtPtr pctxt = NULL; + void *data = NULL; + + if (ctxt != NULL) { + channel = ctxt->error; + data = ctxt->userData; + /* Use the special values to detect if it is part of a parsing + context */ + if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) || + (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) { + long delta = (char *) ctxt - (char *) ctxt->userData; + if ((delta > 0) && (delta < 250)) + pctxt = ctxt->userData; + } + } + if (extra) + __xmlRaiseError(NULL, channel, data, + pctxt, NULL, XML_FROM_VALID, XML_ERR_NO_MEMORY, + XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, + "Memory allocation failed : %s\n", extra); + else + __xmlRaiseError(NULL, channel, data, + pctxt, NULL, XML_FROM_VALID, XML_ERR_NO_MEMORY, + XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, + "Memory allocation failed\n"); +} + +/** + * xmlErrValid: + * @ctxt: an XML validation parser context + * @error: the error number + * @extra: extra information + * + * Handle a validation error + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const char *extra) +{ + xmlGenericErrorFunc channel = NULL; + xmlParserCtxtPtr pctxt = NULL; + void *data = NULL; + + if (ctxt != NULL) { + channel = ctxt->error; + data = ctxt->userData; + /* Use the special values to detect if it is part of a parsing + context */ + if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) || + (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) { + long delta = (char *) ctxt - (char *) ctxt->userData; + if ((delta > 0) && (delta < 250)) + pctxt = ctxt->userData; + } + } + if (extra) + __xmlRaiseError(NULL, channel, data, + pctxt, NULL, XML_FROM_VALID, error, + XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0, + msg, extra); + else + __xmlRaiseError(NULL, channel, data, + pctxt, NULL, XML_FROM_VALID, error, + XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0, + "%s", msg); +} + +#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlErrValidNode: + * @ctxt: an XML validation parser context + * @node: the node raising the error + * @error: the error number + * @str1: extra information + * @str2: extra information + * @str3: extra information + * + * Handle a validation error, provide contextual information + */ +static void LIBXML_ATTR_FORMAT(4,0) +xmlErrValidNode(xmlValidCtxtPtr ctxt, + xmlNodePtr node, xmlParserErrors error, + const char *msg, const xmlChar * str1, + const xmlChar * str2, const xmlChar * str3) +{ + xmlStructuredErrorFunc schannel = NULL; + xmlGenericErrorFunc channel = NULL; + xmlParserCtxtPtr pctxt = NULL; + void *data = NULL; + + if (ctxt != NULL) { + channel = ctxt->error; + data = ctxt->userData; + /* Use the special values to detect if it is part of a parsing + context */ + if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) || + (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) { + long delta = (char *) ctxt - (char *) ctxt->userData; + if ((delta > 0) && (delta < 250)) + pctxt = ctxt->userData; + } + } + __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error, + XML_ERR_ERROR, NULL, 0, + (const char *) str1, + (const char *) str2, + (const char *) str3, 0, 0, msg, str1, str2, str3); +} +#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */ + +#ifdef LIBXML_VALID_ENABLED +/** + * xmlErrValidNodeNr: + * @ctxt: an XML validation parser context + * @node: the node raising the error + * @error: the error number + * @str1: extra information + * @int2: extra information + * @str3: extra information + * + * Handle a validation error, provide contextual information + */ +static void LIBXML_ATTR_FORMAT(4,0) +xmlErrValidNodeNr(xmlValidCtxtPtr ctxt, + xmlNodePtr node, xmlParserErrors error, + const char *msg, const xmlChar * str1, + int int2, const xmlChar * str3) +{ + xmlStructuredErrorFunc schannel = NULL; + xmlGenericErrorFunc channel = NULL; + xmlParserCtxtPtr pctxt = NULL; + void *data = NULL; + + if (ctxt != NULL) { + channel = ctxt->error; + data = ctxt->userData; + /* Use the special values to detect if it is part of a parsing + context */ + if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) || + (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) { + long delta = (char *) ctxt - (char *) ctxt->userData; + if ((delta > 0) && (delta < 250)) + pctxt = ctxt->userData; + } + } + __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error, + XML_ERR_ERROR, NULL, 0, + (const char *) str1, + (const char *) str3, + NULL, int2, 0, msg, str1, int2, str3); +} + +/** + * xmlErrValidWarning: + * @ctxt: an XML validation parser context + * @node: the node raising the error + * @error: the error number + * @str1: extra information + * @str2: extra information + * @str3: extra information + * + * Handle a validation error, provide contextual information + */ +static void LIBXML_ATTR_FORMAT(4,0) +xmlErrValidWarning(xmlValidCtxtPtr ctxt, + xmlNodePtr node, xmlParserErrors error, + const char *msg, const xmlChar * str1, + const xmlChar * str2, const xmlChar * str3) +{ + xmlStructuredErrorFunc schannel = NULL; + xmlGenericErrorFunc channel = NULL; + xmlParserCtxtPtr pctxt = NULL; + void *data = NULL; + + if (ctxt != NULL) { + channel = ctxt->warning; + data = ctxt->userData; + /* Use the special values to detect if it is part of a parsing + context */ + if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) || + (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) { + long delta = (char *) ctxt - (char *) ctxt->userData; + if ((delta > 0) && (delta < 250)) + pctxt = ctxt->userData; + } + } + __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error, + XML_ERR_WARNING, NULL, 0, + (const char *) str1, + (const char *) str2, + (const char *) str3, 0, 0, msg, str1, str2, str3); +} + + + +#ifdef LIBXML_REGEXP_ENABLED +/* + * If regexp are enabled we can do continuous validation without the + * need of a tree to validate the content model. this is done in each + * callbacks. + * Each xmlValidState represent the validation state associated to the + * set of nodes currently open from the document root to the current element. + */ + + +typedef struct _xmlValidState { + xmlElementPtr elemDecl; /* pointer to the content model */ + xmlNodePtr node; /* pointer to the current node */ + xmlRegExecCtxtPtr exec; /* regexp runtime */ +} _xmlValidState; + + +static int +vstateVPush(xmlValidCtxtPtr ctxt, xmlElementPtr elemDecl, xmlNodePtr node) { + if ((ctxt->vstateMax == 0) || (ctxt->vstateTab == NULL)) { + ctxt->vstateMax = 10; + ctxt->vstateTab = (xmlValidState *) xmlMalloc(ctxt->vstateMax * + sizeof(ctxt->vstateTab[0])); + if (ctxt->vstateTab == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(-1); + } + } + + if (ctxt->vstateNr >= ctxt->vstateMax) { + xmlValidState *tmp; + + tmp = (xmlValidState *) xmlRealloc(ctxt->vstateTab, + 2 * ctxt->vstateMax * sizeof(ctxt->vstateTab[0])); + if (tmp == NULL) { + xmlVErrMemory(ctxt, "realloc failed"); + return(-1); + } + ctxt->vstateMax *= 2; + ctxt->vstateTab = tmp; + } + ctxt->vstate = &ctxt->vstateTab[ctxt->vstateNr]; + ctxt->vstateTab[ctxt->vstateNr].elemDecl = elemDecl; + ctxt->vstateTab[ctxt->vstateNr].node = node; + if ((elemDecl != NULL) && (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT)) { + if (elemDecl->contModel == NULL) + xmlValidBuildContentModel(ctxt, elemDecl); + if (elemDecl->contModel != NULL) { + ctxt->vstateTab[ctxt->vstateNr].exec = + xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL); + } else { + ctxt->vstateTab[ctxt->vstateNr].exec = NULL; + xmlErrValidNode(ctxt, (xmlNodePtr) elemDecl, + XML_ERR_INTERNAL_ERROR, + "Failed to build content model regexp for %s\n", + node->name, NULL, NULL); + } + } + return(ctxt->vstateNr++); +} + +static int +vstateVPop(xmlValidCtxtPtr ctxt) { + xmlElementPtr elemDecl; + + if (ctxt->vstateNr < 1) return(-1); + ctxt->vstateNr--; + elemDecl = ctxt->vstateTab[ctxt->vstateNr].elemDecl; + ctxt->vstateTab[ctxt->vstateNr].elemDecl = NULL; + ctxt->vstateTab[ctxt->vstateNr].node = NULL; + if ((elemDecl != NULL) && (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT)) { + xmlRegFreeExecCtxt(ctxt->vstateTab[ctxt->vstateNr].exec); + } + ctxt->vstateTab[ctxt->vstateNr].exec = NULL; + if (ctxt->vstateNr >= 1) + ctxt->vstate = &ctxt->vstateTab[ctxt->vstateNr - 1]; + else + ctxt->vstate = NULL; + return(ctxt->vstateNr); +} + +#else /* not LIBXML_REGEXP_ENABLED */ +/* + * If regexp are not enabled, it uses a home made algorithm less + * complex and easier to + * debug/maintain than a generic NFA -> DFA state based algo. The + * only restriction is on the deepness of the tree limited by the + * size of the occurs bitfield + * + * this is the content of a saved state for rollbacks + */ + +#define ROLLBACK_OR 0 +#define ROLLBACK_PARENT 1 + +typedef struct _xmlValidState { + xmlElementContentPtr cont; /* pointer to the content model subtree */ + xmlNodePtr node; /* pointer to the current node in the list */ + long occurs;/* bitfield for multiple occurrences */ + unsigned char depth; /* current depth in the overall tree */ + unsigned char state; /* ROLLBACK_XXX */ +} _xmlValidState; + +#define MAX_RECURSE 25000 +#define MAX_DEPTH ((sizeof(_xmlValidState.occurs)) * 8) +#define CONT ctxt->vstate->cont +#define NODE ctxt->vstate->node +#define DEPTH ctxt->vstate->depth +#define OCCURS ctxt->vstate->occurs +#define STATE ctxt->vstate->state + +#define OCCURRENCE (ctxt->vstate->occurs & (1 << DEPTH)) +#define PARENT_OCCURRENCE (ctxt->vstate->occurs & ((1 << DEPTH) - 1)) + +#define SET_OCCURRENCE ctxt->vstate->occurs |= (1 << DEPTH) +#define RESET_OCCURRENCE ctxt->vstate->occurs &= ((1 << DEPTH) - 1) + +static int +vstateVPush(xmlValidCtxtPtr ctxt, xmlElementContentPtr cont, + xmlNodePtr node, unsigned char depth, long occurs, + unsigned char state) { + int i = ctxt->vstateNr - 1; + + if (ctxt->vstateNr > MAX_RECURSE) { + return(-1); + } + if (ctxt->vstateTab == NULL) { + ctxt->vstateMax = 8; + ctxt->vstateTab = (xmlValidState *) xmlMalloc( + ctxt->vstateMax * sizeof(ctxt->vstateTab[0])); + if (ctxt->vstateTab == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(-1); + } + } + if (ctxt->vstateNr >= ctxt->vstateMax) { + xmlValidState *tmp; + + tmp = (xmlValidState *) xmlRealloc(ctxt->vstateTab, + 2 * ctxt->vstateMax * sizeof(ctxt->vstateTab[0])); + if (tmp == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(-1); + } + ctxt->vstateMax *= 2; + ctxt->vstateTab = tmp; + ctxt->vstate = &ctxt->vstateTab[0]; + } + /* + * Don't push on the stack a state already here + */ + if ((i >= 0) && (ctxt->vstateTab[i].cont == cont) && + (ctxt->vstateTab[i].node == node) && + (ctxt->vstateTab[i].depth == depth) && + (ctxt->vstateTab[i].occurs == occurs) && + (ctxt->vstateTab[i].state == state)) + return(ctxt->vstateNr); + ctxt->vstateTab[ctxt->vstateNr].cont = cont; + ctxt->vstateTab[ctxt->vstateNr].node = node; + ctxt->vstateTab[ctxt->vstateNr].depth = depth; + ctxt->vstateTab[ctxt->vstateNr].occurs = occurs; + ctxt->vstateTab[ctxt->vstateNr].state = state; + return(ctxt->vstateNr++); +} + +static int +vstateVPop(xmlValidCtxtPtr ctxt) { + if (ctxt->vstateNr <= 1) return(-1); + ctxt->vstateNr--; + ctxt->vstate = &ctxt->vstateTab[0]; + ctxt->vstate->cont = ctxt->vstateTab[ctxt->vstateNr].cont; + ctxt->vstate->node = ctxt->vstateTab[ctxt->vstateNr].node; + ctxt->vstate->depth = ctxt->vstateTab[ctxt->vstateNr].depth; + ctxt->vstate->occurs = ctxt->vstateTab[ctxt->vstateNr].occurs; + ctxt->vstate->state = ctxt->vstateTab[ctxt->vstateNr].state; + return(ctxt->vstateNr); +} + +#endif /* LIBXML_REGEXP_ENABLED */ + +static int +nodeVPush(xmlValidCtxtPtr ctxt, xmlNodePtr value) +{ + if (ctxt->nodeMax <= 0) { + ctxt->nodeMax = 4; + ctxt->nodeTab = + (xmlNodePtr *) xmlMalloc(ctxt->nodeMax * + sizeof(ctxt->nodeTab[0])); + if (ctxt->nodeTab == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + ctxt->nodeMax = 0; + return (0); + } + } + if (ctxt->nodeNr >= ctxt->nodeMax) { + xmlNodePtr *tmp; + tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab, + ctxt->nodeMax * 2 * sizeof(ctxt->nodeTab[0])); + if (tmp == NULL) { + xmlVErrMemory(ctxt, "realloc failed"); + return (0); + } + ctxt->nodeMax *= 2; + ctxt->nodeTab = tmp; + } + ctxt->nodeTab[ctxt->nodeNr] = value; + ctxt->node = value; + return (ctxt->nodeNr++); +} +static xmlNodePtr +nodeVPop(xmlValidCtxtPtr ctxt) +{ + xmlNodePtr ret; + + if (ctxt->nodeNr <= 0) + return (NULL); + ctxt->nodeNr--; + if (ctxt->nodeNr > 0) + ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1]; + else + ctxt->node = NULL; + ret = ctxt->nodeTab[ctxt->nodeNr]; + ctxt->nodeTab[ctxt->nodeNr] = NULL; + return (ret); +} + +#ifdef DEBUG_VALID_ALGO +static void +xmlValidPrintNode(xmlNodePtr cur) { + if (cur == NULL) { + xmlGenericError(xmlGenericErrorContext, "null"); + return; + } + switch (cur->type) { + case XML_ELEMENT_NODE: + xmlGenericError(xmlGenericErrorContext, "%s ", cur->name); + break; + case XML_TEXT_NODE: + xmlGenericError(xmlGenericErrorContext, "text "); + break; + case XML_CDATA_SECTION_NODE: + xmlGenericError(xmlGenericErrorContext, "cdata "); + break; + case XML_ENTITY_REF_NODE: + xmlGenericError(xmlGenericErrorContext, "&%s; ", cur->name); + break; + case XML_PI_NODE: + xmlGenericError(xmlGenericErrorContext, "pi(%s) ", cur->name); + break; + case XML_COMMENT_NODE: + xmlGenericError(xmlGenericErrorContext, "comment "); + break; + case XML_ATTRIBUTE_NODE: + xmlGenericError(xmlGenericErrorContext, "?attr? "); + break; + case XML_ENTITY_NODE: + xmlGenericError(xmlGenericErrorContext, "?ent? "); + break; + case XML_DOCUMENT_NODE: + xmlGenericError(xmlGenericErrorContext, "?doc? "); + break; + case XML_DOCUMENT_TYPE_NODE: + xmlGenericError(xmlGenericErrorContext, "?doctype? "); + break; + case XML_DOCUMENT_FRAG_NODE: + xmlGenericError(xmlGenericErrorContext, "?frag? "); + break; + case XML_NOTATION_NODE: + xmlGenericError(xmlGenericErrorContext, "?nota? "); + break; + case XML_HTML_DOCUMENT_NODE: + xmlGenericError(xmlGenericErrorContext, "?html? "); + break; +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: + xmlGenericError(xmlGenericErrorContext, "?docb? "); + break; +#endif + case XML_DTD_NODE: + xmlGenericError(xmlGenericErrorContext, "?dtd? "); + break; + case XML_ELEMENT_DECL: + xmlGenericError(xmlGenericErrorContext, "?edecl? "); + break; + case XML_ATTRIBUTE_DECL: + xmlGenericError(xmlGenericErrorContext, "?adecl? "); + break; + case XML_ENTITY_DECL: + xmlGenericError(xmlGenericErrorContext, "?entdecl? "); + break; + case XML_NAMESPACE_DECL: + xmlGenericError(xmlGenericErrorContext, "?nsdecl? "); + break; + case XML_XINCLUDE_START: + xmlGenericError(xmlGenericErrorContext, "incstart "); + break; + case XML_XINCLUDE_END: + xmlGenericError(xmlGenericErrorContext, "incend "); + break; + } +} + +static void +xmlValidPrintNodeList(xmlNodePtr cur) { + if (cur == NULL) + xmlGenericError(xmlGenericErrorContext, "null "); + while (cur != NULL) { + xmlValidPrintNode(cur); + cur = cur->next; + } +} + +static void +xmlValidDebug(xmlNodePtr cur, xmlElementContentPtr cont) { + char expr[5000]; + + expr[0] = 0; + xmlGenericError(xmlGenericErrorContext, "valid: "); + xmlValidPrintNodeList(cur); + xmlGenericError(xmlGenericErrorContext, "against "); + xmlSnprintfElementContent(expr, 5000, cont, 1); + xmlGenericError(xmlGenericErrorContext, "%s\n", expr); +} + +static void +xmlValidDebugState(xmlValidStatePtr state) { + xmlGenericError(xmlGenericErrorContext, "("); + if (state->cont == NULL) + xmlGenericError(xmlGenericErrorContext, "null,"); + else + switch (state->cont->type) { + case XML_ELEMENT_CONTENT_PCDATA: + xmlGenericError(xmlGenericErrorContext, "pcdata,"); + break; + case XML_ELEMENT_CONTENT_ELEMENT: + xmlGenericError(xmlGenericErrorContext, "%s,", + state->cont->name); + break; + case XML_ELEMENT_CONTENT_SEQ: + xmlGenericError(xmlGenericErrorContext, "seq,"); + break; + case XML_ELEMENT_CONTENT_OR: + xmlGenericError(xmlGenericErrorContext, "or,"); + break; + } + xmlValidPrintNode(state->node); + xmlGenericError(xmlGenericErrorContext, ",%d,%X,%d)", + state->depth, state->occurs, state->state); +} + +static void +xmlValidStateDebug(xmlValidCtxtPtr ctxt) { + int i, j; + + xmlGenericError(xmlGenericErrorContext, "state: "); + xmlValidDebugState(ctxt->vstate); + xmlGenericError(xmlGenericErrorContext, " stack: %d ", + ctxt->vstateNr - 1); + for (i = 0, j = ctxt->vstateNr - 1;(i < 3) && (j > 0);i++,j--) + xmlValidDebugState(&ctxt->vstateTab[j]); + xmlGenericError(xmlGenericErrorContext, "\n"); +} + +/***** +#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c); + *****/ + +#define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt); +#define DEBUG_VALID_MSG(m) \ + xmlGenericError(xmlGenericErrorContext, "%s\n", m); + +#else +#define DEBUG_VALID_STATE(n,c) +#define DEBUG_VALID_MSG(m) +#endif + +/* TODO: use hash table for accesses to elem and attribute definitions */ + + +#define CHECK_DTD \ + if (doc == NULL) return(0); \ + else if ((doc->intSubset == NULL) && \ + (doc->extSubset == NULL)) return(0) + +#ifdef LIBXML_REGEXP_ENABLED + +/************************************************************************ + * * + * Content model validation based on the regexps * + * * + ************************************************************************/ + +/** + * xmlValidBuildAContentModel: + * @content: the content model + * @ctxt: the schema parser context + * @name: the element name whose content is being built + * + * Generate the automata sequence needed for that type + * + * Returns 1 if successful or 0 in case of error. + */ +static int +xmlValidBuildAContentModel(xmlElementContentPtr content, + xmlValidCtxtPtr ctxt, + const xmlChar *name) { + if (content == NULL) { + xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR, + "Found NULL content in content model of %s\n", + name, NULL, NULL); + return(0); + } + switch (content->type) { + case XML_ELEMENT_CONTENT_PCDATA: + xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR, + "Found PCDATA in content model of %s\n", + name, NULL, NULL); + return(0); + break; + case XML_ELEMENT_CONTENT_ELEMENT: { + xmlAutomataStatePtr oldstate = ctxt->state; + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(content->name, content->prefix, fn, 50); + if (fullname == NULL) { + xmlVErrMemory(ctxt, "Building content model"); + return(0); + } + + switch (content->ocur) { + case XML_ELEMENT_CONTENT_ONCE: + ctxt->state = xmlAutomataNewTransition(ctxt->am, + ctxt->state, NULL, fullname, NULL); + break; + case XML_ELEMENT_CONTENT_OPT: + ctxt->state = xmlAutomataNewTransition(ctxt->am, + ctxt->state, NULL, fullname, NULL); + xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); + break; + case XML_ELEMENT_CONTENT_PLUS: + ctxt->state = xmlAutomataNewTransition(ctxt->am, + ctxt->state, NULL, fullname, NULL); + xmlAutomataNewTransition(ctxt->am, ctxt->state, + ctxt->state, fullname, NULL); + break; + case XML_ELEMENT_CONTENT_MULT: + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, + ctxt->state, NULL); + xmlAutomataNewTransition(ctxt->am, + ctxt->state, ctxt->state, fullname, NULL); + break; + } + if ((fullname != fn) && (fullname != content->name)) + xmlFree(fullname); + break; + } + case XML_ELEMENT_CONTENT_SEQ: { + xmlAutomataStatePtr oldstate, oldend; + xmlElementContentOccur ocur; + + /* + * Simply iterate over the content + */ + oldstate = ctxt->state; + ocur = content->ocur; + if (ocur != XML_ELEMENT_CONTENT_ONCE) { + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldstate, NULL); + oldstate = ctxt->state; + } + do { + xmlValidBuildAContentModel(content->c1, ctxt, name); + content = content->c2; + } while ((content->type == XML_ELEMENT_CONTENT_SEQ) && + (content->ocur == XML_ELEMENT_CONTENT_ONCE)); + xmlValidBuildAContentModel(content, ctxt, name); + oldend = ctxt->state; + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldend, NULL); + switch (ocur) { + case XML_ELEMENT_CONTENT_ONCE: + break; + case XML_ELEMENT_CONTENT_OPT: + xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); + break; + case XML_ELEMENT_CONTENT_MULT: + xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); + xmlAutomataNewEpsilon(ctxt->am, oldend, oldstate); + break; + case XML_ELEMENT_CONTENT_PLUS: + xmlAutomataNewEpsilon(ctxt->am, oldend, oldstate); + break; + } + break; + } + case XML_ELEMENT_CONTENT_OR: { + xmlAutomataStatePtr oldstate, oldend; + xmlElementContentOccur ocur; + + ocur = content->ocur; + if ((ocur == XML_ELEMENT_CONTENT_PLUS) || + (ocur == XML_ELEMENT_CONTENT_MULT)) { + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, + ctxt->state, NULL); + } + oldstate = ctxt->state; + oldend = xmlAutomataNewState(ctxt->am); + + /* + * iterate over the subtypes and remerge the end with an + * epsilon transition + */ + do { + ctxt->state = oldstate; + xmlValidBuildAContentModel(content->c1, ctxt, name); + xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldend); + content = content->c2; + } while ((content->type == XML_ELEMENT_CONTENT_OR) && + (content->ocur == XML_ELEMENT_CONTENT_ONCE)); + ctxt->state = oldstate; + xmlValidBuildAContentModel(content, ctxt, name); + xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldend); + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldend, NULL); + switch (ocur) { + case XML_ELEMENT_CONTENT_ONCE: + break; + case XML_ELEMENT_CONTENT_OPT: + xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); + break; + case XML_ELEMENT_CONTENT_MULT: + xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); + xmlAutomataNewEpsilon(ctxt->am, oldend, oldstate); + break; + case XML_ELEMENT_CONTENT_PLUS: + xmlAutomataNewEpsilon(ctxt->am, oldend, oldstate); + break; + } + break; + } + default: + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "ContentModel broken for element %s\n", + (const char *) name); + return(0); + } + return(1); +} +/** + * xmlValidBuildContentModel: + * @ctxt: a validation context + * @elem: an element declaration node + * + * (Re)Build the automata associated to the content model of this + * element + * + * Returns 1 in case of success, 0 in case of error + */ +int +xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) { + + if ((ctxt == NULL) || (elem == NULL)) + return(0); + if (elem->type != XML_ELEMENT_DECL) + return(0); + if (elem->etype != XML_ELEMENT_TYPE_ELEMENT) + return(1); + /* TODO: should we rebuild in this case ? */ + if (elem->contModel != NULL) { + if (!xmlRegexpIsDeterminist(elem->contModel)) { + ctxt->valid = 0; + return(0); + } + return(1); + } + + ctxt->am = xmlNewAutomata(); + if (ctxt->am == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, + XML_ERR_INTERNAL_ERROR, + "Cannot create automata for element %s\n", + elem->name, NULL, NULL); + return(0); + } + ctxt->state = xmlAutomataGetInitState(ctxt->am); + xmlValidBuildAContentModel(elem->content, ctxt, elem->name); + xmlAutomataSetFinalState(ctxt->am, ctxt->state); + elem->contModel = xmlAutomataCompile(ctxt->am); + if (xmlRegexpIsDeterminist(elem->contModel) != 1) { + char expr[5000]; + expr[0] = 0; + xmlSnprintfElementContent(expr, 5000, elem->content, 1); + xmlErrValidNode(ctxt, (xmlNodePtr) elem, + XML_DTD_CONTENT_NOT_DETERMINIST, + "Content model of %s is not determinist: %s\n", + elem->name, BAD_CAST expr, NULL); +#ifdef DEBUG_REGEXP_ALGO + xmlRegexpPrint(stderr, elem->contModel); +#endif + ctxt->valid = 0; + ctxt->state = NULL; + xmlFreeAutomata(ctxt->am); + ctxt->am = NULL; + return(0); + } + ctxt->state = NULL; + xmlFreeAutomata(ctxt->am); + ctxt->am = NULL; + return(1); +} + +#endif /* LIBXML_REGEXP_ENABLED */ + +/**************************************************************** + * * + * Util functions for data allocation/deallocation * + * * + ****************************************************************/ + +/** + * xmlNewValidCtxt: + * + * Allocate a validation context structure. + * + * Returns NULL if not, otherwise the new validation context structure + */ +xmlValidCtxtPtr xmlNewValidCtxt(void) { + xmlValidCtxtPtr ret; + + if ((ret = xmlMalloc(sizeof (xmlValidCtxt))) == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return (NULL); + } + + (void) memset(ret, 0, sizeof (xmlValidCtxt)); + + return (ret); +} + +/** + * xmlFreeValidCtxt: + * @cur: the validation context to free + * + * Free a validation context structure. + */ +void +xmlFreeValidCtxt(xmlValidCtxtPtr cur) { + if (cur->vstateTab != NULL) + xmlFree(cur->vstateTab); + if (cur->nodeTab != NULL) + xmlFree(cur->nodeTab); + xmlFree(cur); +} + +#endif /* LIBXML_VALID_ENABLED */ + +/** + * xmlNewDocElementContent: + * @doc: the document + * @name: the subelement name or NULL + * @type: the type of element content decl + * + * Allocate an element content structure for the document. + * + * Returns NULL if not, otherwise the new element content structure + */ +xmlElementContentPtr +xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, + xmlElementContentType type) { + xmlElementContentPtr ret; + xmlDictPtr dict = NULL; + + if (doc != NULL) + dict = doc->dict; + + switch(type) { + case XML_ELEMENT_CONTENT_ELEMENT: + if (name == NULL) { + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "xmlNewElementContent : name == NULL !\n", + NULL); + } + break; + case XML_ELEMENT_CONTENT_PCDATA: + case XML_ELEMENT_CONTENT_SEQ: + case XML_ELEMENT_CONTENT_OR: + if (name != NULL) { + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "xmlNewElementContent : name != NULL !\n", + NULL); + } + break; + default: + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "Internal: ELEMENT content corrupted invalid type\n", + NULL); + return(NULL); + } + ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); + if (ret == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + memset(ret, 0, sizeof(xmlElementContent)); + ret->type = type; + ret->ocur = XML_ELEMENT_CONTENT_ONCE; + if (name != NULL) { + int l; + const xmlChar *tmp; + + tmp = xmlSplitQName3(name, &l); + if (tmp == NULL) { + if (dict == NULL) + ret->name = xmlStrdup(name); + else + ret->name = xmlDictLookup(dict, name, -1); + } else { + if (dict == NULL) { + ret->prefix = xmlStrndup(name, l); + ret->name = xmlStrdup(tmp); + } else { + ret->prefix = xmlDictLookup(dict, name, l); + ret->name = xmlDictLookup(dict, tmp, -1); + } + } + } + return(ret); +} + +/** + * xmlNewElementContent: + * @name: the subelement name or NULL + * @type: the type of element content decl + * + * Allocate an element content structure. + * Deprecated in favor of xmlNewDocElementContent + * + * Returns NULL if not, otherwise the new element content structure + */ +xmlElementContentPtr +xmlNewElementContent(const xmlChar *name, xmlElementContentType type) { + return(xmlNewDocElementContent(NULL, name, type)); +} + +/** + * xmlCopyDocElementContent: + * @doc: the document owning the element declaration + * @cur: An element content pointer. + * + * Build a copy of an element content description. + * + * Returns the new xmlElementContentPtr or NULL in case of error. + */ +xmlElementContentPtr +xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) { + xmlElementContentPtr ret = NULL, prev = NULL, tmp; + xmlDictPtr dict = NULL; + + if (cur == NULL) return(NULL); + + if (doc != NULL) + dict = doc->dict; + + ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); + if (ret == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + memset(ret, 0, sizeof(xmlElementContent)); + ret->type = cur->type; + ret->ocur = cur->ocur; + if (cur->name != NULL) { + if (dict) + ret->name = xmlDictLookup(dict, cur->name, -1); + else + ret->name = xmlStrdup(cur->name); + } + + if (cur->prefix != NULL) { + if (dict) + ret->prefix = xmlDictLookup(dict, cur->prefix, -1); + else + ret->prefix = xmlStrdup(cur->prefix); + } + if (cur->c1 != NULL) + ret->c1 = xmlCopyDocElementContent(doc, cur->c1); + if (ret->c1 != NULL) + ret->c1->parent = ret; + if (cur->c2 != NULL) { + prev = ret; + cur = cur->c2; + while (cur != NULL) { + tmp = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); + if (tmp == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(ret); + } + memset(tmp, 0, sizeof(xmlElementContent)); + tmp->type = cur->type; + tmp->ocur = cur->ocur; + prev->c2 = tmp; + if (cur->name != NULL) { + if (dict) + tmp->name = xmlDictLookup(dict, cur->name, -1); + else + tmp->name = xmlStrdup(cur->name); + } + + if (cur->prefix != NULL) { + if (dict) + tmp->prefix = xmlDictLookup(dict, cur->prefix, -1); + else + tmp->prefix = xmlStrdup(cur->prefix); + } + if (cur->c1 != NULL) + tmp->c1 = xmlCopyDocElementContent(doc,cur->c1); + if (tmp->c1 != NULL) + tmp->c1->parent = ret; + prev = tmp; + cur = cur->c2; + } + } + return(ret); +} + +/** + * xmlCopyElementContent: + * @cur: An element content pointer. + * + * Build a copy of an element content description. + * Deprecated, use xmlCopyDocElementContent instead + * + * Returns the new xmlElementContentPtr or NULL in case of error. + */ +xmlElementContentPtr +xmlCopyElementContent(xmlElementContentPtr cur) { + return(xmlCopyDocElementContent(NULL, cur)); +} + +/** + * xmlFreeDocElementContent: + * @doc: the document owning the element declaration + * @cur: the element content tree to free + * + * Free an element content structure. The whole subtree is removed. + */ +void +xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) { + xmlDictPtr dict = NULL; + size_t depth = 0; + + if (cur == NULL) + return; + if (doc != NULL) + dict = doc->dict; + + while (1) { + xmlElementContentPtr parent; + + while ((cur->c1 != NULL) || (cur->c2 != NULL)) { + cur = (cur->c1 != NULL) ? cur->c1 : cur->c2; + depth += 1; + } + + switch (cur->type) { + case XML_ELEMENT_CONTENT_PCDATA: + case XML_ELEMENT_CONTENT_ELEMENT: + case XML_ELEMENT_CONTENT_SEQ: + case XML_ELEMENT_CONTENT_OR: + break; + default: + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "Internal: ELEMENT content corrupted invalid type\n", + NULL); + return; + } + if (dict) { + if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name))) + xmlFree((xmlChar *) cur->name); + if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix))) + xmlFree((xmlChar *) cur->prefix); + } else { + if (cur->name != NULL) xmlFree((xmlChar *) cur->name); + if (cur->prefix != NULL) xmlFree((xmlChar *) cur->prefix); + } + parent = cur->parent; + if ((depth == 0) || (parent == NULL)) { + xmlFree(cur); + break; + } + if (cur == parent->c1) + parent->c1 = NULL; + else + parent->c2 = NULL; + xmlFree(cur); + + if (parent->c2 != NULL) { + cur = parent->c2; + } else { + depth -= 1; + cur = parent; + } + } +} + +/** + * xmlFreeElementContent: + * @cur: the element content tree to free + * + * Free an element content structure. The whole subtree is removed. + * Deprecated, use xmlFreeDocElementContent instead + */ +void +xmlFreeElementContent(xmlElementContentPtr cur) { + xmlFreeDocElementContent(NULL, cur); +} + +#ifdef LIBXML_OUTPUT_ENABLED +/** + * xmlDumpElementOccur: + * @buf: An XML buffer + * @cur: An element table + * + * Dump the occurrence operator of an element. + */ +static void +xmlDumpElementOccur(xmlBufferPtr buf, xmlElementContentPtr cur) { + switch (cur->ocur) { + case XML_ELEMENT_CONTENT_ONCE: + break; + case XML_ELEMENT_CONTENT_OPT: + xmlBufferWriteChar(buf, "?"); + break; + case XML_ELEMENT_CONTENT_MULT: + xmlBufferWriteChar(buf, "*"); + break; + case XML_ELEMENT_CONTENT_PLUS: + xmlBufferWriteChar(buf, "+"); + break; + } +} + +/** + * xmlDumpElementContent: + * @buf: An XML buffer + * @content: An element table + * + * This will dump the content of the element table as an XML DTD definition + */ +static void +xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content) { + xmlElementContentPtr cur; + + if (content == NULL) return; + + xmlBufferWriteChar(buf, "("); + cur = content; + + do { + if (cur == NULL) return; + + switch (cur->type) { + case XML_ELEMENT_CONTENT_PCDATA: + xmlBufferWriteChar(buf, "#PCDATA"); + break; + case XML_ELEMENT_CONTENT_ELEMENT: + if (cur->prefix != NULL) { + xmlBufferWriteCHAR(buf, cur->prefix); + xmlBufferWriteChar(buf, ":"); + } + xmlBufferWriteCHAR(buf, cur->name); + break; + case XML_ELEMENT_CONTENT_SEQ: + case XML_ELEMENT_CONTENT_OR: + if ((cur != content) && + (cur->parent != NULL) && + ((cur->type != cur->parent->type) || + (cur->ocur != XML_ELEMENT_CONTENT_ONCE))) + xmlBufferWriteChar(buf, "("); + cur = cur->c1; + continue; + default: + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "Internal: ELEMENT cur corrupted invalid type\n", + NULL); + } + + while (cur != content) { + xmlElementContentPtr parent = cur->parent; + + if (parent == NULL) return; + + if (((cur->type == XML_ELEMENT_CONTENT_OR) || + (cur->type == XML_ELEMENT_CONTENT_SEQ)) && + ((cur->type != parent->type) || + (cur->ocur != XML_ELEMENT_CONTENT_ONCE))) + xmlBufferWriteChar(buf, ")"); + xmlDumpElementOccur(buf, cur); + + if (cur == parent->c1) { + if (parent->type == XML_ELEMENT_CONTENT_SEQ) + xmlBufferWriteChar(buf, " , "); + else if (parent->type == XML_ELEMENT_CONTENT_OR) + xmlBufferWriteChar(buf, " | "); + + cur = parent->c2; + break; + } + + cur = parent; + } + } while (cur != content); + + xmlBufferWriteChar(buf, ")"); + xmlDumpElementOccur(buf, content); +} + +/** + * xmlSprintfElementContent: + * @buf: an output buffer + * @content: An element table + * @englob: 1 if one must print the englobing parenthesis, 0 otherwise + * + * Deprecated, unsafe, use xmlSnprintfElementContent + */ +void +xmlSprintfElementContent(char *buf ATTRIBUTE_UNUSED, + xmlElementContentPtr content ATTRIBUTE_UNUSED, + int englob ATTRIBUTE_UNUSED) { +} +#endif /* LIBXML_OUTPUT_ENABLED */ + +/** + * xmlSnprintfElementContent: + * @buf: an output buffer + * @size: the buffer size + * @content: An element table + * @englob: 1 if one must print the englobing parenthesis, 0 otherwise + * + * This will dump the content of the element content definition + * Intended just for the debug routine + */ +void +xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob) { + int len; + + if (content == NULL) return; + len = strlen(buf); + if (size - len < 50) { + if ((size - len > 4) && (buf[len - 1] != '.')) + strcat(buf, " ..."); + return; + } + if (englob) strcat(buf, "("); + switch (content->type) { + case XML_ELEMENT_CONTENT_PCDATA: + strcat(buf, "#PCDATA"); + break; + case XML_ELEMENT_CONTENT_ELEMENT: { + int qnameLen = xmlStrlen(content->name); + + if (content->prefix != NULL) + qnameLen += xmlStrlen(content->prefix) + 1; + if (size - len < qnameLen + 10) { + strcat(buf, " ..."); + return; + } + if (content->prefix != NULL) { + strcat(buf, (char *) content->prefix); + strcat(buf, ":"); + } + if (content->name != NULL) + strcat(buf, (char *) content->name); + break; + } + case XML_ELEMENT_CONTENT_SEQ: + if ((content->c1->type == XML_ELEMENT_CONTENT_OR) || + (content->c1->type == XML_ELEMENT_CONTENT_SEQ)) + xmlSnprintfElementContent(buf, size, content->c1, 1); + else + xmlSnprintfElementContent(buf, size, content->c1, 0); + len = strlen(buf); + if (size - len < 50) { + if ((size - len > 4) && (buf[len - 1] != '.')) + strcat(buf, " ..."); + return; + } + strcat(buf, " , "); + if (((content->c2->type == XML_ELEMENT_CONTENT_OR) || + (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) && + (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT)) + xmlSnprintfElementContent(buf, size, content->c2, 1); + else + xmlSnprintfElementContent(buf, size, content->c2, 0); + break; + case XML_ELEMENT_CONTENT_OR: + if ((content->c1->type == XML_ELEMENT_CONTENT_OR) || + (content->c1->type == XML_ELEMENT_CONTENT_SEQ)) + xmlSnprintfElementContent(buf, size, content->c1, 1); + else + xmlSnprintfElementContent(buf, size, content->c1, 0); + len = strlen(buf); + if (size - len < 50) { + if ((size - len > 4) && (buf[len - 1] != '.')) + strcat(buf, " ..."); + return; + } + strcat(buf, " | "); + if (((content->c2->type == XML_ELEMENT_CONTENT_SEQ) || + (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) && + (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT)) + xmlSnprintfElementContent(buf, size, content->c2, 1); + else + xmlSnprintfElementContent(buf, size, content->c2, 0); + break; + } + if (size - strlen(buf) <= 2) return; + if (englob) + strcat(buf, ")"); + switch (content->ocur) { + case XML_ELEMENT_CONTENT_ONCE: + break; + case XML_ELEMENT_CONTENT_OPT: + strcat(buf, "?"); + break; + case XML_ELEMENT_CONTENT_MULT: + strcat(buf, "*"); + break; + case XML_ELEMENT_CONTENT_PLUS: + strcat(buf, "+"); + break; + } +} + +/**************************************************************** + * * + * Registration of DTD declarations * + * * + ****************************************************************/ + +/** + * xmlFreeElement: + * @elem: An element + * + * Deallocate the memory used by an element definition + */ +static void +xmlFreeElement(xmlElementPtr elem) { + if (elem == NULL) return; + xmlUnlinkNode((xmlNodePtr) elem); + xmlFreeDocElementContent(elem->doc, elem->content); + if (elem->name != NULL) + xmlFree((xmlChar *) elem->name); + if (elem->prefix != NULL) + xmlFree((xmlChar *) elem->prefix); +#ifdef LIBXML_REGEXP_ENABLED + if (elem->contModel != NULL) + xmlRegFreeRegexp(elem->contModel); +#endif + xmlFree(elem); +} + + +/** + * xmlAddElementDecl: + * @ctxt: the validation context + * @dtd: pointer to the DTD + * @name: the entity name + * @type: the element type + * @content: the element content tree or NULL + * + * Register a new element declaration + * + * Returns NULL if not, otherwise the entity + */ +xmlElementPtr +xmlAddElementDecl(xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, const xmlChar *name, + xmlElementTypeVal type, + xmlElementContentPtr content) { + xmlElementPtr ret; + xmlElementTablePtr table; + xmlAttributePtr oldAttributes = NULL; + xmlChar *ns, *uqname; + + if (dtd == NULL) { + return(NULL); + } + if (name == NULL) { + return(NULL); + } + + switch (type) { + case XML_ELEMENT_TYPE_EMPTY: + if (content != NULL) { + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "xmlAddElementDecl: content != NULL for EMPTY\n", + NULL); + return(NULL); + } + break; + case XML_ELEMENT_TYPE_ANY: + if (content != NULL) { + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "xmlAddElementDecl: content != NULL for ANY\n", + NULL); + return(NULL); + } + break; + case XML_ELEMENT_TYPE_MIXED: + if (content == NULL) { + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "xmlAddElementDecl: content == NULL for MIXED\n", + NULL); + return(NULL); + } + break; + case XML_ELEMENT_TYPE_ELEMENT: + if (content == NULL) { + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "xmlAddElementDecl: content == NULL for ELEMENT\n", + NULL); + return(NULL); + } + break; + default: + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "Internal: ELEMENT decl corrupted invalid type\n", + NULL); + return(NULL); + } + + /* + * check if name is a QName + */ + uqname = xmlSplitQName2(name, &ns); + if (uqname != NULL) + name = uqname; + + /* + * Create the Element table if needed. + */ + table = (xmlElementTablePtr) dtd->elements; + if (table == NULL) { + xmlDictPtr dict = NULL; + + if (dtd->doc != NULL) + dict = dtd->doc->dict; + table = xmlHashCreateDict(0, dict); + dtd->elements = (void *) table; + } + if (table == NULL) { + xmlVErrMemory(ctxt, + "xmlAddElementDecl: Table creation failed!\n"); + if (uqname != NULL) + xmlFree(uqname); + if (ns != NULL) + xmlFree(ns); + return(NULL); + } + + /* + * lookup old attributes inserted on an undefined element in the + * internal subset. + */ + if ((dtd->doc != NULL) && (dtd->doc->intSubset != NULL)) { + ret = xmlHashLookup2(dtd->doc->intSubset->elements, name, ns); + if ((ret != NULL) && (ret->etype == XML_ELEMENT_TYPE_UNDEFINED)) { + oldAttributes = ret->attributes; + ret->attributes = NULL; + xmlHashRemoveEntry2(dtd->doc->intSubset->elements, name, ns, NULL); + xmlFreeElement(ret); + } + } + + /* + * The element may already be present if one of its attribute + * was registered first + */ + ret = xmlHashLookup2(table, name, ns); + if (ret != NULL) { + if (ret->etype != XML_ELEMENT_TYPE_UNDEFINED) { +#ifdef LIBXML_VALID_ENABLED + /* + * The element is already defined in this DTD. + */ + xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED, + "Redefinition of element %s\n", + name, NULL, NULL); +#endif /* LIBXML_VALID_ENABLED */ + if (uqname != NULL) + xmlFree(uqname); + if (ns != NULL) + xmlFree(ns); + return(NULL); + } + if (ns != NULL) { + xmlFree(ns); + ns = NULL; + } + } else { + ret = (xmlElementPtr) xmlMalloc(sizeof(xmlElement)); + if (ret == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + if (uqname != NULL) + xmlFree(uqname); + if (ns != NULL) + xmlFree(ns); + return(NULL); + } + memset(ret, 0, sizeof(xmlElement)); + ret->type = XML_ELEMENT_DECL; + + /* + * fill the structure. + */ + ret->name = xmlStrdup(name); + if (ret->name == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + if (uqname != NULL) + xmlFree(uqname); + if (ns != NULL) + xmlFree(ns); + xmlFree(ret); + return(NULL); + } + ret->prefix = ns; + + /* + * Validity Check: + * Insertion must not fail + */ + if (xmlHashAddEntry2(table, name, ns, ret)) { +#ifdef LIBXML_VALID_ENABLED + /* + * The element is already defined in this DTD. + */ + xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED, + "Redefinition of element %s\n", + name, NULL, NULL); +#endif /* LIBXML_VALID_ENABLED */ + xmlFreeElement(ret); + if (uqname != NULL) + xmlFree(uqname); + return(NULL); + } + /* + * For new element, may have attributes from earlier + * definition in internal subset + */ + ret->attributes = oldAttributes; + } + + /* + * Finish to fill the structure. + */ + ret->etype = type; + /* + * Avoid a stupid copy when called by the parser + * and flag it by setting a special parent value + * so the parser doesn't unallocate it. + */ + if ((ctxt != NULL) && + ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) || + (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1))) { + ret->content = content; + if (content != NULL) + content->parent = (xmlElementContentPtr) 1; + } else { + ret->content = xmlCopyDocElementContent(dtd->doc, content); + } + + /* + * Link it to the DTD + */ + ret->parent = dtd; + ret->doc = dtd->doc; + if (dtd->last == NULL) { + dtd->children = dtd->last = (xmlNodePtr) ret; + } else { + dtd->last->next = (xmlNodePtr) ret; + ret->prev = dtd->last; + dtd->last = (xmlNodePtr) ret; + } + if (uqname != NULL) + xmlFree(uqname); + return(ret); +} + +static void +xmlFreeElementTableEntry(void *elem, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlFreeElement((xmlElementPtr) elem); +} + +/** + * xmlFreeElementTable: + * @table: An element table + * + * Deallocate the memory used by an element hash table. + */ +void +xmlFreeElementTable(xmlElementTablePtr table) { + xmlHashFree(table, xmlFreeElementTableEntry); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlCopyElement: + * @elem: An element + * + * Build a copy of an element. + * + * Returns the new xmlElementPtr or NULL in case of error. + */ +static void * +xmlCopyElement(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlElementPtr elem = (xmlElementPtr) payload; + xmlElementPtr cur; + + cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement)); + if (cur == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + memset(cur, 0, sizeof(xmlElement)); + cur->type = XML_ELEMENT_DECL; + cur->etype = elem->etype; + if (elem->name != NULL) + cur->name = xmlStrdup(elem->name); + else + cur->name = NULL; + if (elem->prefix != NULL) + cur->prefix = xmlStrdup(elem->prefix); + else + cur->prefix = NULL; + cur->content = xmlCopyElementContent(elem->content); + /* TODO : rebuild the attribute list on the copy */ + cur->attributes = NULL; + return(cur); +} + +/** + * xmlCopyElementTable: + * @table: An element table + * + * Build a copy of an element table. + * + * Returns the new xmlElementTablePtr or NULL in case of error. + */ +xmlElementTablePtr +xmlCopyElementTable(xmlElementTablePtr table) { + return((xmlElementTablePtr) xmlHashCopy(table, xmlCopyElement)); +} +#endif /* LIBXML_TREE_ENABLED */ + +#ifdef LIBXML_OUTPUT_ENABLED +/** + * xmlDumpElementDecl: + * @buf: the XML buffer output + * @elem: An element table + * + * This will dump the content of the element declaration as an XML + * DTD definition + */ +void +xmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) { + if ((buf == NULL) || (elem == NULL)) + return; + switch (elem->etype) { + case XML_ELEMENT_TYPE_EMPTY: + xmlBufferWriteChar(buf, "prefix != NULL) { + xmlBufferWriteCHAR(buf, elem->prefix); + xmlBufferWriteChar(buf, ":"); + } + xmlBufferWriteCHAR(buf, elem->name); + xmlBufferWriteChar(buf, " EMPTY>\n"); + break; + case XML_ELEMENT_TYPE_ANY: + xmlBufferWriteChar(buf, "prefix != NULL) { + xmlBufferWriteCHAR(buf, elem->prefix); + xmlBufferWriteChar(buf, ":"); + } + xmlBufferWriteCHAR(buf, elem->name); + xmlBufferWriteChar(buf, " ANY>\n"); + break; + case XML_ELEMENT_TYPE_MIXED: + xmlBufferWriteChar(buf, "prefix != NULL) { + xmlBufferWriteCHAR(buf, elem->prefix); + xmlBufferWriteChar(buf, ":"); + } + xmlBufferWriteCHAR(buf, elem->name); + xmlBufferWriteChar(buf, " "); + xmlDumpElementContent(buf, elem->content); + xmlBufferWriteChar(buf, ">\n"); + break; + case XML_ELEMENT_TYPE_ELEMENT: + xmlBufferWriteChar(buf, "prefix != NULL) { + xmlBufferWriteCHAR(buf, elem->prefix); + xmlBufferWriteChar(buf, ":"); + } + xmlBufferWriteCHAR(buf, elem->name); + xmlBufferWriteChar(buf, " "); + xmlDumpElementContent(buf, elem->content); + xmlBufferWriteChar(buf, ">\n"); + break; + default: + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "Internal: ELEMENT struct corrupted invalid type\n", + NULL); + } +} + +/** + * xmlDumpElementDeclScan: + * @elem: An element table + * @buf: the XML buffer output + * + * This routine is used by the hash scan function. It just reverses + * the arguments. + */ +static void +xmlDumpElementDeclScan(void *elem, void *buf, + const xmlChar *name ATTRIBUTE_UNUSED) { + xmlDumpElementDecl((xmlBufferPtr) buf, (xmlElementPtr) elem); +} + +/** + * xmlDumpElementTable: + * @buf: the XML buffer output + * @table: An element table + * + * This will dump the content of the element table as an XML DTD definition + */ +void +xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table) { + if ((buf == NULL) || (table == NULL)) + return; + xmlHashScan(table, xmlDumpElementDeclScan, buf); +} +#endif /* LIBXML_OUTPUT_ENABLED */ + +/** + * xmlCreateEnumeration: + * @name: the enumeration name or NULL + * + * create and initialize an enumeration attribute node. + * + * Returns the xmlEnumerationPtr just created or NULL in case + * of error. + */ +xmlEnumerationPtr +xmlCreateEnumeration(const xmlChar *name) { + xmlEnumerationPtr ret; + + ret = (xmlEnumerationPtr) xmlMalloc(sizeof(xmlEnumeration)); + if (ret == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + memset(ret, 0, sizeof(xmlEnumeration)); + + if (name != NULL) + ret->name = xmlStrdup(name); + return(ret); +} + +/** + * xmlFreeEnumeration: + * @cur: the tree to free. + * + * free an enumeration attribute node (recursive). + */ +void +xmlFreeEnumeration(xmlEnumerationPtr cur) { + if (cur == NULL) return; + + if (cur->next != NULL) xmlFreeEnumeration(cur->next); + + if (cur->name != NULL) xmlFree((xmlChar *) cur->name); + xmlFree(cur); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlCopyEnumeration: + * @cur: the tree to copy. + * + * Copy an enumeration attribute node (recursive). + * + * Returns the xmlEnumerationPtr just created or NULL in case + * of error. + */ +xmlEnumerationPtr +xmlCopyEnumeration(xmlEnumerationPtr cur) { + xmlEnumerationPtr ret; + + if (cur == NULL) return(NULL); + ret = xmlCreateEnumeration((xmlChar *) cur->name); + if (ret == NULL) return(NULL); + + if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next); + else ret->next = NULL; + + return(ret); +} +#endif /* LIBXML_TREE_ENABLED */ + +#ifdef LIBXML_OUTPUT_ENABLED +/** + * xmlDumpEnumeration: + * @buf: the XML buffer output + * @enum: An enumeration + * + * This will dump the content of the enumeration + */ +static void +xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) { + if ((buf == NULL) || (cur == NULL)) + return; + + xmlBufferWriteCHAR(buf, cur->name); + if (cur->next == NULL) + xmlBufferWriteChar(buf, ")"); + else { + xmlBufferWriteChar(buf, " | "); + xmlDumpEnumeration(buf, cur->next); + } +} +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef LIBXML_VALID_ENABLED +/** + * xmlScanIDAttributeDecl: + * @ctxt: the validation context + * @elem: the element name + * @err: whether to raise errors here + * + * Verify that the element don't have too many ID attributes + * declared. + * + * Returns the number of ID attributes found. + */ +static int +xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem, int err) { + xmlAttributePtr cur; + int ret = 0; + + if (elem == NULL) return(0); + cur = elem->attributes; + while (cur != NULL) { + if (cur->atype == XML_ATTRIBUTE_ID) { + ret ++; + if ((ret > 1) && (err)) + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_MULTIPLE_ID, + "Element %s has too many ID attributes defined : %s\n", + elem->name, cur->name, NULL); + } + cur = cur->nexth; + } + return(ret); +} +#endif /* LIBXML_VALID_ENABLED */ + +/** + * xmlFreeAttribute: + * @elem: An attribute + * + * Deallocate the memory used by an attribute definition + */ +static void +xmlFreeAttribute(xmlAttributePtr attr) { + xmlDictPtr dict; + + if (attr == NULL) return; + if (attr->doc != NULL) + dict = attr->doc->dict; + else + dict = NULL; + xmlUnlinkNode((xmlNodePtr) attr); + if (attr->tree != NULL) + xmlFreeEnumeration(attr->tree); + if (dict) { + if ((attr->elem != NULL) && (!xmlDictOwns(dict, attr->elem))) + xmlFree((xmlChar *) attr->elem); + if ((attr->name != NULL) && (!xmlDictOwns(dict, attr->name))) + xmlFree((xmlChar *) attr->name); + if ((attr->prefix != NULL) && (!xmlDictOwns(dict, attr->prefix))) + xmlFree((xmlChar *) attr->prefix); + if ((attr->defaultValue != NULL) && + (!xmlDictOwns(dict, attr->defaultValue))) + xmlFree((xmlChar *) attr->defaultValue); + } else { + if (attr->elem != NULL) + xmlFree((xmlChar *) attr->elem); + if (attr->name != NULL) + xmlFree((xmlChar *) attr->name); + if (attr->defaultValue != NULL) + xmlFree((xmlChar *) attr->defaultValue); + if (attr->prefix != NULL) + xmlFree((xmlChar *) attr->prefix); + } + xmlFree(attr); +} + + +/** + * xmlAddAttributeDecl: + * @ctxt: the validation context + * @dtd: pointer to the DTD + * @elem: the element name + * @name: the attribute name + * @ns: the attribute namespace prefix + * @type: the attribute type + * @def: the attribute default type + * @defaultValue: the attribute default value + * @tree: if it's an enumeration, the associated list + * + * Register a new attribute declaration + * Note that @tree becomes the ownership of the DTD + * + * Returns NULL if not new, otherwise the attribute decl + */ +xmlAttributePtr +xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, const xmlChar *elem, + const xmlChar *name, const xmlChar *ns, + xmlAttributeType type, xmlAttributeDefault def, + const xmlChar *defaultValue, xmlEnumerationPtr tree) { + xmlAttributePtr ret; + xmlAttributeTablePtr table; + xmlElementPtr elemDef; + xmlDictPtr dict = NULL; + + if (dtd == NULL) { + xmlFreeEnumeration(tree); + return(NULL); + } + if (name == NULL) { + xmlFreeEnumeration(tree); + return(NULL); + } + if (elem == NULL) { + xmlFreeEnumeration(tree); + return(NULL); + } + if (dtd->doc != NULL) + dict = dtd->doc->dict; + +#ifdef LIBXML_VALID_ENABLED + /* + * Check the type and possibly the default value. + */ + switch (type) { + case XML_ATTRIBUTE_CDATA: + break; + case XML_ATTRIBUTE_ID: + break; + case XML_ATTRIBUTE_IDREF: + break; + case XML_ATTRIBUTE_IDREFS: + break; + case XML_ATTRIBUTE_ENTITY: + break; + case XML_ATTRIBUTE_ENTITIES: + break; + case XML_ATTRIBUTE_NMTOKEN: + break; + case XML_ATTRIBUTE_NMTOKENS: + break; + case XML_ATTRIBUTE_ENUMERATION: + break; + case XML_ATTRIBUTE_NOTATION: + break; + default: + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "Internal: ATTRIBUTE struct corrupted invalid type\n", + NULL); + xmlFreeEnumeration(tree); + return(NULL); + } + if ((defaultValue != NULL) && + (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) { + xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT, + "Attribute %s of %s: invalid default value\n", + elem, name, defaultValue); + defaultValue = NULL; + if (ctxt != NULL) + ctxt->valid = 0; + } +#endif /* LIBXML_VALID_ENABLED */ + + /* + * Check first that an attribute defined in the external subset wasn't + * already defined in the internal subset + */ + if ((dtd->doc != NULL) && (dtd->doc->extSubset == dtd) && + (dtd->doc->intSubset != NULL) && + (dtd->doc->intSubset->attributes != NULL)) { + ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem); + if (ret != NULL) { + xmlFreeEnumeration(tree); + return(NULL); + } + } + + /* + * Create the Attribute table if needed. + */ + table = (xmlAttributeTablePtr) dtd->attributes; + if (table == NULL) { + table = xmlHashCreateDict(0, dict); + dtd->attributes = (void *) table; + } + if (table == NULL) { + xmlVErrMemory(ctxt, + "xmlAddAttributeDecl: Table creation failed!\n"); + xmlFreeEnumeration(tree); + return(NULL); + } + + + ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute)); + if (ret == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + xmlFreeEnumeration(tree); + return(NULL); + } + memset(ret, 0, sizeof(xmlAttribute)); + ret->type = XML_ATTRIBUTE_DECL; + + /* + * fill the structure. + */ + ret->atype = type; + /* + * doc must be set before possible error causes call + * to xmlFreeAttribute (because it's used to check on + * dict use) + */ + ret->doc = dtd->doc; + if (dict) { + ret->name = xmlDictLookup(dict, name, -1); + ret->prefix = xmlDictLookup(dict, ns, -1); + ret->elem = xmlDictLookup(dict, elem, -1); + } else { + ret->name = xmlStrdup(name); + ret->prefix = xmlStrdup(ns); + ret->elem = xmlStrdup(elem); + } + ret->def = def; + ret->tree = tree; + if (defaultValue != NULL) { + if (dict) + ret->defaultValue = xmlDictLookup(dict, defaultValue, -1); + else + ret->defaultValue = xmlStrdup(defaultValue); + } + + /* + * Validity Check: + * Search the DTD for previous declarations of the ATTLIST + */ + if (xmlHashAddEntry3(table, ret->name, ret->prefix, ret->elem, ret) < 0) { +#ifdef LIBXML_VALID_ENABLED + /* + * The attribute is already defined in this DTD. + */ + xmlErrValidWarning(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_REDEFINED, + "Attribute %s of element %s: already defined\n", + name, elem, NULL); +#endif /* LIBXML_VALID_ENABLED */ + xmlFreeAttribute(ret); + return(NULL); + } + + /* + * Validity Check: + * Multiple ID per element + */ + elemDef = xmlGetDtdElementDesc2(dtd, elem, 1); + if (elemDef != NULL) { + +#ifdef LIBXML_VALID_ENABLED + if ((type == XML_ATTRIBUTE_ID) && + (xmlScanIDAttributeDecl(NULL, elemDef, 1) != 0)) { + xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID, + "Element %s has too may ID attributes defined : %s\n", + elem, name, NULL); + if (ctxt != NULL) + ctxt->valid = 0; + } +#endif /* LIBXML_VALID_ENABLED */ + + /* + * Insert namespace default def first they need to be + * processed first. + */ + if ((xmlStrEqual(ret->name, BAD_CAST "xmlns")) || + ((ret->prefix != NULL && + (xmlStrEqual(ret->prefix, BAD_CAST "xmlns"))))) { + ret->nexth = elemDef->attributes; + elemDef->attributes = ret; + } else { + xmlAttributePtr tmp = elemDef->attributes; + + while ((tmp != NULL) && + ((xmlStrEqual(tmp->name, BAD_CAST "xmlns")) || + ((ret->prefix != NULL && + (xmlStrEqual(ret->prefix, BAD_CAST "xmlns")))))) { + if (tmp->nexth == NULL) + break; + tmp = tmp->nexth; + } + if (tmp != NULL) { + ret->nexth = tmp->nexth; + tmp->nexth = ret; + } else { + ret->nexth = elemDef->attributes; + elemDef->attributes = ret; + } + } + } + + /* + * Link it to the DTD + */ + ret->parent = dtd; + if (dtd->last == NULL) { + dtd->children = dtd->last = (xmlNodePtr) ret; + } else { + dtd->last->next = (xmlNodePtr) ret; + ret->prev = dtd->last; + dtd->last = (xmlNodePtr) ret; + } + return(ret); +} + +static void +xmlFreeAttributeTableEntry(void *attr, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlFreeAttribute((xmlAttributePtr) attr); +} + +/** + * xmlFreeAttributeTable: + * @table: An attribute table + * + * Deallocate the memory used by an entities hash table. + */ +void +xmlFreeAttributeTable(xmlAttributeTablePtr table) { + xmlHashFree(table, xmlFreeAttributeTableEntry); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlCopyAttribute: + * @attr: An attribute + * + * Build a copy of an attribute. + * + * Returns the new xmlAttributePtr or NULL in case of error. + */ +static void * +xmlCopyAttribute(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlAttributePtr attr = (xmlAttributePtr) payload; + xmlAttributePtr cur; + + cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute)); + if (cur == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + memset(cur, 0, sizeof(xmlAttribute)); + cur->type = XML_ATTRIBUTE_DECL; + cur->atype = attr->atype; + cur->def = attr->def; + cur->tree = xmlCopyEnumeration(attr->tree); + if (attr->elem != NULL) + cur->elem = xmlStrdup(attr->elem); + if (attr->name != NULL) + cur->name = xmlStrdup(attr->name); + if (attr->prefix != NULL) + cur->prefix = xmlStrdup(attr->prefix); + if (attr->defaultValue != NULL) + cur->defaultValue = xmlStrdup(attr->defaultValue); + return(cur); +} + +/** + * xmlCopyAttributeTable: + * @table: An attribute table + * + * Build a copy of an attribute table. + * + * Returns the new xmlAttributeTablePtr or NULL in case of error. + */ +xmlAttributeTablePtr +xmlCopyAttributeTable(xmlAttributeTablePtr table) { + return((xmlAttributeTablePtr) xmlHashCopy(table, xmlCopyAttribute)); +} +#endif /* LIBXML_TREE_ENABLED */ + +#ifdef LIBXML_OUTPUT_ENABLED +/** + * xmlDumpAttributeDecl: + * @buf: the XML buffer output + * @attr: An attribute declaration + * + * This will dump the content of the attribute declaration as an XML + * DTD definition + */ +void +xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) { + if ((buf == NULL) || (attr == NULL)) + return; + xmlBufferWriteChar(buf, "elem); + xmlBufferWriteChar(buf, " "); + if (attr->prefix != NULL) { + xmlBufferWriteCHAR(buf, attr->prefix); + xmlBufferWriteChar(buf, ":"); + } + xmlBufferWriteCHAR(buf, attr->name); + switch (attr->atype) { + case XML_ATTRIBUTE_CDATA: + xmlBufferWriteChar(buf, " CDATA"); + break; + case XML_ATTRIBUTE_ID: + xmlBufferWriteChar(buf, " ID"); + break; + case XML_ATTRIBUTE_IDREF: + xmlBufferWriteChar(buf, " IDREF"); + break; + case XML_ATTRIBUTE_IDREFS: + xmlBufferWriteChar(buf, " IDREFS"); + break; + case XML_ATTRIBUTE_ENTITY: + xmlBufferWriteChar(buf, " ENTITY"); + break; + case XML_ATTRIBUTE_ENTITIES: + xmlBufferWriteChar(buf, " ENTITIES"); + break; + case XML_ATTRIBUTE_NMTOKEN: + xmlBufferWriteChar(buf, " NMTOKEN"); + break; + case XML_ATTRIBUTE_NMTOKENS: + xmlBufferWriteChar(buf, " NMTOKENS"); + break; + case XML_ATTRIBUTE_ENUMERATION: + xmlBufferWriteChar(buf, " ("); + xmlDumpEnumeration(buf, attr->tree); + break; + case XML_ATTRIBUTE_NOTATION: + xmlBufferWriteChar(buf, " NOTATION ("); + xmlDumpEnumeration(buf, attr->tree); + break; + default: + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "Internal: ATTRIBUTE struct corrupted invalid type\n", + NULL); + } + switch (attr->def) { + case XML_ATTRIBUTE_NONE: + break; + case XML_ATTRIBUTE_REQUIRED: + xmlBufferWriteChar(buf, " #REQUIRED"); + break; + case XML_ATTRIBUTE_IMPLIED: + xmlBufferWriteChar(buf, " #IMPLIED"); + break; + case XML_ATTRIBUTE_FIXED: + xmlBufferWriteChar(buf, " #FIXED"); + break; + default: + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "Internal: ATTRIBUTE struct corrupted invalid def\n", + NULL); + } + if (attr->defaultValue != NULL) { + xmlBufferWriteChar(buf, " "); + xmlBufferWriteQuotedString(buf, attr->defaultValue); + } + xmlBufferWriteChar(buf, ">\n"); +} + +/** + * xmlDumpAttributeDeclScan: + * @attr: An attribute declaration + * @buf: the XML buffer output + * + * This is used with the hash scan function - just reverses arguments + */ +static void +xmlDumpAttributeDeclScan(void *attr, void *buf, + const xmlChar *name ATTRIBUTE_UNUSED) { + xmlDumpAttributeDecl((xmlBufferPtr) buf, (xmlAttributePtr) attr); +} + +/** + * xmlDumpAttributeTable: + * @buf: the XML buffer output + * @table: An attribute table + * + * This will dump the content of the attribute table as an XML DTD definition + */ +void +xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table) { + if ((buf == NULL) || (table == NULL)) + return; + xmlHashScan(table, xmlDumpAttributeDeclScan, buf); +} +#endif /* LIBXML_OUTPUT_ENABLED */ + +/************************************************************************ + * * + * NOTATIONs * + * * + ************************************************************************/ +/** + * xmlFreeNotation: + * @not: A notation + * + * Deallocate the memory used by an notation definition + */ +static void +xmlFreeNotation(xmlNotationPtr nota) { + if (nota == NULL) return; + if (nota->name != NULL) + xmlFree((xmlChar *) nota->name); + if (nota->PublicID != NULL) + xmlFree((xmlChar *) nota->PublicID); + if (nota->SystemID != NULL) + xmlFree((xmlChar *) nota->SystemID); + xmlFree(nota); +} + + +/** + * xmlAddNotationDecl: + * @dtd: pointer to the DTD + * @ctxt: the validation context + * @name: the entity name + * @PublicID: the public identifier or NULL + * @SystemID: the system identifier or NULL + * + * Register a new notation declaration + * + * Returns NULL if not, otherwise the entity + */ +xmlNotationPtr +xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *PublicID, const xmlChar *SystemID) { + xmlNotationPtr ret; + xmlNotationTablePtr table; + + if (dtd == NULL) { + return(NULL); + } + if (name == NULL) { + return(NULL); + } + if ((PublicID == NULL) && (SystemID == NULL)) { + return(NULL); + } + + /* + * Create the Notation table if needed. + */ + table = (xmlNotationTablePtr) dtd->notations; + if (table == NULL) { + xmlDictPtr dict = NULL; + if (dtd->doc != NULL) + dict = dtd->doc->dict; + + dtd->notations = table = xmlHashCreateDict(0, dict); + } + if (table == NULL) { + xmlVErrMemory(ctxt, + "xmlAddNotationDecl: Table creation failed!\n"); + return(NULL); + } + + ret = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation)); + if (ret == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(NULL); + } + memset(ret, 0, sizeof(xmlNotation)); + + /* + * fill the structure. + */ + ret->name = xmlStrdup(name); + if (SystemID != NULL) + ret->SystemID = xmlStrdup(SystemID); + if (PublicID != NULL) + ret->PublicID = xmlStrdup(PublicID); + + /* + * Validity Check: + * Check the DTD for previous declarations of the ATTLIST + */ + if (xmlHashAddEntry(table, name, ret)) { +#ifdef LIBXML_VALID_ENABLED + xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED, + "xmlAddNotationDecl: %s already defined\n", + (const char *) name); +#endif /* LIBXML_VALID_ENABLED */ + xmlFreeNotation(ret); + return(NULL); + } + return(ret); +} + +static void +xmlFreeNotationTableEntry(void *nota, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlFreeNotation((xmlNotationPtr) nota); +} + +/** + * xmlFreeNotationTable: + * @table: An notation table + * + * Deallocate the memory used by an entities hash table. + */ +void +xmlFreeNotationTable(xmlNotationTablePtr table) { + xmlHashFree(table, xmlFreeNotationTableEntry); +} + +#ifdef LIBXML_TREE_ENABLED +/** + * xmlCopyNotation: + * @nota: A notation + * + * Build a copy of a notation. + * + * Returns the new xmlNotationPtr or NULL in case of error. + */ +static void * +xmlCopyNotation(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlNotationPtr nota = (xmlNotationPtr) payload; + xmlNotationPtr cur; + + cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation)); + if (cur == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + if (nota->name != NULL) + cur->name = xmlStrdup(nota->name); + else + cur->name = NULL; + if (nota->PublicID != NULL) + cur->PublicID = xmlStrdup(nota->PublicID); + else + cur->PublicID = NULL; + if (nota->SystemID != NULL) + cur->SystemID = xmlStrdup(nota->SystemID); + else + cur->SystemID = NULL; + return(cur); +} + +/** + * xmlCopyNotationTable: + * @table: A notation table + * + * Build a copy of a notation table. + * + * Returns the new xmlNotationTablePtr or NULL in case of error. + */ +xmlNotationTablePtr +xmlCopyNotationTable(xmlNotationTablePtr table) { + return((xmlNotationTablePtr) xmlHashCopy(table, xmlCopyNotation)); +} +#endif /* LIBXML_TREE_ENABLED */ + +#ifdef LIBXML_OUTPUT_ENABLED +/** + * xmlDumpNotationDecl: + * @buf: the XML buffer output + * @nota: A notation declaration + * + * This will dump the content the notation declaration as an XML DTD definition + */ +void +xmlDumpNotationDecl(xmlBufferPtr buf, xmlNotationPtr nota) { + if ((buf == NULL) || (nota == NULL)) + return; + xmlBufferWriteChar(buf, "name); + if (nota->PublicID != NULL) { + xmlBufferWriteChar(buf, " PUBLIC "); + xmlBufferWriteQuotedString(buf, nota->PublicID); + if (nota->SystemID != NULL) { + xmlBufferWriteChar(buf, " "); + xmlBufferWriteQuotedString(buf, nota->SystemID); + } + } else { + xmlBufferWriteChar(buf, " SYSTEM "); + xmlBufferWriteQuotedString(buf, nota->SystemID); + } + xmlBufferWriteChar(buf, " >\n"); +} + +/** + * xmlDumpNotationDeclScan: + * @nota: A notation declaration + * @buf: the XML buffer output + * + * This is called with the hash scan function, and just reverses args + */ +static void +xmlDumpNotationDeclScan(void *nota, void *buf, + const xmlChar *name ATTRIBUTE_UNUSED) { + xmlDumpNotationDecl((xmlBufferPtr) buf, (xmlNotationPtr) nota); +} + +/** + * xmlDumpNotationTable: + * @buf: the XML buffer output + * @table: A notation table + * + * This will dump the content of the notation table as an XML DTD definition + */ +void +xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) { + if ((buf == NULL) || (table == NULL)) + return; + xmlHashScan(table, xmlDumpNotationDeclScan, buf); +} +#endif /* LIBXML_OUTPUT_ENABLED */ + +/************************************************************************ + * * + * IDs * + * * + ************************************************************************/ +/** + * DICT_FREE: + * @str: a string + * + * Free a string if it is not owned by the "dict" dictionary in the + * current scope + */ +#define DICT_FREE(str) \ + if ((str) && ((!dict) || \ + (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \ + xmlFree((char *)(str)); + +/** + * xmlFreeID: + * @not: A id + * + * Deallocate the memory used by an id definition + */ +static void +xmlFreeID(xmlIDPtr id) { + xmlDictPtr dict = NULL; + + if (id == NULL) return; + + if (id->doc != NULL) + dict = id->doc->dict; + + if (id->value != NULL) + DICT_FREE(id->value) + if (id->name != NULL) + DICT_FREE(id->name) + xmlFree(id); +} + + +/** + * xmlAddID: + * @ctxt: the validation context + * @doc: pointer to the document + * @value: the value name + * @attr: the attribute holding the ID + * + * Register a new id declaration + * + * Returns NULL if not, otherwise the new xmlIDPtr + */ +xmlIDPtr +xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, + xmlAttrPtr attr) { + xmlIDPtr ret; + xmlIDTablePtr table; + + if (doc == NULL) { + return(NULL); + } + if (value == NULL) { + return(NULL); + } + if (attr == NULL) { + return(NULL); + } + + /* + * Create the ID table if needed. + */ + table = (xmlIDTablePtr) doc->ids; + if (table == NULL) { + doc->ids = table = xmlHashCreateDict(0, doc->dict); + } + if (table == NULL) { + xmlVErrMemory(ctxt, + "xmlAddID: Table creation failed!\n"); + return(NULL); + } + + ret = (xmlIDPtr) xmlMalloc(sizeof(xmlID)); + if (ret == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(NULL); + } + + /* + * fill the structure. + */ + ret->value = xmlStrdup(value); + ret->doc = doc; + if ((ctxt != NULL) && (ctxt->vstateNr != 0)) { + /* + * Operating in streaming mode, attr is gonna disappear + */ + if (doc->dict != NULL) + ret->name = xmlDictLookup(doc->dict, attr->name, -1); + else + ret->name = xmlStrdup(attr->name); + ret->attr = NULL; + } else { + ret->attr = attr; + ret->name = NULL; + } + ret->lineno = xmlGetLineNo(attr->parent); + + if (xmlHashAddEntry(table, value, ret) < 0) { +#ifdef LIBXML_VALID_ENABLED + /* + * The id is already defined in this DTD. + */ + if (ctxt != NULL) { + xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED, + "ID %s already defined\n", value, NULL, NULL); + } +#endif /* LIBXML_VALID_ENABLED */ + xmlFreeID(ret); + return(NULL); + } + if (attr != NULL) + attr->atype = XML_ATTRIBUTE_ID; + return(ret); +} + +static void +xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlFreeID((xmlIDPtr) id); +} + +/** + * xmlFreeIDTable: + * @table: An id table + * + * Deallocate the memory used by an ID hash table. + */ +void +xmlFreeIDTable(xmlIDTablePtr table) { + xmlHashFree(table, xmlFreeIDTableEntry); +} + +/** + * xmlIsID: + * @doc: the document + * @elem: the element carrying the attribute + * @attr: the attribute + * + * Determine whether an attribute is of type ID. In case we have DTD(s) + * then this is done if DTD loading has been requested. In the case + * of HTML documents parsed with the HTML parser, then ID detection is + * done systematically. + * + * Returns 0 or 1 depending on the lookup result + */ +int +xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) { + if ((attr == NULL) || (attr->name == NULL)) return(0); + if ((attr->ns != NULL) && (attr->ns->prefix != NULL) && + (!strcmp((char *) attr->name, "id")) && + (!strcmp((char *) attr->ns->prefix, "xml"))) + return(1); + if (doc == NULL) return(0); + if ((doc->intSubset == NULL) && (doc->extSubset == NULL) && + (doc->type != XML_HTML_DOCUMENT_NODE)) { + return(0); + } else if (doc->type == XML_HTML_DOCUMENT_NODE) { + if ((xmlStrEqual(BAD_CAST "id", attr->name)) || + ((xmlStrEqual(BAD_CAST "name", attr->name)) && + ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a"))))) + return(1); + return(0); + } else if (elem == NULL) { + return(0); + } else { + xmlAttributePtr attrDecl = NULL; + + xmlChar felem[50], fattr[50]; + xmlChar *fullelemname, *fullattrname; + + fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ? + xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) : + (xmlChar *)elem->name; + + fullattrname = (attr->ns != NULL && attr->ns->prefix != NULL) ? + xmlBuildQName(attr->name, attr->ns->prefix, fattr, 50) : + (xmlChar *)attr->name; + + if (fullelemname != NULL && fullattrname != NULL) { + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullelemname, + fullattrname); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullelemname, + fullattrname); + } + + if ((fullattrname != fattr) && (fullattrname != attr->name)) + xmlFree(fullattrname); + if ((fullelemname != felem) && (fullelemname != elem->name)) + xmlFree(fullelemname); + + if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID)) + return(1); + } + return(0); +} + +/** + * xmlRemoveID: + * @doc: the document + * @attr: the attribute + * + * Remove the given attribute from the ID table maintained internally. + * + * Returns -1 if the lookup failed and 0 otherwise + */ +int +xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) { + xmlIDTablePtr table; + xmlIDPtr id; + xmlChar *ID; + + if (doc == NULL) return(-1); + if (attr == NULL) return(-1); + + table = (xmlIDTablePtr) doc->ids; + if (table == NULL) + return(-1); + + ID = xmlNodeListGetString(doc, attr->children, 1); + if (ID == NULL) + return(-1); + + id = xmlHashLookup(table, ID); + if (id == NULL || id->attr != attr) { + xmlFree(ID); + return(-1); + } + + xmlHashRemoveEntry(table, ID, xmlFreeIDTableEntry); + xmlFree(ID); + attr->atype = 0; + return(0); +} + +/** + * xmlGetID: + * @doc: pointer to the document + * @ID: the ID value + * + * Search the attribute declaring the given ID + * + * Returns NULL if not found, otherwise the xmlAttrPtr defining the ID + */ +xmlAttrPtr +xmlGetID(xmlDocPtr doc, const xmlChar *ID) { + xmlIDTablePtr table; + xmlIDPtr id; + + if (doc == NULL) { + return(NULL); + } + + if (ID == NULL) { + return(NULL); + } + + table = (xmlIDTablePtr) doc->ids; + if (table == NULL) + return(NULL); + + id = xmlHashLookup(table, ID); + if (id == NULL) + return(NULL); + if (id->attr == NULL) { + /* + * We are operating on a stream, return a well known reference + * since the attribute node doesn't exist anymore + */ + return((xmlAttrPtr) doc); + } + return(id->attr); +} + +/************************************************************************ + * * + * Refs * + * * + ************************************************************************/ +typedef struct xmlRemoveMemo_t +{ + xmlListPtr l; + xmlAttrPtr ap; +} xmlRemoveMemo; + +typedef xmlRemoveMemo *xmlRemoveMemoPtr; + +typedef struct xmlValidateMemo_t +{ + xmlValidCtxtPtr ctxt; + const xmlChar *name; +} xmlValidateMemo; + +typedef xmlValidateMemo *xmlValidateMemoPtr; + +/** + * xmlFreeRef: + * @lk: A list link + * + * Deallocate the memory used by a ref definition + */ +static void +xmlFreeRef(xmlLinkPtr lk) { + xmlRefPtr ref = (xmlRefPtr)xmlLinkGetData(lk); + if (ref == NULL) return; + if (ref->value != NULL) + xmlFree((xmlChar *)ref->value); + if (ref->name != NULL) + xmlFree((xmlChar *)ref->name); + xmlFree(ref); +} + +/** + * xmlFreeRefTableEntry: + * @list_ref: A list of references. + * + * Deallocate the memory used by a list of references + */ +static void +xmlFreeRefTableEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) { + xmlListPtr list_ref = (xmlListPtr) payload; + if (list_ref == NULL) return; + xmlListDelete(list_ref); +} + +/** + * xmlWalkRemoveRef: + * @data: Contents of current link + * @user: Value supplied by the user + * + * Returns 0 to abort the walk or 1 to continue + */ +static int +xmlWalkRemoveRef(const void *data, void *user) +{ + xmlAttrPtr attr0 = ((xmlRefPtr)data)->attr; + xmlAttrPtr attr1 = ((xmlRemoveMemoPtr)user)->ap; + xmlListPtr ref_list = ((xmlRemoveMemoPtr)user)->l; + + if (attr0 == attr1) { /* Matched: remove and terminate walk */ + xmlListRemoveFirst(ref_list, (void *)data); + return 0; + } + return 1; +} + +/** + * xmlDummyCompare + * @data0: Value supplied by the user + * @data1: Value supplied by the user + * + * Do nothing, return 0. Used to create unordered lists. + */ +static int +xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED, + const void *data1 ATTRIBUTE_UNUSED) +{ + return (0); +} + +/** + * xmlAddRef: + * @ctxt: the validation context + * @doc: pointer to the document + * @value: the value name + * @attr: the attribute holding the Ref + * + * Register a new ref declaration + * + * Returns NULL if not, otherwise the new xmlRefPtr + */ +xmlRefPtr +xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, + xmlAttrPtr attr) { + xmlRefPtr ret; + xmlRefTablePtr table; + xmlListPtr ref_list; + + if (doc == NULL) { + return(NULL); + } + if (value == NULL) { + return(NULL); + } + if (attr == NULL) { + return(NULL); + } + + /* + * Create the Ref table if needed. + */ + table = (xmlRefTablePtr) doc->refs; + if (table == NULL) { + doc->refs = table = xmlHashCreateDict(0, doc->dict); + } + if (table == NULL) { + xmlVErrMemory(ctxt, + "xmlAddRef: Table creation failed!\n"); + return(NULL); + } + + ret = (xmlRefPtr) xmlMalloc(sizeof(xmlRef)); + if (ret == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(NULL); + } + + /* + * fill the structure. + */ + ret->value = xmlStrdup(value); + if ((ctxt != NULL) && (ctxt->vstateNr != 0)) { + /* + * Operating in streaming mode, attr is gonna disappear + */ + ret->name = xmlStrdup(attr->name); + ret->attr = NULL; + } else { + ret->name = NULL; + ret->attr = attr; + } + ret->lineno = xmlGetLineNo(attr->parent); + + /* To add a reference :- + * References are maintained as a list of references, + * Lookup the entry, if no entry create new nodelist + * Add the owning node to the NodeList + * Return the ref + */ + + if (NULL == (ref_list = xmlHashLookup(table, value))) { + if (NULL == (ref_list = xmlListCreate(xmlFreeRef, xmlDummyCompare))) { + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "xmlAddRef: Reference list creation failed!\n", + NULL); + goto failed; + } + if (xmlHashAddEntry(table, value, ref_list) < 0) { + xmlListDelete(ref_list); + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "xmlAddRef: Reference list insertion failed!\n", + NULL); + goto failed; + } + } + if (xmlListAppend(ref_list, ret) != 0) { + xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, + "xmlAddRef: Reference list insertion failed!\n", + NULL); + goto failed; + } + return(ret); +failed: + if (ret != NULL) { + if (ret->value != NULL) + xmlFree((char *)ret->value); + if (ret->name != NULL) + xmlFree((char *)ret->name); + xmlFree(ret); + } + return(NULL); +} + +/** + * xmlFreeRefTable: + * @table: An ref table + * + * Deallocate the memory used by an Ref hash table. + */ +void +xmlFreeRefTable(xmlRefTablePtr table) { + xmlHashFree(table, xmlFreeRefTableEntry); +} + +/** + * xmlIsRef: + * @doc: the document + * @elem: the element carrying the attribute + * @attr: the attribute + * + * Determine whether an attribute is of type Ref. In case we have DTD(s) + * then this is simple, otherwise we use an heuristic: name Ref (upper + * or lowercase). + * + * Returns 0 or 1 depending on the lookup result + */ +int +xmlIsRef(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) { + if (attr == NULL) + return(0); + if (doc == NULL) { + doc = attr->doc; + if (doc == NULL) return(0); + } + + if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) { + return(0); + } else if (doc->type == XML_HTML_DOCUMENT_NODE) { + /* TODO @@@ */ + return(0); + } else { + xmlAttributePtr attrDecl; + + if (elem == NULL) return(0); + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, + elem->name, attr->name); + + if ((attrDecl != NULL) && + (attrDecl->atype == XML_ATTRIBUTE_IDREF || + attrDecl->atype == XML_ATTRIBUTE_IDREFS)) + return(1); + } + return(0); +} + +/** + * xmlRemoveRef: + * @doc: the document + * @attr: the attribute + * + * Remove the given attribute from the Ref table maintained internally. + * + * Returns -1 if the lookup failed and 0 otherwise + */ +int +xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) { + xmlListPtr ref_list; + xmlRefTablePtr table; + xmlChar *ID; + xmlRemoveMemo target; + + if (doc == NULL) return(-1); + if (attr == NULL) return(-1); + + table = (xmlRefTablePtr) doc->refs; + if (table == NULL) + return(-1); + + ID = xmlNodeListGetString(doc, attr->children, 1); + if (ID == NULL) + return(-1); + + ref_list = xmlHashLookup(table, ID); + if(ref_list == NULL) { + xmlFree(ID); + return (-1); + } + + /* At this point, ref_list refers to a list of references which + * have the same key as the supplied attr. Our list of references + * is ordered by reference address and we don't have that information + * here to use when removing. We'll have to walk the list and + * check for a matching attribute, when we find one stop the walk + * and remove the entry. + * The list is ordered by reference, so that means we don't have the + * key. Passing the list and the reference to the walker means we + * will have enough data to be able to remove the entry. + */ + target.l = ref_list; + target.ap = attr; + + /* Remove the supplied attr from our list */ + xmlListWalk(ref_list, xmlWalkRemoveRef, &target); + + /*If the list is empty then remove the list entry in the hash */ + if (xmlListEmpty(ref_list)) + xmlHashUpdateEntry(table, ID, NULL, xmlFreeRefTableEntry); + xmlFree(ID); + return(0); +} + +/** + * xmlGetRefs: + * @doc: pointer to the document + * @ID: the ID value + * + * Find the set of references for the supplied ID. + * + * Returns NULL if not found, otherwise node set for the ID. + */ +xmlListPtr +xmlGetRefs(xmlDocPtr doc, const xmlChar *ID) { + xmlRefTablePtr table; + + if (doc == NULL) { + return(NULL); + } + + if (ID == NULL) { + return(NULL); + } + + table = (xmlRefTablePtr) doc->refs; + if (table == NULL) + return(NULL); + + return (xmlHashLookup(table, ID)); +} + +/************************************************************************ + * * + * Routines for validity checking * + * * + ************************************************************************/ + +/** + * xmlGetDtdElementDesc: + * @dtd: a pointer to the DtD to search + * @name: the element name + * + * Search the DTD for the description of this element + * + * returns the xmlElementPtr if found or NULL + */ + +xmlElementPtr +xmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name) { + xmlElementTablePtr table; + xmlElementPtr cur; + xmlChar *uqname = NULL, *prefix = NULL; + + if ((dtd == NULL) || (name == NULL)) return(NULL); + if (dtd->elements == NULL) + return(NULL); + table = (xmlElementTablePtr) dtd->elements; + + uqname = xmlSplitQName2(name, &prefix); + if (uqname != NULL) + name = uqname; + cur = xmlHashLookup2(table, name, prefix); + if (prefix != NULL) xmlFree(prefix); + if (uqname != NULL) xmlFree(uqname); + return(cur); +} +/** + * xmlGetDtdElementDesc2: + * @dtd: a pointer to the DtD to search + * @name: the element name + * @create: create an empty description if not found + * + * Search the DTD for the description of this element + * + * returns the xmlElementPtr if found or NULL + */ + +static xmlElementPtr +xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) { + xmlElementTablePtr table; + xmlElementPtr cur; + xmlChar *uqname = NULL, *prefix = NULL; + + if (dtd == NULL) return(NULL); + if (dtd->elements == NULL) { + xmlDictPtr dict = NULL; + + if (dtd->doc != NULL) + dict = dtd->doc->dict; + + if (!create) + return(NULL); + /* + * Create the Element table if needed. + */ + table = (xmlElementTablePtr) dtd->elements; + if (table == NULL) { + table = xmlHashCreateDict(0, dict); + dtd->elements = (void *) table; + } + if (table == NULL) { + xmlVErrMemory(NULL, "element table allocation failed"); + return(NULL); + } + } + table = (xmlElementTablePtr) dtd->elements; + + uqname = xmlSplitQName2(name, &prefix); + if (uqname != NULL) + name = uqname; + cur = xmlHashLookup2(table, name, prefix); + if ((cur == NULL) && (create)) { + cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement)); + if (cur == NULL) { + xmlVErrMemory(NULL, "malloc failed"); + return(NULL); + } + memset(cur, 0, sizeof(xmlElement)); + cur->type = XML_ELEMENT_DECL; + + /* + * fill the structure. + */ + cur->name = xmlStrdup(name); + cur->prefix = xmlStrdup(prefix); + cur->etype = XML_ELEMENT_TYPE_UNDEFINED; + + xmlHashAddEntry2(table, name, prefix, cur); + } + if (prefix != NULL) xmlFree(prefix); + if (uqname != NULL) xmlFree(uqname); + return(cur); +} + +/** + * xmlGetDtdQElementDesc: + * @dtd: a pointer to the DtD to search + * @name: the element name + * @prefix: the element namespace prefix + * + * Search the DTD for the description of this element + * + * returns the xmlElementPtr if found or NULL + */ + +xmlElementPtr +xmlGetDtdQElementDesc(xmlDtdPtr dtd, const xmlChar *name, + const xmlChar *prefix) { + xmlElementTablePtr table; + + if (dtd == NULL) return(NULL); + if (dtd->elements == NULL) return(NULL); + table = (xmlElementTablePtr) dtd->elements; + + return(xmlHashLookup2(table, name, prefix)); +} + +/** + * xmlGetDtdAttrDesc: + * @dtd: a pointer to the DtD to search + * @elem: the element name + * @name: the attribute name + * + * Search the DTD for the description of this attribute on + * this element. + * + * returns the xmlAttributePtr if found or NULL + */ + +xmlAttributePtr +xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name) { + xmlAttributeTablePtr table; + xmlAttributePtr cur; + xmlChar *uqname = NULL, *prefix = NULL; + + if (dtd == NULL) return(NULL); + if (dtd->attributes == NULL) return(NULL); + + table = (xmlAttributeTablePtr) dtd->attributes; + if (table == NULL) + return(NULL); + + uqname = xmlSplitQName2(name, &prefix); + + if (uqname != NULL) { + cur = xmlHashLookup3(table, uqname, prefix, elem); + if (prefix != NULL) xmlFree(prefix); + if (uqname != NULL) xmlFree(uqname); + } else + cur = xmlHashLookup3(table, name, NULL, elem); + return(cur); +} + +/** + * xmlGetDtdQAttrDesc: + * @dtd: a pointer to the DtD to search + * @elem: the element name + * @name: the attribute name + * @prefix: the attribute namespace prefix + * + * Search the DTD for the description of this qualified attribute on + * this element. + * + * returns the xmlAttributePtr if found or NULL + */ + +xmlAttributePtr +xmlGetDtdQAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, + const xmlChar *prefix) { + xmlAttributeTablePtr table; + + if (dtd == NULL) return(NULL); + if (dtd->attributes == NULL) return(NULL); + table = (xmlAttributeTablePtr) dtd->attributes; + + return(xmlHashLookup3(table, name, prefix, elem)); +} + +/** + * xmlGetDtdNotationDesc: + * @dtd: a pointer to the DtD to search + * @name: the notation name + * + * Search the DTD for the description of this notation + * + * returns the xmlNotationPtr if found or NULL + */ + +xmlNotationPtr +xmlGetDtdNotationDesc(xmlDtdPtr dtd, const xmlChar *name) { + xmlNotationTablePtr table; + + if (dtd == NULL) return(NULL); + if (dtd->notations == NULL) return(NULL); + table = (xmlNotationTablePtr) dtd->notations; + + return(xmlHashLookup(table, name)); +} + +#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +/** + * xmlValidateNotationUse: + * @ctxt: the validation context + * @doc: the document + * @notationName: the notation name to check + * + * Validate that the given name match a notation declaration. + * - [ VC: Notation Declared ] + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateNotationUse(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + const xmlChar *notationName) { + xmlNotationPtr notaDecl; + if ((doc == NULL) || (doc->intSubset == NULL) || + (notationName == NULL)) return(-1); + + notaDecl = xmlGetDtdNotationDesc(doc->intSubset, notationName); + if ((notaDecl == NULL) && (doc->extSubset != NULL)) + notaDecl = xmlGetDtdNotationDesc(doc->extSubset, notationName); + + if ((notaDecl == NULL) && (ctxt != NULL)) { + xmlErrValidNode(ctxt, (xmlNodePtr) doc, XML_DTD_UNKNOWN_NOTATION, + "NOTATION %s is not declared\n", + notationName, NULL, NULL); + return(0); + } + return(1); +} +#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */ + +/** + * xmlIsMixedElement: + * @doc: the document + * @name: the element name + * + * Search in the DtDs whether an element accept Mixed content (or ANY) + * basically if it is supposed to accept text childs + * + * returns 0 if no, 1 if yes, and -1 if no element description is available + */ + +int +xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) { + xmlElementPtr elemDecl; + + if ((doc == NULL) || (doc->intSubset == NULL)) return(-1); + + elemDecl = xmlGetDtdElementDesc(doc->intSubset, name); + if ((elemDecl == NULL) && (doc->extSubset != NULL)) + elemDecl = xmlGetDtdElementDesc(doc->extSubset, name); + if (elemDecl == NULL) return(-1); + switch (elemDecl->etype) { + case XML_ELEMENT_TYPE_UNDEFINED: + return(-1); + case XML_ELEMENT_TYPE_ELEMENT: + return(0); + case XML_ELEMENT_TYPE_EMPTY: + /* + * return 1 for EMPTY since we want VC error to pop up + * on for example + */ + case XML_ELEMENT_TYPE_ANY: + case XML_ELEMENT_TYPE_MIXED: + return(1); + } + return(1); +} + +#ifdef LIBXML_VALID_ENABLED + +static int +xmlIsDocNameStartChar(xmlDocPtr doc, int c) { + if ((doc == NULL) || (doc->properties & XML_DOC_OLD10) == 0) { + /* + * Use the new checks of production [4] [4a] amd [5] of the + * Update 5 of XML-1.0 + */ + if (((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + (c == '_') || (c == ':') || + ((c >= 0xC0) && (c <= 0xD6)) || + ((c >= 0xD8) && (c <= 0xF6)) || + ((c >= 0xF8) && (c <= 0x2FF)) || + ((c >= 0x370) && (c <= 0x37D)) || + ((c >= 0x37F) && (c <= 0x1FFF)) || + ((c >= 0x200C) && (c <= 0x200D)) || + ((c >= 0x2070) && (c <= 0x218F)) || + ((c >= 0x2C00) && (c <= 0x2FEF)) || + ((c >= 0x3001) && (c <= 0xD7FF)) || + ((c >= 0xF900) && (c <= 0xFDCF)) || + ((c >= 0xFDF0) && (c <= 0xFFFD)) || + ((c >= 0x10000) && (c <= 0xEFFFF))) + return(1); + } else { + if (IS_LETTER(c) || (c == '_') || (c == ':')) + return(1); + } + return(0); +} + +static int +xmlIsDocNameChar(xmlDocPtr doc, int c) { + if ((doc == NULL) || (doc->properties & XML_DOC_OLD10) == 0) { + /* + * Use the new checks of production [4] [4a] amd [5] of the + * Update 5 of XML-1.0 + */ + if (((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + ((c >= '0') && (c <= '9')) || /* !start */ + (c == '_') || (c == ':') || + (c == '-') || (c == '.') || (c == 0xB7) || /* !start */ + ((c >= 0xC0) && (c <= 0xD6)) || + ((c >= 0xD8) && (c <= 0xF6)) || + ((c >= 0xF8) && (c <= 0x2FF)) || + ((c >= 0x300) && (c <= 0x36F)) || /* !start */ + ((c >= 0x370) && (c <= 0x37D)) || + ((c >= 0x37F) && (c <= 0x1FFF)) || + ((c >= 0x200C) && (c <= 0x200D)) || + ((c >= 0x203F) && (c <= 0x2040)) || /* !start */ + ((c >= 0x2070) && (c <= 0x218F)) || + ((c >= 0x2C00) && (c <= 0x2FEF)) || + ((c >= 0x3001) && (c <= 0xD7FF)) || + ((c >= 0xF900) && (c <= 0xFDCF)) || + ((c >= 0xFDF0) && (c <= 0xFFFD)) || + ((c >= 0x10000) && (c <= 0xEFFFF))) + return(1); + } else { + if ((IS_LETTER(c)) || (IS_DIGIT(c)) || + (c == '.') || (c == '-') || + (c == '_') || (c == ':') || + (IS_COMBINING(c)) || + (IS_EXTENDER(c))) + return(1); + } + return(0); +} + +/** + * xmlValidateNameValue: + * @doc: pointer to the document or NULL + * @value: an Name value + * + * Validate that the given value match Name production + * + * returns 1 if valid or 0 otherwise + */ + +static int +xmlValidateNameValueInternal(xmlDocPtr doc, const xmlChar *value) { + const xmlChar *cur; + int val, len; + + if (value == NULL) return(0); + cur = value; + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + if (!xmlIsDocNameStartChar(doc, val)) + return(0); + + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + while (xmlIsDocNameChar(doc, val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + + if (val != 0) return(0); + + return(1); +} + +/** + * xmlValidateNameValue: + * @value: an Name value + * + * Validate that the given value match Name production + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateNameValue(const xmlChar *value) { + return(xmlValidateNameValueInternal(NULL, value)); +} + +/** + * xmlValidateNamesValueInternal: + * @doc: pointer to the document or NULL + * @value: an Names value + * + * Validate that the given value match Names production + * + * returns 1 if valid or 0 otherwise + */ + +static int +xmlValidateNamesValueInternal(xmlDocPtr doc, const xmlChar *value) { + const xmlChar *cur; + int val, len; + + if (value == NULL) return(0); + cur = value; + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + + if (!xmlIsDocNameStartChar(doc, val)) + return(0); + + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + while (xmlIsDocNameChar(doc, val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + + /* Should not test IS_BLANK(val) here -- see erratum E20*/ + while (val == 0x20) { + while (val == 0x20) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + + if (!xmlIsDocNameStartChar(doc, val)) + return(0); + + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + + while (xmlIsDocNameChar(doc, val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + } + + if (val != 0) return(0); + + return(1); +} + +/** + * xmlValidateNamesValue: + * @value: an Names value + * + * Validate that the given value match Names production + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateNamesValue(const xmlChar *value) { + return(xmlValidateNamesValueInternal(NULL, value)); +} + +/** + * xmlValidateNmtokenValueInternal: + * @doc: pointer to the document or NULL + * @value: an Nmtoken value + * + * Validate that the given value match Nmtoken production + * + * [ VC: Name Token ] + * + * returns 1 if valid or 0 otherwise + */ + +static int +xmlValidateNmtokenValueInternal(xmlDocPtr doc, const xmlChar *value) { + const xmlChar *cur; + int val, len; + + if (value == NULL) return(0); + cur = value; + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + + if (!xmlIsDocNameChar(doc, val)) + return(0); + + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + while (xmlIsDocNameChar(doc, val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + + if (val != 0) return(0); + + return(1); +} + +/** + * xmlValidateNmtokenValue: + * @value: an Nmtoken value + * + * Validate that the given value match Nmtoken production + * + * [ VC: Name Token ] + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateNmtokenValue(const xmlChar *value) { + return(xmlValidateNmtokenValueInternal(NULL, value)); +} + +/** + * xmlValidateNmtokensValueInternal: + * @doc: pointer to the document or NULL + * @value: an Nmtokens value + * + * Validate that the given value match Nmtokens production + * + * [ VC: Name Token ] + * + * returns 1 if valid or 0 otherwise + */ + +static int +xmlValidateNmtokensValueInternal(xmlDocPtr doc, const xmlChar *value) { + const xmlChar *cur; + int val, len; + + if (value == NULL) return(0); + cur = value; + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + + while (IS_BLANK(val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + + if (!xmlIsDocNameChar(doc, val)) + return(0); + + while (xmlIsDocNameChar(doc, val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + + /* Should not test IS_BLANK(val) here -- see erratum E20*/ + while (val == 0x20) { + while (val == 0x20) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + if (val == 0) return(1); + + if (!xmlIsDocNameChar(doc, val)) + return(0); + + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + + while (xmlIsDocNameChar(doc, val)) { + val = xmlStringCurrentChar(NULL, cur, &len); + cur += len; + } + } + + if (val != 0) return(0); + + return(1); +} + +/** + * xmlValidateNmtokensValue: + * @value: an Nmtokens value + * + * Validate that the given value match Nmtokens production + * + * [ VC: Name Token ] + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateNmtokensValue(const xmlChar *value) { + return(xmlValidateNmtokensValueInternal(NULL, value)); +} + +/** + * xmlValidateNotationDecl: + * @ctxt: the validation context + * @doc: a document instance + * @nota: a notation definition + * + * Try to validate a single notation definition + * basically it does the following checks as described by the + * XML-1.0 recommendation: + * - it seems that no validity constraint exists on notation declarations + * But this function get called anyway ... + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATTRIBUTE_UNUSED, + xmlNotationPtr nota ATTRIBUTE_UNUSED) { + int ret = 1; + + return(ret); +} + +/** + * xmlValidateAttributeValueInternal: + * @doc: the document + * @type: an attribute type + * @value: an attribute value + * + * Validate that the given attribute value match the proper production + * + * returns 1 if valid or 0 otherwise + */ + +static int +xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type, + const xmlChar *value) { + switch (type) { + case XML_ATTRIBUTE_ENTITIES: + case XML_ATTRIBUTE_IDREFS: + return(xmlValidateNamesValueInternal(doc, value)); + case XML_ATTRIBUTE_ENTITY: + case XML_ATTRIBUTE_IDREF: + case XML_ATTRIBUTE_ID: + case XML_ATTRIBUTE_NOTATION: + return(xmlValidateNameValueInternal(doc, value)); + case XML_ATTRIBUTE_NMTOKENS: + case XML_ATTRIBUTE_ENUMERATION: + return(xmlValidateNmtokensValueInternal(doc, value)); + case XML_ATTRIBUTE_NMTOKEN: + return(xmlValidateNmtokenValueInternal(doc, value)); + case XML_ATTRIBUTE_CDATA: + break; + } + return(1); +} + +/** + * xmlValidateAttributeValue: + * @type: an attribute type + * @value: an attribute value + * + * Validate that the given attribute value match the proper production + * + * [ VC: ID ] + * Values of type ID must match the Name production.... + * + * [ VC: IDREF ] + * Values of type IDREF must match the Name production, and values + * of type IDREFS must match Names ... + * + * [ VC: Entity Name ] + * Values of type ENTITY must match the Name production, values + * of type ENTITIES must match Names ... + * + * [ VC: Name Token ] + * Values of type NMTOKEN must match the Nmtoken production; values + * of type NMTOKENS must match Nmtokens. + * + * returns 1 if valid or 0 otherwise + */ +int +xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) { + return(xmlValidateAttributeValueInternal(NULL, type, value)); +} + +/** + * xmlValidateAttributeValue2: + * @ctxt: the validation context + * @doc: the document + * @name: the attribute name (used for error reporting only) + * @type: the attribute type + * @value: the attribute value + * + * Validate that the given attribute value match a given type. + * This typically cannot be done before having finished parsing + * the subsets. + * + * [ VC: IDREF ] + * Values of type IDREF must match one of the declared IDs + * Values of type IDREFS must match a sequence of the declared IDs + * each Name must match the value of an ID attribute on some element + * in the XML document; i.e. IDREF values must match the value of + * some ID attribute + * + * [ VC: Entity Name ] + * Values of type ENTITY must match one declared entity + * Values of type ENTITIES must match a sequence of declared entities + * + * [ VC: Notation Attributes ] + * all notation names in the declaration must be declared. + * + * returns 1 if valid or 0 otherwise + */ + +static int +xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + const xmlChar *name, xmlAttributeType type, const xmlChar *value) { + int ret = 1; + switch (type) { + case XML_ATTRIBUTE_IDREFS: + case XML_ATTRIBUTE_IDREF: + case XML_ATTRIBUTE_ID: + case XML_ATTRIBUTE_NMTOKENS: + case XML_ATTRIBUTE_ENUMERATION: + case XML_ATTRIBUTE_NMTOKEN: + case XML_ATTRIBUTE_CDATA: + break; + case XML_ATTRIBUTE_ENTITY: { + xmlEntityPtr ent; + + ent = xmlGetDocEntity(doc, value); + /* yeah it's a bit messy... */ + if ((ent == NULL) && (doc->standalone == 1)) { + doc->standalone = 0; + ent = xmlGetDocEntity(doc, value); + } + if (ent == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) doc, + XML_DTD_UNKNOWN_ENTITY, + "ENTITY attribute %s reference an unknown entity \"%s\"\n", + name, value, NULL); + ret = 0; + } else if (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { + xmlErrValidNode(ctxt, (xmlNodePtr) doc, + XML_DTD_ENTITY_TYPE, + "ENTITY attribute %s reference an entity \"%s\" of wrong type\n", + name, value, NULL); + ret = 0; + } + break; + } + case XML_ATTRIBUTE_ENTITIES: { + xmlChar *dup, *nam = NULL, *cur, save; + xmlEntityPtr ent; + + dup = xmlStrdup(value); + if (dup == NULL) + return(0); + cur = dup; + while (*cur != 0) { + nam = cur; + while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++; + save = *cur; + *cur = 0; + ent = xmlGetDocEntity(doc, nam); + if (ent == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) doc, + XML_DTD_UNKNOWN_ENTITY, + "ENTITIES attribute %s reference an unknown entity \"%s\"\n", + name, nam, NULL); + ret = 0; + } else if (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { + xmlErrValidNode(ctxt, (xmlNodePtr) doc, + XML_DTD_ENTITY_TYPE, + "ENTITIES attribute %s reference an entity \"%s\" of wrong type\n", + name, nam, NULL); + ret = 0; + } + if (save == 0) + break; + *cur = save; + while (IS_BLANK_CH(*cur)) cur++; + } + xmlFree(dup); + break; + } + case XML_ATTRIBUTE_NOTATION: { + xmlNotationPtr nota; + + nota = xmlGetDtdNotationDesc(doc->intSubset, value); + if ((nota == NULL) && (doc->extSubset != NULL)) + nota = xmlGetDtdNotationDesc(doc->extSubset, value); + + if (nota == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) doc, + XML_DTD_UNKNOWN_NOTATION, + "NOTATION attribute %s reference an unknown notation \"%s\"\n", + name, value, NULL); + ret = 0; + } + break; + } + } + return(ret); +} + +/** + * xmlValidCtxtNormalizeAttributeValue: + * @ctxt: the validation context + * @doc: the document + * @elem: the parent + * @name: the attribute name + * @value: the attribute value + * @ctxt: the validation context or NULL + * + * Does the validation related extra step of the normalization of attribute + * values: + * + * If the declared value is not CDATA, then the XML processor must further + * process the normalized attribute value by discarding any leading and + * trailing space (#x20) characters, and by replacing sequences of space + * (#x20) characters by single space (#x20) character. + * + * Also check VC: Standalone Document Declaration in P32, and update + * ctxt->valid accordingly + * + * returns a new normalized string if normalization is needed, NULL otherwise + * the caller must free the returned value. + */ + +xmlChar * +xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr elem, const xmlChar *name, const xmlChar *value) { + xmlChar *ret, *dst; + const xmlChar *src; + xmlAttributePtr attrDecl = NULL; + int extsubset = 0; + + if (doc == NULL) return(NULL); + if (elem == NULL) return(NULL); + if (name == NULL) return(NULL); + if (value == NULL) return(NULL); + + if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); + if (fullname == NULL) + return(NULL); + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) { + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name); + if (attrDecl != NULL) + extsubset = 1; + } + if ((fullname != fn) && (fullname != elem->name)) + xmlFree(fullname); + } + if ((attrDecl == NULL) && (doc->intSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) { + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name, name); + if (attrDecl != NULL) + extsubset = 1; + } + + if (attrDecl == NULL) + return(NULL); + if (attrDecl->atype == XML_ATTRIBUTE_CDATA) + return(NULL); + + ret = xmlStrdup(value); + if (ret == NULL) + return(NULL); + src = value; + dst = ret; + while (*src == 0x20) src++; + while (*src != 0) { + if (*src == 0x20) { + while (*src == 0x20) src++; + if (*src != 0) + *dst++ = 0x20; + } else { + *dst++ = *src++; + } + } + *dst = 0; + if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) { + xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE, +"standalone: %s on %s value had to be normalized based on external subset declaration\n", + name, elem->name, NULL); + ctxt->valid = 0; + } + return(ret); +} + +/** + * xmlValidNormalizeAttributeValue: + * @doc: the document + * @elem: the parent + * @name: the attribute name + * @value: the attribute value + * + * Does the validation related extra step of the normalization of attribute + * values: + * + * If the declared value is not CDATA, then the XML processor must further + * process the normalized attribute value by discarding any leading and + * trailing space (#x20) characters, and by replacing sequences of space + * (#x20) characters by single space (#x20) character. + * + * Returns a new normalized string if normalization is needed, NULL otherwise + * the caller must free the returned value. + */ + +xmlChar * +xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem, + const xmlChar *name, const xmlChar *value) { + xmlChar *ret, *dst; + const xmlChar *src; + xmlAttributePtr attrDecl = NULL; + + if (doc == NULL) return(NULL); + if (elem == NULL) return(NULL); + if (name == NULL) return(NULL); + if (value == NULL) return(NULL); + + if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); + if (fullname == NULL) + return(NULL); + if ((fullname != fn) && (fullname != elem->name)) + xmlFree(fullname); + } + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name, name); + + if (attrDecl == NULL) + return(NULL); + if (attrDecl->atype == XML_ATTRIBUTE_CDATA) + return(NULL); + + ret = xmlStrdup(value); + if (ret == NULL) + return(NULL); + src = value; + dst = ret; + while (*src == 0x20) src++; + while (*src != 0) { + if (*src == 0x20) { + while (*src == 0x20) src++; + if (*src != 0) + *dst++ = 0x20; + } else { + *dst++ = *src++; + } + } + *dst = 0; + return(ret); +} + +static void +xmlValidateAttributeIdCallback(void *payload, void *data, + const xmlChar *name ATTRIBUTE_UNUSED) { + xmlAttributePtr attr = (xmlAttributePtr) payload; + int *count = (int *) data; + if (attr->atype == XML_ATTRIBUTE_ID) (*count)++; +} + +/** + * xmlValidateAttributeDecl: + * @ctxt: the validation context + * @doc: a document instance + * @attr: an attribute definition + * + * Try to validate a single attribute definition + * basically it does the following checks as described by the + * XML-1.0 recommendation: + * - [ VC: Attribute Default Legal ] + * - [ VC: Enumeration ] + * - [ VC: ID Attribute Default ] + * + * The ID/IDREF uniqueness and matching are done separately + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlAttributePtr attr) { + int ret = 1; + int val; + CHECK_DTD; + if(attr == NULL) return(1); + + /* Attribute Default Legal */ + /* Enumeration */ + if (attr->defaultValue != NULL) { + val = xmlValidateAttributeValueInternal(doc, attr->atype, + attr->defaultValue); + if (val == 0) { + xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_DEFAULT, + "Syntax of default value for attribute %s of %s is not valid\n", + attr->name, attr->elem, NULL); + } + ret &= val; + } + + /* ID Attribute Default */ + if ((attr->atype == XML_ATTRIBUTE_ID)&& + (attr->def != XML_ATTRIBUTE_IMPLIED) && + (attr->def != XML_ATTRIBUTE_REQUIRED)) { + xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ID_FIXED, + "ID attribute %s of %s is not valid must be #IMPLIED or #REQUIRED\n", + attr->name, attr->elem, NULL); + ret = 0; + } + + /* One ID per Element Type */ + if (attr->atype == XML_ATTRIBUTE_ID) { + int nbId; + + /* the trick is that we parse DtD as their own internal subset */ + xmlElementPtr elem = xmlGetDtdElementDesc(doc->intSubset, + attr->elem); + if (elem != NULL) { + nbId = xmlScanIDAttributeDecl(NULL, elem, 0); + } else { + xmlAttributeTablePtr table; + + /* + * The attribute may be declared in the internal subset and the + * element in the external subset. + */ + nbId = 0; + if (doc->intSubset != NULL) { + table = (xmlAttributeTablePtr) doc->intSubset->attributes; + xmlHashScan3(table, NULL, NULL, attr->elem, + xmlValidateAttributeIdCallback, &nbId); + } + } + if (nbId > 1) { + + xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET, + "Element %s has %d ID attribute defined in the internal subset : %s\n", + attr->elem, nbId, attr->name); + } else if (doc->extSubset != NULL) { + int extId = 0; + elem = xmlGetDtdElementDesc(doc->extSubset, attr->elem); + if (elem != NULL) { + extId = xmlScanIDAttributeDecl(NULL, elem, 0); + } + if (extId > 1) { + xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET, + "Element %s has %d ID attribute defined in the external subset : %s\n", + attr->elem, extId, attr->name); + } else if (extId + nbId > 1) { + xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET, +"Element %s has ID attributes defined in the internal and external subset : %s\n", + attr->elem, attr->name, NULL); + } + } + } + + /* Validity Constraint: Enumeration */ + if ((attr->defaultValue != NULL) && (attr->tree != NULL)) { + xmlEnumerationPtr tree = attr->tree; + while (tree != NULL) { + if (xmlStrEqual(tree->name, attr->defaultValue)) break; + tree = tree->next; + } + if (tree == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_VALUE, +"Default value \"%s\" for attribute %s of %s is not among the enumerated set\n", + attr->defaultValue, attr->name, attr->elem); + ret = 0; + } + } + + return(ret); +} + +/** + * xmlValidateElementDecl: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element definition + * + * Try to validate a single element definition + * basically it does the following checks as described by the + * XML-1.0 recommendation: + * - [ VC: One ID per Element Type ] + * - [ VC: No Duplicate Types ] + * - [ VC: Unique Element Type Declaration ] + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlElementPtr elem) { + int ret = 1; + xmlElementPtr tst; + + CHECK_DTD; + + if (elem == NULL) return(1); + +#if 0 +#ifdef LIBXML_REGEXP_ENABLED + /* Build the regexp associated to the content model */ + ret = xmlValidBuildContentModel(ctxt, elem); +#endif +#endif + + /* No Duplicate Types */ + if (elem->etype == XML_ELEMENT_TYPE_MIXED) { + xmlElementContentPtr cur, next; + const xmlChar *name; + + cur = elem->content; + while (cur != NULL) { + if (cur->type != XML_ELEMENT_CONTENT_OR) break; + if (cur->c1 == NULL) break; + if (cur->c1->type == XML_ELEMENT_CONTENT_ELEMENT) { + name = cur->c1->name; + next = cur->c2; + while (next != NULL) { + if (next->type == XML_ELEMENT_CONTENT_ELEMENT) { + if ((xmlStrEqual(next->name, name)) && + (xmlStrEqual(next->prefix, cur->c1->prefix))) { + if (cur->c1->prefix == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, + "Definition of %s has duplicate references of %s\n", + elem->name, name, NULL); + } else { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, + "Definition of %s has duplicate references of %s:%s\n", + elem->name, cur->c1->prefix, name); + } + ret = 0; + } + break; + } + if (next->c1 == NULL) break; + if (next->c1->type != XML_ELEMENT_CONTENT_ELEMENT) break; + if ((xmlStrEqual(next->c1->name, name)) && + (xmlStrEqual(next->c1->prefix, cur->c1->prefix))) { + if (cur->c1->prefix == NULL) { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, + "Definition of %s has duplicate references to %s\n", + elem->name, name, NULL); + } else { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, + "Definition of %s has duplicate references to %s:%s\n", + elem->name, cur->c1->prefix, name); + } + ret = 0; + } + next = next->c2; + } + } + cur = cur->c2; + } + } + + /* VC: Unique Element Type Declaration */ + tst = xmlGetDtdElementDesc(doc->intSubset, elem->name); + if ((tst != NULL ) && (tst != elem) && + ((tst->prefix == elem->prefix) || + (xmlStrEqual(tst->prefix, elem->prefix))) && + (tst->etype != XML_ELEMENT_TYPE_UNDEFINED)) { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_ELEM_REDEFINED, + "Redefinition of element %s\n", + elem->name, NULL, NULL); + ret = 0; + } + tst = xmlGetDtdElementDesc(doc->extSubset, elem->name); + if ((tst != NULL ) && (tst != elem) && + ((tst->prefix == elem->prefix) || + (xmlStrEqual(tst->prefix, elem->prefix))) && + (tst->etype != XML_ELEMENT_TYPE_UNDEFINED)) { + xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_ELEM_REDEFINED, + "Redefinition of element %s\n", + elem->name, NULL, NULL); + ret = 0; + } + /* One ID per Element Type + * already done when registering the attribute + if (xmlScanIDAttributeDecl(ctxt, elem) > 1) { + ret = 0; + } */ + return(ret); +} + +/** + * xmlValidateOneAttribute: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * @attr: an attribute instance + * @value: the attribute value (without entities processing) + * + * Try to validate a single attribute for an element + * basically it does the following checks as described by the + * XML-1.0 recommendation: + * - [ VC: Attribute Value Type ] + * - [ VC: Fixed Attribute Default ] + * - [ VC: Entity Name ] + * - [ VC: Name Token ] + * - [ VC: ID ] + * - [ VC: IDREF ] + * - [ VC: Entity Name ] + * - [ VC: Notation Attributes ] + * + * The ID/IDREF uniqueness and matching are done separately + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value) +{ + xmlAttributePtr attrDecl = NULL; + int val; + int ret = 1; + + CHECK_DTD; + if ((elem == NULL) || (elem->name == NULL)) return(0); + if ((attr == NULL) || (attr->name == NULL)) return(0); + + if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); + if (fullname == NULL) + return(0); + if (attr->ns != NULL) { + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, + attr->name, attr->ns->prefix); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, + attr->name, attr->ns->prefix); + } else { + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, attr->name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, + fullname, attr->name); + } + if ((fullname != fn) && (fullname != elem->name)) + xmlFree(fullname); + } + if (attrDecl == NULL) { + if (attr->ns != NULL) { + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elem->name, + attr->name, attr->ns->prefix); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elem->name, + attr->name, attr->ns->prefix); + } else { + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, + elem->name, attr->name); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, + elem->name, attr->name); + } + } + + + /* Validity Constraint: Attribute Value Type */ + if (attrDecl == NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE, + "No declaration for attribute %s of element %s\n", + attr->name, elem->name, NULL); + return(0); + } + attr->atype = attrDecl->atype; + + val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value); + if (val == 0) { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE, + "Syntax of value for attribute %s of %s is not valid\n", + attr->name, elem->name, NULL); + ret = 0; + } + + /* Validity constraint: Fixed Attribute Default */ + if (attrDecl->def == XML_ATTRIBUTE_FIXED) { + if (!xmlStrEqual(value, attrDecl->defaultValue)) { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_DEFAULT, + "Value for attribute %s of %s is different from default \"%s\"\n", + attr->name, elem->name, attrDecl->defaultValue); + ret = 0; + } + } + + /* Validity Constraint: ID uniqueness */ + if (attrDecl->atype == XML_ATTRIBUTE_ID) { + if (xmlAddID(ctxt, doc, value, attr) == NULL) + ret = 0; + } + + if ((attrDecl->atype == XML_ATTRIBUTE_IDREF) || + (attrDecl->atype == XML_ATTRIBUTE_IDREFS)) { + if (xmlAddRef(ctxt, doc, value, attr) == NULL) + ret = 0; + } + + /* Validity Constraint: Notation Attributes */ + if (attrDecl->atype == XML_ATTRIBUTE_NOTATION) { + xmlEnumerationPtr tree = attrDecl->tree; + xmlNotationPtr nota; + + /* First check that the given NOTATION was declared */ + nota = xmlGetDtdNotationDesc(doc->intSubset, value); + if (nota == NULL) + nota = xmlGetDtdNotationDesc(doc->extSubset, value); + + if (nota == NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, + "Value \"%s\" for attribute %s of %s is not a declared Notation\n", + value, attr->name, elem->name); + ret = 0; + } + + /* Second, verify that it's among the list */ + while (tree != NULL) { + if (xmlStrEqual(tree->name, value)) break; + tree = tree->next; + } + if (tree == NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_NOTATION_VALUE, +"Value \"%s\" for attribute %s of %s is not among the enumerated notations\n", + value, attr->name, elem->name); + ret = 0; + } + } + + /* Validity Constraint: Enumeration */ + if (attrDecl->atype == XML_ATTRIBUTE_ENUMERATION) { + xmlEnumerationPtr tree = attrDecl->tree; + while (tree != NULL) { + if (xmlStrEqual(tree->name, value)) break; + tree = tree->next; + } + if (tree == NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE, + "Value \"%s\" for attribute %s of %s is not among the enumerated set\n", + value, attr->name, elem->name); + ret = 0; + } + } + + /* Fixed Attribute Default */ + if ((attrDecl->def == XML_ATTRIBUTE_FIXED) && + (!xmlStrEqual(attrDecl->defaultValue, value))) { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE, + "Value for attribute %s of %s must be \"%s\"\n", + attr->name, elem->name, attrDecl->defaultValue); + ret = 0; + } + + /* Extra check for the attribute value */ + ret &= xmlValidateAttributeValue2(ctxt, doc, attr->name, + attrDecl->atype, value); + + return(ret); +} + +/** + * xmlValidateOneNamespace: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * @prefix: the namespace prefix + * @ns: an namespace declaration instance + * @value: the attribute value (without entities processing) + * + * Try to validate a single namespace declaration for an element + * basically it does the following checks as described by the + * XML-1.0 recommendation: + * - [ VC: Attribute Value Type ] + * - [ VC: Fixed Attribute Default ] + * - [ VC: Entity Name ] + * - [ VC: Name Token ] + * - [ VC: ID ] + * - [ VC: IDREF ] + * - [ VC: Entity Name ] + * - [ VC: Notation Attributes ] + * + * The ID/IDREF uniqueness and matching are done separately + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateOneNamespace(xmlValidCtxtPtr ctxt, xmlDocPtr doc, +xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) { + /* xmlElementPtr elemDecl; */ + xmlAttributePtr attrDecl = NULL; + int val; + int ret = 1; + + CHECK_DTD; + if ((elem == NULL) || (elem->name == NULL)) return(0); + if ((ns == NULL) || (ns->href == NULL)) return(0); + + if (prefix != NULL) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(elem->name, prefix, fn, 50); + if (fullname == NULL) { + xmlVErrMemory(ctxt, "Validating namespace"); + return(0); + } + if (ns->prefix != NULL) { + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, + ns->prefix, BAD_CAST "xmlns"); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, + ns->prefix, BAD_CAST "xmlns"); + } else { + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, + BAD_CAST "xmlns"); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, + BAD_CAST "xmlns"); + } + if ((fullname != fn) && (fullname != elem->name)) + xmlFree(fullname); + } + if (attrDecl == NULL) { + if (ns->prefix != NULL) { + attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elem->name, + ns->prefix, BAD_CAST "xmlns"); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elem->name, + ns->prefix, BAD_CAST "xmlns"); + } else { + attrDecl = xmlGetDtdAttrDesc(doc->intSubset, + elem->name, BAD_CAST "xmlns"); + if ((attrDecl == NULL) && (doc->extSubset != NULL)) + attrDecl = xmlGetDtdAttrDesc(doc->extSubset, + elem->name, BAD_CAST "xmlns"); + } + } + + + /* Validity Constraint: Attribute Value Type */ + if (attrDecl == NULL) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE, + "No declaration for attribute xmlns:%s of element %s\n", + ns->prefix, elem->name, NULL); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE, + "No declaration for attribute xmlns of element %s\n", + elem->name, NULL, NULL); + } + return(0); + } + + val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value); + if (val == 0) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_DEFAULT, + "Syntax of value for attribute xmlns:%s of %s is not valid\n", + ns->prefix, elem->name, NULL); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_DEFAULT, + "Syntax of value for attribute xmlns of %s is not valid\n", + elem->name, NULL, NULL); + } + ret = 0; + } + + /* Validity constraint: Fixed Attribute Default */ + if (attrDecl->def == XML_ATTRIBUTE_FIXED) { + if (!xmlStrEqual(value, attrDecl->defaultValue)) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_DEFAULT, + "Value for attribute xmlns:%s of %s is different from default \"%s\"\n", + ns->prefix, elem->name, attrDecl->defaultValue); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_DEFAULT, + "Value for attribute xmlns of %s is different from default \"%s\"\n", + elem->name, attrDecl->defaultValue, NULL); + } + ret = 0; + } + } + + /* + * Casting ns to xmlAttrPtr is wrong. We'd need separate functions + * xmlAddID and xmlAddRef for namespace declarations, but it makes + * no practical sense to use ID types anyway. + */ +#if 0 + /* Validity Constraint: ID uniqueness */ + if (attrDecl->atype == XML_ATTRIBUTE_ID) { + if (xmlAddID(ctxt, doc, value, (xmlAttrPtr) ns) == NULL) + ret = 0; + } + + if ((attrDecl->atype == XML_ATTRIBUTE_IDREF) || + (attrDecl->atype == XML_ATTRIBUTE_IDREFS)) { + if (xmlAddRef(ctxt, doc, value, (xmlAttrPtr) ns) == NULL) + ret = 0; + } +#endif + + /* Validity Constraint: Notation Attributes */ + if (attrDecl->atype == XML_ATTRIBUTE_NOTATION) { + xmlEnumerationPtr tree = attrDecl->tree; + xmlNotationPtr nota; + + /* First check that the given NOTATION was declared */ + nota = xmlGetDtdNotationDesc(doc->intSubset, value); + if (nota == NULL) + nota = xmlGetDtdNotationDesc(doc->extSubset, value); + + if (nota == NULL) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, + "Value \"%s\" for attribute xmlns:%s of %s is not a declared Notation\n", + value, ns->prefix, elem->name); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, + "Value \"%s\" for attribute xmlns of %s is not a declared Notation\n", + value, elem->name, NULL); + } + ret = 0; + } + + /* Second, verify that it's among the list */ + while (tree != NULL) { + if (xmlStrEqual(tree->name, value)) break; + tree = tree->next; + } + if (tree == NULL) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_NOTATION_VALUE, +"Value \"%s\" for attribute xmlns:%s of %s is not among the enumerated notations\n", + value, ns->prefix, elem->name); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_NOTATION_VALUE, +"Value \"%s\" for attribute xmlns of %s is not among the enumerated notations\n", + value, elem->name, NULL); + } + ret = 0; + } + } + + /* Validity Constraint: Enumeration */ + if (attrDecl->atype == XML_ATTRIBUTE_ENUMERATION) { + xmlEnumerationPtr tree = attrDecl->tree; + while (tree != NULL) { + if (xmlStrEqual(tree->name, value)) break; + tree = tree->next; + } + if (tree == NULL) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE, +"Value \"%s\" for attribute xmlns:%s of %s is not among the enumerated set\n", + value, ns->prefix, elem->name); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE, +"Value \"%s\" for attribute xmlns of %s is not among the enumerated set\n", + value, elem->name, NULL); + } + ret = 0; + } + } + + /* Fixed Attribute Default */ + if ((attrDecl->def == XML_ATTRIBUTE_FIXED) && + (!xmlStrEqual(attrDecl->defaultValue, value))) { + if (ns->prefix != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_ELEM_NAMESPACE, + "Value for attribute xmlns:%s of %s must be \"%s\"\n", + ns->prefix, elem->name, attrDecl->defaultValue); + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_ELEM_NAMESPACE, + "Value for attribute xmlns of %s must be \"%s\"\n", + elem->name, attrDecl->defaultValue, NULL); + } + ret = 0; + } + + /* Extra check for the attribute value */ + if (ns->prefix != NULL) { + ret &= xmlValidateAttributeValue2(ctxt, doc, ns->prefix, + attrDecl->atype, value); + } else { + ret &= xmlValidateAttributeValue2(ctxt, doc, BAD_CAST "xmlns", + attrDecl->atype, value); + } + + return(ret); +} + +#ifndef LIBXML_REGEXP_ENABLED +/** + * xmlValidateSkipIgnorable: + * @ctxt: the validation context + * @child: the child list + * + * Skip ignorable elements w.r.t. the validation process + * + * returns the first element to consider for validation of the content model + */ + +static xmlNodePtr +xmlValidateSkipIgnorable(xmlNodePtr child) { + while (child != NULL) { + switch (child->type) { + /* These things are ignored (skipped) during validation. */ + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + child = child->next; + break; + case XML_TEXT_NODE: + if (xmlIsBlankNode(child)) + child = child->next; + else + return(child); + break; + /* keep current node */ + default: + return(child); + } + } + return(child); +} + +/** + * xmlValidateElementType: + * @ctxt: the validation context + * + * Try to validate the content model of an element internal function + * + * returns 1 if valid or 0 ,-1 in case of error, -2 if an entity + * reference is found and -3 if the validation succeeded but + * the content model is not determinist. + */ + +static int +xmlValidateElementType(xmlValidCtxtPtr ctxt) { + int ret = -1; + int determinist = 1; + + NODE = xmlValidateSkipIgnorable(NODE); + if ((NODE == NULL) && (CONT == NULL)) + return(1); + if ((NODE == NULL) && + ((CONT->ocur == XML_ELEMENT_CONTENT_MULT) || + (CONT->ocur == XML_ELEMENT_CONTENT_OPT))) { + return(1); + } + if (CONT == NULL) return(-1); + if ((NODE != NULL) && (NODE->type == XML_ENTITY_REF_NODE)) + return(-2); + + /* + * We arrive here when more states need to be examined + */ +cont: + + /* + * We just recovered from a rollback generated by a possible + * epsilon transition, go directly to the analysis phase + */ + if (STATE == ROLLBACK_PARENT) { + DEBUG_VALID_MSG("restored parent branch"); + DEBUG_VALID_STATE(NODE, CONT) + ret = 1; + goto analyze; + } + + DEBUG_VALID_STATE(NODE, CONT) + /* + * we may have to save a backup state here. This is the equivalent + * of handling epsilon transition in NFAs. + */ + if ((CONT != NULL) && + ((CONT->parent == NULL) || + (CONT->parent->type != XML_ELEMENT_CONTENT_OR)) && + ((CONT->ocur == XML_ELEMENT_CONTENT_MULT) || + (CONT->ocur == XML_ELEMENT_CONTENT_OPT) || + ((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURRENCE)))) { + DEBUG_VALID_MSG("saving parent branch"); + if (vstateVPush(ctxt, CONT, NODE, DEPTH, OCCURS, ROLLBACK_PARENT) < 0) + return(0); + } + + + /* + * Check first if the content matches + */ + switch (CONT->type) { + case XML_ELEMENT_CONTENT_PCDATA: + if (NODE == NULL) { + DEBUG_VALID_MSG("pcdata failed no node"); + ret = 0; + break; + } + if (NODE->type == XML_TEXT_NODE) { + DEBUG_VALID_MSG("pcdata found, skip to next"); + /* + * go to next element in the content model + * skipping ignorable elems + */ + do { + NODE = NODE->next; + NODE = xmlValidateSkipIgnorable(NODE); + if ((NODE != NULL) && + (NODE->type == XML_ENTITY_REF_NODE)) + return(-2); + } while ((NODE != NULL) && + ((NODE->type != XML_ELEMENT_NODE) && + (NODE->type != XML_TEXT_NODE) && + (NODE->type != XML_CDATA_SECTION_NODE))); + ret = 1; + break; + } else { + DEBUG_VALID_MSG("pcdata failed"); + ret = 0; + break; + } + break; + case XML_ELEMENT_CONTENT_ELEMENT: + if (NODE == NULL) { + DEBUG_VALID_MSG("element failed no node"); + ret = 0; + break; + } + ret = ((NODE->type == XML_ELEMENT_NODE) && + (xmlStrEqual(NODE->name, CONT->name))); + if (ret == 1) { + if ((NODE->ns == NULL) || (NODE->ns->prefix == NULL)) { + ret = (CONT->prefix == NULL); + } else if (CONT->prefix == NULL) { + ret = 0; + } else { + ret = xmlStrEqual(NODE->ns->prefix, CONT->prefix); + } + } + if (ret == 1) { + DEBUG_VALID_MSG("element found, skip to next"); + /* + * go to next element in the content model + * skipping ignorable elems + */ + do { + NODE = NODE->next; + NODE = xmlValidateSkipIgnorable(NODE); + if ((NODE != NULL) && + (NODE->type == XML_ENTITY_REF_NODE)) + return(-2); + } while ((NODE != NULL) && + ((NODE->type != XML_ELEMENT_NODE) && + (NODE->type != XML_TEXT_NODE) && + (NODE->type != XML_CDATA_SECTION_NODE))); + } else { + DEBUG_VALID_MSG("element failed"); + ret = 0; + break; + } + break; + case XML_ELEMENT_CONTENT_OR: + /* + * Small optimization. + */ + if (CONT->c1->type == XML_ELEMENT_CONTENT_ELEMENT) { + if ((NODE == NULL) || + (!xmlStrEqual(NODE->name, CONT->c1->name))) { + DEPTH++; + CONT = CONT->c2; + goto cont; + } + if ((NODE->ns == NULL) || (NODE->ns->prefix == NULL)) { + ret = (CONT->c1->prefix == NULL); + } else if (CONT->c1->prefix == NULL) { + ret = 0; + } else { + ret = xmlStrEqual(NODE->ns->prefix, CONT->c1->prefix); + } + if (ret == 0) { + DEPTH++; + CONT = CONT->c2; + goto cont; + } + } + + /* + * save the second branch 'or' branch + */ + DEBUG_VALID_MSG("saving 'or' branch"); + if (vstateVPush(ctxt, CONT->c2, NODE, (unsigned char)(DEPTH + 1), + OCCURS, ROLLBACK_OR) < 0) + return(-1); + DEPTH++; + CONT = CONT->c1; + goto cont; + case XML_ELEMENT_CONTENT_SEQ: + /* + * Small optimization. + */ + if ((CONT->c1->type == XML_ELEMENT_CONTENT_ELEMENT) && + ((CONT->c1->ocur == XML_ELEMENT_CONTENT_OPT) || + (CONT->c1->ocur == XML_ELEMENT_CONTENT_MULT))) { + if ((NODE == NULL) || + (!xmlStrEqual(NODE->name, CONT->c1->name))) { + DEPTH++; + CONT = CONT->c2; + goto cont; + } + if ((NODE->ns == NULL) || (NODE->ns->prefix == NULL)) { + ret = (CONT->c1->prefix == NULL); + } else if (CONT->c1->prefix == NULL) { + ret = 0; + } else { + ret = xmlStrEqual(NODE->ns->prefix, CONT->c1->prefix); + } + if (ret == 0) { + DEPTH++; + CONT = CONT->c2; + goto cont; + } + } + DEPTH++; + CONT = CONT->c1; + goto cont; + } + + /* + * At this point handle going up in the tree + */ + if (ret == -1) { + DEBUG_VALID_MSG("error found returning"); + return(ret); + } +analyze: + while (CONT != NULL) { + /* + * First do the analysis depending on the occurrence model at + * this level. + */ + if (ret == 0) { + switch (CONT->ocur) { + xmlNodePtr cur; + + case XML_ELEMENT_CONTENT_ONCE: + cur = ctxt->vstate->node; + DEBUG_VALID_MSG("Once branch failed, rollback"); + if (vstateVPop(ctxt) < 0 ) { + DEBUG_VALID_MSG("exhaustion, failed"); + return(0); + } + if (cur != ctxt->vstate->node) + determinist = -3; + goto cont; + case XML_ELEMENT_CONTENT_PLUS: + if (OCCURRENCE == 0) { + cur = ctxt->vstate->node; + DEBUG_VALID_MSG("Plus branch failed, rollback"); + if (vstateVPop(ctxt) < 0 ) { + DEBUG_VALID_MSG("exhaustion, failed"); + return(0); + } + if (cur != ctxt->vstate->node) + determinist = -3; + goto cont; + } + DEBUG_VALID_MSG("Plus branch found"); + ret = 1; + break; + case XML_ELEMENT_CONTENT_MULT: +#ifdef DEBUG_VALID_ALGO + if (OCCURRENCE == 0) { + DEBUG_VALID_MSG("Mult branch failed"); + } else { + DEBUG_VALID_MSG("Mult branch found"); + } +#endif + ret = 1; + break; + case XML_ELEMENT_CONTENT_OPT: + DEBUG_VALID_MSG("Option branch failed"); + ret = 1; + break; + } + } else { + switch (CONT->ocur) { + case XML_ELEMENT_CONTENT_OPT: + DEBUG_VALID_MSG("Option branch succeeded"); + ret = 1; + break; + case XML_ELEMENT_CONTENT_ONCE: + DEBUG_VALID_MSG("Once branch succeeded"); + ret = 1; + break; + case XML_ELEMENT_CONTENT_PLUS: + if (STATE == ROLLBACK_PARENT) { + DEBUG_VALID_MSG("Plus branch rollback"); + ret = 1; + break; + } + if (NODE == NULL) { + DEBUG_VALID_MSG("Plus branch exhausted"); + ret = 1; + break; + } + DEBUG_VALID_MSG("Plus branch succeeded, continuing"); + SET_OCCURRENCE; + goto cont; + case XML_ELEMENT_CONTENT_MULT: + if (STATE == ROLLBACK_PARENT) { + DEBUG_VALID_MSG("Mult branch rollback"); + ret = 1; + break; + } + if (NODE == NULL) { + DEBUG_VALID_MSG("Mult branch exhausted"); + ret = 1; + break; + } + DEBUG_VALID_MSG("Mult branch succeeded, continuing"); + /* SET_OCCURRENCE; */ + goto cont; + } + } + STATE = 0; + + /* + * Then act accordingly at the parent level + */ + RESET_OCCURRENCE; + if (CONT->parent == NULL) + break; + + switch (CONT->parent->type) { + case XML_ELEMENT_CONTENT_PCDATA: + DEBUG_VALID_MSG("Error: parent pcdata"); + return(-1); + case XML_ELEMENT_CONTENT_ELEMENT: + DEBUG_VALID_MSG("Error: parent element"); + return(-1); + case XML_ELEMENT_CONTENT_OR: + if (ret == 1) { + DEBUG_VALID_MSG("Or succeeded"); + CONT = CONT->parent; + DEPTH--; + } else { + DEBUG_VALID_MSG("Or failed"); + CONT = CONT->parent; + DEPTH--; + } + break; + case XML_ELEMENT_CONTENT_SEQ: + if (ret == 0) { + DEBUG_VALID_MSG("Sequence failed"); + CONT = CONT->parent; + DEPTH--; + } else if (CONT == CONT->parent->c1) { + DEBUG_VALID_MSG("Sequence testing 2nd branch"); + CONT = CONT->parent->c2; + goto cont; + } else { + DEBUG_VALID_MSG("Sequence succeeded"); + CONT = CONT->parent; + DEPTH--; + } + } + } + if (NODE != NULL) { + xmlNodePtr cur; + + cur = ctxt->vstate->node; + DEBUG_VALID_MSG("Failed, remaining input, rollback"); + if (vstateVPop(ctxt) < 0 ) { + DEBUG_VALID_MSG("exhaustion, failed"); + return(0); + } + if (cur != ctxt->vstate->node) + determinist = -3; + goto cont; + } + if (ret == 0) { + xmlNodePtr cur; + + cur = ctxt->vstate->node; + DEBUG_VALID_MSG("Failure, rollback"); + if (vstateVPop(ctxt) < 0 ) { + DEBUG_VALID_MSG("exhaustion, failed"); + return(0); + } + if (cur != ctxt->vstate->node) + determinist = -3; + goto cont; + } + return(determinist); +} +#endif + +/** + * xmlSnprintfElements: + * @buf: an output buffer + * @size: the size of the buffer + * @content: An element + * @glob: 1 if one must print the englobing parenthesis, 0 otherwise + * + * This will dump the list of elements to the buffer + * Intended just for the debug routine + */ +static void +xmlSnprintfElements(char *buf, int size, xmlNodePtr node, int glob) { + xmlNodePtr cur; + int len; + + if (node == NULL) return; + if (glob) strcat(buf, "("); + cur = node; + while (cur != NULL) { + len = strlen(buf); + if (size - len < 50) { + if ((size - len > 4) && (buf[len - 1] != '.')) + strcat(buf, " ..."); + return; + } + switch (cur->type) { + case XML_ELEMENT_NODE: + if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { + if (size - len < xmlStrlen(cur->ns->prefix) + 10) { + if ((size - len > 4) && (buf[len - 1] != '.')) + strcat(buf, " ..."); + return; + } + strcat(buf, (char *) cur->ns->prefix); + strcat(buf, ":"); + } + if (size - len < xmlStrlen(cur->name) + 10) { + if ((size - len > 4) && (buf[len - 1] != '.')) + strcat(buf, " ..."); + return; + } + strcat(buf, (char *) cur->name); + if (cur->next != NULL) + strcat(buf, " "); + break; + case XML_TEXT_NODE: + if (xmlIsBlankNode(cur)) + break; + /* Falls through. */ + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + strcat(buf, "CDATA"); + if (cur->next != NULL) + strcat(buf, " "); + break; + case XML_ATTRIBUTE_NODE: + case XML_DOCUMENT_NODE: +#ifdef LIBXML_DOCB_ENABLED + case XML_DOCB_DOCUMENT_NODE: +#endif + case XML_HTML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_NAMESPACE_DECL: + strcat(buf, "???"); + if (cur->next != NULL) + strcat(buf, " "); + break; + case XML_ENTITY_NODE: + case XML_PI_NODE: + case XML_DTD_NODE: + case XML_COMMENT_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + } + cur = cur->next; + } + if (glob) strcat(buf, ")"); +} + +/** + * xmlValidateElementContent: + * @ctxt: the validation context + * @child: the child list + * @elemDecl: pointer to the element declaration + * @warn: emit the error message + * @parent: the parent element (for error reporting) + * + * Try to validate the content model of an element + * + * returns 1 if valid or 0 if not and -1 in case of error + */ + +static int +xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child, + xmlElementPtr elemDecl, int warn, xmlNodePtr parent) { + int ret = 1; +#ifndef LIBXML_REGEXP_ENABLED + xmlNodePtr repl = NULL, last = NULL, tmp; +#endif + xmlNodePtr cur; + xmlElementContentPtr cont; + const xmlChar *name; + + if ((elemDecl == NULL) || (parent == NULL) || (ctxt == NULL)) + return(-1); + cont = elemDecl->content; + name = elemDecl->name; + +#ifdef LIBXML_REGEXP_ENABLED + /* Build the regexp associated to the content model */ + if (elemDecl->contModel == NULL) + ret = xmlValidBuildContentModel(ctxt, elemDecl); + if (elemDecl->contModel == NULL) { + return(-1); + } else { + xmlRegExecCtxtPtr exec; + + if (!xmlRegexpIsDeterminist(elemDecl->contModel)) { + return(-1); + } + ctxt->nodeMax = 0; + ctxt->nodeNr = 0; + ctxt->nodeTab = NULL; + exec = xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL); + if (exec != NULL) { + cur = child; + while (cur != NULL) { + switch (cur->type) { + case XML_ENTITY_REF_NODE: + /* + * Push the current node to be able to roll back + * and process within the entity + */ + if ((cur->children != NULL) && + (cur->children->children != NULL)) { + nodeVPush(ctxt, cur); + cur = cur->children->children; + continue; + } + break; + case XML_TEXT_NODE: + if (xmlIsBlankNode(cur)) + break; + ret = 0; + goto fail; + case XML_CDATA_SECTION_NODE: + /* TODO */ + ret = 0; + goto fail; + case XML_ELEMENT_NODE: + if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(cur->name, + cur->ns->prefix, fn, 50); + if (fullname == NULL) { + ret = -1; + goto fail; + } + ret = xmlRegExecPushString(exec, fullname, NULL); + if ((fullname != fn) && (fullname != cur->name)) + xmlFree(fullname); + } else { + ret = xmlRegExecPushString(exec, cur->name, NULL); + } + break; + default: + break; + } + /* + * Switch to next element + */ + cur = cur->next; + while (cur == NULL) { + cur = nodeVPop(ctxt); + if (cur == NULL) + break; + cur = cur->next; + } + } + ret = xmlRegExecPushString(exec, NULL, NULL); +fail: + xmlRegFreeExecCtxt(exec); + } + } +#else /* LIBXML_REGEXP_ENABLED */ + /* + * Allocate the stack + */ + ctxt->vstateMax = 8; + ctxt->vstateTab = (xmlValidState *) xmlMalloc( + ctxt->vstateMax * sizeof(ctxt->vstateTab[0])); + if (ctxt->vstateTab == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + return(-1); + } + /* + * The first entry in the stack is reserved to the current state + */ + ctxt->nodeMax = 0; + ctxt->nodeNr = 0; + ctxt->nodeTab = NULL; + ctxt->vstate = &ctxt->vstateTab[0]; + ctxt->vstateNr = 1; + CONT = cont; + NODE = child; + DEPTH = 0; + OCCURS = 0; + STATE = 0; + ret = xmlValidateElementType(ctxt); + if ((ret == -3) && (warn)) { + xmlErrValidWarning(ctxt, child, XML_DTD_CONTENT_NOT_DETERMINIST, + "Content model for Element %s is ambiguous\n", + name, NULL, NULL); + } else if (ret == -2) { + /* + * An entities reference appeared at this level. + * Build a minimal representation of this node content + * sufficient to run the validation process on it + */ + DEBUG_VALID_MSG("Found an entity reference, linearizing"); + cur = child; + while (cur != NULL) { + switch (cur->type) { + case XML_ENTITY_REF_NODE: + /* + * Push the current node to be able to roll back + * and process within the entity + */ + if ((cur->children != NULL) && + (cur->children->children != NULL)) { + nodeVPush(ctxt, cur); + cur = cur->children->children; + continue; + } + break; + case XML_TEXT_NODE: + if (xmlIsBlankNode(cur)) + break; + /* no break on purpose */ + case XML_CDATA_SECTION_NODE: + /* no break on purpose */ + case XML_ELEMENT_NODE: + /* + * Allocate a new node and minimally fills in + * what's required + */ + tmp = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (tmp == NULL) { + xmlVErrMemory(ctxt, "malloc failed"); + xmlFreeNodeList(repl); + ret = -1; + goto done; + } + tmp->type = cur->type; + tmp->name = cur->name; + tmp->ns = cur->ns; + tmp->next = NULL; + tmp->content = NULL; + if (repl == NULL) + repl = last = tmp; + else { + last->next = tmp; + last = tmp; + } + if (cur->type == XML_CDATA_SECTION_NODE) { + /* + * E59 spaces in CDATA does not match the + * nonterminal S + */ + tmp->content = xmlStrdup(BAD_CAST "CDATA"); + } + break; + default: + break; + } + /* + * Switch to next element + */ + cur = cur->next; + while (cur == NULL) { + cur = nodeVPop(ctxt); + if (cur == NULL) + break; + cur = cur->next; + } + } + + /* + * Relaunch the validation + */ + ctxt->vstate = &ctxt->vstateTab[0]; + ctxt->vstateNr = 1; + CONT = cont; + NODE = repl; + DEPTH = 0; + OCCURS = 0; + STATE = 0; + ret = xmlValidateElementType(ctxt); + } +#endif /* LIBXML_REGEXP_ENABLED */ + if ((warn) && ((ret != 1) && (ret != -3))) { + if (ctxt != NULL) { + char expr[5000]; + char list[5000]; + + expr[0] = 0; + xmlSnprintfElementContent(&expr[0], 5000, cont, 1); + list[0] = 0; +#ifndef LIBXML_REGEXP_ENABLED + if (repl != NULL) + xmlSnprintfElements(&list[0], 5000, repl, 1); + else +#endif /* LIBXML_REGEXP_ENABLED */ + xmlSnprintfElements(&list[0], 5000, child, 1); + + if (name != NULL) { + xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL, + "Element %s content does not follow the DTD, expecting %s, got %s\n", + name, BAD_CAST expr, BAD_CAST list); + } else { + xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL, + "Element content does not follow the DTD, expecting %s, got %s\n", + BAD_CAST expr, BAD_CAST list, NULL); + } + } else { + if (name != NULL) { + xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL, + "Element %s content does not follow the DTD\n", + name, NULL, NULL); + } else { + xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL, + "Element content does not follow the DTD\n", + NULL, NULL, NULL); + } + } + ret = 0; + } + if (ret == -3) + ret = 1; + +#ifndef LIBXML_REGEXP_ENABLED +done: + /* + * Deallocate the copy if done, and free up the validation stack + */ + while (repl != NULL) { + tmp = repl->next; + xmlFree(repl); + repl = tmp; + } + ctxt->vstateMax = 0; + if (ctxt->vstateTab != NULL) { + xmlFree(ctxt->vstateTab); + ctxt->vstateTab = NULL; + } +#endif + ctxt->nodeMax = 0; + ctxt->nodeNr = 0; + if (ctxt->nodeTab != NULL) { + xmlFree(ctxt->nodeTab); + ctxt->nodeTab = NULL; + } + return(ret); + +} + +/** + * xmlValidateCdataElement: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * + * Check that an element follows #CDATA + * + * returns 1 if valid or 0 otherwise + */ +static int +xmlValidateOneCdataElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr elem) { + int ret = 1; + xmlNodePtr cur, child; + + if ((ctxt == NULL) || (doc == NULL) || (elem == NULL) || + (elem->type != XML_ELEMENT_NODE)) + return(0); + + child = elem->children; + + cur = child; + while (cur != NULL) { + switch (cur->type) { + case XML_ENTITY_REF_NODE: + /* + * Push the current node to be able to roll back + * and process within the entity + */ + if ((cur->children != NULL) && + (cur->children->children != NULL)) { + nodeVPush(ctxt, cur); + cur = cur->children->children; + continue; + } + break; + case XML_COMMENT_NODE: + case XML_PI_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + break; + default: + ret = 0; + goto done; + } + /* + * Switch to next element + */ + cur = cur->next; + while (cur == NULL) { + cur = nodeVPop(ctxt); + if (cur == NULL) + break; + cur = cur->next; + } + } +done: + ctxt->nodeMax = 0; + ctxt->nodeNr = 0; + if (ctxt->nodeTab != NULL) { + xmlFree(ctxt->nodeTab); + ctxt->nodeTab = NULL; + } + return(ret); +} + +/** + * xmlValidateCheckMixed: + * @ctxt: the validation context + * @cont: the mixed content model + * @qname: the qualified name as appearing in the serialization + * + * Check if the given node is part of the content model. + * + * Returns 1 if yes, 0 if no, -1 in case of error + */ +static int +xmlValidateCheckMixed(xmlValidCtxtPtr ctxt, + xmlElementContentPtr cont, const xmlChar *qname) { + const xmlChar *name; + int plen; + name = xmlSplitQName3(qname, &plen); + + if (name == NULL) { + while (cont != NULL) { + if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { + if ((cont->prefix == NULL) && (xmlStrEqual(cont->name, qname))) + return(1); + } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && + (cont->c1 != NULL) && + (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ + if ((cont->c1->prefix == NULL) && + (xmlStrEqual(cont->c1->name, qname))) + return(1); + } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || + (cont->c1 == NULL) || + (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ + xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT, + "Internal: MIXED struct corrupted\n", + NULL); + break; + } + cont = cont->c2; + } + } else { + while (cont != NULL) { + if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { + if ((cont->prefix != NULL) && + (xmlStrncmp(cont->prefix, qname, plen) == 0) && + (xmlStrEqual(cont->name, name))) + return(1); + } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && + (cont->c1 != NULL) && + (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ + if ((cont->c1->prefix != NULL) && + (xmlStrncmp(cont->c1->prefix, qname, plen) == 0) && + (xmlStrEqual(cont->c1->name, name))) + return(1); + } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || + (cont->c1 == NULL) || + (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ + xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT, + "Internal: MIXED struct corrupted\n", + NULL); + break; + } + cont = cont->c2; + } + } + return(0); +} + +/** + * xmlValidGetElemDecl: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * @extsubset: pointer, (out) indicate if the declaration was found + * in the external subset. + * + * Finds a declaration associated to an element in the document. + * + * returns the pointer to the declaration or NULL if not found. + */ +static xmlElementPtr +xmlValidGetElemDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr elem, int *extsubset) { + xmlElementPtr elemDecl = NULL; + const xmlChar *prefix = NULL; + + if ((ctxt == NULL) || (doc == NULL) || + (elem == NULL) || (elem->name == NULL)) + return(NULL); + if (extsubset != NULL) + *extsubset = 0; + + /* + * Fetch the declaration for the qualified name + */ + if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) + prefix = elem->ns->prefix; + + if (prefix != NULL) { + elemDecl = xmlGetDtdQElementDesc(doc->intSubset, + elem->name, prefix); + if ((elemDecl == NULL) && (doc->extSubset != NULL)) { + elemDecl = xmlGetDtdQElementDesc(doc->extSubset, + elem->name, prefix); + if ((elemDecl != NULL) && (extsubset != NULL)) + *extsubset = 1; + } + } + + /* + * Fetch the declaration for the non qualified name + * This is "non-strict" validation should be done on the + * full QName but in that case being flexible makes sense. + */ + if (elemDecl == NULL) { + elemDecl = xmlGetDtdElementDesc(doc->intSubset, elem->name); + if ((elemDecl == NULL) && (doc->extSubset != NULL)) { + elemDecl = xmlGetDtdElementDesc(doc->extSubset, elem->name); + if ((elemDecl != NULL) && (extsubset != NULL)) + *extsubset = 1; + } + } + if (elemDecl == NULL) { + xmlErrValidNode(ctxt, elem, + XML_DTD_UNKNOWN_ELEM, + "No declaration for element %s\n", + elem->name, NULL, NULL); + } + return(elemDecl); +} + +#ifdef LIBXML_REGEXP_ENABLED +/** + * xmlValidatePushElement: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * @qname: the qualified name as appearing in the serialization + * + * Push a new element start on the validation stack. + * + * returns 1 if no validation problem was found or 0 otherwise + */ +int +xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr elem, const xmlChar *qname) { + int ret = 1; + xmlElementPtr eDecl; + int extsubset = 0; + + if (ctxt == NULL) + return(0); +/* printf("PushElem %s\n", qname); */ + if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) { + xmlValidStatePtr state = ctxt->vstate; + xmlElementPtr elemDecl; + + /* + * Check the new element against the content model of the new elem. + */ + if (state->elemDecl != NULL) { + elemDecl = state->elemDecl; + + switch(elemDecl->etype) { + case XML_ELEMENT_TYPE_UNDEFINED: + ret = 0; + break; + case XML_ELEMENT_TYPE_EMPTY: + xmlErrValidNode(ctxt, state->node, + XML_DTD_NOT_EMPTY, + "Element %s was declared EMPTY this one has content\n", + state->node->name, NULL, NULL); + ret = 0; + break; + case XML_ELEMENT_TYPE_ANY: + /* I don't think anything is required then */ + break; + case XML_ELEMENT_TYPE_MIXED: + /* simple case of declared as #PCDATA */ + if ((elemDecl->content != NULL) && + (elemDecl->content->type == + XML_ELEMENT_CONTENT_PCDATA)) { + xmlErrValidNode(ctxt, state->node, + XML_DTD_NOT_PCDATA, + "Element %s was declared #PCDATA but contains non text nodes\n", + state->node->name, NULL, NULL); + ret = 0; + } else { + ret = xmlValidateCheckMixed(ctxt, elemDecl->content, + qname); + if (ret != 1) { + xmlErrValidNode(ctxt, state->node, + XML_DTD_INVALID_CHILD, + "Element %s is not declared in %s list of possible children\n", + qname, state->node->name, NULL); + } + } + break; + case XML_ELEMENT_TYPE_ELEMENT: + /* + * TODO: + * VC: Standalone Document Declaration + * - element types with element content, if white space + * occurs directly within any instance of those types. + */ + if (state->exec != NULL) { + ret = xmlRegExecPushString(state->exec, qname, NULL); + if (ret < 0) { + xmlErrValidNode(ctxt, state->node, + XML_DTD_CONTENT_MODEL, + "Element %s content does not follow the DTD, Misplaced %s\n", + state->node->name, qname, NULL); + ret = 0; + } else { + ret = 1; + } + } + break; + } + } + } + eDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset); + vstateVPush(ctxt, eDecl, elem); + return(ret); +} + +/** + * xmlValidatePushCData: + * @ctxt: the validation context + * @data: some character data read + * @len: the length of the data + * + * check the CData parsed for validation in the current stack + * + * returns 1 if no validation problem was found or 0 otherwise + */ +int +xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) { + int ret = 1; + +/* printf("CDATA %s %d\n", data, len); */ + if (ctxt == NULL) + return(0); + if (len <= 0) + return(ret); + if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) { + xmlValidStatePtr state = ctxt->vstate; + xmlElementPtr elemDecl; + + /* + * Check the new element against the content model of the new elem. + */ + if (state->elemDecl != NULL) { + elemDecl = state->elemDecl; + + switch(elemDecl->etype) { + case XML_ELEMENT_TYPE_UNDEFINED: + ret = 0; + break; + case XML_ELEMENT_TYPE_EMPTY: + xmlErrValidNode(ctxt, state->node, + XML_DTD_NOT_EMPTY, + "Element %s was declared EMPTY this one has content\n", + state->node->name, NULL, NULL); + ret = 0; + break; + case XML_ELEMENT_TYPE_ANY: + break; + case XML_ELEMENT_TYPE_MIXED: + break; + case XML_ELEMENT_TYPE_ELEMENT: { + int i; + + for (i = 0;i < len;i++) { + if (!IS_BLANK_CH(data[i])) { + xmlErrValidNode(ctxt, state->node, + XML_DTD_CONTENT_MODEL, + "Element %s content does not follow the DTD, Text not allowed\n", + state->node->name, NULL, NULL); + ret = 0; + goto done; + } + } + /* + * TODO: + * VC: Standalone Document Declaration + * element types with element content, if white space + * occurs directly within any instance of those types. + */ + break; + } + } + } + } +done: + return(ret); +} + +/** + * xmlValidatePopElement: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * @qname: the qualified name as appearing in the serialization + * + * Pop the element end from the validation stack. + * + * returns 1 if no validation problem was found or 0 otherwise + */ +int +xmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED, + xmlNodePtr elem ATTRIBUTE_UNUSED, + const xmlChar *qname ATTRIBUTE_UNUSED) { + int ret = 1; + + if (ctxt == NULL) + return(0); +/* printf("PopElem %s\n", qname); */ + if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) { + xmlValidStatePtr state = ctxt->vstate; + xmlElementPtr elemDecl; + + /* + * Check the new element against the content model of the new elem. + */ + if (state->elemDecl != NULL) { + elemDecl = state->elemDecl; + + if (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT) { + if (state->exec != NULL) { + ret = xmlRegExecPushString(state->exec, NULL, NULL); + if (ret == 0) { + xmlErrValidNode(ctxt, state->node, + XML_DTD_CONTENT_MODEL, + "Element %s content does not follow the DTD, Expecting more child\n", + state->node->name, NULL,NULL); + } else { + /* + * previous validation errors should not generate + * a new one here + */ + ret = 1; + } + } + } + } + vstateVPop(ctxt); + } + return(ret); +} +#endif /* LIBXML_REGEXP_ENABLED */ + +/** + * xmlValidateOneElement: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * + * Try to validate a single element and it's attributes, + * basically it does the following checks as described by the + * XML-1.0 recommendation: + * - [ VC: Element Valid ] + * - [ VC: Required Attribute ] + * Then call xmlValidateOneAttribute() for each attribute present. + * + * The ID/IDREF checkings are done separately + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, + xmlNodePtr elem) { + xmlElementPtr elemDecl = NULL; + xmlElementContentPtr cont; + xmlAttributePtr attr; + xmlNodePtr child; + int ret = 1, tmp; + const xmlChar *name; + int extsubset = 0; + + CHECK_DTD; + + if (elem == NULL) return(0); + switch (elem->type) { + case XML_ATTRIBUTE_NODE: + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Attribute element not expected\n", NULL, NULL ,NULL); + return(0); + case XML_TEXT_NODE: + if (elem->children != NULL) { + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Text element has children !\n", + NULL,NULL,NULL); + return(0); + } + if (elem->ns != NULL) { + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Text element has namespace !\n", + NULL,NULL,NULL); + return(0); + } + if (elem->content == NULL) { + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Text element has no content !\n", + NULL,NULL,NULL); + return(0); + } + return(1); + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + return(1); + case XML_CDATA_SECTION_NODE: + case XML_ENTITY_REF_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + return(1); + case XML_ENTITY_NODE: + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Entity element not expected\n", NULL, NULL ,NULL); + return(0); + case XML_NOTATION_NODE: + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Notation element not expected\n", NULL, NULL ,NULL); + return(0); + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "Document element not expected\n", NULL, NULL ,NULL); + return(0); + case XML_HTML_DOCUMENT_NODE: + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "HTML Document not expected\n", NULL, NULL ,NULL); + return(0); + case XML_ELEMENT_NODE: + break; + default: + xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR, + "unknown element type\n", NULL, NULL ,NULL); + return(0); + } + + /* + * Fetch the declaration + */ + elemDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset); + if (elemDecl == NULL) + return(0); + + /* + * If vstateNr is not zero that means continuous validation is + * activated, do not try to check the content model at that level. + */ + if (ctxt->vstateNr == 0) { + /* Check that the element content matches the definition */ + switch (elemDecl->etype) { + case XML_ELEMENT_TYPE_UNDEFINED: + xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ELEM, + "No declaration for element %s\n", + elem->name, NULL, NULL); + return(0); + case XML_ELEMENT_TYPE_EMPTY: + if (elem->children != NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_NOT_EMPTY, + "Element %s was declared EMPTY this one has content\n", + elem->name, NULL, NULL); + ret = 0; + } + break; + case XML_ELEMENT_TYPE_ANY: + /* I don't think anything is required then */ + break; + case XML_ELEMENT_TYPE_MIXED: + + /* simple case of declared as #PCDATA */ + if ((elemDecl->content != NULL) && + (elemDecl->content->type == XML_ELEMENT_CONTENT_PCDATA)) { + ret = xmlValidateOneCdataElement(ctxt, doc, elem); + if (!ret) { + xmlErrValidNode(ctxt, elem, XML_DTD_NOT_PCDATA, + "Element %s was declared #PCDATA but contains non text nodes\n", + elem->name, NULL, NULL); + } + break; + } + child = elem->children; + /* Hum, this start to get messy */ + while (child != NULL) { + if (child->type == XML_ELEMENT_NODE) { + name = child->name; + if ((child->ns != NULL) && (child->ns->prefix != NULL)) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(child->name, child->ns->prefix, + fn, 50); + if (fullname == NULL) + return(0); + cont = elemDecl->content; + while (cont != NULL) { + if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { + if (xmlStrEqual(cont->name, fullname)) + break; + } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && + (cont->c1 != NULL) && + (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ + if (xmlStrEqual(cont->c1->name, fullname)) + break; + } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || + (cont->c1 == NULL) || + (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ + xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT, + "Internal: MIXED struct corrupted\n", + NULL); + break; + } + cont = cont->c2; + } + if ((fullname != fn) && (fullname != child->name)) + xmlFree(fullname); + if (cont != NULL) + goto child_ok; + } + cont = elemDecl->content; + while (cont != NULL) { + if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { + if (xmlStrEqual(cont->name, name)) break; + } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && + (cont->c1 != NULL) && + (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)) { + if (xmlStrEqual(cont->c1->name, name)) break; + } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || + (cont->c1 == NULL) || + (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)) { + xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT, + "Internal: MIXED struct corrupted\n", + NULL); + break; + } + cont = cont->c2; + } + if (cont == NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_CHILD, + "Element %s is not declared in %s list of possible children\n", + name, elem->name, NULL); + ret = 0; + } + } +child_ok: + child = child->next; + } + break; + case XML_ELEMENT_TYPE_ELEMENT: + if ((doc->standalone == 1) && (extsubset == 1)) { + /* + * VC: Standalone Document Declaration + * - element types with element content, if white space + * occurs directly within any instance of those types. + */ + child = elem->children; + while (child != NULL) { + if (child->type == XML_TEXT_NODE) { + const xmlChar *content = child->content; + + while (IS_BLANK_CH(*content)) + content++; + if (*content == 0) { + xmlErrValidNode(ctxt, elem, + XML_DTD_STANDALONE_WHITE_SPACE, +"standalone: %s declared in the external subset contains white spaces nodes\n", + elem->name, NULL, NULL); + ret = 0; + break; + } + } + child =child->next; + } + } + child = elem->children; + cont = elemDecl->content; + tmp = xmlValidateElementContent(ctxt, child, elemDecl, 1, elem); + if (tmp <= 0) + ret = tmp; + break; + } + } /* not continuous */ + + /* [ VC: Required Attribute ] */ + attr = elemDecl->attributes; + while (attr != NULL) { + if (attr->def == XML_ATTRIBUTE_REQUIRED) { + int qualified = -1; + + if ((attr->prefix == NULL) && + (xmlStrEqual(attr->name, BAD_CAST "xmlns"))) { + xmlNsPtr ns; + + ns = elem->nsDef; + while (ns != NULL) { + if (ns->prefix == NULL) + goto found; + ns = ns->next; + } + } else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) { + xmlNsPtr ns; + + ns = elem->nsDef; + while (ns != NULL) { + if (xmlStrEqual(attr->name, ns->prefix)) + goto found; + ns = ns->next; + } + } else { + xmlAttrPtr attrib; + + attrib = elem->properties; + while (attrib != NULL) { + if (xmlStrEqual(attrib->name, attr->name)) { + if (attr->prefix != NULL) { + xmlNsPtr nameSpace = attrib->ns; + + if (nameSpace == NULL) + nameSpace = elem->ns; + /* + * qualified names handling is problematic, having a + * different prefix should be possible but DTDs don't + * allow to define the URI instead of the prefix :-( + */ + if (nameSpace == NULL) { + if (qualified < 0) + qualified = 0; + } else if (!xmlStrEqual(nameSpace->prefix, + attr->prefix)) { + if (qualified < 1) + qualified = 1; + } else + goto found; + } else { + /* + * We should allow applications to define namespaces + * for their application even if the DTD doesn't + * carry one, otherwise, basically we would always + * break. + */ + goto found; + } + } + attrib = attrib->next; + } + } + if (qualified == -1) { + if (attr->prefix == NULL) { + xmlErrValidNode(ctxt, elem, XML_DTD_MISSING_ATTRIBUTE, + "Element %s does not carry attribute %s\n", + elem->name, attr->name, NULL); + ret = 0; + } else { + xmlErrValidNode(ctxt, elem, XML_DTD_MISSING_ATTRIBUTE, + "Element %s does not carry attribute %s:%s\n", + elem->name, attr->prefix,attr->name); + ret = 0; + } + } else if (qualified == 0) { + xmlErrValidWarning(ctxt, elem, XML_DTD_NO_PREFIX, + "Element %s required attribute %s:%s has no prefix\n", + elem->name, attr->prefix, attr->name); + } else if (qualified == 1) { + xmlErrValidWarning(ctxt, elem, XML_DTD_DIFFERENT_PREFIX, + "Element %s required attribute %s:%s has different prefix\n", + elem->name, attr->prefix, attr->name); + } + } else if (attr->def == XML_ATTRIBUTE_FIXED) { + /* + * Special tests checking #FIXED namespace declarations + * have the right value since this is not done as an + * attribute checking + */ + if ((attr->prefix == NULL) && + (xmlStrEqual(attr->name, BAD_CAST "xmlns"))) { + xmlNsPtr ns; + + ns = elem->nsDef; + while (ns != NULL) { + if (ns->prefix == NULL) { + if (!xmlStrEqual(attr->defaultValue, ns->href)) { + xmlErrValidNode(ctxt, elem, + XML_DTD_ELEM_DEFAULT_NAMESPACE, + "Element %s namespace name for default namespace does not match the DTD\n", + elem->name, NULL, NULL); + ret = 0; + } + goto found; + } + ns = ns->next; + } + } else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) { + xmlNsPtr ns; + + ns = elem->nsDef; + while (ns != NULL) { + if (xmlStrEqual(attr->name, ns->prefix)) { + if (!xmlStrEqual(attr->defaultValue, ns->href)) { + xmlErrValidNode(ctxt, elem, XML_DTD_ELEM_NAMESPACE, + "Element %s namespace name for %s does not match the DTD\n", + elem->name, ns->prefix, NULL); + ret = 0; + } + goto found; + } + ns = ns->next; + } + } + } +found: + attr = attr->nexth; + } + return(ret); +} + +/** + * xmlValidateRoot: + * @ctxt: the validation context + * @doc: a document instance + * + * Try to validate a the root element + * basically it does the following check as described by the + * XML-1.0 recommendation: + * - [ VC: Root Element Type ] + * it doesn't try to recurse or apply other check to the element + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { + xmlNodePtr root; + int ret; + + if (doc == NULL) return(0); + + root = xmlDocGetRootElement(doc); + if ((root == NULL) || (root->name == NULL)) { + xmlErrValid(ctxt, XML_DTD_NO_ROOT, + "no root element\n", NULL); + return(0); + } + + /* + * When doing post validation against a separate DTD, those may + * no internal subset has been generated + */ + if ((doc->intSubset != NULL) && + (doc->intSubset->name != NULL)) { + /* + * Check first the document root against the NQName + */ + if (!xmlStrEqual(doc->intSubset->name, root->name)) { + if ((root->ns != NULL) && (root->ns->prefix != NULL)) { + xmlChar fn[50]; + xmlChar *fullname; + + fullname = xmlBuildQName(root->name, root->ns->prefix, fn, 50); + if (fullname == NULL) { + xmlVErrMemory(ctxt, NULL); + return(0); + } + ret = xmlStrEqual(doc->intSubset->name, fullname); + if ((fullname != fn) && (fullname != root->name)) + xmlFree(fullname); + if (ret == 1) + goto name_ok; + } + if ((xmlStrEqual(doc->intSubset->name, BAD_CAST "HTML")) && + (xmlStrEqual(root->name, BAD_CAST "html"))) + goto name_ok; + xmlErrValidNode(ctxt, root, XML_DTD_ROOT_NAME, + "root and DTD name do not match '%s' and '%s'\n", + root->name, doc->intSubset->name, NULL); + return(0); + } + } +name_ok: + return(1); +} + + +/** + * xmlValidateElement: + * @ctxt: the validation context + * @doc: a document instance + * @elem: an element instance + * + * Try to validate the subtree under an element + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) { + xmlNodePtr child; + xmlAttrPtr attr; + xmlNsPtr ns; + const xmlChar *value; + int ret = 1; + + if (elem == NULL) return(0); + + /* + * XInclude elements were added after parsing in the infoset, + * they don't really mean anything validation wise. + */ + if ((elem->type == XML_XINCLUDE_START) || + (elem->type == XML_XINCLUDE_END) || + (elem->type == XML_NAMESPACE_DECL)) + return(1); + + CHECK_DTD; + + /* + * Entities references have to be handled separately + */ + if (elem->type == XML_ENTITY_REF_NODE) { + return(1); + } + + ret &= xmlValidateOneElement(ctxt, doc, elem); + if (elem->type == XML_ELEMENT_NODE) { + attr = elem->properties; + while (attr != NULL) { + value = xmlNodeListGetString(doc, attr->children, 0); + ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value); + if (value != NULL) + xmlFree((char *)value); + attr= attr->next; + } + ns = elem->nsDef; + while (ns != NULL) { + if (elem->ns == NULL) + ret &= xmlValidateOneNamespace(ctxt, doc, elem, NULL, + ns, ns->href); + else + ret &= xmlValidateOneNamespace(ctxt, doc, elem, + elem->ns->prefix, ns, ns->href); + ns = ns->next; + } + } + child = elem->children; + while (child != NULL) { + ret &= xmlValidateElement(ctxt, doc, child); + child = child->next; + } + + return(ret); +} + +/** + * xmlValidateRef: + * @ref: A reference to be validated + * @ctxt: Validation context + * @name: Name of ID we are searching for + * + */ +static void +xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt, + const xmlChar *name) { + xmlAttrPtr id; + xmlAttrPtr attr; + + if (ref == NULL) + return; + if ((ref->attr == NULL) && (ref->name == NULL)) + return; + attr = ref->attr; + if (attr == NULL) { + xmlChar *dup, *str = NULL, *cur, save; + + dup = xmlStrdup(name); + if (dup == NULL) { + ctxt->valid = 0; + return; + } + cur = dup; + while (*cur != 0) { + str = cur; + while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++; + save = *cur; + *cur = 0; + id = xmlGetID(ctxt->doc, str); + if (id == NULL) { + xmlErrValidNodeNr(ctxt, NULL, XML_DTD_UNKNOWN_ID, + "attribute %s line %d references an unknown ID \"%s\"\n", + ref->name, ref->lineno, str); + ctxt->valid = 0; + } + if (save == 0) + break; + *cur = save; + while (IS_BLANK_CH(*cur)) cur++; + } + xmlFree(dup); + } else if (attr->atype == XML_ATTRIBUTE_IDREF) { + id = xmlGetID(ctxt->doc, name); + if (id == NULL) { + xmlErrValidNode(ctxt, attr->parent, XML_DTD_UNKNOWN_ID, + "IDREF attribute %s references an unknown ID \"%s\"\n", + attr->name, name, NULL); + ctxt->valid = 0; + } + } else if (attr->atype == XML_ATTRIBUTE_IDREFS) { + xmlChar *dup, *str = NULL, *cur, save; + + dup = xmlStrdup(name); + if (dup == NULL) { + xmlVErrMemory(ctxt, "IDREFS split"); + ctxt->valid = 0; + return; + } + cur = dup; + while (*cur != 0) { + str = cur; + while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++; + save = *cur; + *cur = 0; + id = xmlGetID(ctxt->doc, str); + if (id == NULL) { + xmlErrValidNode(ctxt, attr->parent, XML_DTD_UNKNOWN_ID, + "IDREFS attribute %s references an unknown ID \"%s\"\n", + attr->name, str, NULL); + ctxt->valid = 0; + } + if (save == 0) + break; + *cur = save; + while (IS_BLANK_CH(*cur)) cur++; + } + xmlFree(dup); + } +} + +/** + * xmlWalkValidateList: + * @data: Contents of current link + * @user: Value supplied by the user + * + * Returns 0 to abort the walk or 1 to continue + */ +static int +xmlWalkValidateList(const void *data, void *user) +{ + xmlValidateMemoPtr memo = (xmlValidateMemoPtr)user; + xmlValidateRef((xmlRefPtr)data, memo->ctxt, memo->name); + return 1; +} + +/** + * xmlValidateCheckRefCallback: + * @ref_list: List of references + * @ctxt: Validation context + * @name: Name of ID we are searching for + * + */ +static void +xmlValidateCheckRefCallback(void *payload, void *data, const xmlChar *name) { + xmlListPtr ref_list = (xmlListPtr) payload; + xmlValidCtxtPtr ctxt = (xmlValidCtxtPtr) data; + xmlValidateMemo memo; + + if (ref_list == NULL) + return; + memo.ctxt = ctxt; + memo.name = name; + + xmlListWalk(ref_list, xmlWalkValidateList, &memo); + +} + +/** + * xmlValidateDocumentFinal: + * @ctxt: the validation context + * @doc: a document instance + * + * Does the final step for the document validation once all the + * incremental validation steps have been completed + * + * basically it does the following checks described by the XML Rec + * + * Check all the IDREF/IDREFS attributes definition for validity + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { + xmlRefTablePtr table; + unsigned int save; + + if (ctxt == NULL) + return(0); + if (doc == NULL) { + xmlErrValid(ctxt, XML_DTD_NO_DOC, + "xmlValidateDocumentFinal: doc == NULL\n", NULL); + return(0); + } + + /* trick to get correct line id report */ + save = ctxt->finishDtd; + ctxt->finishDtd = 0; + + /* + * Check all the NOTATION/NOTATIONS attributes + */ + /* + * Check all the ENTITY/ENTITIES attributes definition for validity + */ + /* + * Check all the IDREF/IDREFS attributes definition for validity + */ + table = (xmlRefTablePtr) doc->refs; + ctxt->doc = doc; + ctxt->valid = 1; + xmlHashScan(table, xmlValidateCheckRefCallback, ctxt); + + ctxt->finishDtd = save; + return(ctxt->valid); +} + +/** + * xmlValidateDtd: + * @ctxt: the validation context + * @doc: a document instance + * @dtd: a dtd instance + * + * Try to validate the document against the dtd instance + * + * Basically it does check all the definitions in the DtD. + * Note the the internal subset (if present) is de-coupled + * (i.e. not used), which could give problems if ID or IDREF + * is present. + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) { + int ret; + xmlDtdPtr oldExt, oldInt; + xmlNodePtr root; + + if (dtd == NULL) return(0); + if (doc == NULL) return(0); + oldExt = doc->extSubset; + oldInt = doc->intSubset; + doc->extSubset = dtd; + doc->intSubset = NULL; + ret = xmlValidateRoot(ctxt, doc); + if (ret == 0) { + doc->extSubset = oldExt; + doc->intSubset = oldInt; + return(ret); + } + if (doc->ids != NULL) { + xmlFreeIDTable(doc->ids); + doc->ids = NULL; + } + if (doc->refs != NULL) { + xmlFreeRefTable(doc->refs); + doc->refs = NULL; + } + root = xmlDocGetRootElement(doc); + ret = xmlValidateElement(ctxt, doc, root); + ret &= xmlValidateDocumentFinal(ctxt, doc); + doc->extSubset = oldExt; + doc->intSubset = oldInt; + return(ret); +} + +static void +xmlValidateNotationCallback(void *payload, void *data, + const xmlChar *name ATTRIBUTE_UNUSED) { + xmlEntityPtr cur = (xmlEntityPtr) payload; + xmlValidCtxtPtr ctxt = (xmlValidCtxtPtr) data; + if (cur == NULL) + return; + if (cur->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { + xmlChar *notation = cur->content; + + if (notation != NULL) { + int ret; + + ret = xmlValidateNotationUse(ctxt, cur->doc, notation); + if (ret != 1) { + ctxt->valid = 0; + } + } + } +} + +static void +xmlValidateAttributeCallback(void *payload, void *data, + const xmlChar *name ATTRIBUTE_UNUSED) { + xmlAttributePtr cur = (xmlAttributePtr) payload; + xmlValidCtxtPtr ctxt = (xmlValidCtxtPtr) data; + int ret; + xmlDocPtr doc; + xmlElementPtr elem = NULL; + + if (cur == NULL) + return; + switch (cur->atype) { + case XML_ATTRIBUTE_CDATA: + case XML_ATTRIBUTE_ID: + case XML_ATTRIBUTE_IDREF : + case XML_ATTRIBUTE_IDREFS: + case XML_ATTRIBUTE_NMTOKEN: + case XML_ATTRIBUTE_NMTOKENS: + case XML_ATTRIBUTE_ENUMERATION: + break; + case XML_ATTRIBUTE_ENTITY: + case XML_ATTRIBUTE_ENTITIES: + case XML_ATTRIBUTE_NOTATION: + if (cur->defaultValue != NULL) { + + ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name, + cur->atype, cur->defaultValue); + if ((ret == 0) && (ctxt->valid == 1)) + ctxt->valid = 0; + } + if (cur->tree != NULL) { + xmlEnumerationPtr tree = cur->tree; + while (tree != NULL) { + ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, + cur->name, cur->atype, tree->name); + if ((ret == 0) && (ctxt->valid == 1)) + ctxt->valid = 0; + tree = tree->next; + } + } + } + if (cur->atype == XML_ATTRIBUTE_NOTATION) { + doc = cur->doc; + if (cur->elem == NULL) { + xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, + "xmlValidateAttributeCallback(%s): internal error\n", + (const char *) cur->name); + return; + } + + if (doc != NULL) + elem = xmlGetDtdElementDesc(doc->intSubset, cur->elem); + if ((elem == NULL) && (doc != NULL)) + elem = xmlGetDtdElementDesc(doc->extSubset, cur->elem); + if ((elem == NULL) && (cur->parent != NULL) && + (cur->parent->type == XML_DTD_NODE)) + elem = xmlGetDtdElementDesc((xmlDtdPtr) cur->parent, cur->elem); + if (elem == NULL) { + xmlErrValidNode(ctxt, NULL, XML_DTD_UNKNOWN_ELEM, + "attribute %s: could not find decl for element %s\n", + cur->name, cur->elem, NULL); + return; + } + if (elem->etype == XML_ELEMENT_TYPE_EMPTY) { + xmlErrValidNode(ctxt, NULL, XML_DTD_EMPTY_NOTATION, + "NOTATION attribute %s declared for EMPTY element %s\n", + cur->name, cur->elem, NULL); + ctxt->valid = 0; + } + } +} + +/** + * xmlValidateDtdFinal: + * @ctxt: the validation context + * @doc: a document instance + * + * Does the final step for the dtds validation once all the + * subsets have been parsed + * + * basically it does the following checks described by the XML Rec + * - check that ENTITY and ENTITIES type attributes default or + * possible values matches one of the defined entities. + * - check that NOTATION type attributes default or + * possible values matches one of the defined notations. + * + * returns 1 if valid or 0 if invalid and -1 if not well-formed + */ + +int +xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { + xmlDtdPtr dtd; + xmlAttributeTablePtr table; + xmlEntitiesTablePtr entities; + + if ((doc == NULL) || (ctxt == NULL)) return(0); + if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) + return(0); + ctxt->doc = doc; + ctxt->valid = 1; + dtd = doc->intSubset; + if ((dtd != NULL) && (dtd->attributes != NULL)) { + table = (xmlAttributeTablePtr) dtd->attributes; + xmlHashScan(table, xmlValidateAttributeCallback, ctxt); + } + if ((dtd != NULL) && (dtd->entities != NULL)) { + entities = (xmlEntitiesTablePtr) dtd->entities; + xmlHashScan(entities, xmlValidateNotationCallback, ctxt); + } + dtd = doc->extSubset; + if ((dtd != NULL) && (dtd->attributes != NULL)) { + table = (xmlAttributeTablePtr) dtd->attributes; + xmlHashScan(table, xmlValidateAttributeCallback, ctxt); + } + if ((dtd != NULL) && (dtd->entities != NULL)) { + entities = (xmlEntitiesTablePtr) dtd->entities; + xmlHashScan(entities, xmlValidateNotationCallback, ctxt); + } + return(ctxt->valid); +} + +/** + * xmlValidateDocument: + * @ctxt: the validation context + * @doc: a document instance + * + * Try to validate the document instance + * + * basically it does the all the checks described by the XML Rec + * i.e. validates the internal and external subset (if present) + * and validate the document tree. + * + * returns 1 if valid or 0 otherwise + */ + +int +xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { + int ret; + xmlNodePtr root; + + if (doc == NULL) + return(0); + if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) { + xmlErrValid(ctxt, XML_DTD_NO_DTD, + "no DTD found!\n", NULL); + return(0); + } + if ((doc->intSubset != NULL) && ((doc->intSubset->SystemID != NULL) || + (doc->intSubset->ExternalID != NULL)) && (doc->extSubset == NULL)) { + xmlChar *sysID; + if (doc->intSubset->SystemID != NULL) { + sysID = xmlBuildURI(doc->intSubset->SystemID, + doc->URL); + if (sysID == NULL) { + xmlErrValid(ctxt, XML_DTD_LOAD_ERROR, + "Could not build URI for external subset \"%s\"\n", + (const char *) doc->intSubset->SystemID); + return 0; + } + } else + sysID = NULL; + doc->extSubset = xmlParseDTD(doc->intSubset->ExternalID, + (const xmlChar *)sysID); + if (sysID != NULL) + xmlFree(sysID); + if (doc->extSubset == NULL) { + if (doc->intSubset->SystemID != NULL) { + xmlErrValid(ctxt, XML_DTD_LOAD_ERROR, + "Could not load the external subset \"%s\"\n", + (const char *) doc->intSubset->SystemID); + } else { + xmlErrValid(ctxt, XML_DTD_LOAD_ERROR, + "Could not load the external subset \"%s\"\n", + (const char *) doc->intSubset->ExternalID); + } + return(0); + } + } + + if (doc->ids != NULL) { + xmlFreeIDTable(doc->ids); + doc->ids = NULL; + } + if (doc->refs != NULL) { + xmlFreeRefTable(doc->refs); + doc->refs = NULL; + } + ret = xmlValidateDtdFinal(ctxt, doc); + if (!xmlValidateRoot(ctxt, doc)) return(0); + + root = xmlDocGetRootElement(doc); + ret &= xmlValidateElement(ctxt, doc, root); + ret &= xmlValidateDocumentFinal(ctxt, doc); + return(ret); +} + +/************************************************************************ + * * + * Routines for dynamic validation editing * + * * + ************************************************************************/ + +/** + * xmlValidGetPotentialChildren: + * @ctree: an element content tree + * @names: an array to store the list of child names + * @len: a pointer to the number of element in the list + * @max: the size of the array + * + * Build/extend a list of potential children allowed by the content tree + * + * returns the number of element in the list, or -1 in case of error. + */ + +int +xmlValidGetPotentialChildren(xmlElementContent *ctree, + const xmlChar **names, + int *len, int max) { + int i; + + if ((ctree == NULL) || (names == NULL) || (len == NULL)) + return(-1); + if (*len >= max) return(*len); + + switch (ctree->type) { + case XML_ELEMENT_CONTENT_PCDATA: + for (i = 0; i < *len;i++) + if (xmlStrEqual(BAD_CAST "#PCDATA", names[i])) return(*len); + names[(*len)++] = BAD_CAST "#PCDATA"; + break; + case XML_ELEMENT_CONTENT_ELEMENT: + for (i = 0; i < *len;i++) + if (xmlStrEqual(ctree->name, names[i])) return(*len); + names[(*len)++] = ctree->name; + break; + case XML_ELEMENT_CONTENT_SEQ: + xmlValidGetPotentialChildren(ctree->c1, names, len, max); + xmlValidGetPotentialChildren(ctree->c2, names, len, max); + break; + case XML_ELEMENT_CONTENT_OR: + xmlValidGetPotentialChildren(ctree->c1, names, len, max); + xmlValidGetPotentialChildren(ctree->c2, names, len, max); + break; + } + + return(*len); +} + +/* + * Dummy function to suppress messages while we try out valid elements + */ +static void XMLCDECL xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED, + const char *msg ATTRIBUTE_UNUSED, ...) { + return; +} + +/** + * xmlValidGetValidElements: + * @prev: an element to insert after + * @next: an element to insert next + * @names: an array to store the list of child names + * @max: the size of the array + * + * This function returns the list of authorized children to insert + * within an existing tree while respecting the validity constraints + * forced by the Dtd. The insertion point is defined using @prev and + * @next in the following ways: + * to insert before 'node': xmlValidGetValidElements(node->prev, node, ... + * to insert next 'node': xmlValidGetValidElements(node, node->next, ... + * to replace 'node': xmlValidGetValidElements(node->prev, node->next, ... + * to prepend a child to 'node': xmlValidGetValidElements(NULL, node->childs, + * to append a child to 'node': xmlValidGetValidElements(node->last, NULL, ... + * + * pointers to the element names are inserted at the beginning of the array + * and do not need to be freed. + * + * returns the number of element in the list, or -1 in case of error. If + * the function returns the value @max the caller is invited to grow the + * receiving array and retry. + */ + +int +xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names, + int max) { + xmlValidCtxt vctxt; + int nb_valid_elements = 0; + const xmlChar *elements[256]={0}; + int nb_elements = 0, i; + const xmlChar *name; + + xmlNode *ref_node; + xmlNode *parent; + xmlNode *test_node; + + xmlNode *prev_next; + xmlNode *next_prev; + xmlNode *parent_childs; + xmlNode *parent_last; + + xmlElement *element_desc; + + if (prev == NULL && next == NULL) + return(-1); + + if (names == NULL) return(-1); + if (max <= 0) return(-1); + + memset(&vctxt, 0, sizeof (xmlValidCtxt)); + vctxt.error = xmlNoValidityErr; /* this suppresses err/warn output */ + + nb_valid_elements = 0; + ref_node = prev ? prev : next; + parent = ref_node->parent; + + /* + * Retrieves the parent element declaration + */ + element_desc = xmlGetDtdElementDesc(parent->doc->intSubset, + parent->name); + if ((element_desc == NULL) && (parent->doc->extSubset != NULL)) + element_desc = xmlGetDtdElementDesc(parent->doc->extSubset, + parent->name); + if (element_desc == NULL) return(-1); + + /* + * Do a backup of the current tree structure + */ + prev_next = prev ? prev->next : NULL; + next_prev = next ? next->prev : NULL; + parent_childs = parent->children; + parent_last = parent->last; + + /* + * Creates a dummy node and insert it into the tree + */ + test_node = xmlNewDocNode (ref_node->doc, NULL, BAD_CAST "", NULL); + if (test_node == NULL) + return(-1); + + test_node->parent = parent; + test_node->prev = prev; + test_node->next = next; + name = test_node->name; + + if (prev) prev->next = test_node; + else parent->children = test_node; + + if (next) next->prev = test_node; + else parent->last = test_node; + + /* + * Insert each potential child node and check if the parent is + * still valid + */ + nb_elements = xmlValidGetPotentialChildren(element_desc->content, + elements, &nb_elements, 256); + + for (i = 0;i < nb_elements;i++) { + test_node->name = elements[i]; + if (xmlValidateOneElement(&vctxt, parent->doc, parent)) { + int j; + + for (j = 0; j < nb_valid_elements;j++) + if (xmlStrEqual(elements[i], names[j])) break; + names[nb_valid_elements++] = elements[i]; + if (nb_valid_elements >= max) break; + } + } + + /* + * Restore the tree structure + */ + if (prev) prev->next = prev_next; + if (next) next->prev = next_prev; + parent->children = parent_childs; + parent->last = parent_last; + + /* + * Free up the dummy node + */ + test_node->name = name; + xmlFreeNode(test_node); + + return(nb_valid_elements); +} +#endif /* LIBXML_VALID_ENABLED */ + +#define bottom_valid +#include "elfgcchack.h" diff --git a/src/win32/Makefile.bcb b/src/win32/Makefile.bcb new file mode 100644 index 000000000000..d326fb99568e --- /dev/null +++ b/src/win32/Makefile.bcb @@ -0,0 +1,347 @@ +# Makefile for libxml2, specific for Windows, BCB6 and Borland make. +# +# Take a look at the beginning and modify the variables to suit your +# environment. Having done that, you can do a +# +# make [all] to build the libxml and the accompanying utilities. +# make clean to remove all compiler output files and return to a +# clean state. +# make rebuild to rebuild everything from scratch. This basically does +# a 'nmake clean' and then a 'nmake all'. +# make install to install the library and its header files. +# +# August 2003, Eric Zurcher +# based on the MSVC version of +# March 2002, Igor Zlatkovic +# + +# There should never be a need to modify anything below this line. +# ---------------------------------------------------------------- + +AUTOCONF = .\config.bcb +!include $(AUTOCONF) + +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif +.autodepend + +# Names of various input and output components. +XML_NAME = xml2 +XML_BASENAME = lib$(XML_NAME) +XML_SO = $(XML_BASENAME).dll +XML_IMP = $(XML_BASENAME).lib +XML_DEF = $(XML_BASENAME).def +XML_A = $(XML_BASENAME)_a.lib +DUMMY = dir.exists + +# Place where we let the compiler put its intermediate trash. +BINDIR = bin.bcb +XML_INTDIR = int.bcb +XML_INTDIR_A = int.a.bcb +UTILS_INTDIR = int.utils.bcb + +# The preprocessor and its options. +CPP = cpp32.exe -P- -DWIN32 +CPPFLAGS = -I"$(XML_SRCDIR)\include" -DNOLIBTOOL +!if "$(WITH_THREADS)" != "no" +CPPFLAGS = $(CPPFLAGS) -D_REENTRANT -D__MT__ +!endif + +# The compiler and its options. +CC = bcc32.exe +CFLAGS = -q -DWIN32 -D_NO_VCL -D_WINDOWS -D_MBCS -DEILSEQ=2 -DNOLIBTOOL -w- +CFLAGS = $(CFLAGS) -I"$(XML_SRCDIR)" -I"$(XML_SRCDIR)\include" -I"$(INCPREFIX)" -I"$(INCLUDE)" +!if "$(WITH_THREADS)" != "no" +CFLAGS = $(CFLAGS) -D_REENTRANT -tWM +!endif +!if "$(DYNRUNTIME)" == "1" +CFLAGS = $(CFLAGS) -tWR +!endif +!if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls" +CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS +!else if "$(WITH_THREADS)" == "native" +CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS +!else if "$(WITH_THREADS)" == "posix" +CFLAGS = $(CFLAGS) -DHAVE_PTHREAD_H +!endif + +# The linker and its options. +LD = ilink32.exe +LDFLAGS = -q -U$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION) +LDFLAGS = $(LDFLAGS) -L"$(BINDIR);$(LIBPREFIX);$(LIB);$(BCB)\lib;$(BCB)\lib\PSdk" +LIBS = import32.lib +!if "$(WITH_THREADS)" != "no" && "$(DYNRUNTIME)" == "1" +LIBS = $(LIBS) cw32mti.lib +!elif "$(WITH_THREADS)" != "no" +LIBS = $(LIBS) cw32mt.lib +!elif "$(DYNRUNTIME)" == "1" +LIBS = $(LIBS) cw32i.lib +!else +LIBS = $(LIBS) cw32.lib +!endif +!if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1" +LIBS = $(LIBS) wsock32.lib ws2_32.lib +!endif +!if "$(WITH_ICONV)" == "1" +LIBS = $(LIBS) iconvomf.lib +!endif +!if "$(WITH_ZLIB)" == "1" +LIBS = $(LIBS) zlibomf.lib +!endif +!if "$(WITH_LZMA)" == "1" +LIBS = $(LIBS) liblzma.lib +!endif +!if "$(WITH_THREADS)" == "posix" +LIBS = $(LIBS) pthreadVC.lib +!endif +!if "$(WITH_MODULES)" == "1" +LIBS = $(LIBS) kernel32.lib +!endif + +# The archiver and its options. +AR = tlib.exe +ARFLAGS = /P64 /0 + +# Optimisation and debug symbols. +!if "$(DEBUG)" == "1" +CFLAGS = $(CFLAGS) -D_DEBUG -Od -v +LDFLAGS = $(LDFLAGS) -v +!else +CFLAGS = $(CFLAGS) -DNDEBUG -O2 +LDFLAGS = $(LDFLAGS) +!endif + +# Libxml object files. +XML_OBJS = $(XML_INTDIR)\buf.obj\ + $(XML_INTDIR)\c14n.obj\ + $(XML_INTDIR)\catalog.obj\ + $(XML_INTDIR)\chvalid.obj\ + $(XML_INTDIR)\debugXML.obj\ + $(XML_INTDIR)\dict.obj\ + $(XML_INTDIR)\DOCBparser.obj\ + $(XML_INTDIR)\encoding.obj\ + $(XML_INTDIR)\entities.obj\ + $(XML_INTDIR)\error.obj\ + $(XML_INTDIR)\globals.obj\ + $(XML_INTDIR)\hash.obj\ + $(XML_INTDIR)\HTMLparser.obj\ + $(XML_INTDIR)\HTMLtree.obj\ + $(XML_INTDIR)\legacy.obj\ + $(XML_INTDIR)\list.obj\ + $(XML_INTDIR)\nanoftp.obj\ + $(XML_INTDIR)\nanohttp.obj\ + $(XML_INTDIR)\parser.obj\ + $(XML_INTDIR)\parserInternals.obj\ + $(XML_INTDIR)\pattern.obj\ + $(XML_INTDIR)\relaxng.obj\ + $(XML_INTDIR)\SAX.obj\ + $(XML_INTDIR)\SAX2.obj\ + $(XML_INTDIR)\schematron.obj\ + $(XML_INTDIR)\threads.obj\ + $(XML_INTDIR)\tree.obj\ + $(XML_INTDIR)\uri.obj\ + $(XML_INTDIR)\valid.obj\ + $(XML_INTDIR)\xinclude.obj\ + $(XML_INTDIR)\xlink.obj\ + $(XML_INTDIR)\xmlIO.obj\ + $(XML_INTDIR)\xmlmemory.obj\ + $(XML_INTDIR)\xmlreader.obj\ + $(XML_INTDIR)\xmlregexp.obj\ + $(XML_INTDIR)\xmlmodule.obj\ + $(XML_INTDIR)\xmlsave.obj\ + $(XML_INTDIR)\xmlschemas.obj\ + $(XML_INTDIR)\xmlschemastypes.obj\ + $(XML_INTDIR)\xmlunicode.obj\ + $(XML_INTDIR)\xmlwriter.obj\ + $(XML_INTDIR)\xpath.obj\ + $(XML_INTDIR)\xpointer.obj\ + $(XML_INTDIR)\xmlstring.obj + +# Static libxml object files. +XML_OBJS_A = $(XML_INTDIR_A)\buf.obj\ + $(XML_INTDIR_A)\c14n.obj\ + $(XML_INTDIR_A)\catalog.obj\ + $(XML_INTDIR_A)\chvalid.obj\ + $(XML_INTDIR_A)\debugXML.obj\ + $(XML_INTDIR_A)\dict.obj\ + $(XML_INTDIR_A)\DOCBparser.obj\ + $(XML_INTDIR_A)\encoding.obj\ + $(XML_INTDIR_A)\entities.obj\ + $(XML_INTDIR_A)\error.obj\ + $(XML_INTDIR_A)\globals.obj\ + $(XML_INTDIR_A)\hash.obj\ + $(XML_INTDIR_A)\HTMLparser.obj\ + $(XML_INTDIR_A)\HTMLtree.obj\ + $(XML_INTDIR_A)\legacy.obj\ + $(XML_INTDIR_A)\list.obj\ + $(XML_INTDIR_A)\nanoftp.obj\ + $(XML_INTDIR_A)\nanohttp.obj\ + $(XML_INTDIR_A)\parser.obj\ + $(XML_INTDIR_A)\parserInternals.obj\ + $(XML_INTDIR_A)\pattern.obj\ + $(XML_INTDIR_A)\relaxng.obj\ + $(XML_INTDIR_A)\SAX.obj\ + $(XML_INTDIR_A)\SAX2.obj\ + $(XML_INTDIR_A)\schematron.obj\ + $(XML_INTDIR_A)\threads.obj\ + $(XML_INTDIR_A)\tree.obj\ + $(XML_INTDIR_A)\uri.obj\ + $(XML_INTDIR_A)\valid.obj\ + $(XML_INTDIR_A)\xinclude.obj\ + $(XML_INTDIR_A)\xlink.obj\ + $(XML_INTDIR_A)\xmlIO.obj\ + $(XML_INTDIR_A)\xmlmemory.obj\ + $(XML_INTDIR_A)\xmlreader.obj\ + $(XML_INTDIR_A)\xmlregexp.obj\ + $(XML_INTDIR_A)\xmlmodule.obj\ + $(XML_INTDIR_A)\xmlsave.obj\ + $(XML_INTDIR_A)\xmlschemas.obj\ + $(XML_INTDIR_A)\xmlschemastypes.obj\ + $(XML_INTDIR_A)\xmlunicode.obj\ + $(XML_INTDIR_A)\xmlwriter.obj\ + $(XML_INTDIR_A)\xpath.obj\ + $(XML_INTDIR_A)\xpointer.obj\ + $(XML_INTDIR_A)\xmlstring.obj + +# Xmllint and friends executables. +UTILS = $(BINDIR)\xmllint.exe\ + $(BINDIR)\xmlcatalog.exe\ + $(BINDIR)\testAutomata.exe\ + $(BINDIR)\testC14N.exe\ + $(BINDIR)\testDocbook.exe\ + $(BINDIR)\testHTML.exe\ + $(BINDIR)\testReader.exe\ + $(BINDIR)\testRelax.exe\ + $(BINDIR)\testRegexp.exe\ + $(BINDIR)\testModule.exe\ + $(BINDIR)\testSAX.exe\ + $(BINDIR)\testSchemas.exe\ + $(BINDIR)\testURI.exe\ + $(BINDIR)\testXPath.exe\ + $(BINDIR)\runtest.exe\ + $(BINDIR)\runsuite.exe\ + $(BINDIR)\testapi.exe\ + $(BINDIR)\testlimits.exe + + +!if "$(WITH_THREADS)" != "no" +UTILS = $(UTILS) $(BINDIR)\testThreads.exe +!endif + + +all : libxml libxmla utils + +libxml : $(BINDIR)\$(XML_SO) + +libxmla : $(BINDIR)\$(XML_A) + +utils : $(UTILS) + +clean : + if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR) + if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A) + if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR) + if exist $(BINDIR) rmdir /S /Q $(BINDIR) + +distclean : clean + if exist config.* del config.* + if exist Makefile del Makefile + +rebuild : clean all + +install-libs : all + if not exist "$(INCPREFIX)\libxml2" mkdir "$(INCPREFIX)\libxml2" + if not exist "$(INCPREFIX)\libxml2\libxml" mkdir "$(INCPREFIX)\libxml2\libxml" + if not exist "$(BINPREFIX)" mkdir "$(BINPREFIX)" + if not exist "$(LIBPREFIX)" mkdir "$(LIBPREFIX)" + copy $(XML_SRCDIR)\include\libxml\*.h "$(INCPREFIX)\libxml2\libxml" + copy $(BINDIR)\$(XML_SO) "$(SOPREFIX)" + copy $(BINDIR)\$(XML_A) "$(LIBPREFIX)" + copy $(BINDIR)\$(XML_IMP) "$(LIBPREFIX)" + copy $(BINDIR)\*.exe "$(BINPREFIX)" + +install : install-libs + copy $(BINDIR)\*.exe "$(BINPREFIX)" + +install-dist : install-libs + copy $(BINDIR)\xml*.exe "$(BINPREFIX)" + +# This is a target for me, to make a binary distribution. Not for the public use, +# keep your hands off :-) +BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION) +BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32 +bindist : all + $(MAKE) /nologo PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)\bin install-dist + cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt + + +# Makes the output directory. +$(BINDIR)\$(DUMMY) : + if not exist $(BINDIR) mkdir $(BINDIR) + touch $(BINDIR)\$(DUMMY) + +# Makes the libxml intermediate directory. +$(XML_INTDIR)\$(DUMMY) : + if not exist $(XML_INTDIR) mkdir $(XML_INTDIR) + touch $(XML_INTDIR)\$(DUMMY) + +# Makes the static libxml intermediate directory. +$(XML_INTDIR_A)\$(DUMMY) : + if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A) + touch $(XML_INTDIR_A)\$(DUMMY) + +# An implicit rule for libxml compilation. +{$(XML_SRCDIR)}.c{$(XML_INTDIR)}.obj: + $(CC) $(CFLAGS) -n$(XML_INTDIR) -c $< + +# An implicit rule for static libxml compilation. +{$(XML_SRCDIR)}.c{$(XML_INTDIR_A)}.obj: + $(CC) $(CFLAGS) -DLIBXML_STATIC -n$(XML_INTDIR_A)\ -c $< + +# Compiles libxml source. Uses the implicit rule for commands. +$(XML_OBJS) : $(XML_INTDIR)\$(DUMMY) + +# Compiles static libxml source. Uses the implicit rule for commands. +$(XML_OBJS_A) : $(XML_INTDIR_A)\$(DUMMY) + +#def4bcb.exe : def4bcb.c + +# Creates the export definition file (DEF) for libxml. +#$(XML_INTDIR)\$(XML_DEF) : $(XML_INTDIR)\$(DUMMY) $(XML_DEF).src def4bcb.exe +# $(CPP) $(CPPFLAGS) -o $(XML_INTDIR)\$(XML_DEF).tmp $(XML_DEF).src +# def4bcb -msnames < $(XML_INTDIR)\$(XML_DEF).tmp > $(XML_INTDIR)\$(XML_DEF) + +# Creates the libxml shared object. +$(BINDIR)\$(XML_SO) : $(BINDIR)\$(DUMMY) $(XML_OBJS) + $(LD) $(LDFLAGS) -Tpd -Gi c0d32.obj $(XML_OBJS),$(BINDIR)\$(XML_SO),,$(LIBS) + +#$(BINDIR)\$(XML_SO) : $(BINDIR)\$(DUMMY) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF) +# $(LD) $(LDFLAGS) -Tpd -Gi c0d32.obj $(XML_OBJS),$(BINDIR)\$(XML_SO),,$(LIBS),$(XML_INTDIR)\$(XML_DEF) + +# Creates the libxml archive. +$(BINDIR)\$(XML_A) : $(BINDIR)\$(DUMMY) $(XML_OBJS_A) + $(AR) $(BINDIR)\$(XML_A) $(ARFLAGS) /u $(XML_OBJS_A) + +# Makes the utils intermediate directory. +$(UTILS_INTDIR)\$(DUMMY) : + if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR) + touch $(UTILS_INTDIR)\$(DUMMY) + +# An implicit rule for xmllint and friends. +!if "$(STATIC)" == "1" +{$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe: + $(CC) -DLIBXML_STATIC -w -tWC $(CFLAGS) -o$(UTILS_INTDIR)\$&.obj -c $< + $(LD) $(LDFLAGS) c0x32.obj $(UTILS_INTDIR)\$&.obj,$@,,$(LIBS) $(XML_A) +!else +{$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe: + $(CC) $(CFLAGS) -tWC -o$(UTILS_INTDIR)\$&.obj -c $< + $(LD) $(LDFLAGS) c0x32.obj $(UTILS_INTDIR)\$&.obj $(XML_IMP),$@,,$(LIBS) +!endif + +# Builds xmllint and friends. Uses the implicit rule for commands. +$(UTILS) : $(UTILS_INTDIR)\$(DUMMY) $(BINDIR)\$(DUMMY) $(BINDIR)\$(XML_SO) $(BINDIR)\$(XML_A) + +# Source dependences should be autogenerated somehow here, but how to +# do it? I have no clue. + diff --git a/src/win32/Makefile.mingw b/src/win32/Makefile.mingw new file mode 100644 index 000000000000..9dfa4abec69d --- /dev/null +++ b/src/win32/Makefile.mingw @@ -0,0 +1,337 @@ +# Makefile for libxml2, specific for Windows, GCC (mingw) and GNU make. +# +# Take a look at the beginning and modify the variables to suit your +# environment. Having done that, you can do a +# +# nmake [all] to build the libxml and the accompanying utilities. +# nmake clean to remove all compiler output files and return to a +# clean state. +# nmake rebuild to rebuild everything from scratch. This basically does +# a 'nmake clean' and then a 'nmake all'. +# nmake install to install the library and its header files. +# +# November 2002, Igor Zlatkovic + +# There should never be a need to modify anything below this line. +# ---------------------------------------------------------------- + +AUTOCONF = .\config.mingw +include $(AUTOCONF) + +# Names of various input and output components. +XML_NAME = xml2 +XML_BASENAME = lib$(XML_NAME) +XML_SO = $(XML_BASENAME).dll +XML_IMP = $(XML_BASENAME).lib +XML_A = $(XML_BASENAME).a + +# Place where we let the compiler put its output. +BINDIR = bin.mingw +XML_INTDIR = int.mingw +XML_INTDIR_A = int.a.mingw +UTILS_INTDIR = int.utils.mingw + +# The preprocessor and its options. +CPP = gcc.exe -E +CPPFLAGS += -I$(XML_SRCDIR)/include -DNOLIBTOOL +ifeq ($(WITH_THREADS),1) +CPPFLAGS += -D_REENTRANT +endif + +# The compiler and its options. +CC = gcc.exe +CFLAGS += -DWIN32 -D_WINDOWS -D_MBCS -DNOLIBTOOL +CFLAGS += -I$(XML_SRCDIR) -I$(XML_SRCDIR)/include -I$(INCPREFIX) $(INCLUDE) +ifneq ($(WITH_THREADS),no) +CFLAGS += -D_REENTRANT +endif +ifeq ($(WITH_THREADS),yes) +CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS +endif +ifeq ($(WITH_THREADS),ctls) +CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS +endif +ifeq ($(WITH_THREADS),native) +CFLAGS += -DHAVE_WIN32_THREADS +endif +ifeq ($(WITH_THREADS),posix) +CFLAGS += -DHAVE_PTHREAD_H +endif + +# The linker and its options. +LD = gcc.exe +LDFLAGS += -Wl,--major-image-version,$(LIBXML_MAJOR_VERSION) +LDFLAGS += -Wl,--minor-image-version,$(LIBXML_MINOR_VERSION) +LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX) +LIBS = +ifeq ($(WITH_FTP),1) +LIBS += -lwsock32 -lws2_32 +endif +ifeq ($(WITH_HTTP),1) +LIBS += -lwsock32 -lws2_32 +endif +ifeq ($(WITH_ICONV),1) +LIBS += -liconv +endif +ifeq ($(WITH_ZLIB),1) +# Could be named differently +# LIBS += -lzdll +LIBS += -lz +endif +ifeq ($(WITH_LZMA),1) +LIBS += -llzma +endif +ifeq ($(WITH_THREADS),posix) +LIBS += -lpthreadGC +endif +ifeq ($(WITH_MODULES),1) +LIBS += -lkernel32 +endif + +LIBS += $(LIB) + +# The archiver and its options. +AR = ar.exe +ARFLAGS = -r + +# Optimisation and debug symbols. +ifeq ($(DEBUG),1) +CFLAGS += -D_DEBUG -g +LDFLAGS += +else +CFLAGS += -DNDEBUG -O2 +LDFLAGS += +endif + + +# Libxml object files. +XML_OBJS = $(XML_INTDIR)/buf.o\ + $(XML_INTDIR)/c14n.o\ + $(XML_INTDIR)/catalog.o\ + $(XML_INTDIR)/chvalid.o\ + $(XML_INTDIR)/debugXML.o\ + $(XML_INTDIR)/dict.o\ + $(XML_INTDIR)/DOCBparser.o\ + $(XML_INTDIR)/encoding.o\ + $(XML_INTDIR)/entities.o\ + $(XML_INTDIR)/error.o\ + $(XML_INTDIR)/globals.o\ + $(XML_INTDIR)/hash.o\ + $(XML_INTDIR)/HTMLparser.o\ + $(XML_INTDIR)/HTMLtree.o\ + $(XML_INTDIR)/legacy.o\ + $(XML_INTDIR)/list.o\ + $(XML_INTDIR)/nanoftp.o\ + $(XML_INTDIR)/nanohttp.o\ + $(XML_INTDIR)/parser.o\ + $(XML_INTDIR)/parserInternals.o\ + $(XML_INTDIR)/pattern.o\ + $(XML_INTDIR)/relaxng.o\ + $(XML_INTDIR)/SAX.o\ + $(XML_INTDIR)/SAX2.o\ + $(XML_INTDIR)/schematron.o\ + $(XML_INTDIR)/threads.o\ + $(XML_INTDIR)/tree.o\ + $(XML_INTDIR)/uri.o\ + $(XML_INTDIR)/valid.o\ + $(XML_INTDIR)/xinclude.o\ + $(XML_INTDIR)/xlink.o\ + $(XML_INTDIR)/xmlIO.o\ + $(XML_INTDIR)/xmlmemory.o\ + $(XML_INTDIR)/xmlreader.o\ + $(XML_INTDIR)/xmlregexp.o\ + $(XML_INTDIR)/xmlmodule.o\ + $(XML_INTDIR)/xmlsave.o\ + $(XML_INTDIR)/xmlschemas.o\ + $(XML_INTDIR)/xmlschemastypes.o\ + $(XML_INTDIR)/xmlunicode.o\ + $(XML_INTDIR)/xmlwriter.o\ + $(XML_INTDIR)/xpath.o\ + $(XML_INTDIR)/xpointer.o\ + $(XML_INTDIR)/xmlstring.o + +XML_SRCS = $(subst .o,.c,$(subst $(XML_INTDIR)/,$(XML_SRCDIR)/,$(XML_OBJS))) + +# Static libxml object files. +XML_OBJS_A = $(XML_INTDIR_A)/buf.o\ + $(XML_INTDIR_A)/c14n.o\ + $(XML_INTDIR_A)/catalog.o\ + $(XML_INTDIR_A)/chvalid.o\ + $(XML_INTDIR_A)/debugXML.o\ + $(XML_INTDIR_A)/dict.o\ + $(XML_INTDIR_A)/DOCBparser.o\ + $(XML_INTDIR_A)/encoding.o\ + $(XML_INTDIR_A)/entities.o\ + $(XML_INTDIR_A)/error.o\ + $(XML_INTDIR_A)/globals.o\ + $(XML_INTDIR_A)/hash.o\ + $(XML_INTDIR_A)/HTMLparser.o\ + $(XML_INTDIR_A)/HTMLtree.o\ + $(XML_INTDIR_A)/legacy.o\ + $(XML_INTDIR_A)/list.o\ + $(XML_INTDIR_A)/nanoftp.o\ + $(XML_INTDIR_A)/nanohttp.o\ + $(XML_INTDIR_A)/parser.o\ + $(XML_INTDIR_A)/parserInternals.o\ + $(XML_INTDIR_A)/pattern.o\ + $(XML_INTDIR_A)/relaxng.o\ + $(XML_INTDIR_A)/SAX.o\ + $(XML_INTDIR_A)/SAX2.o\ + $(XML_INTDIR_A)/schematron.o\ + $(XML_INTDIR_A)/threads.o\ + $(XML_INTDIR_A)/tree.o\ + $(XML_INTDIR_A)/uri.o\ + $(XML_INTDIR_A)/valid.o\ + $(XML_INTDIR_A)/xinclude.o\ + $(XML_INTDIR_A)/xlink.o\ + $(XML_INTDIR_A)/xmlIO.o\ + $(XML_INTDIR_A)/xmlmemory.o\ + $(XML_INTDIR_A)/xmlreader.o\ + $(XML_INTDIR_A)/xmlregexp.o\ + $(XML_INTDIR_A)/xmlmodule.o\ + $(XML_INTDIR_A)/xmlsave.o\ + $(XML_INTDIR_A)/xmlschemas.o\ + $(XML_INTDIR_A)/xmlschemastypes.o\ + $(XML_INTDIR_A)/xmlunicode.o\ + $(XML_INTDIR_A)/xmlwriter.o\ + $(XML_INTDIR_A)/xpath.o\ + $(XML_INTDIR_A)/xpointer.o\ + $(XML_INTDIR_A)/xmlstring.o + +XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A))) + +# Xmllint and friends executables. +UTILS = $(BINDIR)/xmllint.exe\ + $(BINDIR)/xmlcatalog.exe\ + $(BINDIR)/testAutomata.exe\ + $(BINDIR)/testC14N.exe\ + $(BINDIR)/testDocbook.exe\ + $(BINDIR)/testHTML.exe\ + $(BINDIR)/testReader.exe\ + $(BINDIR)/testRegexp.exe\ + $(BINDIR)/testModule.exe\ + $(BINDIR)/testRelax.exe\ + $(BINDIR)/testSAX.exe\ + $(BINDIR)/testSchemas.exe\ + $(BINDIR)/testURI.exe\ + $(BINDIR)/testXPath.exe\ + $(BINDIR)/runtest.exe\ + $(BINDIR)/runsuite.exe\ + $(BINDIR)/testapi.exe\ + $(BINDIR)/testlimits.exe + +ifneq ($(WITH_THREADS),no) +UTILS += $(BINDIR)/testThreads.exe +endif + +all : dep libxml libxmla utils + +libxml : $(BINDIR)/$(XML_SO) + +libxmla : $(BINDIR)/$(XML_A) + +utils : $(UTILS) + +clean : + cmd.exe /C "if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)" + cmd.exe /C "if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)" + cmd.exe /C "if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)" + cmd.exe /C "if exist $(BINDIR) rmdir /S /Q $(BINDIR)" + cmd.exe /C "if exist depends.mingw del depends.mingw" + +distclean : clean + cmd.exe /C "if exist config.* del config.*" + cmd.exe /C "if exist Makefile del Makefile" + +rebuild : clean all + +install-libs : all + cmd.exe /C "if not exist $(INCPREFIX)\libxml2 mkdir $(INCPREFIX)\libxml2" + cmd.exe /C "if not exist $(INCPREFIX)\libxml2\libxml mkdir $(INCPREFIX)\libxml2\libxml" + cmd.exe /C "if not exist $(BINPREFIX) mkdir $(BINPREFIX)" + cmd.exe /C "if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)" + cmd.exe /C "copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml2\libxml" + cmd.exe /C "copy $(BINDIR)\$(XML_SO) $(SOPREFIX)" + cmd.exe /C "copy $(BINDIR)\$(XML_A) $(LIBPREFIX)" + cmd.exe /C "copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)" + cmd.exe /C "copy $(BINDIR)\xml*.exe $(BINPREFIX)" + +install : install-libs + cmd.exe /C "copy $(BINDIR)\*.exe $(BINPREFIX)" + +install-dist : install-libs + cmd.exe /C "copy $(BINDIR)\xml*.exe $(BINPREFIX)" + +# This is a target for me, to make a binary distribution. Not for the public use, +# keep your hands off :-) +BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION) +BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32 +bindist : all + $(MAKE) PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)/bin install-dist + cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt + + +# Creates the dependency file +dep : + $(CC) $(CFLAGS) -M $(XML_SRCS) > depends.mingw + + +# Makes the output directory. +$(BINDIR) : + cmd.exe /C if not exist $(BINDIR) mkdir $(BINDIR) + + +# Makes the libxml intermediate directory. +$(XML_INTDIR) : + cmd.exe /C if not exist $(XML_INTDIR) mkdir $(XML_INTDIR) + +# Makes the static libxml intermediate directory. +$(XML_INTDIR_A) : + cmd.exe /C if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A) + +# An implicit rule for libxml compilation. +$(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c + $(CC) $(CFLAGS) -o $@ -c $< + +# An implicit rule for static libxml compilation. +$(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c + $(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $< + + +# Compiles libxml source. Uses the implicit rule for commands. +$(XML_OBJS) : $(XML_INTDIR) + +# Compiles static libxml source. Uses the implicit rule for commands. +$(XML_OBJS_A) : $(XML_INTDIR_A) + +# Creates the libxml shared object. +XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP) +$(BINDIR)/$(XML_SO) : $(BINDIR) $(XML_OBJS) + $(LD) $(XMLSO_LDFLAGS) -o $(BINDIR)/$(XML_SO) $(XML_OBJS) $(LIBS) + +# Creates the libxml archive. +$(BINDIR)/$(XML_A) : $(BINDIR) $(XML_OBJS_A) + $(AR) $(ARFLAGS) $(BINDIR)\$(XML_A) $(XML_OBJS_A) + + +# Makes the utils intermediate directory. +$(UTILS_INTDIR) : + cmd.exe /C if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR) + +# An implicit rule for xmllint and friends. +ifeq ($(STATIC),1) +$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c + $(CC) -DLIBXML_STATIC $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$( + +# There should never be a need to modify anything below this line. +# ---------------------------------------------------------------- + +AUTOCONF = .\config.msvc +!include $(AUTOCONF) + +# Names of various input and output components. +XML_NAME = xml2 +XML_BASENAME = lib$(XML_NAME) +XML_SO = $(XML_BASENAME).dll +XML_RES = $(XML_BASENAME).res +XML_IMP = $(XML_BASENAME).lib +XML_DEF = $(XML_BASENAME).def +XML_A = $(XML_BASENAME)_a.lib +XML_A_DLL = $(XML_BASENAME)_a_dll.lib + +# Place where we let the compiler put its output. +BINDIR = bin.msvc +XML_INTDIR = int.msvc +XML_INTDIR_A = int.a.msvc +XML_INTDIR_A_DLL = int.a.dll.msvc +UTILS_INTDIR = int.utils.msvc + +# The preprocessor and its options. +CPP = cl.exe /EP +CPPFLAGS = /nologo /I$(XML_SRCDIR)\include /D "NOLIBTOOL" +!if "$(WITH_THREADS)" != "no" +CPPFLAGS = $(CPPFLAGS) /D "_REENTRANT" +!endif + +# The compiler and its options. +CC = cl.exe +CFLAGS = /nologo /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W3 /wd4244 /wd4267 $(CRUNTIME) +CFLAGS = $(CFLAGS) /I$(XML_SRCDIR) /I$(XML_SRCDIR)\include /I$(INCPREFIX) +!if "$(WITH_THREADS)" != "no" +CFLAGS = $(CFLAGS) /D "_REENTRANT" +!endif +!if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls" +CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS" /D "HAVE_COMPILER_TLS" +!else if "$(WITH_THREADS)" == "native" +CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS" +!else if "$(WITH_THREADS)" == "posix" +CFLAGS = $(CFLAGS) /D "HAVE_PTHREAD_H" +!endif +CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE + +# The linker and its options. +LD = link.exe +LDFLAGS = /nologo /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION) +LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX) +LIBS = +!if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1" +LIBS = $(LIBS) wsock32.lib ws2_32.lib +!endif +!if "$(WITH_ICONV)" == "1" +LIBS = $(LIBS) iconv.lib +!endif +!if "$(WITH_ICU)" == "1" +!if "$(STATIC)" == "1" +LIBS = $(LIBS) advapi32.lib sicuuc.lib sicuin.lib sicudt.lib +!else +LIBS = $(LIBS) icuuc.lib icuin.lib icudt.lib +!endif +!endif +!if "$(WITH_ZLIB)" == "1" +# could be named differently zdll or zlib +# LIBS = $(LIBS) zdll.lib +LIBS = $(LIBS) zlib.lib +!endif +!if "$(WITH_LZMA)" == "1" +LIBS = $(LIBS) liblzma.lib +!endif +!if "$(WITH_THREADS)" == "posix" +LIBS = $(LIBS) pthreadVC.lib +!endif +!if "$(WITH_MODULES)" == "1" +LIBS = $(LIBS) kernel32.lib +!endif + +# The archiver and its options. +AR = lib.exe +ARFLAGS = /nologo + +# Optimisation and debug symbols. +!if "$(DEBUG)" == "1" +CFLAGS = $(CFLAGS) /D "_DEBUG" /Od /Z7 +LDFLAGS = $(LDFLAGS) /DEBUG +!else +CFLAGS = $(CFLAGS) /D "NDEBUG" /O2 +# commented out as this break VC10 c.f. 634846 +# LDFLAGS = $(LDFLAGS) /OPT:NOWIN98 +LDFLAGS = $(LDFLAGS) +!endif + +# append CFLAGS etc. passed on command line +CPPFLAGS = $(CPPFLAGS) $(EXTRA_CPPFLAGS) +CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) +LDFLAGS = $(LDFLAGS) $(EXTRA_LDFLAGS) + +# Libxml object files. +XML_OBJS = $(XML_INTDIR)\buf.obj\ + $(XML_INTDIR)\c14n.obj\ + $(XML_INTDIR)\catalog.obj\ + $(XML_INTDIR)\chvalid.obj\ + $(XML_INTDIR)\debugXML.obj\ + $(XML_INTDIR)\dict.obj\ + $(XML_INTDIR)\DOCBparser.obj\ + $(XML_INTDIR)\encoding.obj\ + $(XML_INTDIR)\entities.obj\ + $(XML_INTDIR)\error.obj\ + $(XML_INTDIR)\globals.obj\ + $(XML_INTDIR)\hash.obj\ + $(XML_INTDIR)\HTMLparser.obj\ + $(XML_INTDIR)\HTMLtree.obj\ + $(XML_INTDIR)\legacy.obj\ + $(XML_INTDIR)\list.obj\ + $(XML_INTDIR)\nanoftp.obj\ + $(XML_INTDIR)\nanohttp.obj\ + $(XML_INTDIR)\parser.obj\ + $(XML_INTDIR)\parserInternals.obj\ + $(XML_INTDIR)\pattern.obj\ + $(XML_INTDIR)\relaxng.obj\ + $(XML_INTDIR)\SAX2.obj\ + $(XML_INTDIR)\SAX.obj\ + $(XML_INTDIR)\schematron.obj\ + $(XML_INTDIR)\threads.obj\ + $(XML_INTDIR)\tree.obj\ + $(XML_INTDIR)\uri.obj\ + $(XML_INTDIR)\valid.obj\ + $(XML_INTDIR)\xinclude.obj\ + $(XML_INTDIR)\xlink.obj\ + $(XML_INTDIR)\xmlIO.obj\ + $(XML_INTDIR)\xmlmemory.obj\ + $(XML_INTDIR)\xmlreader.obj\ + $(XML_INTDIR)\xmlregexp.obj\ + $(XML_INTDIR)\xmlmodule.obj\ + $(XML_INTDIR)\xmlsave.obj\ + $(XML_INTDIR)\xmlschemas.obj\ + $(XML_INTDIR)\xmlschemastypes.obj\ + $(XML_INTDIR)\xmlunicode.obj\ + $(XML_INTDIR)\xmlwriter.obj\ + $(XML_INTDIR)\xpath.obj\ + $(XML_INTDIR)\xpointer.obj\ + $(XML_INTDIR)\xmlstring.obj + +# Static libxml object files. +XML_OBJS_A = $(XML_INTDIR_A)\buf.obj\ + $(XML_INTDIR_A)\c14n.obj\ + $(XML_INTDIR_A)\catalog.obj\ + $(XML_INTDIR_A)\chvalid.obj\ + $(XML_INTDIR_A)\debugXML.obj\ + $(XML_INTDIR_A)\dict.obj\ + $(XML_INTDIR_A)\DOCBparser.obj\ + $(XML_INTDIR_A)\encoding.obj\ + $(XML_INTDIR_A)\entities.obj\ + $(XML_INTDIR_A)\error.obj\ + $(XML_INTDIR_A)\globals.obj\ + $(XML_INTDIR_A)\hash.obj\ + $(XML_INTDIR_A)\HTMLparser.obj\ + $(XML_INTDIR_A)\HTMLtree.obj\ + $(XML_INTDIR_A)\legacy.obj\ + $(XML_INTDIR_A)\list.obj\ + $(XML_INTDIR_A)\nanoftp.obj\ + $(XML_INTDIR_A)\nanohttp.obj\ + $(XML_INTDIR_A)\parser.obj\ + $(XML_INTDIR_A)\parserInternals.obj\ + $(XML_INTDIR_A)\pattern.obj\ + $(XML_INTDIR_A)\relaxng.obj\ + $(XML_INTDIR_A)\SAX2.obj\ + $(XML_INTDIR_A)\SAX.obj\ + $(XML_INTDIR_A)\schematron.obj\ + $(XML_INTDIR_A)\threads.obj\ + $(XML_INTDIR_A)\tree.obj\ + $(XML_INTDIR_A)\uri.obj\ + $(XML_INTDIR_A)\valid.obj\ + $(XML_INTDIR_A)\xinclude.obj\ + $(XML_INTDIR_A)\xlink.obj\ + $(XML_INTDIR_A)\xmlIO.obj\ + $(XML_INTDIR_A)\xmlmemory.obj\ + $(XML_INTDIR_A)\xmlreader.obj\ + $(XML_INTDIR_A)\xmlregexp.obj\ + $(XML_INTDIR_A)\xmlmodule.obj\ + $(XML_INTDIR_A)\xmlsave.obj\ + $(XML_INTDIR_A)\xmlschemas.obj\ + $(XML_INTDIR_A)\xmlschemastypes.obj\ + $(XML_INTDIR_A)\xmlunicode.obj\ + $(XML_INTDIR_A)\xmlwriter.obj\ + $(XML_INTDIR_A)\xpath.obj\ + $(XML_INTDIR_A)\xpointer.obj\ + $(XML_INTDIR_A)\xmlstring.obj + +# Static libxml object files. +XML_OBJS_A_DLL = $(XML_INTDIR_A_DLL)\buf.obj\ + $(XML_INTDIR_A_DLL)\c14n.obj\ + $(XML_INTDIR_A_DLL)\catalog.obj\ + $(XML_INTDIR_A_DLL)\chvalid.obj\ + $(XML_INTDIR_A_DLL)\debugXML.obj\ + $(XML_INTDIR_A_DLL)\dict.obj\ + $(XML_INTDIR_A_DLL)\DOCBparser.obj\ + $(XML_INTDIR_A_DLL)\encoding.obj\ + $(XML_INTDIR_A_DLL)\entities.obj\ + $(XML_INTDIR_A_DLL)\error.obj\ + $(XML_INTDIR_A_DLL)\globals.obj\ + $(XML_INTDIR_A_DLL)\hash.obj\ + $(XML_INTDIR_A_DLL)\HTMLparser.obj\ + $(XML_INTDIR_A_DLL)\HTMLtree.obj\ + $(XML_INTDIR_A_DLL)\legacy.obj\ + $(XML_INTDIR_A_DLL)\list.obj\ + $(XML_INTDIR_A_DLL)\nanoftp.obj\ + $(XML_INTDIR_A_DLL)\nanohttp.obj\ + $(XML_INTDIR_A_DLL)\parser.obj\ + $(XML_INTDIR_A_DLL)\parserInternals.obj\ + $(XML_INTDIR_A_DLL)\pattern.obj\ + $(XML_INTDIR_A_DLL)\relaxng.obj\ + $(XML_INTDIR_A_DLL)\SAX2.obj\ + $(XML_INTDIR_A_DLL)\SAX.obj\ + $(XML_INTDIR_A_DLL)\schematron.obj\ + $(XML_INTDIR_A_DLL)\threads.obj\ + $(XML_INTDIR_A_DLL)\tree.obj\ + $(XML_INTDIR_A_DLL)\uri.obj\ + $(XML_INTDIR_A_DLL)\valid.obj\ + $(XML_INTDIR_A_DLL)\xinclude.obj\ + $(XML_INTDIR_A_DLL)\xlink.obj\ + $(XML_INTDIR_A_DLL)\xmlIO.obj\ + $(XML_INTDIR_A_DLL)\xmlmemory.obj\ + $(XML_INTDIR_A_DLL)\xmlreader.obj\ + $(XML_INTDIR_A_DLL)\xmlregexp.obj\ + $(XML_INTDIR_A_DLL)\xmlmodule.obj\ + $(XML_INTDIR_A_DLL)\xmlsave.obj\ + $(XML_INTDIR_A_DLL)\xmlschemas.obj\ + $(XML_INTDIR_A_DLL)\xmlschemastypes.obj\ + $(XML_INTDIR_A_DLL)\xmlunicode.obj\ + $(XML_INTDIR_A_DLL)\xmlwriter.obj\ + $(XML_INTDIR_A_DLL)\xpath.obj\ + $(XML_INTDIR_A_DLL)\xpointer.obj\ + $(XML_INTDIR_A_DLL)\xmlstring.obj + +!if "$(WITH_LZMA)" == "1" +XML_OBJS = $(XML_OBJS) $(XML_INTDIR)\xzlib.obj +XML_OBJS_A = $(XML_OBJS_A) $(XML_INTDIR_A)\xzlib.obj +XML_OBJS_A_DLL = $(XML_OBJS_A_DLL) $(XML_INTDIR_A_DLL)\xzlib.obj +!endif + +# Xmllint and friends executables. +UTILS = $(BINDIR)\xmllint.exe\ + $(BINDIR)\xmlcatalog.exe\ + $(BINDIR)\testAutomata.exe\ + $(BINDIR)\testC14N.exe\ + $(BINDIR)\testDocbook.exe\ + $(BINDIR)\testHTML.exe\ + $(BINDIR)\testReader.exe\ + $(BINDIR)\testRelax.exe\ + $(BINDIR)\testRegexp.exe\ + $(BINDIR)\testModule.exe\ + $(BINDIR)\testSAX.exe\ + $(BINDIR)\testSchemas.exe\ + $(BINDIR)\testURI.exe\ + $(BINDIR)\testXPath.exe\ + $(BINDIR)\runtest.exe\ + $(BINDIR)\runsuite.exe\ + $(BINDIR)\runxmlconf.exe\ + $(BINDIR)\testapi.exe\ + $(BINDIR)\testchar.exe\ + $(BINDIR)\testdict.exe\ + $(BINDIR)\testlimits.exe\ + $(BINDIR)\testrecurse.exe + +!if "$(WITH_THREADS)" != "no" +UTILS = $(UTILS) $(BINDIR)\testThreads.exe +!endif + +!if "$(VCMANIFEST)" == "1" +_VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 +_VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 +!else +_VC_MANIFEST_EMBED_EXE= +_VC_MANIFEST_EMBED_DLL= +!endif + +all : libxml libxmla libxmladll utils + +libxml : $(BINDIR)\$(XML_SO) + +libxmla : $(BINDIR)\$(XML_A) + +libxmladll : $(BINDIR)\$(XML_A_DLL) + +utils : $(UTILS) + +clean : + if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR) + if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A) + if exist $(XML_INTDIR_A_DLL) rmdir /S /Q $(XML_INTDIR_A_DLL) + if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR) + if exist $(BINDIR) rmdir /S /Q $(BINDIR) + +distclean : clean + if exist config.* del config.* + if exist Makefile del Makefile + +rebuild : clean all + +install-libs : all + if not exist $(INCPREFIX)\libxml2 mkdir $(INCPREFIX)\libxml2 + if not exist $(INCPREFIX)\libxml2\libxml mkdir $(INCPREFIX)\libxml2\libxml + if not exist $(BINPREFIX) mkdir $(BINPREFIX) + if not exist $(LIBPREFIX) mkdir $(LIBPREFIX) + if not exist $(SOPREFIX) mkdir $(SOPREFIX) + copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml2\libxml + copy $(BINDIR)\$(XML_SO) $(SOPREFIX) + copy $(BINDIR)\$(XML_A) $(LIBPREFIX) + copy $(BINDIR)\$(XML_A_DLL) $(LIBPREFIX) + copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX) + +install : install-libs + copy $(BINDIR)\*.exe $(BINPREFIX) + -copy $(BINDIR)\*.pdb $(BINPREFIX) + +install-dist : install-libs + copy $(BINDIR)\xml*.exe $(BINPREFIX) + -copy $(BINDIR)\xml*.pdb $(BINPREFIX) + +# This is a target for me, to make a binary distribution. Not for the public use, +# keep your hands off :-) +BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION) +BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32 +bindist : all + $(MAKE) /nologo PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)\bin install-dist + cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt + + +# Makes the output directory. +$(BINDIR) : + if not exist $(BINDIR) mkdir $(BINDIR) + + +# Makes the libxml intermediate directory. +$(XML_INTDIR) : + if not exist $(XML_INTDIR) mkdir $(XML_INTDIR) + +# Makes the static libxml intermediate directory. +$(XML_INTDIR_A) : + if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A) + +# Makes the static for dll libxml intermediate directory. +$(XML_INTDIR_A_DLL) : + if not exist $(XML_INTDIR_A_DLL) mkdir $(XML_INTDIR_A_DLL) + +# An implicit rule for libxml compilation. +{$(XML_SRCDIR)}.c{$(XML_INTDIR)}.obj:: + $(CC) $(CFLAGS) /Fo$(XML_INTDIR)\ /c $< + +# An implicit rule for static libxml compilation. +{$(XML_SRCDIR)}.c{$(XML_INTDIR_A)}.obj:: + $(CC) $(CFLAGS) /D "LIBXML_STATIC" /Fo$(XML_INTDIR_A)\ /c $< + +# An implicit rule for static for dll libxml compilation. +{$(XML_SRCDIR)}.c{$(XML_INTDIR_A_DLL)}.obj:: + $(CC) $(CFLAGS) /D "LIBXML_STATIC" /D "LIBXML_STATIC_FOR_DLL" /Fo$(XML_INTDIR_A_DLL)\ /c $< + +# Compiles libxml source. Uses the implicit rule for commands. +$(XML_OBJS) : $(XML_INTDIR) + +# Compiles static libxml source. Uses the implicit rule for commands. +$(XML_OBJS_A) : $(XML_INTDIR_A) + +# Compiles static for dll libxml source. Uses the implicit rule for commands. +$(XML_OBJS_A_DLL) : $(XML_INTDIR_A_DLL) + +# Creates the export definition file (DEF) for libxml. +$(XML_INTDIR)\$(XML_DEF) : $(XML_INTDIR) $(XML_DEF).src + $(CPP) $(CPPFLAGS) $(XML_DEF).src > $(XML_INTDIR)\$(XML_DEF) +$(XML_INTDIR)\$(XML_RES) : $(XML_INTDIR) libxml2.rc + rc -Fo $(XML_INTDIR)\$(XML_RES) libxml2.rc + +# Creates the libxml shared object. +$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF) $(XML_INTDIR)\$(XML_RES) + $(LD) $(LDFLAGS) /DLL \ + /IMPLIB:$(BINDIR)\$(XML_IMP) /OUT:$(BINDIR)\$(XML_SO) $(XML_OBJS) $(XML_INTDIR)\$(XML_RES) $(LIBS) + @$(_VC_MANIFEST_EMBED_DLL) + +#$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF) +# $(LD) $(LDFLAGS) /DLL /DEF:$(XML_INTDIR)\$(XML_DEF) \ +# /IMPLIB:$(BINDIR)\$(XML_IMP) /OUT:$(BINDIR)\$(XML_SO) $(XML_OBJS) $(LIBS) + +# Creates the libxml archive. +$(BINDIR)\$(XML_A) : $(BINDIR) $(XML_OBJS_A) + $(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(XML_A) $(XML_OBJS_A) + +# Creates the libxml static for dll archive. +$(BINDIR)\$(XML_A_DLL) : $(BINDIR) $(XML_OBJS_A_DLL) + $(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(XML_A_DLL) $(XML_OBJS_A_DLL) + +# Makes the utils intermediate directory. +$(UTILS_INTDIR) : + if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR) + +# An implicit rule for xmllint and friends. +!if "$(STATIC)" == "1" +{$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe: + $(CC) /D "LIBXML_STATIC" $(CFLAGS) /Fo$(UTILS_INTDIR)\ /c $< + $(LD) $(LDFLAGS) /OUT:$@ $(XML_A) $(LIBS) $(UTILS_INTDIR)\$( .memdump + @echo ## XPath regression tests + @-$(BINDIR)\testXPath.exe | find /C "support not compiled in" 1>nul + @if %ERRORLEVEL% NEQ 0 @( \ + echo Skipping debug not compiled in\ + @exit 0 \ + ) + @for %%I in ($(XML_SRCDIR)\test\XPath\expr\*.*) do @( \ + @IF NOT EXIST $(XML_SRCDIR)\result\XPath\expr\%%~nxI ( \ + @echo New test %%~nxI &&\ + @echo %%~nxI &&\ + $(BINDIR)\testXPath.exe -f --expr %%I > $(XML_SRCDIR)/result/XPath/expr/%%~nxI &&\ + findstr /C:"MEMORY ALLOCATED : 0" \ + ) ELSE ( \ + $(BINDIR)\testXPath.exe -f --expr %%I 2>&1 > result.%%~nxI &&\ + fc $(XML_SRCDIR)\result\XPath\expr\%%~nxI result.%%~nxI >nul &\ + iF ERRORLEVEL 1 exit 1 & \ + findstr "MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" >nul &&\ + del result.%%~nxI \ + ) \ + ) + @for %%I in ($(XML_SRCDIR)\test\XPath\docs\*.*) do @( \ + for %%J in ($(XML_SRCDIR)\test\XPath\tests\%%~nxI*.*) do @( \ + if not exist $(XML_SRCDIR)\result\XPath\tests\%%~nxJ ( \ + $(BINDIR)\testXPath.exe -f -i %%I %%J > $(XML_SRCDIR)\result\XPath\tests\%%~nxJ &&\ + findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > nul \ + ) ELSE ( \ + $(BINDIR)\testXPAth.exe -f -i %%I %%J 2>&1 > result.%%~nxJ &&\ + findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0">null &&\ + fc $(XML_SRCDIR)\result\XPath\tests\%%~nxJ result.%%~nxJ >null & \ + IF ERRORLEVEL 1 (echo Error: %%I %%J & exit 1) & \ + del result.%%~nxJ \ + )\ + )\ + ) + +XMLtests : $(BINDIR)\xmllint.exe + @echo. 2> .memdump + @echo ## XML regression tests + -@for %%I in ($(XML_SRCDIR)\test\*) do @( \ + if not exist $(XML_SRCDIR)\result\%%~nxI ( \ + echo New test file %%~nxI &\ + $(BINDIR)\xmllint.exe %%I > $(XML_SRCDIR)\result\%%~nxI && \ + findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null \ + ) ELSE ( \ + $(BINDIR)\xmllint.exe %%I 2>&1 > result.%%~nxI && \ + findstr /C:"MEMORY ALLOC" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null && \ + fc $(XML_SRCDIR)\result\%%~nxI result.%%~nxI > null && \ + $(BINDIR)\xmllint.exe result.%%~nxI 2>&1 > result2.%%~nxI | findstr /V /C:"failed to load external entity" && \ + fc result.%%~nxI result2.%%~nxI & \ + del result.%%~nxI result2.%%~nxI\ + ) \ + ) + + + + + + diff --git a/src/win32/Readme.txt b/src/win32/Readme.txt new file mode 100644 index 000000000000..d02070e28e87 --- /dev/null +++ b/src/win32/Readme.txt @@ -0,0 +1,226 @@ + + Windows port + ============ + +This directory contains the files required to build this software on the +native Windows platform. This is not a place to look for help if you are +using a POSIX emulator, such as Cygwin. Check the Unix instructions for +that. + + + +CONTENTS +======== + +1. General + 1.1 Building From the Command-Line + 1.2 Configuring The Source + 1.3 Compiling + 1.4 Installing + +2. Compiler Specifics + 2.1 Microsoft Visual C/C++ + 2.1 GNU C/C++, Mingw Edition + 2.2 Borland C++ Builder + 2.2.1 Building with iconv support + 2.2.2 Compatibility problems with MSVC (and probably CYGWIN) + 2.2.3 Other caveats + + + + +1. General +========== + + +1.1 Building From The Command-Line +---------------------------------- + +This is the easiest, preferred and currently supported method. It can +be that a subdirectory of the directory where this file resides +contains project files for some IDE. If you want to use that, please +refer to the readme file within that subdirectory. + +In order to build from the command-line you need to make sure that +your compiler works from the command line. This is not always the +case, often the required environment variables are missing. If you are +not sure, test if this works first. If it doesn't, you will first have +to configure your compiler suite to run from the command-line - please +refer to your compiler's documentation regarding that. + +The first thing you want to do is configure the source. You can have +the configuration script do this automatically for you. The +configuration script is written in JScript, a Microsoft's +implementation of the ECMA scripting language. Almost every Windows +machine can execute this through the Windows Scripting Host. If your +system lacks the ability to execute JScript for some reason, you must +perform the configuration manually and you are on your own with that. + +The second step is compiling the source and, optionally, installing it +to the location of your choosing. + + +1.2 Configuring The Source +-------------------------- + +The configuration script accepts numerous options. Some of these +affect features which will be available in the compiled software, +others affect the way the software is built and installed. To see a +full list of options supported by the configuration script, run + + cscript configure.js help + +from the win32 subdirectory. The configuration script will present you +the options it accepts and give a biref explanation of these. In every +case you will have two sets of options. The first set is specific to +the software you are building and the second one is specific to the +Windows port. + +Once you have decided which options suit you, run the script with that +options. Here is an example: + + cscript configure.js compiler=msvc prefix=c:\opt + include=c:\opt\include lib=c:\opt\lib debug=yes + +The previous example will configure the process to use the Microsoft's +compiler, install the library in c:\opt, use c:\opt\include and +c:\opt\lib as additional search paths for the compiler and the linker +and build executables with debug symbols. + +Note: Please do not use path names which contain spaces. This will +fail. Allowing this would require me to put almost everything in the +Makefile in quotas and that looks quite ugly with my +syntax-highlighting engine. If you absolutely must use spaces in paths +send me an email and tell me why. If there are enough of you out there +who need this, or if a single one has a very good reason, I will +modify the Makefile to allow spaces in paths. + + +1.3 Compiling +------------- + +After the configuration stage has been completed, you want to build +the software. You will have to use the make tool which comes with +your compiler. If you, for example, configured the source to build +with Microsoft's MSVC compiler, you would use the NMAKE utility. If +you configured it to build with GNU C compiler, mingw edition, you +would use the GNU make. Assuming you use MSVC, type + + nmake /f Makefile.msvc + +and if you use MinGW, you would type + + make -f Makefile.mingw + +and if you use Borland's compiler, you would type + + bmake -f Makefile.bcb + +in the win32 subdirectory. When the building completes, you will find +the executable files in win32\bin.* directory, where * stands for the +name of the compiler you have used. + + +1.4 Installing +-------------- + +You can install the software into the directory you specified to the +configure script during the configure stage by typing (with MSVC in +this example) + + nmake /f Makefile.msvc install + +That would be it, enjoy. + + + + + +2. Compiler Specifics +===================== + + +2.1 Microsoft Visual C/C++ +-------------------------- + +If you use the compiler which comes with Visual Studio .NET, note that +it will link to its own C-runtime named msvcr70.dll or msvcr71.dll. This +file is not available on any machine which doesn't have Visual Studio +.NET installed. + + +2.2 GNU C/C++, Mingw edition +---------------------------- + +When specifying paths to configure.js, please use slashes instead of +backslashes for directory separation. Sometimes Mingw needs this. If +this is the case, and you specify backslashes, then the compiler will +complain about not finding necessary header files. + + +2.2 Borland C++ Builder +----------------------- + +To compile libxml2 with the BCB6 compiler and associated tools, just follow +the basic instructions found in this file file. Be sure to specify +the "compiler=bcb" option when running the configure script. To compile the +library and test programs, just type + + make -fMakefile.bcb + +That should be all that's required. But there are a few other things to note: + +2.2.1 Building with iconv support + +If you configure libxml2 to include iconv support, you will obviously need to +obtain the iconv library and include files. To get them, just follow the links +at http://www.gnu.org/software/libiconv/ - there are pre-compiled Win32 +versions available, but note that these where built with MSVC. Hence the +supplied import library is in COFF format rather than OMF format. You can +convert this library by using Borland's COFF2OMF utility, or use IMPLIB to +build a new import library from the DLL. Alternatively, it is possible to +obtain the iconv source, and build the DLL using the Borland compiler. + +There is a minor problem with the header files for iconv - they expect a +macro named "EILSEQ" in errno.h, but this is not defined in the Borland +headers, and its absence can cause problems. To circumvent this problem, I +define EILSEQ=2 in Makefile.bcb. The value "2" is the value for ENOFILE (file +not found). This should not have any disastrous side effects beyond possibly +displaying a misleading error message in certain situations. + +2.2.2 Compatibility problems with MSVC (and probably CYGWIN) + +A libxml2 DLL generated by BCB is callable from MSVC programs, but there is a +minor problem with the names of the symbols exported from the library. The +Borland compiler, by default, prepends an underscore character to global +identifiers (functions and global variables) when generating object files. +Hence the function "xmlAddChild" is added to the DLL with the name +"_xmlAddChild". The MSVC compiler does not have this behaviour, and looks for +the unadorned name. I currently circumvent this problem by writing a .def file +which causes BOTH the adorned and unadorned names to be exported from the DLL. +This behaviour may not be supported in the future. + +An even worse problem is that of generating an import library for the DLL. The +Borland-generated DLL is in OMF format. MSVC expects libraries in COFF format, +but they don't provide a "OMF2COFF" utility, or even the equivalent of +Borland's IMPLIB utility. But it is possible to create an import lib from the +.def file, using the command: + LIB /DEF:libxml2.def + +If you don't have the .def file, it's possible to create one manually. Use +DUMPBIN /EXPORTS /OUT:libxml2.tmp libxml2.dll to get a list of the exported +names, and edit this into .def file format. + +A similar problem is likely with Cygwin. + +2.2.3 Other caveats + +We have tested this only with BCB6, Professional Edition, and BCB 5.5 free +command-line tools. + + + +Authors: Igor Zlatkovic + Eric Zurcher + + diff --git a/src/win32/VC10/README.vc10 b/src/win32/VC10/README.vc10 new file mode 100644 index 000000000000..25c385bd6687 --- /dev/null +++ b/src/win32/VC10/README.vc10 @@ -0,0 +1,27 @@ + +README file for VC10 project files for libxml2 +---------------------------------------------- + +to clarify: This is not the readme file for the whole libxml2 project. +Rather, it's a readme for the VC10 project files, attached to the libxml2 project. + +Quick Start +----------- + +1) To use, load the libxml2.sln solution file into visual studio +2) check and correct paths for dependent "iconv" project which most certainly +are wrong on your environment. +3) Compile all projects + + +Background Info +--------------- + +Running of "configure.sh" won't make sense since VS doesn't support +this kind of build system and the environment is pretty much known already +if you're using Visual Studio. Instead, a preconfigured "config.h" file +is provided in the "win32\VC10" directory and referenced by the project +files already. + +The compile process is not completely warning-free: Some warnings will +appear during compile which can be ignored. diff --git a/src/win32/VC10/RuleSet1.ruleset b/src/win32/VC10/RuleSet1.ruleset new file mode 100644 index 000000000000..9985a6c61674 --- /dev/null +++ b/src/win32/VC10/RuleSet1.ruleset @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/win32/configure.js b/src/win32/configure.js new file mode 100644 index 000000000000..cec64c539080 --- /dev/null +++ b/src/win32/configure.js @@ -0,0 +1,718 @@ +/* Configure script for libxml, specific for Windows with Scripting Host. + * + * This script will configure the libxml build process and create necessary files. + * Run it with an 'help', or an invalid option and it will tell you what options + * it accepts. + * + * March 2002, Igor Zlatkovic + */ + +/* The source directory, relative to the one where this file resides. */ +var srcDirXml = ".."; +var srcDirUtils = ".."; +/* Base name of what we are building. */ +var baseName = "libxml2"; +/* Configure file which contains the version and the output file where + we can store our build configuration. */ +var configFile = srcDirXml + "\\configure.ac"; +var versionFile = ".\\config.msvc"; +/* Input and output files regarding the libxml features. */ +var optsFileIn = srcDirXml + "\\include\\libxml\\xmlversion.h.in"; +var optsFile = srcDirXml + "\\include\\libxml\\xmlversion.h"; +/* Version strings for the binary distribution. Will be filled later + in the code. */ +var verMajor; +var verMinor; +var verMicro; +var verMicroSuffix; +var verCvs; +var useCvsVer = true; +/* Libxml features. */ +var withTrio = false; +var withThreads = "native"; +var withFtp = true; +var withHttp = true; +var withHtml = true; +var withC14n = true; +var withCatalog = true; +var withDocb = true; +var withXpath = true; +var withXptr = true; +var withXinclude = true; +var withIconv = true; +var withIcu = false; +var withIso8859x = false; +var withZlib = false; +var withLzma = false; +var withDebug = true; +var withMemDebug = false; +var withRunDebug = false; +var withSchemas = true; +var withSchematron = true; +var withRegExps = true; +var withModules = true; +var withTree = true; +var withReader = true; +var withWriter = true; +var withWalker = true; +var withPattern = true; +var withPush = true; +var withValid = true; +var withSax1 = true; +var withLegacy = true; +var withOutput = true; +var withPython = false; +/* Win32 build options. */ +var dirSep = "\\"; +var compiler = "msvc"; +var cruntime = "/MD"; +var dynruntime = true; +var vcmanifest = false; +var buildDebug = 0; +var buildStatic = 0; +var buildPrefix = "."; +var buildBinPrefix = ""; +var buildIncPrefix = ""; +var buildLibPrefix = ""; +var buildSoPrefix = ""; +var buildInclude = "."; +var buildLib = "."; +/* Local stuff */ +var error = 0; + +/* Helper function, transforms the option variable into the 'Enabled' + or 'Disabled' string. */ +function boolToStr(opt) +{ + if (opt == false) + return "no"; + else if (opt == true) + return "yes"; + error = 1; + return "*** undefined ***"; +} + +/* Helper function, transforms the argument string into a boolean + value. */ +function strToBool(opt) +{ + if (opt == 0 || opt == "no") + return false; + else if (opt == 1 || opt == "yes") + return true; + error = 1; + return false; +} + +/* Displays the details about how to use this script. */ +function usage() +{ + var txt; + txt = "Usage:\n"; + txt += " cscript " + WScript.ScriptName + " \n"; + txt += " cscript " + WScript.ScriptName + " help\n\n"; + txt += "Options can be specified in the form
    +
    + تاريخ درج: چهارشنبه، 29 اسفند 1386 + - Wednesday, March 19, 2008      + نويسنده:       + دفعات مشاهده: 2688 + بار      كد: 341 +
    +
    + + + +
    +
    +
    +
    + +
    + + + +
    + عکس محصول هنر یکی از همکاران است. روی آن کلیک کند.
    +
    + +
    +

    +

    The +text between the start-tag and +end-tag is called the element's +content: + +Content of Elements +toto diff --git a/fuzz/seed_corpus/2c3804c6aa81bfef7ddba8bd392f0d8968c6bcb4 b/fuzz/seed_corpus/2c3804c6aa81bfef7ddba8bd392f0d8968c6bcb4 new file mode 100644 index 000000000000..74eeea147c37 --- /dev/null +++ b/fuzz/seed_corpus/2c3804c6aa81bfef7ddba8bd392f0d8968c6bcb4 @@ -0,0 +1,11 @@ + + + A B + + A + + B + A B + C + + diff --git a/fuzz/seed_corpus/2ca8525d0ef8ef80c4cffeb1d6ca35b171832867 b/fuzz/seed_corpus/2ca8525d0ef8ef80c4cffeb1d6ca35b171832867 new file mode 100644 index 000000000000..66193e80ac8e --- /dev/null +++ b/fuzz/seed_corpus/2ca8525d0ef8ef80c4cffeb1d6ca35b171832867 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/2cb101abf3950cb2d16e120a8388cdf3fa696b74 b/fuzz/seed_corpus/2cb101abf3950cb2d16e120a8388cdf3fa696b74 new file mode 100644 index 000000000000..a0fbf229495c --- /dev/null +++ b/fuzz/seed_corpus/2cb101abf3950cb2d16e120a8388cdf3fa696b74 @@ -0,0 +1,5 @@ + + +]> +&WhatHeSaid; diff --git a/fuzz/seed_corpus/2ce1c305d0d78f9723c9e64b4faf9ea18665742d b/fuzz/seed_corpus/2ce1c305d0d78f9723c9e64b4faf9ea18665742d new file mode 100644 index 000000000000..edeab32d74a6 --- /dev/null +++ b/fuzz/seed_corpus/2ce1c305d0d78f9723c9e64b4faf9ea18665742d @@ -0,0 +1,4 @@ + + %SYSTEM; + + +]> + + diff --git a/fuzz/seed_corpus/2d1090e9e9674e281a7383e2e5d137174df9ae24 b/fuzz/seed_corpus/2d1090e9e9674e281a7383e2e5d137174df9ae24 new file mode 100644 index 000000000000..18b1459e0b14 --- /dev/null +++ b/fuzz/seed_corpus/2d1090e9e9674e281a7383e2e5d137174df9ae24 @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/2d4938de49e0ab437dc84b2b4d0cd436ef30a188 b/fuzz/seed_corpus/2d4938de49e0ab437dc84b2b4d0cd436ef30a188 new file mode 100644 index 000000000000..bc98388a3f29 --- /dev/null +++ b/fuzz/seed_corpus/2d4938de49e0ab437dc84b2b4d0cd436ef30a188 @@ -0,0 +1,4 @@ + + + + diff --git a/fuzz/seed_corpus/2d571657158293cbeb414954c868b7d059f18202 b/fuzz/seed_corpus/2d571657158293cbeb414954c868b7d059f18202 new file mode 100644 index 000000000000..19a95a0eeb06 --- /dev/null +++ b/fuzz/seed_corpus/2d571657158293cbeb414954c868b7d059f18202 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/2db003f3dd00fd677ec17137c627baa9aa65956a b/fuzz/seed_corpus/2db003f3dd00fd677ec17137c627baa9aa65956a new file mode 100644 index 000000000000..de066f9d2385 --- /dev/null +++ b/fuzz/seed_corpus/2db003f3dd00fd677ec17137c627baa9aa65956a @@ -0,0 +1,12 @@ + + + + +]> + + + + + + diff --git a/fuzz/seed_corpus/2dcf80305d3a0dbe303d3327b0fc3fefa84d6163 b/fuzz/seed_corpus/2dcf80305d3a0dbe303d3327b0fc3fefa84d6163 new file mode 100644 index 000000000000..1259ef2b4188 --- /dev/null +++ b/fuzz/seed_corpus/2dcf80305d3a0dbe303d3327b0fc3fefa84d6163 @@ -0,0 +1,33 @@ + + + + + 0836217462 + Being a Dog Is a Full-Time Job + + Charles M Schulz + 1922-11-26 + 2000-02-12 + + + Peppermint Patty + 196T6-08-22 + bold, brash and tomboyish + + + Snoopy + 1950-10-04 + extroverted beagle + + + Schroeder + 1951-05-30 + brought classical music to the Peanuts strip + + + Lucy + 1952-03-03 + bossy, crabby and selfish + + + diff --git a/fuzz/seed_corpus/2de6eaa9ea8b2c3315c76c444d363d747310cd41 b/fuzz/seed_corpus/2de6eaa9ea8b2c3315c76c444d363d747310cd41 new file mode 100644 index 000000000000..9bdb4a362888 --- /dev/null +++ b/fuzz/seed_corpus/2de6eaa9ea8b2c3315c76c444d363d747310cd41 @@ -0,0 +1,7 @@ + + +c diff --git a/fuzz/seed_corpus/2e8bbbb3d3b04f9832e3cc27e71e480bb7cc7053 b/fuzz/seed_corpus/2e8bbbb3d3b04f9832e3cc27e71e480bb7cc7053 new file mode 100644 index 000000000000..a91aa61d28e5 --- /dev/null +++ b/fuzz/seed_corpus/2e8bbbb3d3b04f9832e3cc27e71e480bb7cc7053 @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/fuzz/seed_corpus/2ea6d56fdb6dff6d7419d04feb8c487ed1bc9449 b/fuzz/seed_corpus/2ea6d56fdb6dff6d7419d04feb8c487ed1bc9449 new file mode 100644 index 000000000000..daa185b884d8 --- /dev/null +++ b/fuzz/seed_corpus/2ea6d56fdb6dff6d7419d04feb8c487ed1bc9449 @@ -0,0 +1 @@ + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang or xml:space attributes + on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2001/03/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself. In other words, if the XML Schema namespace changes, the version + of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2001/03/xml.xsd will not change. + + + + + + In due course, we should install the relevant ISO 2- and 3-letter + codes as the enumerated possible values . . . + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + + + + + diff --git a/fuzz/seed_corpus/2ef2e635bc69fe780e952fc98be6310e257bfc9b b/fuzz/seed_corpus/2ef2e635bc69fe780e952fc98be6310e257bfc9b new file mode 100644 index 000000000000..cf3626139eaf --- /dev/null +++ b/fuzz/seed_corpus/2ef2e635bc69fe780e952fc98be6310e257bfc9b @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/2f69fe1657e0fa419119d088df4d7fabd1349375 b/fuzz/seed_corpus/2f69fe1657e0fa419119d088df4d7fabd1349375 new file mode 100644 index 000000000000..c9bda7f1d7ec --- /dev/null +++ b/fuzz/seed_corpus/2f69fe1657e0fa419119d088df4d7fabd1349375 @@ -0,0 +1 @@ + 1.2 3.4 diff --git a/fuzz/seed_corpus/2f9d077a8d222d675767c15f40f4e02b5af87fbb b/fuzz/seed_corpus/2f9d077a8d222d675767c15f40f4e02b5af87fbb new file mode 100644 index 000000000000..e630ff5497f2 --- /dev/null +++ b/fuzz/seed_corpus/2f9d077a8d222d675767c15f40f4e02b5af87fbb @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/2fc3463adc8d5efee1d1264b040d4f7592f0f25b b/fuzz/seed_corpus/2fc3463adc8d5efee1d1264b040d4f7592f0f25b new file mode 100644 index 000000000000..b4db7917d6c0 --- /dev/null +++ b/fuzz/seed_corpus/2fc3463adc8d5efee1d1264b040d4f7592f0f25b @@ -0,0 +1,6 @@ + + + ]> + diff --git a/fuzz/seed_corpus/2ff26c57e9859c67ce742f7d9e3998d221a6b3ed b/fuzz/seed_corpus/2ff26c57e9859c67ce742f7d9e3998d221a6b3ed new file mode 100644 index 000000000000..32faaf30c1f5 --- /dev/null +++ b/fuzz/seed_corpus/2ff26c57e9859c67ce742f7d9e3998d221a6b3ed @@ -0,0 +1,13 @@ + + + + + +]> + diff --git a/fuzz/seed_corpus/3033050fc78db9c6ae43d421ab0c6ac919508c4c b/fuzz/seed_corpus/3033050fc78db9c6ae43d421ab0c6ac919508c4c new file mode 100644 index 000000000000..157d178645f5 --- /dev/null +++ b/fuzz/seed_corpus/3033050fc78db9c6ae43d421ab0c6ac919508c4c @@ -0,0 +1,5 @@ + + + diff --git a/fuzz/seed_corpus/306a8956f55a33546f18cf9e074260c213a2650e b/fuzz/seed_corpus/306a8956f55a33546f18cf9e074260c213a2650e new file mode 100644 index 000000000000..014500bc0bfc --- /dev/null +++ b/fuzz/seed_corpus/306a8956f55a33546f18cf9e074260c213a2650e @@ -0,0 +1,13 @@ + + +]> + diff --git a/fuzz/seed_corpus/312ea7279fbd73cb85b56f4b091d5fa30d5edf7d b/fuzz/seed_corpus/312ea7279fbd73cb85b56f4b091d5fa30d5edf7d new file mode 100644 index 000000000000..fb5b0fae5218 --- /dev/null +++ b/fuzz/seed_corpus/312ea7279fbd73cb85b56f4b091d5fa30d5edf7d @@ -0,0 +1 @@ + diff --git a/fuzz/seed_corpus/315af194713e19575d14219f809979c413352caa b/fuzz/seed_corpus/315af194713e19575d14219f809979c413352caa new file mode 100644 index 000000000000..84ddb0815bcd --- /dev/null +++ b/fuzz/seed_corpus/315af194713e19575d14219f809979c413352caa @@ -0,0 +1,10 @@ + + (//.|//@*|//namespace::*) + [ + self::ietf:e1 + or + (parent::ietf:e1 and not(self::text() or self::e2)) + or + count(id("E3")|ancestor-or-self::node()) = count(ancestor-or-self::node()) + ] + \ No newline at end of file diff --git a/fuzz/seed_corpus/31bb7a40c73fb9d577cac3a77f5d2f3dba735e9a b/fuzz/seed_corpus/31bb7a40c73fb9d577cac3a77f5d2f3dba735e9a new file mode 100644 index 000000000000..43c769f4642b --- /dev/null +++ b/fuzz/seed_corpus/31bb7a40c73fb9d577cac3a77f5d2f3dba735e9a @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fuzz/seed_corpus/3200c178d8bf3a746a4896fb23f0ca07ffa3a252 b/fuzz/seed_corpus/3200c178d8bf3a746a4896fb23f0ca07ffa3a252 new file mode 100644 index 000000000000..1ff1d3c2c5af --- /dev/null +++ b/fuzz/seed_corpus/3200c178d8bf3a746a4896fb23f0ca07ffa3a252 @@ -0,0 +1,3 @@ + + + diff --git a/fuzz/seed_corpus/325141a45d26c576c5f6d4e25f29af6b3d3b2bca b/fuzz/seed_corpus/325141a45d26c576c5f6d4e25f29af6b3d3b2bca new file mode 100644 index 000000000000..5274badc203e --- /dev/null +++ b/fuzz/seed_corpus/325141a45d26c576c5f6d4e25f29af6b3d3b2bca @@ -0,0 +1 @@ + 1.2 3.4 diff --git a/fuzz/seed_corpus/328781b84caf8ec37b9a0d723938810d40fe4719 b/fuzz/seed_corpus/328781b84caf8ec37b9a0d723938810d40fe4719 new file mode 100644 index 000000000000..c8dd2bf3a37b --- /dev/null +++ b/fuzz/seed_corpus/328781b84caf8ec37b9a0d723938810d40fe4719 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/32bb4cd890770928b31d81934920acaae0b02106 b/fuzz/seed_corpus/32bb4cd890770928b31d81934920acaae0b02106 new file mode 100644 index 000000000000..f0c441da6e83 --- /dev/null +++ b/fuzz/seed_corpus/32bb4cd890770928b31d81934920acaae0b02106 @@ -0,0 +1,2 @@ + + diff --git a/fuzz/seed_corpus/32f877dee5fdbf4544c8eb601367508bb39f4678 b/fuzz/seed_corpus/32f877dee5fdbf4544c8eb601367508bb39f4678 new file mode 100644 index 000000000000..fef5f2517932 --- /dev/null +++ b/fuzz/seed_corpus/32f877dee5fdbf4544c8eb601367508bb39f4678 @@ -0,0 +1 @@ +1.2 diff --git a/fuzz/seed_corpus/33417f3b4591d775c4cfe7ce2def35bc06c8e5f8 b/fuzz/seed_corpus/33417f3b4591d775c4cfe7ce2def35bc06c8e5f8 new file mode 100644 index 000000000000..cc9d8ac0956c --- /dev/null +++ b/fuzz/seed_corpus/33417f3b4591d775c4cfe7ce2def35bc06c8e5f8 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/336db03b7edf31bcd28841ecbe5ab4be0c2337ff b/fuzz/seed_corpus/336db03b7edf31bcd28841ecbe5ab4be0c2337ff new file mode 100644 index 000000000000..d0376f769861 --- /dev/null +++ b/fuzz/seed_corpus/336db03b7edf31bcd28841ecbe5ab4be0c2337ff @@ -0,0 +1,15 @@ + + + + + +"> +&c;"> +]> + + +&bc; +&bc; + + diff --git a/fuzz/seed_corpus/33b9edc2a8b46940af9b62e871b640b8810ca177 b/fuzz/seed_corpus/33b9edc2a8b46940af9b62e871b640b8810ca177 new file mode 100644 index 000000000000..ba1504184bbd --- /dev/null +++ b/fuzz/seed_corpus/33b9edc2a8b46940af9b62e871b640b8810ca177 @@ -0,0 +1,11 @@ + + + + + + + Here is my title + diff --git a/fuzz/seed_corpus/33d4e2071e444fef93043f9f8f95ff74c1915b53 b/fuzz/seed_corpus/33d4e2071e444fef93043f9f8f95ff74c1915b53 new file mode 100644 index 000000000000..23ae8f79a658 --- /dev/null +++ b/fuzz/seed_corpus/33d4e2071e444fef93043f9f8f95ff74c1915b53 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/fuzz/seed_corpus/33d68da1f9e21a0e30a5a81ebc2bbf57d2a9fb87 b/fuzz/seed_corpus/33d68da1f9e21a0e30a5a81ebc2bbf57d2a9fb87 new file mode 100644 index 000000000000..af1f1908c20b --- /dev/null +++ b/fuzz/seed_corpus/33d68da1f9e21a0e30a5a81ebc2bbf57d2a9fb87 @@ -0,0 +1,34 @@ + + + + +