1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef CMS_ERR_H
- #define CMS_ERR_H
-
- typedef enum cms_err_code
- {
- CMS_ERR_NONE = 0,
- CMS_ERR_UNKNOWN,
- CMS_ERR_ALLOC,
- CMS_ERR_PARSE,
- CMS_ERR_NOENT,
- CMS_ERR_NOTFILE,
- CMS_ERR_NOTDIR,
- CMS_ERR_FILEEXISTS,
- CMS_ERR_FILEREAD,
- CMS_ERR_DIREXISTS,
- CMS_ERR_PERM,
- CMS_ERR_INITED,
- CMS_ERR_NOTINITED
- } cms_err_code;
-
- typedef struct cms_err
- {
- cms_err_code code;
- char* msg;
- const char* file;
- int line;
- } cms_err;
-
- //Create an error. Returns NULL if the error code is CMS_ERR_NONE.
- cms_err* _cms_err_create(cms_err_code code, char* msg, const char* file, int line);
- #define cms_err_create(code, msg) _cms_err_create(code, msg, __FILE__, __LINE__)
-
- void cms_err_free(cms_err* err);
-
- void cms_err_panic(cms_err* err);
-
- cms_err* _cms_err_from_std_err(int err, const char* file, int line);
- #define cms_err_from_std_err(err) _cms_err_from_std_err(err, __FILE__, __LINE__)
-
- #endif
|