Compare commits
18 Commits
62c6d43ca3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
fe0381c762
|
|||
|
019c4302ad
|
|||
|
189bf94034
|
|||
|
3071db8e19
|
|||
|
0bbcbb7207
|
|||
|
d57db951aa
|
|||
|
417115c3be
|
|||
|
3c96448bcf
|
|||
|
92902a4f76
|
|||
|
43ef4805a5
|
|||
|
a29a785b20
|
|||
|
accc095403
|
|||
|
b15ec36e38
|
|||
|
b000f5eca7
|
|||
|
35cbb8647d
|
|||
|
f6d552766b
|
|||
|
00d6c5ede9
|
|||
|
b87206bb93
|
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required (VERSION 3.0)
|
cmake_minimum_required (VERSION 3.0...3.27)
|
||||||
project (hex VERSION 0.1.0 LANGUAGES C)
|
project (hex VERSION 0.1.0 LANGUAGES C)
|
||||||
|
|
||||||
# Moar warnings
|
# Moar warnings
|
||||||
@@ -20,7 +20,6 @@ include (AddThreads)
|
|||||||
find_package (Termo QUIET NO_MODULE)
|
find_package (Termo QUIET NO_MODULE)
|
||||||
option (USE_SYSTEM_TERMO
|
option (USE_SYSTEM_TERMO
|
||||||
"Don't compile our own termo library, use the system one" ${Termo_FOUND})
|
"Don't compile our own termo library, use the system one" ${Termo_FOUND})
|
||||||
|
|
||||||
if (USE_SYSTEM_TERMO)
|
if (USE_SYSTEM_TERMO)
|
||||||
if (NOT Termo_FOUND)
|
if (NOT Termo_FOUND)
|
||||||
message (FATAL_ERROR "System termo library not found")
|
message (FATAL_ERROR "System termo library not found")
|
||||||
@@ -41,11 +40,10 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set (project_libraries ${Unistring_LIBRARIES}
|
set (project_libraries ${Unistring_LIBRARIES}
|
||||||
${Ncursesw_LIBRARIES} termo-static)
|
${Ncursesw_LIBRARIES} ${Termo_LIBRARIES})
|
||||||
|
|
||||||
pkg_search_module (lua lua53 lua5.3 lua-5.3 lua>=5.3)
|
pkg_search_module (lua lua53 lua5.3 lua-5.3 lua54 lua5.4 lua-5.4 lua>=5.3)
|
||||||
option (WITH_LUA "Enable support for Lua plugins" ${lua_FOUND})
|
option (WITH_LUA "Enable support for Lua plugins" ${lua_FOUND})
|
||||||
|
|
||||||
if (WITH_LUA)
|
if (WITH_LUA)
|
||||||
if (NOT lua_FOUND)
|
if (NOT lua_FOUND)
|
||||||
message (FATAL_ERROR "Lua library not found")
|
message (FATAL_ERROR "Lua library not found")
|
||||||
@@ -54,28 +52,37 @@ if (WITH_LUA)
|
|||||||
list (APPEND project_libraries ${lua_LIBRARIES})
|
list (APPEND project_libraries ${lua_LIBRARIES})
|
||||||
include_directories (${lua_INCLUDE_DIRS})
|
include_directories (${lua_INCLUDE_DIRS})
|
||||||
link_directories (${lua_LIBRARY_DIRS})
|
link_directories (${lua_LIBRARY_DIRS})
|
||||||
|
|
||||||
include (CheckTypeSize)
|
|
||||||
set (CMAKE_REQUIRED_LIBRARIES ${lua_LIBRARIES})
|
|
||||||
set (CMAKE_REQUIRED_INCLUDES ${lua_INCLUDE_DIRS})
|
|
||||||
set (CMAKE_EXTRA_INCLUDE_FILES "lua.h")
|
|
||||||
CHECK_TYPE_SIZE (lua_Integer LUA_INTEGER)
|
|
||||||
if (NOT HAVE_LUA_INTEGER OR LUA_INTEGER LESS 8)
|
|
||||||
message (FATAL_ERROR "Lua must have at least 64-bit integers")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
pkg_check_modules (x11 x11 xrender xft fontconfig libpng)
|
||||||
|
option (WITH_X11 "Build with X11 support" ${x11_FOUND})
|
||||||
|
if (WITH_X11)
|
||||||
|
if (NOT x11_FOUND)
|
||||||
|
message (FATAL_ERROR "Some X11 libraries were not found")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
list (APPEND project_libraries ${x11_LIBRARIES})
|
||||||
|
include_directories (${x11_INCLUDE_DIRS})
|
||||||
|
link_directories (${x11_LIBRARY_DIRS})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include_directories (${Unistring_INCLUDE_DIRS}
|
include_directories (${Unistring_INCLUDE_DIRS}
|
||||||
${Ncursesw_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS})
|
${Ncursesw_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS})
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
|
||||||
|
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
|
||||||
|
# our POSIX version macros make it undefined
|
||||||
|
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
|
||||||
|
elseif (APPLE)
|
||||||
|
add_definitions (-D_DARWIN_C_SOURCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
include (CheckFunctionExists)
|
include (CheckFunctionExists)
|
||||||
set (CMAKE_REQUIRED_LIBRARIES ${Ncursesw_LIBRARIES})
|
set (CMAKE_REQUIRED_LIBRARIES ${Ncursesw_LIBRARIES})
|
||||||
CHECK_FUNCTION_EXISTS ("resizeterm" HAVE_RESIZETERM)
|
CHECK_FUNCTION_EXISTS ("resizeterm" HAVE_RESIZETERM)
|
||||||
|
|
||||||
# Generate a configuration file
|
# Generate a configuration file
|
||||||
set (HAVE_LUA "${WITH_LUA}")
|
|
||||||
|
|
||||||
configure_file (${PROJECT_SOURCE_DIR}/config.h.in
|
configure_file (${PROJECT_SOURCE_DIR}/config.h.in
|
||||||
${PROJECT_BINARY_DIR}/config.h)
|
${PROJECT_BINARY_DIR}/config.h)
|
||||||
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
|
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
|
||||||
@@ -89,6 +96,30 @@ add_threads (${PROJECT_NAME})
|
|||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||||
|
if (WITH_LUA)
|
||||||
|
install (DIRECTORY plugins
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
|
||||||
|
endif ()
|
||||||
|
if (WITH_X11)
|
||||||
|
include (IconUtils)
|
||||||
|
|
||||||
|
set (icon_base ${PROJECT_BINARY_DIR}/icons)
|
||||||
|
set (icon_png_list)
|
||||||
|
foreach (icon_size 16 32 48)
|
||||||
|
icon_to_png (${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.svg
|
||||||
|
${icon_size} ${icon_base} icon_png)
|
||||||
|
list (APPEND icon_png_list ${icon_png})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
add_custom_target (icons ALL DEPENDS ${icon_png_list})
|
||||||
|
|
||||||
|
install (FILES ${PROJECT_NAME}.svg
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
|
||||||
|
install (DIRECTORY ${icon_base}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATADIR})
|
||||||
|
install (FILES ${PROJECT_NAME}.desktop
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Generate documentation from text markup
|
# Generate documentation from text markup
|
||||||
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
|
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
|
||||||
@@ -137,7 +168,7 @@ foreach (page ${project_MAN_PAGES})
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
# CPack
|
# CPack
|
||||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hex viewer")
|
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Interpreting hex viewer")
|
||||||
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
|
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
|
||||||
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
|
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
|
||||||
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2016 - 2017, Přemysl Eric Janouch <p@janouch.name>
|
Copyright (c) 2016 - 2024, Přemysl Eric Janouch <p@janouch.name>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted.
|
purpose with or without fee is hereby granted.
|
||||||
|
|||||||
16
README.adoc
16
README.adoc
@@ -3,7 +3,7 @@ hex
|
|||||||
|
|
||||||
'hex' is yet another hex viewer. It automatically interprets fields within
|
'hex' is yet another hex viewer. It automatically interprets fields within
|
||||||
files using a set of Lua scripts, colorizing them and showing descriptions on
|
files using a set of Lua scripts, colorizing them and showing descriptions on
|
||||||
the side.
|
the side. It also runs equally well in the terminal, or as an X11 client.
|
||||||
|
|
||||||
At the moment there aren't that many features and we only have a few decoders.
|
At the moment there aren't that many features and we only have a few decoders.
|
||||||
|
|
||||||
@@ -11,8 +11,10 @@ image::hex.png[align="center"]
|
|||||||
|
|
||||||
Packages
|
Packages
|
||||||
--------
|
--------
|
||||||
Regular releases are sporadic. git master should be stable enough. You can get
|
Regular releases are sporadic. git master should be stable enough.
|
||||||
a package with the latest development version from Archlinux's AUR.
|
You can get a package with the latest development version using Arch Linux's
|
||||||
|
https://aur.archlinux.org/packages/hex-git[AUR],
|
||||||
|
or as a https://git.janouch.name/p/nixexprs[Nix derivation].
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
@@ -21,9 +23,11 @@ The rest of this README will concern itself with externalities.
|
|||||||
|
|
||||||
Building and Running
|
Building and Running
|
||||||
--------------------
|
--------------------
|
||||||
Build dependencies: CMake, pkg-config, awk, liberty (included),
|
Build-only dependencies: CMake, pkg-config, awk, liberty (included),
|
||||||
termo (included), asciidoctor or asciidoc (recommended but optional) +
|
termo (included), asciidoctor or asciidoc (recommended but optional),
|
||||||
Runtime dependencies: ncursesw, libunistring, Lua >= 5.3 (for highlighting)
|
rsvg-convert (X11) +
|
||||||
|
Runtime dependencies: ncursesw, libunistring, Lua >= 5.3 (for highlighting) +
|
||||||
|
Optional runtime dependencies: x11 + xft + libpng (X11)
|
||||||
|
|
||||||
$ git clone --recursive https://git.janouch.name/p/hex.git
|
$ git clone --recursive https://git.janouch.name/p/hex.git
|
||||||
$ mkdir hex/build
|
$ mkdir hex/build
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
#define PROGRAM_VERSION "${PROJECT_VERSION}"
|
#define PROGRAM_VERSION "${PROJECT_VERSION}"
|
||||||
|
|
||||||
#cmakedefine HAVE_RESIZETERM
|
#cmakedefine HAVE_RESIZETERM
|
||||||
#cmakedefine HAVE_LUA
|
#cmakedefine WITH_LUA
|
||||||
|
#cmakedefine WITH_X11
|
||||||
|
|
||||||
#endif // ! CONFIG_H
|
#endif // ! CONFIG_H
|
||||||
|
|
||||||
|
|||||||
4
hex.adoc
4
hex.adoc
@@ -38,6 +38,10 @@ _G_=1024M, and _GB_=1000M. The default value is 1G.
|
|||||||
*-d*, *--debug*::
|
*-d*, *--debug*::
|
||||||
Run in debug mode.
|
Run in debug mode.
|
||||||
|
|
||||||
|
*-x*, *--x11*::
|
||||||
|
Use an X11 interface even when run from a terminal.
|
||||||
|
Note that the application may be built with this feature disabled.
|
||||||
|
|
||||||
*-h*, *--help*::
|
*-h*, *--help*::
|
||||||
Display a help message and exit.
|
Display a help message and exit.
|
||||||
|
|
||||||
|
|||||||
9
hex.desktop
Normal file
9
hex.desktop
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=hex
|
||||||
|
GenericName=Interpreting hex viewer
|
||||||
|
Icon=hex
|
||||||
|
Exec=hex %f
|
||||||
|
NoDisplay=true
|
||||||
|
StartupNotify=false
|
||||||
|
Categories=Utility;
|
||||||
10
hex.svg
Normal file
10
hex.svg
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg version="1.0" width="48" height="48" viewBox="0 0 48 48"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g transform="translate(24 24) scale(2 2)">
|
||||||
|
<path d="M 0 0 -10 0 -10 -10 0 -10 Z" stroke-width="0" fill="#c6ffd6" />
|
||||||
|
<path d="M 0 0 10 0 10 -10 0 -10 Z" stroke-width="0" fill="#ffd8d8" />
|
||||||
|
<path d="M 0 0 -10 0 -10 10 0 10 Z" stroke-width="0" fill="#d8d8ff" />
|
||||||
|
<path d="M 0 0 10 0 10 10 0 10 Z" stroke-width="0" fill="#ffffac" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 524 B |
2
liberty
2
liberty
Submodule liberty updated: 34f86651f6...d8f785eae5
@@ -18,7 +18,7 @@
|
|||||||
-- See man 5 elf, /usr/include/elf.h and /usr/include/llvm/Support/ELF.h
|
-- See man 5 elf, /usr/include/elf.h and /usr/include/llvm/Support/ELF.h
|
||||||
|
|
||||||
local detect = function (c)
|
local detect = function (c)
|
||||||
return c:read (4) == "\x7FELF"
|
return #c >= 4 and c:read (4) == "\x7FELF"
|
||||||
end
|
end
|
||||||
|
|
||||||
local ph_type_table = {
|
local ph_type_table = {
|
||||||
@@ -63,7 +63,7 @@ local decode_ph = function (elf, c)
|
|||||||
ph.vaddr = elf.uwide (c, "virtual address: %#x")
|
ph.vaddr = elf.uwide (c, "virtual address: %#x")
|
||||||
ph.paddr = elf.uwide (c, "physical address: %#x")
|
ph.paddr = elf.uwide (c, "physical address: %#x")
|
||||||
ph.filesz = elf.uwide (c, "size in file: %d")
|
ph.filesz = elf.uwide (c, "size in file: %d")
|
||||||
ph.memsz = elf.uwide (c, "sise in memory: %d")
|
ph.memsz = elf.uwide (c, "size in memory: %d")
|
||||||
if elf.class == 1 then ph.flags = c:u32 ("flags: %s", xform_ph_flags) end
|
if elf.class == 1 then ph.flags = c:u32 ("flags: %s", xform_ph_flags) end
|
||||||
ph.align = elf.uwide (c, "alignment: %d")
|
ph.align = elf.uwide (c, "alignment: %d")
|
||||||
return ph
|
return ph
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
local detect = function (c)
|
local detect = function (c)
|
||||||
return c:read (2) == "\x1f\x8b"
|
return #c >= 2 and c:read (2) == "\x1f\x8b"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function latin1_to_utf8 (s)
|
local function latin1_to_utf8 (s)
|
||||||
|
|||||||
@@ -16,11 +16,17 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
local detect = function (c)
|
local detect = function (c)
|
||||||
|
if #c < 4 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
local magic = c:u32 ()
|
local magic = c:u32 ()
|
||||||
return magic == 0xa1b2c3d4 or magic == 0xd4c3b2a1
|
return magic == 0xa1b2c3d4 or magic == 0xd4c3b2a1
|
||||||
end
|
end
|
||||||
|
|
||||||
local detect_ng = function (c)
|
local detect_ng = function (c)
|
||||||
|
if #c < 8 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
local magic = c (9):u32 ()
|
local magic = c (9):u32 ()
|
||||||
return c:u32 () == 0x0a0d0d0a
|
return c:u32 () == 0x0a0d0d0a
|
||||||
and (magic == 0x1a2b3c4d or magic == 0x4d3c2b1a)
|
and (magic == 0x1a2b3c4d or magic == 0x4d3c2b1a)
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ end
|
|||||||
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
local detect = function (c)
|
local detect = function (c)
|
||||||
return c:read (5) == "%PDF-"
|
return #c >= 5 and c:read (5) == "%PDF-"
|
||||||
end
|
end
|
||||||
|
|
||||||
local decode_xref_subsection = function (lex, start, count, result)
|
local decode_xref_subsection = function (lex, start, count, result)
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
local detect = function (c)
|
local detect = function (c)
|
||||||
|
if #c < 68 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
c.position = 65
|
c.position = 65
|
||||||
return c:read (4) == "\x7F\x10\xDA\xBE"
|
return c:read (4) == "\x7F\x10\xDA\xBE"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
local detect = function (c)
|
local detect = function (c)
|
||||||
return c:read (4) == "Xcur"
|
return #c >= 4 and c:read (4) == "Xcur"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- https://www.x.org/releases/current/doc/man/man3/Xcursor.3.xhtml
|
-- https://www.x.org/releases/current/doc/man/man3/Xcursor.3.xhtml
|
||||||
|
|||||||
2
termo
2
termo
Submodule termo updated: 8265f075b1...f9a102456f
Reference in New Issue
Block a user