summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/deps/brotli/tools
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:44 +0000
commit836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch)
tree1604da8f482d02effa033c94a84be42bc0c848c3 /web/server/h2o/libh2o/deps/brotli/tools
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz
netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/brotli/tools')
-rw-r--r--web/server/h2o/libh2o/deps/brotli/tools/Makefile25
-rw-r--r--web/server/h2o/libh2o/deps/brotli/tools/bro.cc303
-rwxr-xr-xweb/server/h2o/libh2o/deps/brotli/tools/rfc-format.py92
-rw-r--r--web/server/h2o/libh2o/deps/brotli/tools/version.h14
4 files changed, 0 insertions, 434 deletions
diff --git a/web/server/h2o/libh2o/deps/brotli/tools/Makefile b/web/server/h2o/libh2o/deps/brotli/tools/Makefile
deleted file mode 100644
index 6b46ad880..000000000
--- a/web/server/h2o/libh2o/deps/brotli/tools/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-#brotli/tools
-
-include ../shared.mk
-
-BROTLI = ..
-ENCOBJ = $(BROTLI)/enc/*.o
-DECOBJ = $(BROTLI)/dec/*.o
-
-EXECUTABLES=bro
-
-EXE_OBJS=$(patsubst %, %.o, $(EXECUTABLES))
-
-all : $(EXECUTABLES)
-
-$(EXECUTABLES) : $(EXE_OBJS) deps
- $(CXX) $(LDFLAGS) $(ENCOBJ) $(DECOBJ) $@.o -o $@
-
-deps :
- $(MAKE) -C $(BROTLI)/dec
- $(MAKE) -C $(BROTLI)/enc nodict
-
-clean :
- rm -f $(OBJS) $(EXE_OBJS) $(EXECUTABLES)
- $(MAKE) -C $(BROTLI)/dec clean
- $(MAKE) -C $(BROTLI)/enc clean
diff --git a/web/server/h2o/libh2o/deps/brotli/tools/bro.cc b/web/server/h2o/libh2o/deps/brotli/tools/bro.cc
deleted file mode 100644
index 635751c80..000000000
--- a/web/server/h2o/libh2o/deps/brotli/tools/bro.cc
+++ /dev/null
@@ -1,303 +0,0 @@
-/* Copyright 2014 Google Inc. All Rights Reserved.
-
- Distributed under MIT license.
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
-*/
-
-/* Example main() function for Brotli library. */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <ctime>
-#include <string>
-
-#include "../dec/decode.h"
-#include "../enc/encode.h"
-
-
-static bool ParseQuality(const char* s, int* quality) {
- if (s[0] >= '0' && s[0] <= '9') {
- *quality = s[0] - '0';
- if (s[1] >= '0' && s[1] <= '9') {
- *quality = *quality * 10 + s[1] - '0';
- return s[2] == 0;
- }
- return s[1] == 0;
- }
- return false;
-}
-
-static void ParseArgv(int argc, char **argv,
- char **input_path,
- char **output_path,
- int *force,
- int *quality,
- int *decompress,
- int *repeat,
- int *verbose,
- int *lgwin) {
- *force = 0;
- *input_path = 0;
- *output_path = 0;
- *repeat = 1;
- *verbose = 0;
- *lgwin = 22;
- {
- size_t argv0_len = strlen(argv[0]);
- *decompress =
- argv0_len >= 5 && strcmp(&argv[0][argv0_len - 5], "unbro") == 0;
- }
- for (int k = 1; k < argc; ++k) {
- if (!strcmp("--force", argv[k]) ||
- !strcmp("-f", argv[k])) {
- if (*force != 0) {
- goto error;
- }
- *force = 1;
- continue;
- } else if (!strcmp("--decompress", argv[k]) ||
- !strcmp("--uncompress", argv[k]) ||
- !strcmp("-d", argv[k])) {
- *decompress = 1;
- continue;
- } else if (!strcmp("--verbose", argv[k]) ||
- !strcmp("-v", argv[k])) {
- if (*verbose != 0) {
- goto error;
- }
- *verbose = 1;
- continue;
- }
- if (k < argc - 1) {
- if (!strcmp("--input", argv[k]) ||
- !strcmp("--in", argv[k]) ||
- !strcmp("-i", argv[k])) {
- if (*input_path != 0) {
- goto error;
- }
- *input_path = argv[k + 1];
- ++k;
- continue;
- } else if (!strcmp("--output", argv[k]) ||
- !strcmp("--out", argv[k]) ||
- !strcmp("-o", argv[k])) {
- if (*output_path != 0) {
- goto error;
- }
- *output_path = argv[k + 1];
- ++k;
- continue;
- } else if (!strcmp("--quality", argv[k]) ||
- !strcmp("-q", argv[k])) {
- if (!ParseQuality(argv[k + 1], quality)) {
- goto error;
- }
- ++k;
- continue;
- } else if (!strcmp("--repeat", argv[k]) ||
- !strcmp("-r", argv[k])) {
- if (!ParseQuality(argv[k + 1], repeat)) {
- goto error;
- }
- ++k;
- continue;
- } else if (!strcmp("--window", argv[k]) ||
- !strcmp("-w", argv[k])) {
- if (!ParseQuality(argv[k + 1], lgwin)) {
- goto error;
- }
- if (*lgwin < 10 || *lgwin >= 25) {
- goto error;
- }
- ++k;
- continue;
- }
- }
- goto error;
- }
- return;
-error:
- fprintf(stderr,
- "Usage: %s [--force] [--quality n] [--decompress]"
- " [--input filename] [--output filename] [--repeat iters]"
- " [--verbose] [--window n]\n",
- argv[0]);
- exit(1);
-}
-
-static FILE* OpenInputFile(const char* input_path) {
- if (input_path == 0) {
- return fdopen(STDIN_FILENO, "rb");
- }
- FILE* f = fopen(input_path, "rb");
- if (f == 0) {
- perror("fopen");
- exit(1);
- }
- return f;
-}
-
-static FILE *OpenOutputFile(const char *output_path, const int force) {
- if (output_path == 0) {
- return fdopen(STDOUT_FILENO, "wb");
- }
- int excl = force ? 0 : O_EXCL;
-#if defined(_WIN32)
- int fd = open(output_path, O_CREAT | excl | O_WRONLY | O_TRUNC | O_BINARY,
- S_IREAD | S_IWRITE);
-#else
- int fd = open(output_path, O_CREAT | excl | O_WRONLY | O_TRUNC,
- S_IRUSR | S_IWUSR);
-#endif
- if (fd < 0) {
- if (!force) {
- struct stat statbuf;
- if (stat(output_path, &statbuf) == 0) {
- fprintf(stderr, "output file exists\n");
- exit(1);
- }
- }
- perror("open");
- exit(1);
- }
- return fdopen(fd, "wb");
-}
-
-int64_t FileSize(char *path) {
- FILE *f = fopen(path, "rb");
- if (f == NULL) {
- return -1;
- }
- if (fseek(f, 0L, SEEK_END) != 0) {
- fclose(f);
- return -1;
- }
- int64_t retval = ftell(f);
- if (fclose(f) != 0) {
- return -1;
- }
- return retval;
-}
-
-static const size_t kFileBufferSize = 65536;
-
-void Decompresss(FILE* fin, FILE* fout) {
- uint8_t* input = new uint8_t[kFileBufferSize];
- uint8_t* output = new uint8_t[kFileBufferSize];
- size_t total_out;
- size_t available_in;
- const uint8_t* next_in;
- size_t available_out = kFileBufferSize;
- uint8_t* next_out = output;
- BrotliResult result = BROTLI_RESULT_NEEDS_MORE_INPUT;
- BrotliState s;
- BrotliStateInit(&s);
- while (1) {
- if (result == BROTLI_RESULT_NEEDS_MORE_INPUT) {
- if (feof(fin)) {
- break;
- }
- available_in = fread(input, 1, kFileBufferSize, fin);
- next_in = input;
- if (ferror(fin)) {
- break;
- }
- } else if (result == BROTLI_RESULT_NEEDS_MORE_OUTPUT) {
- fwrite(output, 1, kFileBufferSize, fout);
- if (ferror(fout)) {
- break;
- }
- available_out = kFileBufferSize;
- next_out = output;
- } else {
- break; /* Error or success. */
- }
- result = BrotliDecompressStream(&available_in, &next_in,
- &available_out, &next_out, &total_out, &s);
- }
- if (next_out != output) {
- fwrite(output, 1, next_out - output, fout);
- }
- BrotliStateCleanup(&s);
- delete[] input;
- delete[] output;
- if ((result == BROTLI_RESULT_NEEDS_MORE_OUTPUT) || ferror(fout)) {
- fprintf(stderr, "failed to write output\n");
- exit(1);
- } else if (result != BROTLI_RESULT_SUCCESS) { /* Error or needs more input. */
- fprintf(stderr, "corrupt input\n");
- exit(1);
- }
-}
-
-int main(int argc, char** argv) {
- char *input_path = 0;
- char *output_path = 0;
- int force = 0;
- int quality = 11;
- int decompress = 0;
- int repeat = 1;
- int verbose = 0;
- int lgwin = 0;
- ParseArgv(argc, argv, &input_path, &output_path, &force,
- &quality, &decompress, &repeat, &verbose, &lgwin);
- const clock_t clock_start = clock();
- for (int i = 0; i < repeat; ++i) {
- FILE* fin = OpenInputFile(input_path);
- FILE* fout = OpenOutputFile(output_path, force);
- if (decompress) {
- Decompresss(fin, fout);
- } else {
- brotli::BrotliParams params;
- params.lgwin = lgwin;
- params.quality = quality;
- try {
- brotli::BrotliFileIn in(fin, 1 << 16);
- brotli::BrotliFileOut out(fout);
- if (!BrotliCompress(params, &in, &out)) {
- fprintf(stderr, "compression failed\n");
- unlink(output_path);
- exit(1);
- }
- } catch (std::bad_alloc&) {
- fprintf(stderr, "not enough memory\n");
- unlink(output_path);
- exit(1);
- }
- }
- if (fclose(fin) != 0) {
- perror("fclose");
- exit(1);
- }
- if (fclose(fout) != 0) {
- perror("fclose");
- exit(1);
- }
- }
- if (verbose) {
- const clock_t clock_end = clock();
- double duration =
- static_cast<double>(clock_end - clock_start) / CLOCKS_PER_SEC;
- if (duration < 1e-9) {
- duration = 1e-9;
- }
- int64_t uncompressed_size = FileSize(decompress ? output_path : input_path);
- if (uncompressed_size == -1) {
- fprintf(stderr, "failed to determine uncompressed file size\n");
- exit(1);
- }
- double uncompressed_bytes_in_MB =
- (repeat * uncompressed_size) / (1024.0 * 1024.0);
- if (decompress) {
- printf("Brotli decompression speed: ");
- } else {
- printf("Brotli compression speed: ");
- }
- printf("%g MB/s\n", uncompressed_bytes_in_MB / duration);
- }
- return 0;
-}
diff --git a/web/server/h2o/libh2o/deps/brotli/tools/rfc-format.py b/web/server/h2o/libh2o/deps/brotli/tools/rfc-format.py
deleted file mode 100755
index 61696a0cd..000000000
--- a/web/server/h2o/libh2o/deps/brotli/tools/rfc-format.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-#
-# Takes an .nroff source file and prints a text file in RFC format.
-#
-# Usage: rfc-format.py <source file>
-
-import re
-import sys
-from subprocess import Popen, PIPE
-
-
-def Readfile(fn):
- f = open(fn, "r")
- return f.read()
-
-
-def FixNroffOutput(buf):
- p = re.compile(r'(.*)FORMFEED(\[Page\s+\d+\])$')
- strip_empty = False
- out = ""
- for line in buf.split("\n"):
- line = line.replace("\xe2\x80\x99", "'")
- line = line.replace("\xe2\x80\x90", "-")
- for i in range(len(line)):
- if ord(line[i]) > 128:
- print >>sys.stderr, "Invalid character %d\n" % ord(line[i])
- m = p.search(line)
- if strip_empty and len(line) == 0:
- continue
- if m:
- out += p.sub(r'\1 \2\n\f', line)
- out += "\n"
- strip_empty = True
- else:
- out += "%s\n" % line
- strip_empty = False
- return out.rstrip("\n")
-
-
-def Nroff(buf):
- p = Popen(["nroff", "-ms"], stdin=PIPE, stdout=PIPE)
- out, err = p.communicate(input=buf)
- return FixNroffOutput(out)
-
-
-def FormatTocLine(section, title, page):
- line = ""
- level = 1
- if section:
- level = section.count(".")
- for i in range(level):
- line += " "
- if section:
- line += "%s " % section
- line += "%s " % title
- pagenum = "%d" % page
- nspace = 72 - len(line) - len(pagenum)
- if nspace % 2:
- line += " "
- for i in range(nspace / 2):
- line += ". "
- line += "%d\n" % page
- return line
-
-
-def CreateToc(buf):
- p1 = re.compile(r'^((\d+\.)+)\s+(.*)$')
- p2 = re.compile(r'^(Appendix [A-Z].)\s+(.*)$')
- p3 = re.compile(r'\[Page (\d+)\]$')
- found = 0
- page = 1
- out = ""
- for line in buf.split("\n"):
- m1 = p1.search(line)
- m2 = p2.search(line)
- m3 = p3.search(line)
- if m1:
- out += FormatTocLine(m1.group(1), m1.group(3), page)
- elif m2:
- out += FormatTocLine(m2.group(1), m2.group(2), page)
- elif line.startswith("Authors"):
- out += FormatTocLine(None, line, page)
- elif m3:
- page = int(m3.group(1)) + 1
- return out
-
-
-src = Readfile(sys.argv[1])
-out = Nroff(src)
-toc = CreateToc(out)
-src = src.replace("INSERT_TOC_HERE", toc)
-print Nroff(src)
diff --git a/web/server/h2o/libh2o/deps/brotli/tools/version.h b/web/server/h2o/libh2o/deps/brotli/tools/version.h
deleted file mode 100644
index 6125a73e9..000000000
--- a/web/server/h2o/libh2o/deps/brotli/tools/version.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright 2015 Google Inc. All Rights Reserved.
-
- Distributed under MIT license.
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
-*/
-
-/* Defines a common version string used by all of the brotli tools. */
-
-#ifndef BROTLI_TOOLS_VERSION_H_
-#define BROTLI_TOOLS_VERSION_H_
-
-#define BROTLI_VERSION "0.3.0"
-
-#endif /* BROTLI_TOOLS_VERSION_H_ */