2023-11-23 18:02:40 +00:00
|
|
|
#ifndef _BOOTSTRAP_CONFIG_H
|
|
|
|
#define _BOOTSTRAP_CONFIG_H
|
2023-11-22 21:39:27 +00:00
|
|
|
|
|
|
|
struct Config {
|
2023-11-23 18:02:40 +00:00
|
|
|
// The directory the `bootstrap` command was run from.
|
2023-11-23 15:07:22 +00:00
|
|
|
// OWNERSHIP: Does not own this pointer.
|
|
|
|
const char *cwd;
|
|
|
|
// The root directory housing our specs.
|
|
|
|
// OWNERSHIP: Does not own this pointer.
|
2023-11-22 21:55:55 +00:00
|
|
|
const char *root_dir;
|
2023-11-23 18:02:40 +00:00
|
|
|
// The name of the spec we want to bootstrap.
|
2023-11-23 15:07:22 +00:00
|
|
|
// OWNERSHIP: Does not own this pointer.
|
2023-11-22 21:39:27 +00:00
|
|
|
const char *target;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ConfigError {
|
2023-11-23 20:31:54 +00:00
|
|
|
// The $CWD could not be retrieved.
|
2023-11-23 15:07:22 +00:00
|
|
|
CE_ENV_CWD_INVALID = 1,
|
2023-11-23 20:31:54 +00:00
|
|
|
// The $BOOTSTRAP_ROOT_DIR environment variable is empty.
|
2023-11-23 18:02:40 +00:00
|
|
|
CE_ENV_ROOT_DIR_INVALID,
|
2023-11-23 20:31:54 +00:00
|
|
|
// The target argument is invalid.
|
2023-11-23 15:07:22 +00:00
|
|
|
CE_TARGET_INVALID,
|
2023-11-24 18:47:23 +00:00
|
|
|
// No spec with the given name was found.
|
|
|
|
CE_TARGET_NOT_FOUND,
|
|
|
|
// The spec is not a directory.
|
|
|
|
CE_TARGET_NOT_DIR,
|
2023-11-22 21:39:27 +00:00
|
|
|
};
|
|
|
|
|
2023-11-23 14:40:17 +00:00
|
|
|
enum ConfigError config_load(
|
2023-11-23 15:07:22 +00:00
|
|
|
const char *cwd,
|
2023-11-23 11:09:32 +00:00
|
|
|
const char *root_dir,
|
|
|
|
const char *target,
|
2023-11-23 14:40:17 +00:00
|
|
|
struct Config **config
|
2023-11-23 11:09:32 +00:00
|
|
|
);
|
2023-11-22 21:39:27 +00:00
|
|
|
|
2023-11-23 14:40:17 +00:00
|
|
|
void config_free(struct Config *config);
|
2023-11-22 21:39:27 +00:00
|
|
|
|
2023-11-23 18:02:40 +00:00
|
|
|
#endif /* BOOTSTRAP_CONFIG_H */
|