dcm2desc 779 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. #
  3. # dcm2desc - Convert .dcm files to genex descriptions
  4. #
  5. # Copyright 2012 by Werner Almesberger
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. usage()
  13. {
  14. echo "usage: $0 [-L libdir ...] [-l lib ...]" 1>&2
  15. exit 1
  16. }
  17. scan_dcm()
  18. {
  19. for n in "$@"; do
  20. sed -e '/^\$CMP /{s///;x;}' \
  21. -e '/^[DKF] /{s///;x;G;s/\n/: /;p;s/: .*//;x;}' \
  22. -e d <"$n"
  23. done
  24. }
  25. while [ "$1" ]; do
  26. case "$1" in
  27. -L) shift
  28. [ "`echo \"$1\"/*.dcm`" != "$1/*.dcm" ] &&
  29. scan_dcm "$1"/*.dcm;;
  30. -l) shift
  31. scan_dcm "$1";;
  32. -*) usage;;
  33. *) usage;;
  34. esac
  35. shift
  36. done
  37. exit 0