bootstrap/src/config.c

36 lines
598 B
C
Raw Normal View History

#include <stdlib.h>
#include <string.h>
#include "config.h"
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-23 15:07:22 +00:00
if (cwd == 0) {
return CE_ENV_CWD_INVALID;
}
2023-11-23 15:07:22 +00:00
if (root_dir == 0) {
2023-11-23 18:02:40 +00:00
return CE_ENV_ROOT_DIR_INVALID;
}
if (target == 0) {
2023-11-23 15:07:22 +00:00
return CE_TARGET_INVALID;
}
2023-11-23 14:40:17 +00:00
*config = malloc(sizeof(struct Config));
2023-11-23 15:07:22 +00:00
(*config)->cwd = cwd;
2023-11-23 14:40:17 +00:00
(*config)->root_dir = root_dir;
2023-11-23 15:07:22 +00:00
(*config)->target = target;
return 0;
}
2023-11-23 14:40:17 +00:00
void config_free(struct Config *config) {
if (!config) {
return;
}
free(config);
}