[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] utils: new utility pk-bin2poke
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] utils: new utility pk-bin2poke |
Date: |
Sun, 09 Jan 2022 12:25:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2022-01-08 Jose E. Marchesi <jemarch@gnu.org>
* utils/pk-bin2poke.in: New file.
* utils/Makefile.am (pk-bin2poke): New rule.
(EXTRA_DIST): Add pk-bin2poke.
(bin_SCRIPTS): Likewise.
---
ChangeLog | 7 +++++++
utils/Makefile.am | 9 +++++++--
utils/pk-bin2poke.in | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)
create mode 100644 utils/pk-bin2poke.in
diff --git a/ChangeLog b/ChangeLog
index 97c7712c..714a2961 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-01-08 Jose E. Marchesi <jemarch@gnu.org>
+
+ * utils/pk-bin2poke.in: New file.
+ * utils/Makefile.am (pk-bin2poke): New rule.
+ (EXTRA_DIST): Add pk-bin2poke.
+ (bin_SCRIPTS): Likewise.
+
2022-01-08 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pkl-ast.h (pkl_ast_type_integrable_p): New function.
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 5608fbe5..fd15d835 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -15,9 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-bin_SCRIPTS = pk-elfextractor pk-strings
+bin_SCRIPTS = pk-elfextractor pk-strings pk-bin2poke
CLEANFILES = $(bin_SCRIPTS)
-EXTRA_DIST = pk-elfextractor.in pk-strings.in
+EXTRA_DIST = pk-elfextractor.in pk-strings.in pk-bin2poke.in
do_subst = sed -e 's,[@]bindir[@],$(bindir),g'
@@ -28,3 +28,8 @@ pk-elfextractor: pk-elfextractor.in Makefile
pk-strings: pk-strings.in Makefile
$(do_subst) < $(srcdir)/pk-strings.in > pk-strings
chmod +x pk-strings
+
+pk-bin2poke: pk-bin2poke.in Makefile
+ $(do_subst) < $(srcdir)/pk-bin2poke.in > pk-bin2poke
+ chmod +x pk-bin2poke
+
diff --git a/utils/pk-bin2poke.in b/utils/pk-bin2poke.in
new file mode 100644
index 00000000..1272ad6c
--- /dev/null
+++ b/utils/pk-bin2poke.in
@@ -0,0 +1,52 @@
+#!@bindir@/poke -L
+!#
+
+/* pk-bin2poke - Translate a binary to a Poke file. */
+
+/* Copyright (C) 2022 Jose E. Marchesi */
+
+/* This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+var stdin = open ("<stdin>");
+var stdout = open ("<stdout>");
+
+fun write_string = (string s) void:
+{
+ var ca = char[s'length] ();
+
+ stoca (s, ca);
+ char[] @ stdout : iosize (stdout) = ca;
+}
+
+var offset = 0#B;
+
+write_string ("var _data = [\n");
+
+try
+{
+ flush (stdin, offset);
+
+ if (offset > 0#B && offset % 8#B == 0#B)
+ write_string ("\n");
+
+ var b = byte @ stdin : offset++;
+ write_string (format ("0x%u8xUB, " b));
+}
+until E_eof;
+
+write_string ("];\n");
+
+close (stdin);
+close (stdout);
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] utils: new utility pk-bin2poke,
Jose E. Marchesi <=