PageRenderTime 68ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/srclib/apr/build/make_nw_export.awk

https://bitbucket.org/gencer/apache2nginx
AWK | 106 lines | 71 code | 12 blank | 23 comment | 0 complexity | d4536dc48aeca1bf03da9b8fef1bcd38 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. add_symbol("apr_wait_for_io_or_timeout")
  21. }
  22. function add_symbol(sym_name) {
  23. sub(" ", "", sym_name)
  24. exports[++idx] = sym_name
  25. }
  26. # List of functions that we don't support, yet??
  27. #/apr_##name##_set_inherit/{next}
  28. #/apr_##name##_unset_inherit/{next}
  29. /^[ \t]*AP[RUI]?_DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ {
  30. sub("[ \t]*AP[RUI]?_DECLARE[^(]*[(][^)]*[)][ \t]*", "")
  31. sub("[(].*", "")
  32. sub("([^ ]* (^([ \t]*[(])))+", "")
  33. add_symbol($0)
  34. next
  35. }
  36. /^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ {
  37. split($0, args, ",")
  38. symbol = args[2]
  39. sub("^[ \t]+", "", symbol)
  40. sub("[ \t]+$", "", symbol)
  41. add_symbol("ap_hook_" symbol)
  42. add_symbol("ap_hook_get_" symbol)
  43. add_symbol("ap_run_" symbol)
  44. next
  45. }
  46. /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ {
  47. sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0)
  48. sub("[)].*$", "", $0)
  49. add_symbol("apr_" $0 "_pool_get")
  50. next
  51. }
  52. /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ {
  53. sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0)
  54. sub("[)].*$", "", $0)
  55. add_symbol("apr_" $0 "_inherit_set")
  56. next
  57. }
  58. /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ {
  59. sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0)
  60. sub("[)].*$", "", $0)
  61. add_symbol("apr_" $0 "_inherit_unset")
  62. next
  63. }
  64. /^[ \t]*AP[RUI]?_DECLARE_DATA .*;/ {
  65. gsub(/[*;\n\r]/, "", $NF)
  66. gsub(/\[.*\]/, "", $NF)
  67. add_symbol($NF)
  68. }
  69. END {
  70. printf("Added %d symbols to export list.\n", idx) > "/dev/stderr"
  71. # sort symbols with shell sort
  72. increment = int(idx / 2)
  73. while (increment > 0) {
  74. for (i = increment+1; i <= idx; i++) {
  75. j = i
  76. temp = exports[i]
  77. while ((j >= increment+1) && (exports[j-increment] > temp)) {
  78. exports[j] = exports[j-increment]
  79. j -= increment
  80. }
  81. exports[j] = temp
  82. }
  83. if (increment == 2)
  84. increment = 1
  85. else
  86. increment = int(increment*5/11)
  87. }
  88. # print the array
  89. printf(" (%s)\n", EXPPREFIX)
  90. while (x < idx - 1) {
  91. printf(" %s,\n", exports[++x])
  92. }
  93. printf(" %s\n", exports[++x])
  94. }