- minor renamings
[oweals/gnunet.git] / src / env / env.c
index 1a8c1a5689ac7809c0232fb47e030544def26d06..107be8827aff193f2f961c40f2a0a7a60c7ffe95 100644 (file)
@@ -64,9 +64,9 @@ GNUNET_ENV_environment_create ()
  * @param value_size Size of @a value.
  */
 void
-GNUNET_ENV_environment_add_mod (struct GNUNET_ENV_Environment *env,
-                                enum GNUNET_ENV_Operator oper, const char *name,
-                                const void *value, size_t value_size)
+GNUNET_ENV_environment_add (struct GNUNET_ENV_Environment *env,
+                            enum GNUNET_ENV_Operator oper, const char *name,
+                            const void *value, size_t value_size)
 {
   struct GNUNET_ENV_Modifier *mod = GNUNET_new (struct GNUNET_ENV_Modifier);
   mod->oper = oper;
@@ -78,6 +78,67 @@ GNUNET_ENV_environment_add_mod (struct GNUNET_ENV_Environment *env,
 }
 
 
+/** 
+ * Get the modifier at the beginning of an environment.
+ *
+ * @param env 
+ * @param oper 
+ * @param name 
+ * @param value 
+ * @param value_size 
+ * 
+ * @return 
+ */
+int
+GNUNET_ENV_environment_head (struct GNUNET_ENV_Environment *env,
+                              enum GNUNET_ENV_Operator *oper, const char **name,
+                              const void **value, size_t *value_size)
+{
+  if (NULL == env->mod_head)
+    return GNUNET_NO;
+
+  struct GNUNET_ENV_Modifier *mod = env->mod_head;
+  *oper = mod->oper;
+  *name = mod->name;
+  *value = mod->value;
+  *value_size = mod->value_size;
+  return GNUNET_YES;
+}
+
+
+/** 
+ * Get the modifier at the beginning of an environment and remove it.
+ *
+ * @param env 
+ * @param oper 
+ * @param name 
+ * @param value 
+ * @param value_size 
+ * 
+ * @return 
+ */
+int
+GNUNET_ENV_environment_shift (struct GNUNET_ENV_Environment *env,
+                              enum GNUNET_ENV_Operator *oper, const char **name,
+                              const void **value, size_t *value_size)
+{
+  if (NULL == env->mod_head)
+    return GNUNET_NO;
+
+  struct GNUNET_ENV_Modifier *mod = env->mod_head;
+  *oper = mod->oper;
+  *name = mod->name;
+  *value = mod->value;
+  *value_size = mod->value_size;
+
+  GNUNET_CONTAINER_DLL_remove (env->mod_head, env->mod_tail, mod);
+  GNUNET_free (mod);
+  env->mod_count--;
+
+  return GNUNET_YES;
+}
+
+
 /**
  * Iterate through all modifiers in the environment.
  *
@@ -91,7 +152,7 @@ GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env,
 {
   struct GNUNET_ENV_Modifier *mod;
   for (mod = env->mod_head; NULL != mod; mod = mod->next)
-    it (it_cls, mod);
+    it (it_cls, mod->oper, mod->name, mod->value, mod->value_size);
 }
 
 
@@ -103,7 +164,7 @@ GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env,
  * @return Number of modifiers.
  */
 size_t
-GNUNET_ENV_environment_get_mod_count (const struct GNUNET_ENV_Environment *env)
+GNUNET_ENV_environment_get_count (const struct GNUNET_ENV_Environment *env)
 {
   return env->mod_count;
 }