diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-06-01 14:47:15 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-06-01 14:47:15 +0200 |
commit | d09cb20cb349cb1e691dd1435c4ca1322ebab8e4 (patch) | |
tree | d8f2ac89c6739bd42e94b0d61bee02a78c404744 /src/lib/eiotas_particle.c | |
parent | 1be871be95118d674e32aa389822b35e8a66fd6f (diff) | |
download | edoors-d09cb20cb349cb1e691dd1435c4ca1322ebab8e4.zip edoors-d09cb20cb349cb1e691dd1435c4ca1322ebab8e4.tar.gz |
Particle : add static add_destination and tests
Diffstat (limited to 'src/lib/eiotas_particle.c')
-rw-r--r-- | src/lib/eiotas_particle.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 5f302cf..a72d55f 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -20,6 +20,7 @@ #include "eiotas_private.h" static void update_link_value(Eiotas_Particle *particle, const char *field); +static Eina_Bool add_destination(Eiotas_Particle *particle, const char *dst, int l); Eiotas_Particle* eiotas_particle_alloc() { @@ -100,29 +101,44 @@ EAPI Eina_Bool eiotas_particle_has_dst(Eiotas_Particle *particle) EAPI void eiotas_particle_destinations_add(Eiotas_Particle *particle, const char* destinations) { - int n; char *dst, *sep; - Eina_Stringshare *s; dst = (char*)destinations; for(; *dst;) { for(; *dst==' '; dst++) /* eat leading spaces */; sep = dst; for(; (*sep && *sep!=EIOTAS_FIELDS_SEP && *sep!=' '); sep++) /* search destination end */; - n = (sep-dst); - if(n==0) { - ERR("ignore empty destination"); - } else { - s = eina_stringshare_add_length(dst,n); - eina_array_push(particle->dsts,s); - DBG("add dst >%s<",s); - } + add_destination(particle,dst,(sep-dst)); for(; (*sep && *sep!=EIOTAS_FIELDS_SEP); sep++) /* eat whatever following */; if(!*sep) return; dst = sep+1; } } +static Eina_Bool add_destination(Eiotas_Particle *particle, const char *dst, int n) +{ + Eina_Stringshare *s; + + if(n==0) { + ERR("ignore empty destination"); + return EINA_FALSE; + } + if(*dst==EIOTAS_ACTION_SEP || *dst==EIOTAS_PATH_SEP ) { + ERR("ignore destination starting with '%c' ",*dst); + return EINA_FALSE; + } + if(dst[n-1]==EIOTAS_ACTION_SEP || dst[n-1]==EIOTAS_PATH_SEP ) { + ERR("ignore destination ending with '%c' ",dst[n-1]); + return EINA_FALSE; + } + + s = eina_stringshare_add_length(dst,n); + eina_array_push(particle->dsts,s); + DBG("add dst >%s<",s); + + return EINA_TRUE; +} + EAPI void eiotas_particle_link_fields_set(Eiotas_Particle *particle, const char *link_fields) { int n; |