#define log_error c_log_error\r
#define log_info c_log_info\r
#define log_warning c_log_warning\r
+#define log_debug c_log_debug\r
\r
#define read_file c_read_file\r
#define touch_file_if_doesnt_exist c_touch_file_if_doesnt_exist\r
#define c_log_warning(fmt, ...) do {\\r
fprintf(stdout, "%s"fmt"\n", "[WARNING] ", ##__VA_ARGS__);\\r
} while (0)\r
-\r
+#ifdef DEBUG\r
+#define c_log_debug(fmt, ...) do {\\r
+ fprintf(stdout, "%s"fmt"\n", "[DEBUG] ", ##__VA_ARGS__);\\r
+ } while (0)\r
+#else\r
+#define c_log_debug(...)\r
+#endif // DEBUG\r
//\r
// File\r
//\r
\r
size_t read = fread((char*)result, sizeof(char), fsize, f);\r
\r
- *file_size = (int)read;\r
+ // Process the result to remove '\r' characters\r
+ char* cleaned_result = malloc(read + 1); // Allocate memory for cleaned result\r
+ if (cleaned_result == NULL) {\r
+ fprintf(stderr, "Memory allocation failed\n");\r
+ free(result);\r
+ return NULL;\r
+ }\r
\r
- // set null-terminator\r
- result[read] = '\0';\r
+ size_t j = 0; // Index for cleaned_result\r
+ for (size_t i = 0; i < read; i++) {\r
+ if (result[i] != '\r') { // Skip '\r' characters\r
+ cleaned_result[j++] = result[i];\r
+ }\r
+ }\r
+ cleaned_result[j] = '\0'; // Null-terminate the cleaned result\r
+\r
+ free(result); // Free the original result\r
+ *file_size = (int)j; // Update the file size without '\r'\r
+ return cleaned_result; // Return the cleaned result\r
+\r
+ *file_size = (int)read;\r
\r
defer:\r
if (f) fclose(f);\r
+#define DEBUG
+
#define COMMONLIB_IMPLEMENTATION
#include "../commonlib.h"
c_log_info("This is an info log");
c_log_error("This one is an error log");
c_log_warning("And this is a warning log");
+ c_log_debug("And this is a debug log");
return 0;
}