/* flags used when setting/clearing variables */
#define VF_UPDATEONLY 0x00000001 // SCOPE_PROC variables are only updated
+#define VF_CREATEONLY 0x00000002 // do nothing if the variable already exists
enum vars_scope {
SCOPE_SESS = 0,
* Flags is a bitfield that may contain one of the following flags:
* - VF_UPDATEONLY: if the scope is SCOPE_PROC, the variable may only be
* updated but not created.
+ * - VF_CREATEONLY: do nothing if the variable already exists (success).
*
* It returns 0 on failure, non-zero on success.
*/
var = var_get(vars, name);
if (var) {
+ if (flags & VF_CREATEONLY) {
+ ret = 1;
+ goto unlock;
+ }
+
/* free its used memory. */
if (var->data.type == SMP_T_STR ||
var->data.type == SMP_T_BIN) {