From 0833dc8bd16c01d30912b7a259f9a0aee2d1b430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 May 2012 16:35:04 +0200 Subject: Particle: add static void update_link_value --- src/lib/eiotas_particle.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 2cf1f47..7f45848 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -19,6 +19,8 @@ #include "eiotas_particle.h" #include "eiotas_private.h" +static void update_link_value(Eiotas_Particle *particle, const char *field); + Eiotas_Particle* eiotas_particle_alloc() { BUILD_INSTANCE(Eiotas_Particle,particle); @@ -110,7 +112,44 @@ EAPI void eiotas_particle_destinations_add(Eiotas_Particle *particle, const char } for(; (*sep && *sep!=EIOTAS_FIELDS_SEP); sep++) /* eat whatever following */; if(!*sep) return; - dst=sep+1; + dst = sep+1; + } +} + +static void update_link_value(Eiotas_Particle *particle, const char *field) +{ + unsigned int i; + unsigned int l; + Eina_Stringshare *k; + Eina_Stringshare *v; + Eina_Array_Iterator it; + Eina_Bool update; + char tmp[EIOTAS_MAX_VALUE_LENGTH]; + char *dst; + + if(field!=NULL) { + update = EINA_FALSE; + EINA_ARRAY_ITER_NEXT(particle->link_fields, i, k, it) { + if(strcmp(field,k)==0) { + update = EINA_TRUE; + break; + } + } + if(!update) return; + } + + if(particle->link_value) eina_stringshare_del(particle->link_value); + + dst = tmp; + EINA_ARRAY_ITER_NEXT(particle->link_fields, i, k, it) { + v = eina_hash_find(particle->payload,k); + if(v!=NULL) { + l = strlen(v); + strcpy(dst,v); + dst += l; + } } + *dst='\0'; + particle->link_value = eina_stringshare_add(tmp); } -- cgit v1.1-2-g2b99