(FEA) More macros for Status

This commit is contained in:
William
2024-06-07 17:17:32 +08:00
parent 66c1d57188
commit 8775d75de8
14 changed files with 415 additions and 525 deletions

29
catlog.h Executable file → Normal file
View File

@@ -15,6 +15,26 @@ typedef enum {
CATLOG_LEVEL_NONE
} CatlogLevel;
DEFSTATUS(CatCannotSendMessage, 1,
"Cat had trouble while sending your message.",
STATUS_ERROR, &ReadWriteError);
DEFSTATUS(CatMessageTooLong, 1,
"Cat cannot finish reading your loooong message before deadline.",
STATUS_ERROR, &MaximumLengthExceeded);
DEFSTATUS(CatCannotFindFile, 1,
"Cat cannot have your file found.",
STATUS_ERROR, &FileNotFound);
DEFSTATUS(CatHasInsufficientPermission, 1,
"Cat cannot access your file with its given permission.",
STATUS_ERROR, &InsufficientAccessPermission);
DEFSTATUS(CatCannotOpenFile, 1,
"Cat cannot open your file because fopen returned NULL.",
STATUS_ERROR, &ReadWriteError);
typedef struct {
time_t time;
CatlogLevel level;
@@ -36,11 +56,10 @@ typedef struct {
Status CatlogSender_Create(CatlogSender *inst, CatlogMsg *msg, FILE *dst);
Status CatlogSender_CopyOf(CatlogSender *inst, CatlogSender *other);
Status CatlogSender_Send(CatlogSender *inst);
bool CatlogSender_Equals(CatlogSender *inst, CatlogSender *other);
Status CatlogSender_Send(CatlogSender *inst, char *filepath, bool append)
throws(ReadWriteError);
Status CatlogUtils_CalcElapsed(struct timespec t1, struct timespec t2);
Status CatlogUtils_OpenFile(FILE *store, char *filepath,
const char const *__restrict mode);
Status CatlogUtils_OpenFile(FILE **fileptr, const char *filepath,
const char const *restrict mode);
Status CatlogUtils_CloseFile(FILE **fileptr);
#endif /* COMPOUND_CATLOG_H */