Full Code of kovidgoyal/kitty for AI

master c57305addc2a cached
951 files
13.6 MB
3.6M tokens
1 requests
Copy disabled (too large) Download .txt
Showing preview only (14,394K chars total). Download the full file to get everything.
Repository: kovidgoyal/kitty
Branch: master
Commit: c57305addc2a
Files: 951
Total size: 13.6 MB

Directory structure:
gitextract_7m1o6j63/

├── .editorconfig
├── .gitattributes
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   ├── copilot-instructions.md
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.py
│       ├── ci.yml
│       ├── codeql-analysis.yml
│       ├── depscan.yml
│       └── macos_crash_report.py
├── .gitignore
├── 3rdparty/
│   ├── base64/
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── config.h
│   │   ├── include/
│   │   │   └── libbase64.h
│   │   └── lib/
│   │       ├── arch/
│   │       │   ├── avx/
│   │       │   │   ├── codec.c
│   │       │   │   └── enc_loop_asm.c
│   │       │   ├── avx2/
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_loop.c
│   │       │   │   ├── dec_reshuffle.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   ├── enc_loop_asm.c
│   │       │   │   ├── enc_reshuffle.c
│   │       │   │   └── enc_translate.c
│   │       │   ├── avx512/
│   │       │   │   ├── codec.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   └── enc_reshuffle_translate.c
│   │       │   ├── generic/
│   │       │   │   ├── 32/
│   │       │   │   │   ├── dec_loop.c
│   │       │   │   │   └── enc_loop.c
│   │       │   │   ├── 64/
│   │       │   │   │   └── enc_loop.c
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_head.c
│   │       │   │   ├── dec_tail.c
│   │       │   │   ├── enc_head.c
│   │       │   │   └── enc_tail.c
│   │       │   ├── neon32/
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_loop.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   ├── enc_reshuffle.c
│   │       │   │   └── enc_translate.c
│   │       │   ├── neon64/
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_loop.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   ├── enc_loop_asm.c
│   │       │   │   └── enc_reshuffle.c
│   │       │   ├── sse41/
│   │       │   │   └── codec.c
│   │       │   ├── sse42/
│   │       │   │   └── codec.c
│   │       │   └── ssse3/
│   │       │       ├── codec.c
│   │       │       ├── dec_loop.c
│   │       │       ├── dec_reshuffle.c
│   │       │       ├── enc_loop.c
│   │       │       ├── enc_loop_asm.c
│   │       │       ├── enc_reshuffle.c
│   │       │       └── enc_translate.c
│   │       ├── codec_choose.c
│   │       ├── codecs.h
│   │       ├── env.h
│   │       ├── exports.txt
│   │       ├── lib.c
│   │       ├── lib_openmp.c
│   │       └── tables/
│   │           ├── .gitignore
│   │           ├── Makefile
│   │           ├── table_dec_32bit.h
│   │           ├── table_enc_12bit.h
│   │           ├── table_enc_12bit.py
│   │           ├── table_generator.c
│   │           ├── tables.c
│   │           └── tables.h
│   ├── ringbuf/
│   │   ├── ringbuf.c
│   │   └── ringbuf.h
│   └── verstable.h
├── Brewfile
├── CHANGELOG.rst
├── CONTRIBUTING.md
├── INSTALL.md
├── LICENSE
├── Makefile
├── README.asciidoc
├── SECURITY.md
├── __main__.py
├── benchmark.py
├── build-terminfo
├── bypy/
│   ├── devenv.go
│   ├── init_env.py
│   ├── linux/
│   │   └── __main__.py
│   ├── linux.conf
│   ├── macos/
│   │   └── __main__.py
│   ├── macos.conf
│   ├── rsync.conf
│   ├── site.py
│   └── sources.json
├── count-lines-of-code
├── dev.sh
├── docs/
│   ├── Makefile
│   ├── _static/
│   │   ├── custom.css
│   │   ├── custom.js
│   │   ├── timestamps.css
│   │   └── timestamps.js
│   ├── _templates/
│   │   └── base.html
│   ├── actions.rst
│   ├── basic.rst
│   ├── binary.rst
│   ├── build.rst
│   ├── changelog.rst
│   ├── clipboard.rst
│   ├── color-stack.rst
│   ├── conf.py
│   ├── conf.rst
│   ├── deccara.rst
│   ├── desktop-notifications.rst
│   ├── extract-rst-targets.py
│   ├── faq.rst
│   ├── file-transfer-protocol.rst
│   ├── glossary.rst
│   ├── graphics-protocol.rst
│   ├── index.rst
│   ├── installer.sh
│   ├── integrations.rst
│   ├── intro_vid.rst
│   ├── invocation.rst
│   ├── keyboard-protocol.rst
│   ├── kittens/
│   │   ├── broadcast.rst
│   │   ├── choose-files.rst
│   │   ├── choose-fonts.rst
│   │   ├── clipboard.rst
│   │   ├── custom.rst
│   │   ├── desktop-ui.rst
│   │   ├── developing-builtin-kittens.rst
│   │   ├── diff.rst
│   │   ├── hints.rst
│   │   ├── hyperlinked_grep.rst
│   │   ├── icat.rst
│   │   ├── notify.rst
│   │   ├── panel.rst
│   │   ├── query_terminal.rst
│   │   ├── quick-access-terminal.rst
│   │   ├── remote_file.rst
│   │   ├── ssh.rst
│   │   ├── themes.rst
│   │   ├── transfer.rst
│   │   └── unicode_input.rst
│   ├── kittens_intro.rst
│   ├── launch.rst
│   ├── layouts.rst
│   ├── mapping.rst
│   ├── marks.rst
│   ├── misc-protocol.rst
│   ├── multiple-cursors-protocol.rst
│   ├── notifications.py
│   ├── open_actions.rst
│   ├── overview.rst
│   ├── performance.rst
│   ├── pipe.rst
│   ├── pointer-shapes.rst
│   ├── press-mentions.rst
│   ├── protocol-extensions.rst
│   ├── quake-screenshots.rst
│   ├── quickstart.rst
│   ├── rc_protocol.rst
│   ├── remote-control.rst
│   ├── requirements.txt
│   ├── sessions.rst
│   ├── shell-integration.rst
│   ├── support.html
│   ├── support.rst
│   ├── text-sizing-protocol.rst
│   ├── underlines.rst
│   ├── unscroll.rst
│   └── wide-gamut-colors.rst
├── embeds.go
├── gen/
│   ├── README.rst
│   ├── __init__.py
│   ├── __main__.py
│   ├── apc_parsers.py
│   ├── bitfields.py
│   ├── color_names.py
│   ├── config.py
│   ├── cursors.py
│   ├── go_code.py
│   ├── key_constants.py
│   ├── rowcolumn-diacritics.txt
│   ├── srgb_lut.py
│   └── wcwidth.py
├── glad/
│   └── generate.py
├── glfw/
│   ├── __init__.py
│   ├── backend_utils.c
│   ├── backend_utils.h
│   ├── cocoa_displaylink.m
│   ├── cocoa_init.m
│   ├── cocoa_joystick.h
│   ├── cocoa_joystick.m
│   ├── cocoa_monitor.m
│   ├── cocoa_platform.h
│   ├── cocoa_window.m
│   ├── context.c
│   ├── dbus_glfw.c
│   ├── dbus_glfw.h
│   ├── egl_context.c
│   ├── egl_context.h
│   ├── glfw.py
│   ├── glfw3.h
│   ├── glx_context.c
│   ├── glx_context.h
│   ├── ibus_glfw.c
│   ├── ibus_glfw.h
│   ├── init.c
│   ├── input.c
│   ├── internal.h
│   ├── kwin-blur-v1.xml
│   ├── linux_desktop_settings.c
│   ├── linux_desktop_settings.h
│   ├── linux_joystick.c
│   ├── linux_joystick.h
│   ├── linux_notify.c
│   ├── linux_notify.h
│   ├── main_loop.h
│   ├── mappings.h
│   ├── memfd.h
│   ├── momentum-scroll.c
│   ├── monitor.c
│   ├── monotonic.c
│   ├── nsgl_context.h
│   ├── nsgl_context.m
│   ├── null_init.c
│   ├── null_joystick.c
│   ├── null_joystick.h
│   ├── null_monitor.c
│   ├── null_platform.h
│   ├── null_window.c
│   ├── osmesa_context.c
│   ├── osmesa_context.h
│   ├── posix_thread.c
│   ├── posix_thread.h
│   ├── source-info.json
│   ├── vulkan.c
│   ├── window.c
│   ├── wl_client_side_decorations.c
│   ├── wl_client_side_decorations.h
│   ├── wl_cursors.c
│   ├── wl_cursors.h
│   ├── wl_init.c
│   ├── wl_monitor.c
│   ├── wl_platform.h
│   ├── wl_text_input.c
│   ├── wl_text_input.h
│   ├── wl_window.c
│   ├── wlr-layer-shell-unstable-v1.xml
│   ├── x11_init.c
│   ├── x11_monitor.c
│   ├── x11_platform.h
│   ├── x11_window.c
│   ├── xkb-compat-shim.h
│   ├── xkb_glfw.c
│   └── xkb_glfw.h
├── go.mod
├── go.sum
├── key_encoding.json
├── kittens/
│   ├── __init__.py
│   ├── ask/
│   │   ├── __init__.py
│   │   ├── choices.go
│   │   ├── get_line.go
│   │   ├── main.go
│   │   └── main.py
│   ├── broadcast/
│   │   ├── __init__.py
│   │   └── main.py
│   ├── choose_files/
│   │   ├── __init__.py
│   │   ├── archive.go
│   │   ├── calibre.go
│   │   ├── cmd_preview.go
│   │   ├── collection.go
│   │   ├── ffmpeg.go
│   │   ├── filters.go
│   │   ├── footer.go
│   │   ├── graphics.go
│   │   ├── image_preview.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── preview.go
│   │   ├── results.go
│   │   ├── results_test.go
│   │   ├── save-file.go
│   │   ├── scan.go
│   │   ├── scan_test.go
│   │   └── search-bar.go
│   ├── choose_fonts/
│   │   ├── __init__.py
│   │   ├── backend.go
│   │   ├── backend.py
│   │   ├── face.go
│   │   ├── faces.go
│   │   ├── family_list.go
│   │   ├── final.go
│   │   ├── graphics.go
│   │   ├── index_feature.go
│   │   ├── list.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── styles.go
│   │   ├── types.go
│   │   └── ui.go
│   ├── clipboard/
│   │   ├── __init__.py
│   │   ├── legacy.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── read.go
│   │   └── write.go
│   ├── command_palette/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   └── main_test.go
│   ├── desktop_ui/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   └── portal.go
│   ├── diff/
│   │   ├── __init__.py
│   │   ├── collect.go
│   │   ├── collect_test.go
│   │   ├── diff.go
│   │   ├── highlight.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── mouse.go
│   │   ├── patch.go
│   │   ├── patch_test.go
│   │   ├── render.go
│   │   ├── search.go
│   │   └── ui.go
│   ├── hints/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── marks.go
│   │   └── marks_test.go
│   ├── hyperlinked_grep/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   └── main_test.go
│   ├── icat/
│   │   ├── __init__.py
│   │   ├── detect.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── process_images.go
│   │   ├── scaling_test.go
│   │   └── transmit.go
│   ├── notify/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── pager/
│   │   ├── __init__.py
│   │   ├── file_input.go
│   │   ├── main.go
│   │   └── main.py
│   ├── panel/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── query_terminal/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── quick_access_terminal/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── remote_file/
│   │   ├── __init__.py
│   │   └── main.py
│   ├── resize_window/
│   │   ├── __init__.py
│   │   └── main.py
│   ├── runner.py
│   ├── show_key/
│   │   ├── __init__.py
│   │   ├── kitty.go
│   │   ├── legacy.go
│   │   ├── main.go
│   │   └── main.py
│   ├── ssh/
│   │   ├── __init__.py
│   │   ├── askpass.go
│   │   ├── config.go
│   │   ├── config_test.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── main_test.go
│   │   ├── utils.go
│   │   ├── utils.py
│   │   └── utils_test.go
│   ├── themes/
│   │   ├── __init__.py
│   │   ├── list.go
│   │   ├── main.go
│   │   ├── main.py
│   │   └── ui.go
│   ├── transfer/
│   │   ├── __init__.py
│   │   ├── algorithm.c
│   │   ├── ftc.go
│   │   ├── ftc_test.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── receive.go
│   │   ├── rsync.pyi
│   │   ├── send.go
│   │   ├── send_test.go
│   │   ├── utils.go
│   │   └── utils.py
│   ├── tui/
│   │   ├── __init__.py
│   │   ├── dircolors.py
│   │   ├── handler.py
│   │   ├── images.py
│   │   ├── line_edit.py
│   │   ├── loop.py
│   │   ├── operations.py
│   │   ├── operations_stub.py
│   │   ├── path_completer.py
│   │   ├── progress.py
│   │   ├── spinners.py
│   │   └── utils.py
│   └── unicode_input/
│       ├── __init__.py
│       ├── main.go
│       ├── main.py
│       └── table.go
├── kitty/
│   ├── __init__.py
│   ├── actions.py
│   ├── alpha_blend.glsl
│   ├── animation.c
│   ├── animation.h
│   ├── arches.h
│   ├── arena.h
│   ├── backtrace.h
│   ├── banned.h
│   ├── base64.h
│   ├── bash.py
│   ├── bgimage_fragment.glsl
│   ├── bgimage_vertex.glsl
│   ├── binary.h
│   ├── blit_common.glsl
│   ├── blit_fragment.glsl
│   ├── blit_vertex.glsl
│   ├── border_fragment.glsl
│   ├── border_vertex.glsl
│   ├── borders.py
│   ├── boss.py
│   ├── cell_defines.glsl
│   ├── cell_fragment.glsl
│   ├── cell_vertex.glsl
│   ├── char-props-data.h
│   ├── char-props.c
│   ├── char-props.h
│   ├── charsets.c
│   ├── charsets.h
│   ├── child-monitor.c
│   ├── child.c
│   ├── child.py
│   ├── choose_entry.py
│   ├── cleanup.c
│   ├── cleanup.h
│   ├── cli.py
│   ├── cli_stub.py
│   ├── client.py
│   ├── clipboard.py
│   ├── cocoa_window.h
│   ├── cocoa_window.m
│   ├── color-names.h
│   ├── colors.c
│   ├── colors.h
│   ├── colors.py
│   ├── conf/
│   │   ├── __init__.py
│   │   ├── generate.py
│   │   ├── types.py
│   │   └── utils.py
│   ├── config.py
│   ├── constants.py
│   ├── control-codes.h
│   ├── core_text.m
│   ├── cross-platform-random.h
│   ├── crypto.c
│   ├── cursor.c
│   ├── cursor_trail.c
│   ├── data-types.c
│   ├── data-types.h
│   ├── debug_config.py
│   ├── decorations.c
│   ├── decorations.h
│   ├── desktop.c
│   ├── disk-cache.c
│   ├── disk-cache.h
│   ├── entry_points.py
│   ├── fast-file-copy.c
│   ├── fast-file-copy.h
│   ├── fast_data_types.pyi
│   ├── file_transmission.py
│   ├── fixed_size_deque.h
│   ├── font-names.c
│   ├── fontconfig.c
│   ├── fonts/
│   │   ├── __init__.py
│   │   ├── common.py
│   │   ├── core_text.py
│   │   ├── features.py
│   │   ├── fontconfig.py
│   │   ├── list.py
│   │   └── render.py
│   ├── fonts.c
│   ├── fonts.h
│   ├── freetype.c
│   ├── freetype_render_ui_text.c
│   ├── freetype_render_ui_text.h
│   ├── gl-wrapper.c
│   ├── gl-wrapper.h
│   ├── gl.c
│   ├── gl.h
│   ├── glfw-wrapper.c
│   ├── glfw-wrapper.h
│   ├── glfw.c
│   ├── glyph-cache.c
│   ├── glyph-cache.h
│   ├── graphics.c
│   ├── graphics.h
│   ├── graphics_fragment.glsl
│   ├── graphics_vertex.glsl
│   ├── guess_mime_type.py
│   ├── history.c
│   ├── history.h
│   ├── hsluv.glsl
│   ├── hyperlink.c
│   ├── hyperlink.h
│   ├── iqsort.h
│   ├── key_encoding.c
│   ├── key_encoding.py
│   ├── key_names.py
│   ├── keys.c
│   ├── keys.h
│   ├── keys.py
│   ├── kittens.c
│   ├── kitty-verstable.h
│   ├── launch.py
│   ├── launcher/
│   │   ├── cli-parser.h
│   │   ├── cmdline.c
│   │   ├── launcher.h
│   │   ├── main.c
│   │   ├── shlex.h
│   │   ├── single-instance.c
│   │   └── utils.h
│   ├── layout/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── grid.py
│   │   ├── interface.py
│   │   ├── splits.py
│   │   ├── stack.py
│   │   ├── tall.py
│   │   └── vertical.py
│   ├── line-buf.c
│   ├── line-buf.h
│   ├── line.c
│   ├── line.h
│   ├── linear2srgb.glsl
│   ├── lineops.h
│   ├── logging.c
│   ├── loop-utils.c
│   ├── loop-utils.h
│   ├── macos_process_info.c
│   ├── main.py
│   ├── marks.py
│   ├── modes.h
│   ├── monotonic.c
│   ├── monotonic.h
│   ├── mouse.c
│   ├── multiprocessing.py
│   ├── notifications.py
│   ├── open_actions.py
│   ├── options/
│   │   ├── __init__.py
│   │   ├── definition.py
│   │   ├── parse.py
│   │   ├── to-c-generated.h
│   │   ├── to-c.h
│   │   ├── types.py
│   │   └── utils.py
│   ├── os_window_size.py
│   ├── parse-graphics-command.h
│   ├── parse-multicell-command.h
│   ├── png-reader.c
│   ├── png-reader.h
│   ├── print-graphics.h
│   ├── progress.py
│   ├── rc/
│   │   ├── __init__.py
│   │   ├── action.py
│   │   ├── base.py
│   │   ├── close_tab.py
│   │   ├── close_window.py
│   │   ├── create_marker.py
│   │   ├── detach_tab.py
│   │   ├── detach_window.py
│   │   ├── disable_ligatures.py
│   │   ├── env.py
│   │   ├── focus_tab.py
│   │   ├── focus_window.py
│   │   ├── get_colors.py
│   │   ├── get_text.py
│   │   ├── goto_layout.py
│   │   ├── kitten.py
│   │   ├── last_used_layout.py
│   │   ├── launch.py
│   │   ├── load_config.py
│   │   ├── ls.py
│   │   ├── new_window.py
│   │   ├── remove_marker.py
│   │   ├── resize_os_window.py
│   │   ├── resize_window.py
│   │   ├── run.py
│   │   ├── scroll_window.py
│   │   ├── select_window.py
│   │   ├── send_key.py
│   │   ├── send_text.py
│   │   ├── set_background_image.py
│   │   ├── set_background_opacity.py
│   │   ├── set_colors.py
│   │   ├── set_enabled_layouts.py
│   │   ├── set_font_size.py
│   │   ├── set_spacing.py
│   │   ├── set_tab_color.py
│   │   ├── set_tab_title.py
│   │   ├── set_user_vars.py
│   │   ├── set_window_logo.py
│   │   ├── set_window_title.py
│   │   └── signal_child.py
│   ├── remote_control.py
│   ├── render_cache.py
│   ├── resize.c
│   ├── resize.h
│   ├── rgb.py
│   ├── rounded_rect_fragment.glsl
│   ├── rounded_rect_vertex.glsl
│   ├── rowcolumn-diacritics.c
│   ├── safe-wrappers.h
│   ├── screen.c
│   ├── screen.h
│   ├── screenshot_fragment.glsl
│   ├── screenshot_vertex.glsl
│   ├── search_query_parser.py
│   ├── session.py
│   ├── shaders.c
│   ├── shaders.py
│   ├── shell_integration.py
│   ├── shlex.c
│   ├── shm.py
│   ├── short_uuid.py
│   ├── simd-string-128.c
│   ├── simd-string-256.c
│   ├── simd-string-impl.h
│   ├── simd-string.c
│   ├── simd-string.h
│   ├── simple_cli_definitions.py
│   ├── srgb_gamma.h
│   ├── state.c
│   ├── state.h
│   ├── systemd.c
│   ├── tab_bar.py
│   ├── tabs.py
│   ├── terminfo.h
│   ├── terminfo.py
│   ├── text-cache.c
│   ├── text-cache.h
│   ├── threading.h
│   ├── tint_fragment.glsl
│   ├── tint_vertex.glsl
│   ├── trail_fragment.glsl
│   ├── trail_vertex.glsl
│   ├── types.py
│   ├── typing_compat.py
│   ├── typing_compat.pyi
│   ├── unicode-data.h
│   ├── update_check.py
│   ├── utils.glsl
│   ├── utils.py
│   ├── utmp.c
│   ├── vt-parser.c
│   ├── vt-parser.h
│   ├── wcswidth.c
│   ├── wcswidth.h
│   ├── window.py
│   ├── window_list.py
│   ├── window_logo.c
│   ├── window_logo.h
│   ├── window_title_bar.py
│   └── xdg.py
├── kitty_tests/
│   ├── CascadiaCode-Regular.otf
│   ├── FiraCode-Medium.otf
│   ├── GraphemeBreakTest.json
│   ├── __init__.py
│   ├── atexit.py
│   ├── check_build.py
│   ├── clipboard.py
│   ├── command_palette.py
│   ├── completion.py
│   ├── crypto.py
│   ├── datatypes.py
│   ├── file_transmission.py
│   ├── fonts.py
│   ├── glfw.py
│   ├── gr.py
│   ├── graphics.py
│   ├── keys.py
│   ├── layout.py
│   ├── main.py
│   ├── mouse.py
│   ├── multicell.py
│   ├── notifications.py
│   ├── open_actions.py
│   ├── options.py
│   ├── panels.py
│   ├── parser.py
│   ├── screen.py
│   ├── search_query_parser.py
│   ├── shell_integration.py
│   ├── shm.py
│   ├── ssh.py
│   ├── tui.py
│   ├── twemoji_smiley-cff2_colr_1.otf
│   └── utmp.py
├── logo/
│   ├── attribution.txt
│   └── make.py
├── publish.py
├── pyproject.toml
├── rsync-and-build.sh
├── session.vim
├── setup.py
├── shell-integration/
│   ├── bash/
│   │   └── kitty.bash
│   ├── fish/
│   │   ├── vendor_completions.d/
│   │   │   ├── clone-in-kitty.fish
│   │   │   ├── kitten.fish
│   │   │   └── kitty.fish
│   │   └── vendor_conf.d/
│   │       └── kitty-shell-integration.fish
│   ├── ssh/
│   │   ├── bootstrap-utils.sh
│   │   ├── bootstrap.py
│   │   ├── bootstrap.sh
│   │   ├── kitten
│   │   └── kitty
│   └── zsh/
│       ├── .zshenv
│       ├── completions/
│       │   └── _kitty
│       ├── kitty-integration
│       └── kitty.zsh
├── shell.nix
├── staticcheck.conf
├── terminfo/
│   ├── kitty.termcap
│   ├── kitty.terminfo
│   └── x/
│       └── xterm-kitty
├── test.py
├── tools/
│   ├── README.rst
│   ├── cli/
│   │   ├── bash.go
│   │   ├── command.go
│   │   ├── completion-main.go
│   │   ├── completion-parse-args.go
│   │   ├── completion.go
│   │   ├── files.go
│   │   ├── files_test.go
│   │   ├── fish.go
│   │   ├── group.go
│   │   ├── help.go
│   │   ├── markup/
│   │   │   └── prettify.go
│   │   ├── option-from-string.go
│   │   ├── option.go
│   │   ├── parse-args.go
│   │   ├── types_test.go
│   │   ├── wcswidth_kitten.go
│   │   └── zsh.go
│   ├── cmd/
│   │   ├── at/
│   │   │   ├── complete_actions.go
│   │   │   ├── env.go
│   │   │   ├── launch.go
│   │   │   ├── main.go
│   │   │   ├── main_test.go
│   │   │   ├── run.go
│   │   │   ├── scroll_window.go
│   │   │   ├── send_text.go
│   │   │   ├── set_background_opacity.go
│   │   │   ├── set_colors.go
│   │   │   ├── set_font_size.go
│   │   │   ├── set_spacing.go
│   │   │   ├── set_tab_color.go
│   │   │   ├── set_window_logo.go
│   │   │   ├── shell.go
│   │   │   ├── socket_io.go
│   │   │   ├── template.go
│   │   │   └── tty_io.go
│   │   ├── atexit/
│   │   │   └── main.go
│   │   ├── benchmark/
│   │   │   └── main.go
│   │   ├── completion/
│   │   │   └── kitty.go
│   │   ├── edit_in_kitty/
│   │   │   └── main.go
│   │   ├── main.go
│   │   ├── mouse_demo/
│   │   │   └── main.go
│   │   ├── pytest/
│   │   │   └── main.go
│   │   ├── run_shell/
│   │   │   └── main.go
│   │   ├── show_error/
│   │   │   └── main.go
│   │   ├── tool/
│   │   │   ├── confirm_and_run_shebang.go
│   │   │   └── main.go
│   │   └── update_self/
│   │       └── main.go
│   ├── config/
│   │   ├── api.go
│   │   ├── api_test.go
│   │   ├── utils.go
│   │   └── utils_test.go
│   ├── crypto/
│   │   └── crypto.go
│   ├── disk_cache/
│   │   ├── api.go
│   │   ├── implementation.go
│   │   └── implementation_test.go
│   ├── fzf/
│   │   ├── algo.go
│   │   ├── algo_test.go
│   │   ├── api.go
│   │   └── types.go
│   ├── highlight/
│   │   ├── api.go
│   │   └── impl.go
│   ├── icons/
│   │   └── file-types.go
│   ├── ignorefiles/
│   │   ├── api.go
│   │   ├── gitignore.go
│   │   └── gitignore_test.go
│   ├── rsync/
│   │   ├── algorithm.go
│   │   ├── api.go
│   │   └── api_test.go
│   ├── simdstring/
│   │   ├── benchmark.sh
│   │   ├── benchmarks_test.go
│   │   ├── generate.go
│   │   ├── generate.sh
│   │   ├── intrinsics.go
│   │   ├── intrinsics_test.go
│   │   ├── scalar.go
│   │   └── test.sh
│   ├── themes/
│   │   ├── collection.go
│   │   └── collection_test.go
│   ├── tty/
│   │   ├── tty.go
│   │   ├── tty_bsd.go
│   │   └── tty_linux.go
│   ├── tui/
│   │   ├── dcs_to_kitty.go
│   │   ├── download_with_progress.go
│   │   ├── graphics/
│   │   │   ├── collection.go
│   │   │   ├── command.go
│   │   │   └── command_test.go
│   │   ├── hold.go
│   │   ├── loop/
│   │   │   ├── api.go
│   │   │   ├── capabilities.go
│   │   │   ├── key-encoding.go
│   │   │   ├── key-encoding_test.go
│   │   │   ├── mouse.go
│   │   │   ├── read.go
│   │   │   ├── run.go
│   │   │   ├── terminal-state.go
│   │   │   ├── timers.go
│   │   │   └── write.go
│   │   ├── mouse.go
│   │   ├── password.go
│   │   ├── progress-bar.go
│   │   ├── progress-bar_test.go
│   │   ├── readline/
│   │   │   ├── actions.go
│   │   │   ├── actions_test.go
│   │   │   ├── api.go
│   │   │   ├── completion.go
│   │   │   ├── draw.go
│   │   │   ├── history.go
│   │   │   └── keys.go
│   │   ├── render_lines.go
│   │   ├── run.go
│   │   ├── sgr/
│   │   │   ├── insert-formatting.go
│   │   │   └── insert-formatting_test.go
│   │   ├── shell_integration/
│   │   │   ├── api.go
│   │   │   ├── api_test.go
│   │   │   └── data.go
│   │   ├── shortcuts/
│   │   │   ├── api.go
│   │   │   └── implementation.go
│   │   ├── spinners.go
│   │   ├── subseq/
│   │   │   ├── score.go
│   │   │   └── score_test.go
│   │   ├── tmux.go
│   │   └── ui_kitten.go
│   ├── unicode_names/
│   │   ├── names.txt
│   │   ├── query.go
│   │   └── query_test.go
│   ├── utils/
│   │   ├── atexit.go
│   │   ├── atomic-write.go
│   │   ├── base85/
│   │   │   ├── base85.go
│   │   │   └── base85_test.go
│   │   ├── cache.go
│   │   ├── cached_values.go
│   │   ├── clock_with_raw.go
│   │   ├── clock_without_raw.go
│   │   ├── colors.go
│   │   ├── download_file.go
│   │   ├── embed.go
│   │   ├── filelock.go
│   │   ├── filelock_test.go
│   │   ├── hostname.go
│   │   ├── humanize/
│   │   │   ├── bytes.go
│   │   │   ├── times.go
│   │   │   └── times_test.go
│   │   ├── images/
│   │   │   ├── convert.go
│   │   │   ├── formats.go
│   │   │   ├── loading.go
│   │   │   ├── rowcolumn_diacritics.go
│   │   │   ├── serialize_test.go
│   │   │   ├── to_rgb.go
│   │   │   ├── to_rgba.go
│   │   │   └── utils.go
│   │   ├── io.go
│   │   ├── iso8601.go
│   │   ├── iso8601_test.go
│   │   ├── levenshtein.go
│   │   ├── longest-common.go
│   │   ├── longest-common_test.go
│   │   ├── mimetypes.go
│   │   ├── misc.go
│   │   ├── passwd.go
│   │   ├── passwd_test.go
│   │   ├── paths/
│   │   │   └── well_known.go
│   │   ├── paths.go
│   │   ├── random/
│   │   │   └── random.go
│   │   ├── regexp.go
│   │   ├── ring.go
│   │   ├── ring_test.go
│   │   ├── secrets/
│   │   │   └── tokens.go
│   │   ├── select.go
│   │   ├── select_posix.go
│   │   ├── select_without_pselect.go
│   │   ├── set.go
│   │   ├── shell.go
│   │   ├── shlex/
│   │   │   ├── ansi_c_escapes.go
│   │   │   ├── shlex.go
│   │   │   └── shlex_test.go
│   │   ├── short-uuid.go
│   │   ├── short-uuid_test.go
│   │   ├── sockets.go
│   │   ├── sockets_test.go
│   │   ├── stream_decompressor.go
│   │   ├── stream_decompressor_test.go
│   │   ├── strings.go
│   │   ├── strings_test.go
│   │   ├── style/
│   │   │   ├── api.go
│   │   │   ├── colorspaces.go
│   │   │   ├── colorspaces_bench_test.go
│   │   │   ├── colorspaces_test.go
│   │   │   ├── indent-and-wrap.go
│   │   │   ├── indent-and-wrap_test.go
│   │   │   ├── wrapper.go
│   │   │   └── wrapper_test.go
│   │   ├── tar.go
│   │   ├── tar_test.go
│   │   ├── tmpfile_linux.go
│   │   ├── tmpfile_others.go
│   │   ├── tpmfile_test.go
│   │   ├── types.go
│   │   ├── unsafe.go
│   │   ├── utf-8.go
│   │   └── which.go
│   ├── vt/
│   │   ├── cell.go
│   │   ├── line.go
│   │   └── linebuf.go
│   └── wcswidth/
│       ├── char-props-data.go
│       ├── char-props.go
│       ├── char-props_test.go
│       ├── escape-code-parser.go
│       ├── escape-code-parser_test.go
│       ├── iter.go
│       ├── truncate.go
│       ├── wcswidth.go
│       └── wcswidth_test.go
└── update-on-ox

================================================
FILE CONTENTS
================================================

================================================
FILE: .editorconfig
================================================
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true

[{Makefile,*.terminfo,*.go}]
indent_style = tab

# Autogenerated files with tabs below this line.

[kitty/char-props-data.h]
indent_style = tab

[kittens/unicode_input/names.h]
indent_style = tab

[glfw/wayland-*-protocol.{c,h}]
indent_style = tab


================================================
FILE: .gitattributes
================================================
kitty/terminfo.h linguist-generated=true
terminfo/kitty.termcap linguist-generated=true
terminfo/kitty.terminfo linguist-generated=true
terminfo/x/xterm-kitty linguist-generated=true
kitty/char-props-data.h linguist-generated=true
kitty_tests/GraphemeBreakTest.json linguist-generated=true
kitty/charsets.c linguist-generated=true
kitty/key_encoding.py linguist-generated=true
kitty/rowcolumn-diacritics.c linguist-generated=true
kitty/rgb.py linguist-generated=true
kitty/srgb_gamma.* linguist-generated=true
kitty/gl-wrapper.* linguist-generated=true
kitty/glfw-wrapper.* linguist-generated=true
kitty/color-names.h linguist-generated=true
kitty/parse-graphics-command.h linguist-generated=true
kitty/parse-multicell-command.h linguist-generated=true
kitty/options/types.py linguist-generated=true
kitty/options/parse.py linguist-generated=true
kitty/options/to-c-generated.h linguist-generated=true
kittens/diff/options/types.py linguist-generated=true
kittens/diff/options/parse.py linguist-generated=true
glfw/*.c linguist-vendored=true
glfw/*.h linguist-vendored=true
3rdparty/** linguist-vendored=true
kittens/unicode_input/names.h linguist-generated=true
tools/wcswidth/char-props-data.go linguist-generated=true
tools/unicode_names/names.txt linguist-generated=true
terminfo/kitty.term* linguist-generated=true
terminfo/x/* linguist-generated=true
*_generated.* linguist-generated=true
*_generated_test.* linguist-generated=true

*.py  text diff=python
*.m  text diff=objc
*.go text diff=go


================================================
FILE: .github/FUNDING.yml
================================================
github: kovidgoyal
patreon: kovidgoyal
liberapay: kovidgoyal
custom: https://sw.kovidgoyal.net/kitty/support.html


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a bug report
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. XXX
2. YYY
3. ZZZ
4. See error

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment details**
```
Press Ctrl+Shift+F6 (cmd+option+comma on macOS) in kitty, to copy debug output about kitty and its
configuration to the clipboard and paste it here.

On older versions of kitty, run kitty --debug-config instead
```

**Additional context**
Try to reproduce the problem with `kitty --config NONE` if you cannot then post a minimal kitty.conf that reproduces the problem. If the problem involves interaction with some other terminal program post a minimal config for that program to reproduce the problem as well.


================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.


================================================
FILE: .github/copilot-instructions.md
================================================
Before implementing any code changes or responding to a request, run the
following three commands:

sudo apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev ca-certificates libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev zsh libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev libxxhash-dev uuid-dev libsimde-dev libsystemd-dev libcairo2-dev zsh bash dash systemd-coredump gdb
sudo chmod -R og-w /usr/share/zsh
./dev.sh build

This will download needed dependencies, then create all generated files
and build the project, making it ready for inspection.

# Repository Build & Test Instructions

## Build Procedures
- **Build command:** Run `./dev.sh build` to build the project
- Run `gen/config.py` to update generated config parsing code for both kitty
  and kitten. The `gen/go_code.py` generator is run automatically by the build
  command to keep generated Go code files up to date.
- To build individual kittens use the build command above **do not** try to run go build
  yourself.

Once a build is done, the kitty and kitten binaries will be in the `kitty/launcher` directory.
Note that the kitty binary can run python files using `kitty +launch file.py`.
When it does so the kitty fast_data_types module is available to the python
code.

## Test Procedures
- To run the complete test suite, run `./test.py`
- To run a specific test, run `./test.py test-name` t
  `test-name` is the name of the test without the
  leading `test_` for Python tests and without the leading `Test` for Go tests.
- Do not use go test or ./setup.py test to run tests



================================================
FILE: .github/dependabot.yml
================================================
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
  - package-ecosystem: "gomod" # See documentation for possible values
    directory: "/" # Location of package manifests
    schedule:
      interval: "weekly"
    groups:
      all-go-deps:
        patterns:
          - "*"  # group all non-security update PRs
    cooldown:
      default-days: 7
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"
    groups:
      actions:
        patterns:
          - "*"
    cooldown:
      default-days: 7

================================================
FILE: .github/workflows/ci.py
================================================
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>

import glob
import io
import lzma
import os
import shlex
import shutil
import subprocess
import sys
import tarfile
import time
from urllib.request import Request, urlopen

BUNDLE_URL = 'https://download.calibre-ebook.com/ci/kitty/{}-64.tar.xz'
FONTS_URL = 'https://download.calibre-ebook.com/ci/fonts.tar.xz'
NERD_URL = 'https://github.com/ryanoasis/nerd-fonts/releases/latest/download/NerdFontsSymbolsOnly.tar.xz'
is_bundle = os.environ.get('KITTY_BUNDLE') == '1'
is_codeql = os.environ.get('KITTY_CODEQL') == '1'
is_macos = 'darwin' in sys.platform.lower()
SW = ''


def do_print_crash_reports() -> None:
    print('Printing available crash reports...')
    if is_macos:
        end_time = time.monotonic() + 90
        while time.monotonic() < end_time:
            time.sleep(1)
            items = glob.glob(os.path.join(os.path.expanduser('~/Library/Logs/DiagnosticReports'), 'kitty-*.ips'))
            if items:
                break
        if items:
            time.sleep(1)
            print(os.path.basename(items[0]))
            sdir = os.path.dirname(os.path.abspath(__file__))
            subprocess.check_call([sys.executable, os.path.join(sdir, 'macos_crash_report.py'), items[0]])
    else:
        run('sh -c "echo bt | coredumpctl debug"')
    print(flush=True)


def run(*a: str, print_crash_reports: bool = False) -> None:
    if len(a) == 1:
        a = tuple(shlex.split(a[0]))
    cmd = ' '.join(map(shlex.quote, a))
    print(cmd)
    sys.stdout.flush()
    ret = subprocess.Popen(a).wait()
    if ret != 0:
        if ret < 0:
            import signal
            try:
                sig = signal.Signals(-ret)
            except ValueError:
                pass
            else:
                if print_crash_reports:
                    do_print_crash_reports()
                raise SystemExit(f'The following process was killed by signal: {sig.name}:\n{cmd}')
        raise SystemExit(f'The following process failed with exit code: {ret}:\n{cmd}')


def download_with_retry(url: str | Request, count: int = 5) -> bytes:
    for i in range(count):
        try:
            print('Downloading', getattr(url, 'full_url', url), flush=True)
            with urlopen(url) as f:
                ans: bytes = f.read()
            return ans
        except Exception as err:
            if getattr(err, 'code', -1) == 403:
                raise
            if i >= count - 1:
                raise
            print(f'Download failed with error {err} retrying...', file=sys.stderr)
            time.sleep(1)
    return b''


def install_fonts() -> None:
    data = download_with_retry(FONTS_URL)
    fonts_dir = os.path.expanduser('~/Library/Fonts' if is_macos else '~/.local/share/fonts')
    os.makedirs(fonts_dir, exist_ok=True)
    with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
        try:
            tf.extractall(fonts_dir, filter='fully_trusted')
        except TypeError:
            tf.extractall(fonts_dir)
    data = download_with_retry(NERD_URL)
    with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
        try:
            tf.extractall(fonts_dir, filter='fully_trusted')
        except TypeError:
            tf.extractall(fonts_dir)


def install_deps() -> None:
    print('Installing kitty dependencies...')
    sys.stdout.flush()
    if is_macos:
        if not is_codeql:  # for some reason brew fails on CodeQL we dont need it anyway
            items = [x.split()[1].strip('"') for x in open('Brewfile').readlines() if x.strip().startswith('brew ')]
            openssl = 'openssl'
            items.remove('go')  # already installed by ci.yml
            import ssl
            if ssl.OPENSSL_VERSION_INFO[0] == 1:
                openssl += '@1.1'
            run('brew', 'install', 'fish', openssl, *items)
    else:
        run('sudo apt-get update')
        run('sudo apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev ca-certificates'
            ' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev zsh'
            ' libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev libxxhash-dev uuid-dev'
            ' libsimde-dev libsystemd-dev libcairo2-dev zsh bash dash systemd-coredump gdb')
        # for some reason these directories are world writable which causes zsh
        # compinit to break
        run('sudo chmod -R og-w /usr/share/zsh')
    if is_bundle:
        install_bundle()
    else:
        cmd = 'python3 -m pip install Pillow pygments'
        if sys.version_info[:2] < (3, 7):
            cmd += ' importlib-resources dataclasses'
        run(cmd)
    install_fonts()


def build_kitty() -> None:
    python = shutil.which('python3') if is_bundle else sys.executable
    cmd = f'{python} setup.py build --verbose'
    if is_macos:
        cmd += ' --debug'  # for better crash report to debug SIGILL issue
    if os.environ.get('KITTY_SANITIZE') == '1':
        cmd += ' --debug --sanitize'
    run(cmd)


def test_kitty() -> None:
    if is_macos:
        run('ulimit -c unlimited')
        run('sudo chmod -R 777 /cores')
    run('./test.py', print_crash_reports=True)


def package_kitty() -> None:
    python = 'python3' if is_macos else 'python'
    run(f'{python} setup.py linux-package --update-check-interval=0 --verbose')
    if is_macos:
        run('python3 setup.py kitty.app --update-check-interval=0 --verbose')
        run('kitty.app/Contents/MacOS/kitty +runpy "from kitty.constants import *; print(kitty_exe())"')


def replace_in_file(path: str, src: str, dest: str) -> None:
    with open(path, 'r+') as f:
        n = f.read().replace(src, dest)
        f.seek(0), f.truncate()
        f.write(n)


def setup_bundle_env() -> None:
    global SW
    os.environ['SW'] = SW = '/Users/Shared/kitty-build/sw/sw' if is_macos else os.path.join(os.environ['GITHUB_WORKSPACE'], 'sw')
    os.environ['PKG_CONFIG_PATH'] = os.path.join(SW, 'lib', 'pkgconfig')
    if is_macos:
        os.environ['PATH'] = '{}:{}'.format('/usr/local/opt/sphinx-doc/bin', os.environ['PATH'])
    else:
        os.environ['LD_LIBRARY_PATH'] = os.path.join(SW, 'lib')
        os.environ['PYTHONHOME'] = SW
    os.environ['PATH'] = '{}:{}'.format(os.path.join(SW, 'bin'), os.environ['PATH'])


def install_bundle(dest: str = '', which: str = '') -> None:
    dest = dest or SW
    cwd = os.getcwd()
    os.makedirs(dest, exist_ok=True)
    os.chdir(dest)
    which = which or ('macos' if is_macos else 'linux')
    data = download_with_retry(BUNDLE_URL.format(which))
    with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
        try:
            tf.extractall(filter='fully_trusted')
        except TypeError:
            tf.extractall()
    if not is_macos:
        replaced = 0
        for dirpath, dirnames, filenames in os.walk('.'):
            for f in filenames:
                if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')):
                    replace_in_file(os.path.join(dirpath, f), '/sw/sw', dest)
                    replaced += 1
        if replaced < 2:
            raise SystemExit('Failed to replace path to SW in bundle')
    os.chdir(cwd)


def install_grype(exe: str = '/tmp/grype') -> str:
    raw = download_with_retry('https://download.calibre-ebook.com/ci/grype.xz')
    raw = lzma.decompress(raw)
    with open(exe, 'wb') as f:
        f.write(raw)
        os.fchmod(f.fileno(), 0o755)
    subprocess.check_call([exe, 'db', 'update'])
    return exe


IGNORED_DEPENDENCY_CVES = [
    # Python stdlib
    'CVE-2025-8194', # DoS in tarfile
    'CVE-2025-6069', # DoS in HTMLParser
    'CVE-2025-13836', # DoS in http client reading from malicious server
    'CVE-2025-12084', # DoS in xml.dom.minidom unused in kitty
    'CVE-2025-13837', # DoS in plistlib reading plist. We only use plistlib for writing
    'CVE-2025-6075',  # Quadratic complexity in os.path.expandvars()
    # python stdlib all these are erroneously marked as fixed in python 3.15
    # when it hasnt even been released. Sigh.
    'CVE-2026-1299',
    'CVE-2026-0865',
    'CVE-2025-15282',
    'CVE-2026-0672',
    'CVE-2025-15366',
    'CVE-2025-15367',
    'CVE-2025-12781',
    'CVE-2025-11468',
    'CVE-2026-2297',
    'CVE-2026-3644',
    'CVE-2026-4224',
    # github.com/nwaples/rardecode/v2
    'CVE-2025-11579', # rardecode is version 2.2.1, not vulnerable
    'CVE-2026-2673',  # openssl fix not released
]


def check_dependencies() -> None:
    grype = install_grype()
    with open((gc := os.path.expanduser('~/.grype.yml')), 'w') as f:
        print('ignore:', file=f)
        for x in IGNORED_DEPENDENCY_CVES:
            print('  - vulnerability:', x, file=f)
    dest = os.path.join(SW, 'linux')
    os.makedirs(dest, exist_ok=True)
    install_bundle(dest, os.path.basename(dest))
    dest = os.path.join(SW, 'macos')
    os.makedirs(dest, exist_ok=True)
    install_bundle(dest, os.path.basename(dest))
    cmdline = [grype, '--by-cve', '--config', gc, '--fail-on', 'medium', '--only-fixed', '--add-cpes-if-none']
    if (subprocess.run(cmdline + ['dir:' + SW])).returncode != 0:
        raise SystemExit('grype found problems during filesystem scan')
    # Now test against the SBOM
    import runpy
    orig = sys.argv, sys.stdout
    sys.argv = ['bypy', 'sbom', 'kovidgoyal/kitty', '1.0.0']
    buf = io.StringIO()
    sys.stdout = buf
    runpy.run_path('bypy-src')
    sys.argv, sys.stdout = orig
    print(buf.getvalue())
    if (subprocess.run(cmdline, input=buf.getvalue().encode())).returncode != 0:
        raise SystemExit('grype found problems during SBOM scan')


def main() -> None:
    if is_bundle:
        setup_bundle_env()
    else:
        if not is_macos and 'pythonLocation' in os.environ:
            os.environ['LD_LIBRARY_PATH'] = os.path.join(os.environ['pythonLocation'], 'lib')
    action = sys.argv[-1]
    if action in ('build', 'package'):
        install_deps()
    if action == 'build':
        build_kitty()
    elif action == 'package':
        package_kitty()
    elif action == 'test':
        test_kitty()
    elif action == 'test':
        test_kitty()
    elif action == 'govulncheck':
        subprocess.check_call(['go', 'install', 'golang.org/x/vuln/cmd/govulncheck@latest'])
        subprocess.check_call(['govulncheck', '-mode=binary', 'kitty/launcher/kitten'])
        subprocess.check_call(['govulncheck', './...'])
    elif action == 'gofmt':
        q = subprocess.check_output('gofmt -s -l tools kittens'.split()).decode()
        if q.strip():
            q = '\n'.join(filter(lambda x: not x.rstrip().endswith('_generated.go'), q.strip().splitlines())).strip()
            if q:
                raise SystemExit(q)
    elif action == 'check-dependencies':
        check_dependencies()
    else:
        raise SystemExit(f'Unknown action: {action}')


if __name__ == '__main__':
    main()


================================================
FILE: .github/workflows/ci.yml
================================================
name: CI
on: [push, pull_request]
env:
    CI: 'true'
    ASAN_OPTIONS: detect_leaks=0
    LC_ALL: en_US.UTF-8
    LANG: en_US.UTF-8

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
    linux:
        name: Linux (python=${{ matrix.pyver }} cc=${{ matrix.cc }} sanitize=${{ matrix.sanitize }})
        runs-on: ubuntu-latest
        env:
            CC: ${{ matrix.cc }}
            KITTY_SANITIZE: ${{ matrix.sanitize }}

        strategy:
            matrix:
                python: [a, b, c]
                cc: [gcc, clang]
                include:
                    - python: a
                      pyver: "3.10"
                      sanitize: 0

                    - python: b
                      pyver: "3.11"
                      sanitize: 1

                    - python: c
                      pyver: "3.12"
                      sanitize: 1


                exclude:
                    - python: a
                      cc: clang
                    - python: b
                      cc: clang
                    - python: c
                      cc: gcc

        steps:
          - name: Checkout source code
            uses: actions/checkout@v6
            with:
              fetch-depth: 10
              persist-credentials: false

          - name: Set up Python ${{ matrix.pyver }}
            uses: actions/setup-python@v6
            with:
              python-version: ${{ matrix.pyver }}

          - name: Install Go
            uses: actions/setup-go@v6
            with:
              go-version-file: go.mod

          - name: Build kitty
            run: python .github/workflows/ci.py build

          - name: Test kitty
            run: python .github/workflows/ci.py test

    linux-package:
        name: Linux package
        runs-on: ubuntu-latest
        env:
            CFLAGS: -funsigned-char
        steps:
          - name: Checkout source code
            uses: actions/checkout@v6
            with:
              fetch-depth: 0  # needed for :commit: docs role
              persist-credentials: false

          - name: Test for trailing whitespace
            run: if grep -Inr '\s$' kitty kitty_tests kittens docs *.py *.asciidoc *.rst *.go .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi

          - name: Test for bad code block formatting
            run: if grep -Inr ':code:`\s' kitty kitty_tests kittens docs *.py *.asciidoc *.rst *.go .gitattributes .gitignore; then echo Space at code block start found, aborting.; exit 1; fi

          - name: Set up Python
            uses: actions/setup-python@v6
            with:
              python-version: "3.13"

          - name: Install Go
            uses: actions/setup-go@v6
            with:
              go-version-file: go.mod
              cache: false

          - name: Cache Go build artifacts separately
            uses: actions/cache@v5
            with:
              path: |
                ~/.cache/go-build
                ~/go/pkg/mod
              key: ${{ runner.os }}-golang-static-${{ hashFiles('**/go.sum') }}
              restore-keys: |
                ${{ runner.os }}-golang-static-

          - name: Install build-only deps
            run: python -m pip install -r docs/requirements.txt ruff mypy types-requests types-docutils types-Pygments

          - name: Run ruff
            run: ruff check .

          - name: Run gofmt
            run: go version && python .github/workflows/ci.py gofmt

          - name: Build kitty package
            run: python .github/workflows/ci.py package

          - name: Build kitty
            run: python setup.py build --debug

          - name: Run mypy
            run: which python && python -m mypy --version && ./test.py mypy

          - name: Run go vet
            run: go version && go vet -tags testing ./...

          - name: Build man page
            run: make FAIL_WARN=1 man

          - name: Build HTML docs
            run: make FAIL_WARN=1 html

          - name: Build static kittens
            run: python setup.py build-static-binaries

    bundle:
        name: Bundle test (${{ matrix.os }})
        runs-on: ${{ matrix.os }}
        strategy:
            matrix:
                os: [ubuntu-latest, macos-latest]
        env:
            KITTY_BUNDLE: 1
        steps:
          - name: Checkout source code
            uses: actions/checkout@v6
            with:
              fetch-depth: 10
              persist-credentials: false

          - name: Install Go
            uses: actions/setup-go@v6
            with:
              go-version-file: go.mod

          - name: Build kitty
            run: which python3 && python3 .github/workflows/ci.py build

          - name: Test kitty
            run: python3 .github/workflows/ci.py test

    brew:
        name: macOS Brew
        runs-on: macos-latest
        steps:
          - name: Checkout source code
            uses: actions/checkout@v6
            with:
              fetch-depth: 0  # needed for :commit: docs role
              persist-credentials: false

          - name: Set up Python
            uses: actions/setup-python@v6
            with:
              python-version: "3.11"

          - name: Install Go
            uses: actions/setup-go@v6
            with:
              go-version-file: go.mod

          - name: Build kitty
            run: python3 .github/workflows/ci.py build

          - name: Test kitty
            run: python3 .github/workflows/ci.py test

          - name: Install deps for docs
            run: python3 -m pip install -r docs/requirements.txt

          - name: Builds docs
            run: make FAIL_WARN=1 docs

          - name: Build kitty package
            run: python3 .github/workflows/ci.py package

          - name: Run benchmarks
            run: ./benchmark.py

    linux-dev:
        name: Test ./dev.sh and benchmark
        runs-on: ubuntu-latest
        steps:
          - name: Checkout source code
            uses: actions/checkout@v6
            with:
              fetch-depth: 10
              persist-credentials: false

          - name: Install build deps
            run: sudo apt-get update && sudo apt-get install -y curl xz-utils build-essential git pkg-config libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev libxkbcommon-x11-dev libfontconfig-dev libx11-xcb-dev libdbus-1-dev

          - name: Install Go
            uses: actions/setup-go@v6
            with:
              go-version-file: go.mod

          - name: Build kitty
            run: ./dev.sh build

          - name: Run benchmarks
            run: ./benchmark.py


================================================
FILE: .github/workflows/codeql-analysis.yml
================================================
name: "CodeQL"

on:
    push:
        branches: [master]
    pull_request:
        # The branches below must be a subset of the branches above
        branches: [master]
    schedule:
        - cron: '0 22 * * 5'

jobs:
    CodeQL-Build:

        permissions:
            contents: read # to fetch code (actions/checkout)
            security-events: write # to upload SARIF results (github/codeql-action/analyze)

        strategy:
          fail-fast: false
          matrix:
            include:
               - language: python
                 os: ubuntu-latest
               - language: c
                 os: ubuntu-latest
               - language: c
                 os: macos-latest
               - language: go
                 os: ubuntu-latest
               - language: actions
                 os: ubuntu-latest

        runs-on: ${{ matrix.os }}
        env:
            KITTY_BUNDLE: 1
            KITTY_CODEQL: 1

        steps:

        - name: Checkout repository
          uses: actions/checkout@v6
          with:
              # We must fetch at least the immediate parents so that if this is
              # a pull request then we can checkout the head.
              fetch-depth: 2
              persist-credentials: false

        - name: Install Go
          if: matrix.language == 'c' || matrix.language == 'go'
          uses: actions/setup-go@v6
          with:
              go-version-file: go.mod

        # Initializes the CodeQL tools for scanning.
        - name: Initialize CodeQL
          uses: github/codeql-action/init@v4
          with:
              languages: ${{ matrix.language }}
              trap-caching: false

        - name: Build kitty
          if: matrix.language == 'c' || matrix.language == 'go'
          run: python3 .github/workflows/ci.py build

        - name: Perform CodeQL Analysis
          uses: github/codeql-action/analyze@v4

        - name: Run govulncheck
          if: matrix.language == 'go'
          run: python3 .github/workflows/ci.py govulncheck


================================================
FILE: .github/workflows/depscan.yml
================================================
name: Depscan
on:
    push:
        branches: [master]
    schedule:
        - cron: '0 12 * * 5'

env:
    CI: 'true'
    ASAN_OPTIONS: detect_leaks=0
    LC_ALL: en_US.UTF-8
    LANG: en_US.UTF-8

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
    dependecy-scanner:
        name: Scan dependencies for vulnerabilities
        runs-on: ubuntu-latest
        env:
            KITTY_BUNDLE: 1
        steps:
          - name: Checkout source code
            uses: actions/checkout@v6
            with:
              fetch-depth: 10
              persist-credentials: false

          - name: Checkout bypy
            uses: actions/checkout@v6
            with:
              fetch-depth: 1
              persist-credentials: false
              repository: kovidgoyal/bypy
              path: bypy-src

          - name: Check dependencies
            run: python3 .github/workflows/ci.py check-dependencies


================================================
FILE: .github/workflows/macos_crash_report.py
================================================
#!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>

import json
import posixpath
import sys
from collections import namedtuple
from datetime import datetime
from enum import Enum
from functools import cached_property
from typing import IO, List, Mapping, Optional

Frame = namedtuple('Frame', 'image_name image_base image_offset symbol symbol_offset')
Register = namedtuple('Register', 'name value')


def surround(x: str, start: int, end: int) -> str:
    if sys.stdout.isatty():
        x = f'\033[{start}m{x}\033[{end}m'
    return x


def cyan(x: str) -> str:
    return surround(x, 96, 39)


def bold(x: str) -> str:
    return surround(x, 1, 22)


class BugType(Enum):
    WatchdogTimeout = '28'
    BasebandStats = '195'
    GPUEvent = '284'
    Sandbox = '187'
    TerminatingStackshot = '509'
    ServiceWatchdogTimeout = '29'
    Session = '179'
    LegacyStackshot = '188'
    MACorrelation = '197'
    iMessages = '189'
    log_power = '278'
    PowerLog = 'powerlog'
    DuetKnowledgeCollector2 = '58'
    BridgeRestore = '83'
    LegacyJetsam = '198'
    ExcResource_385 = '385'
    Modem = '199'
    Stackshot = '288'
    SystemInformation = 'system_profile'
    Jetsam_298 = '298'
    MemoryResource = '30'
    Bridge = '31'
    DifferentialPrivacy = 'diff_privacy'
    FirmwareIntegrity = '32'
    CoreAnalytics_33 = '33'
    AutoBugCapture = '34'
    EfiFirmwareIntegrity = '35'
    SystemStats = '36'
    AnonSystemStats = '37'
    Crash_9 = '9'
    Jetsam_98 = '98'
    LDCM = '100'
    Panic_10 = '10'
    Spin = '11'
    CLTM = '101'
    Hang = '12'
    Panic_110 = '110'
    ConnectionFailure = '13'
    MessageTracer = '14'
    LowBattery = '120'
    Siri = '201'
    ShutdownStall = '17'
    Panic_210 = '210'
    SymptomsCPUUsage = '202'
    AssumptionViolation = '18'
    CoreHandwriting = 'chw'
    IOMicroStackShot = '44'
    CoreAnalytics_211 = '211'
    SiriAppPrediction = '203'
    spin_45 = '45'
    PowerMicroStackshots = '220'
    BTMetadata = '212'
    SystemMemoryReset = '301'
    ResetCount = '115'
    AutoBugCapture_204 = '204'
    WifiCrashBinary = '221'
    MicroRunloopHang = '310'
    Rosetta = '213'
    glitchyspin = '302'
    System = '116'
    IOPowerSources = '141'
    PanicStats = '205'
    PowerLog_230 = '230'
    LongRunloopHang = '222'
    HomeProductsAnalytics = '311'
    DifferentialPrivacy_150 = '150'
    Rhodes = '214'
    ProactiveEventTrackerTransparency = '303'
    WiFi = '117'
    SymptomsCPUWakes = '142'
    SymptomsCPUUsageFatal = '206'
    Crash_109 = '109'
    ShortRunloopHang = '223'
    CoreHandwriting_231 = '231'
    ForceReset = '151'
    SiriAppSelection = '215'
    PrivateFederatedLearning = '304'
    Bluetooth = '118'
    SCPMotion = '143'
    HangSpin = '207'
    StepCount = '160'
    RTCTransparency = '224'
    DiagnosticRequest = '312'
    MemorySnapshot = '152'
    Rosetta_B = '216'
    AudioAccessory = '305'
    General = '119'
    HotSpotIOMicroSS = '144'
    GeoServicesTransparency = '233'
    MotionState = '161'
    AppStoreTransparency = '225'
    SiriSearchFeedback = '313'
    BearTrapReserved = '153'
    Portrait = '217'
    AWDMetricLog = 'metriclog'
    SymptomsIO = '145'
    SubmissionReserved = '170'
    WifiCrash = '209'
    Natalies = '162'
    SecurityTransparency = '226'
    BiomeMapReduce = '234'
    MemoryGraph = '154'
    MultichannelAudio = '218'
    honeybee_payload = '146'
    MesaReserved = '171'
    WifiSensing = '235'
    SiriMiss = '163'
    ExcResourceThreads_227 = '227'
    TestA = 'T01'
    NetworkUsage = '155'
    WifiReserved = '180'
    SiriActionPrediction = '219'
    honeybee_heartbeat = '147'
    ECCEvent = '172'
    KeyTransparency = '236'
    SubDiagHeartBeat = '164'
    ThirdPartyHang = '228'
    OSFault = '308'
    CoreTime = '156'
    WifiDriverReserved = '181'
    Crash_309 = '309'
    honeybee_issue = '148'
    CellularPerfReserved = '173'
    TestB = 'T02'
    StorageStatus = '165'
    SiriNotificationTransparency = '229'
    TestC = 'T03'
    CPUMicroSS = '157'
    AccessoryUpdate = '182'
    xprotect = '20'
    MultitouchFirmware = '149'
    MicroStackshot = '174'
    AppLaunchDiagnostics = '238'
    KeyboardAccuracy = '166'
    GPURestart = '21'
    FaceTime = '191'
    DuetKnowledgeCollector = '158'
    OTASUpdate = '183'
    ExcResourceThreads_327 = '327'
    ExcResource_22 = '22'
    DuetDB = '175'
    ThirdPartyHangDeveloper = '328'
    PrivacySettings = '167'
    GasGauge = '192'
    MicroStackShots = '23'
    BasebandCrash = '159'
    GPURestart_184 = '184'
    SystemWatchdogCrash = '409'
    FlashStatus = '176'
    SleepWakeFailure = '24'
    CarouselEvent = '168'
    AggregateD = '193'
    WakeupsMonitorViolation = '25'
    DifferentialPrivacy_50 = '50'
    ExcResource_185 = '185'
    UIAutomation = '177'
    ping = '26'
    SiriTransaction = '169'
    SURestore = '194'
    KtraceStackshot = '186'
    WirelessDiagnostics = '27'
    PowerLogLite = '178'
    SKAdNetworkAnalytics = '237'
    HangWorkflowResponsiveness = '239'
    CompositorClientHang = '243'


class CrashReportBase:
    def __init__(self, metadata: Mapping, data: str, filename: str = None):
        self.filename = filename
        self._metadata = metadata
        self._data = data
        self._parse()

    def _parse(self):
        self._is_json = False
        try:
            modified_data = self._data
            if '\n  \n' in modified_data:
                modified_data, rest = modified_data.split('\n  \n', 1)
                rest = '",' + rest.split('",', 1)[1]
                modified_data += rest
            self._data = json.loads(modified_data)
            self._is_json = True
        except json.decoder.JSONDecodeError:
            pass

    @cached_property
    def bug_type(self) -> BugType:
        return BugType(self.bug_type_str)

    @cached_property
    def bug_type_str(self) -> str:
        return self._metadata['bug_type']

    @cached_property
    def incident_id(self):
        return self._metadata.get('incident_id')

    @cached_property
    def timestamp(self) -> datetime:
        timestamp = self._metadata.get('timestamp')
        timestamp_without_timezone = timestamp.rsplit(' ', 1)[0]
        return datetime.strptime(timestamp_without_timezone, '%Y-%m-%d %H:%M:%S.%f')

    @cached_property
    def name(self) -> str:
        return self._metadata.get('name')

    def __repr__(self) -> str:
        filename = ''
        if self.filename:
            filename = f'FILENAME:{posixpath.basename(self.filename)} '
        return f'<{self.__class__} {filename}TIMESTAMP:{self.timestamp}>'

    def __str__(self) -> str:
        filename = ''
        if self.filename:
            filename = self.filename

        return cyan(f'{self.incident_id} {self.timestamp}\n{filename}\n\n')


class UserModeCrashReport(CrashReportBase):
    def _parse_field(self, name: str) -> str:
        name += ':'
        for line in self._data.split('\n'):
            if line.startswith(name):
                field = line.split(name, 1)[1]
                field = field.strip()
                return field

    @cached_property
    def faulting_thread(self) -> int:
        if self._is_json:
            return self._data['faultingThread']
        else:
            return int(self._parse_field('Triggered by Thread'))

    @cached_property
    def frames(self) -> List[Frame]:
        result = []
        if self._is_json:
            thread_index = self.faulting_thread
            images = self._data['usedImages']
            for frame in self._data['threads'][thread_index]['frames']:
                image = images[frame['imageIndex']]
                result.append(
                    Frame(image_name=image.get('path'), image_base=image.get('base'), symbol=frame.get('symbol'),
                          image_offset=frame.get('imageOffset'), symbol_offset=frame.get('symbolLocation')))
        else:
            in_frames = False
            for line in self._data.split('\n'):
                if in_frames:
                    splitted = line.split()

                    if len(splitted) == 0:
                        break

                    assert splitted[-2] == '+'
                    image_base = splitted[-3]
                    if image_base.startswith('0x'):
                        result.append(Frame(image_name=splitted[1], image_base=int(image_base, 16), symbol=None,
                                            image_offset=int(splitted[-1]), symbol_offset=None))
                    else:
                        # symbolicated
                        result.append(Frame(image_name=splitted[1], image_base=None, symbol=image_base,
                                            image_offset=None, symbol_offset=int(splitted[-1])))

                if line.startswith(f'Thread {self.faulting_thread} Crashed:'):
                    in_frames = True

        return result

    @cached_property
    def registers(self) -> List[Register]:
        result = []
        if self._is_json:
            thread_index = self._data['faultingThread']
            thread_state = self._data['threads'][thread_index]['threadState']

            if 'x' in thread_state:
                for i, reg_x in enumerate(thread_state['x']):
                    result.append(Register(name=f'x{i}', value=reg_x['value']))

            for i, (name, value) in enumerate(thread_state.items()):
                if name == 'x':
                    for j, reg_x in enumerate(value):
                        result.append(Register(name=f'x{j}', value=reg_x['value']))
                else:
                    if isinstance(value, dict):
                        result.append(Register(name=name, value=value['value']))
        else:
            in_frames = False
            for line in self._data.split('\n'):
                if in_frames:
                    splitted = line.split()

                    if len(splitted) == 0:
                        break

                    for i in range(0, len(splitted), 2):
                        register_name = splitted[i]
                        if not register_name.endswith(':'):
                            break

                        register_name = register_name[:-1]
                        register_value = int(splitted[i + 1], 16)

                        result.append(Register(name=register_name, value=register_value))

                if line.startswith(f'Thread {self.faulting_thread} crashed with ARM Thread State'):
                    in_frames = True

        return result

    @cached_property
    def exception_type(self):
        if self._is_json:
            return self._data['exception'].get('type')
        else:
            return self._parse_field('Exception Type')

    @cached_property
    def exception_subtype(self) -> Optional[str]:
        if self._is_json:
            return self._data['exception'].get('subtype')
        else:
            return self._parse_field('Exception Subtype')

    @cached_property
    def application_specific_information(self) -> Optional[str]:
        result = ''
        if self._is_json:
            asi = self._data.get('asi')
            if asi is None:
                return None
            return asi
        else:
            in_frames = False
            for line in self._data.split('\n'):
                if in_frames:
                    line = line.strip()
                    if len(line) == 0:
                        break

                    result += line + '\n'

                if line.startswith('Application Specific Information:'):
                    in_frames = True

        result = result.strip()
        if not result:
            return None
        return result

    def __str__(self) -> str:
        result = super().__str__()
        result += bold(f'Exception: {self.exception_type}\n')

        if self.exception_subtype:
            result += bold('Exception Subtype: ')
            result += f'{self.exception_subtype}\n'

        if self.application_specific_information:
            result += bold('Application Specific Information: ')
            result += str(self.application_specific_information)

        result += '\n'

        result += bold('Registers:')
        for i, register in enumerate(self.registers):
            if i % 4 == 0:
                result += '\n'

            result += f'{register.name} = 0x{register.value:016x} '.rjust(30)

        result += '\n\n'

        result += bold('Frames:\n')
        for frame in self.frames:
            image_base = '_HEADER'
            if frame.image_base is not None:
                image_base = f'0x{frame.image_base:x}'
            result += f'\t[{frame.image_name}] {image_base}'
            if frame.image_offset:
                result += f' + 0x{frame.image_offset:x}'
            if frame.symbol is not None:
                result += f' ({frame.symbol} + 0x{frame.symbol_offset:x})'
            result += '\n'

        return result


def get_crash_report_from_file(crash_report_file: IO) -> CrashReportBase:
    metadata = json.loads(crash_report_file.readline())

    try:
        bug_type = BugType(metadata['bug_type'])
    except ValueError:
        return CrashReportBase(metadata, crash_report_file.read(), crash_report_file.name)

    bug_type_parsers = {
        BugType.Crash_109: UserModeCrashReport,
        BugType.Crash_309: UserModeCrashReport,
        BugType.ExcResourceThreads_327: UserModeCrashReport,
        BugType.ExcResource_385: UserModeCrashReport,
    }

    parser = bug_type_parsers.get(bug_type)
    if parser is None:
        return CrashReportBase(metadata, crash_report_file.read(), crash_report_file.name)

    return parser(metadata, crash_report_file.read(), crash_report_file.name)


if __name__ == '__main__':
    with open(sys.argv[-1]) as f:
        print(get_crash_report_from_file(f))


================================================
FILE: .gitignore
================================================
*.so
*.pyc
*.pyo
*.bin
*_stub.pyi
*_generated.go
*_generated.s
*_generated_test.go
*_generated_test.s
*_generated.h
/.dmypy.json
/dependencies
/tags
/build/
/fonts/
/linux-package/
/kitty.app/
/glad/out/
/kitty/launcher/kitt*
/*.dSYM/
__pycache__/
/glfw/wayland-*-client-protocol.[ch]
/docs/_build/
/docs/generated/
/tools/simdstring/simdstring.test
/.mypy_cache
/.ruff_cache
.DS_Store
.cache
bypy/b
bypy/virtual-machines.conf
_codeql_detected_source_root



================================================
FILE: 3rdparty/base64/LICENSE
================================================
Copyright (c) 2005-2007, Nick Galbreath
Copyright (c) 2015-2018, Wojciech Muła
Copyright (c) 2016-2017, Matthieu Darbois
Copyright (c) 2013-2022, Alfred Klomp
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


================================================
FILE: 3rdparty/base64/README.md
================================================
# Fast Base64 stream encoder/decoder

[![Build Status](https://github.com/aklomp/base64/actions/workflows/test.yml/badge.svg)](https://github.com/aklomp/base64/actions/workflows/test.yml)

This is an implementation of a base64 stream encoding/decoding library in C99
with SIMD (AVX2, AVX512, NEON, AArch64/NEON, SSSE3, SSE4.1, SSE4.2, AVX) and
[OpenMP](http://www.openmp.org) acceleration. It also contains wrapper functions
to encode/decode simple length-delimited strings. This library aims to be:

- FAST;
- easy to use;
- elegant.

On x86, the library does runtime feature detection. The first time it's called,
the library will determine the appropriate encoding/decoding routines for the
machine. It then remembers them for the lifetime of the program. If your
processor supports AVX2, SSSE3, SSE4.1, SSE4.2 or AVX instructions, the library
will pick an optimized codec that lets it encode/decode 12 or 24 bytes at a
time, which gives a speedup of four or more times compared to the "plain"
bytewise codec.

AVX512 support is only for encoding at present, utilizing the AVX512 VL and VBMI
instructions. Decoding part reused AVX2 implementations. For CPUs later than
Cannonlake (manufactured in 2018) supports these instructions.

NEON support is hardcoded to on or off at compile time, because portable
runtime feature detection is unavailable on ARM.

Even if your processor does not support SIMD instructions, this is a very fast
library. The fallback routine can process 32 or 64 bits of input in one round,
depending on your processor's word width, which still makes it significantly
faster than naive bytewise implementations. On some 64-bit machines, the 64-bit
routines even outperform the SSSE3 ones.

To the author's knowledge, at the time of original release, this was the only
Base64 library to offer SIMD acceleration. The author wrote
[an article](http://www.alfredklomp.com/programming/sse-base64) explaining one
possible SIMD approach to encoding/decoding Base64. The article can help figure
out what the code is doing, and why.

Notable features:

- Really fast on x86 and ARM systems by using SIMD vector processing;
- Can use [OpenMP](http://www.openmp.org) for even more parallel speedups;
- Really fast on other 32 or 64-bit platforms through optimized routines;
- Reads/writes blocks of streaming data;
- Does not dynamically allocate memory;
- Valid C99 that compiles with pedantic options on;
- Re-entrant and threadsafe;
- Unit tested;
- Uses Duff's Device.

## Acknowledgements

The original AVX2, NEON and Aarch64/NEON codecs were generously contributed by
[Inkymail](https://github.com/inkymail/base64), who, in their fork, also
implemented some additional features. Their work is slowly being backported
into this project.

The SSSE3 and AVX2 codecs were substantially improved by using some very clever
optimizations described by Wojciech Muła in a
[series](http://0x80.pl/notesen/2016-01-12-sse-base64-encoding.html) of
[articles](http://0x80.pl/notesen/2016-01-17-sse-base64-decoding.html).
His own code is [here](https://github.com/WojciechMula/toys/tree/master/base64).

The AVX512 encoder is based on code from Wojciech Muła's
[base64simd](https://github.com/WojciechMula/base64simd) library.

The OpenMP implementation was added by Ferry Toth (@htot) from [Exalon Delft](http://www.exalondelft.nl).

## Building

The `lib` directory contains the code for the actual library.
Typing `make` in the toplevel directory will build `lib/libbase64.o` and `bin/base64`.
The first is a single, self-contained object file that you can link into your own project.
The second is a standalone test binary that works similarly to the `base64` system utility.

The matching header file needed to use this library is in `include/libbase64.h`.

To compile just the "plain" library without SIMD codecs, type:

```sh
make lib/libbase64.o
```

Optional SIMD codecs can be included by specifying the `AVX2_CFLAGS`, `AVX512_CFLAGS`,
`NEON32_CFLAGS`, `NEON64_CFLAGS`, `SSSE3_CFLAGS`, `SSE41_CFLAGS`, `SSE42_CFLAGS` and/or `AVX_CFLAGS` environment variables.
A typical build invocation on x86 looks like this:

```sh
AVX2_CFLAGS=-mavx2 SSSE3_CFLAGS=-mssse3 SSE41_CFLAGS=-msse4.1 SSE42_CFLAGS=-msse4.2 AVX_CFLAGS=-mavx make lib/libbase64.o
```

### AVX2

To build and include the AVX2 codec, set the `AVX2_CFLAGS` environment variable to a value that will turn on AVX2 support in your compiler, typically `-mavx2`.
Example:

```sh
AVX2_CFLAGS=-mavx2 make
```

### AVX512

To build and include the AVX512 codec, set the `AVX512_CFLAGS` environment variable to a value that will turn on AVX512 support in your compiler, typically `-mavx512vl -mavx512vbmi`.
Example:

```sh
AVX512_CFLAGS="-mavx512vl -mavx512vbmi" make
```

The codec will only be used if runtime feature detection shows that the target machine supports AVX2.

### SSSE3

To build and include the SSSE3 codec, set the `SSSE3_CFLAGS` environment variable to a value that will turn on SSSE3 support in your compiler, typically `-mssse3`.
Example:

```sh
SSSE3_CFLAGS=-mssse3 make
```

The codec will only be used if runtime feature detection shows that the target machine supports SSSE3.

### NEON

This library includes two NEON codecs: one for regular 32-bit ARM and one for the 64-bit AArch64 with NEON, which has double the amount of SIMD registers and can do full 64-byte table lookups.
These codecs encode in 48-byte chunks and decode in massive 64-byte chunks, so they had to be augmented with an uint32/64 codec to stay fast on smaller inputs!

Use LLVM/Clang for compiling the NEON codecs.
The code generation of at least GCC 4.6 (the version shipped with Raspbian and used for testing) contains a bug when compiling `vstq4_u8()`, and the generated assembly code is of low quality.
NEON intrinsics are a known weak area of GCC.
Clang does a better job.

NEON support can unfortunately not be portably detected at runtime from userland (the `mrc` instruction is privileged), so the default value for using the NEON codec is determined at compile-time.
But you can do your own runtime detection.
You can include the NEON codec and make it the default, then do a runtime check if the CPU has NEON support, and if not, force a downgrade to non-NEON with `BASE64_FORCE_PLAIN`.

These are your options:

1. Don't include NEON support;
2. build NEON support and make it the default, but build all other code without NEON flags so that you can override the default at runtime with `BASE64_FORCE_PLAIN`;
3. build everything with NEON support and make it the default;
4. build everything with NEON support, but don't make it the default (which makes no sense).

For option 1, simply don't specify any NEON-specific compiler flags at all, like so:

```sh
CC=clang CFLAGS="-march=armv6" make
```

For option 2, keep your `CFLAGS` plain, but set the `NEON32_CFLAGS` environment variable to a value that will build NEON support.
The line below, for instance, will build all the code at ARMv6 level, except for the NEON codec, which is built at ARMv7.
It will also make the NEON codec the default.
For ARMv6 platforms, override that default at runtime with the `BASE64_FORCE_PLAIN` flag.
No ARMv7/NEON code will then be touched.

```sh
CC=clang CFLAGS="-march=armv6" NEON32_CFLAGS="-march=armv7 -mfpu=neon" make
```

For option 3, put everything in your `CFLAGS` and use a stub, but non-empty, `NEON32_CFLAGS`.
This example works for the Raspberry Pi 2B V1.1, which has NEON support:

```sh
CC=clang CFLAGS="-march=armv7 -mtune=cortex-a7" NEON32_CFLAGS="-mfpu=neon" make
```

To build and include the NEON64 codec, use `CFLAGS` as usual to define the platform and set `NEON64_CFLAGS` to a nonempty stub.
(The AArch64 target has mandatory NEON64 support.)
Example:

```sh
CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" NEON64_CFLAGS=" " make
```

### OpenMP

To enable OpenMP on GCC you need to build with `-fopenmp`. This can be by setting the `OPENMP` environment variable to `1`.

Example:

```sh
OPENMP=1 make
```

This will let the compiler define `_OPENMP`, which in turn will include the OpenMP optimized `lib_openmp.c` into `lib.c`.

By default the number of parallel threads will be equal to the number of cores of the processor.
On a quad core with hyperthreading eight cores will be detected, but hyperthreading will not increase the performance.

To get verbose information about OpenMP start the program with `OMP_DISPLAY_ENV=VERBOSE`, for instance

```sh
OMP_DISPLAY_ENV=VERBOSE test/benchmark
```

To put a limit on the number of threads, start the program with `OMP_THREAD_LIMIT=n`, for instance

```sh
OMP_THREAD_LIMIT=2 test/benchmark
```

An example of running a benchmark with OpenMP, SSSE3 and AVX2 enabled:

```sh
make clean && OPENMP=1 SSSE3_CFLAGS=-mssse3 AVX2_CFLAGS=-mavx2 make && OPENMP=1 make -C test
```

## API reference

Strings are represented as a pointer and a length; they are not
zero-terminated. This was a conscious design decision. In the decoding step,
relying on zero-termination would make no sense since the output could contain
legitimate zero bytes. In the encoding step, returning the length saves the
overhead of calling `strlen()` on the output. If you insist on the trailing
zero, you can easily add it yourself at the given offset.

### Flags

Some API calls take a `flags` argument.
That argument can be used to force the use of a specific codec, even if that codec is a no-op in the current build.
Mainly there for testing purposes, this is also useful on ARM where the only way to do runtime NEON detection is to ask the OS if it's available.
The following constants can be used:

- `BASE64_FORCE_AVX2`
- `BASE64_FORCE_AVX512`
- `BASE64_FORCE_NEON32`
- `BASE64_FORCE_NEON64`
- `BASE64_FORCE_PLAIN`
- `BASE64_FORCE_SSSE3`
- `BASE64_FORCE_SSE41`
- `BASE64_FORCE_SSE42`
- `BASE64_FORCE_AVX`

Set `flags` to `0` for the default behavior, which is runtime feature detection on x86, a compile-time fixed codec on ARM, and the plain codec on other platforms.

### Encoding

#### base64_encode

```c
void base64_encode
    ( const char  *src
    , size_t       srclen
    , char        *out
    , size_t      *outlen
    , int          flags
    ) ;
```

Wrapper function to encode a plain string of given length.
Output is written to `out` without trailing zero.
Output length in bytes is written to `outlen`.
The buffer in `out` has been allocated by the caller and is at least 4/3 the size of the input.

#### base64_stream_encode_init

```c
void base64_stream_encode_init
    ( struct base64_state  *state
    , int                   flags
    ) ;
```

Call this before calling `base64_stream_encode()` to init the state.

#### base64_stream_encode

```c
void base64_stream_encode
    ( struct base64_state  *state
    , const char           *src
    , size_t                srclen
    , char                 *out
    , size_t               *outlen
    ) ;
```

Encodes the block of data of given length at `src`, into the buffer at `out`.
Caller is responsible for allocating a large enough out-buffer; it must be at least 4/3 the size of the in-buffer, but take some margin.
Places the number of new bytes written into `outlen` (which is set to zero when the function starts).
Does not zero-terminate or finalize the output.

#### base64_stream_encode_final

```c
void base64_stream_encode_final
    ( struct base64_state  *state
    , char                 *out
    , size_t               *outlen
    ) ;
```

Finalizes the output begun by previous calls to `base64_stream_encode()`.
Adds the required end-of-stream markers if appropriate.
`outlen` is modified and will contain the number of new bytes written at `out` (which will quite often be zero).

### Decoding

#### base64_decode

```c
int base64_decode
    ( const char  *src
    , size_t       srclen
    , char        *out
    , size_t      *outlen
    , int          flags
    ) ;
```

Wrapper function to decode a plain string of given length.
Output is written to `out` without trailing zero. Output length in bytes is written to `outlen`.
The buffer in `out` has been allocated by the caller and is at least 3/4 the size of the input.
Returns `1` for success, and `0` when a decode error has occured due to invalid input.
Returns `-1` if the chosen codec is not included in the current build.

#### base64_stream_decode_init

```c
void base64_stream_decode_init
    ( struct base64_state  *state
    , int                   flags
    ) ;
```

Call this before calling `base64_stream_decode()` to init the state.

#### base64_stream_decode

```c
int base64_stream_decode
    ( struct base64_state  *state
    , const char           *src
    , size_t                srclen
    , char                 *out
    , size_t               *outlen
    ) ;
```

Decodes the block of data of given length at `src`, into the buffer at `out`.
Caller is responsible for allocating a large enough out-buffer; it must be at least 3/4 the size of the in-buffer, but take some margin.
Places the number of new bytes written into `outlen` (which is set to zero when the function starts).
Does not zero-terminate the output.
Returns 1 if all is well, and 0 if a decoding error was found, such as an invalid character.
Returns -1 if the chosen codec is not included in the current build.
Used by the test harness to check whether a codec is available for testing.

## Examples

A simple example of encoding a static string to base64 and printing the output
to stdout:

```c
#include <stdio.h>	/* fwrite */
#include "libbase64.h"

int main ()
{
	char src[] = "hello world";
	char out[20];
	size_t srclen = sizeof(src) - 1;
	size_t outlen;

	base64_encode(src, srclen, out, &outlen, 0);

	fwrite(out, outlen, 1, stdout);

	return 0;
}
```

A simple example (no error checking, etc) of stream encoding standard input to
standard output:

```c
#include <stdio.h>
#include "libbase64.h"

int main ()
{
	size_t nread, nout;
	char buf[12000], out[16000];
	struct base64_state state;

	// Initialize stream encoder:
	base64_stream_encode_init(&state, 0);

	// Read contents of stdin into buffer:
	while ((nread = fread(buf, 1, sizeof(buf), stdin)) > 0) {

		// Encode buffer:
		base64_stream_encode(&state, buf, nread, out, &nout);

		// If there's output, print it to stdout:
		if (nout) {
			fwrite(out, nout, 1, stdout);
		}

		// If an error occurred, exit the loop:
		if (feof(stdin)) {
			break;
		}
	}

	// Finalize encoding:
	base64_stream_encode_final(&state, out, &nout);

	// If the finalizing resulted in extra output bytes, print them:
	if (nout) {
		fwrite(out, nout, 1, stdout);
	}

	return 0;
}
```

Also see `bin/base64.c` for a simple re-implementation of the `base64` utility.
A file or standard input is fed through the encoder/decoder, and the output is
written to standard output.

## Tests

See `tests/` for a small test suite. Testing is automated with
[GitHub Actions](https://github.com/aklomp/base64/actions), which builds and
tests the code across various architectures.

## Benchmarks

Benchmarks can be run with the built-in benchmark program as follows:

```sh
make -C test benchmark <buildflags> && test/benchmark
```

It will run an encoding and decoding benchmark for all of the compiled-in codecs.

The tables below contain some results on random machines. All numbers measured with a 10MB buffer in MB/sec, rounded to the nearest integer.

\*: Update needed

x86 processors

| Processor                                 | Plain enc | Plain dec | SSSE3 enc | SSSE3 dec | AVX enc | AVX dec | AVX2 enc | AVX2 dec |
|-------------------------------------------|----------:|----------:|----------:|----------:|--------:|--------:|---------:|---------:|
| i7-4771 @ 3.5 GHz                         | 833\*     | 1111\*    | 3333\*    | 4444\*    | TBD     | TBD     | 4999\*   | 6666\*   |
| i7-4770 @ 3.4 GHz DDR1600                 | 1790\*    | 3038\*    | 4899\*    | 4043\*    | 4796\*  | 5709\*  | 4681\*   | 6386\*   |
| i7-4770 @ 3.4 GHz DDR1600 OPENMP 1 thread | 1784\*    | 3041\*    | 4945\*    | 4035\*    | 4776\*  | 5719\*  | 4661\*   | 6294\*   |
| i7-4770 @ 3.4 GHz DDR1600 OPENMP 2 thread | 3401\*    | 5729\*    | 5489\*    | 7444\*    | 5003\*  | 8624\*  | 5105\*   | 8558\*   |
| i7-4770 @ 3.4 GHz DDR1600 OPENMP 4 thread | 4884\*    | 7099\*    | 4917\*    | 7057\*    | 4799\*  | 7143\*  | 4902\*   | 7219\*   |
| i7-4770 @ 3.4 GHz DDR1600 OPENMP 8 thread | 5212\*    | 8849\*    | 5284\*    | 9099\*    | 5289\*  | 9220\*  | 4849\*   | 9200\*   |
| i7-4870HQ @ 2.5 GHz                       | 1471\*    | 3066\*    | 6721\*    | 6962\*    | 7015\*  | 8267\*  | 8328\*   | 11576\*  |
| i5-4590S @ 3.0 GHz                        | 3356      | 3197      | 4363      | 6104      | 4243\*  | 6233    | 4160\*   | 6344     |
| Xeon X5570 @ 2.93 GHz                     | 2161      | 1508      | 3160      | 3915      | -       | -       | -        | -        |
| Pentium4 @ 3.4 GHz                        | 896       | 740       | -         | -         | -       | -       | -        | -        |
| Atom N270                                 | 243       | 266       | 508       | 387       | -       | -       | -        | -        |
| AMD E-450                                 | 645       | 564       | 625       | 634       | -       | -       | -        | -        |
| Intel Edison @ 500 MHz                    | 79\*      | 92\*      | 152\*     | 172\*     | -       | -       | -        | -        |
| Intel Edison @ 500 MHz OPENMP 2 thread    | 158\*     | 184\*     | 300\*     | 343\*     | -       | -       | -        | -        |
| Intel Edison @ 500 MHz (x86-64)           | 162       | 119       | 209       | 164       | -       | -       | -        | -        |
| Intel Edison @ 500 MHz (x86-64) 2 thread  | 319       | 237       | 412       | 329       | -       | -       | -        | -        |

ARM processors

| Processor                                 | Plain enc | Plain dec | NEON32 enc | NEON32 dec | NEON64 enc | NEON64 dec |
|-------------------------------------------|----------:|----------:|-----------:|-----------:|-----------:|-----------:|
| Raspberry PI B+ V1.2                      | 46\*      | 40\*      | -          | -          | -          | -          |
| Raspberry PI 2 B V1.1                     | 85        | 141       | 300        | 225        | -          | -          |
| Apple iPhone SE armv7                     | 1056\*    | 895\*     | 2943\*     | 2618\*     | -          | -          |
| Apple iPhone SE arm64                     | 1061\*    | 1239\*    | -          | -          | 4098\*     | 3983\*     |

PowerPC processors

| Processor                                 | Plain enc | Plain dec |
|-------------------------------------------|----------:|----------:|
| PowerPC E6500 @ 1.8GHz                    | 270\*     | 265\*     |


Benchmarks on i7-4770 @ 3.4 GHz DDR1600 with varrying buffer sizes:
![Benchmarks](base64-benchmarks.png)

Note: optimal buffer size to take advantage of the cache is in the range of 100 kB to 1 MB, leading to 12x faster AVX encoding/decoding compared to Plain, or a throughput of 24/27GB/sec.
Also note the performance degradation when the buffer size is less than 10 kB due to thread creation overhead.
To prevent this from happening `lib_openmp.c` defines `OMP_THRESHOLD 20000`, requiring at least a 20000 byte buffer to enable multithreading.

## License

This repository is licensed under the
[BSD 2-clause License](http://opensource.org/licenses/BSD-2-Clause). See the
LICENSE file.


================================================
FILE: 3rdparty/base64/config.h
================================================


================================================
FILE: 3rdparty/base64/include/libbase64.h
================================================
#ifndef LIBBASE64_H
#define LIBBASE64_H

#include <stddef.h>	/* size_t */


#if defined(_WIN32) || defined(__CYGWIN__)
#define BASE64_SYMBOL_IMPORT __declspec(dllimport)
#define BASE64_SYMBOL_EXPORT __declspec(dllexport)
#define BASE64_SYMBOL_PRIVATE

#elif __GNUC__ >= 4
#define BASE64_SYMBOL_IMPORT   __attribute__ ((visibility ("default")))
#define BASE64_SYMBOL_EXPORT   __attribute__ ((visibility ("default")))
#define BASE64_SYMBOL_PRIVATE  __attribute__ ((visibility ("hidden")))

#else
#define BASE64_SYMBOL_IMPORT
#define BASE64_SYMBOL_EXPORT
#define BASE64_SYMBOL_PRIVATE
#endif

#if defined(BASE64_STATIC_DEFINE)
#define BASE64_EXPORT
#define BASE64_NO_EXPORT

#else
#if defined(BASE64_EXPORTS) // defined if we are building the shared library
#define BASE64_EXPORT BASE64_SYMBOL_EXPORT

#else
#define BASE64_EXPORT BASE64_SYMBOL_IMPORT
#endif

#define BASE64_NO_EXPORT BASE64_SYMBOL_PRIVATE
#endif


#ifdef __cplusplus
extern "C" {
#endif

/* These are the flags that can be passed in the `flags` argument. The values
 * below force the use of a given codec, even if that codec is a no-op in the
 * current build. Used in testing. Set to 0 for the default behavior, which is
 * runtime feature detection on x86, a compile-time fixed codec on ARM, and
 * the plain codec on other platforms: */
#define BASE64_FORCE_AVX2	(1 << 0)
#define BASE64_FORCE_NEON32	(1 << 1)
#define BASE64_FORCE_NEON64	(1 << 2)
#define BASE64_FORCE_PLAIN	(1 << 3)
#define BASE64_FORCE_SSSE3	(1 << 4)
#define BASE64_FORCE_SSE41	(1 << 5)
#define BASE64_FORCE_SSE42	(1 << 6)
#define BASE64_FORCE_AVX	(1 << 7)
#define BASE64_FORCE_AVX512	(1 << 8)

struct base64_state {
	int eof;
	int bytes;
	int flags;
	unsigned char carry;
};

/* Wrapper function to encode a plain string of given length. Output is written
 * to *out without trailing zero. Output length in bytes is written to *outlen.
 * The buffer in `out` has been allocated by the caller and is at least 4/3 the
 * size of the input. See above for `flags`; set to 0 for default operation: */
void BASE64_EXPORT base64_encode
	( const char		*src
	, size_t		 srclen
	, char			*out
	, size_t		*outlen
	, int			 flags
	) ;

/* Call this before calling base64_stream_encode() to init the state. See above
 * for `flags`; set to 0 for default operation: */
void BASE64_EXPORT base64_stream_encode_init
	( struct base64_state	*state
	, int			 flags
	) ;

/* Encodes the block of data of given length at `src`, into the buffer at
 * `out`. Caller is responsible for allocating a large enough out-buffer; it
 * must be at least 4/3 the size of the in-buffer, but take some margin. Places
 * the number of new bytes written into `outlen` (which is set to zero when the
 * function starts). Does not zero-terminate or finalize the output. */
void BASE64_EXPORT base64_stream_encode
	( struct base64_state	*state
	, const char		*src
	, size_t		 srclen
	, char			*out
	, size_t		*outlen
	) ;

/* Finalizes the output begun by previous calls to `base64_stream_encode()`.
 * Adds the required end-of-stream markers if appropriate. `outlen` is modified
 * and will contain the number of new bytes written at `out` (which will quite
 * often be zero). */
void BASE64_EXPORT base64_stream_encode_final
	( struct base64_state	*state
	, char			*out
	, size_t		*outlen
	) ;

/* Wrapper function to decode a plain string of given length. Output is written
 * to *out without trailing zero. Output length in bytes is written to *outlen.
 * The buffer in `out` has been allocated by the caller and is at least 3/4 the
 * size of the input. See above for `flags`, set to 0 for default operation: */
int BASE64_EXPORT base64_decode
	( const char		*src
	, size_t		 srclen
	, char			*out
	, size_t		*outlen
	, int			 flags
	) ;

/* Call this before calling base64_stream_decode() to init the state. See above
 * for `flags`; set to 0 for default operation: */
void BASE64_EXPORT base64_stream_decode_init
	( struct base64_state	*state
	, int			 flags
	) ;

/* Decodes the block of data of given length at `src`, into the buffer at
 * `out`. Caller is responsible for allocating a large enough out-buffer; it
 * must be at least 3/4 the size of the in-buffer, but take some margin. Places
 * the number of new bytes written into `outlen` (which is set to zero when the
 * function starts). Does not zero-terminate the output. Returns 1 if all is
 * well, and 0 if a decoding error was found, such as an invalid character.
 * Returns -1 if the chosen codec is not included in the current build. Used by
 * the test harness to check whether a codec is available for testing. */
int BASE64_EXPORT base64_stream_decode
	( struct base64_state	*state
	, const char		*src
	, size_t		 srclen
	, char			*out
	, size_t		*outlen
	) ;

#ifdef __cplusplus
}
#endif

#endif /* LIBBASE64_H */


================================================
FILE: 3rdparty/base64/lib/arch/avx/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if HAVE_AVX
#include <immintrin.h>

// Only enable inline assembly on supported compilers and on 64-bit CPUs.
#ifndef BASE64_AVX_USE_ASM
# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
#  define BASE64_AVX_USE_ASM 1
# else
#  define BASE64_AVX_USE_ASM 0
# endif
#endif

#include "../ssse3/dec_reshuffle.c"
#include "../ssse3/dec_loop.c"

#if BASE64_AVX_USE_ASM
# include "enc_loop_asm.c"
#else
# include "../ssse3/enc_translate.c"
# include "../ssse3/enc_reshuffle.c"
# include "../ssse3/enc_loop.c"
#endif

#endif	// HAVE_AVX

BASE64_ENC_FUNCTION(avx)
{
#if HAVE_AVX
	#include "../generic/enc_head.c"

	// For supported compilers, use a hand-optimized inline assembly
	// encoder. Otherwise fall back on the SSSE3 encoder, but compiled with
	// AVX flags to generate better optimized AVX code.

#if BASE64_AVX_USE_ASM
	enc_loop_avx(&s, &slen, &o, &olen);
#else
	enc_loop_ssse3(&s, &slen, &o, &olen);
#endif

	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(avx)
{
#if HAVE_AVX
	#include "../generic/dec_head.c"
	dec_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/avx/enc_loop_asm.c
================================================
// Apologies in advance for combining the preprocessor with inline assembly,
// two notoriously gnarly parts of C, but it was necessary to avoid a lot of
// code repetition. The preprocessor is used to template large sections of
// inline assembly that differ only in the registers used. If the code was
// written out by hand, it would become very large and hard to audit.

// Generate a block of inline assembly that loads register R0 from memory. The
// offset at which the register is loaded is set by the given round.
#define LOAD(R0, ROUND) \
	"vlddqu ("#ROUND" * 12)(%[src]), %["R0"] \n\t"

// Generate a block of inline assembly that deinterleaves and shuffles register
// R0 using preloaded constants. Outputs in R0 and R1.
#define SHUF(R0, R1, R2) \
	"vpshufb  %[lut0], %["R0"], %["R1"] \n\t" \
	"vpand    %["R1"], %[msk0], %["R2"] \n\t" \
	"vpand    %["R1"], %[msk2], %["R1"] \n\t" \
	"vpmulhuw %["R2"], %[msk1], %["R2"] \n\t" \
	"vpmullw  %["R1"], %[msk3], %["R1"] \n\t" \
	"vpor     %["R1"], %["R2"], %["R1"] \n\t"

// Generate a block of inline assembly that takes R0 and R1 and translates
// their contents to the base64 alphabet, using preloaded constants.
#define TRAN(R0, R1, R2) \
	"vpsubusb %[n51],  %["R1"], %["R0"] \n\t" \
	"vpcmpgtb %[n25],  %["R1"], %["R2"] \n\t" \
	"vpsubb   %["R2"], %["R0"], %["R0"] \n\t" \
	"vpshufb  %["R0"], %[lut1], %["R2"] \n\t" \
	"vpaddb   %["R1"], %["R2"], %["R0"] \n\t"

// Generate a block of inline assembly that stores the given register R0 at an
// offset set by the given round.
#define STOR(R0, ROUND) \
	"vmovdqu %["R0"], ("#ROUND" * 16)(%[dst]) \n\t"

// Generate a block of inline assembly that generates a single self-contained
// encoder round: fetch the data, process it, and store the result. Then update
// the source and destination pointers.
#define ROUND() \
	LOAD("a", 0) \
	SHUF("a", "b", "c") \
	TRAN("a", "b", "c") \
	STOR("a", 0) \
	"add $12, %[src] \n\t" \
	"add $16, %[dst] \n\t"

// Define a macro that initiates a three-way interleaved encoding round by
// preloading registers a, b and c from memory.
// The register graph shows which registers are in use during each step, and
// is a visual aid for choosing registers for that step. Symbol index:
//
//  +  indicates that a register is loaded by that step.
//  |  indicates that a register is in use and must not be touched.
//  -  indicates that a register is decommissioned by that step.
//  x  indicates that a register is used as a temporary by that step.
//  V  indicates that a register is an input or output to the macro.
//
#define ROUND_3_INIT() 			/*  a b c d e f  */ \
	LOAD("a",   0)			/*  +            */ \
	SHUF("a", "d", "e")		/*  |     + x    */ \
	LOAD("b",   1)			/*  | +   |      */ \
	TRAN("a", "d", "e")		/*  | |   - x    */ \
	LOAD("c",   2)			/*  V V V        */

// Define a macro that translates, shuffles and stores the input registers A, B
// and C, and preloads registers D, E and F for the next round.
// This macro can be arbitrarily daisy-chained by feeding output registers D, E
// and F back into the next round as input registers A, B and C. The macro
// carefully interleaves memory operations with data operations for optimal
// pipelined performance.

#define ROUND_3(ROUND, A,B,C,D,E,F) 	/*  A B C D E F  */ \
	LOAD(D, (ROUND + 3))		/*  V V V +      */ \
	SHUF(B, E, F)			/*  | | | | + x  */ \
	STOR(A, (ROUND + 0))		/*  - | | | |    */ \
	TRAN(B, E, F)			/*    | | | - x  */ \
	LOAD(E, (ROUND + 4))		/*    | | | +    */ \
	SHUF(C, A, F)			/*  + | | | | x  */ \
	STOR(B, (ROUND + 1))		/*  | - | | |    */ \
	TRAN(C, A, F)			/*  -   | | | x  */ \
	LOAD(F, (ROUND + 5))		/*      | | | +  */ \
	SHUF(D, A, B)			/*  + x | | | |  */ \
	STOR(C, (ROUND + 2))		/*  |   - | | |  */ \
	TRAN(D, A, B)			/*  - x   V V V  */

// Define a macro that terminates a ROUND_3 macro by taking pre-loaded
// registers D, E and F, and translating, shuffling and storing them.
#define ROUND_3_END(ROUND, A,B,C,D,E,F)	/*  A B C D E F  */ \
	SHUF(E, A, B)			/*  + x   V V V  */ \
	STOR(D, (ROUND + 3))		/*  |     - | |  */ \
	TRAN(E, A, B)			/*  - x     | |  */ \
	SHUF(F, C, D)			/*      + x | |  */ \
	STOR(E, (ROUND + 4))		/*      |   - |  */ \
	TRAN(F, C, D)			/*      - x   |  */ \
	STOR(F, (ROUND + 5))		/*            -  */

// Define a type A round. Inputs are a, b, and c, outputs are d, e, and f.
#define ROUND_3_A(ROUND) \
	ROUND_3(ROUND, "a", "b", "c", "d", "e", "f")

// Define a type B round. Inputs and outputs are swapped with regard to type A.
#define ROUND_3_B(ROUND) \
	ROUND_3(ROUND, "d", "e", "f", "a", "b", "c")

// Terminating macro for a type A round.
#define ROUND_3_A_LAST(ROUND) \
	ROUND_3_A(ROUND) \
	ROUND_3_END(ROUND, "a", "b", "c", "d", "e", "f")

// Terminating macro for a type B round.
#define ROUND_3_B_LAST(ROUND) \
	ROUND_3_B(ROUND) \
	ROUND_3_END(ROUND, "d", "e", "f", "a", "b", "c")

// Suppress clang's warning that the literal string in the asm statement is
// overlong (longer than the ISO-mandated minimum size of 4095 bytes for C99
// compilers). It may be true, but the goal here is not C99 portability.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverlength-strings"

static inline void
enc_loop_avx (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	// For a clearer explanation of the algorithm used by this function,
	// please refer to the plain (not inline assembly) implementation. This
	// function follows the same basic logic.

	if (*slen < 16) {
		return;
	}

	// Process blocks of 12 bytes at a time. Input is read in blocks of 16
	// bytes, so "reserve" four bytes from the input buffer to ensure that
	// we never read beyond the end of the input buffer.
	size_t rounds = (*slen - 4) / 12;

	*slen -= rounds * 12;   // 12 bytes consumed per round
	*olen += rounds * 16;   // 16 bytes produced per round

	// Number of times to go through the 36x loop.
	size_t loops = rounds / 36;

	// Number of rounds remaining after the 36x loop.
	rounds %= 36;

	// Lookup tables.
	const __m128i lut0 = _mm_set_epi8(
		10, 11,  9, 10,  7,  8,  6,  7,  4,  5,  3,  4,  1,  2,  0,  1);

	const __m128i lut1 = _mm_setr_epi8(
		65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0);

	// Temporary registers.
	__m128i a, b, c, d, e, f;

	__asm__ volatile (

		// If there are 36 rounds or more, enter a 36x unrolled loop of
		// interleaved encoding rounds. The rounds interleave memory
		// operations (load/store) with data operations (table lookups,
		// etc) to maximize pipeline throughput.
		"    test %[loops], %[loops] \n\t"
		"    jz   18f                \n\t"
		"    jmp  36f                \n\t"
		"                            \n\t"
		".balign 64                  \n\t"
		"36: " ROUND_3_INIT()
		"    " ROUND_3_A( 0)
		"    " ROUND_3_B( 3)
		"    " ROUND_3_A( 6)
		"    " ROUND_3_B( 9)
		"    " ROUND_3_A(12)
		"    " ROUND_3_B(15)
		"    " ROUND_3_A(18)
		"    " ROUND_3_B(21)
		"    " ROUND_3_A(24)
		"    " ROUND_3_B(27)
		"    " ROUND_3_A_LAST(30)
		"    add $(12 * 36), %[src] \n\t"
		"    add $(16 * 36), %[dst] \n\t"
		"    dec %[loops]           \n\t"
		"    jnz 36b                \n\t"

		// Enter an 18x unrolled loop for rounds of 18 or more.
		"18: cmp $18, %[rounds] \n\t"
		"    jl  9f             \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A(0)
		"    " ROUND_3_B(3)
		"    " ROUND_3_A(6)
		"    " ROUND_3_B(9)
		"    " ROUND_3_A_LAST(12)
		"    sub $18,        %[rounds] \n\t"
		"    add $(12 * 18), %[src]    \n\t"
		"    add $(16 * 18), %[dst]    \n\t"

		// Enter a 9x unrolled loop for rounds of 9 or more.
		"9:  cmp $9, %[rounds] \n\t"
		"    jl  6f            \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A(0)
		"    " ROUND_3_B_LAST(3)
		"    sub $9,        %[rounds] \n\t"
		"    add $(12 * 9), %[src]    \n\t"
		"    add $(16 * 9), %[dst]    \n\t"

		// Enter a 6x unrolled loop for rounds of 6 or more.
		"6:  cmp $6, %[rounds] \n\t"
		"    jl  55f           \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A_LAST(0)
		"    sub $6,        %[rounds] \n\t"
		"    add $(12 * 6), %[src]    \n\t"
		"    add $(16 * 6), %[dst]    \n\t"

		// Dispatch the remaining rounds 0..5.
		"55: cmp $3, %[rounds] \n\t"
		"    jg  45f           \n\t"
		"    je  3f            \n\t"
		"    cmp $1, %[rounds] \n\t"
		"    jg  2f            \n\t"
		"    je  1f            \n\t"
		"    jmp 0f            \n\t"

		"45: cmp $4, %[rounds] \n\t"
		"    je  4f            \n\t"

		// Block of non-interlaced encoding rounds, which can each
		// individually be jumped to. Rounds fall through to the next.
		"5: " ROUND()
		"4: " ROUND()
		"3: " ROUND()
		"2: " ROUND()
		"1: " ROUND()
		"0: \n\t"

		// Outputs (modified).
		: [rounds] "+r"  (rounds),
		  [loops]  "+r"  (loops),
		  [src]    "+r"  (*s),
		  [dst]    "+r"  (*o),
		  [a]      "=&x" (a),
		  [b]      "=&x" (b),
		  [c]      "=&x" (c),
		  [d]      "=&x" (d),
		  [e]      "=&x" (e),
		  [f]      "=&x" (f)

		// Inputs (not modified).
		: [lut0] "x" (lut0),
		  [lut1] "x" (lut1),
		  [msk0] "x" (_mm_set1_epi32(0x0FC0FC00)),
		  [msk1] "x" (_mm_set1_epi32(0x04000040)),
		  [msk2] "x" (_mm_set1_epi32(0x003F03F0)),
		  [msk3] "x" (_mm_set1_epi32(0x01000010)),
		  [n51]  "x" (_mm_set1_epi8(51)),
		  [n25]  "x" (_mm_set1_epi8(25))

		// Clobbers.
		: "cc", "memory"
	);
}

#pragma GCC diagnostic pop


================================================
FILE: 3rdparty/base64/lib/arch/avx2/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if HAVE_AVX2
#include <immintrin.h>

// Only enable inline assembly on supported compilers and on 64-bit CPUs.
#ifndef BASE64_AVX2_USE_ASM
# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
#  define BASE64_AVX2_USE_ASM 1
# else
#  define BASE64_AVX2_USE_ASM 0
# endif
#endif

#include "dec_reshuffle.c"
#include "dec_loop.c"

#if BASE64_AVX2_USE_ASM
# include "enc_loop_asm.c"
#else
# include "enc_translate.c"
# include "enc_reshuffle.c"
# include "enc_loop.c"
#endif

#endif	// HAVE_AVX2

BASE64_ENC_FUNCTION(avx2)
{
#if HAVE_AVX2
	#include "../generic/enc_head.c"
	enc_loop_avx2(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(avx2)
{
#if HAVE_AVX2
	#include "../generic/dec_head.c"
	dec_loop_avx2(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/avx2/dec_loop.c
================================================
static inline int
dec_loop_avx2_inner (const uint8_t **s, uint8_t **o, size_t *rounds)
{
	const __m256i lut_lo = _mm256_setr_epi8(
		0x15, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
		0x11, 0x11, 0x13, 0x1A, 0x1B, 0x1B, 0x1B, 0x1A,
		0x15, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
		0x11, 0x11, 0x13, 0x1A, 0x1B, 0x1B, 0x1B, 0x1A);

	const __m256i lut_hi = _mm256_setr_epi8(
		0x10, 0x10, 0x01, 0x02, 0x04, 0x08, 0x04, 0x08,
		0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
		0x10, 0x10, 0x01, 0x02, 0x04, 0x08, 0x04, 0x08,
		0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10);

	const __m256i lut_roll = _mm256_setr_epi8(
		0,  16,  19,   4, -65, -65, -71, -71,
		0,   0,   0,   0,   0,   0,   0,   0,
		0,  16,  19,   4, -65, -65, -71, -71,
		0,   0,   0,   0,   0,   0,   0,   0);

	const __m256i mask_2F = _mm256_set1_epi8(0x2F);

	// Load input:
	__m256i str = _mm256_loadu_si256((__m256i *) *s);

	// See the SSSE3 decoder for an explanation of the algorithm.
	const __m256i hi_nibbles = _mm256_and_si256(_mm256_srli_epi32(str, 4), mask_2F);
	const __m256i lo_nibbles = _mm256_and_si256(str, mask_2F);
	const __m256i hi         = _mm256_shuffle_epi8(lut_hi, hi_nibbles);
	const __m256i lo         = _mm256_shuffle_epi8(lut_lo, lo_nibbles);

	if (!_mm256_testz_si256(lo, hi)) {
		return 0;
	}

	const __m256i eq_2F = _mm256_cmpeq_epi8(str, mask_2F);
	const __m256i roll  = _mm256_shuffle_epi8(lut_roll, _mm256_add_epi8(eq_2F, hi_nibbles));

	// Now simply add the delta values to the input:
	str = _mm256_add_epi8(str, roll);

	// Reshuffle the input to packed 12-byte output format:
	str = dec_reshuffle(str);

	// Store the output:
	_mm256_storeu_si256((__m256i *) *o, str);

	*s += 32;
	*o += 24;
	*rounds -= 1;

	return 1;
}

static inline void
dec_loop_avx2 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 45) {
		return;
	}

	// Process blocks of 32 bytes per round. Because 8 extra zero bytes are
	// written after the output, ensure that there will be at least 13
	// bytes of input data left to cover the gap. (11 data bytes and up to
	// two end-of-string markers.)
	size_t rounds = (*slen - 13) / 32;

	*slen -= rounds * 32;	// 32 bytes consumed per round
	*olen += rounds * 24;	// 24 bytes produced per round

	do {
		if (rounds >= 8) {
			if (dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		if (rounds >= 4) {
			if (dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		if (rounds >= 2) {
			if (dec_loop_avx2_inner(s, o, &rounds) &&
			    dec_loop_avx2_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		dec_loop_avx2_inner(s, o, &rounds);
		break;

	} while (rounds > 0);

	// Adjust for any rounds that were skipped:
	*slen += rounds * 32;
	*olen -= rounds * 24;
}


================================================
FILE: 3rdparty/base64/lib/arch/avx2/dec_reshuffle.c
================================================
static inline __m256i
dec_reshuffle (const __m256i in)
{
	// in, lower lane, bits, upper case are most significant bits, lower
	// case are least significant bits:
	// 00llllll 00kkkkLL 00jjKKKK 00JJJJJJ
	// 00iiiiii 00hhhhII 00ggHHHH 00GGGGGG
	// 00ffffff 00eeeeFF 00ddEEEE 00DDDDDD
	// 00cccccc 00bbbbCC 00aaBBBB 00AAAAAA

	const __m256i merge_ab_and_bc = _mm256_maddubs_epi16(in, _mm256_set1_epi32(0x01400140));
	// 0000kkkk LLllllll 0000JJJJ JJjjKKKK
	// 0000hhhh IIiiiiii 0000GGGG GGggHHHH
	// 0000eeee FFffffff 0000DDDD DDddEEEE
	// 0000bbbb CCcccccc 0000AAAA AAaaBBBB

	__m256i out = _mm256_madd_epi16(merge_ab_and_bc, _mm256_set1_epi32(0x00011000));
	// 00000000 JJJJJJjj KKKKkkkk LLllllll
	// 00000000 GGGGGGgg HHHHhhhh IIiiiiii
	// 00000000 DDDDDDdd EEEEeeee FFffffff
	// 00000000 AAAAAAaa BBBBbbbb CCcccccc

	// Pack bytes together in each lane:
	out = _mm256_shuffle_epi8(out, _mm256_setr_epi8(
		2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1,
		2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1));
	// 00000000 00000000 00000000 00000000
	// LLllllll KKKKkkkk JJJJJJjj IIiiiiii
	// HHHHhhhh GGGGGGgg FFffffff EEEEeeee
	// DDDDDDdd CCcccccc BBBBbbbb AAAAAAaa

	// Pack lanes:
	return _mm256_permutevar8x32_epi32(out, _mm256_setr_epi32(0, 1, 2, 4, 5, 6, -1, -1));
}


================================================
FILE: 3rdparty/base64/lib/arch/avx2/enc_loop.c
================================================
static inline void
enc_loop_avx2_inner_first (const uint8_t **s, uint8_t **o)
{
	// First load is done at s - 0 to not get a segfault:
	__m256i src = _mm256_loadu_si256((__m256i *) *s);

	// Shift by 4 bytes, as required by enc_reshuffle:
	src = _mm256_permutevar8x32_epi32(src, _mm256_setr_epi32(0, 0, 1, 2, 3, 4, 5, 6));

	// Reshuffle, translate, store:
	src = enc_reshuffle(src);
	src = enc_translate(src);
	_mm256_storeu_si256((__m256i *) *o, src);

	// Subsequent loads will be done at s - 4, set pointer for next round:
	*s += 20;
	*o += 32;
}

static inline void
enc_loop_avx2_inner (const uint8_t **s, uint8_t **o)
{
	// Load input:
	__m256i src = _mm256_loadu_si256((__m256i *) *s);

	// Reshuffle, translate, store:
	src = enc_reshuffle(src);
	src = enc_translate(src);
	_mm256_storeu_si256((__m256i *) *o, src);

	*s += 24;
	*o += 32;
}

static inline void
enc_loop_avx2 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 32) {
		return;
	}

	// Process blocks of 24 bytes at a time. Because blocks are loaded 32
	// bytes at a time an offset of -4, ensure that there will be at least
	// 4 remaining bytes after the last round, so that the final read will
	// not pass beyond the bounds of the input buffer:
	size_t rounds = (*slen - 4) / 24;

	*slen -= rounds * 24;   // 24 bytes consumed per round
	*olen += rounds * 32;   // 32 bytes produced per round

	// The first loop iteration requires special handling to ensure that
	// the read, which is done at an offset, does not underflow the buffer:
	enc_loop_avx2_inner_first(s, o);
	rounds--;

	while (rounds > 0) {
		if (rounds >= 8) {
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_avx2_inner(s, o);
			enc_loop_avx2_inner(s, o);
			rounds -= 2;
			continue;
		}
		enc_loop_avx2_inner(s, o);
		break;
	}

	// Add the offset back:
	*s += 4;
}


================================================
FILE: 3rdparty/base64/lib/arch/avx2/enc_loop_asm.c
================================================
// Apologies in advance for combining the preprocessor with inline assembly,
// two notoriously gnarly parts of C, but it was necessary to avoid a lot of
// code repetition. The preprocessor is used to template large sections of
// inline assembly that differ only in the registers used. If the code was
// written out by hand, it would become very large and hard to audit.

// Generate a block of inline assembly that loads register R0 from memory. The
// offset at which the register is loaded is set by the given round and a
// constant offset.
#define LOAD(R0, ROUND, OFFSET) \
	"vlddqu ("#ROUND" * 24 + "#OFFSET")(%[src]), %["R0"] \n\t"

// Generate a block of inline assembly that deinterleaves and shuffles register
// R0 using preloaded constants. Outputs in R0 and R1.
#define SHUF(R0, R1, R2) \
	"vpshufb  %[lut0], %["R0"], %["R1"] \n\t" \
	"vpand    %["R1"], %[msk0], %["R2"] \n\t" \
	"vpand    %["R1"], %[msk2], %["R1"] \n\t" \
	"vpmulhuw %["R2"], %[msk1], %["R2"] \n\t" \
	"vpmullw  %["R1"], %[msk3], %["R1"] \n\t" \
	"vpor     %["R1"], %["R2"], %["R1"] \n\t"

// Generate a block of inline assembly that takes R0 and R1 and translates
// their contents to the base64 alphabet, using preloaded constants.
#define TRAN(R0, R1, R2) \
	"vpsubusb %[n51],  %["R1"], %["R0"] \n\t" \
	"vpcmpgtb %[n25],  %["R1"], %["R2"] \n\t" \
	"vpsubb   %["R2"], %["R0"], %["R0"] \n\t" \
	"vpshufb  %["R0"], %[lut1], %["R2"] \n\t" \
	"vpaddb   %["R1"], %["R2"], %["R0"] \n\t"

// Generate a block of inline assembly that stores the given register R0 at an
// offset set by the given round.
#define STOR(R0, ROUND) \
	"vmovdqu %["R0"], ("#ROUND" * 32)(%[dst]) \n\t"

// Generate a block of inline assembly that generates a single self-contained
// encoder round: fetch the data, process it, and store the result. Then update
// the source and destination pointers.
#define ROUND() \
	LOAD("a", 0, -4) \
	SHUF("a", "b", "c") \
	TRAN("a", "b", "c") \
	STOR("a", 0) \
	"add $24, %[src] \n\t" \
	"add $32, %[dst] \n\t"

// Define a macro that initiates a three-way interleaved encoding round by
// preloading registers a, b and c from memory.
// The register graph shows which registers are in use during each step, and
// is a visual aid for choosing registers for that step. Symbol index:
//
//  +  indicates that a register is loaded by that step.
//  |  indicates that a register is in use and must not be touched.
//  -  indicates that a register is decommissioned by that step.
//  x  indicates that a register is used as a temporary by that step.
//  V  indicates that a register is an input or output to the macro.
//
#define ROUND_3_INIT() 			/*  a b c d e f  */ \
	LOAD("a",   0,  -4)		/*  +            */ \
	SHUF("a", "d", "e")		/*  |     + x    */ \
	LOAD("b",   1,  -4)		/*  | +   |      */ \
	TRAN("a", "d", "e")		/*  | |   - x    */ \
	LOAD("c",   2,  -4)		/*  V V V        */

// Define a macro that translates, shuffles and stores the input registers A, B
// and C, and preloads registers D, E and F for the next round.
// This macro can be arbitrarily daisy-chained by feeding output registers D, E
// and F back into the next round as input registers A, B and C. The macro
// carefully interleaves memory operations with data operations for optimal
// pipelined performance.

#define ROUND_3(ROUND, A,B,C,D,E,F) 	/*  A B C D E F  */ \
	LOAD(D, (ROUND + 3), -4)	/*  V V V +      */ \
	SHUF(B, E, F)			/*  | | | | + x  */ \
	STOR(A, (ROUND + 0))		/*  - | | | |    */ \
	TRAN(B, E, F)			/*    | | | - x  */ \
	LOAD(E, (ROUND + 4), -4)	/*    | | | +    */ \
	SHUF(C, A, F)			/*  + | | | | x  */ \
	STOR(B, (ROUND + 1))		/*  | - | | |    */ \
	TRAN(C, A, F)			/*  -   | | | x  */ \
	LOAD(F, (ROUND + 5), -4)	/*      | | | +  */ \
	SHUF(D, A, B)			/*  + x | | | |  */ \
	STOR(C, (ROUND + 2))		/*  |   - | | |  */ \
	TRAN(D, A, B)			/*  - x   V V V  */

// Define a macro that terminates a ROUND_3 macro by taking pre-loaded
// registers D, E and F, and translating, shuffling and storing them.
#define ROUND_3_END(ROUND, A,B,C,D,E,F)	/*  A B C D E F  */ \
	SHUF(E, A, B)			/*  + x   V V V  */ \
	STOR(D, (ROUND + 3))		/*  |     - | |  */ \
	TRAN(E, A, B)			/*  - x     | |  */ \
	SHUF(F, C, D)			/*      + x | |  */ \
	STOR(E, (ROUND + 4))		/*      |   - |  */ \
	TRAN(F, C, D)			/*      - x   |  */ \
	STOR(F, (ROUND + 5))		/*            -  */

// Define a type A round. Inputs are a, b, and c, outputs are d, e, and f.
#define ROUND_3_A(ROUND) \
	ROUND_3(ROUND, "a", "b", "c", "d", "e", "f")

// Define a type B round. Inputs and outputs are swapped with regard to type A.
#define ROUND_3_B(ROUND) \
	ROUND_3(ROUND, "d", "e", "f", "a", "b", "c")

// Terminating macro for a type A round.
#define ROUND_3_A_LAST(ROUND) \
	ROUND_3_A(ROUND) \
	ROUND_3_END(ROUND, "a", "b", "c", "d", "e", "f")

// Terminating macro for a type B round.
#define ROUND_3_B_LAST(ROUND) \
	ROUND_3_B(ROUND) \
	ROUND_3_END(ROUND, "d", "e", "f", "a", "b", "c")

// Suppress clang's warning that the literal string in the asm statement is
// overlong (longer than the ISO-mandated minimum size of 4095 bytes for C99
// compilers). It may be true, but the goal here is not C99 portability.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverlength-strings"

static inline void
enc_loop_avx2 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	// For a clearer explanation of the algorithm used by this function,
	// please refer to the plain (not inline assembly) implementation. This
	// function follows the same basic logic.

	if (*slen < 32) {
		return;
	}

	// Process blocks of 24 bytes at a time. Because blocks are loaded 32
	// bytes at a time an offset of -4, ensure that there will be at least
	// 4 remaining bytes after the last round, so that the final read will
	// not pass beyond the bounds of the input buffer.
	size_t rounds = (*slen - 4) / 24;

	*slen -= rounds * 24;   // 24 bytes consumed per round
	*olen += rounds * 32;   // 32 bytes produced per round

	// Pre-decrement the number of rounds to get the number of rounds
	// *after* the first round, which is handled as a special case.
	rounds--;

	// Number of times to go through the 36x loop.
	size_t loops = rounds / 36;

	// Number of rounds remaining after the 36x loop.
	rounds %= 36;

	// Lookup tables.
	const __m256i lut0 = _mm256_set_epi8(
		10, 11,  9, 10,  7,  8,  6,  7,  4,  5,  3,  4,  1,  2,  0,  1,
		14, 15, 13, 14, 11, 12, 10, 11,  8,  9,  7,  8,  5,  6,  4,  5);

	const __m256i lut1 = _mm256_setr_epi8(
		65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0,
		65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0);

	// Temporary registers.
	__m256i a, b, c, d, e;

	// Temporary register f doubles as the shift mask for the first round.
	__m256i f = _mm256_setr_epi32(0, 0, 1, 2, 3, 4, 5, 6);

	__asm__ volatile (

		// The first loop iteration requires special handling to ensure
		// that the read, which is normally done at an offset of -4,
		// does not underflow the buffer. Load the buffer at an offset
		// of 0 and permute the input to achieve the same effect.
		LOAD("a", 0, 0)
		"vpermd %[a], %[f], %[a] \n\t"

		// Perform the standard shuffling and translation steps.
		SHUF("a", "b", "c")
		TRAN("a", "b", "c")

		// Store the result and increment the source and dest pointers.
		"vmovdqu %[a], (%[dst]) \n\t"
		"add     $24,  %[src]   \n\t"
		"add     $32,  %[dst]   \n\t"

		// If there are 36 rounds or more, enter a 36x unrolled loop of
		// interleaved encoding rounds. The rounds interleave memory
		// operations (load/store) with data operations (table lookups,
		// etc) to maximize pipeline throughput.
		"    test %[loops], %[loops] \n\t"
		"    jz   18f                \n\t"
		"    jmp  36f                \n\t"
		"                            \n\t"
		".balign 64                  \n\t"
		"36: " ROUND_3_INIT()
		"    " ROUND_3_A( 0)
		"    " ROUND_3_B( 3)
		"    " ROUND_3_A( 6)
		"    " ROUND_3_B( 9)
		"    " ROUND_3_A(12)
		"    " ROUND_3_B(15)
		"    " ROUND_3_A(18)
		"    " ROUND_3_B(21)
		"    " ROUND_3_A(24)
		"    " ROUND_3_B(27)
		"    " ROUND_3_A_LAST(30)
		"    add $(24 * 36), %[src] \n\t"
		"    add $(32 * 36), %[dst] \n\t"
		"    dec %[loops]           \n\t"
		"    jnz 36b                \n\t"

		// Enter an 18x unrolled loop for rounds of 18 or more.
		"18: cmp $18, %[rounds] \n\t"
		"    jl  9f             \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A(0)
		"    " ROUND_3_B(3)
		"    " ROUND_3_A(6)
		"    " ROUND_3_B(9)
		"    " ROUND_3_A_LAST(12)
		"    sub $18,        %[rounds] \n\t"
		"    add $(24 * 18), %[src]    \n\t"
		"    add $(32 * 18), %[dst]    \n\t"

		// Enter a 9x unrolled loop for rounds of 9 or more.
		"9:  cmp $9, %[rounds] \n\t"
		"    jl  6f            \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A(0)
		"    " ROUND_3_B_LAST(3)
		"    sub $9,        %[rounds] \n\t"
		"    add $(24 * 9), %[src]    \n\t"
		"    add $(32 * 9), %[dst]    \n\t"

		// Enter a 6x unrolled loop for rounds of 6 or more.
		"6:  cmp $6, %[rounds] \n\t"
		"    jl  55f           \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A_LAST(0)
		"    sub $6,        %[rounds] \n\t"
		"    add $(24 * 6), %[src]    \n\t"
		"    add $(32 * 6), %[dst]    \n\t"

		// Dispatch the remaining rounds 0..5.
		"55: cmp $3, %[rounds] \n\t"
		"    jg  45f           \n\t"
		"    je  3f            \n\t"
		"    cmp $1, %[rounds] \n\t"
		"    jg  2f            \n\t"
		"    je  1f            \n\t"
		"    jmp 0f            \n\t"

		"45: cmp $4, %[rounds] \n\t"
		"    je  4f            \n\t"

		// Block of non-interlaced encoding rounds, which can each
		// individually be jumped to. Rounds fall through to the next.
		"5: " ROUND()
		"4: " ROUND()
		"3: " ROUND()
		"2: " ROUND()
		"1: " ROUND()
		"0: \n\t"

		// Outputs (modified).
		: [rounds] "+r"  (rounds),
		  [loops]  "+r"  (loops),
		  [src]    "+r"  (*s),
		  [dst]    "+r"  (*o),
		  [a]      "=&x" (a),
		  [b]      "=&x" (b),
		  [c]      "=&x" (c),
		  [d]      "=&x" (d),
		  [e]      "=&x" (e),
		  [f]      "+x"  (f)

		// Inputs (not modified).
		: [lut0] "x" (lut0),
		  [lut1] "x" (lut1),
		  [msk0] "x" (_mm256_set1_epi32(0x0FC0FC00)),
		  [msk1] "x" (_mm256_set1_epi32(0x04000040)),
		  [msk2] "x" (_mm256_set1_epi32(0x003F03F0)),
		  [msk3] "x" (_mm256_set1_epi32(0x01000010)),
		  [n51]  "x" (_mm256_set1_epi8(51)),
		  [n25]  "x" (_mm256_set1_epi8(25))

		// Clobbers.
		: "cc", "memory"
	);
}

#pragma GCC diagnostic pop


================================================
FILE: 3rdparty/base64/lib/arch/avx2/enc_reshuffle.c
================================================
static inline __m256i
enc_reshuffle (const __m256i input)
{
	// Translation of the SSSE3 reshuffling algorithm to AVX2. This one
	// works with shifted (4 bytes) input in order to be able to work
	// efficiently in the two 128-bit lanes.

	// Input, bytes MSB to LSB:
	// 0 0 0 0 x w v u t s r q p o n m
	// l k j i h g f e d c b a 0 0 0 0

	const __m256i in = _mm256_shuffle_epi8(input, _mm256_set_epi8(
		10, 11,  9, 10,
		 7,  8,  6,  7,
		 4,  5,  3,  4,
		 1,  2,  0,  1,

		14, 15, 13, 14,
		11, 12, 10, 11,
		 8,  9,  7,  8,
		 5,  6,  4,  5));
	// in, bytes MSB to LSB:
	// w x v w
	// t u s t
	// q r p q
	// n o m n
	// k l j k
	// h i g h
	// e f d e
	// b c a b

	const __m256i t0 = _mm256_and_si256(in, _mm256_set1_epi32(0x0FC0FC00));
	// bits, upper case are most significant bits, lower case are least
	// significant bits.
	// 0000wwww XX000000 VVVVVV00 00000000
	// 0000tttt UU000000 SSSSSS00 00000000
	// 0000qqqq RR000000 PPPPPP00 00000000
	// 0000nnnn OO000000 MMMMMM00 00000000
	// 0000kkkk LL000000 JJJJJJ00 00000000
	// 0000hhhh II000000 GGGGGG00 00000000
	// 0000eeee FF000000 DDDDDD00 00000000
	// 0000bbbb CC000000 AAAAAA00 00000000

	const __m256i t1 = _mm256_mulhi_epu16(t0, _mm256_set1_epi32(0x04000040));
	// 00000000 00wwwwXX 00000000 00VVVVVV
	// 00000000 00ttttUU 00000000 00SSSSSS
	// 00000000 00qqqqRR 00000000 00PPPPPP
	// 00000000 00nnnnOO 00000000 00MMMMMM
	// 00000000 00kkkkLL 00000000 00JJJJJJ
	// 00000000 00hhhhII 00000000 00GGGGGG
	// 00000000 00eeeeFF 00000000 00DDDDDD
	// 00000000 00bbbbCC 00000000 00AAAAAA

	const __m256i t2 = _mm256_and_si256(in, _mm256_set1_epi32(0x003F03F0));
	// 00000000 00xxxxxx 000000vv WWWW0000
	// 00000000 00uuuuuu 000000ss TTTT0000
	// 00000000 00rrrrrr 000000pp QQQQ0000
	// 00000000 00oooooo 000000mm NNNN0000
	// 00000000 00llllll 000000jj KKKK0000
	// 00000000 00iiiiii 000000gg HHHH0000
	// 00000000 00ffffff 000000dd EEEE0000
	// 00000000 00cccccc 000000aa BBBB0000

	const __m256i t3 = _mm256_mullo_epi16(t2, _mm256_set1_epi32(0x01000010));
	// 00xxxxxx 00000000 00vvWWWW 00000000
	// 00uuuuuu 00000000 00ssTTTT 00000000
	// 00rrrrrr 00000000 00ppQQQQ 00000000
	// 00oooooo 00000000 00mmNNNN 00000000
	// 00llllll 00000000 00jjKKKK 00000000
	// 00iiiiii 00000000 00ggHHHH 00000000
	// 00ffffff 00000000 00ddEEEE 00000000
	// 00cccccc 00000000 00aaBBBB 00000000

	return _mm256_or_si256(t1, t3);
	// 00xxxxxx 00wwwwXX 00vvWWWW 00VVVVVV
	// 00uuuuuu 00ttttUU 00ssTTTT 00SSSSSS
	// 00rrrrrr 00qqqqRR 00ppQQQQ 00PPPPPP
	// 00oooooo 00nnnnOO 00mmNNNN 00MMMMMM
	// 00llllll 00kkkkLL 00jjKKKK 00JJJJJJ
	// 00iiiiii 00hhhhII 00ggHHHH 00GGGGGG
	// 00ffffff 00eeeeFF 00ddEEEE 00DDDDDD
	// 00cccccc 00bbbbCC 00aaBBBB 00AAAAAA
}


================================================
FILE: 3rdparty/base64/lib/arch/avx2/enc_translate.c
================================================
static inline __m256i
enc_translate (const __m256i in)
{
	// A lookup table containing the absolute offsets for all ranges:
	const __m256i lut = _mm256_setr_epi8(
		65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0,
		65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0);

	// Translate values 0..63 to the Base64 alphabet. There are five sets:
	// #  From      To         Abs    Index  Characters
	// 0  [0..25]   [65..90]   +65        0  ABCDEFGHIJKLMNOPQRSTUVWXYZ
	// 1  [26..51]  [97..122]  +71        1  abcdefghijklmnopqrstuvwxyz
	// 2  [52..61]  [48..57]    -4  [2..11]  0123456789
	// 3  [62]      [43]       -19       12  +
	// 4  [63]      [47]       -16       13  /

	// Create LUT indices from the input. The index for range #0 is right,
	// others are 1 less than expected:
	__m256i indices = _mm256_subs_epu8(in, _mm256_set1_epi8(51));

	// mask is 0xFF (-1) for range #[1..4] and 0x00 for range #0:
	const __m256i mask = _mm256_cmpgt_epi8(in, _mm256_set1_epi8(25));

	// Subtract -1, so add 1 to indices for range #[1..4]. All indices are
	// now correct:
	indices = _mm256_sub_epi8(indices, mask);

	// Add offsets to input values:
	return _mm256_add_epi8(in, _mm256_shuffle_epi8(lut, indices));
}


================================================
FILE: 3rdparty/base64/lib/arch/avx512/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if HAVE_AVX512
#include <immintrin.h>

#include "../avx2/dec_reshuffle.c"
#include "../avx2/dec_loop.c"
#include "enc_reshuffle_translate.c"
#include "enc_loop.c"

#endif	// HAVE_AVX512

BASE64_ENC_FUNCTION(avx512)
{
#if HAVE_AVX512
	#include "../generic/enc_head.c"
	enc_loop_avx512(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

// Reuse AVX2 decoding. Not supporting AVX512 at present
BASE64_DEC_FUNCTION(avx512)
{
#if HAVE_AVX512
	#include "../generic/dec_head.c"
	dec_loop_avx2(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/avx512/enc_loop.c
================================================
static inline void
enc_loop_avx512_inner (const uint8_t **s, uint8_t **o)
{
	// Load input.
	__m512i src = _mm512_loadu_si512((__m512i *) *s);

	// Reshuffle, translate, store.
	src = enc_reshuffle_translate(src);
	_mm512_storeu_si512((__m512i *) *o, src);

	*s += 48;
	*o += 64;
}

static inline void
enc_loop_avx512 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 64) {
		return;
	}

	// Process blocks of 48 bytes at a time. Because blocks are loaded 64
	// bytes at a time, ensure that there will be at least 24 remaining
	// bytes after the last round, so that the final read will not pass
	// beyond the bounds of the input buffer.
	size_t rounds = (*slen - 24) / 48;

	*slen -= rounds * 48;   // 48 bytes consumed per round
	*olen += rounds * 64;   // 64 bytes produced per round

	while (rounds > 0) {
		if (rounds >= 8) {
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_avx512_inner(s, o);
			enc_loop_avx512_inner(s, o);
			rounds -= 2;
			continue;
		}
		enc_loop_avx512_inner(s, o);
		break;
	}
}


================================================
FILE: 3rdparty/base64/lib/arch/avx512/enc_reshuffle_translate.c
================================================
// AVX512 algorithm is based on permutevar and multishift. The code is based on
// https://github.com/WojciechMula/base64simd which is under BSD-2 license.

static inline __m512i
enc_reshuffle_translate (const __m512i input)
{
	// 32-bit input
	// [ 0  0  0  0  0  0  0  0|c1 c0 d5 d4 d3 d2 d1 d0|
	//  b3 b2 b1 b0 c5 c4 c3 c2|a5 a4 a3 a2 a1 a0 b5 b4]
	// output order  [1, 2, 0, 1]
	// [b3 b2 b1 b0 c5 c4 c3 c2|c1 c0 d5 d4 d3 d2 d1 d0|
	//  a5 a4 a3 a2 a1 a0 b5 b4|b3 b2 b1 b0 c3 c2 c1 c0]

	const __m512i shuffle_input = _mm512_setr_epi32(0x01020001,
	                                                0x04050304,
	                                                0x07080607,
	                                                0x0a0b090a,
	                                                0x0d0e0c0d,
	                                                0x10110f10,
	                                                0x13141213,
	                                                0x16171516,
	                                                0x191a1819,
	                                                0x1c1d1b1c,
	                                                0x1f201e1f,
	                                                0x22232122,
	                                                0x25262425,
	                                                0x28292728,
	                                                0x2b2c2a2b,
	                                                0x2e2f2d2e);

	// Reorder bytes
	// [b3 b2 b1 b0 c5 c4 c3 c2|c1 c0 d5 d4 d3 d2 d1 d0|
	//  a5 a4 a3 a2 a1 a0 b5 b4|b3 b2 b1 b0 c3 c2 c1 c0]
	const __m512i in = _mm512_permutexvar_epi8(shuffle_input, input);

	// After multishift a single 32-bit lane has following layout
	// [c1 c0 d5 d4 d3 d2 d1 d0|b1 b0 c5 c4 c3 c2 c1 c0|
	//  a1 a0 b5 b4 b3 b2 b1 b0|d1 d0 a5 a4 a3 a2 a1 a0]
	// (a = [10:17], b = [4:11], c = [22:27], d = [16:21])

	// 48, 54, 36, 42, 16, 22, 4, 10
	const __m512i shifts = _mm512_set1_epi64(0x3036242a1016040alu);
	__m512i shuffled_in = _mm512_multishift_epi64_epi8(shifts, in);

	// Translate immediatedly after reshuffled.
	const __m512i lookup = _mm512_loadu_si512(base64_table_enc_6bit);

	// Translation 6-bit values to ASCII.
	return _mm512_permutexvar_epi8(shuffled_in, lookup);
}


================================================
FILE: 3rdparty/base64/lib/arch/generic/32/dec_loop.c
================================================
static inline int
dec_loop_generic_32_inner (const uint8_t **s, uint8_t **o, size_t *rounds)
{
	const uint32_t str
		= base64_table_dec_32bit_d0[(*s)[0]]
		| base64_table_dec_32bit_d1[(*s)[1]]
		| base64_table_dec_32bit_d2[(*s)[2]]
		| base64_table_dec_32bit_d3[(*s)[3]];

#if BASE64_LITTLE_ENDIAN

	// LUTs for little-endian set MSB in case of invalid character:
	if (str & UINT32_C(0x80000000)) {
		return 0;
	}
#else
	// LUTs for big-endian set LSB in case of invalid character:
	if (str & UINT32_C(1)) {
		return 0;
	}
#endif
	// Store the output:
	memcpy(*o, &str, sizeof (str));

	*s += 4;
	*o += 3;
	*rounds -= 1;

	return 1;
}

static inline void
dec_loop_generic_32 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 8) {
		return;
	}

	// Process blocks of 4 bytes per round. Because one extra zero byte is
	// written after the output, ensure that there will be at least 4 bytes
	// of input data left to cover the gap. (Two data bytes and up to two
	// end-of-string markers.)
	size_t rounds = (*slen - 4) / 4;

	*slen -= rounds * 4;	// 4 bytes consumed per round
	*olen += rounds * 3;	// 3 bytes produced per round

	do {
		if (rounds >= 8) {
			if (dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		if (rounds >= 4) {
			if (dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		if (rounds >= 2) {
			if (dec_loop_generic_32_inner(s, o, &rounds) &&
			    dec_loop_generic_32_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		dec_loop_generic_32_inner(s, o, &rounds);
		break;

	} while (rounds > 0);

	// Adjust for any rounds that were skipped:
	*slen += rounds * 4;
	*olen -= rounds * 3;
}


================================================
FILE: 3rdparty/base64/lib/arch/generic/32/enc_loop.c
================================================
static inline void
enc_loop_generic_32_inner (const uint8_t **s, uint8_t **o)
{
	uint32_t src;

	// Load input:
	memcpy(&src, *s, sizeof (src));

	// Reorder to 32-bit big-endian, if not already in that format. The
	// workset must be in big-endian, otherwise the shifted bits do not
	// carry over properly among adjacent bytes:
	src = BASE64_HTOBE32(src);

	// Two indices for the 12-bit lookup table:
	const size_t index0 = (src >> 20) & 0xFFFU;
	const size_t index1 = (src >>  8) & 0xFFFU;

	// Table lookup and store:
	memcpy(*o + 0, base64_table_enc_12bit + index0, 2);
	memcpy(*o + 2, base64_table_enc_12bit + index1, 2);

	*s += 3;
	*o += 4;
}

static inline void
enc_loop_generic_32 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 4) {
		return;
	}

	// Process blocks of 3 bytes at a time. Because blocks are loaded 4
	// bytes at a time, ensure that there will be at least one remaining
	// byte after the last round, so that the final read will not pass
	// beyond the bounds of the input buffer:
	size_t rounds = (*slen - 1) / 3;

	*slen -= rounds * 3;	// 3 bytes consumed per round
	*olen += rounds * 4;	// 4 bytes produced per round

	do {
		if (rounds >= 8) {
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_generic_32_inner(s, o);
			enc_loop_generic_32_inner(s, o);
			rounds -= 2;
			continue;
		}
		enc_loop_generic_32_inner(s, o);
		break;

	} while (rounds > 0);
}


================================================
FILE: 3rdparty/base64/lib/arch/generic/64/enc_loop.c
================================================
static inline void
enc_loop_generic_64_inner (const uint8_t **s, uint8_t **o)
{
	uint64_t src;

	// Load input:
	memcpy(&src, *s, sizeof (src));

	// Reorder to 64-bit big-endian, if not already in that format. The
	// workset must be in big-endian, otherwise the shifted bits do not
	// carry over properly among adjacent bytes:
	src = BASE64_HTOBE64(src);

	// Four indices for the 12-bit lookup table:
	const size_t index0 = (src >> 52) & 0xFFFU;
	const size_t index1 = (src >> 40) & 0xFFFU;
	const size_t index2 = (src >> 28) & 0xFFFU;
	const size_t index3 = (src >> 16) & 0xFFFU;

	// Table lookup and store:
	memcpy(*o + 0, base64_table_enc_12bit + index0, 2);
	memcpy(*o + 2, base64_table_enc_12bit + index1, 2);
	memcpy(*o + 4, base64_table_enc_12bit + index2, 2);
	memcpy(*o + 6, base64_table_enc_12bit + index3, 2);

	*s += 6;
	*o += 8;
}

static inline void
enc_loop_generic_64 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 8) {
		return;
	}

	// Process blocks of 6 bytes at a time. Because blocks are loaded 8
	// bytes at a time, ensure that there will be at least 2 remaining
	// bytes after the last round, so that the final read will not pass
	// beyond the bounds of the input buffer:
	size_t rounds = (*slen - 2) / 6;

	*slen -= rounds * 6;	// 6 bytes consumed per round
	*olen += rounds * 8;	// 8 bytes produced per round

	do {
		if (rounds >= 8) {
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_generic_64_inner(s, o);
			enc_loop_generic_64_inner(s, o);
			rounds -= 2;
			continue;
		}
		enc_loop_generic_64_inner(s, o);
		break;

	} while (rounds > 0);
}


================================================
FILE: 3rdparty/base64/lib/arch/generic/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <string.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if BASE64_WORDSIZE == 32
#  include "32/enc_loop.c"
#elif BASE64_WORDSIZE == 64
#  include "64/enc_loop.c"
#endif

#if BASE64_WORDSIZE >= 32
#  include "32/dec_loop.c"
#endif

BASE64_ENC_FUNCTION(plain)
{
	#include "enc_head.c"
#if BASE64_WORDSIZE == 32
	enc_loop_generic_32(&s, &slen, &o, &olen);
#elif BASE64_WORDSIZE == 64
	enc_loop_generic_64(&s, &slen, &o, &olen);
#endif
	#include "enc_tail.c"
}

BASE64_DEC_FUNCTION(plain)
{
	#include "dec_head.c"
#if BASE64_WORDSIZE >= 32
	dec_loop_generic_32(&s, &slen, &o, &olen);
#endif
	#include "dec_tail.c"
}


================================================
FILE: 3rdparty/base64/lib/arch/generic/dec_head.c
================================================
int ret = 0;
const uint8_t *s = (const uint8_t *) src;
uint8_t *o = (uint8_t *) out;
uint8_t q;

// Use local temporaries to avoid cache thrashing:
size_t olen = 0;
size_t slen = srclen;
struct base64_state st;
st.eof = state->eof;
st.bytes = state->bytes;
st.carry = state->carry;

// If we previously saw an EOF or an invalid character, bail out:
if (st.eof) {
	*outlen = 0;
	ret = 0;
	// If there was a trailing '=' to check, check it:
	if (slen && (st.eof == BASE64_AEOF)) {
		state->bytes = 0;
		state->eof = BASE64_EOF;
		ret = ((base64_table_dec_8bit[*s++] == 254) && (slen == 1)) ? 1 : 0;
	}
	return ret;
}

// Turn four 6-bit numbers into three bytes:
// out[0] = 11111122
// out[1] = 22223333
// out[2] = 33444444

// Duff's device again:
switch (st.bytes)
{
	for (;;)
	{
	case 0:


================================================
FILE: 3rdparty/base64/lib/arch/generic/dec_tail.c
================================================
		if (slen-- == 0) {
			ret = 1;
			break;
		}
		if ((q = base64_table_dec_8bit[*s++]) >= 254) {
			st.eof = BASE64_EOF;
			// Treat character '=' as invalid for byte 0:
			break;
		}
		st.carry = q << 2;
		st.bytes++;

		// Deliberate fallthrough:
		BASE64_FALLTHROUGH

	case 1:	if (slen-- == 0) {
			ret = 1;
			break;
		}
		if ((q = base64_table_dec_8bit[*s++]) >= 254) {
			st.eof = BASE64_EOF;
			// Treat character '=' as invalid for byte 1:
			break;
		}
		*o++ = st.carry | (q >> 4);
		st.carry = q << 4;
		st.bytes++;
		olen++;

		// Deliberate fallthrough:
		BASE64_FALLTHROUGH

	case 2:	if (slen-- == 0) {
			ret = 1;
			break;
		}
		if ((q = base64_table_dec_8bit[*s++]) >= 254) {
			st.bytes++;
			// When q == 254, the input char is '='.
			// Check if next byte is also '=':
			if (q == 254) {
				if (slen-- != 0) {
					st.bytes = 0;
					// EOF:
					st.eof = BASE64_EOF;
					q = base64_table_dec_8bit[*s++];
					ret = ((q == 254) && (slen == 0)) ? 1 : 0;
					break;
				}
				else {
					// Almost EOF
					st.eof = BASE64_AEOF;
					ret = 1;
					break;
				}
			}
			// If we get here, there was an error:
			break;
		}
		*o++ = st.carry | (q >> 2);
		st.carry = q << 6;
		st.bytes++;
		olen++;

		// Deliberate fallthrough:
		BASE64_FALLTHROUGH

	case 3:	if (slen-- == 0) {
			ret = 1;
			break;
		}
		if ((q = base64_table_dec_8bit[*s++]) >= 254) {
			st.bytes = 0;
			st.eof = BASE64_EOF;
			// When q == 254, the input char is '='. Return 1 and EOF.
			// When q == 255, the input char is invalid. Return 0 and EOF.
			ret = ((q == 254) && (slen == 0)) ? 1 : 0;
			break;
		}
		*o++ = st.carry | q;
		st.carry = 0;
		st.bytes = 0;
		olen++;
	}
}

state->eof = st.eof;
state->bytes = st.bytes;
state->carry = st.carry;
*outlen = olen;
return ret;


================================================
FILE: 3rdparty/base64/lib/arch/generic/enc_head.c
================================================
// Assume that *out is large enough to contain the output.
// Theoretically it should be 4/3 the length of src.
const uint8_t *s = (const uint8_t *) src;
uint8_t *o = (uint8_t *) out;

// Use local temporaries to avoid cache thrashing:
size_t olen = 0;
size_t slen = srclen;
struct base64_state st;
st.bytes = state->bytes;
st.carry = state->carry;

// Turn three bytes into four 6-bit numbers:
// in[0] = 00111111
// in[1] = 00112222
// in[2] = 00222233
// in[3] = 00333333

// Duff's device, a for() loop inside a switch() statement. Legal!
switch (st.bytes)
{
	for (;;)
	{
	case 0:


================================================
FILE: 3rdparty/base64/lib/arch/generic/enc_tail.c
================================================
		if (slen-- == 0) {
			break;
		}
		*o++ = base64_table_enc_6bit[*s >> 2];
		st.carry = (*s++ << 4) & 0x30;
		st.bytes++;
		olen += 1;

		// Deliberate fallthrough:
		BASE64_FALLTHROUGH

	case 1:	if (slen-- == 0) {
			break;
		}
		*o++ = base64_table_enc_6bit[st.carry | (*s >> 4)];
		st.carry = (*s++ << 2) & 0x3C;
		st.bytes++;
		olen += 1;

		// Deliberate fallthrough:
		BASE64_FALLTHROUGH

	case 2:	if (slen-- == 0) {
			break;
		}
		*o++ = base64_table_enc_6bit[st.carry | (*s >> 6)];
		*o++ = base64_table_enc_6bit[*s++ & 0x3F];
		st.bytes = 0;
		olen += 2;
	}
}
state->bytes = st.bytes;
state->carry = st.carry;
*outlen = olen;


================================================
FILE: 3rdparty/base64/lib/arch/neon32/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <string.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#ifdef __arm__
#  if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && HAVE_NEON32
#    define BASE64_USE_NEON32
#  endif
#endif

#ifdef BASE64_USE_NEON32
#include <arm_neon.h>

// Only enable inline assembly on supported compilers.
#if defined(__GNUC__) || defined(__clang__)
#define BASE64_NEON32_USE_ASM
#endif

static inline uint8x16_t
vqtbl1q_u8 (const uint8x16_t lut, const uint8x16_t indices)
{
	// NEON32 only supports 64-bit wide lookups in 128-bit tables. Emulate
	// the NEON64 `vqtbl1q_u8` intrinsic to do 128-bit wide lookups.
	uint8x8x2_t lut2;
	uint8x8x2_t result;

	lut2.val[0] = vget_low_u8(lut);
	lut2.val[1] = vget_high_u8(lut);

	result.val[0] = vtbl2_u8(lut2, vget_low_u8(indices));
	result.val[1] = vtbl2_u8(lut2, vget_high_u8(indices));

	return vcombine_u8(result.val[0], result.val[1]);
}

#include "../generic/32/dec_loop.c"
#include "../generic/32/enc_loop.c"
#include "dec_loop.c"
#include "enc_reshuffle.c"
#include "enc_translate.c"
#include "enc_loop.c"

#endif	// BASE64_USE_NEON32

// Stride size is so large on these NEON 32-bit functions
// (48 bytes encode, 32 bytes decode) that we inline the
// uint32 codec to stay performant on smaller inputs.

BASE64_ENC_FUNCTION(neon32)
{
#ifdef BASE64_USE_NEON32
	#include "../generic/enc_head.c"
	enc_loop_neon32(&s, &slen, &o, &olen);
	enc_loop_generic_32(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(neon32)
{
#ifdef BASE64_USE_NEON32
	#include "../generic/dec_head.c"
	dec_loop_neon32(&s, &slen, &o, &olen);
	dec_loop_generic_32(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/neon32/dec_loop.c
================================================
static inline int
is_nonzero (const uint8x16_t v)
{
	uint64_t u64;
	const uint64x2_t v64 = vreinterpretq_u64_u8(v);
	const uint32x2_t v32 = vqmovn_u64(v64);

	vst1_u64(&u64, vreinterpret_u64_u32(v32));
	return u64 != 0;
}

static inline uint8x16_t
delta_lookup (const uint8x16_t v)
{
	const uint8x8_t lut = {
		0, 16, 19, 4, (uint8_t) -65, (uint8_t) -65, (uint8_t) -71, (uint8_t) -71,
	};

	return vcombine_u8(
		vtbl1_u8(lut, vget_low_u8(v)),
		vtbl1_u8(lut, vget_high_u8(v)));
}

static inline uint8x16_t
dec_loop_neon32_lane (uint8x16_t *lane)
{
	// See the SSSE3 decoder for an explanation of the algorithm.
	const uint8x16_t lut_lo = {
		0x15, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
		0x11, 0x11, 0x13, 0x1A, 0x1B, 0x1B, 0x1B, 0x1A
	};

	const uint8x16_t lut_hi = {
		0x10, 0x10, 0x01, 0x02, 0x04, 0x08, 0x04, 0x08,
		0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
	};

	const uint8x16_t mask_0F = vdupq_n_u8(0x0F);
	const uint8x16_t mask_2F = vdupq_n_u8(0x2F);

	const uint8x16_t hi_nibbles = vshrq_n_u8(*lane, 4);
	const uint8x16_t lo_nibbles = vandq_u8(*lane, mask_0F);
	const uint8x16_t eq_2F      = vceqq_u8(*lane, mask_2F);

	const uint8x16_t hi = vqtbl1q_u8(lut_hi, hi_nibbles);
	const uint8x16_t lo = vqtbl1q_u8(lut_lo, lo_nibbles);

	// Now simply add the delta values to the input:
	*lane = vaddq_u8(*lane, delta_lookup(vaddq_u8(eq_2F, hi_nibbles)));

	// Return the validity mask:
	return vandq_u8(lo, hi);
}

static inline void
dec_loop_neon32 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 64) {
		return;
	}

	// Process blocks of 64 bytes per round. Unlike the SSE codecs, no
	// extra trailing zero bytes are written, so it is not necessary to
	// reserve extra input bytes:
	size_t rounds = *slen / 64;

	*slen -= rounds * 64;	// 64 bytes consumed per round
	*olen += rounds * 48;	// 48 bytes produced per round

	do {
		uint8x16x3_t dec;

		// Load 64 bytes and deinterleave:
		uint8x16x4_t str = vld4q_u8(*s);

		// Decode each lane, collect a mask of invalid inputs:
		const uint8x16_t classified
			= dec_loop_neon32_lane(&str.val[0])
			| dec_loop_neon32_lane(&str.val[1])
			| dec_loop_neon32_lane(&str.val[2])
			| dec_loop_neon32_lane(&str.val[3]);

		// Check for invalid input: if any of the delta values are
		// zero, fall back on bytewise code to do error checking and
		// reporting:
		if (is_nonzero(classified)) {
			break;
		}

		// Compress four bytes into three:
		dec.val[0] = vorrq_u8(vshlq_n_u8(str.val[0], 2), vshrq_n_u8(str.val[1], 4));
		dec.val[1] = vorrq_u8(vshlq_n_u8(str.val[1], 4), vshrq_n_u8(str.val[2], 2));
		dec.val[2] = vorrq_u8(vshlq_n_u8(str.val[2], 6), str.val[3]);

		// Interleave and store decoded result:
		vst3q_u8(*o, dec);

		*s += 64;
		*o += 48;

	} while (--rounds > 0);

	// Adjust for any rounds that were skipped:
	*slen += rounds * 64;
	*olen -= rounds * 48;
}


================================================
FILE: 3rdparty/base64/lib/arch/neon32/enc_loop.c
================================================
#ifdef BASE64_NEON32_USE_ASM
static inline void
enc_loop_neon32_inner_asm (const uint8_t **s, uint8_t **o)
{
	// This function duplicates the functionality of enc_loop_neon32_inner,
	// but entirely with inline assembly. This gives a significant speedup
	// over using NEON intrinsics, which do not always generate very good
	// code. The logic of the assembly is directly lifted from the
	// intrinsics version, so it can be used as a guide to this code.

	// Temporary registers, used as scratch space.
	uint8x16_t tmp0, tmp1, tmp2, tmp3;
	uint8x16_t mask0, mask1, mask2, mask3;

	// A lookup table containing the absolute offsets for all ranges.
	const uint8x16_t lut = {
		  65U,  71U, 252U, 252U,
		 252U, 252U, 252U, 252U,
		 252U, 252U, 252U, 252U,
		 237U, 240U,   0U,   0U
	};

	// Numeric constants.
	const uint8x16_t n51 = vdupq_n_u8(51);
	const uint8x16_t n25 = vdupq_n_u8(25);
	const uint8x16_t n63 = vdupq_n_u8(63);

	__asm__ (

		// Load 48 bytes and deinterleave. The bytes are loaded to
		// hard-coded registers q12, q13 and q14, to ensure that they
		// are contiguous. Increment the source pointer.
		"vld3.8 {d24, d26, d28}, [%[src]]! \n\t"
		"vld3.8 {d25, d27, d29}, [%[src]]! \n\t"

		// Reshuffle the bytes using temporaries.
		"vshr.u8 %q[t0], q12,    #2      \n\t"
		"vshr.u8 %q[t1], q13,    #4      \n\t"
		"vshr.u8 %q[t2], q14,    #6      \n\t"
		"vsli.8  %q[t1], q12,    #4      \n\t"
		"vsli.8  %q[t2], q13,    #2      \n\t"
		"vand.u8 %q[t1], %q[t1], %q[n63] \n\t"
		"vand.u8 %q[t2], %q[t2], %q[n63] \n\t"
		"vand.u8 %q[t3], q14,    %q[n63] \n\t"

		// t0..t3 are the reshuffled inputs. Create LUT indices.
		"vqsub.u8 q12, %q[t0], %q[n51] \n\t"
		"vqsub.u8 q13, %q[t1], %q[n51] \n\t"
		"vqsub.u8 q14, %q[t2], %q[n51] \n\t"
		"vqsub.u8 q15, %q[t3], %q[n51] \n\t"

		// Create the mask for range #0.
		"vcgt.u8 %q[m0], %q[t0], %q[n25] \n\t"
		"vcgt.u8 %q[m1], %q[t1], %q[n25] \n\t"
		"vcgt.u8 %q[m2], %q[t2], %q[n25] \n\t"
		"vcgt.u8 %q[m3], %q[t3], %q[n25] \n\t"

		// Subtract -1 to correct the LUT indices.
		"vsub.u8 q12, %q[m0] \n\t"
		"vsub.u8 q13, %q[m1] \n\t"
		"vsub.u8 q14, %q[m2] \n\t"
		"vsub.u8 q15, %q[m3] \n\t"

		// Lookup the delta values.
		"vtbl.u8 d24, {%q[lut]}, d24 \n\t"
		"vtbl.u8 d25, {%q[lut]}, d25 \n\t"
		"vtbl.u8 d26, {%q[lut]}, d26 \n\t"
		"vtbl.u8 d27, {%q[lut]}, d27 \n\t"
		"vtbl.u8 d28, {%q[lut]}, d28 \n\t"
		"vtbl.u8 d29, {%q[lut]}, d29 \n\t"
		"vtbl.u8 d30, {%q[lut]}, d30 \n\t"
		"vtbl.u8 d31, {%q[lut]}, d31 \n\t"

		// Add the delta values.
		"vadd.u8 q12, %q[t0] \n\t"
		"vadd.u8 q13, %q[t1] \n\t"
		"vadd.u8 q14, %q[t2] \n\t"
		"vadd.u8 q15, %q[t3] \n\t"

		// Store 64 bytes and interleave. Increment the dest pointer.
		"vst4.8 {d24, d26, d28, d30}, [%[dst]]! \n\t"
		"vst4.8 {d25, d27, d29, d31}, [%[dst]]! \n\t"

		// Outputs (modified).
		: [src] "+r"  (*s),
		  [dst] "+r"  (*o),
		  [t0]  "=&w" (tmp0),
		  [t1]  "=&w" (tmp1),
		  [t2]  "=&w" (tmp2),
		  [t3]  "=&w" (tmp3),
		  [m0]  "=&w" (mask0),
		  [m1]  "=&w" (mask1),
		  [m2]  "=&w" (mask2),
		  [m3]  "=&w" (mask3)

		// Inputs (not modified).
		: [lut] "w" (lut),
		  [n25] "w" (n25),
		  [n51] "w" (n51),
		  [n63] "w" (n63)

		// Clobbers.
		: "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
		  "cc", "memory"
	);
}
#endif

static inline void
enc_loop_neon32_inner (const uint8_t **s, uint8_t **o)
{
#ifdef BASE64_NEON32_USE_ASM
	enc_loop_neon32_inner_asm(s, o);
#else
	// Load 48 bytes and deinterleave:
	uint8x16x3_t src = vld3q_u8(*s);

	// Reshuffle:
	uint8x16x4_t out = enc_reshuffle(src);

	// Translate reshuffled bytes to the Base64 alphabet:
	out = enc_translate(out);

	// Interleave and store output:
	vst4q_u8(*o, out);

	*s += 48;
	*o += 64;
#endif
}

static inline void
enc_loop_neon32 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	size_t rounds = *slen / 48;

	*slen -= rounds * 48;	// 48 bytes consumed per round
	*olen += rounds * 64;	// 64 bytes produced per round

	while (rounds > 0) {
		if (rounds >= 8) {
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_neon32_inner(s, o);
			enc_loop_neon32_inner(s, o);
			rounds -= 2;
			continue;
		}
		enc_loop_neon32_inner(s, o);
		break;
	}
}


================================================
FILE: 3rdparty/base64/lib/arch/neon32/enc_reshuffle.c
================================================
static inline uint8x16x4_t
enc_reshuffle (uint8x16x3_t in)
{
	uint8x16x4_t out;

	// Input:
	// in[0]  = a7 a6 a5 a4 a3 a2 a1 a0
	// in[1]  = b7 b6 b5 b4 b3 b2 b1 b0
	// in[2]  = c7 c6 c5 c4 c3 c2 c1 c0

	// Output:
	// out[0] = 00 00 a7 a6 a5 a4 a3 a2
	// out[1] = 00 00 a1 a0 b7 b6 b5 b4
	// out[2] = 00 00 b3 b2 b1 b0 c7 c6
	// out[3] = 00 00 c5 c4 c3 c2 c1 c0

	// Move the input bits to where they need to be in the outputs. Except
	// for the first output, the high two bits are not cleared.
	out.val[0] = vshrq_n_u8(in.val[0], 2);
	out.val[1] = vshrq_n_u8(in.val[1], 4);
	out.val[2] = vshrq_n_u8(in.val[2], 6);
	out.val[1] = vsliq_n_u8(out.val[1], in.val[0], 4);
	out.val[2] = vsliq_n_u8(out.val[2], in.val[1], 2);

	// Clear the high two bits in the second, third and fourth output.
	out.val[1] = vandq_u8(out.val[1], vdupq_n_u8(0x3F));
	out.val[2] = vandq_u8(out.val[2], vdupq_n_u8(0x3F));
	out.val[3] = vandq_u8(in.val[2],  vdupq_n_u8(0x3F));

	return out;
}


================================================
FILE: 3rdparty/base64/lib/arch/neon32/enc_translate.c
================================================
static inline uint8x16x4_t
enc_translate (const uint8x16x4_t in)
{
	// A lookup table containing the absolute offsets for all ranges:
	const uint8x16_t lut = {
		 65U,  71U, 252U, 252U,
		252U, 252U, 252U, 252U,
		252U, 252U, 252U, 252U,
		237U, 240U,   0U,   0U
	};

	const uint8x16_t offset = vdupq_n_u8(51);

	uint8x16x4_t indices, mask, delta, out;

	// Translate values 0..63 to the Base64 alphabet. There are five sets:
	// #  From      To         Abs    Index  Characters
	// 0  [0..25]   [65..90]   +65        0  ABCDEFGHIJKLMNOPQRSTUVWXYZ
	// 1  [26..51]  [97..122]  +71        1  abcdefghijklmnopqrstuvwxyz
	// 2  [52..61]  [48..57]    -4  [2..11]  0123456789
	// 3  [62]      [43]       -19       12  +
	// 4  [63]      [47]       -16       13  /

	// Create LUT indices from input:
	// the index for range #0 is right, others are 1 less than expected:
	indices.val[0] = vqsubq_u8(in.val[0], offset);
	indices.val[1] = vqsubq_u8(in.val[1], offset);
	indices.val[2] = vqsubq_u8(in.val[2], offset);
	indices.val[3] = vqsubq_u8(in.val[3], offset);

	// mask is 0xFF (-1) for range #[1..4] and 0x00 for range #0:
	mask.val[0] = vcgtq_u8(in.val[0], vdupq_n_u8(25));
	mask.val[1] = vcgtq_u8(in.val[1], vdupq_n_u8(25));
	mask.val[2] = vcgtq_u8(in.val[2], vdupq_n_u8(25));
	mask.val[3] = vcgtq_u8(in.val[3], vdupq_n_u8(25));

	// Subtract -1, so add 1 to indices for range #[1..4], All indices are
	// now correct:
	indices.val[0] = vsubq_u8(indices.val[0], mask.val[0]);
	indices.val[1] = vsubq_u8(indices.val[1], mask.val[1]);
	indices.val[2] = vsubq_u8(indices.val[2], mask.val[2]);
	indices.val[3] = vsubq_u8(indices.val[3], mask.val[3]);

	// Lookup delta values:
	delta.val[0] = vqtbl1q_u8(lut, indices.val[0]);
	delta.val[1] = vqtbl1q_u8(lut, indices.val[1]);
	delta.val[2] = vqtbl1q_u8(lut, indices.val[2]);
	delta.val[3] = vqtbl1q_u8(lut, indices.val[3]);

	// Add delta values:
	out.val[0] = vaddq_u8(in.val[0], delta.val[0]);
	out.val[1] = vaddq_u8(in.val[1], delta.val[1]);
	out.val[2] = vaddq_u8(in.val[2], delta.val[2]);
	out.val[3] = vaddq_u8(in.val[3], delta.val[3]);

	return out;
}


================================================
FILE: 3rdparty/base64/lib/arch/neon64/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <string.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#ifdef __aarch64__
#  if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && HAVE_NEON64
#    define BASE64_USE_NEON64
#  endif
#endif

#ifdef BASE64_USE_NEON64
#include <arm_neon.h>

// Only enable inline assembly on supported compilers.
#if defined(__GNUC__) || defined(__clang__)
#define BASE64_NEON64_USE_ASM
#endif

static inline uint8x16x4_t
load_64byte_table (const uint8_t *p)
{
#ifdef BASE64_NEON64_USE_ASM

	// Force the table to be loaded into contiguous registers. GCC will not
	// normally allocate contiguous registers for a `uint8x16x4_t'. These
	// registers are chosen to not conflict with the ones in the enc loop.
	register uint8x16_t t0 __asm__ ("v8");
	register uint8x16_t t1 __asm__ ("v9");
	register uint8x16_t t2 __asm__ ("v10");
	register uint8x16_t t3 __asm__ ("v11");

	__asm__ (
		"ld1 {%[t0].16b, %[t1].16b, %[t2].16b, %[t3].16b}, [%[src]], #64 \n\t"
		: [src] "+r" (p),
		  [t0]  "=w" (t0),
		  [t1]  "=w" (t1),
		  [t2]  "=w" (t2),
		  [t3]  "=w" (t3)
	);

	return (uint8x16x4_t) {
		.val[0] = t0,
		.val[1] = t1,
		.val[2] = t2,
		.val[3] = t3,
	};
#else
	return vld1q_u8_x4(p);
#endif
}

#include "../generic/32/dec_loop.c"
#include "../generic/64/enc_loop.c"
#include "dec_loop.c"

#ifdef BASE64_NEON64_USE_ASM
# include "enc_loop_asm.c"
#else
# include "enc_reshuffle.c"
# include "enc_loop.c"
#endif

#endif	// BASE64_USE_NEON64

// Stride size is so large on these NEON 64-bit functions
// (48 bytes encode, 64 bytes decode) that we inline the
// uint64 codec to stay performant on smaller inputs.

BASE64_ENC_FUNCTION(neon64)
{
#ifdef BASE64_USE_NEON64
	#include "../generic/enc_head.c"
	enc_loop_neon64(&s, &slen, &o, &olen);
	enc_loop_generic_64(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(neon64)
{
#ifdef BASE64_USE_NEON64
	#include "../generic/dec_head.c"
	dec_loop_neon64(&s, &slen, &o, &olen);
	dec_loop_generic_32(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/neon64/dec_loop.c
================================================
// The input consists of five valid character sets in the Base64 alphabet,
// which we need to map back to the 6-bit values they represent.
// There are three ranges, two singles, and then there's the rest.
//
//   #  From       To        LUT  Characters
//   1  [0..42]    [255]      #1  invalid input
//   2  [43]       [62]       #1  +
//   3  [44..46]   [255]      #1  invalid input
//   4  [47]       [63]       #1  /
//   5  [48..57]   [52..61]   #1  0..9
//   6  [58..63]   [255]      #1  invalid input
//   7  [64]       [255]      #2  invalid input
//   8  [65..90]   [0..25]    #2  A..Z
//   9  [91..96]   [255]      #2  invalid input
//  10  [97..122]  [26..51]   #2  a..z
//  11  [123..126] [255]      #2  invalid input
// (12) Everything else => invalid input

// The first LUT will use the VTBL instruction (out of range indices are set to
// 0 in destination).
static const uint8_t dec_lut1[] = {
	255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
	255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
	255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,  62U, 255U, 255U, 255U,  63U,
	 52U,  53U,  54U,  55U,  56U,  57U,  58U,  59U,  60U,  61U, 255U, 255U, 255U, 255U, 255U, 255U,
};

// The second LUT will use the VTBX instruction (out of range indices will be
// unchanged in destination). Input [64..126] will be mapped to index [1..63]
// in this LUT. Index 0 means that value comes from LUT #1.
static const uint8_t dec_lut2[] = {
	  0U, 255U,   0U,   1U,   2U,   3U,   4U,   5U,   6U,   7U,   8U,   9U,  10U,  11U,  12U,  13U,
	 14U,  15U,  16U,  17U,  18U,  19U,  20U,  21U,  22U,  23U,  24U,  25U, 255U, 255U, 255U, 255U,
	255U, 255U,  26U,  27U,  28U,  29U,  30U,  31U,  32U,  33U,  34U,  35U,  36U,  37U,  38U,  39U,
	 40U,  41U,  42U,  43U,  44U,  45U,  46U,  47U,  48U,  49U,  50U,  51U, 255U, 255U, 255U, 255U,
};

// All input values in range for the first look-up will be 0U in the second
// look-up result. All input values out of range for the first look-up will be
// 0U in the first look-up result. Thus, the two results can be ORed without
// conflicts.
//
// Invalid characters that are in the valid range for either look-up will be
// set to 255U in the combined result. Other invalid characters will just be
// passed through with the second look-up result (using the VTBX instruction).
// Since the second LUT is 64 bytes, those passed-through values are guaranteed
// to have a value greater than 63U. Therefore, valid characters will be mapped
// to the valid [0..63] range and all invalid characters will be mapped to
// values greater than 63.

static inline void
dec_loop_neon64 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 64) {
		return;
	}

	// Process blocks of 64 bytes per round. Unlike the SSE codecs, no
	// extra trailing zero bytes are written, so it is not necessary to
	// reserve extra input bytes:
	size_t rounds = *slen / 64;

	*slen -= rounds * 64;	// 64 bytes consumed per round
	*olen += rounds * 48;	// 48 bytes produced per round

	const uint8x16x4_t tbl_dec1 = load_64byte_table(dec_lut1);
	const uint8x16x4_t tbl_dec2 = load_64byte_table(dec_lut2);

	do {
		const uint8x16_t offset = vdupq_n_u8(63U);
		uint8x16x4_t dec1, dec2;
		uint8x16x3_t dec;

		// Load 64 bytes and deinterleave:
		uint8x16x4_t str = vld4q_u8((uint8_t *) *s);

		// Get indices for second LUT:
		dec2.val[0] = vqsubq_u8(str.val[0], offset);
		dec2.val[1] = vqsubq_u8(str.val[1], offset);
		dec2.val[2] = vqsubq_u8(str.val[2], offset);
		dec2.val[3] = vqsubq_u8(str.val[3], offset);

		// Get values from first LUT:
		dec1.val[0] = vqtbl4q_u8(tbl_dec1, str.val[0]);
		dec1.val[1] = vqtbl4q_u8(tbl_dec1, str.val[1]);
		dec1.val[2] = vqtbl4q_u8(tbl_dec1, str.val[2]);
		dec1.val[3] = vqtbl4q_u8(tbl_dec1, str.val[3]);

		// Get values from second LUT:
		dec2.val[0] = vqtbx4q_u8(dec2.val[0], tbl_dec2, dec2.val[0]);
		dec2.val[1] = vqtbx4q_u8(dec2.val[1], tbl_dec2, dec2.val[1]);
		dec2.val[2] = vqtbx4q_u8(dec2.val[2], tbl_dec2, dec2.val[2]);
		dec2.val[3] = vqtbx4q_u8(dec2.val[3], tbl_dec2, dec2.val[3]);

		// Get final values:
		str.val[0] = vorrq_u8(dec1.val[0], dec2.val[0]);
		str.val[1] = vorrq_u8(dec1.val[1], dec2.val[1]);
		str.val[2] = vorrq_u8(dec1.val[2], dec2.val[2]);
		str.val[3] = vorrq_u8(dec1.val[3], dec2.val[3]);

		// Check for invalid input, any value larger than 63:
		const uint8x16_t classified
			= vcgtq_u8(str.val[0], vdupq_n_u8(63))
			| vcgtq_u8(str.val[1], vdupq_n_u8(63))
			| vcgtq_u8(str.val[2], vdupq_n_u8(63))
			| vcgtq_u8(str.val[3], vdupq_n_u8(63));

		// Check that all bits are zero:
		if (vmaxvq_u8(classified) != 0U) {
			break;
		}

		// Compress four bytes into three:
		dec.val[0] = vshlq_n_u8(str.val[0], 2) | vshrq_n_u8(str.val[1], 4);
		dec.val[1] = vshlq_n_u8(str.val[1], 4) | vshrq_n_u8(str.val[2], 2);
		dec.val[2] = vshlq_n_u8(str.val[2], 6) | str.val[3];

		// Interleave and store decoded result:
		vst3q_u8((uint8_t *) *o, dec);

		*s += 64;
		*o += 48;

	} while (--rounds > 0);

	// Adjust for any rounds that were skipped:
	*slen += rounds * 64;
	*olen -= rounds * 48;
}


================================================
FILE: 3rdparty/base64/lib/arch/neon64/enc_loop.c
================================================
static inline void
enc_loop_neon64_inner (const uint8_t **s, uint8_t **o, const uint8x16x4_t tbl_enc)
{
	// Load 48 bytes and deinterleave:
	uint8x16x3_t src = vld3q_u8(*s);

	// Divide bits of three input bytes over four output bytes:
	uint8x16x4_t out = enc_reshuffle(src);

	// The bits have now been shifted to the right locations;
	// translate their values 0..63 to the Base64 alphabet.
	// Use a 64-byte table lookup:
	out.val[0] = vqtbl4q_u8(tbl_enc, out.val[0]);
	out.val[1] = vqtbl4q_u8(tbl_enc, out.val[1]);
	out.val[2] = vqtbl4q_u8(tbl_enc, out.val[2]);
	out.val[3] = vqtbl4q_u8(tbl_enc, out.val[3]);

	// Interleave and store output:
	vst4q_u8(*o, out);

	*s += 48;
	*o += 64;
}

static inline void
enc_loop_neon64 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	size_t rounds = *slen / 48;

	*slen -= rounds * 48;	// 48 bytes consumed per round
	*olen += rounds * 64;	// 64 bytes produced per round

	// Load the encoding table:
	const uint8x16x4_t tbl_enc = load_64byte_table(base64_table_enc_6bit);

	while (rounds > 0) {
		if (rounds >= 8) {
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_neon64_inner(s, o, tbl_enc);
			enc_loop_neon64_inner(s, o, tbl_enc);
			rounds -= 2;
			continue;
		}
		enc_loop_neon64_inner(s, o, tbl_enc);
		break;
	}
}


================================================
FILE: 3rdparty/base64/lib/arch/neon64/enc_loop_asm.c
================================================
// Apologies in advance for combining the preprocessor with inline assembly,
// two notoriously gnarly parts of C, but it was necessary to avoid a lot of
// code repetition. The preprocessor is used to template large sections of
// inline assembly that differ only in the registers used. If the code was
// written out by hand, it would become very large and hard to audit.

// Generate a block of inline assembly that loads three user-defined registers
// A, B, C from memory and deinterleaves them, post-incrementing the src
// pointer. The register set should be sequential.
#define LOAD(A, B, C) \
	"ld3 {"A".16b, "B".16b, "C".16b}, [%[src]], #48 \n\t"

// Generate a block of inline assembly that takes three deinterleaved registers
// and shuffles the bytes. The output is in temporary registers t0..t3.
#define SHUF(A, B, C) \
	"ushr %[t0].16b, "A".16b,   #2         \n\t" \
	"ushr %[t1].16b, "B".16b,   #4         \n\t" \
	"ushr %[t2].16b, "C".16b,   #6         \n\t" \
	"sli  %[t1].16b, "A".16b,   #4         \n\t" \
	"sli  %[t2].16b, "B".16b,   #2         \n\t" \
	"and  %[t1].16b, %[t1].16b, %[n63].16b \n\t" \
	"and  %[t2].16b, %[t2].16b, %[n63].16b \n\t" \
	"and  %[t3].16b, "C".16b,   %[n63].16b \n\t"

// Generate a block of inline assembly that takes temporary registers t0..t3
// and translates them to the base64 alphabet, using a table loaded into
// v8..v11. The output is in user-defined registers A..D.
#define TRAN(A, B, C, D) \
	"tbl "A".16b, {v8.16b-v11.16b}, %[t0].16b \n\t" \
	"tbl "B".16b, {v8.16b-v11.16b}, %[t1].16b \n\t" \
	"tbl "C".16b, {v8.16b-v11.16b}, %[t2].16b \n\t" \
	"tbl "D".16b, {v8.16b-v11.16b}, %[t3].16b \n\t"

// Generate a block of inline assembly that interleaves four registers and
// stores them, post-incrementing the destination pointer.
#define STOR(A, B, C, D) \
	"st4 {"A".16b, "B".16b, "C".16b, "D".16b}, [%[dst]], #64 \n\t"

// Generate a block of inline assembly that generates a single self-contained
// encoder round: fetch the data, process it, and store the result.
#define ROUND() \
	LOAD("v12", "v13", "v14") \
	SHUF("v12", "v13", "v14") \
	TRAN("v12", "v13", "v14", "v15") \
	STOR("v12", "v13", "v14", "v15")

// Generate a block of assembly that generates a type A interleaved encoder
// round. It uses registers that were loaded by the previous type B round, and
// in turn loads registers for the next type B round.
#define ROUND_A() \
	SHUF("v2",  "v3",  "v4") \
	LOAD("v12", "v13", "v14") \
	TRAN("v2",  "v3",  "v4", "v5") \
	STOR("v2",  "v3",  "v4", "v5")

// Type B interleaved encoder round. Same as type A, but register sets swapped.
#define ROUND_B() \
	SHUF("v12", "v13", "v14") \
	LOAD("v2",  "v3",  "v4") \
	TRAN("v12", "v13", "v14", "v15") \
	STOR("v12", "v13", "v14", "v15")

// The first type A round needs to load its own registers.
#define ROUND_A_FIRST() \
	LOAD("v2", "v3", "v4") \
	ROUND_A()

// The last type B round omits the load for the next step.
#define ROUND_B_LAST() \
	SHUF("v12", "v13", "v14") \
	TRAN("v12", "v13", "v14", "v15") \
	STOR("v12", "v13", "v14", "v15")

// Suppress clang's warning that the literal string in the asm statement is
// overlong (longer than the ISO-mandated minimum size of 4095 bytes for C99
// compilers). It may be true, but the goal here is not C99 portability.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverlength-strings"

static inline void
enc_loop_neon64 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	size_t rounds = *slen / 48;

	if (rounds == 0) {
		return;
	}

	*slen -= rounds * 48;	// 48 bytes consumed per round.
	*olen += rounds * 64;	// 64 bytes produced per round.

	// Number of times to go through the 8x loop.
	size_t loops = rounds / 8;

	// Number of rounds remaining after the 8x loop.
	rounds %= 8;

	// Temporary registers, used as scratch space.
	uint8x16_t tmp0, tmp1, tmp2, tmp3;

	__asm__ volatile (

		// Load the encoding table into v8..v11.
		"    ld1 {v8.16b-v11.16b}, [%[tbl]] \n\t"

		// If there are eight rounds or more, enter an 8x unrolled loop
		// of interleaved encoding rounds. The rounds interleave memory
		// operations (load/store) with data operations to maximize
		// pipeline throughput.
		"    cbz %[loops], 4f \n\t"

		// The SIMD instructions do not touch the flags.
		"88: subs %[loops], %[loops], #1 \n\t"
		"    " ROUND_A_FIRST()
		"    " ROUND_B()
		"    " ROUND_A()
		"    " ROUND_B()
		"    " ROUND_A()
		"    " ROUND_B()
		"    " ROUND_A()
		"    " ROUND_B_LAST()
		"    b.ne 88b \n\t"

		// Enter a 4x unrolled loop for rounds of 4 or more.
		"4:  cmp  %[rounds], #4 \n\t"
		"    b.lt 30f           \n\t"
		"    " ROUND_A_FIRST()
		"    " ROUND_B()
		"    " ROUND_A()
		"    " ROUND_B_LAST()
		"    sub %[rounds], %[rounds], #4 \n\t"

		// Dispatch the remaining rounds 0..3.
		"30: cbz  %[rounds], 0f \n\t"
		"    cmp  %[rounds], #2 \n\t"
		"    b.eq 2f            \n\t"
		"    b.lt 1f            \n\t"

		// Block of non-interlaced encoding rounds, which can each
		// individually be jumped to. Rounds fall through to the next.
		"3:  " ROUND()
		"2:  " ROUND()
		"1:  " ROUND()
		"0:  \n\t"

		// Outputs (modified).
		: [loops] "+r"  (loops),
		  [src]   "+r"  (*s),
		  [dst]   "+r"  (*o),
		  [t0]    "=&w" (tmp0),
		  [t1]    "=&w" (tmp1),
		  [t2]    "=&w" (tmp2),
		  [t3]    "=&w" (tmp3)

		// Inputs (not modified).
		: [rounds] "r" (rounds),
		  [tbl]    "r" (base64_table_enc_6bit),
		  [n63]    "w" (vdupq_n_u8(63))

		// Clobbers.
		: "v2",  "v3",  "v4",  "v5",
		  "v8",  "v9",  "v10", "v11",
		  "v12", "v13", "v14", "v15",
		  "cc", "memory"
	);
}

#pragma GCC diagnostic pop


================================================
FILE: 3rdparty/base64/lib/arch/neon64/enc_reshuffle.c
================================================
static inline uint8x16x4_t
enc_reshuffle (const uint8x16x3_t in)
{
	uint8x16x4_t out;

	// Input:
	// in[0]  = a7 a6 a5 a4 a3 a2 a1 a0
	// in[1]  = b7 b6 b5 b4 b3 b2 b1 b0
	// in[2]  = c7 c6 c5 c4 c3 c2 c1 c0

	// Output:
	// out[0] = 00 00 a7 a6 a5 a4 a3 a2
	// out[1] = 00 00 a1 a0 b7 b6 b5 b4
	// out[2] = 00 00 b3 b2 b1 b0 c7 c6
	// out[3] = 00 00 c5 c4 c3 c2 c1 c0

	// Move the input bits to where they need to be in the outputs. Except
	// for the first output, the high two bits are not cleared.
	out.val[0] = vshrq_n_u8(in.val[0], 2);
	out.val[1] = vshrq_n_u8(in.val[1], 4);
	out.val[2] = vshrq_n_u8(in.val[2], 6);
	out.val[1] = vsliq_n_u8(out.val[1], in.val[0], 4);
	out.val[2] = vsliq_n_u8(out.val[2], in.val[1], 2);

	// Clear the high two bits in the second, third and fourth output.
	out.val[1] = vandq_u8(out.val[1], vdupq_n_u8(0x3F));
	out.val[2] = vandq_u8(out.val[2], vdupq_n_u8(0x3F));
	out.val[3] = vandq_u8(in.val[2],  vdupq_n_u8(0x3F));

	return out;
}


================================================
FILE: 3rdparty/base64/lib/arch/sse41/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if HAVE_SSE41
#include <smmintrin.h>

// Only enable inline assembly on supported compilers and on 64-bit CPUs.
#ifndef BASE64_SSE41_USE_ASM
# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
#  define BASE64_SSE41_USE_ASM 1
# else
#  define BASE64_SSE41_USE_ASM 0
# endif
#endif

#include "../ssse3/dec_reshuffle.c"
#include "../ssse3/dec_loop.c"

#if BASE64_SSE41_USE_ASM
# include "../ssse3/enc_loop_asm.c"
#else
# include "../ssse3/enc_translate.c"
# include "../ssse3/enc_reshuffle.c"
# include "../ssse3/enc_loop.c"
#endif

#endif	// HAVE_SSE41

BASE64_ENC_FUNCTION(sse41)
{
#if HAVE_SSE41
	#include "../generic/enc_head.c"
	enc_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(sse41)
{
#if HAVE_SSE41
	#include "../generic/dec_head.c"
	dec_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/sse42/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if HAVE_SSE42
#include <nmmintrin.h>

// Only enable inline assembly on supported compilers and on 64-bit CPUs.
#ifndef BASE64_SSE42_USE_ASM
# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
#  define BASE64_SSE42_USE_ASM 1
# else
#  define BASE64_SSE42_USE_ASM 0
# endif
#endif

#include "../ssse3/dec_reshuffle.c"
#include "../ssse3/dec_loop.c"

#if BASE64_SSE42_USE_ASM
# include "../ssse3/enc_loop_asm.c"
#else
# include "../ssse3/enc_translate.c"
# include "../ssse3/enc_reshuffle.c"
# include "../ssse3/enc_loop.c"
#endif

#endif	// HAVE_SSE42

BASE64_ENC_FUNCTION(sse42)
{
#if HAVE_SSE42
	#include "../generic/enc_head.c"
	enc_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(sse42)
{
#if HAVE_SSE42
	#include "../generic/dec_head.c"
	dec_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/codec.c
================================================
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#include "../../../include/libbase64.h"
#include "../../tables/tables.h"
#include "../../codecs.h"
#include "config.h"
#include "../../env.h"

#if HAVE_SSSE3
#include <tmmintrin.h>

// Only enable inline assembly on supported compilers and on 64-bit CPUs.
// 32-bit CPUs with SSSE3 support, such as low-end Atoms, only have eight XMM
// registers, which is not enough to run the inline assembly.
#ifndef BASE64_SSSE3_USE_ASM
# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
#  define BASE64_SSSE3_USE_ASM 1
# else
#  define BASE64_SSSE3_USE_ASM 0
# endif
#endif

#include "dec_reshuffle.c"
#include "dec_loop.c"

#if BASE64_SSSE3_USE_ASM
# include "enc_loop_asm.c"
#else
# include "enc_reshuffle.c"
# include "enc_translate.c"
# include "enc_loop.c"
#endif

#endif	// HAVE_SSSE3

BASE64_ENC_FUNCTION(ssse3)
{
#if HAVE_SSSE3
	#include "../generic/enc_head.c"
	enc_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/enc_tail.c"
#else
	BASE64_ENC_STUB
#endif
}

BASE64_DEC_FUNCTION(ssse3)
{
#if HAVE_SSSE3
	#include "../generic/dec_head.c"
	dec_loop_ssse3(&s, &slen, &o, &olen);
	#include "../generic/dec_tail.c"
#else
	BASE64_DEC_STUB
#endif
}


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/dec_loop.c
================================================
// The input consists of six character sets in the Base64 alphabet, which we
// need to map back to the 6-bit values they represent. There are three ranges,
// two singles, and then there's the rest.
//
//  #  From       To        Add  Characters
//  1  [43]       [62]      +19  +
//  2  [47]       [63]      +16  /
//  3  [48..57]   [52..61]   +4  0..9
//  4  [65..90]   [0..25]   -65  A..Z
//  5  [97..122]  [26..51]  -71  a..z
// (6) Everything else => invalid input
//
// We will use lookup tables for character validation and offset computation.
// Remember that 0x2X and 0x0X are the same index for _mm_shuffle_epi8, this
// allows to mask with 0x2F instead of 0x0F and thus save one constant
// declaration (register and/or memory access).
//
// For offsets:
// Perfect hash for lut = ((src >> 4) & 0x2F) + ((src == 0x2F) ? 0xFF : 0x00)
// 0000 = garbage
// 0001 = /
// 0010 = +
// 0011 = 0-9
// 0100 = A-Z
// 0101 = A-Z
// 0110 = a-z
// 0111 = a-z
// 1000 >= garbage
//
// For validation, here's the table.
// A character is valid if and only if the AND of the 2 lookups equals 0:
//
// hi \ lo              0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
//      LUT             0x15 0x11 0x11 0x11 0x11 0x11 0x11 0x11 0x11 0x11 0x13 0x1A 0x1B 0x1B 0x1B 0x1A
//
// 0000 0x10 char        NUL  SOH  STX  ETX  EOT  ENQ  ACK  BEL   BS   HT   LF   VT   FF   CR   SO   SI
//           andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
//
// 0001 0x10 char        DLE  DC1  DC2  DC3  DC4  NAK  SYN  ETB  CAN   EM  SUB  ESC   FS   GS   RS   US
//           andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
//
// 0010 0x01 char               !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /
//           andlut     0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x00 0x01 0x01 0x01 0x00
//
// 0011 0x02 char          0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?
//           andlut     0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x02 0x02 0x02 0x02 0x02
//
// 0100 0x04 char          @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O
//           andlut     0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
//
// 0101 0x08 char          P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _
//           andlut     0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x08 0x08 0x08 0x08
//
// 0110 0x04 char          `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o
//           andlut     0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
// 0111 0x08 char          p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~
//           andlut     0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x08 0x08 0x08 0x08
//
// 1000 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1001 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1010 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1011 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1100 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1101 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1110 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10
// 1111 0x10 andlut     0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10

static inline int
dec_loop_ssse3_inner (const uint8_t **s, uint8_t **o, size_t *rounds)
{
	const __m128i lut_lo = _mm_setr_epi8(
		0x15, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
		0x11, 0x11, 0x13, 0x1A, 0x1B, 0x1B, 0x1B, 0x1A);

	const __m128i lut_hi = _mm_setr_epi8(
		0x10, 0x10, 0x01, 0x02, 0x04, 0x08, 0x04, 0x08,
		0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10);

	const __m128i lut_roll = _mm_setr_epi8(
		0,  16,  19,   4, -65, -65, -71, -71,
		0,   0,   0,   0,   0,   0,   0,   0);

	const __m128i mask_2F = _mm_set1_epi8(0x2F);

	// Load input:
	__m128i str = _mm_loadu_si128((__m128i *) *s);

	// Table lookups:
	const __m128i hi_nibbles = _mm_and_si128(_mm_srli_epi32(str, 4), mask_2F);
	const __m128i lo_nibbles = _mm_and_si128(str, mask_2F);
	const __m128i hi         = _mm_shuffle_epi8(lut_hi, hi_nibbles);
	const __m128i lo         = _mm_shuffle_epi8(lut_lo, lo_nibbles);

	// Check for invalid input: if any "and" values from lo and hi are not
	// zero, fall back on bytewise code to do error checking and reporting:
	if (_mm_movemask_epi8(_mm_cmpgt_epi8(_mm_and_si128(lo, hi), _mm_setzero_si128())) != 0) {
		return 0;
	}

	const __m128i eq_2F = _mm_cmpeq_epi8(str, mask_2F);
	const __m128i roll  = _mm_shuffle_epi8(lut_roll, _mm_add_epi8(eq_2F, hi_nibbles));

	// Now simply add the delta values to the input:
	str = _mm_add_epi8(str, roll);

	// Reshuffle the input to packed 12-byte output format:
	str = dec_reshuffle(str);

	// Store the output:
	_mm_storeu_si128((__m128i *) *o, str);

	*s += 16;
	*o += 12;
	*rounds -= 1;

	return 1;
}

static inline void
dec_loop_ssse3 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 24) {
		return;
	}

	// Process blocks of 16 bytes per round. Because 4 extra zero bytes are
	// written after the output, ensure that there will be at least 8 bytes
	// of input data left to cover the gap. (6 data bytes and up to two
	// end-of-string markers.)
	size_t rounds = (*slen - 8) / 16;

	*slen -= rounds * 16;	// 16 bytes consumed per round
	*olen += rounds * 12;	// 12 bytes produced per round

	do {
		if (rounds >= 8) {
			if (dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		if (rounds >= 4) {
			if (dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		if (rounds >= 2) {
			if (dec_loop_ssse3_inner(s, o, &rounds) &&
			    dec_loop_ssse3_inner(s, o, &rounds)) {
				continue;
			}
			break;
		}
		dec_loop_ssse3_inner(s, o, &rounds);
		break;

	} while (rounds > 0);

	// Adjust for any rounds that were skipped:
	*slen += rounds * 16;
	*olen -= rounds * 12;
}


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/dec_reshuffle.c
================================================
static inline __m128i
dec_reshuffle (const __m128i in)
{
	// in, bits, upper case are most significant bits, lower case are least significant bits
	// 00llllll 00kkkkLL 00jjKKKK 00JJJJJJ
	// 00iiiiii 00hhhhII 00ggHHHH 00GGGGGG
	// 00ffffff 00eeeeFF 00ddEEEE 00DDDDDD
	// 00cccccc 00bbbbCC 00aaBBBB 00AAAAAA

	const __m128i merge_ab_and_bc = _mm_maddubs_epi16(in, _mm_set1_epi32(0x01400140));
	// 0000kkkk LLllllll 0000JJJJ JJjjKKKK
	// 0000hhhh IIiiiiii 0000GGGG GGggHHHH
	// 0000eeee FFffffff 0000DDDD DDddEEEE
	// 0000bbbb CCcccccc 0000AAAA AAaaBBBB

	const __m128i out = _mm_madd_epi16(merge_ab_and_bc, _mm_set1_epi32(0x00011000));
	// 00000000 JJJJJJjj KKKKkkkk LLllllll
	// 00000000 GGGGGGgg HHHHhhhh IIiiiiii
	// 00000000 DDDDDDdd EEEEeeee FFffffff
	// 00000000 AAAAAAaa BBBBbbbb CCcccccc

	// Pack bytes together:
	return  _mm_shuffle_epi8(out, _mm_setr_epi8(
		 2,  1,  0,
		 6,  5,  4,
		10,  9,  8,
		14, 13, 12,
		-1, -1, -1, -1));
	// 00000000 00000000 00000000 00000000
	// LLllllll KKKKkkkk JJJJJJjj IIiiiiii
	// HHHHhhhh GGGGGGgg FFffffff EEEEeeee
	// DDDDDDdd CCcccccc BBBBbbbb AAAAAAaa
}


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/enc_loop.c
================================================
static inline void
enc_loop_ssse3_inner (const uint8_t **s, uint8_t **o)
{
	// Load input:
	__m128i str = _mm_loadu_si128((__m128i *) *s);

	// Reshuffle:
	str = enc_reshuffle(str);

	// Translate reshuffled bytes to the Base64 alphabet:
	str = enc_translate(str);

	// Store:
	_mm_storeu_si128((__m128i *) *o, str);

	*s += 12;
	*o += 16;
}

static inline void
enc_loop_ssse3 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	if (*slen < 16) {
		return;
	}

	// Process blocks of 12 bytes at a time. Because blocks are loaded 16
	// bytes at a time, ensure that there will be at least 4 remaining
	// bytes after the last round, so that the final read will not pass
	// beyond the bounds of the input buffer:
	size_t rounds = (*slen - 4) / 12;

	*slen -= rounds * 12;	// 12 bytes consumed per round
	*olen += rounds * 16;	// 16 bytes produced per round

	do {
		if (rounds >= 8) {
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			rounds -= 8;
			continue;
		}
		if (rounds >= 4) {
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			rounds -= 4;
			continue;
		}
		if (rounds >= 2) {
			enc_loop_ssse3_inner(s, o);
			enc_loop_ssse3_inner(s, o);
			rounds -= 2;
			continue;
		}
		enc_loop_ssse3_inner(s, o);
		break;

	} while (rounds > 0);
}


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/enc_loop_asm.c
================================================
// Apologies in advance for combining the preprocessor with inline assembly,
// two notoriously gnarly parts of C, but it was necessary to avoid a lot of
// code repetition. The preprocessor is used to template large sections of
// inline assembly that differ only in the registers used. If the code was
// written out by hand, it would become very large and hard to audit.

// Generate a block of inline assembly that loads register R0 from memory. The
// offset at which the register is loaded is set by the given round.
#define LOAD(R0, ROUND) \
	"lddqu ("#ROUND" * 12)(%[src]), %["R0"] \n\t"

// Generate a block of inline assembly that deinterleaves and shuffles register
// R0 using preloaded constants. Outputs in R0 and R1.
#define SHUF(R0, R1) \
	"pshufb  %[lut0], %["R0"] \n\t" \
	"movdqa  %["R0"], %["R1"] \n\t" \
	"pand    %[msk0], %["R0"] \n\t" \
	"pand    %[msk2], %["R1"] \n\t" \
	"pmulhuw %[msk1], %["R0"] \n\t" \
	"pmullw  %[msk3], %["R1"] \n\t" \
	"por     %["R1"], %["R0"] \n\t"

// Generate a block of inline assembly that takes R0 and R1 and translates
// their contents to the base64 alphabet, using preloaded constants.
#define TRAN(R0, R1, R2) \
	"movdqa  %["R0"], %["R1"] \n\t" \
	"movdqa  %["R0"], %["R2"] \n\t" \
	"psubusb %[n51],  %["R1"] \n\t" \
	"pcmpgtb %[n25],  %["R2"] \n\t" \
	"psubb   %["R2"], %["R1"] \n\t" \
	"movdqa  %[lut1], %["R2"] \n\t" \
	"pshufb  %["R1"], %["R2"] \n\t" \
	"paddb   %["R2"], %["R0"] \n\t"

// Generate a block of inline assembly that stores the given register R0 at an
// offset set by the given round.
#define STOR(R0, ROUND) \
	"movdqu %["R0"], ("#ROUND" * 16)(%[dst]) \n\t"

// Generate a block of inline assembly that generates a single self-contained
// encoder round: fetch the data, process it, and store the result. Then update
// the source and destination pointers.
#define ROUND() \
	LOAD("a", 0) \
	SHUF("a", "b") \
	TRAN("a", "b", "c") \
	STOR("a", 0) \
	"add $12, %[src] \n\t" \
	"add $16, %[dst] \n\t"

// Define a macro that initiates a three-way interleaved encoding round by
// preloading registers a, b and c from memory.
// The register graph shows which registers are in use during each step, and
// is a visual aid for choosing registers for that step. Symbol index:
//
//  +  indicates that a register is loaded by that step.
//  |  indicates that a register is in use and must not be touched.
//  -  indicates that a register is decommissioned by that step.
//  x  indicates that a register is used as a temporary by that step.
//  V  indicates that a register is an input or output to the macro.
//
#define ROUND_3_INIT() 			/*  a b c d e f  */ \
	LOAD("a", 0)			/*  +            */ \
	SHUF("a", "d")			/*  |     +      */ \
	LOAD("b", 1)			/*  | +   |      */ \
	TRAN("a", "d", "e")		/*  | |   - x    */ \
	LOAD("c", 2)			/*  V V V        */

// Define a macro that translates, shuffles and stores the input registers A, B
// and C, and preloads registers D, E and F for the next round.
// This macro can be arbitrarily daisy-chained by feeding output registers D, E
// and F back into the next round as input registers A, B and C. The macro
// carefully interleaves memory operations with data operations for optimal
// pipelined performance.

#define ROUND_3(ROUND, A,B,C,D,E,F) 	/*  A B C D E F  */ \
	LOAD(D, (ROUND + 3))		/*  V V V +      */ \
	SHUF(B, E)			/*  | | | | +    */ \
	STOR(A, (ROUND + 0))		/*  - | | | |    */ \
	TRAN(B, E, F)			/*    | | | - x  */ \
	LOAD(E, (ROUND + 4))		/*    | | | +    */ \
	SHUF(C, A)			/*  + | | | |    */ \
	STOR(B, (ROUND + 1))		/*  | - | | |    */ \
	TRAN(C, A, F)			/*  -   | | | x  */ \
	LOAD(F, (ROUND + 5))		/*      | | | +  */ \
	SHUF(D, A)			/*  +   | | | |  */ \
	STOR(C, (ROUND + 2))		/*  |   - | | |  */ \
	TRAN(D, A, B)			/*  - x   V V V  */

// Define a macro that terminates a ROUND_3 macro by taking pre-loaded
// registers D, E and F, and translating, shuffling and storing them.
#define ROUND_3_END(ROUND, A,B,C,D,E,F)	/*  A B C D E F  */ \
	SHUF(E, A)			/*  +     V V V  */ \
	STOR(D, (ROUND + 3))		/*  |     - | |  */ \
	TRAN(E, A, B)			/*  - x     | |  */ \
	SHUF(F, C)			/*      +   | |  */ \
	STOR(E, (ROUND + 4))		/*      |   - |  */ \
	TRAN(F, C, D)			/*      - x   |  */ \
	STOR(F, (ROUND + 5))		/*            -  */

// Define a type A round. Inputs are a, b, and c, outputs are d, e, and f.
#define ROUND_3_A(ROUND) \
	ROUND_3(ROUND, "a", "b", "c", "d", "e", "f")

// Define a type B round. Inputs and outputs are swapped with regard to type A.
#define ROUND_3_B(ROUND) \
	ROUND_3(ROUND, "d", "e", "f", "a", "b", "c")

// Terminating macro for a type A round.
#define ROUND_3_A_LAST(ROUND) \
	ROUND_3_A(ROUND) \
	ROUND_3_END(ROUND, "a", "b", "c", "d", "e", "f")

// Terminating macro for a type B round.
#define ROUND_3_B_LAST(ROUND) \
	ROUND_3_B(ROUND) \
	ROUND_3_END(ROUND, "d", "e", "f", "a", "b", "c")

// Suppress clang's warning that the literal string in the asm statement is
// overlong (longer than the ISO-mandated minimum size of 4095 bytes for C99
// compilers). It may be true, but the goal here is not C99 portability.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverlength-strings"

static inline void
enc_loop_ssse3 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen)
{
	// For a clearer explanation of the algorithm used by this function,
	// please refer to the plain (not inline assembly) implementation. This
	// function follows the same basic logic.

	if (*slen < 16) {
		return;
	}

	// Process blocks of 12 bytes at a time. Input is read in blocks of 16
	// bytes, so "reserve" four bytes from the input buffer to ensure that
	// we never read beyond the end of the input buffer.
	size_t rounds = (*slen - 4) / 12;

	*slen -= rounds * 12;   // 12 bytes consumed per round
	*olen += rounds * 16;   // 16 bytes produced per round

	// Number of times to go through the 36x loop.
	size_t loops = rounds / 36;

	// Number of rounds remaining after the 36x loop.
	rounds %= 36;

	// Lookup tables.
	const __m128i lut0 = _mm_set_epi8(
		10, 11,  9, 10,  7,  8,  6,  7,  4,  5,  3,  4,  1,  2,  0,  1);

	const __m128i lut1 = _mm_setr_epi8(
		65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0);

	// Temporary registers.
	__m128i a, b, c, d, e, f;

	__asm__ volatile (

		// If there are 36 rounds or more, enter a 36x unrolled loop of
		// interleaved encoding rounds. The rounds interleave memory
		// operations (load/store) with data operations (table lookups,
		// etc) to maximize pipeline throughput.
		"    test %[loops], %[loops] \n\t"
		"    jz   18f                \n\t"
		"    jmp  36f                \n\t"
		"                            \n\t"
		".balign 64                  \n\t"
		"36: " ROUND_3_INIT()
		"    " ROUND_3_A( 0)
		"    " ROUND_3_B( 3)
		"    " ROUND_3_A( 6)
		"    " ROUND_3_B( 9)
		"    " ROUND_3_A(12)
		"    " ROUND_3_B(15)
		"    " ROUND_3_A(18)
		"    " ROUND_3_B(21)
		"    " ROUND_3_A(24)
		"    " ROUND_3_B(27)
		"    " ROUND_3_A_LAST(30)
		"    add $(12 * 36), %[src] \n\t"
		"    add $(16 * 36), %[dst] \n\t"
		"    dec %[loops]           \n\t"
		"    jnz 36b                \n\t"

		// Enter an 18x unrolled loop for rounds of 18 or more.
		"18: cmp $18, %[rounds] \n\t"
		"    jl  9f             \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A(0)
		"    " ROUND_3_B(3)
		"    " ROUND_3_A(6)
		"    " ROUND_3_B(9)
		"    " ROUND_3_A_LAST(12)
		"    sub $18,        %[rounds] \n\t"
		"    add $(12 * 18), %[src]    \n\t"
		"    add $(16 * 18), %[dst]    \n\t"

		// Enter a 9x unrolled loop for rounds of 9 or more.
		"9:  cmp $9, %[rounds] \n\t"
		"    jl  6f            \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A(0)
		"    " ROUND_3_B_LAST(3)
		"    sub $9,        %[rounds] \n\t"
		"    add $(12 * 9), %[src]    \n\t"
		"    add $(16 * 9), %[dst]    \n\t"

		// Enter a 6x unrolled loop for rounds of 6 or more.
		"6:  cmp $6, %[rounds] \n\t"
		"    jl  55f           \n\t"
		"    " ROUND_3_INIT()
		"    " ROUND_3_A_LAST(0)
		"    sub $6,        %[rounds] \n\t"
		"    add $(12 * 6), %[src]    \n\t"
		"    add $(16 * 6), %[dst]    \n\t"

		// Dispatch the remaining rounds 0..5.
		"55: cmp $3, %[rounds] \n\t"
		"    jg  45f           \n\t"
		"    je  3f            \n\t"
		"    cmp $1, %[rounds] \n\t"
		"    jg  2f            \n\t"
		"    je  1f            \n\t"
		"    jmp 0f            \n\t"

		"45: cmp $4, %[rounds] \n\t"
		"    je  4f            \n\t"

		// Block of non-interlaced encoding rounds, which can each
		// individually be jumped to. Rounds fall through to the next.
		"5: " ROUND()
		"4: " ROUND()
		"3: " ROUND()
		"2: " ROUND()
		"1: " ROUND()
		"0: \n\t"

		// Outputs (modified).
		: [rounds] "+r"  (rounds),
		  [loops]  "+r"  (loops),
		  [src]    "+r"  (*s),
		  [dst]    "+r"  (*o),
		  [a]      "=&x" (a),
		  [b]      "=&x" (b),
		  [c]      "=&x" (c),
		  [d]      "=&x" (d),
		  [e]      "=&x" (e),
		  [f]      "=&x" (f)

		// Inputs (not modified).
		: [lut0] "x" (lut0),
		  [lut1] "x" (lut1),
		  [msk0] "x" (_mm_set1_epi32(0x0FC0FC00)),
		  [msk1] "x" (_mm_set1_epi32(0x04000040)),
		  [msk2] "x" (_mm_set1_epi32(0x003F03F0)),
		  [msk3] "x" (_mm_set1_epi32(0x01000010)),
		  [n51]  "x" (_mm_set1_epi8(51)),
		  [n25]  "x" (_mm_set1_epi8(25))

		// Clobbers.
		: "cc", "memory"
	);
}

#pragma GCC diagnostic pop


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/enc_reshuffle.c
================================================
static inline __m128i
enc_reshuffle (__m128i in)
{
	// Input, bytes MSB to LSB:
	// 0 0 0 0 l k j i h g f e d c b a

	in = _mm_shuffle_epi8(in, _mm_set_epi8(
		10, 11,  9, 10,
		 7,  8,  6,  7,
		 4,  5,  3,  4,
		 1,  2,  0,  1));
	// in, bytes MSB to LSB:
	// k l j k
	// h i g h
	// e f d e
	// b c a b

	const __m128i t0 = _mm_and_si128(in, _mm_set1_epi32(0x0FC0FC00));
	// bits, upper case are most significant bits, lower case are least significant bits
	// 0000kkkk LL000000 JJJJJJ00 00000000
	// 0000hhhh II000000 GGGGGG00 00000000
	// 0000eeee FF000000 DDDDDD00 00000000
	// 0000bbbb CC000000 AAAAAA00 00000000

	const __m128i t1 = _mm_mulhi_epu16(t0, _mm_set1_epi32(0x04000040));
	// 00000000 00kkkkLL 00000000 00JJJJJJ
	// 00000000 00hhhhII 00000000 00GGGGGG
	// 00000000 00eeeeFF 00000000 00DDDDDD
	// 00000000 00bbbbCC 00000000 00AAAAAA

	const __m128i t2 = _mm_and_si128(in, _mm_set1_epi32(0x003F03F0));
	// 00000000 00llllll 000000jj KKKK0000
	// 00000000 00iiiiii 000000gg HHHH0000
	// 00000000 00ffffff 000000dd EEEE0000
	// 00000000 00cccccc 000000aa BBBB0000

	const __m128i t3 = _mm_mullo_epi16(t2, _mm_set1_epi32(0x01000010));
	// 00llllll 00000000 00jjKKKK 00000000
	// 00iiiiii 00000000 00ggHHHH 00000000
	// 00ffffff 00000000 00ddEEEE 00000000
	// 00cccccc 00000000 00aaBBBB 00000000

	return _mm_or_si128(t1, t3);
	// 00llllll 00kkkkLL 00jjKKKK 00JJJJJJ
	// 00iiiiii 00hhhhII 00ggHHHH 00GGGGGG
	// 00ffffff 00eeeeFF 00ddEEEE 00DDDDDD
	// 00cccccc 00bbbbCC 00aaBBBB 00AAAAAA
}


================================================
FILE: 3rdparty/base64/lib/arch/ssse3/enc_translate.c
================================================
static inline __m128i
enc_translate (const __m128i in)
{
	// A lookup table containing the absolute offsets for all ranges:
	const __m128i lut = _mm_setr_epi8(
		 65,  71, -4, -4,
		 -4,  -4, -4, -4,
		 -4,  -4, -4, -4,
		-19, -16,  0,  0
	);

	// Translate values 0..63 to the Base64 alphabet. There are five sets:
	// #  From      To         Abs    Index  Characters
	// 0  [0..25]   [65..90]   +65        0  ABCDEFGHIJKLMNOPQRSTUVWXYZ
	// 1  [26..51]  [97..122]  +71        1  abcdefghijklmnopqrstuvwxyz
	// 2  [52..61]  [48..57]    -4  [2..11]  0123456789
	// 3  [62]      [43]       -19       12  +
	// 4  [63]      [47]       -16       13  /

	// Create LUT indices from the input. The index for range #0 is right,
	// others are 1 less than expected:
	__m128i indices = _mm_subs_epu8(in, _mm_set1_epi8(51));

	// mask is 0xFF (-1) for range #[1..4] and 0x00 for range #0:
	__m128i mask = _mm_cmpgt_epi8(in, _mm_set1_epi8(25));

	// Subtract -1, so add 1 to indices for range #[1..4]. All indices are
	// now correct:
	indices = _mm_sub_epi8(indices, mask);

	// Add offsets to input values:
	return _mm_add_epi8(in, _mm_shuffle_epi8(lut, indices));
}


================================================
FILE: 3rdparty/base64/lib/codec_choose.c
================================================
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#include "../include/libbase64.h"
#include "codecs.h"
#include "config.h"
#include "env.h"

#if (__x86_64__ || __i386__ || _M_X86 || _M_X64)
  #define BASE64_X86
  #if (HAVE_SSSE3 || HAVE_SSE41 || HAVE_SSE42 || HAVE_AVX || HAVE_AVX2 || HAVE_AVX512)
    #define BASE64_X86_SIMD
  #endif
#endif

#ifdef BASE64_X86
#ifdef _MSC_VER
	#include <intrin.h>
	#define __cpuid_count(__level, __count, __eax, __ebx, __ecx, __edx) \
	{						\
		int info[4];				\
		__cpuidex(info, __level, __count);	\
		__eax = info[0];			\
		__ebx = info[1];			\
		__ecx = info[2];			\
		__edx = info[3];			\
	}
	#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \
		__cpuid_count(__level, 0, __eax, __ebx, __ecx, __edx)
#else
	#include <cpuid.h>
	#if HAVE_AVX512 || HAVE_AVX2 || HAVE_AVX
		#if ((__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 2) || (__clang_major__ >= 3))
			static inline uint64_t _xgetbv (uint32_t index)
			{
				uint32_t eax, edx;
				__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
				return ((uint64_t)edx << 32) | eax;
			}
		#else
			#error "Platform not supported"
		#endif
	#endif
#endif

#ifndef bit_AVX512vl
#define bit_AVX512vl (1 << 31)
#endif
#ifndef bit_AVX512vbmi
#define bit_AVX512vbmi (1 << 1)
#endif
#ifndef bit_AVX2
#define bit_AVX2 (1 << 5)
#endif
#ifndef bit_SSSE3
#define bit_SSSE3 (1 << 9)
#endif
#ifndef bit_SSE41
#define bit_SSE41 (1 << 19)
#endif
#ifndef bit_SSE42
#define bit_SSE42 (1 << 20)
#endif
#ifndef bit_AVX
#define bit_AVX (1 << 28)
#endif

#define bit_XSAVE_XRSTORE (1 << 27)

#ifndef _XCR_XFEATURE_ENABLED_MASK
#define _XCR_XFEATURE_ENABLED_MASK 0
#endif

#define _XCR_XMM_AND_YMM_STATE_ENABLED_BY_OS 0x6
#endif

// Function declarations:
#define BASE64_CODEC_FUNCS(arch)	\
	BASE64_ENC_FUNCTION(arch);	\
	BASE64_DEC_FUNCTION(arch);	\

BASE64_CODEC_FUNCS(avx512)
BASE64_CODEC_FUNCS(avx2)
BASE64_CODEC_FUNCS(neon32)
BASE64_CODEC_FUNCS(neon64)
BASE64_CODEC_FUNCS(plain)
BASE64_CODEC_FUNCS(ssse3)
BASE64_CODEC_FUNCS(sse41)
BASE64_CODEC_FUNCS(sse42)
BASE64_CODEC_FUNCS(avx)

static bool
codec_choose_forced (struct codec *codec, int flags)
{
	// If the user wants to use a certain codec,
	// always allow it, even if the codec is a no-op.
	// For testing purposes.

	if (!(flags & 0xFFFF)) {
		return false;
	}

	if (flags & BASE64_FORCE_AVX2) {
		codec->enc = base64_stream_encode_avx2;
		codec->dec = base64_stream_decode_avx2;
		return true;
	}
	if (flags & BASE64_FORCE_NEON32) {
		codec->enc = base64_stream_encode_neon32;
		codec->dec = base64_stream_decode_neon32;
		return true;
	}
	if (flags & BASE64_FORCE_NEON64) {
		codec->enc = base64_stream_encode_neon64;
		codec->dec = base64_stream_decode_neon64;
		return true;
	}
	if (flags & BASE64_FORCE_PLAIN) {
		codec->enc = base64_stream_encode_plain;
		codec->dec = base64_stream_decode_plain;
		return true;
	}
	if (flags & BASE64_FORCE_SSSE3) {
		codec->enc = base64_stream_encode_ssse3;
		codec->dec = base64_stream_decode_ssse3;
		return true;
	}
	if (flags & BASE64_FORCE_SSE41) {
		codec->enc = base64_stream_encode_sse41;
		codec->dec = base64_stream_decode_sse41;
		return true;
	}
	if (flags & BASE64_FORCE_SSE42) {
		codec->enc = base64_stream_encode_sse42;
		codec->dec = base64_stream_decode_sse42;
		return true;
	}
	if (flags & BASE64_FORCE_AVX) {
		codec->enc = base64_stream_encode_avx;
		codec->dec = base64_stream_decode_avx;
		return true;
	}
	if (flags & BASE64_FORCE_AVX512) {
		codec->enc = base64_stream_encode_avx512;
		codec->dec = base64_stream_decode_avx512;
		return true;
	}
	return false;
}

static bool
codec_choose_arm (struct codec *codec)
{
#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && ((defined(__aarch64__) && HAVE_NEON64) || HAVE_NEON32)

	// Unfortunately there is no portable way to check for NEON
	// support at runtime from userland in the same way that x86
	// has cpuid, so just stick to the compile-time configuration:

	#if defined(__aarch64__) && HAVE_NEON64
	codec->enc = base64_stream_encode_neon64;
	codec->dec = base64_stream_decode_neon64;
	#else
	codec->enc = base64_stream_encode_neon32;
	codec->dec = base64_stream_decode_neon32;
	#endif

	return true;

#else
	(void)codec;
	return false;
#endif
}

static bool
codec_choose_x86 (struct codec *codec)
{
#ifdef BASE64_X86_SIMD

	unsigned int eax, ebx = 0, ecx = 0, edx;
	unsigned int max_level;

	#ifdef _MSC_VER
	int info[4];
	__cpuidex(info, 0, 0);
	max_level = info[0];
	#else
	max_level = __get_cpuid_max(0, NULL);
	#endif

	#if HAVE_AVX512 || HAVE_AVX2 || HAVE_AVX
	// Check for AVX/AVX2/AVX512 support:
	// Checking for AVX requires 3 things:
	// 1) CPUID indicates that the OS uses XSAVE and XRSTORE instructions
	//    (allowing saving YMM registers on context switch)
	// 2) CPUID indicates support for AVX
	// 3) XGETBV indicates the AVX registers will be saved and restored on
	//    context switch
	//
	// Note that XGETBV is only available on 686 or later CPUs, so the
	// instruction needs to be conditionally run.
	if (max_level >= 1) {
		__cpuid_count(1, 0, eax, ebx, ecx, edx);
		if (ecx & bit_XSAVE_XRSTORE) {
			uint64_t xcr_mask;
			xcr_mask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
			if ((xcr_mask & _XCR_XMM_AND_YMM_STATE_ENABLED_BY_OS) == _XCR_XMM_AND_YMM_STATE_ENABLED_BY_OS) { // check multiple bits at once
				#if HAVE_AVX512
				if (max_level >= 7) {
					__cpuid_count(7, 0, eax, ebx, ecx, edx);
					if ((ebx & bit_AVX512vl) && (ecx & bit_AVX512vbmi)) {
						codec->enc = base64_stream_encode_avx512;
						codec->dec = base64_stream_decode_avx512;
						return true;
					}
				}
				#endif
				#if HAVE_AVX2
				if (max_level >= 7) {
					__cpuid_count(7, 0, eax, ebx, ecx, edx);
					if (ebx & bit_AVX2) {
						codec->enc = base64_stream_encode_avx2;
						codec->dec = base64_stream_decode_avx2;
						return true;
					}
				}
				#endif
				#if HAVE_AVX
				__cpuid_count(1, 0, eax, ebx, ecx, edx);
				if (ecx & bit_AVX) {
					codec->enc = base64_stream_encode_avx;
					codec->dec = base64_stream_decode_avx;
					return true;
				}
				#endif
			}
		}
	}
	#endif

	#if HAVE_SSE42
	// Check for SSE42 support:
	if (max_level >= 1) {
		__cpuid(1, eax, ebx, ecx, edx);
		if (ecx & bit_SSE42) {
			codec->enc = base64_stream_encode_sse42;
			codec->dec = base64_stream_decode_sse42;
			return true;
		}
	}
	#endif

	#if HAVE_SSE41
	// Check for SSE41 support:
	if (max_level >= 1) {
		__cpuid(1, eax, ebx, ecx, edx);
		if (ecx & bit_SSE41) {
			codec->enc = base64_stream_encode_sse41;
			codec->dec = base64_stream_decode_sse41;
			return true;
		}
	}
	#endif

	#if HAVE_SSSE3
	// Check for SSSE3 support:
	if (max_level >= 1) {
		__cpuid(1, eax, ebx, ecx, edx);
		if (ecx & bit_SSSE3) {
			codec->enc = base64_stream_encode_ssse3;
			codec->dec = base64_stream_decode_ssse3;
			return true;
		}
	}
	#endif

#else
	(void)codec;
#endif

	return false;
}

void
codec_choose (struct codec *codec, int flags)
{
	// User forced a codec:
	if (codec_choose_forced(codec, flags)) {
		return;
	}

	// Runtime feature detection:
	if (codec_choose_arm(codec)) {
		return;
	}
	if (codec_choose_x86(codec)) {
		return;
	}
	codec->enc = base64_stream_encode_plain;
	codec->dec = base64_stream_decode_plain;
}


================================================
FILE: 3rdparty/base64/lib/codecs.h
================================================
#include <stdint.h>
#include <stddef.h>

#include "../include/libbase64.h"
#include "config.h"

// Function parameters for encoding functions:
#define BASE64_ENC_PARAMS			\
	( struct base64_state	*state		\
	, const char		*src		\
	, size_t		 srclen		\
	, char			*out		\
	, size_t		*outlen		\
	)

// Function parameters for decoding functions:
#define BASE64_DEC_PARAMS			\
	( struct base64_state	*state		\
	, const char		*src		\
	, size_t		 srclen		\
	, char			*out		\
	, size_t		*outlen		\
	)

// Function signature for encoding functions:
#define BASE64_ENC_FUNCTION(arch)		\
	void					\
	base64_stream_encode_ ## arch		\
	BASE64_ENC_PARAMS

// Function signature for decoding functions:
#define BASE64_DEC_FUNCTION(arch)		\
	int					\
	base64_stream_decode_ ## arch		\
	BASE64_DEC_PARAMS

// Cast away unused variable, silence compiler:
#define UNUSED(x)		((void)(x))

// Stub function when encoder arch unsupported:
#define BASE64_ENC_STUB				\
	UNUSED(state);				\
	UNUSED(src);				\
	UNUSED(srclen);				\
	UNUSED(out);				\
						\
	*outlen = 0;

// Stub function when decoder arch unsupported:
#define BASE64_DEC_STUB				\
	UNUSED(state);				\
	UNUSED(src);				\
	UNUSED(srclen);				\
	UNUSED(out);				\
	UNUSED(outlen);				\
						\
	return -1;

struct codec
{
	void (* enc) BASE64_ENC_PARAMS;
	int  (* dec) BASE64_DEC_PARAMS;
};

extern void codec_choose (struct codec *, int flags);


================================================
FILE: 3rdparty/base64/lib/env.h
================================================
#ifndef BASE64_ENV_H
#define BASE64_ENV_H

// This header file contains macro definitions that describe certain aspects of
// the compile-time environment. Compatibility and portability macros go here.

// Define machine endianness. This is for GCC:
#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#  define BASE64_LITTLE_ENDIAN 1
#else
#  define BASE64_LITTLE_ENDIAN 0
#endif

// This is for Clang:
#ifdef __LITTLE_ENDIAN__
#  define BASE64_LITTLE_ENDIAN 1
#endif

#ifdef __BIG_ENDIAN__
#  define BASE64_LITTLE_ENDIAN 0
#endif

// MSVC++ needs intrin.h for _byteswap_uint64 (issue #68):
#if BASE64_LITTLE_ENDIAN && defined(_MSC_VER)
#  include <intrin.h>
#endif

// Endian conversion functions:
#if BASE64_LITTLE_ENDIAN
#  ifdef _MSC_VER
//   Microsoft Visual C++:
#    define BASE64_HTOBE32(x)	_byteswap_ulong(x)
#    define BASE64_HTOBE64(x)	_byteswap_uint64(x)
#  else
//   GCC and Clang:
#    define BASE64_HTOBE32(x)	__builtin_bswap32(x)
#    define BASE64_HTOBE64(x)	__builtin_bswap64(x)
#  endif
#else
// No conversion needed:
#  define BASE64_HTOBE32(x)	(x)
#  define BASE64_HTOBE64(x)	(x)
#endif

// Detect word size:
#if defined (__x86_64__)
// This also works for the x32 ABI, which has a 64-bit word size.
#  define BASE64_WORDSIZE 64
#elif defined (_INTEGRAL_MAX_BITS)
#  define BASE64_WORDSIZE _INTEGRAL_MAX_BITS
#elif defined (__WORDSIZE)
#  define BASE64_WORDSIZE __WORDSIZE
#elif defined (__SIZE_WIDTH__)
#  define BASE64_WORDSIZE __SIZE_WIDTH__
#else
#  error BASE64_WORDSIZE_NOT_DEFINED
#endif

// End-of-file definitions.
// Almost end-of-file when waiting for the last '=' character:
#define BASE64_AEOF 1
// End-of-file when stream end has been reached or invalid input provided:
#define BASE64_EOF 2

// GCC 7 defaults to issuing a warning for fallthrough in switch statements,
// unless the fallthrough cases are marked with an attribute. As we use
// fallthrough deliberately, define an alias for the attribute:
#if __GNUC__ >= 7
#  define BASE64_FALLTHROUGH  __attribute__((fallthrough));
#else
#  define BASE64_FALLTHROUGH
#endif

#endif	// BASE64_ENV_H


================================================
FILE: 3rdparty/base64/lib/exports.txt
================================================
base64_encode
base64_stream_encode
base64_stream_encode_init
base64_stream_encode_final
base64_decode
base64_stream_decode
base64_stream_decode_init


================================================
FILE: 3rdparty/base64/lib/lib.c
================================================
#include <stdint.h>
#include <stddef.h>
#ifdef _OPENMP
#include <omp.h>
#endif

#include "../include/libbase64.h"
#include "tables/tables.h"
#include "codecs.h"
#include "env.h"

// These static function pointers are initialized once when the library is
// first used, and remain in use for the remaining lifetime of the program.
// The idea being that CPU features don't change at runtime.
static struct codec codec = { NULL, NULL };

void
base64_stream_encode_init (struct base64_state *state, int flags)
{
	// If any of the codec flags are set, redo choice:
	if (codec.enc == NULL || flags & 0xFF) {
		codec_choose(&codec, flags);
	}
	state->eof = 0;
	state->bytes = 0;
	state->carry = 0;
	state->flags = flags;
}

void
base64_stream_encode
	( struct base64_state	*state
	, const char		*src
	, size_t		 srclen
	, char			*out
	, size_t		*outlen
	)
{
	codec.enc(state, src, srclen, out, outlen);
}

void
base64_stream_encode_final
	( struct base64_state	*state
	, char			*out
	, size_t		*outlen
	)
{
	uint8_t *o = (uint8_t *)out;

	if (state->bytes == 1) {
		*o++ = base64_table_enc_6bit[state->carry];
		*o++ = '=';
		*o++ = '=';
		*outlen = 3;
		return;
	}
	if (state->bytes == 2) {
		*o++ = base64_table_enc_6bit[state->carry];
		*o++ = '=';
		*outlen = 2;
		return;
	}
	*outlen = 0;
}

void
base64_stream_decode_init (struct base64_state *state, int flags)
{
	// If any of the codec flags are set, redo choice:
	if (codec.dec == NULL || flags & 0xFFFF) {
		codec_choose(&codec, flags);
	}
	state->eof = 0;
	state->bytes = 0;
	state->carry = 0;
	state->flags = flags;
}

int
base64_stream_decode
	( struct base64_state	*state
	, const char		*src
	, size_t		 srclen
	, char			*out
	, size_t		*outlen
	)
{
	return codec.dec(state, src, srclen, out, outlen);
}

#ifdef _OPENMP

	// Due to the overhead of initializing OpenMP and creating a team of
	// threads, we require the data length to be larger than a threshold:
	#define OMP_THRESHOLD 20000

	// Conditionally include OpenMP-accelerated codec implementations:
	#include "lib_openmp.c"
#endif

void
base64_encode
	( const char	*src
	, size_t	 srclen
	, char		*out
	, size_t	*outlen
	, int		 flags
	)
{
	size_t s;
	size_t t;
	struct base64_state state;

	#ifdef _OPENMP
	if (srclen >= OMP_THRESHOLD) {
		base64_encode_openmp(src, srclen, out, outlen, flags);
		return;
	}
	#endif

	// Init the stream reader:
	base64_stream_encode_init(&state, flags);

	// Feed the whole string to the stream reader:
	base64_stream_encode(&state, src, srclen, out, &s);

	// Finalize the stream by writing trailer if any:
	base64_stream_encode_final(&state, out + s, &t);

	// Final output length is stream length plus tail:
	*outlen = s + t;
}

int
base64_decode
	( const char	*src
	, size_t	 srclen
	, char		*out
	, size_t	*outlen
	, int		 flags
	)
{
	int ret;
	struct base64_state state;

	#ifdef _OPENMP
	if (srclen >= OMP_THRESHOLD) {
		return base64_decode_openmp(src, srclen, out, outlen, flags);
	}
	#endif

	// Init the stream reader:
	base64_stream_decode_init(&state, flags);

	// Feed the whole string to the stream reader:
	ret = base64_stream_decode(&state, src, srclen, out, outlen);

	// If when decoding a whole block, we're still waiting for input then fail:
	if (ret && (state.bytes == 0)) {
		return ret;
	}
	return 0;
}


================================================
FILE: 3rdparty/base64/lib/lib_openmp.c
================================================
// This code makes some assumptions on the implementation of
// base64_stream_encode_init(), base64_stream_encode() and base64_stream_decode().
// Basically these assumptions boil down to that when breaking the src into
// parts, out parts can be written without side effects.
// This is met when:
// 1) base64_stream_encode() and base64_stream_decode() don't use globals;
// 2) the shared variables src and out are not read or written outside of the
//    bounds of their parts, i.e.  when base64_stream_encode() reads a multiple
//    of 3 bytes, it must write no more then a multiple of 4 bytes, not even
//    temporarily;
// 3) the state flag can be discarded after base64_stream_encode() and
//    base64_stream_decode() on the parts.

static inline void
base64_encode_openmp
	( const char	*src
	, size_t	 srclen
	, char		*out
	, size_t	*outlen
	, int		 flags
	)
{
	size_t s;
	size_t t;
	size_t sum = 0, len, last_len;
	struct base64_state state, initial_state;
	int num_threads, i;

	// Request a number of threads but not necessarily get them:
	#pragma omp parallel
	{
		// Get the number of threads used from one thread only,
		// as num_threads is a shared var:
		#pragma omp single
		{
			num_threads = omp_get_num_threads();

			// Split the input string into num_threads parts, each
			// part a multiple of 3 bytes. The remaining bytes will
			// be done later:
			len = srclen / (num_threads * 3);
			len *= 3;
			last_len = srclen - num_threads * len;

			// Init the stream reader:
			base64_stream_encode_init(&state, flags);
			initial_state = state;
		}

		// Single has an implicit barrier for all threads to wait here
		// for the above to complete:
		#pragma omp for firstprivate(state) private(s) reduction(+:sum) schedule(static,1)
		for (i = 0; i < num_threads; i++)
		{
			// Feed each part of the string to the stream reader:
			base64_stream_encode(&state, src + i * len, len, out + i * len * 4 / 3, &s);
			sum += s;
		}
	}

	// As encoding should never fail and we encode an exact multiple
	// of 3 bytes, we can discard state:
	state = initial_state;

	// Encode the remaining bytes:
	base64_stream_encode(&state, src + num_threads * len, last_len, out + num_threads * len * 4 / 3, &s);

	// Finalize the stream by writing trailer if any:
	base64_stream_encode_final(&state, out + num_threads * len * 4 / 3 + s, &t);

	// Final output length is stream length plus tail:
	sum += s + t;
	*outlen = sum;
}

static inline int
base64_decode_openmp
	( const char	*src
	, size_t	 srclen
	, char		*out
	, size_t	*outlen
	, int		 flags
	)
{
	int num_threads, result = 0, i;
	size_t sum = 0, len, last_len, s;
	struct base64_state state, initial_state;

	// Request a number of threads but not necessarily get them:
	#pragma omp parallel
	{
		// Get the number of threads used from one thread only,
		// as num_threads is a shared var:
		#pragma omp single
		{
			num_threads = omp_get_num_threads();

			// Split the input string into num_threads parts, each
			// part a multiple of 4 bytes. The remaining bytes will
			// be done later:
			len = srclen / (num_threads * 4);
			len *= 4;
			last_len = srclen - num_threads * len;

			// Init the stream reader:
			base64_stream_decode_init(&state, flags);

			initial_state = state;
		}

		// Single has an implicit barrier to wait here for the above to
		// complete:
		#pragma omp for firstprivate(state) private(s) reduction(+:sum, result) schedule(static,1)
		for (i = 0; i < num_threads; i++)
		{
			int this_result;

			// Feed each part of the string to the stream reader:
			this_result = base64_stream_decode(&state, src + i * len, len, out + i * len * 3 / 4, &s);
			sum += s;
			result += this_result;
		}
	}

	// If `result' equals `-num_threads', then all threads returned -1,
	// indicating that the requested codec is not available:
	if (result == -num_threads) {
		return -1;
	}

	// If `result' does not equal `num_threads', then at least one of the
	// threads hit a decode error:
	if (result != num_threads) {
		return 0;
	}

	// So far so good, now decode whatever remains in the buffer. Reuse the
	// initial state, since we are at a 4-byte boundary:
	state = initial_state;
	result = base64_stream_decode(&state, src + num_threads * len, last_len, out + num_threads * len * 3 / 4, &s);
	sum += s;
	*outlen = sum;

	// If when decoding a whole block, we're still waiting for input then fail:
	if (result && (state.bytes == 0)) {
		return result;
	}
	return 0;
}


================================================
FILE: 3rdparty/base64/lib/tables/.gitignore
================================================
table_generator


================================================
FILE: 3rdparty/base64/lib/tables/Makefile
================================================
.PHONY: all clean

TARGETS := table_dec_32bit.h table_enc_12bit.h table_generator

all: $(TARGETS)

clean:
	$(RM) $(TARGETS)

table_dec_32bit.h: table_generator
	./$^ > $@

table_enc_12bit.h: table_enc_12bit.py
	./$^ > $@

table_generator: table_generator.c
	$(CC) $(CFLAGS) -o $@ $^


================================================
FILE: 3rdparty/base64/lib/tables/table_dec_32bit.h
================================================
#include <stdint.h>
#define CHAR62 '+'
#define CHAR63 '/'
#define CHARPAD '='


#if BASE64_LITTLE_ENDIAN


/* SPECIAL DECODE TABLES FOR LITTLE ENDIAN (INTEL) CPUS */

const uint32_t base64_table_dec_32bit_d0[256] = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0x000000f8, 0xffffffff, 0xffffffff, 0xffffffff, 0x000000fc,
0x000000d0, 0x000000d4, 0x000000d8, 0x000000dc, 0x000000e0, 0x000000e4,
0x000000e8, 0x000000ec, 0x000000f0, 0x000000f4, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000,
0x00000004, 0x00000008, 0x0000000c, 0x00000010, 0x00000014, 0x00000018,
0x0000001c, 0x00000020, 0x00000024, 0x00000028, 0x0000002c, 0x00000030,
0x00000034, 0x00000038, 0x0000003c, 0x00000040, 0x00000044, 0x00000048,
0x0000004c, 0x00000050, 0x00000054, 0x00000058, 0x0000005c, 0x00000060,
0x00000064, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0x00000068, 0x0000006c, 0x00000070, 0x00000074, 0x00000078,
0x0000007c, 0x00000080, 0x00000084, 0x00000088, 0x0000008c, 0x00000090,
0x00000094, 0x00000098, 0x0000009c, 0x000000a0, 0x000000a4, 0x000000a8,
0x000000ac, 0x000000b0, 0x000000b4, 0x000000b8, 0x000000bc, 0x000000c0,
0x000000c4, 0x000000c8, 0x000000cc, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
};


const uint32_t base64_table_dec_32bit_d1[256] = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xfffffff
Download .txt
gitextract_7m1o6j63/

├── .editorconfig
├── .gitattributes
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   ├── copilot-instructions.md
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.py
│       ├── ci.yml
│       ├── codeql-analysis.yml
│       ├── depscan.yml
│       └── macos_crash_report.py
├── .gitignore
├── 3rdparty/
│   ├── base64/
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── config.h
│   │   ├── include/
│   │   │   └── libbase64.h
│   │   └── lib/
│   │       ├── arch/
│   │       │   ├── avx/
│   │       │   │   ├── codec.c
│   │       │   │   └── enc_loop_asm.c
│   │       │   ├── avx2/
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_loop.c
│   │       │   │   ├── dec_reshuffle.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   ├── enc_loop_asm.c
│   │       │   │   ├── enc_reshuffle.c
│   │       │   │   └── enc_translate.c
│   │       │   ├── avx512/
│   │       │   │   ├── codec.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   └── enc_reshuffle_translate.c
│   │       │   ├── generic/
│   │       │   │   ├── 32/
│   │       │   │   │   ├── dec_loop.c
│   │       │   │   │   └── enc_loop.c
│   │       │   │   ├── 64/
│   │       │   │   │   └── enc_loop.c
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_head.c
│   │       │   │   ├── dec_tail.c
│   │       │   │   ├── enc_head.c
│   │       │   │   └── enc_tail.c
│   │       │   ├── neon32/
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_loop.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   ├── enc_reshuffle.c
│   │       │   │   └── enc_translate.c
│   │       │   ├── neon64/
│   │       │   │   ├── codec.c
│   │       │   │   ├── dec_loop.c
│   │       │   │   ├── enc_loop.c
│   │       │   │   ├── enc_loop_asm.c
│   │       │   │   └── enc_reshuffle.c
│   │       │   ├── sse41/
│   │       │   │   └── codec.c
│   │       │   ├── sse42/
│   │       │   │   └── codec.c
│   │       │   └── ssse3/
│   │       │       ├── codec.c
│   │       │       ├── dec_loop.c
│   │       │       ├── dec_reshuffle.c
│   │       │       ├── enc_loop.c
│   │       │       ├── enc_loop_asm.c
│   │       │       ├── enc_reshuffle.c
│   │       │       └── enc_translate.c
│   │       ├── codec_choose.c
│   │       ├── codecs.h
│   │       ├── env.h
│   │       ├── exports.txt
│   │       ├── lib.c
│   │       ├── lib_openmp.c
│   │       └── tables/
│   │           ├── .gitignore
│   │           ├── Makefile
│   │           ├── table_dec_32bit.h
│   │           ├── table_enc_12bit.h
│   │           ├── table_enc_12bit.py
│   │           ├── table_generator.c
│   │           ├── tables.c
│   │           └── tables.h
│   ├── ringbuf/
│   │   ├── ringbuf.c
│   │   └── ringbuf.h
│   └── verstable.h
├── Brewfile
├── CHANGELOG.rst
├── CONTRIBUTING.md
├── INSTALL.md
├── LICENSE
├── Makefile
├── README.asciidoc
├── SECURITY.md
├── __main__.py
├── benchmark.py
├── build-terminfo
├── bypy/
│   ├── devenv.go
│   ├── init_env.py
│   ├── linux/
│   │   └── __main__.py
│   ├── linux.conf
│   ├── macos/
│   │   └── __main__.py
│   ├── macos.conf
│   ├── rsync.conf
│   ├── site.py
│   └── sources.json
├── count-lines-of-code
├── dev.sh
├── docs/
│   ├── Makefile
│   ├── _static/
│   │   ├── custom.css
│   │   ├── custom.js
│   │   ├── timestamps.css
│   │   └── timestamps.js
│   ├── _templates/
│   │   └── base.html
│   ├── actions.rst
│   ├── basic.rst
│   ├── binary.rst
│   ├── build.rst
│   ├── changelog.rst
│   ├── clipboard.rst
│   ├── color-stack.rst
│   ├── conf.py
│   ├── conf.rst
│   ├── deccara.rst
│   ├── desktop-notifications.rst
│   ├── extract-rst-targets.py
│   ├── faq.rst
│   ├── file-transfer-protocol.rst
│   ├── glossary.rst
│   ├── graphics-protocol.rst
│   ├── index.rst
│   ├── installer.sh
│   ├── integrations.rst
│   ├── intro_vid.rst
│   ├── invocation.rst
│   ├── keyboard-protocol.rst
│   ├── kittens/
│   │   ├── broadcast.rst
│   │   ├── choose-files.rst
│   │   ├── choose-fonts.rst
│   │   ├── clipboard.rst
│   │   ├── custom.rst
│   │   ├── desktop-ui.rst
│   │   ├── developing-builtin-kittens.rst
│   │   ├── diff.rst
│   │   ├── hints.rst
│   │   ├── hyperlinked_grep.rst
│   │   ├── icat.rst
│   │   ├── notify.rst
│   │   ├── panel.rst
│   │   ├── query_terminal.rst
│   │   ├── quick-access-terminal.rst
│   │   ├── remote_file.rst
│   │   ├── ssh.rst
│   │   ├── themes.rst
│   │   ├── transfer.rst
│   │   └── unicode_input.rst
│   ├── kittens_intro.rst
│   ├── launch.rst
│   ├── layouts.rst
│   ├── mapping.rst
│   ├── marks.rst
│   ├── misc-protocol.rst
│   ├── multiple-cursors-protocol.rst
│   ├── notifications.py
│   ├── open_actions.rst
│   ├── overview.rst
│   ├── performance.rst
│   ├── pipe.rst
│   ├── pointer-shapes.rst
│   ├── press-mentions.rst
│   ├── protocol-extensions.rst
│   ├── quake-screenshots.rst
│   ├── quickstart.rst
│   ├── rc_protocol.rst
│   ├── remote-control.rst
│   ├── requirements.txt
│   ├── sessions.rst
│   ├── shell-integration.rst
│   ├── support.html
│   ├── support.rst
│   ├── text-sizing-protocol.rst
│   ├── underlines.rst
│   ├── unscroll.rst
│   └── wide-gamut-colors.rst
├── embeds.go
├── gen/
│   ├── README.rst
│   ├── __init__.py
│   ├── __main__.py
│   ├── apc_parsers.py
│   ├── bitfields.py
│   ├── color_names.py
│   ├── config.py
│   ├── cursors.py
│   ├── go_code.py
│   ├── key_constants.py
│   ├── rowcolumn-diacritics.txt
│   ├── srgb_lut.py
│   └── wcwidth.py
├── glad/
│   └── generate.py
├── glfw/
│   ├── __init__.py
│   ├── backend_utils.c
│   ├── backend_utils.h
│   ├── cocoa_displaylink.m
│   ├── cocoa_init.m
│   ├── cocoa_joystick.h
│   ├── cocoa_joystick.m
│   ├── cocoa_monitor.m
│   ├── cocoa_platform.h
│   ├── cocoa_window.m
│   ├── context.c
│   ├── dbus_glfw.c
│   ├── dbus_glfw.h
│   ├── egl_context.c
│   ├── egl_context.h
│   ├── glfw.py
│   ├── glfw3.h
│   ├── glx_context.c
│   ├── glx_context.h
│   ├── ibus_glfw.c
│   ├── ibus_glfw.h
│   ├── init.c
│   ├── input.c
│   ├── internal.h
│   ├── kwin-blur-v1.xml
│   ├── linux_desktop_settings.c
│   ├── linux_desktop_settings.h
│   ├── linux_joystick.c
│   ├── linux_joystick.h
│   ├── linux_notify.c
│   ├── linux_notify.h
│   ├── main_loop.h
│   ├── mappings.h
│   ├── memfd.h
│   ├── momentum-scroll.c
│   ├── monitor.c
│   ├── monotonic.c
│   ├── nsgl_context.h
│   ├── nsgl_context.m
│   ├── null_init.c
│   ├── null_joystick.c
│   ├── null_joystick.h
│   ├── null_monitor.c
│   ├── null_platform.h
│   ├── null_window.c
│   ├── osmesa_context.c
│   ├── osmesa_context.h
│   ├── posix_thread.c
│   ├── posix_thread.h
│   ├── source-info.json
│   ├── vulkan.c
│   ├── window.c
│   ├── wl_client_side_decorations.c
│   ├── wl_client_side_decorations.h
│   ├── wl_cursors.c
│   ├── wl_cursors.h
│   ├── wl_init.c
│   ├── wl_monitor.c
│   ├── wl_platform.h
│   ├── wl_text_input.c
│   ├── wl_text_input.h
│   ├── wl_window.c
│   ├── wlr-layer-shell-unstable-v1.xml
│   ├── x11_init.c
│   ├── x11_monitor.c
│   ├── x11_platform.h
│   ├── x11_window.c
│   ├── xkb-compat-shim.h
│   ├── xkb_glfw.c
│   └── xkb_glfw.h
├── go.mod
├── go.sum
├── key_encoding.json
├── kittens/
│   ├── __init__.py
│   ├── ask/
│   │   ├── __init__.py
│   │   ├── choices.go
│   │   ├── get_line.go
│   │   ├── main.go
│   │   └── main.py
│   ├── broadcast/
│   │   ├── __init__.py
│   │   └── main.py
│   ├── choose_files/
│   │   ├── __init__.py
│   │   ├── archive.go
│   │   ├── calibre.go
│   │   ├── cmd_preview.go
│   │   ├── collection.go
│   │   ├── ffmpeg.go
│   │   ├── filters.go
│   │   ├── footer.go
│   │   ├── graphics.go
│   │   ├── image_preview.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── preview.go
│   │   ├── results.go
│   │   ├── results_test.go
│   │   ├── save-file.go
│   │   ├── scan.go
│   │   ├── scan_test.go
│   │   └── search-bar.go
│   ├── choose_fonts/
│   │   ├── __init__.py
│   │   ├── backend.go
│   │   ├── backend.py
│   │   ├── face.go
│   │   ├── faces.go
│   │   ├── family_list.go
│   │   ├── final.go
│   │   ├── graphics.go
│   │   ├── index_feature.go
│   │   ├── list.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── styles.go
│   │   ├── types.go
│   │   └── ui.go
│   ├── clipboard/
│   │   ├── __init__.py
│   │   ├── legacy.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── read.go
│   │   └── write.go
│   ├── command_palette/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   └── main_test.go
│   ├── desktop_ui/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   └── portal.go
│   ├── diff/
│   │   ├── __init__.py
│   │   ├── collect.go
│   │   ├── collect_test.go
│   │   ├── diff.go
│   │   ├── highlight.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── mouse.go
│   │   ├── patch.go
│   │   ├── patch_test.go
│   │   ├── render.go
│   │   ├── search.go
│   │   └── ui.go
│   ├── hints/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── marks.go
│   │   └── marks_test.go
│   ├── hyperlinked_grep/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   ├── main.py
│   │   └── main_test.go
│   ├── icat/
│   │   ├── __init__.py
│   │   ├── detect.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── process_images.go
│   │   ├── scaling_test.go
│   │   └── transmit.go
│   ├── notify/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── pager/
│   │   ├── __init__.py
│   │   ├── file_input.go
│   │   ├── main.go
│   │   └── main.py
│   ├── panel/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── query_terminal/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── quick_access_terminal/
│   │   ├── __init__.py
│   │   ├── main.go
│   │   └── main.py
│   ├── remote_file/
│   │   ├── __init__.py
│   │   └── main.py
│   ├── resize_window/
│   │   ├── __init__.py
│   │   └── main.py
│   ├── runner.py
│   ├── show_key/
│   │   ├── __init__.py
│   │   ├── kitty.go
│   │   ├── legacy.go
│   │   ├── main.go
│   │   └── main.py
│   ├── ssh/
│   │   ├── __init__.py
│   │   ├── askpass.go
│   │   ├── config.go
│   │   ├── config_test.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── main_test.go
│   │   ├── utils.go
│   │   ├── utils.py
│   │   └── utils_test.go
│   ├── themes/
│   │   ├── __init__.py
│   │   ├── list.go
│   │   ├── main.go
│   │   ├── main.py
│   │   └── ui.go
│   ├── transfer/
│   │   ├── __init__.py
│   │   ├── algorithm.c
│   │   ├── ftc.go
│   │   ├── ftc_test.go
│   │   ├── main.go
│   │   ├── main.py
│   │   ├── receive.go
│   │   ├── rsync.pyi
│   │   ├── send.go
│   │   ├── send_test.go
│   │   ├── utils.go
│   │   └── utils.py
│   ├── tui/
│   │   ├── __init__.py
│   │   ├── dircolors.py
│   │   ├── handler.py
│   │   ├── images.py
│   │   ├── line_edit.py
│   │   ├── loop.py
│   │   ├── operations.py
│   │   ├── operations_stub.py
│   │   ├── path_completer.py
│   │   ├── progress.py
│   │   ├── spinners.py
│   │   └── utils.py
│   └── unicode_input/
│       ├── __init__.py
│       ├── main.go
│       ├── main.py
│       └── table.go
├── kitty/
│   ├── __init__.py
│   ├── actions.py
│   ├── alpha_blend.glsl
│   ├── animation.c
│   ├── animation.h
│   ├── arches.h
│   ├── arena.h
│   ├── backtrace.h
│   ├── banned.h
│   ├── base64.h
│   ├── bash.py
│   ├── bgimage_fragment.glsl
│   ├── bgimage_vertex.glsl
│   ├── binary.h
│   ├── blit_common.glsl
│   ├── blit_fragment.glsl
│   ├── blit_vertex.glsl
│   ├── border_fragment.glsl
│   ├── border_vertex.glsl
│   ├── borders.py
│   ├── boss.py
│   ├── cell_defines.glsl
│   ├── cell_fragment.glsl
│   ├── cell_vertex.glsl
│   ├── char-props-data.h
│   ├── char-props.c
│   ├── char-props.h
│   ├── charsets.c
│   ├── charsets.h
│   ├── child-monitor.c
│   ├── child.c
│   ├── child.py
│   ├── choose_entry.py
│   ├── cleanup.c
│   ├── cleanup.h
│   ├── cli.py
│   ├── cli_stub.py
│   ├── client.py
│   ├── clipboard.py
│   ├── cocoa_window.h
│   ├── cocoa_window.m
│   ├── color-names.h
│   ├── colors.c
│   ├── colors.h
│   ├── colors.py
│   ├── conf/
│   │   ├── __init__.py
│   │   ├── generate.py
│   │   ├── types.py
│   │   └── utils.py
│   ├── config.py
│   ├── constants.py
│   ├── control-codes.h
│   ├── core_text.m
│   ├── cross-platform-random.h
│   ├── crypto.c
│   ├── cursor.c
│   ├── cursor_trail.c
│   ├── data-types.c
│   ├── data-types.h
│   ├── debug_config.py
│   ├── decorations.c
│   ├── decorations.h
│   ├── desktop.c
│   ├── disk-cache.c
│   ├── disk-cache.h
│   ├── entry_points.py
│   ├── fast-file-copy.c
│   ├── fast-file-copy.h
│   ├── fast_data_types.pyi
│   ├── file_transmission.py
│   ├── fixed_size_deque.h
│   ├── font-names.c
│   ├── fontconfig.c
│   ├── fonts/
│   │   ├── __init__.py
│   │   ├── common.py
│   │   ├── core_text.py
│   │   ├── features.py
│   │   ├── fontconfig.py
│   │   ├── list.py
│   │   └── render.py
│   ├── fonts.c
│   ├── fonts.h
│   ├── freetype.c
│   ├── freetype_render_ui_text.c
│   ├── freetype_render_ui_text.h
│   ├── gl-wrapper.c
│   ├── gl-wrapper.h
│   ├── gl.c
│   ├── gl.h
│   ├── glfw-wrapper.c
│   ├── glfw-wrapper.h
│   ├── glfw.c
│   ├── glyph-cache.c
│   ├── glyph-cache.h
│   ├── graphics.c
│   ├── graphics.h
│   ├── graphics_fragment.glsl
│   ├── graphics_vertex.glsl
│   ├── guess_mime_type.py
│   ├── history.c
│   ├── history.h
│   ├── hsluv.glsl
│   ├── hyperlink.c
│   ├── hyperlink.h
│   ├── iqsort.h
│   ├── key_encoding.c
│   ├── key_encoding.py
│   ├── key_names.py
│   ├── keys.c
│   ├── keys.h
│   ├── keys.py
│   ├── kittens.c
│   ├── kitty-verstable.h
│   ├── launch.py
│   ├── launcher/
│   │   ├── cli-parser.h
│   │   ├── cmdline.c
│   │   ├── launcher.h
│   │   ├── main.c
│   │   ├── shlex.h
│   │   ├── single-instance.c
│   │   └── utils.h
│   ├── layout/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── grid.py
│   │   ├── interface.py
│   │   ├── splits.py
│   │   ├── stack.py
│   │   ├── tall.py
│   │   └── vertical.py
│   ├── line-buf.c
│   ├── line-buf.h
│   ├── line.c
│   ├── line.h
│   ├── linear2srgb.glsl
│   ├── lineops.h
│   ├── logging.c
│   ├── loop-utils.c
│   ├── loop-utils.h
│   ├── macos_process_info.c
│   ├── main.py
│   ├── marks.py
│   ├── modes.h
│   ├── monotonic.c
│   ├── monotonic.h
│   ├── mouse.c
│   ├── multiprocessing.py
│   ├── notifications.py
│   ├── open_actions.py
│   ├── options/
│   │   ├── __init__.py
│   │   ├── definition.py
│   │   ├── parse.py
│   │   ├── to-c-generated.h
│   │   ├── to-c.h
│   │   ├── types.py
│   │   └── utils.py
│   ├── os_window_size.py
│   ├── parse-graphics-command.h
│   ├── parse-multicell-command.h
│   ├── png-reader.c
│   ├── png-reader.h
│   ├── print-graphics.h
│   ├── progress.py
│   ├── rc/
│   │   ├── __init__.py
│   │   ├── action.py
│   │   ├── base.py
│   │   ├── close_tab.py
│   │   ├── close_window.py
│   │   ├── create_marker.py
│   │   ├── detach_tab.py
│   │   ├── detach_window.py
│   │   ├── disable_ligatures.py
│   │   ├── env.py
│   │   ├── focus_tab.py
│   │   ├── focus_window.py
│   │   ├── get_colors.py
│   │   ├── get_text.py
│   │   ├── goto_layout.py
│   │   ├── kitten.py
│   │   ├── last_used_layout.py
│   │   ├── launch.py
│   │   ├── load_config.py
│   │   ├── ls.py
│   │   ├── new_window.py
│   │   ├── remove_marker.py
│   │   ├── resize_os_window.py
│   │   ├── resize_window.py
│   │   ├── run.py
│   │   ├── scroll_window.py
│   │   ├── select_window.py
│   │   ├── send_key.py
│   │   ├── send_text.py
│   │   ├── set_background_image.py
│   │   ├── set_background_opacity.py
│   │   ├── set_colors.py
│   │   ├── set_enabled_layouts.py
│   │   ├── set_font_size.py
│   │   ├── set_spacing.py
│   │   ├── set_tab_color.py
│   │   ├── set_tab_title.py
│   │   ├── set_user_vars.py
│   │   ├── set_window_logo.py
│   │   ├── set_window_title.py
│   │   └── signal_child.py
│   ├── remote_control.py
│   ├── render_cache.py
│   ├── resize.c
│   ├── resize.h
│   ├── rgb.py
│   ├── rounded_rect_fragment.glsl
│   ├── rounded_rect_vertex.glsl
│   ├── rowcolumn-diacritics.c
│   ├── safe-wrappers.h
│   ├── screen.c
│   ├── screen.h
│   ├── screenshot_fragment.glsl
│   ├── screenshot_vertex.glsl
│   ├── search_query_parser.py
│   ├── session.py
│   ├── shaders.c
│   ├── shaders.py
│   ├── shell_integration.py
│   ├── shlex.c
│   ├── shm.py
│   ├── short_uuid.py
│   ├── simd-string-128.c
│   ├── simd-string-256.c
│   ├── simd-string-impl.h
│   ├── simd-string.c
│   ├── simd-string.h
│   ├── simple_cli_definitions.py
│   ├── srgb_gamma.h
│   ├── state.c
│   ├── state.h
│   ├── systemd.c
│   ├── tab_bar.py
│   ├── tabs.py
│   ├── terminfo.h
│   ├── terminfo.py
│   ├── text-cache.c
│   ├── text-cache.h
│   ├── threading.h
│   ├── tint_fragment.glsl
│   ├── tint_vertex.glsl
│   ├── trail_fragment.glsl
│   ├── trail_vertex.glsl
│   ├── types.py
│   ├── typing_compat.py
│   ├── typing_compat.pyi
│   ├── unicode-data.h
│   ├── update_check.py
│   ├── utils.glsl
│   ├── utils.py
│   ├── utmp.c
│   ├── vt-parser.c
│   ├── vt-parser.h
│   ├── wcswidth.c
│   ├── wcswidth.h
│   ├── window.py
│   ├── window_list.py
│   ├── window_logo.c
│   ├── window_logo.h
│   ├── window_title_bar.py
│   └── xdg.py
├── kitty_tests/
│   ├── CascadiaCode-Regular.otf
│   ├── FiraCode-Medium.otf
│   ├── GraphemeBreakTest.json
│   ├── __init__.py
│   ├── atexit.py
│   ├── check_build.py
│   ├── clipboard.py
│   ├── command_palette.py
│   ├── completion.py
│   ├── crypto.py
│   ├── datatypes.py
│   ├── file_transmission.py
│   ├── fonts.py
│   ├── glfw.py
│   ├── gr.py
│   ├── graphics.py
│   ├── keys.py
│   ├── layout.py
│   ├── main.py
│   ├── mouse.py
│   ├── multicell.py
│   ├── notifications.py
│   ├── open_actions.py
│   ├── options.py
│   ├── panels.py
│   ├── parser.py
│   ├── screen.py
│   ├── search_query_parser.py
│   ├── shell_integration.py
│   ├── shm.py
│   ├── ssh.py
│   ├── tui.py
│   ├── twemoji_smiley-cff2_colr_1.otf
│   └── utmp.py
├── logo/
│   ├── attribution.txt
│   └── make.py
├── publish.py
├── pyproject.toml
├── rsync-and-build.sh
├── session.vim
├── setup.py
├── shell-integration/
│   ├── bash/
│   │   └── kitty.bash
│   ├── fish/
│   │   ├── vendor_completions.d/
│   │   │   ├── clone-in-kitty.fish
│   │   │   ├── kitten.fish
│   │   │   └── kitty.fish
│   │   └── vendor_conf.d/
│   │       └── kitty-shell-integration.fish
│   ├── ssh/
│   │   ├── bootstrap-utils.sh
│   │   ├── bootstrap.py
│   │   ├── bootstrap.sh
│   │   ├── kitten
│   │   └── kitty
│   └── zsh/
│       ├── .zshenv
│       ├── completions/
│       │   └── _kitty
│       ├── kitty-integration
│       └── kitty.zsh
├── shell.nix
├── staticcheck.conf
├── terminfo/
│   ├── kitty.termcap
│   ├── kitty.terminfo
│   └── x/
│       └── xterm-kitty
├── test.py
├── tools/
│   ├── README.rst
│   ├── cli/
│   │   ├── bash.go
│   │   ├── command.go
│   │   ├── completion-main.go
│   │   ├── completion-parse-args.go
│   │   ├── completion.go
│   │   ├── files.go
│   │   ├── files_test.go
│   │   ├── fish.go
│   │   ├── group.go
│   │   ├── help.go
│   │   ├── markup/
│   │   │   └── prettify.go
│   │   ├── option-from-string.go
│   │   ├── option.go
│   │   ├── parse-args.go
│   │   ├── types_test.go
│   │   ├── wcswidth_kitten.go
│   │   └── zsh.go
│   ├── cmd/
│   │   ├── at/
│   │   │   ├── complete_actions.go
│   │   │   ├── env.go
│   │   │   ├── launch.go
│   │   │   ├── main.go
│   │   │   ├── main_test.go
│   │   │   ├── run.go
│   │   │   ├── scroll_window.go
│   │   │   ├── send_text.go
│   │   │   ├── set_background_opacity.go
│   │   │   ├── set_colors.go
│   │   │   ├── set_font_size.go
│   │   │   ├── set_spacing.go
│   │   │   ├── set_tab_color.go
│   │   │   ├── set_window_logo.go
│   │   │   ├── shell.go
│   │   │   ├── socket_io.go
│   │   │   ├── template.go
│   │   │   └── tty_io.go
│   │   ├── atexit/
│   │   │   └── main.go
│   │   ├── benchmark/
│   │   │   └── main.go
│   │   ├── completion/
│   │   │   └── kitty.go
│   │   ├── edit_in_kitty/
│   │   │   └── main.go
│   │   ├── main.go
│   │   ├── mouse_demo/
│   │   │   └── main.go
│   │   ├── pytest/
│   │   │   └── main.go
│   │   ├── run_shell/
│   │   │   └── main.go
│   │   ├── show_error/
│   │   │   └── main.go
│   │   ├── tool/
│   │   │   ├── confirm_and_run_shebang.go
│   │   │   └── main.go
│   │   └── update_self/
│   │       └── main.go
│   ├── config/
│   │   ├── api.go
│   │   ├── api_test.go
│   │   ├── utils.go
│   │   └── utils_test.go
│   ├── crypto/
│   │   └── crypto.go
│   ├── disk_cache/
│   │   ├── api.go
│   │   ├── implementation.go
│   │   └── implementation_test.go
│   ├── fzf/
│   │   ├── algo.go
│   │   ├── algo_test.go
│   │   ├── api.go
│   │   └── types.go
│   ├── highlight/
│   │   ├── api.go
│   │   └── impl.go
│   ├── icons/
│   │   └── file-types.go
│   ├── ignorefiles/
│   │   ├── api.go
│   │   ├── gitignore.go
│   │   └── gitignore_test.go
│   ├── rsync/
│   │   ├── algorithm.go
│   │   ├── api.go
│   │   └── api_test.go
│   ├── simdstring/
│   │   ├── benchmark.sh
│   │   ├── benchmarks_test.go
│   │   ├── generate.go
│   │   ├── generate.sh
│   │   ├── intrinsics.go
│   │   ├── intrinsics_test.go
│   │   ├── scalar.go
│   │   └── test.sh
│   ├── themes/
│   │   ├── collection.go
│   │   └── collection_test.go
│   ├── tty/
│   │   ├── tty.go
│   │   ├── tty_bsd.go
│   │   └── tty_linux.go
│   ├── tui/
│   │   ├── dcs_to_kitty.go
│   │   ├── download_with_progress.go
│   │   ├── graphics/
│   │   │   ├── collection.go
│   │   │   ├── command.go
│   │   │   └── command_test.go
│   │   ├── hold.go
│   │   ├── loop/
│   │   │   ├── api.go
│   │   │   ├── capabilities.go
│   │   │   ├── key-encoding.go
│   │   │   ├── key-encoding_test.go
│   │   │   ├── mouse.go
│   │   │   ├── read.go
│   │   │   ├── run.go
│   │   │   ├── terminal-state.go
│   │   │   ├── timers.go
│   │   │   └── write.go
│   │   ├── mouse.go
│   │   ├── password.go
│   │   ├── progress-bar.go
│   │   ├── progress-bar_test.go
│   │   ├── readline/
│   │   │   ├── actions.go
│   │   │   ├── actions_test.go
│   │   │   ├── api.go
│   │   │   ├── completion.go
│   │   │   ├── draw.go
│   │   │   ├── history.go
│   │   │   └── keys.go
│   │   ├── render_lines.go
│   │   ├── run.go
│   │   ├── sgr/
│   │   │   ├── insert-formatting.go
│   │   │   └── insert-formatting_test.go
│   │   ├── shell_integration/
│   │   │   ├── api.go
│   │   │   ├── api_test.go
│   │   │   └── data.go
│   │   ├── shortcuts/
│   │   │   ├── api.go
│   │   │   └── implementation.go
│   │   ├── spinners.go
│   │   ├── subseq/
│   │   │   ├── score.go
│   │   │   └── score_test.go
│   │   ├── tmux.go
│   │   └── ui_kitten.go
│   ├── unicode_names/
│   │   ├── names.txt
│   │   ├── query.go
│   │   └── query_test.go
│   ├── utils/
│   │   ├── atexit.go
│   │   ├── atomic-write.go
│   │   ├── base85/
│   │   │   ├── base85.go
│   │   │   └── base85_test.go
│   │   ├── cache.go
│   │   ├── cached_values.go
│   │   ├── clock_with_raw.go
│   │   ├── clock_without_raw.go
│   │   ├── colors.go
│   │   ├── download_file.go
│   │   ├── embed.go
│   │   ├── filelock.go
│   │   ├── filelock_test.go
│   │   ├── hostname.go
│   │   ├── humanize/
│   │   │   ├── bytes.go
│   │   │   ├── times.go
│   │   │   └── times_test.go
│   │   ├── images/
│   │   │   ├── convert.go
│   │   │   ├── formats.go
│   │   │   ├── loading.go
│   │   │   ├── rowcolumn_diacritics.go
│   │   │   ├── serialize_test.go
│   │   │   ├── to_rgb.go
│   │   │   ├── to_rgba.go
│   │   │   └── utils.go
│   │   ├── io.go
│   │   ├── iso8601.go
│   │   ├── iso8601_test.go
│   │   ├── levenshtein.go
│   │   ├── longest-common.go
│   │   ├── longest-common_test.go
│   │   ├── mimetypes.go
│   │   ├── misc.go
│   │   ├── passwd.go
│   │   ├── passwd_test.go
│   │   ├── paths/
│   │   │   └── well_known.go
│   │   ├── paths.go
│   │   ├── random/
│   │   │   └── random.go
│   │   ├── regexp.go
│   │   ├── ring.go
│   │   ├── ring_test.go
│   │   ├── secrets/
│   │   │   └── tokens.go
│   │   ├── select.go
│   │   ├── select_posix.go
│   │   ├── select_without_pselect.go
│   │   ├── set.go
│   │   ├── shell.go
│   │   ├── shlex/
│   │   │   ├── ansi_c_escapes.go
│   │   │   ├── shlex.go
│   │   │   └── shlex_test.go
│   │   ├── short-uuid.go
│   │   ├── short-uuid_test.go
│   │   ├── sockets.go
│   │   ├── sockets_test.go
│   │   ├── stream_decompressor.go
│   │   ├── stream_decompressor_test.go
│   │   ├── strings.go
│   │   ├── strings_test.go
│   │   ├── style/
│   │   │   ├── api.go
│   │   │   ├── colorspaces.go
│   │   │   ├── colorspaces_bench_test.go
│   │   │   ├── colorspaces_test.go
│   │   │   ├── indent-and-wrap.go
│   │   │   ├── indent-and-wrap_test.go
│   │   │   ├── wrapper.go
│   │   │   └── wrapper_test.go
│   │   ├── tar.go
│   │   ├── tar_test.go
│   │   ├── tmpfile_linux.go
│   │   ├── tmpfile_others.go
│   │   ├── tpmfile_test.go
│   │   ├── types.go
│   │   ├── unsafe.go
│   │   ├── utf-8.go
│   │   └── which.go
│   ├── vt/
│   │   ├── cell.go
│   │   ├── line.go
│   │   └── linebuf.go
│   └── wcswidth/
│       ├── char-props-data.go
│       ├── char-props.go
│       ├── char-props_test.go
│       ├── escape-code-parser.go
│       ├── escape-code-parser_test.go
│       ├── iter.go
│       ├── truncate.go
│       ├── wcswidth.go
│       └── wcswidth_test.go
└── update-on-ox
Copy disabled (too large) Download .json
Condensed preview — 951 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (14,843K chars).
[
  {
    "path": ".editorconfig",
    "chars": 352,
    "preview": "root = true\n\n[*]\nindent_style = space\nindent_size = 4\nend_of_line = lf\ntrim_trailing_whitespace = true\n\n[{Makefile,*.ter"
  },
  {
    "path": ".gitattributes",
    "chars": 1500,
    "preview": "kitty/terminfo.h linguist-generated=true\nterminfo/kitty.termcap linguist-generated=true\nterminfo/kitty.terminfo linguist"
  },
  {
    "path": ".github/FUNDING.yml",
    "chars": 114,
    "preview": "github: kovidgoyal\npatreon: kovidgoyal\nliberapay: kovidgoyal\ncustom: https://sw.kovidgoyal.net/kitty/support.html\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "chars": 866,
    "preview": "---\nname: Bug report\nabout: Create a bug report\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n**Describe the bug**\nA clear a"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "chars": 604,
    "preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: enhancement\nassignees: ''\n\n---\n\n**Is"
  },
  {
    "path": ".github/copilot-instructions.md",
    "chars": 1648,
    "preview": "Before implementing any code changes or responding to a request, run the\nfollowing three commands:\n\nsudo apt-get install"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 836,
    "preview": "# To get started with Dependabot version updates, you'll need to specify which\n# package ecosystems to update and where "
  },
  {
    "path": ".github/workflows/ci.py",
    "chars": 11006,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>\n\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 6672,
    "preview": "name: CI\non: [push, pull_request]\nenv:\n    CI: 'true'\n    ASAN_OPTIONS: detect_leaks=0\n    LC_ALL: en_US.UTF-8\n    LANG:"
  },
  {
    "path": ".github/workflows/codeql-analysis.yml",
    "chars": 2029,
    "preview": "name: \"CodeQL\"\n\non:\n    push:\n        branches: [master]\n    pull_request:\n        # The branches below must be a subset"
  },
  {
    "path": ".github/workflows/depscan.yml",
    "chars": 935,
    "preview": "name: Depscan\non:\n    push:\n        branches: [master]\n    schedule:\n        - cron: '0 12 * * 5'\n\nenv:\n    CI: 'true'\n "
  },
  {
    "path": ".github/workflows/macos_crash_report.py",
    "chars": 13873,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport json\nimport posixp"
  },
  {
    "path": ".gitignore",
    "chars": 457,
    "preview": "*.so\n*.pyc\n*.pyo\n*.bin\n*_stub.pyi\n*_generated.go\n*_generated.s\n*_generated_test.go\n*_generated_test.s\n*_generated.h\n/.dm"
  },
  {
    "path": "3rdparty/base64/LICENSE",
    "chars": 1421,
    "preview": "Copyright (c) 2005-2007, Nick Galbreath\nCopyright (c) 2015-2018, Wojciech Muła\nCopyright (c) 2016-2017, Matthieu Darbois"
  },
  {
    "path": "3rdparty/base64/README.md",
    "chars": 19497,
    "preview": "# Fast Base64 stream encoder/decoder\n\n[![Build Status](https://github.com/aklomp/base64/actions/workflows/test.yml/badge"
  },
  {
    "path": "3rdparty/base64/config.h",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "3rdparty/base64/include/libbase64.h",
    "chars": 4789,
    "preview": "#ifndef LIBBASE64_H\n#define LIBBASE64_H\n\n#include <stddef.h>\t/* size_t */\n\n\n#if defined(_WIN32) || defined(__CYGWIN__)\n#"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx/codec.c",
    "chars": 1384,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <stdlib.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx/enc_loop_asm.c",
    "chars": 9314,
    "preview": "// Apologies in advance for combining the preprocessor with inline assembly,\n// two notoriously gnarly parts of C, but i"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/codec.c",
    "chars": 1079,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <stdlib.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/dec_loop.c",
    "chars": 3216,
    "preview": "static inline int\ndec_loop_avx2_inner (const uint8_t **s, uint8_t **o, size_t *rounds)\n{\n\tconst __m256i lut_lo = _mm256_"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/dec_reshuffle.c",
    "chars": 1291,
    "preview": "static inline __m256i\ndec_reshuffle (const __m256i in)\n{\n\t// in, lower lane, bits, upper case are most significant bits,"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/enc_loop.c",
    "chars": 2267,
    "preview": "static inline void\nenc_loop_avx2_inner_first (const uint8_t **s, uint8_t **o)\n{\n\t// First load is done at s - 0 to not g"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/enc_loop_asm.c",
    "chars": 10453,
    "preview": "// Apologies in advance for combining the preprocessor with inline assembly,\n// two notoriously gnarly parts of C, but i"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/enc_reshuffle.c",
    "chars": 2701,
    "preview": "static inline __m256i\nenc_reshuffle (const __m256i input)\n{\n\t// Translation of the SSSE3 reshuffling algorithm to AVX2. "
  },
  {
    "path": "3rdparty/base64/lib/arch/avx2/enc_translate.c",
    "chars": 1238,
    "preview": "static inline __m256i\nenc_translate (const __m256i in)\n{\n\t// A lookup table containing the absolute offsets for all rang"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx512/codec.c",
    "chars": 820,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <stdlib.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx512/enc_loop.c",
    "chars": 1493,
    "preview": "static inline void\nenc_loop_avx512_inner (const uint8_t **s, uint8_t **o)\n{\n\t// Load input.\n\t__m512i src = _mm512_loadu_"
  },
  {
    "path": "3rdparty/base64/lib/arch/avx512/enc_reshuffle_translate.c",
    "chars": 2265,
    "preview": "// AVX512 algorithm is based on permutevar and multishift. The code is based on\n// https://github.com/WojciechMula/base6"
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/32/dec_loop.c",
    "chars": 2205,
    "preview": "static inline int\ndec_loop_generic_32_inner (const uint8_t **s, uint8_t **o, size_t *rounds)\n{\n\tconst uint32_t str\n\t\t= b"
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/32/enc_loop.c",
    "chars": 1919,
    "preview": "static inline void\nenc_loop_generic_32_inner (const uint8_t **s, uint8_t **o)\n{\n\tuint32_t src;\n\n\t// Load input:\n\tmemcpy("
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/64/enc_loop.c",
    "chars": 2115,
    "preview": "static inline void\nenc_loop_generic_64_inner (const uint8_t **s, uint8_t **o)\n{\n\tuint64_t src;\n\n\t// Load input:\n\tmemcpy("
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/codec.c",
    "chars": 762,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <string.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/dec_head.c",
    "chars": 791,
    "preview": "int ret = 0;\nconst uint8_t *s = (const uint8_t *) src;\nuint8_t *o = (uint8_t *) out;\nuint8_t q;\n\n// Use local temporarie"
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/dec_tail.c",
    "chars": 1774,
    "preview": "\t\tif (slen-- == 0) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif ((q = base64_table_dec_8bit[*s++]) >= 254) {\n\t\t\tst.eof = BASE64_EOF;"
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/enc_head.c",
    "chars": 585,
    "preview": "// Assume that *out is large enough to contain the output.\n// Theoretically it should be 4/3 the length of src.\nconst ui"
  },
  {
    "path": "3rdparty/base64/lib/arch/generic/enc_tail.c",
    "chars": 637,
    "preview": "\t\tif (slen-- == 0) {\n\t\t\tbreak;\n\t\t}\n\t\t*o++ = base64_table_enc_6bit[*s >> 2];\n\t\tst.carry = (*s++ << 4) & 0x30;\n\t\tst.bytes+"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon32/codec.c",
    "chars": 1868,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <string.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon32/dec_loop.c",
    "chars": 2867,
    "preview": "static inline int\nis_nonzero (const uint8x16_t v)\n{\n\tuint64_t u64;\n\tconst uint64x2_t v64 = vreinterpretq_u64_u8(v);\n\tcon"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon32/enc_loop.c",
    "chars": 4629,
    "preview": "#ifdef BASE64_NEON32_USE_ASM\nstatic inline void\nenc_loop_neon32_inner_asm (const uint8_t **s, uint8_t **o)\n{\n\t// This fu"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon32/enc_reshuffle.c",
    "chars": 969,
    "preview": "static inline uint8x16x4_t\nenc_reshuffle (uint8x16x3_t in)\n{\n\tuint8x16x4_t out;\n\n\t// Input:\n\t// in[0]  = a7 a6 a5 a4 a3 "
  },
  {
    "path": "3rdparty/base64/lib/arch/neon32/enc_translate.c",
    "chars": 2103,
    "preview": "static inline uint8x16x4_t\nenc_translate (const uint8x16x4_t in)\n{\n\t// A lookup table containing the absolute offsets fo"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon64/codec.c",
    "chars": 2217,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <string.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon64/dec_loop.c",
    "chars": 5205,
    "preview": "// The input consists of five valid character sets in the Base64 alphabet,\n// which we need to map back to the 6-bit val"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon64/enc_loop.c",
    "chars": 1844,
    "preview": "static inline void\nenc_loop_neon64_inner (const uint8_t **s, uint8_t **o, const uint8x16x4_t tbl_enc)\n{\n\t// Load 48 byte"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon64/enc_loop_asm.c",
    "chars": 5617,
    "preview": "// Apologies in advance for combining the preprocessor with inline assembly,\n// two notoriously gnarly parts of C, but i"
  },
  {
    "path": "3rdparty/base64/lib/arch/neon64/enc_reshuffle.c",
    "chars": 975,
    "preview": "static inline uint8x16x4_t\nenc_reshuffle (const uint8x16x3_t in)\n{\n\tuint8x16x4_t out;\n\n\t// Input:\n\t// in[0]  = a7 a6 a5 "
  },
  {
    "path": "3rdparty/base64/lib/arch/sse41/codec.c",
    "chars": 1145,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <stdlib.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/sse42/codec.c",
    "chars": 1145,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <stdlib.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/codec.c",
    "chars": 1231,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#include <stdlib.h>\n\n#include \"../../../include/libbase64.h\"\n#include \"../../tab"
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/dec_loop.c",
    "chars": 6878,
    "preview": "// The input consists of six character sets in the Base64 alphabet, which we\n// need to map back to the 6-bit values the"
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/dec_reshuffle.c",
    "chars": 1105,
    "preview": "static inline __m128i\ndec_reshuffle (const __m128i in)\n{\n\t// in, bits, upper case are most significant bits, lower case "
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/enc_loop.c",
    "chars": 1536,
    "preview": "static inline void\nenc_loop_ssse3_inner (const uint8_t **s, uint8_t **o)\n{\n\t// Load input:\n\t__m128i str = _mm_loadu_si12"
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/enc_loop_asm.c",
    "chars": 9310,
    "preview": "// Apologies in advance for combining the preprocessor with inline assembly,\n// two notoriously gnarly parts of C, but i"
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/enc_reshuffle.c",
    "chars": 1501,
    "preview": "static inline __m128i\nenc_reshuffle (__m128i in)\n{\n\t// Input, bytes MSB to LSB:\n\t// 0 0 0 0 l k j i h g f e d c b a\n\n\tin"
  },
  {
    "path": "3rdparty/base64/lib/arch/ssse3/enc_translate.c",
    "chars": 1158,
    "preview": "static inline __m128i\nenc_translate (const __m128i in)\n{\n\t// A lookup table containing the absolute offsets for all rang"
  },
  {
    "path": "3rdparty/base64/lib/codec_choose.c",
    "chars": 7256,
    "preview": "#include <stdbool.h>\n#include <stdint.h>\n#include <stddef.h>\n#include <stdint.h>\n#include <stdio.h>\n\n#include \"../includ"
  },
  {
    "path": "3rdparty/base64/lib/codecs.h",
    "chars": 1392,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n\n#include \"../include/libbase64.h\"\n#include \"config.h\"\n\n// Function parameters f"
  },
  {
    "path": "3rdparty/base64/lib/env.h",
    "chars": 2082,
    "preview": "#ifndef BASE64_ENV_H\n#define BASE64_ENV_H\n\n// This header file contains macro definitions that describe certain aspects "
  },
  {
    "path": "3rdparty/base64/lib/exports.txt",
    "chars": 149,
    "preview": "base64_encode\nbase64_stream_encode\nbase64_stream_encode_init\nbase64_stream_encode_final\nbase64_decode\nbase64_stream_deco"
  },
  {
    "path": "3rdparty/base64/lib/lib.c",
    "chars": 3281,
    "preview": "#include <stdint.h>\n#include <stddef.h>\n#ifdef _OPENMP\n#include <omp.h>\n#endif\n\n#include \"../include/libbase64.h\"\n#inclu"
  },
  {
    "path": "3rdparty/base64/lib/lib_openmp.c",
    "chars": 4457,
    "preview": "// This code makes some assumptions on the implementation of\n// base64_stream_encode_init(), base64_stream_encode() and "
  },
  {
    "path": "3rdparty/base64/lib/tables/.gitignore",
    "chars": 16,
    "preview": "table_generator\n"
  },
  {
    "path": "3rdparty/base64/lib/tables/Makefile",
    "chars": 284,
    "preview": ".PHONY: all clean\n\nTARGETS := table_dec_32bit.h table_enc_12bit.h table_generator\n\nall: $(TARGETS)\n\nclean:\n\t$(RM) $(TARG"
  },
  {
    "path": "3rdparty/base64/lib/tables/table_dec_32bit.h",
    "chars": 25258,
    "preview": "#include <stdint.h>\n#define CHAR62 '+'\n#define CHAR63 '/'\n#define CHARPAD '='\n\n\n#if BASE64_LITTLE_ENDIAN\n\n\n/* SPECIAL DE"
  },
  {
    "path": "3rdparty/base64/lib/tables/table_enc_12bit.h",
    "chars": 74858,
    "preview": "#include <stdint.h>\n\nconst uint16_t base64_table_enc_12bit[] = {\n#if BASE64_LITTLE_ENDIAN\n\t0x4141U, 0x4241U, 0x4341U, 0x"
  },
  {
    "path": "3rdparty/base64/lib/tables/table_enc_12bit.py",
    "chars": 1124,
    "preview": "#!/usr/bin/python3\n\ndef tr(x):\n    \"\"\"Translate a 6-bit value to the Base64 alphabet.\"\"\"\n    s = 'ABCDEFGHIJKLMNOPQRSTUV"
  },
  {
    "path": "3rdparty/base64/lib/tables/table_generator.c",
    "chars": 5158,
    "preview": "/**\n *\n * Copyright 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com\n * Copyright 2017 Matthieu Darbois\n * All rig"
  },
  {
    "path": "3rdparty/base64/lib/tables/tables.c",
    "chars": 2051,
    "preview": "#include \"tables.h\"\n\nconst uint8_t\nbase64_table_enc_6bit[] =\n\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\t\"abcdefghijklmnopqrstuvwxyz\""
  },
  {
    "path": "3rdparty/base64/lib/tables/tables.h",
    "chars": 704,
    "preview": "#ifndef BASE64_TABLES_H\n#define BASE64_TABLES_H\n\n#include <stdint.h>\n\n#include \"../env.h\"\n\n// These tables are used by a"
  },
  {
    "path": "3rdparty/ringbuf/ringbuf.c",
    "chars": 9536,
    "preview": "/*\n * ringbuf.c - C ring buffer (FIFO) implementation.\n *\n * Written in 2011 by Drew Hess <dhess-src@bothan.net>.\n *\n * "
  },
  {
    "path": "3rdparty/ringbuf/ringbuf.h",
    "chars": 9427,
    "preview": "#pragma once\n/*\n * ringbuf.h - C ring buffer (FIFO) interface.\n *\n * Written in 2011 by Drew Hess <dhess-src@bothan.net>"
  },
  {
    "path": "3rdparty/verstable.h",
    "chars": 80930,
    "preview": "/*------------------------------------------------- VERSTABLE v2.1.1 ---------------------------------------------------"
  },
  {
    "path": "Brewfile",
    "chars": 116,
    "preview": "brew \"zlib\"\nbrew \"xxhash\"\nbrew \"simde\"\nbrew \"python\"\nbrew \"imagemagick\"\nbrew \"harfbuzz\"\nbrew \"sphinx-doc\"\nbrew \"go\"\n"
  },
  {
    "path": "CHANGELOG.rst",
    "chars": 47,
    "preview": "See https://sw.kovidgoyal.net/kitty/changelog/\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 1309,
    "preview": "### Reporting bugs\n\nPlease first search existing bug reports (especially closed ones) for a report\nthat matches your iss"
  },
  {
    "path": "INSTALL.md",
    "chars": 126,
    "preview": "[To build from source](https://sw.kovidgoyal.net/kitty/build/)\n\n[Pre-built binaries](https://sw.kovidgoyal.net/kitty/bin"
  },
  {
    "path": "LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "Makefile",
    "chars": 1046,
    "preview": "ifdef V\n\tVVAL=--verbose\nendif\nifdef VERBOSE\n\tVVAL=--verbose\nendif\n\nifdef FAIL_WARN\nexport FAIL_WARN\nendif\n\nall:\n\tpython3"
  },
  {
    "path": "README.asciidoc",
    "chars": 818,
    "preview": "= kitty - the fast, feature-rich, cross-platform, GPU based terminal\n\nIf you live in the terminal, *kitty* is made for *"
  },
  {
    "path": "SECURITY.md",
    "chars": 767,
    "preview": "# Security Policy\n\n## Supported Versions\n\nThere are no security specific releases of kitty. Security bugs are fixed\nand "
  },
  {
    "path": "__main__.py",
    "chars": 175,
    "preview": "#!/usr/bin/env python\n# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>\n\n\nif __name__ == '__main_"
  },
  {
    "path": "benchmark.py",
    "chars": 2675,
    "preview": "#!./kitty/launcher/kitty +launch\n# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport fcntl\n"
  },
  {
    "path": "build-terminfo",
    "chars": 1999,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>\n"
  },
  {
    "path": "bypy/devenv.go",
    "chars": 11702,
    "preview": "// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"er"
  },
  {
    "path": "bypy/init_env.py",
    "chars": 4547,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>\n\n"
  },
  {
    "path": "bypy/linux/__main__.py",
    "chars": 8694,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>\n\n"
  },
  {
    "path": "bypy/linux.conf",
    "chars": 268,
    "preview": "image 'https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-{}.img'\n\ndeps 'bison flex li"
  },
  {
    "path": "bypy/macos/__main__.py",
    "chars": 18716,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>\n\n"
  },
  {
    "path": "bypy/macos.conf",
    "chars": 241,
    "preview": "# Requires installation of XCode >= 10.3 and go 1.26 and Python 3 and\n# python3 -m pip install certifi meson ninja\n\nvm_n"
  },
  {
    "path": "bypy/rsync.conf",
    "chars": 182,
    "preview": "to_vm_excludes '/dependencies /build /dist /kitty/launcher/kitty* /.build-cache /.cache /.mypy_cache /.ruff_cache /tags "
  },
  {
    "path": "bypy/site.py",
    "chars": 658,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>\n\n"
  },
  {
    "path": "bypy/sources.json",
    "chars": 9934,
    "preview": "[\n    {\n        \"name\": \"zlib 1.3.2\",\n        \"unix\": {\n            \"file_extension\": \"tar.xz\",\n            \"hash\": \"sha"
  },
  {
    "path": "count-lines-of-code",
    "chars": 730,
    "preview": "#!/usr/bin/env python\n\nimport subprocess\n\nls_files = subprocess.check_output([ 'git', 'ls-files']).decode('utf-8')\nall_f"
  },
  {
    "path": "dev.sh",
    "chars": 165,
    "preview": "#!/bin/sh\n#\n# dev.sh\n# Copyright (C) 2023 Kovid Goyal <kovid at kovidgoyal.net>\n#\n# Distributed under terms of the GPLv3"
  },
  {
    "path": "docs/Makefile",
    "chars": 893,
    "preview": "# Minimal makefile for Sphinx documentation\n#\n\nifdef FAIL_WARN\noverride FAIL_WARN=-W\nendif\n\n# You can set these variable"
  },
  {
    "path": "docs/_static/custom.css",
    "chars": 631,
    "preview": "/*\n * custom.css\n * Copyright (C) 2018 Kovid Goyal\n *\n * Distributed under terms of the MIT license.\n */\n\n.italic {\n    "
  },
  {
    "path": "docs/_static/custom.js",
    "chars": 1910,
    "preview": "/* vim:fileencoding=utf-8\n *\n * Copyright (C) 2021 Kovid Goyal <kovid at kovidgoyal.net>\n *\n * Distributed under terms o"
  },
  {
    "path": "docs/_static/timestamps.css",
    "chars": 230,
    "preview": ".video-with-timestamps dl {\n    display: grid;\n    grid-template-columns: max-content auto;\n}\n\n.video-with-timestamps dt"
  },
  {
    "path": "docs/_static/timestamps.js",
    "chars": 1344,
    "preview": "/*jshint esversion: 6 */\n\n(function() {\n    'use strict';\n\n    function init_timestamps() {\n        document.querySelect"
  },
  {
    "path": "docs/_templates/base.html",
    "chars": 485,
    "preview": "{% extends \"!base.html\" %}\n{% block extrahead %}\n\n  {{ super() }}\n\n  {%- if analytics_id %}\n  <!-- Global site tag (gtag"
  },
  {
    "path": "docs/actions.rst",
    "chars": 497,
    "preview": "Mappable actions\n-----------------------\n\n.. highlight:: conf\n\nThe actions described below can be mapped to any key pres"
  },
  {
    "path": "docs/basic.rst",
    "chars": 7738,
    "preview": "Tabs and Windows\n-------------------\n\n|kitty| is capable of running multiple programs organized into tabs and windows.\nT"
  },
  {
    "path": "docs/binary.rst",
    "chars": 4857,
    "preview": "Install kitty\n========================\n\nBinary install\n----------------\n\n.. highlight:: sh\n\nYou can install pre-built bi"
  },
  {
    "path": "docs/build.rst",
    "chars": 7697,
    "preview": "Build from source\n==================\n\n.. image:: https://github.com/kovidgoyal/kitty/workflows/CI/badge.svg\n  :alt: Buil"
  },
  {
    "path": "docs/changelog.rst",
    "chars": 212892,
    "preview": "Changelog\n==============\n\n|kitty| is a feature-rich, cross-platform, *fast*, GPU based terminal.\nTo update |kitty|, :doc"
  },
  {
    "path": "docs/clipboard.rst",
    "chars": 10175,
    "preview": "Copying all data types to the clipboard\n==============================================\n\nThere already exists an escape c"
  },
  {
    "path": "docs/color-stack.rst",
    "chars": 9143,
    "preview": "Color control\n====================\n\nSaving and restoring colors\n------------------------------\n\nIt is often useful for a"
  },
  {
    "path": "docs/conf.py",
    "chars": 28530,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n#\n# Configuration file for the Sphinx documentation builder.\n#\n# This fil"
  },
  {
    "path": "docs/conf.rst",
    "chars": 3802,
    "preview": "kitty.conf\n================\n\n.. highlight:: conf\n\n\n.. only:: man\n\n    Overview\n    --------------\n\n\n|kitty| is highly cu"
  },
  {
    "path": "docs/deccara.rst",
    "chars": 1018,
    "preview": "Setting text styles/colors in arbitrary regions of the screen\n----------------------------------------------------------"
  },
  {
    "path": "docs/desktop-notifications.rst",
    "chars": 26196,
    "preview": ".. _notifications_on_the_desktop:\n\n\nDesktop notifications\n=======================\n\n|kitty| implements an extensible esca"
  },
  {
    "path": "docs/extract-rst-targets.py",
    "chars": 1989,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport os\nimport re\nfrom "
  },
  {
    "path": "docs/faq.rst",
    "chars": 25997,
    "preview": "Frequently Asked Questions\n==============================\n\n.. highlight:: sh\n\nSome special symbols are rendered small/tr"
  },
  {
    "path": "docs/file-transfer-protocol.rst",
    "chars": 26328,
    "preview": "File transfer over the TTY\n===============================\n\nThere are sometimes situations where the TTY is the only con"
  },
  {
    "path": "docs/glossary.rst",
    "chars": 10227,
    "preview": ":orphan:\n\nGlossary\n=========\n\n.. glossary::\n\n   os_window\n     kitty has two kinds of windows. Operating System windows,"
  },
  {
    "path": "docs/graphics-protocol.rst",
    "chars": 58180,
    "preview": "Terminal graphics protocol\n=================================\n\nThe goal of this specification is to create a flexible and"
  },
  {
    "path": "docs/index.rst",
    "chars": 1926,
    "preview": "kitty\n==========================================================\n\n*If you live in the terminal, kitty is made for YOU!*\n"
  },
  {
    "path": "docs/installer.sh",
    "chars": 4571,
    "preview": "#!/bin/sh\n# Copyright (C) 2018 Kovid Goyal <kovid at kovidgoyal.net>\n#\n# Distributed under terms of the GPLv3 license.\n\n"
  },
  {
    "path": "docs/integrations.rst",
    "chars": 13573,
    "preview": ":tocdepth: 2\n\nIntegrations with other tools\n================================\n\nkitty provides extremely powerful interfac"
  },
  {
    "path": "docs/intro_vid.rst",
    "chars": 1985,
    "preview": ".. raw:: html\n\n    <div id=\"intro-video-container\" class=\"video-with-timestamps\">\n\n    <video controls width=\"640\" heigh"
  },
  {
    "path": "docs/invocation.rst",
    "chars": 203,
    "preview": ":orphan:\n\nThe kitty command line interface\n====================================\n\n.. program:: kitty\n\n.. include:: genera"
  },
  {
    "path": "docs/keyboard-protocol.rst",
    "chars": 36269,
    "preview": "Comprehensive keyboard handling in terminals\n==============================================\n\nThere are various problems "
  },
  {
    "path": "docs/kittens/broadcast.rst",
    "chars": 865,
    "preview": "broadcast\n==================================================\n\n.. only:: man\n\n    Overview\n    --------------\n\n*Type text"
  },
  {
    "path": "docs/kittens/choose-files.rst",
    "chars": 5471,
    "preview": "Selecting files, fast\n========================\n\n.. only:: man\n\n    Overview\n    --------------\n\n.. versionadded:: 0.45.0"
  },
  {
    "path": "docs/kittens/choose-fonts.rst",
    "chars": 6007,
    "preview": "Changing kitty fonts\n========================\n\n.. only:: man\n\n    Overview\n    --------------\n\nTerminal aficionados spen"
  },
  {
    "path": "docs/kittens/clipboard.rst",
    "chars": 1893,
    "preview": "clipboard\n==================================================\n\n.. only:: man\n\n    Overview\n    --------------\n\n*Copy/past"
  },
  {
    "path": "docs/kittens/custom.rst",
    "chars": 13749,
    "preview": "Custom kittens\n=================\n\nYou can easily create your own kittens to extend kitty. They are just terminal\nprogram"
  },
  {
    "path": "docs/kittens/desktop-ui.rst",
    "chars": 5518,
    "preview": "Using terminal programs to provide Linux desktop components\n============================================================"
  },
  {
    "path": "docs/kittens/developing-builtin-kittens.rst",
    "chars": 3430,
    "preview": "Developing builtin kittens\n=============================\n\nBuiltin kittens in kitty are written in the Go language, with "
  },
  {
    "path": "docs/kittens/diff.rst",
    "chars": 4340,
    "preview": "kitty-diff\n================================================================================\n\n*A fast side-by-side diff t"
  },
  {
    "path": "docs/kittens/hints.rst",
    "chars": 5264,
    "preview": "Hints\n==========\n\n.. only:: man\n\n    Overview\n    --------------\n\n\n|kitty| has a *hints mode* to select and act on arbit"
  },
  {
    "path": "docs/kittens/hyperlinked_grep.rst",
    "chars": 3411,
    "preview": "Hyperlinked grep\n=================\n\n.. only:: man\n\n    Overview\n    --------------\n\n\n.. note::\n\n   As of ripgrep version"
  },
  {
    "path": "docs/kittens/icat.rst",
    "chars": 2756,
    "preview": "icat\n========================================\n\n.. only:: man\n\n    Overview\n    --------------\n\n\n*Display images in the t"
  },
  {
    "path": "docs/kittens/notify.rst",
    "chars": 1296,
    "preview": "notify\n==================================================\n\n.. only:: man\n\n    Overview\n    --------------\n\nShow pop-up s"
  },
  {
    "path": "docs/kittens/panel.rst",
    "chars": 7202,
    "preview": "Draw a GPU accelerated dock panel on your desktop\n======================================================================"
  },
  {
    "path": "docs/kittens/query_terminal.rst",
    "chars": 915,
    "preview": "Query terminal\n=================\n\n.. only:: man\n\n    Overview\n    --------------\n\n\nThis kitten is used to query |kitty| "
  },
  {
    "path": "docs/kittens/quick-access-terminal.rst",
    "chars": 2809,
    "preview": ".. _quake:\n\nMake a Quake like quick access terminal\n===================================================================="
  },
  {
    "path": "docs/kittens/remote_file.rst",
    "chars": 1731,
    "preview": "Remote files\n==============\n\n.. only:: man\n\n    Overview\n    --------------\n\n\n|kitty| has the ability to easily *Edit*, "
  },
  {
    "path": "docs/kittens/ssh.rst",
    "chars": 8271,
    "preview": "Truly convenient SSH\n=========================================\n\n.. only:: man\n\n   Overview\n   ----------------\n\n* Automa"
  },
  {
    "path": "docs/kittens/themes.rst",
    "chars": 5464,
    "preview": "Changing kitty colors\n========================\n\n.. only:: man\n\n    Overview\n    --------------\n\n\nThe themes kitten allow"
  },
  {
    "path": "docs/kittens/transfer.rst",
    "chars": 3374,
    "preview": "Transfer files\n================\n\n.. only:: man\n\n    Overview\n    --------------\n\n\n.. versionadded:: 0.30.0\n\n.. _rsync: h"
  },
  {
    "path": "docs/kittens/unicode_input.rst",
    "chars": 1469,
    "preview": "Unicode input\n================\n\n.. only:: man\n\n    Overview\n    --------------\n\n\nYou can input Unicode characters by nam"
  },
  {
    "path": "docs/kittens_intro.rst",
    "chars": 2904,
    "preview": ".. _kittens:\n\nExtend with kittens\n-----------------------\n\n.. toctree::\n   :hidden:\n   :glob:\n\n   kittens/icat\n   kitten"
  },
  {
    "path": "docs/launch.rst",
    "chars": 8813,
    "preview": "The :command:`launch` command\n--------------------------------\n\n.. program:: launch\n\n\n|kitty| has a :code:`launch` actio"
  },
  {
    "path": "docs/layouts.rst",
    "chars": 12373,
    "preview": "Arrange windows\n-------------------\n\nkitty has the ability to define its own windows that can be tiled next to each\nothe"
  },
  {
    "path": "docs/mapping.rst",
    "chars": 15392,
    "preview": ":orphan:\n\nMaking your keyboard dance\n==============================\n\n.. highlight:: conf\n\nkitty has extremely powerful f"
  },
  {
    "path": "docs/marks.rst",
    "chars": 4034,
    "preview": "Mark text on screen\n---------------------\n\n\nkitty has the ability to mark text on the screen based on regular expression"
  },
  {
    "path": "docs/misc-protocol.rst",
    "chars": 2791,
    "preview": "Miscellaneous protocol extensions\n==============================================\n\nThese are a few small protocol extensi"
  },
  {
    "path": "docs/multiple-cursors-protocol.rst",
    "chars": 10321,
    "preview": "The multiple cursors protocol\n==============================================\n\n.. versionadded:: 0.43.0\n\nMany editors sup"
  },
  {
    "path": "docs/notifications.py",
    "chars": 1963,
    "preview": "#!/usr/bin/env python\n\n# A sample script to process notifications. Save it as\n# ~/.config/kitty/notifications.py\n\nimport"
  },
  {
    "path": "docs/open_actions.rst",
    "chars": 6157,
    "preview": "Scripting the mouse click\n======================================================\n\n|kitty| has support for :term:`termina"
  },
  {
    "path": "docs/overview.rst",
    "chars": 10894,
    "preview": "Overview\n==============\n\nDesign philosophy\n-------------------\n\n|kitty| is designed for power keyboard users. To that en"
  },
  {
    "path": "docs/performance.rst",
    "chars": 6765,
    "preview": "Performance\n===================\n\nThe main goals for |kitty| performance are user perceived latency while typing\nand \"smo"
  },
  {
    "path": "docs/pipe.rst",
    "chars": 2874,
    "preview": ":orphan:\n\nWorking with the screen and history buffer contents\n======================================================\n\n.."
  },
  {
    "path": "docs/pointer-shapes.rst",
    "chars": 6084,
    "preview": "Mouse pointer shapes\n=======================\n\n.. versionadded:: 0.31.0\n\nThis is a simple escape code that can be used by"
  },
  {
    "path": "docs/press-mentions.rst",
    "chars": 516,
    "preview": "Press mentions of kitty\n========================\n\n`Python Bytes 272 <https://youtu.be/8HKliSbA-gQ?t=815>`__ (Feb 2022)\n "
  },
  {
    "path": "docs/protocol-extensions.rst",
    "chars": 1446,
    "preview": "Terminal protocol extensions\n===================================\n\n|kitty| has extensions to the legacy terminal protocol"
  },
  {
    "path": "docs/quake-screenshots.rst",
    "chars": 883,
    "preview": "\n.. sidebar::\n\n    .. only:: not man\n\n        **Screenshots**\n\n        .. figure:: /screenshots/quake-macos.webp\n       "
  },
  {
    "path": "docs/quickstart.rst",
    "chars": 911,
    "preview": ".. _quickstart:\n\nQuickstart\n===========\n\n.. toctree::\n   :hidden:\n\n   binary\n   build\n\nPre-built binaries of |kitty| are"
  },
  {
    "path": "docs/rc_protocol.rst",
    "chars": 4873,
    "preview": "The kitty remote control protocol\n==================================\n\nThe kitty remote control protocol is a simple prot"
  },
  {
    "path": "docs/remote-control.rst",
    "chars": 14173,
    "preview": "Control kitty from scripts\n----------------------------\n\n.. highlight:: sh\n\n|kitty| can be controlled from scripts or th"
  },
  {
    "path": "docs/requirements.txt",
    "chars": 151,
    "preview": "# sphinx-inline-tabs breaks with sphinx >= 9\nsphinx <= 8.2.3\nfuro\nsphinx-copybutton\nsphinxext-opengraph\nsphinx-inline-ta"
  },
  {
    "path": "docs/sessions.rst",
    "chars": 15404,
    "preview": ".. _sessions:\n\nSessions\n=============\n\nkitty has robust support for sessions. A session is basically a simple text\nfile "
  },
  {
    "path": "docs/shell-integration.rst",
    "chars": 18755,
    "preview": ".. _shell_integration:\n\nShell integration\n-------------------\n\nkitty has the ability to integrate closely within common "
  },
  {
    "path": "docs/support.html",
    "chars": 1979,
    "preview": "<style>\n#support-buttons {\n    display: flex;\n    flex-wrap: wrap;\n}\n\n.support-button {\n    box-sizing: border-box;\n    "
  },
  {
    "path": "docs/support.rst",
    "chars": 962,
    "preview": "Support kitty development ❤️\n==============================\n\nMy goal with |kitty| is to move the stagnant terminal ecosy"
  },
  {
    "path": "docs/text-sizing-protocol.rst",
    "chars": 24403,
    "preview": "The text sizing protocol\n==============================================\n\n.. versionadded:: 0.40.0\n\nClassically, because "
  },
  {
    "path": "docs/underlines.rst",
    "chars": 1421,
    "preview": "Colored and styled underlines\n================================\n\n|kitty| supports colored and styled (wavy) underlines. T"
  },
  {
    "path": "docs/unscroll.rst",
    "chars": 1657,
    "preview": ".. _unscroll:\n\nUnscrolling the screen\n========================\n\nThis is a small extension to the `SD (Pan up) escape cod"
  },
  {
    "path": "docs/wide-gamut-colors.rst",
    "chars": 2676,
    "preview": "Wide gamut color formats\n=========================\n\nkitty supports modern wide gamut color formats for precise color spe"
  },
  {
    "path": "embeds.go",
    "chars": 564,
    "preview": "package kitty\n\nimport (\n\t_ \"embed\"\n\t\"encoding/json\"\n\t\"fmt\"\n)\n\nvar _ = fmt.Print\n\n//go:embed logo/kitty.png\nvar KittyLogo"
  },
  {
    "path": "gen/README.rst",
    "chars": 268,
    "preview": "Scripts to generate code for various things like keys, mouse cursors, unicode\ndata etc. Some of these generate code that"
  },
  {
    "path": "gen/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "gen/__main__.py",
    "chars": 1192,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>\n\n\nimport os\nimport sys\n\n\nd"
  },
  {
    "path": "gen/apc_parsers.py",
    "chars": 12123,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport os\nimport subproce"
  },
  {
    "path": "gen/bitfields.py",
    "chars": 1930,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport os\nfrom typing imp"
  },
  {
    "path": "gen/color_names.py",
    "chars": 27594,
    "preview": "#!./kitty/launcher/kitty +launch\n# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport os\nimpo"
  },
  {
    "path": "gen/config.py",
    "chars": 2686,
    "preview": "#!./kitty/launcher/kitty +launch\n# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>\n\n\nimport os\nimp"
  },
  {
    "path": "gen/cursors.py",
    "chars": 9247,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport os\nimport subproce"
  },
  {
    "path": "gen/go_code.py",
    "chars": 36619,
    "preview": "#!./kitty/launcher/kitty +launch\n# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport argpars"
  },
  {
    "path": "gen/key_constants.py",
    "chars": 19915,
    "preview": "#!/usr/bin/env python\n# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>\n\nimport os\nimport string\ni"
  },
  {
    "path": "gen/rowcolumn-diacritics.txt",
    "chars": 18055,
    "preview": "# This file lists the diacritics used to indicate row/column numbers for\n# Unicode terminal image placeholders. It is de"
  },
  {
    "path": "gen/srgb_lut.py",
    "chars": 1419,
    "preview": "#!/usr/bin/env python\n\nimport os\nimport sys\nfrom functools import lru_cache\n\nif __name__ == '__main__' and not __package"
  },
  {
    "path": "gen/wcwidth.py",
    "chars": 46124,
    "preview": "#!/usr/bin/env python\n# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>\n\n# Imports {{{\nimport jso"
  },
  {
    "path": "glad/generate.py",
    "chars": 1139,
    "preview": "#!/usr/bin/env python\n# vim:fileencoding=utf-8\n# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>\n"
  },
  {
    "path": "glfw/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "glfw/backend_utils.c",
    "chars": 14100,
    "preview": "/*\n * backend_utils.c\n * Copyright (C) 2018 Kovid Goyal <kovid at kovidgoyal.net>\n *\n * Distributed under terms of the G"
  },
  {
    "path": "glfw/backend_utils.h",
    "chars": 3810,
    "preview": "//========================================================================\n// GLFW 3.4\n//-------------------------------"
  },
  {
    "path": "glfw/cocoa_displaylink.m",
    "chars": 10987,
    "preview": "/*\n * cocoa_displaylink.m\n * Copyright (C) 2024 Kovid Goyal <kovid at kovidgoyal.net>\n *\n * Distributed under terms of t"
  },
  {
    "path": "glfw/cocoa_init.m",
    "chars": 52100,
    "preview": "//========================================================================\n// GLFW 3.4 macOS - www.glfw.org\n//----------"
  },
  {
    "path": "glfw/cocoa_joystick.h",
    "chars": 1701,
    "preview": "//========================================================================\n// GLFW 3.4 Cocoa - www.glfw.org\n//----------"
  },
  {
    "path": "glfw/cocoa_joystick.m",
    "chars": 15631,
    "preview": "//========================================================================\n// GLFW 3.4 Cocoa - www.glfw.org\n//----------"
  },
  {
    "path": "glfw/cocoa_monitor.m",
    "chars": 20491,
    "preview": "//========================================================================\n// GLFW 3.4 macOS - www.glfw.org\n//----------"
  },
  {
    "path": "glfw/cocoa_platform.h",
    "chars": 10239,
    "preview": "//========================================================================\n// GLFW 3.4 macOS - www.glfw.org\n//----------"
  },
  {
    "path": "glfw/cocoa_window.m",
    "chars": 176802,
    "preview": "//========================================================================\n// GLFW 3.4 macOS - www.glfw.org\n//----------"
  },
  {
    "path": "glfw/context.c",
    "chars": 19471,
    "preview": "//========================================================================\n// GLFW 3.4 - www.glfw.org\n//----------------"
  },
  {
    "path": "glfw/dbus_glfw.c",
    "chars": 12509,
    "preview": "//========================================================================\n// GLFW 3.4 XKB - www.glfw.org\n//------------"
  },
  {
    "path": "glfw/dbus_glfw.h",
    "chars": 2891,
    "preview": "//========================================================================\n// GLFW 3.4 XKB - www.glfw.org\n//------------"
  },
  {
    "path": "glfw/egl_context.c",
    "chars": 27113,
    "preview": "//========================================================================\n// GLFW 3.4 EGL - www.glfw.org\n//------------"
  }
]

// ... and 751 more files (download for full content)

About this extraction

This page contains the full source code of the kovidgoyal/kitty GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 951 files (13.6 MB), approximately 3.6M tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!