PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/build/make_nw_export.awk

https://bitbucket.org/gencer/apache2nginx
AWK | 117 lines | 82 code | 13 blank | 22 comment | 0 complexity | f7c030e5dd350f9a1d647f9eb3f4705c MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. # Based on apr's make_export.awk, which is
  17. # based on Ryan Bloom's make_export.pl
  18. #
  19. BEGIN {
  20. }
  21. function add_symbol(sym_name) {
  22. sub(" ", "", sym_name)
  23. exports[++idx] = sym_name
  24. }
  25. # List of functions that we don't support, yet??
  26. #/ap_some_name/{next}
  27. /^[ \t]*(AP|DAV)([RU]|_CORE)?_DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ {
  28. sub("[ \t]*(AP|DAV)([RU]|_CORE)?_DECLARE[^(]*[(][^)]*[)][ \t]*", "")
  29. sub("[(].*", "")
  30. sub("([^ ]* (^([ \t]*[(])))+", "")
  31. add_symbol($0)
  32. next
  33. }
  34. /^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ {
  35. split($0, args, ",")
  36. symbol = args[2]
  37. sub("^[ \t]+", "", symbol)
  38. sub("[ \t]+$", "", symbol)
  39. add_symbol("ap_hook_" symbol)
  40. add_symbol("ap_hook_get_" symbol)
  41. add_symbol("ap_run_" symbol)
  42. next
  43. }
  44. /^[ \t]*AP[RU]?_DECLARE_EXTERNAL_HOOK[^(]*[(][^)]*/ {
  45. split($0, args, ",")
  46. prefix = args[1]
  47. sub("^.*[(]", "", prefix)
  48. symbol = args[4]
  49. sub("^[ \t]+", "", symbol)
  50. sub("[ \t]+$", "", symbol)
  51. add_symbol(prefix "_hook_" symbol)
  52. add_symbol(prefix "_hook_get_" symbol)
  53. add_symbol(prefix "_run_" symbol)
  54. next
  55. }
  56. /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ {
  57. sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0)
  58. sub("[)].*$", "", $0)
  59. add_symbol("apr_" $0 "_pool_get")
  60. next
  61. }
  62. /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ {
  63. sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0)
  64. sub("[)].*$", "", $0)
  65. add_symbol("apr_" $0 "_inherit_set")
  66. next
  67. }
  68. /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ {
  69. sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0)
  70. sub("[)].*$", "", $0)
  71. add_symbol("apr_" $0 "_inherit_unset")
  72. next
  73. }
  74. /^[ \t]*(extern[ \t]+)?AP[RU]?_DECLARE_DATA .*;/ {
  75. gsub(/[*;\n\r]/, "", $NF)
  76. gsub(/\[.*\]/, "", $NF)
  77. add_symbol($NF)
  78. }
  79. END {
  80. printf("Added %d symbols to export list.\n", idx) > "/dev/stderr"
  81. # sort symbols with shell sort
  82. increment = int(idx / 2)
  83. while (increment > 0) {
  84. for (i = increment+1; i <= idx; i++) {
  85. j = i
  86. temp = exports[i]
  87. while ((j >= increment+1) && (exports[j-increment] > temp)) {
  88. exports[j] = exports[j-increment]
  89. j -= increment
  90. }
  91. exports[j] = temp
  92. }
  93. if (increment == 2)
  94. increment = 1
  95. else
  96. increment = int(increment*5/11)
  97. }
  98. # print the array
  99. printf(" (%s)\n", EXPPREFIX)
  100. while (x < idx - 1) {
  101. printf(" %s,\n", exports[++x])
  102. }
  103. printf(" %s\n", exports[++x])
  104. }