summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-31 16:36:43 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-31 16:36:43 +0200
commit8c561b86372f517b3d6ac9137f09a94f6d2425da (patch)
tree4c0ae6a97100e56d8095bbf2e2cfb6329e9cf144 /src
parent0833dc8bd16c01d30912b7a259f9a0aee2d1b430 (diff)
downloadedoors-8c561b86372f517b3d6ac9137f09a94f6d2425da.zip
edoors-8c561b86372f517b3d6ac9137f09a94f6d2425da.tar.gz
Particle : add eiotas_particle_link_fields_set
Diffstat (limited to 'src')
-rw-r--r--src/include/eiotas_particle.h9
-rw-r--r--src/lib/eiotas_particle.c31
2 files changed, 40 insertions, 0 deletions
diff --git a/src/include/eiotas_particle.h b/src/include/eiotas_particle.h
index e6fdedf..34b59ed 100644
--- a/src/include/eiotas_particle.h
+++ b/src/include/eiotas_particle.h
@@ -107,6 +107,15 @@ EAPI void eiotas_particle_merge(Eiotas_Particle *particle, const Eiotas_Particle
EAPI void eiotas_particle_destinations_add(Eiotas_Particle *particle, const char *destinations);
/**
+ * @brief Set the link fields
+ *
+ * @param particle The @ref Eiotas_Particle to set the link fields to
+ * @param link_fields A comma separated list of fields name
+ *
+ */
+EAPI void eiotas_particle_link_fields_set(Eiotas_Particle *particle, const char *link_fields);
+
+/**
* @}
*/
diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c
index 7f45848..a2252bd 100644
--- a/src/lib/eiotas_particle.c
+++ b/src/lib/eiotas_particle.c
@@ -116,6 +116,37 @@ EAPI void eiotas_particle_destinations_add(Eiotas_Particle *particle, const char
}
}
+EAPI void eiotas_particle_link_fields_set(Eiotas_Particle *particle, const char *link_fields)
+{
+ int n;
+ unsigned int i;
+ Eina_Stringshare *s;
+ Eina_Array_Iterator it;
+ char *field, *sep;
+
+ EINA_ARRAY_ITER_NEXT(particle->link_fields, i, s, it) eina_stringshare_del(s);
+ eina_array_clean(particle->link_fields);
+
+ field = (char*)link_fields;
+ for(; *field;) {
+ for(; *field==' '; field++) /* eat leading spaces */;
+ sep = field;
+ for(; (*sep && *sep!=EIOTAS_FIELDS_SEP && *sep!=' '); sep++) /* search field end */;
+ n = (sep-field);
+ if(n==0) {
+ ERR("ignore empty field");
+ } else {
+ s = eina_stringshare_add_length(field,n);
+ eina_array_push(particle->link_fields,s);
+ DBG("add field >%s<",s);
+ }
+ for(; (*sep && *sep!=EIOTAS_FIELDS_SEP); sep++) /* eat whatever following */;
+ if(!*sep) return;
+ field = sep+1;
+ }
+ update_link_value(particle,NULL);
+}
+
static void update_link_value(Eiotas_Particle *particle, const char *field)
{
unsigned int i;