From 091ef8e3a86b1e1f3231ed3376bc566d57d48ff2 Mon Sep 17 00:00:00 2001 From: Lammert Bies Date: Sun, 11 Dec 2016 01:24:29 +0100 Subject: [PATCH] Moved construct_etag to own file --- Makefile | 1 + src/httplib_construct_etag.c | 44 ++++++++++++++++++++++++++++++++++++ src/libhttp.c | 9 -------- 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 src/httplib_construct_etag.c diff --git a/Makefile b/Makefile index 57ffcef2..d7f2ab7d 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ LIB_SOURCES = src/libhttp.c \ src/httplib_close_socket_gracefully.c \ src/httplib_connect_client.c \ src/httplib_connect_websocket_client.c \ + src/httplib_construct_etag.c \ src/httplib_consume_socket.c \ src/httplib_delete_file.c \ src/httplib_download.c \ diff --git a/src/httplib_construct_etag.c b/src/httplib_construct_etag.c new file mode 100644 index 00000000..31a57420 --- /dev/null +++ b/src/httplib_construct_etag.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016 Lammert Bies + * Copyright (c) 2013-2016 the Civetweb developers + * Copyright (c) 2004-2013 Sergey Lyubka + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + + +#include "libhttp-private.h" + + + +/* + * void XX_httplib_construct_etag( char *buf, size_t buf_len, const struct file *filep ); + * + * The function XX_httplib_construct_etag() is used to construct an etag which + * can be used to identify a file on a specific moment. + */ + +void XX_httplib_construct_etag( char *buf, size_t buf_len, const struct file *filep ) { + + if (filep != NULL && buf != NULL) { + XX_httplib_snprintf(NULL, NULL, buf, buf_len, "\"%lx.%" INT64_FMT "\"", (unsigned long)filep->last_modified, filep->size); + } + +} /* XX_httplib_construct_etag */ diff --git a/src/libhttp.c b/src/libhttp.c index 6d9b2a83..b5611e11 100644 --- a/src/libhttp.c +++ b/src/libhttp.c @@ -4878,12 +4878,3 @@ int XX_httplib_parse_range_header( const char *header, int64_t *a, int64_t *b ) return sscanf(header, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b); } /* XX_httplib_parse_range_header */ - - -void XX_httplib_construct_etag( char *buf, size_t buf_len, const struct file *filep ) { - - if (filep != NULL && buf != NULL) { - XX_httplib_snprintf(NULL, NULL, buf, buf_len, "\"%lx.%" INT64_FMT "\"", (unsigned long)filep->last_modified, filep->size); - } - -} /* XX_httplib_construct_etag */