This repository was archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsd_errors.h
More file actions
72 lines (60 loc) · 1.98 KB
/
Copy pathsd_errors.h
File metadata and controls
72 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (C) 2022 Valentin-Ioan VINTILA (313CA / 2021-2022).
// All rights reserved.
#ifndef SD_ERRORS_H
#define SD_ERRORS_H
// This header contains lots of info about possible errrors, as well as a great
// logging function, custom-made for this project!
// Include detailed debugging information. This is optional.
#define SD_LOG_DEBUG
// If in a private environment, always debug.
#ifdef SD_LOG_FULL
#define SD_LOG_DEBUG
#endif
// These are the different types of errors that can be returned in case
// something very wrong happens
typedef enum {
// Critical errors are negative :(
CRITICAL_OUTPUT_FILE = -9,
CRITICAL_INPUT_SP = -8,
CRITICAL_INPUT_KW = -7,
CRITICAL_INPUT_DIR = -6,
CRITICAL_INPUT_FILE = -5,
CRITICAL_SAFE_REALLOC = -4,
CRITICAL_SAFE_CALLOC = -3,
CRITICAL_SAFE_MALLOC = -2,
CRITICAL_UNKNOWN = -1,
// No error, no problem! We got you covered ;)
NO_ERROR = 0,
// Warnings, also known as "who cares" errors
WARNING_KW_COLLECTION_EMPTY = 1,
WARNING_UNKNOWN = 2
} error_t;
// There are quite a few ways to write a log entry:
typedef enum {
LOG_DEBUG,
LOG_INFO,
LOG_WARN,
LOG_ERROR,
LOG_GENERAL,
LOG_CLOSE_SIGNAL
} log_t;
// General header file
#include "spam_detector.h"
// This function tests if an error is critical or not.
// - - - - -
// error_t e = A given error that should be checked.
// - - - - -
// Return: bool = true if the error was critical.
extern bool is_critical(error_t e);
// This function provides a safe way to output information to a log file.
// - - - - -
// log_t type = The message will be prefixed with a string based on this option
// The next arguments are similar to a printfs'
extern void sd_log(log_t type, const char *format, ...);
// This function is a faster way to output a default log message for an error.
// - - - - -
// error_t e = The error based on which a message shall be written.
extern void sd_log_error(error_t e);
// This function sends the closing signal to the log.
extern void sd_log_close(void);
#endif // SD_ERRORS_H