diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-29 09:40:20 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-29 09:40:20 +0200 |
commit | 4f4c2d9686a432953f129b8503a53dcdd038b975 (patch) | |
tree | 2488e570affe197bc063afdb93a92626bbc81e9b /src/lib | |
parent | 520e1ba759641d0282e82504e27ed57783fd6e8d (diff) | |
download | edoors-4f4c2d9686a432953f129b8503a53dcdd038b975.zip edoors-4f4c2d9686a432953f129b8503a53dcdd038b975.tar.gz |
Particle: implement eiotas_particle_add_destinations
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/eiotas_particle.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 4927e90..4b0a5f6 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -89,3 +89,33 @@ EAPI void eiotas_particle_merge(Eiotas_Particle *particle, Eiotas_Particle *p) particle->merged = eina_inlist_append(particle->merged, EINA_INLIST_GET(p)); } +EAPI void eiotas_particle_add_destinations(Eiotas_Particle *particle, char* destinations) +{ + int n; + char *dst, *sep; + Eina_Stringshare *shared; + char tmp[EIOTAS_MAX_PATH_LENGTH]; + + dst = 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 if(n+2>EIOTAS_MAX_PATH_LENGTH) { + ERR("buffer overflow (%d)",n); + } else { + memcpy(tmp,dst,n); + tmp[n]='\0'; + shared = eina_stringshare_add(tmp); + eina_array_push(particle->dsts,shared); + DBG("add dst >%s<",shared); + } + for(; (*sep && *sep!=EIOTAS_FIELDS_SEP); sep++) /* eat whatever following */; + if(!*sep) return; + dst=sep+1; + } +} + |