Reworked `PROG_RET_` to return negatives on internal, memory, or file/mapping failures, and to return the first haystack number that failed to match instead as return code (haystack numbers start at 1, since 0 is the needle). If all matched, return 0 from main().
Deprecated `PROG_RET_MAP_HAYSTACK_FAILED`
XXX: Currently `PROG_RET_MATCH_HAYSTACK_N_FAILED(n)` returns `n` verbatim (casted to `int`). Maybe we should ensure the number is nonzero in the macro? Or rework haystack numbers to start at 0 and have this macro add 1 to `n`? The former seems easier.
Fortune for naka's current commit: Middle blessing − 中吉
//NOTE: -- Reworked `PROG_RET_` to have mapping and internal failures be negative, and the first haystack number to fail returned verbatim (haystack numbers start at 1). So, after consolidating the threadpool's results, we iterate over haystack numbers, find the first non-match, and exit process with its number. Otherwise, we return 0.
// Invalid arguments to program (print usage to stderr)
// Invalid arguments to program (print usage to stderr)
#define PROG_RET_ARGS 1
#define PROG_RET_ARGS -2
// Mapping of argv[1] failed
// Mapping of argv[1] failed
#define PROG_RET_MAP_NEEDLE_FAILED 2
#define PROG_RET_MAP_NEEDLE_FAILED -3
// `h` is the number in argv[] of the haystack file
// `h` is the number in argv[] of the haystack file
//TODO: Use either `cmp_find()` or `cmp_find_many()` to find the `needle` (mapped above) within those haystacks.
//TODO: Use either `cmp_find()` or `cmp_find_many()` to find the `needle` (mapped above) within those haystacks.
//TODO: Within the threadpool: output information regarding each match/nonmatch.
//TODO: Within the threadpool: output information regarding each match/nonmatch.
//TODO: Join the threadpool and consolidate results.
//TODO: Join the threadpool and consolidate results.
//TODO: Iterate through the haystack numbers match results, return the first non-match haystack number through `PROG_RET_MATCH_HAYSTACK_N_FAILED(n)` (haystack numbers are always nonzero). If all were matched, return 0
//TODO: Should we return an error (`PROG_RET_MAP_HAYSTACK_N_FAILED(n)`) if one (or more) of the haystacks fail? Or consolidate multiple failures into `PROG_RET_MAP_HAYSTACK_FAILED | (failures)`? The latter would be the most complete.