1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2 * BSD-style license. Please see the COPYING file for details.
9 int parse_url_info(const char *url, struct url_info *info) {
22 if (len > MAX_TAG_LENGTH)
24 memcpy(info->name, url, len);
26 info->contents |= URL_INFO_NAME;
28 if (c == NULL || c[1] == 0)
29 return info->contents;
31 info->record = strtoull(c + 1, NULL, 10);
32 info->contents |= URL_INFO_RECORD;
35 if (c == NULL || c[1] == 0)
36 return info->contents;
38 info->record_to = strtoull(c + 1, NULL, 10);
39 info->contents |= URL_INFO_RECORD_TO;
41 return info->contents;
44 int parse_auth_cookie(const char *str, struct auth_cookie *cookie) {
50 char *token_begin = strchr(str, '/');
51 if (token_begin == NULL) {
54 int len = token_begin - str;
55 if (len > MAX_TAG_LENGTH || len == 0) {
58 memcpy(cookie->name, str, len);
59 cookie->name[len] = 0;
62 len = strlen(token_begin);
63 if (len != TOKEN_SIZE * 2) {
66 memcpy(cookie->token, token_begin, TOKEN_SIZE * 2);
67 cookie->token[TOKEN_SIZE * 2] = 0;
72 uint64_t *make_sequential_list(uint64_t from, uint64_t to) {
73 uint64_t len = to - from + 1;
74 uint64_t *list = malloc(len * sizeof(uint64_t));
77 for (i = 0; i < len; i++) {