return 0;
}
+// Appends something to an environment variable, separated by :
+int pakfire_env_append(struct pakfire_env* env, const char* key, const char* format, ...) {
+ const char* old_value = NULL;
+ char value[PATH_MAX];
+ va_list args;
+ int r;
+
+ // Format the value
+ va_start(args, format);
+ r = pakfire_string_vformat(value, format, args);
+ va_end(args);
+ if (r < 0)
+ return r;
+
+ // Fetch the old value
+ old_value = pakfire_env_get(env, key);
+
+ // If there was no previous value, we will just set the new value
+ if (!old_value)
+ return pakfire_env_set(env, key, "%s", value);
+
+ // Otherwise we will append it separated by :
+ return pakfire_env_set(env, key, "%s:%s", old_value, value);
+}
+
// Imports an environment
int pakfire_env_import(struct pakfire_env* env, const char** e) {
char* key = NULL;
const char* pakfire_env_get(struct pakfire_env* env, const char* key);
int pakfire_env_set(struct pakfire_env* env, const char* key, const char* format, ...)
__attribute__((format(printf, 3, 4)));
+int pakfire_env_append(struct pakfire_env* env, const char* key, const char* format, ...)
+ __attribute__((format(printf, 3, 4)));
int pakfire_env_import(struct pakfire_env* env, const char** e);