linuxinstall/src/utils.h

32 lines
761 B
C
Raw Normal View History

2024-02-15 19:42:22 +01:00
#pragma once
#include <stdint.h>
2024-02-17 23:59:38 +01:00
#include <stdbool.h>
2024-02-15 19:42:22 +01:00
typedef enum {
SUCCESS,
2024-02-17 23:59:38 +01:00
FAILURE
} Status;
typedef enum {
LOG_LEVEL_DEBUG,
2024-02-17 23:59:38 +01:00
LOG_LEVEL_INFO,
LOG_LEVEL_WARNING,
LOG_LEVEL_ERROR,
2024-02-15 19:42:22 +01:00
} LogLevel;
extern LogLevel log_level;
2024-02-15 19:42:22 +01:00
2024-02-17 23:59:38 +01:00
void SetLogLevel(LogLevel level);
void Log(LogLevel level, const char* format, ...);
2024-02-17 23:59:38 +01:00
Status Format(char** _string, const char* fmt, ...);
2024-02-17 14:21:14 +01:00
2024-02-17 23:59:38 +01:00
Status RunExecutable(int* _exit_code, char** _stdout, char** _stderr, const char* executable, ...);
2024-02-17 14:38:52 +01:00
2024-02-17 23:59:38 +01:00
Status ReadFileDescriptor(int fd, char** _content);
Status WriteFileDescriptor(int fd, const char* content);
Status ReadFile(const char* path, char** _content);
Status WriteFile(const char* path, const char* content);
Status CopyFile(const char* source_path, const char* destination_path);