X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=common%2Fapp.c;fp=common%2Fapp.c;h=2fad96e6f11818db67b5deb3e44a17dc4118ffe1;hb=a06b78f6b47c6e5287ea9a5c935afea4ded6e0b8;hp=55ec75a7ef34344bbe93ab547564b1ab4daeeb89;hpb=3e3138025852408ef03f3213972e042e12841bed;p=blerg.git diff --git a/common/app.c b/common/app.c index 55ec75a..2fad96e 100644 --- a/common/app.c +++ b/common/app.c @@ -41,6 +41,29 @@ int parse_url_info(const char *url, struct url_info *info) { return info->contents; } +int parse_auth_cookie(const char *str, struct auth_cookie *cookie) { + char *token_begin = strchr(str, '/'); + if (token_begin == NULL) { + return 0; + } + int len = token_begin - str; + if (len > MAX_TAG_LENGTH || len == 0) { + return 0; + } + memcpy(cookie->name, str, len); + cookie->name[len] = 0; + + token_begin++; + len = strlen(token_begin); + if (len != TOKEN_SIZE * 2) { + return 0; + } + memcpy(cookie->token, token_begin, TOKEN_SIZE * 2); + cookie->token[TOKEN_SIZE * 2] = 0; + + return 1; +} + uint64_t *make_sequential_list(uint64_t from, uint64_t to) { uint64_t len = to - from + 1; uint64_t *list = malloc(len * sizeof(uint64_t));