const_gen.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. #
  3. # Gearman PHP Extension
  4. #
  5. # Copyright (C) 2008 James M. Luedke <contact@jamesluedke.com>,
  6. # Eric Day <eday@oddments.org>
  7. # All rights reserved.
  8. #
  9. # Use and distribution licensed under the PHP license. See
  10. # the LICENSE file in this directory for full text.
  11. if [ "$1" = "" ]
  12. then
  13. header=/usr/local/include/libgearman/constants.h
  14. else
  15. header=$1
  16. fi
  17. if [ ! -e $header ]
  18. then
  19. echo "$header does not exist"
  20. exit 1;
  21. fi
  22. if [ -e php_gearman.c.new ]
  23. then
  24. echo "php_gearman.c.new already exists"
  25. exit 1;
  26. fi
  27. awk 'BEGIN { p= 1; } \
  28. /CONST_GEN_START/ { p= 0; print $0; } \
  29. { if (p == 1) { print $0; } }' php_gearman.c >> php_gearman.c.new
  30. grep ' GEARMAN' $header | \
  31. sed 's/.*\(GEARMAN[A-Z0-9_]*\).*/\1/' | \
  32. sed 's/\(.*\)/ REGISTER_LONG_CONSTANT("\1",\
  33. \1,\
  34. CONST_CS | CONST_PERSISTENT);/' | \
  35. sed 's/LONG\(.*GEARMAN_DEFAULT_TCP_HOST\)/STRING\1/' | \
  36. sed 's/LONG\(.*GEARMAN_DEFAULT_UDS\)/STRING\1/' | \
  37. sed 's/LONG\(.*GEARMAN_DEFAULT_USER\)/STRING\1/' >> php_gearman.c.new
  38. awk 'BEGIN { p= 0; } \
  39. /CONST_GEN_STOP/ { p= 1; } \
  40. { if (p == 1) { print $0; } }' php_gearman.c >> php_gearman.c.new
  41. echo "New source file can be found in: php_gearman.c.new"
  42. exit 0