//! Re-exports Makefile defines as more usable types
#ifndef _PROJECT_H
#define _PROJECT_H

#include <limits.h>

#include "macros.h"
#include "ints.h"
#include "version.h"

/// Project version, as a raw version identifier (u32).
/// Use `v_rawtoc()` to convert to `version_t`.
#define PROG_VERSION VERSION(_VERSION_MAJOR, \
				_VERSION_MINOR, \
				_VERSION_BUGFIX, \
				_VERSION_REVISION)

/// Project name. Output binary name
#define PROG_NAME _PROJECT_NAME
/// Project description
#define PROG_DESCRIPTION _PROJECT_DESCRIPTION
/// Project authour(s)
#define PROG_AUTHOUR _PROJECT_AUTHOR
/// Project license
#define PROG_LICENSE _PROJECT_LICENSE
/// Compiled time (UTC unix timestamp)
#define PROG_COMPILED_TIMESTAMP AS(_PROJECT_COMPILED, u64)


// Returns from the program

//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)
#define PROG_RET_ARGS -2
// Mapping of argv[1] failed
#define PROG_RET_MAP_NEEDLE_FAILED -3
// `h` is the number in argv[] of the haystack file
#define PROG_RET_MAP_HAYSTACK_N_FAILED(h) -((h) << 2)
// `h` is the number in argv[] of the haystack file
#define PROG_RET_UNMAP_HAYSTACK_N_FAILED(h) -(((h) << 2) | 1)
// Match of haystack number `h` failed.
#define PROG_RET_MATCH_HAYSTACK_N_FAILED(h) AS(h, int)
// Bitwise OR this with the number(s) of the haystack that match failed. It must not exceed INT_MAX-1
// XXX: DEPRECATED
#define PROG_RET_MAP_HAYSTACK_FAILED AS((AS(INT_MAX, u64) >> 1lu) ^ AS(INT_MAX, u64), int)
// Unmapping of argv[1] failed
#define PROG_RET_UNMAP_NEEDLE_FAILED -4
// Internal error
#define PROG_RET_INTERNAL -1

#endif /* _PROJECT_H */
