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 | |
parent | 520e1ba759641d0282e82504e27ed57783fd6e8d (diff) | |
download | edoors-4f4c2d9686a432953f129b8503a53dcdd038b975.zip edoors-4f4c2d9686a432953f129b8503a53dcdd038b975.tar.gz |
Particle: implement eiotas_particle_add_destinations
Diffstat (limited to 'src')
-rw-r--r-- | src/include/eiotas_particle.h | 2 | ||||
-rw-r--r-- | src/lib/eiotas_particle.c | 30 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/include/eiotas_particle.h b/src/include/eiotas_particle.h index 4ebe415..6897d89 100644 --- a/src/include/eiotas_particle.h +++ b/src/include/eiotas_particle.h @@ -51,4 +51,6 @@ EAPI void eiotas_particle_init(Eiotas_Particle *particle, Eiotas_Iota *iota); EAPI void eiotas_particle_merge(Eiotas_Particle *particle, Eiotas_Particle *p); +EAPI void eiotas_particle_add_destinations(Eiotas_Particle *particle, char* destinations); + #endif // __EIOTAS_PARTICLE_H__ 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; + } +} + |