merk/include/utilities.h

56 lines
1.5 KiB
C

#ifndef UTILITIES_H
#define UTILITIES_H
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
#include "myers.h"
#include "action_list.h"
#define IS_ALPHA(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
#define IS_DIGIT(c) (c >= '0' && c <= '9')
#define IS_ALNUM(c) (IS_ALPHA(c) || IS_DIGIT(c))
#define IS_PUNCT(c) ((c >= 33 && c <= 47) || (c >= 58 && c <= 64) || (c >= 91 && c <= 96) || (c >= 123 && c <= 126))
#define RESET "\033[0m"
#define RED_BG "\033[41m"
#define GREEN_BG "\033[42m"
#define BLACK_FG "\033[30m"
typedef enum {
PT_NOEXIST,
PT_FILE,
PT_DIR,
PT_OTHER,
PT_ERROR
} PathType;
typedef List StringBuffer;
typedef struct {
uint32_t insertions;
uint32_t deletions;
} Changes;
StringBuffer* string_buffer_new();
int string_buffer_push(StringBuffer*, char*);
void string_buffer_sort(StringBuffer*);
char* string_buffer_search(StringBuffer*, char*);
char* find_root(char*);
void walk(char*, char*, char*, FileInfoBuffer*, int, char*);
char* get_repo_path(char*, char*);
int is_in_repo(char*, char*);
void visualize_diff(File*, File*, ActionList*);
int cut_path(char*, char*);
void combine_path(char*, char*);
PathType get_path_type(const char*);
char* get_file_content(char*);
char* get_file_content_with_size(char*, size_t*);
int create_default_config_file(char*);
int save_diff(ActionList*, char*, char*, size_t, char*, File*, int);
int read_diff(char*, char*, ActionList*);
int save_file_diff(char*, char*, size_t, char*, Changes*);
#endif // UTILITIES_H