diff --git a/include/psyc/uniform.h b/include/psyc/uniform.h index bf1d84c..332367e 100644 --- a/include/psyc/uniform.h +++ b/include/psyc/uniform.h @@ -32,8 +32,10 @@ typedef struct { PsycString body; // the URL without scheme and '//' PsycString user_host; // mailto and xmpp style PsycString host_port; // just host:port (and transport) - PsycString root; // root UNI of peer/server + PsycString root; // root UNI + PsycString entity; // entity UNI, without the channel PsycString slashes; // the // if the protocol has them + PsycString slash; // first / after host PsycString nick; // whatever works as a nickname } PsycUniform; diff --git a/src/uniform.c b/src/uniform.c index 26b83bf..d888423 100644 --- a/src/uniform.c +++ b/src/uniform.c @@ -64,6 +64,9 @@ int psyc_uniform_parse (PsycUniform *uni, char *str, size_t length) part = PSYC_UNIFORM_PORT; p = &uni->port; } else if (c == '/') { + uni->slash.data = str + pos; + uni->slash.length = 1; + part = PSYC_UNIFORM_RESOURCE; p = &uni->resource; } @@ -83,6 +86,9 @@ int psyc_uniform_parse (PsycUniform *uni, char *str, size_t length) return PSYC_PARSE_UNIFORM_INVALID_PORT; if (c == '/') { + uni->slash.data = str + pos; + uni->slash.length = 1; + part = PSYC_UNIFORM_RESOURCE; uni->resource.data = str + pos + 1; uni->resource.length = 0; @@ -108,6 +114,9 @@ int psyc_uniform_parse (PsycUniform *uni, char *str, size_t length) uni->transport.length++; break; case '/': + uni->slash.data = str + pos; + uni->slash.length = 1; + part = PSYC_UNIFORM_RESOURCE; uni->resource.data = str + pos + 1; uni->resource.length = 0; @@ -149,6 +158,9 @@ int psyc_uniform_parse (PsycUniform *uni, char *str, size_t length) uni->root.length = uni->scheme.length + 1 + uni->slashes.length + uni->host_port.length; + uni->entity.data = str; + uni->entity.length = uni->root.length + uni->slash.length + uni->resource.length; + uni->body.data = uni->host.data; uni->body.length = length - uni->scheme.length - 1 - uni->slashes.length; diff --git a/test/uniform_parse.c b/test/uniform_parse.c index 1a466fa..0b82b61 100644 --- a/test/uniform_parse.c +++ b/test/uniform_parse.c @@ -10,7 +10,7 @@ testUniform (char *str, int ret) { printf("%s\n", str); int r = psyc_uniform_parse(uni, str, strlen(str)); - PP(("[%.*s] : [%.*s] [%.*s] : [%.*s] [%.*s] / [%.*s] # [%.*s]\n[%.*s] [%.*s]\n[%.*s]\n\n", + PP(("[%.*s] : [%.*s] [%.*s] : [%.*s] [%.*s] / [%.*s] # [%.*s]\n[%.*s]\n[%.*s] [%.*s]\n[%.*s]\n\n", (int)PSYC_S2ARG2(uni->scheme), (int)PSYC_S2ARG2(uni->slashes), (int)PSYC_S2ARG2(uni->host), @@ -18,6 +18,7 @@ testUniform (char *str, int ret) { (int)PSYC_S2ARG2(uni->transport), (int)PSYC_S2ARG2(uni->resource), (int)PSYC_S2ARG2(uni->channel), + (int)PSYC_S2ARG2(uni->entity), (int)PSYC_S2ARG2(uni->root), (int)PSYC_S2ARG2(uni->nick), (int)PSYC_S2ARG2(uni->body)));