+#define NOTFOUND "<html><head><title>404 Not Found</title></head><body><h1>404 Not Found</h1>I couldn't find that.</body></html>"
+
+struct MHD_Response *response404;
+
+void init_responses() {
+ response404 = MHD_create_response_from_data(strlen(NOTFOUND), NOTFOUND, MHD_NO, MHD_NO);
+}
+
+int respond_404(struct MHD_Connection *connection) {
+ return MHD_queue_response(connection, MHD_HTTP_NOT_FOUND, response404);
+}
+
+int parse_url_info(const char *url, char *author, uint64_t *record) {
+ const char *c;
+ int ret = 0;
+ int len;
+
+ c = strchr(url, '/');
+ if (c == NULL) {
+ len = strlen(url);
+ } else {
+ len = c - url;
+ }
+ if (len == 0)
+ return 0;
+ memcpy(author, url, len);
+ author[len] = 0;
+ ret |= URL_INFO_AUTHOR;
+
+ if (c != NULL && c[1] != 0) {
+ *record = strtoull(c + 1, NULL, 10);
+ ret |= URL_INFO_RECORD;
+ }
+
+ return ret;
+}