linuxinstall/src/utils.h

34 lines
975 B
C
Raw Normal View History

2024-02-15 19:42:22 +01:00
#pragma once
2024-02-19 16:01:53 +01:00
#include <stdlib.h>
#include <stdint.h>
2024-02-17 23:59:38 +01:00
#include <stdbool.h>
2024-02-15 19:42:22 +01:00
2024-02-19 16:01:53 +01:00
#define ERROR_BUFFER_SIZE 4096
extern char ERROR_BUFFER[];
2024-02-15 19:42:22 +01:00
2024-02-19 16:01:53 +01:00
typedef int result_t;
2024-02-15 19:42:22 +01:00
2024-02-19 16:01:53 +01:00
result_t success(void);
result_t failure(const char* format, ...);
const char* error(void);
2024-02-19 16:01:53 +01:00
result_t format(char** _str, const char* format, ...);
result_t substring(char** _str, const char* str, size_t start, size_t length);
2024-02-17 14:21:14 +01:00
2024-02-19 16:01:53 +01:00
result_t format_size(char** _str, uint64_t size);
result_t parse_size(uint64_t* _size, const char* str);
2024-02-18 14:05:04 +01:00
2024-02-19 16:01:53 +01:00
result_t execute(int* _exit_code, char** _stdoutbuf, char** _stderrbuf, const char* executable, ...);
2024-02-17 14:38:52 +01:00
2024-02-19 16:01:53 +01:00
result_t read_fd(char** _str, int fd);
result_t write_fd(int fd, const char* str);
result_t read_file(char** _str, const char* path);
result_t write_file(const char* path, const char* str);
2024-02-19 18:18:18 +01:00
result_t copy_file(const char* src, const char* dst);
2024-02-19 16:01:53 +01:00
result_t list_files(char*** _files, const char* path, bool (*filter)(const char*));
2024-02-19 18:18:18 +01:00
result_t md5sum(char** _md5, const char* path);