LoginSignup
0
0

More than 5 years have passed since last update.

BinHex符号化コマンドとしての StreamRelay.NET.exe

Last updated at Posted at 2017-06-05

BinHEX は、簡易的な圧縮と、Base64 のような符号化、簡単なヘッダ/フッタの挿入の3段階で処理されるので、

それぞれ

簡易的な圧縮/伸張
- BinHexdecompress
- BinHexcompress

Base64のような符号化処理
- BinHexdecode
- BinHexencode

データに対しての装飾処理
- BinHexdecorate
- BinHexencorate

のオプションで個別に実装した。

それぞれを netstream スキームの Proxy オブジェクトとして、指定すればよい

BinHex エンコード

binhexsource.txt を BinHEX 符号化し、binhexsource.binhexが結果ファイル
BinHexCUI.exe En binhexsource.txt | StreamRelay.NET.exe -LocalPort 0 -RemotePort 0 -RemoteProxy netstream:///?BinHexEnCorate -RemoteProxy netstream:///?BinHexEnCode -RemoteProxy netstream:///?BinHexCompress -RemoteOutputFile binhexsource.binhex

つまり、

  1. BinHexCUI.exe からbinhexsource.txtを読みつつBinHEXフォーマット(ファイル名とかファイルサイズとかをデータに埋め込む)へ変換して、「ローカル」と呼称されるストリームへ渡す
  2. 「ローカル」と呼称されるストリームから読み込まれる
  3. 「リモート」と呼称されるストリームへ書き込まれる前に、
  4. まずは、BinHEX圧縮を実施する
  5. 次は、base64のような BinHEX符号化を実施する
  6. 最後に BinHEX用のヘッダ/フッタ(「(This file must be converted with BinHex 4.0)」という文字列を先頭に付与して ":(コロン)" でデータを囲む)を挿入して・・・
  7. 「リモート」と呼称されるストリームへ書き込まれる

BinHex デコード

BinHex符号化されたbinhexsource.binhexをBinHexデコードを実施して、binhexsource.txt.outを作成する
StreamRelay.NET.exe -LocalinputFile binhexsource.binhex -LocalPort 0 -RemotePort 0 -LocalProxy netstream:///?BinHexDeCorate -LocalProxy netstream:///?BinHexDeCode -LocalProxy netstream:///?BinHexDeCompress | BinHexCUI.exe De binhexsource.txt.out

  1. BinHexCUI.exe からbinhexsource.txtを読みつつBinHEXフォーマットへ変換して、「ローカル」と呼称されるストリームへ渡す
  2. 「ローカル」と呼称されるストリームからBinHEX符号化されたbinhexsource.binhexを読み込む
  3. 「ローカル」と呼称されるストリーム上で、BinHEX用のヘッダ/フッタを排除する
  4. 「ローカル」と呼称されるストリーム上で、BinHEXデコードを実施する
  5. 「ローカル」と呼称されるストリーム上で、BinHEX伸張を実施する
  6. 「リモート」と呼称されるストリームへ書き込まれる
  7. BinHexCUI.exeへ渡されて、BinHEXフォーマットから 普通のファイルbinhexsource.txt.outが作成される

binhexsource.txt = binhexsource.txt.out

BinHexCUI.exe

StreamRelay.NET.exe に実装できなかった部分を支援するサポートプログラム

BinHex エンコードの詳細

  1. BinHexCUI.exe en a.txt ファイル名とかサイズとかそういう前処理を実施する binhex001.png
  2. BinHexCUI.exe En a.txt | StreamRelay.NET.exe -LocalPort 0 -RemotePort 0 -RemoteProxy netstream:///?BinHexCompress 前処理後にBinHex圧縮を実施するとこんな感じ binhex002.png
  3. BinHexCUI.exe En a.txt | StreamRelay.NET.exe -LocalPort 0 -RemotePort 0 -RemoteProxy netstream:///?BinHexEnCode -RemoteProxy netstream:///?BinHexCompress 前処理からBinHex圧縮→BinHex符号化まで実施 binhex003.png
  4. BinHexCUI.exe En a.txt | StreamRelay.NET.exe -LocalPort 0 -RemotePort 0 -RemoteProxy netstream:///?BinHexEnCorate -RemoteProxy netstream:///?BinHexEnCode -RemoteProxy netstream:///?BinHexCompress 前処理からBinHex圧縮→BinHex符号化→BinHexデコレートまで実施して完成。という感じ binhex004.png

BinHexデコードは、この逆の処理を実施している。

ちなみに、エンコード処理は、書き込み側のストリームに割り当てるのだけど、引数の順番通りにストリームに割り当てていくので、引数の順番と処理の順番が逆転しているよ。


符号化コマンドとしての StreamRelay.NET.exe

符号化コマンドとしての StreamRelay.NET.exe


目次へ戻る

目次というか最初の一歩

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0