aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core.h12
-rw-r--r--include/envctl.h37
2 files changed, 40 insertions, 9 deletions
diff --git a/include/core.h b/include/core.h
index d065096..1ea0f5e 100644
--- a/include/core.h
+++ b/include/core.h
@@ -21,6 +21,7 @@
#define HTTP_ERROR(X) X >= 400
#include "config.h"
+#include "envctl.h"
#include "template.h"
#include "utils.h"
#include "copy.h"
@@ -59,11 +60,6 @@
} \
} while (0)
-struct EnvCtl {
- unsigned flags;
- const char *name[10];
-};
-
struct STASIS_GLOBAL {
bool verbose; //!< Enable verbose output
bool always_update_base_environment; //!< Update base environment immediately after activation
@@ -73,6 +69,7 @@ struct STASIS_GLOBAL {
bool enable_artifactory; //!< Enable artifactory uploads
bool enable_testing; //!< Enable package testing
bool enable_overwrite; //!< Enable release file clobbering
+ bool enable_rewrite_spec_stage_2; //!< Enable automatic @STR@ replacement in output files
struct StrList *conda_packages; //!< Conda packages to install after initial activation
struct StrList *pip_packages; //!< Pip packages to install after initial activation
char *tmpdir; //!< Path to temporary storage directory
@@ -93,13 +90,10 @@ struct STASIS_GLOBAL {
char *repo;
char *url;
} jfrog;
- struct EnvCtl envctl[];
+ struct EnvCtl *envctl;
};
extern struct STASIS_GLOBAL globals;
-#define STASIS_ENVCTL_PASSTHRU 0 << 1
-#define STASIS_ENVCTL_REQUIRED 1 << 1
-#define STASIS_ENVCTL_REDACT 2 << 1
extern const char *VERSION;
extern const char *AUTHOR;
extern const char *BANNER;
diff --git a/include/envctl.h b/include/envctl.h
new file mode 100644
index 0000000..c8ef357
--- /dev/null
+++ b/include/envctl.h
@@ -0,0 +1,37 @@
+#ifndef STASIS_ENVCTL_H
+#define STASIS_ENVCTL_H
+
+#include <stdlib.h>
+
+#define STASIS_ENVCTL_PASSTHRU 0
+#define STASIS_ENVCTL_REQUIRED 1 << 1
+#define STASIS_ENVCTL_REDACT 1 << 2
+#define STASIS_ENVCTL_DEFAULT_ALLOC 100
+
+#define STASIS_ENVCTL_RET_FAIL (-1)
+#define STASIS_ENVCTL_RET_SUCCESS 1
+#define STASIS_ENVCTL_RET_IGNORE 2
+typedef int (envctl_except_fn)(const void *, const void *);
+
+struct EnvCtl_Item {
+ unsigned flags; //<! One or more STASIS_ENVCTL_* flags
+ const char *name; //<! Environment variable name
+ envctl_except_fn *callback;
+};
+
+struct EnvCtl {
+ size_t num_alloc;
+ size_t num_used;
+ struct EnvCtl_Item **item;
+};
+
+struct EnvCtl *envctl_init();
+int envctl_register(struct EnvCtl **envctl, unsigned flags, envctl_except_fn *callback, const char *name);
+unsigned envctl_get_flags(const struct EnvCtl *envctl, const char *name);
+unsigned envctl_check_required(unsigned flags);
+unsigned envctl_check_redact(unsigned flags);
+int envctl_check_present(const struct EnvCtl_Item *item, const char *name);
+void envctl_do_required(const struct EnvCtl *envctl, int verbose);
+void envctl_free(struct EnvCtl **envctl);
+
+#endif // STASIS_ENVCTL_H \ No newline at end of file