void
ngx_md5_update(ngx_md5_t *ctx, const void *data, size_t size)
{
    size_t  used, free;
    used = (size_t) (ctx->bytes & 0x3f);
    ctx->bytes += size;
    if (used) {
        free = 64 - used;
        if (size < free) {
            ngx_memcpy(&ctx->buffer[used], data, size);
            return;
        }
        ngx_memcpy(&ctx->buffer[used], data, free);
        data = (u_char *) data + free;
        size -= free;
        (void) ngx_md5_body(ctx, ctx->buffer, 64);
    }
    if (size >= 64) {
        data = ngx_md5_body(ctx, data, size & ~(size_t) 0x3f);
        size &= 0x3f;
    }
    ngx_memcpy(ctx->buffer, data, size);
}
['void\nngx_http_file_cache_update_header(ngx_http_request_t *r)\n{\n    ssize_t                        n;\n    ngx_err_t                      err;\n    ngx_file_t                     file;\n    ngx_file_info_t                fi;\n    ngx_http_cache_t              *c;\n    ngx_http_file_cache_header_t   h;\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "http file cache update header");\n    c = r->cache;\n    ngx_memzero(&file, sizeof(ngx_file_t));\n    file.name = c->file.name;\n    file.log = r->connection->log;\n    file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR, NGX_FILE_OPEN, 0);\n    if (file.fd == NGX_INVALID_FILE) {\n        err = ngx_errno;\n        if (err == NGX_ENOENT) {\n            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                           "http file cache \\"%s\\" not found",\n                           file.name.data);\n            return;\n        }\n        ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,\n                      ngx_open_file_n " \\"%s\\" failed", file.name.data);\n        return;\n    }\n    if (ngx_fd_info(file.fd, &fi) == NGX_FILE_ERROR) {\n        ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,\n                      ngx_fd_info_n " \\"%s\\" failed", file.name.data);\n        goto done;\n    }\n    if (c->uniq != ngx_file_uniq(&fi)\n        || c->length != ngx_file_size(&fi))\n    {\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http file cache \\"%s\\" changed",\n                       file.name.data);\n        goto done;\n    }\n    n = ngx_read_file(&file, (u_char *) &h,\n                      sizeof(ngx_http_file_cache_header_t), 0);\n    if (n == NGX_ERROR) {\n        goto done;\n    }\n    if ((size_t) n != sizeof(ngx_http_file_cache_header_t)) {\n        ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,\n                      ngx_read_file_n " read only %z of %z from \\"%s\\"",\n                      n, sizeof(ngx_http_file_cache_header_t), file.name.data);\n        goto done;\n    }\n    if (h.version != NGX_HTTP_CACHE_VERSION\n        || h.last_modified != c->last_modified\n        || h.crc32 != c->crc32\n        || (size_t) h.header_start != c->header_start\n        || (size_t) h.body_start != c->body_start)\n    {\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http file cache \\"%s\\" content changed",\n                       file.name.data);\n        goto done;\n    }\n    ngx_memzero(&h, sizeof(ngx_http_file_cache_header_t));\n    h.version = NGX_HTTP_CACHE_VERSION;\n    h.valid_sec = c->valid_sec;\n    h.updating_sec = c->updating_sec;\n    h.error_sec = c->error_sec;\n    h.last_modified = c->last_modified;\n    h.date = c->date;\n    h.crc32 = c->crc32;\n    h.valid_msec = (u_short) c->valid_msec;\n    h.header_start = (u_short) c->header_start;\n    h.body_start = (u_short) c->body_start;\n    if (c->etag.len <= NGX_HTTP_CACHE_ETAG_LEN) {\n        h.etag_len = (u_char) c->etag.len;\n        ngx_memcpy(h.etag, c->etag.data, c->etag.len);\n    }\n    if (c->vary.len) {\n        if (c->vary.len > NGX_HTTP_CACHE_VARY_LEN) {\n            c->vary.len = NGX_HTTP_CACHE_VARY_LEN;\n        }\n        h.vary_len = (u_char) c->vary.len;\n        ngx_memcpy(h.vary, c->vary.data, c->vary.len);\n        ngx_http_file_cache_vary(r, c->vary.data, c->vary.len, c->variant);\n        ngx_memcpy(h.variant, c->variant, NGX_HTTP_CACHE_KEY_LEN);\n    }\n    (void) ngx_write_file(&file, (u_char *) &h,\n                          sizeof(ngx_http_file_cache_header_t), 0);\ndone:\n    if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {\n        ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,\n                      ngx_close_file_n " \\"%s\\" failed", file.name.data);\n    }\n}', 'static void\nngx_http_file_cache_vary(ngx_http_request_t *r, u_char *vary, size_t len,\n    u_char *hash)\n{\n    u_char     *p, *last;\n    ngx_str_t   name;\n    ngx_md5_t   md5;\n    u_char      buf[NGX_HTTP_CACHE_VARY_LEN];\n    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "http file cache vary: \\"%*s\\"", len, vary);\n    ngx_md5_init(&md5);\n    ngx_md5_update(&md5, r->cache->main, NGX_HTTP_CACHE_KEY_LEN);\n    ngx_strlow(buf, vary, len);\n    p = buf;\n    last = buf + len;\n    while (p < last) {\n        while (p < last && (*p == \' \' || *p == \',\')) { p++; }\n        name.data = p;\n        while (p < last && *p != \',\' && *p != \' \') { p++; }\n        name.len = p - name.data;\n        if (name.len == 0) {\n            break;\n        }\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http file cache vary: %V", &name);\n        ngx_md5_update(&md5, name.data, name.len);\n        ngx_md5_update(&md5, (u_char *) ":", sizeof(":") - 1);\n        ngx_http_file_cache_vary_header(r, &md5, &name);\n        ngx_md5_update(&md5, (u_char *) CRLF, sizeof(CRLF) - 1);\n    }\n    ngx_md5_final(hash, &md5);\n}', 'void\nngx_md5_update(ngx_md5_t *ctx, const void *data, size_t size)\n{\n    size_t  used, free;\n    used = (size_t) (ctx->bytes & 0x3f);\n    ctx->bytes += size;\n    if (used) {\n        free = 64 - used;\n        if (size < free) {\n            ngx_memcpy(&ctx->buffer[used], data, size);\n            return;\n        }\n        ngx_memcpy(&ctx->buffer[used], data, free);\n        data = (u_char *) data + free;\n        size -= free;\n        (void) ngx_md5_body(ctx, ctx->buffer, 64);\n    }\n    if (size >= 64) {\n        data = ngx_md5_body(ctx, data, size & ~(size_t) 0x3f);\n        size &= 0x3f;\n    }\n    ngx_memcpy(ctx->buffer, data, size);\n}']