A static site generator, written in C
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cms_err.c 795B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "cms_err.h"
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. static char* get_message(cms_err err)
  5. {
  6. switch (err)
  7. {
  8. case CMS_ERR_NONE:
  9. return "";
  10. case CMS_ERR_UNKNOWN:
  11. return "Unknown error.";
  12. case CMS_ERR_MEMORY:
  13. return "Memory allocation failed.";
  14. case CMS_ERR_PARSE:
  15. return "Parse error.";
  16. case CMS_ERR_FILENOENT:
  17. return "File doesn't exist.";
  18. case CMS_ERR_DIRNOENT:
  19. return "Directory doesn't exist.";
  20. case CMS_ERR_NOTFILE:
  21. return "Not a file.";
  22. case CMS_ERR_NOTDIR:
  23. return "Not a directory.";
  24. case CMS_ERR_PERM:
  25. return "Permission denied.";
  26. }
  27. }
  28. void cms_err_panic(cms_err err, char* msg)
  29. {
  30. if (err == CMS_ERR_NONE)
  31. return;
  32. if (msg == NULL)
  33. printf("Error: %s\n", get_message(err));
  34. else
  35. printf("Error: %s (%s)\n", get_message(err), msg);
  36. exit(1);
  37. }