get_exp.awk 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # ***************************************************************************
  2. # * _ _ ____ _
  3. # * Project ___| | | | _ \| |
  4. # * / __| | | | |_) | |
  5. # * | (__| |_| | _ <| |___
  6. # * \___|\___/|_| \_\_____|
  7. # *
  8. # * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. # *
  10. # * This software is licensed as described in the file COPYING, which
  11. # * you should have received as part of this distribution. The terms
  12. # * are also available at https://curl.haxx.se/docs/copyright.html.
  13. # *
  14. # * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # * copies of the Software, and permit persons to whom the Software is
  16. # * furnished to do so, under the terms of the COPYING file.
  17. # *
  18. # * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # * KIND, either express or implied.
  20. # *
  21. # ***************************************************************************
  22. # awk script which fetches curl function symbols from public header input
  23. # files and write them to STDOUT. Here you can get an awk version for Win32:
  24. # http://www.gknw.net/development/prgtools/awk-20100523.zip
  25. #
  26. BEGIN {
  27. add_symbol("curl_strequal")
  28. add_symbol("curl_strnequal")
  29. }
  30. function add_symbol(sym_name) {
  31. sub(" ", "", sym_name)
  32. exports[++idx] = sym_name
  33. }
  34. /^CURL_EXTERN .* [*]?curl_.*[(]/ {
  35. sub("[(].*", "")
  36. sub("^.* ", "")
  37. sub("^[*]", "")
  38. add_symbol($0)
  39. }
  40. END {
  41. printf("Added %d symbols to export list.\n", idx) > "/dev/stderr"
  42. # sort symbols with shell sort
  43. increment = int(idx / 2)
  44. while (increment > 0) {
  45. for (i = increment+1; i <= idx; i++) {
  46. j = i
  47. temp = exports[i]
  48. while ((j >= increment+1) && (exports[j-increment] > temp)) {
  49. exports[j] = exports[j-increment]
  50. j -= increment
  51. }
  52. exports[j] = temp
  53. }
  54. if (increment == 2)
  55. increment = 1
  56. else
  57. increment = int(increment*5/11)
  58. }
  59. # print the array
  60. if (EXPPREFIX) {
  61. printf(" (%s)\n", EXPPREFIX)
  62. }
  63. while (x < idx - 1) {
  64. printf(" %s,\n", exports[++x])
  65. }
  66. printf(" %s\n", exports[++x])
  67. }