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) {
45 char *token_begin = strchr(str, '/');
46 if (token_begin == NULL) {
49 int len = token_begin - str;
50 if (len > MAX_TAG_LENGTH || len == 0) {
53 memcpy(cookie->name, str, len);
54 cookie->name[len] = 0;
57 len = strlen(token_begin);
58 if (len != TOKEN_SIZE * 2) {
61 memcpy(cookie->token, token_begin, TOKEN_SIZE * 2);
62 cookie->token[TOKEN_SIZE * 2] = 0;
67 uint64_t *make_sequential_list(uint64_t from, uint64_t to) {
68 uint64_t len = to - from + 1;
69 uint64_t *list = malloc(len * sizeof(uint64_t));
72 for (i = 0; i < len; i++) {