You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-configutils.xml 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ~ Copyright (c) 2006-2017 DMDirc Developers
  4. ~
  5. ~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  6. ~ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  7. ~ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  8. ~ permit persons to whom the Software is furnished to do so, subject to the following conditions:
  9. ~
  10. ~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  11. ~ Software.
  12. ~
  13. ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14. ~ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  15. ~ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16. ~ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. -->
  18. <project basedir=".">
  19. <macrodef name="readdomain">
  20. <attribute name="contents"/>
  21. <attribute name="domain"/>
  22. <attribute name="outputproperty"/>
  23. <sequential>
  24. <local name="extracted"/>
  25. <!-- Extract the entire domain contents -->
  26. <propertyregex property="extracted" override="true" input="@{contents}" select="\1" defaultvalue="">
  27. <regexp pattern="(?si)^.*[\r\n]+\Q@{domain}\E:[\r\n]+(.*?)([\r\n]+[^\r\n]+:[\r\n]+|$)"/>
  28. </propertyregex>
  29. <!-- Trim leading whitespace -->
  30. <propertyregex property="@{outputproperty}" override="true" input="${extracted}" replace="" global="true">
  31. <regexp pattern="(?m)^\s+"/>
  32. </propertyregex>
  33. </sequential>
  34. </macrodef>
  35. <macrodef name="readvalue">
  36. <attribute name="domaincontents"/>
  37. <attribute name="setting"/>
  38. <attribute name="outputproperty"/>
  39. <sequential>
  40. <local name="extracted"/>
  41. <!-- Extract the raw value -->
  42. <propertyregex property="extracted" override="true" input="@{domaincontents}" select="\1">
  43. <regexp pattern="(?mi)^\s*\Q@{setting}\E\s*=\s*(.*?)[\r\n]*?$"/>
  44. </propertyregex>
  45. <!-- Unescape \r, \n, \=, \#, \: and \\ -->
  46. <propertyregex property="extracted" override="true" input="${extracted}" defaultvalue="${extracted}" regexp="\\n" replace="\n" global="true"/>
  47. <propertyregex property="extracted" override="true" input="${extracted}" defaultvalue="${extracted}" regexp="\\r" replace="\r" global="true"/>
  48. <propertyregex property="extracted" override="true" input="${extracted}" defaultvalue="${extracted}" regexp="\\=" replace="=" global="true"/>
  49. <propertyregex property="extracted" override="true" input="${extracted}" defaultvalue="${extracted}" regexp="\\#" replace="#" global="true"/>
  50. <propertyregex property="extracted" override="true" input="${extracted}" defaultvalue="${extracted}" regexp="\\:" replace=":" global="true"/>
  51. <propertyregex property="@{outputproperty}" override="true" input="${extracted}" defaultvalue="${extracted}" regexp="\\\\" replace="\" global="true"/>
  52. </sequential>
  53. </macrodef>
  54. </project>