You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naka/include/comp.h

35 lines
1.2 KiB

#ifndef _COMP_H
#define _COMP_H
#include <macros.h>
#include <ints.h>
typedef struct comp_aggregate {
bool all_matched;
int idx_first_failure;
usize num_results;
struct comp_single_result {
map_t* _shared mapping;
bool matched;
usize slice_start;
} aggr[];
} comp_multires_t;
/// Find `needle` in `haystack`, sets the start of `needle`'s `origin` in `haystack`'s to `pos` and returns `true` if a match is found, otherwise returns false.
bool cmp_find(const map_t *pIN needle, const map_t *pIN haystack, usize *pOUT pos);
/// Check `needle` against `nhaystacks` number of haystack maps, store the offset in `sizes[n]` where `n` is the haystack number.
/// `sizes` must be at least `nhaystacks` long. The haystacks themselves are expected to be of type `const map_t* pIN`
/// Returns `-1` if all haystacks passed match, otherwise returns the index of the haystack that failed.
///
/// # Panics
/// Will `FATAL` if any of the haystack pointers are `NULL`
int cmp_find_many(const map_t *pIN needle, usize nhaystacks, usize sizes[pOUT nhaystacks], ...);
// The return value of this function must be `free()`d after use
comp_multires_t* comp_match_all(map_t *pIN needle, usize nh, map_t hs[pIN nh], bool abort_on_fail);
#endif /* _COMP_H */