mkdumpstrerrno.py 510 B

123456789101112131415161718192021222324252627282930313233
  1. #! /usr/bin/env python2.7
  2. import sys
  3. def main ():
  4. r = []
  5. while True:
  6. line = sys.stdin.readline()
  7. if line == '':
  8. break
  9. s = line.split()[0][:-1]
  10. r.append("\tD(\"%s\", %s)" % (s, s))
  11. print """/* this file was generated automatically */
  12. #include <errno.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15. static void D (const char *s, int e)
  16. {
  17. printf("%%s, %%s\\n", s, strerror(e));
  18. }
  19. int main (int argc, const char *argv[])
  20. {
  21. %s;
  22. return 0;
  23. }""" % (';\n'.join(r),)
  24. if __name__ == '__main__':
  25. main()