FSOVA5GJECIC6SQYUX6IK2FGMUDBHPIDMOEAET7HAVNPHHS5UYRAC
#define mbrtoc16 tabula_mbrtoc16
#define c16rtomb tabula_c16rtomb
#define mbrtoc32 tabula_mbrtoc32
#define c32rtomb tabula_c32rtomb
#define mbrtoc16(A, B, C, D) tabula_mbrtoc16(A, B, C, D)
#define c16rtomb(A, B, C, D) tabula_c16rtomb(A, B, C, D)
#define mbrtoc32(A, B, C, D) tabula_mbrtoc32(A, B, C, D)
#define c32rtomb(A, B, C, D) tabula_c32rtomb(A, B, C, D)
#define printf tabula_printf
#define vprintf tabula_vprintf
#define cprintf tabula_cprintf
#define vcprintf tabula_vcprintf
#define sprintf tabula_sprintf
#define vsprintf tabula_vsprintf
#define snprintf tabula_snprintf
#define vsnprintf tabula_vsnprintf
#define asprintf tabula_asprintf
#define printf(A, ...) tabula_printf(A, ## __VA_ARGS__)
#define vprintf(A, B) tabula_vprintf(A, B)
#define cprintf(A, ...) tabula_cprintf(A, ## __VA_ARGS__)
#define vcprintf(A, B) tabula_vcprintf(A, B)
#define sprintf(A, B, C, ...) tabula_sprintf(A, B, C, ## __VA_ARGS__)
#define vsprintf(A, B, C, D) tabula_vsprintf(A, B, C, D)
#define snprintf(A, B, C, D, ...) tabula_snprintf(A, B, C, D, ## __VA_ARGS__)
#define vsnprintf(A, B, C, D, E) tabula_vsnprintf(A, B, C, D, E)
#define asprintf(A, ...) tabula_asprintf(A, ## __VA_ARGS__)
#include <alias/glob.h>
bool alias_glob_match(alias_str pattern, alias_str string) {
for(;;) {
if(*pattern == 0 && *string == 0) {
return true;
}
if(*pattern == 0) {
return false;
}
if(*pattern == '*') {
pattern++;
if(*pattern == 0) {
return true;
}
while(*string) {
if(alias_glob_match(pattern, string)) {
return true;
}
string++;
}
return false;
}
if(*string == 0) {
return false;
}
if(*pattern == '?') {
pattern++;
string++;
continue;
}
if(*pattern == '[') {
pattern++;
uint32_t ascii[8] = {0};
bool negate = *pattern == '!';
pattern += negate;
if(pattern[1] == '-' && pattern[3] == ']') {
for(uint32_t i = pattern[0]; i < pattern[2]; i++) {
if(i <= 255) {
ascii[i >> 5] |= 1 << (i & 31);
}
}
pattern += 4;
} else {
while(*pattern && *pattern != ']') {
ascii[*pattern >> 5] |= 1 << (*pattern & 31);
pattern++;
}
pattern++;
}
if(negate) {
for(uint32_t i = 0; i < 8; i++) {
ascii[i] ^= 0xFFFFFFFFu;
}
}
if(ascii[*string >> 5] & (1 << (*string & 31))) {
string++;
continue;
}
return false;
}
}
}
void alias_file_write(alias_str path, void (*error)(void *ud), void (*f)(void *ud, struct alias_FileWriter *writer), void *ud) {
void alias_file_write(alias_str path, void (*error)(void *ud), void (*f)(void *ud, struct alias_FileWriter *writer),
void *ud) {
static void DirectorySetExists_cb(void *state_, bool value) {
struct DirectorySetExists *state = (struct DirectorySetExists *)state_;
static void DirectoryListExists_cb(void *state_, bool value) {
struct DirectoryListExists *state = (struct DirectoryListExists *)state_;
if(state->dir.paths[index].path != NULL) {
char * path;
alias_str_stack_format(path, "%s/%s", state->dir.paths[index].path, state->path);
result = alias_file_exists(path, DirectorySetExists_cb, state);
if(state->dir->paths.data[index].path != NULL) {
char *path;
alias_str_stack_format(path, "%s/%s", state->dir->paths.data[index].path, state->path);
alias_file_exists(path, DirectoryListExists_cb, state);
void alias_DirectorySet_exists(const struct alias_DirectorySet *dir, alias_str path, void (*f)(void *ud, bool value),
void *ud) {
struct DirectorySetExists *state = (struct DirectorySetExists *)alias_malloc(NULL, sizeof(*state), alignof(*state));
void alias_DirectoryList_exists(const struct alias_DirectoryList *dir, alias_str path, void (*f)(void *ud, bool value),
void *ud) {
struct DirectoryListExists *state = (struct DirectoryListExists *)alias_malloc(NULL, sizeof(*state), alignof(*state));
struct DirectorySetRead {
const struct alias_DirectorySet *dir;
struct DirectoryListFind {
struct alias_DirectoryList *dir;
uint32_t index;
alias_str pattern;
alias_Vector(alias_str) found_set;
void (*error)(void *ud);
void (*found)(void *ud, alias_str found_path);
void (*done)(void *ud);
void *ud;
};
static void DirectoryListFind_free(struct DirectoryListFind *state) {
alias_str_free(NULL, state->pattern);
for(uint32_t i = 0; i < state->found_set.length; i++) {
alias_str_free(NULL, state->found_set.data[i]);
}
alias_Vector_free(&state->found_set, NULL);
alias_free(NULL, state, sizeof(*state), alignof(*state));
}
static void DirectoryListFind_find_done(void *state_);
static void DirectoryListFind_find_error(void *state_) {
DirectoryListFind_find_done(state_);
}
static int str_compare(const void *a, const void *b, void *ud) {
return alias_str_compare((alias_str)a, (alias_str)b);
}
static void DirectoryListFind_find_found(void *state_, alias_str path) {
struct DirectoryListFind *state = (struct DirectoryListFind *)state_;
alias_str *entry = alias_Vector_bsearch(&state->found_set, &path, str_compare, NULL);
if(entry == NULL) {
state->found(state->ud, path);
alias_Vector_space_for(&state->found_set, NULL, 1);
*alias_Vector_push(&state->found_set) = alias_str_clone(NULL, path);
alias_Vector_qsort(&state->found_set, str_compare, NULL);
}
}
static void DirectoryListFind_find_done(void *state_) {
struct DirectoryListFind *state = (struct DirectoryListFind *)state_;
if(state->index == 0) {
state->done(state->ud);
DirectoryListFind_free(state);
return;
}
const struct alias_Directory *current = &state->dir->paths.data[--state->index];
if(current->path != NULL) {
alias_file_find(current->path, state->pattern, DirectoryListFind_find_error, DirectoryListFind_find_found,
DirectoryListFind_find_done, state_);
} else {
}
}
void alias_DirectoryList_find(struct alias_DirectoryList *dir, alias_str pattern, void (*error)(void *ud),
void (*found)(void *ud, alias_str found_path), void (*done)(void *ud), void *ud) {
struct DirectoryListFind *state = (struct DirectoryListFind *)alias_malloc(NULL, sizeof(*state), alignof(*state));
state->dir = dir;
state->index = dir->paths.length;
state->pattern = alias_str_clone(NULL, pattern);
alias_Vector_init(&state->found_set);
state->error = error;
state->found = found;
state->done = done;
state->ud = ud;
DirectoryListFind_find_done(dir);
}
struct DirectoryListRead {
const struct alias_DirectoryList *dir;
static void DirectorySetRead_file_read_error_cb(void *state_) {
struct DirectorySetRead *state = (struct DirectorySetRead *)state_;
static void DirectoryListRead_file_read_error_cb(void *state_) {
struct DirectoryListRead *state = (struct DirectoryListRead *)state_;
static void DirectorySetRead_file_read_partial_cb(void *state_, const void *data, uint64_t length) {
struct DirectorySetRead *state = (struct DirectorySetRead *)state_;
static void DirectoryListRead_file_read_partial_cb(void *state_, const void *data, uint64_t length) {
struct DirectoryListRead *state = (struct DirectoryListRead *)state_;
static void DirectorySetRead_file_read_done_cb(void *state_) {
struct DirectorySetRead *state = (struct DirectorySetRead *)state_;
static void DirectoryListRead_file_read_done_cb(void *state_) {
struct DirectoryListRead *state = (struct DirectoryListRead *)state_;
static void DirectorySetRead_exists_cb(void *state_, bool value) {
struct DirectorySetRead *state = (struct DirectorySetRead *)state_;
static void DirectoryListRead_exists_cb(void *state_, bool value) {
struct DirectoryListRead *state = (struct DirectoryListRead *)state_;
alias_file_read(path, DirectorySetRead_file_read_error_cb, DirectorySetRead_file_read_partial_cb, DirectorySetRead_file_read_done_cb, state_);
alias_file_read(path, DirectoryListRead_file_read_error_cb, DirectoryListRead_file_read_partial_cb,
DirectoryListRead_file_read_done_cb, state_);
void alias_DirectorySet_read(const struct alias_DirectorySet *dir, alias_str path, void (*error)(void *ud),
void (*partial)(void *ud, const void *data, uint64_t length), void (*done)(void *ud),
void *ud) {
struct DirectorySetRead *state = (struct DirectorySetRead *)alias_malloc(NULL, sizeof(*state), alignof(*state));
void alias_DirectoryList_read(const struct alias_DirectoryList *dir, alias_str path, void (*error)(void *ud),
void (*partial)(void *ud, const void *data, uint64_t length), void (*done)(void *ud),
void *ud) {
struct DirectoryListRead *state = (struct DirectoryListRead *)alias_malloc(NULL, sizeof(*state), alignof(*state));
void alias_DirectorySet_read_all(const struct alias_DirectorySet *dir, alias_str path, void (*error)(void *ud),
void (*done)(void *ud, const void *data, uint64_t length), void *ud) {}
void alias_DirectoryList_read_all(const struct alias_DirectoryList *dir, alias_str path, void (*error)(void *ud),
void (*done)(void *ud, const void *data, uint64_t length), void *ud) {}
bool alias_DirectorySet_read_all_synchronous(const struct alias_DirectorySet *dir, alias_str path, void **data_ptr,
uint64_t *length_ptr) {
bool alias_DirectoryList_read_all_synchronous(const struct alias_DirectoryList *dir, alias_str path, void **data_ptr,
uint64_t *length_ptr) {
void alias_FileWriter_write(struct alias_FileWriter *writer, const void *data, uint64_t length, void (*error)(void *ud), void (*done)(void *ud), void *ud) {
void alias_FileWriter_write(struct alias_FileWriter *writer, const void *data, uint64_t length, void (*error)(void *ud),
void (*done)(void *ud), void *ud) {
#ifndef _ALIAS_GLOB_H_
#define _ALIAS_GLOB_H_
#include <stdbool.h>
#include <alias/str.h>
/// Syntax
/// * - matches any number of any characters including none
/// ? - matches any single character
/// [abc] - matches one character given in the bracket
/// [a-z] - matches one character from the range given in the bracket
/// [!abc] - matches one character that is not given in the bracket
/// [!a-z] - matches one character that is not from the range given in the bracket
bool alias_glob_match(alias_str pattern, alias_str string);
#endif
uint32_t alias_DirectorySet_add_synchronous_interface(
struct alias_DirectorySet *dir, alias_MemoryCB *mcb, bool (*exists_syncronous)(void *ud, alias_str path),
uint32_t alias_DirectoryList_add_synchronous_interface(
struct alias_DirectoryList *dir, alias_MemoryCB *mcb, bool (*exists_syncronous)(void *ud, alias_str path),