bootstrap/include/config.h

39 lines
971 B
C

#ifndef _BOOTSTRAP_CONFIG_H
#define _BOOTSTRAP_CONFIG_H
struct Config {
// The directory the `bootstrap` command was run from.
// OWNERSHIP: Does not own this pointer.
const char *cwd;
// The root directory housing our specs.
// OWNERSHIP: Does not own this pointer.
const char *root_dir;
// The name of the spec we want to bootstrap.
// OWNERSHIP: Does not own this pointer.
const char *target;
};
enum ConfigError {
// The $CWD could not be retrieved.
CE_ENV_CWD_INVALID = 1,
// The $BOOTSTRAP_ROOT_DIR environment variable is empty.
CE_ENV_ROOT_DIR_INVALID,
// The target argument is invalid.
CE_TARGET_INVALID,
// No spec with the given name was found.
CE_TARGET_NOT_FOUND,
// The spec is not a directory.
CE_TARGET_NOT_DIR,
};
enum ConfigError config_load(
const char *cwd,
const char *root_dir,
const char *target,
struct Config **config
);
void config_free(struct Config *config);
#endif /* BOOTSTRAP_CONFIG_H */