1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

added entity & slash to uniform struct

This commit is contained in:
Gabor Adam Toth 2011-11-01 12:22:30 +01:00
parent 0cd53743e2
commit ed5feee0e3
3 changed files with 17 additions and 2 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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)));