Add [hexedit]
Package name
hexedit
Brief description of package
hexedit is a very old and extremely useful and small tool for inspecting and editing files on the binary level via Hex code. It's an essential in every single nix distribution. I'm very surprised no package already provided this.
URL for package's homepage
https://github.com/pixel/hexedit/ https://man.archlinux.org/man/hexedit.1.en
Provide a basic test case to validate the package's functionality.
see repo
MINGW environments where you need the package
- [x] MINGW64
- [ ] MINGW32
- [x] UCRT64
- [x] CLANG64
- [ ] CLANGARM64
Are you willing to submit a PR?
possibly
Link to Arch: https://archlinux.org/packages/extra/x86_64/hexedit/
Note that we already have various hex editors:
- https://packages.msys2.org/base/mingw-w64-hexyl
- https://packages.msys2.org/base/mingw-w64-ghex
- https://packages.msys2.org/base/hexcurse (seems abandoned though, so maybe this would be a good replacement)
I don't know if they provide the features you need, but maybe you can give them a try.
@lazka Hi Christoph, Thanks for quick reply.
Note that we already have various hex editors: ... mingw-w64-hexyl (Requires Rust!) ... mingw-w64-ghex (Requires the GNOME desktop!)
I've never heard of those! And with those names, I would certainly never find them when searching for a hex editor. 😆 Also, I'm looking for a minimalist CLI tool, not a desktop application. So although they look nice, it's not something I can use.
Anyway, I managed to get original hexedit to compile under MSYS, without modification, but not under MINGW64. There I get:
gcc -DHAVE_CONFIG_H -I/mingw64/include/ncurses -c display.c
display.c: In function 'initCurses':
display.c:106:20: error: storage size of 'sa' isn't known
106 | struct sigaction sa;
| ^~
make: *** [Makefile:31: display.o] Error 1
Some AI told me:
The error storage size of 'sa' isn't known means that struct sigaction is not defined.
This is a POSIX-specific structure that doesn't exist in Windows/MinGW's headers.
This is a deeper compatibility issue - hexedit uses POSIX signal handling which isn't directly available on Windows.
So I tried on MSYS, and it worked.
UPDATE
I now also managed to get it to compile and run for MINGW64, with some minor patches.
You need to apply the following (from: # git diff display.c interact.c):
diff --git a/display.c b/display.c
index 06a2b31..7812f30 100644
--- a/display.c
+++ b/display.c
@@ -14,6 +14,10 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
+#include <windows.h>
+#ifndef __MINGW32__
+#include <signal.h>
+#endif
#include "hexedit.h"
int move_cursor(INT delta)
@@ -103,7 +107,9 @@ int computeCursorXPos(int cursor, int hexOrAscii)
void initCurses(void)
{
+#ifndef __MINGW32__
struct sigaction sa;
+#endif
initscr();
#ifdef HAVE_COLORS
diff --git a/interact.c b/interact.c
index 5eb1fc4..0668375 100644
--- a/interact.c
+++ b/interact.c
@@ -15,7 +15,11 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
#include "hexedit.h"
-
+#ifndef __MINGW32__
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#endif
static void goto_char(void);
static void goto_sector(void);
@@ -116,7 +120,14 @@ static void end_of_buffer(void)
set_cursor(s);
}
+#ifdef __MINGW32__
+static void suspend(void) {
+ displayMessageAndWaitForKey("Suspend not supported on Windows");
+}
+#else
static void suspend(void) { kill(getpid(), SIGTSTP); }
+#endif
+
static void undo(void) { discardEdited(); readFile(); }
static void quoted_insert(void) { setTo(getch()); }
static void toggle(void) { hexOrAscii = (hexOrAscii + 1) % 2; }
@@ -306,6 +317,15 @@ static void save_buffer(void)
static void help(void)
{
+#ifdef __MINGW32__
+ /* Windows doesn't have fork/exec, and likely doesn't have man pages */
+ displayTwoLineMessage(
+ "Help: Open https://github.com/pixel/hexedit in a browser",
+ "or run 'man hexedit' on Linux/Unix for full documentation"
+ );
+ getch();
+ refresh();
+#else
char *args[3];
int status;
@@ -319,6 +339,7 @@ static void help(void)
}
wait(&status);
refresh();
+#endif
raw();
}
However, the --color switch produces no color in MINGW64.
Also, the binaries are not compatible, and need to be compiled for each environment.
(I'm not sure how to make them environment agnostic.)
The build commands for MSYS and MINGW64 are:
# For MSYS:
./autogen.sh && ./configure CFLAGS="-I/usr/include/ncursesw" LDFLAGS="-L/usr/lib" LIBS="-lncursesw" && make
# For MINGW64:
./autogen.sh && ./configure CFLAGS="-I/mingw64/include/ncursesw" LDFLAGS="-L/mingw64/lib" LIBS="-lncursesw" && make
# For both:
make install
@lazka Hi Christoph, Thanks for quick reply.
Note that we already have various hex editors: ... mingw-w64-hexyl (Requires Rust!) ... mingw-w64-ghex (Requires the GNOME desktop!)
I've never heard of those! And with those names, I would certainly never find them when searching for a hex editor. 😆 Also, I'm looking for a minimalist CLI tool, not a desktop application. So although they look nice, it's not something I can use.
Well, hexyl runs in the terminal. I'd say that is a pretty minimalistic CLI tool. And Rust is only required to build hexyl, but not to run it. Just install the package with pacman and you can use it. No Rust required.