1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include "cms_err.h"
- #include <stdio.h>
- #include <unistd.h>
-
- static char* get_message(cms_err err)
- {
- switch (err)
- {
- case CMS_ERR_NONE:
- return "";
- case CMS_ERR_UNKNOWN:
- return "Unknown error.";
- case CMS_ERR_MEMORY:
- return "Memory allocation failed.";
- case CMS_ERR_PARSE:
- return "Parse error.";
- case CMS_ERR_FILENOENT:
- return "File doesn't exist.";
- case CMS_ERR_DIRNOENT:
- return "Directory doesn't exist.";
- case CMS_ERR_NOTFILE:
- return "Not a file.";
- case CMS_ERR_NOTDIR:
- return "Not a directory.";
- case CMS_ERR_PERM:
- return "Permission denied.";
- }
- }
-
- void cms_err_panic(cms_err err, char* msg)
- {
- if (err == CMS_ERR_NONE)
- return;
-
- if (msg == NULL)
- printf("Error: %s\n", get_message(err));
- else
- printf("Error: %s (%s)\n", get_message(err), msg);
-
- exit(1);
- }
|