/crypto/heimdal/lib/roken/roken.awk

https://bitbucket.org/freebsd/freebsd-head/ · AWK · 43 lines · 38 code · 4 blank · 1 comment · 16 complexity · 5356c76f4d3006302feea1f23773ebdc MD5 · raw file

  1. # $Id$
  2. BEGIN {
  3. print "#include <config.h>"
  4. print "#include <stdio.h>"
  5. print "#ifdef HAVE_SYS_TYPES_H"
  6. print "#include <sys/types.h>"
  7. print "#endif"
  8. print "#ifdef HAVE_SYS_SOCKET_H"
  9. print "#include <sys/socket.h>"
  10. print "#endif"
  11. print ""
  12. print "int main(int argc, char **argv)"
  13. print "{"
  14. print "puts(\"/* This is an OS dependent, generated file */\");"
  15. print "puts(\"\\n\");"
  16. print "puts(\"#ifndef __ROKEN_H__\");"
  17. print "puts(\"#define __ROKEN_H__\");"
  18. print "puts(\"\");"
  19. }
  20. $1 == "#ifdef" || $1 == "#ifndef" || $1 == "#if" || $1 == "#else" || $1 == "#elif" || $1 == "#endif" {
  21. print $0;
  22. next
  23. }
  24. {
  25. s = ""
  26. for(i = 1; i <= length; i++){
  27. x = substr($0, i, 1)
  28. if(x == "\"" || x == "\\")
  29. s = s "\\";
  30. s = s x;
  31. }
  32. print "puts(\"" s "\");"
  33. }
  34. END {
  35. print "puts(\"\");"
  36. print "puts(\"#endif /* __ROKEN_H__ */\");"
  37. print "return 0;"
  38. print "}"
  39. }