(Click here to evaluate this HTML)
このプログラムは、dump(バイナリファイルを文字コードに変換)およびundump(dumpの逆)をするプログラムです。このプログラムの著作権は全て私 yh8888が所有します。
binedit は、dump と undump をするソフトです。
Dump機能では、任意のファイルを、文字コードを並べたファイルにするわけですが、指定した文字数毎に改行や空白を入れられます。ソース(C言語)プログラムのある部分を書き換えれば、改行や空白の代わりに別な文字を挿入できたりします。
Undump機能は、dump機能の逆操作ですが、入力ファイルは特定のフォーマットではなく、ただ文字コードが並んでいればOKです。
実行の仕方は、MS-DOS なり Windows のコマンドプロンプトなり UNIX なり、コマンドラインから引数を与えて実行します。
おまけとして、引数無しで実行すると対話型実行になります。
主な用途は、バイナリファイルの編集、バイナリファイルの電子メールへの添付等です。発想次第で色々使えるでしょう。
コマンドラインからしか使えませんのでご注意下さい。今の所、コマンドライン以外のユーザインタフェースを使用する予定はありません。
MS-DOS, Windows3.1, 95, 98, Meの場合、MS-DOS上で動いている為、ファイル名はlong filenamesが使えません。long filenameを持つファイルを扱いたい場合には、入力ファイル名は8.3ファイル名を調べて入力して下さい。出力ファイルは8.3ファイル名で出力してからrenameして下さい。
ungetc(tmpc, fpr);” → “ungetc(tmpc, fpr); (*fpr0)--;”
PC-9800, DOS/V については、ダウンロードしたアーカイブ中の“exe/dos/binedit.exe”をご利用になれます。UNIXについてはソースをコンパイルして下さい。
私の2000-07-19現在の環境(Pentium III 600BE[MHz])では、状況により多少変わるかも知れませんが、実行速度は毎秒約1.4[MB]です。実行速度を考えればファイルサイズは5[MB](bin 5[MB], txt 10[MB])程度迄が適当でしょう。そもそもあまり大きいと、テキストエディタが対応できないでしょう。
大きいファイルについては、分割·統合ソフト(私は自作のを使用しているが非公開)で必要な箇所を切り出すのが妥当でしょう。なお、ver.0.0604から、“入力ファイルの__バイト目から__バイト目までをdumpする”という指定ができるようになりました。
電子メールにファイルを添付する (差出人は“binedit.exe r”, 受取人は“binedit.exe w”) … 私が binedit をフリーで公開しているのは、ファイル添付に使って欲しいからでした。でも、もうMIME Base64のencoder/decoderを自作した(但し非公開)ので、事情は変わりました。
メールのヘッダ等のアスキーテキストに非アスキー文字を入れる … base64では、
=?ISO-2022-JP?B?ここから … ここまで?=
ex. =?ISO-2022-JP?B?GyRCSjg7ek5zGyhC?=
と書きます。これを真似して、
=?Shift_JIS?binedit?ここから … ここまで?=
ex. =?Shift_JIS?binedit?95B68E9A97F1?=
と書くのが好きでした。ここで、“ここから … ここまで”は、非アスキー文字をbase64やbineditによってアスキー文字に直したものです。でも、私はもうMIME Base64のencoder/decoderを自作した(但し非公開)ので、メールに関しては素直にBase64を使います。
円周率や自然対数の底の値が保存されたテキストファイルを“binedit.exe w”によりファイルサイズ半分にする。これは、バイナリエディタで読み込めば値が読めるし、“binedit.exe r infile outfile 100 8”等とすれば適当に改行や空白を挿入できる。
TCC.EXE -DDOS binedit.c stdio.c consts.c string.c file.c codec.c
gcc.exe -DUNIX -o binedit.exe binedit.c stdio.c consts.c string.c file.c codec.c
gcc -DUNIX -DUNIXSYS -o binedit.exe binedit.c stdio.c consts.c string.c file.c codec.c
D:\>DIR /W
ディレクトリは D:\
BINEDIT.LZH
1 個 19283 バイトのファイルがあります.
D:\>MKDIR BINEDIT
D:\>CD BINEDIT
D:\BINEDIT>LHA e -xm ..\BINEDIT.LZH
Extracting from archive : ../BINEDIT.LZH
Melted binedit.exe
Melted binedit.c
Melted stdio.c
Melted unix.c
Melted file.c
Melted consts.h
Melted file.h
Melted stdio.h
Melted types.h
Melted unix.h
Melted binedit.doc
Melted binedit.htm
D:\BINEDIT>DIR /W
ディレクトリは D:\BINEDIT
[.] [..] [EXE] [SRC] [DOC]
5 個 0 バイトのファイルがあります.
D:\BINEDIT>CD SRC
D:\BINEDIT\SRC>DIR /W
ディレクトリは D:\BINEDIT\SRC
[.] [..] BINEDIT.C STDIO.C UNIX.C
FILE.C [8888]
7 個 10797 バイトのファイルがあります.
D:\BINEDIT\SRC>A:\B\TC\BIN\TCC.EXE -DDOS BINEDIT.C STDIO.C FILE.C (注意: これはver.0.0500の場合です。)
Turbo C++ Version 1.01 Copyright (c) 1990 Borland International
binedit.c:
Warning binedit.c 133: Unreachable code in function main
stdio.c:
file.c:
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Available memory 181440
D:\BINEDIT\SRC>DIR /W
ディレクトリは D:\BINEDIT\SRC
[.] [..] BINEDIT.C STDIO.C UNIX.C
FILE.C [8888] BINEDIT.OBJ STDIO.OBJ FILE.OBJ
BINEDIT.EXE
11 個 35152 バイトのファイルがあります.
D:\BINEDIT\SRC>BINEDIT.EXE -h
Binary file reader/writer for editing "binedit" by 8888 ver.0.0500
Usage :
binedit.exe [r|w [infile [outfile [width1 [width2]]]]]
<<commands>> r : Read binary file w : Write binary file
binedit.exe -h
Widths can be 0, 2, 3, 4, ... . width1 defaults to 64 and width2 to 0.
Please report bugs, requirements, etc. to "yh8888@geocities.co.jp".
D:\BINEDIT\SRC>
command-line> ls BINEDIT.LZH command-line> mkdir binedit command-line> cd binedit command-line> lha e ../BINEDIT.LZH exe/dos/binedit.exe - Melted src/binedit.c - Melted src/stdio.c - Melted src/unix.c - Melted src/file.c - Melted src/8888/consts.h - Melted src/8888/file.h - Melted src/8888/stdio.h - Melted src/8888/types.h - Melted src/8888/unix.h - Melted doc/binedit.doc - Melted doc/binedit.html - Melted command-line> ls doc/ exe/ src/ command-line> cd src command-line> ls 8888/ binedit.c file.c stdio.c unix.c command-line> gcc -o binedit.exe -DUNIX binedit.c stdio.c file.c unix.c (注意: これはver.0.0500の場合です。) command-line> ls 8888/ binedit.exe* stdio.c binedit.c file.c unix.c command-line> ./binedit.exe -h Binary file reader/writer for editing "binedit" by 8888 ver.0.0500 Usage : binedit.exe [r|w [infile [outfile [width1 [width2]]]]] <<commands>> r : Read binary file w : Write binary file binedit.exe -h Widths can be 0, 2, 3, 4, ... . width1 defaults to 64 and width2 to 0. Please report bugs, requirements, etc. to "yh8888@geocities.co.jp". command-line>
&lqduo;binedit.exe -h”とすれば次のような説明が表示されます。
command-line> binedit.EXE -h Binary file reader/writer for editing "binedit" by yh8888 ver.0.0612 Usage : binedit.exe [r [--from n] [--to n] [--size n] [infile [outfile [width1 [width2]]]]] binedit.exe [w [infile [outfile]]] <<commands>> r : Read binary file w : Write binary file binedit.exe -h Widths can be 0, 2, 3, 4, ... . width1 defaults to 64 and width2 to 0. Please report bugs, requirements, etc. to "yh8888@geocities.co.jp". command-line>
dump (i.e. バイナリ → 文字コード)
- width1
- width1文字毎及びファイル末に改行を挿入
- width2
- width2文字毎に空白を挿入
入力ファイルのどこからどこまでをdumpするかを指定する。開始点、終了点、(終了点-開始点) の3つのうち2つをバイト数で指定する。バイト数の数え方は、例えば8[Bytes]のファイルは0,…,7と数えて、全体をdumpするなら0以上8未満の8[Bytes]ということで“--from 0 --to 8”あるいは“--from 0 --size 8”とする。
例をご覧下さい。
Program debuggin 50726F6772616D20646562756767696E
of many was to d 0A6F66206D616E792077617320746F20
the need to face 640A746865206E65656420746F206661
thesis in showin 63650A74686573697320696E2073686F
treatment which 77696E0A74726561746D656E74207768
Because of the t 696368200A42656361757365206F6620
it evolved mostl 74686520740A69742065766F6C766564
206D6F73746C0A
TMP TMP.TXT
“binedit.exe r TMP TMP.TXT 32”とすれば左から右が得られ、binedit.exe w TMP.TXT TMP”とすれば右から左が得られます。
Program debuggin 50726F6772616D20646562756767696E0A6F66206D616E792077617320746F20640A746865206E65656420746F20666163650A74686573697320696E2073686F77696E0A74726561746D656E74207768696368200A42656361757365206F662074686520740A69742065766F6C766564206D6F73746C0A
of many was to d
the need to face
thesis in showin
treatment which
Because of the t
it evolved mostl
TMP TMP.TXT
“binedit.exe r TMP TMP.TXT 0”とすれば左から右が得られ、binedit.exe w TMP.TXT TMP”とすれば右から左が得られます。
Program debuggin 50 72 6F 67 72 61 6D 20 64 65 62 75 67 67 69 6E
of many was to d 0A 6F 66 20 6D 61 6E 79 20 77 61 73 20 74 6F 20
the need to face 64 0A 74 68 65 20 6E 65 65 64 20 74 6F 20 66 61
thesis in showin 63 65 0A 74 68 65 73 69 73 20 69 6E 20 73 68 6F
treatment which 77 69 6E 0A 74 72 65 61 74 6D 65 6E 74 20 77 68
Because of the t 69 63 68 20 0A 42 65 63 61 75 73 65 20 6F 66 20
it evolved mostl 74 68 65 20 74 0A 69 74 20 65 76 6F 6C 76 65 64
20 6D 6F 73 74 6C 0A
TMP TMP.TXT
“binedit.exe r TMP TMP.TXT 32 2”とすれば左から右が得られ、binedit.exe w TMP.TXT TMP”とすれば右から左が得られます。
#define DEFAULT_WIDTH1 32 #define DEFAULT_WIDTH2 16 SepaChar1 = '\x0A', SepaChar2 = '-', SepaChar3 = ' ';
Program debuggin 50 72 6F 67 72 61 6D 20-64 65 62 75 67 67 69 6E
of many was to d 0A 6F 66 20 6D 61 6E 79-20 77 61 73 20 74 6F 20
the need to face 64 0A 74 68 65 20 6E 65-65 64 20 74 6F 20 66 61
thesis in showin 63 65 0A 74 68 65 73 69-73 20 69 6E 20 73 68 6F
treatment which 77 69 6E 0A 74 72 65 61-74 6D 65 6E 74 20 77 68
Because of the t 69 63 68 20 0A 42 65 63-61 75 73 65 20 6F 66 20
it evolved mostl 74 68 65 20 74 0A 69 74-20 65 76 6F 6C 76 65 64
20 6D 6F 73 74 6C 0A
TMP TMP.TXT
“binedit.exe r TMP TMP.TXT”とすれば左から右が得られ、binedit.exe w TMP.TXT TMP”とすれば右から左が得られます。
'+'を追加、8個→9個に書き換えてコンパイルすれば、
#define MAX_SpaceChar 9
const char SpaceChar[] ={
' ', '\n', '\r', '\x0D', '\x0A', '\t', '-', '\x1A', '+'};
“binedit.exe w”の時に、+という文字が入力ファイルに入っていてもwarningが出なくなります。
yh8888のトップページへ