GenerateApplicationHeader.awk 700 B

123456789101112131415161718192021222324252627
  1. # generate an application header
  2. BEGIN {
  3. NAME_LENGTH = 32
  4. for (i = 0; i < NAME_LENGTH; ++i) {
  5. padding = padding "\0"
  6. }
  7. n = 0
  8. name[0] = substr("No Name" padding, 0, NAME_LENGTH)
  9. }
  10. END {
  11. printf("SAMO%c\0\0\0", n)
  12. for (i = 0; i < n; ++i) {
  13. printf(name[i])
  14. }
  15. }
  16. /^[[:space:]]*#[[:space:]]*define[[:space:]]+APPLICATION_TITLE[[:digit:]]*[[:space:]]+/ {
  17. line = gensub("^.*APPLICATION_TITLE[[:digit:]]*[[:space:]]*\"", "", 1, $0)
  18. line = gensub("\".*$", "", 1, line)
  19. if ("" != line) {
  20. name[n] = substr(line padding, 0, NAME_LENGTH)
  21. n = n + 1
  22. }
  23. }