|
今日は、Iranoan です。
> 取り敢えずマクロでは、
> 256 文字で制限をつけるしかなさそうですね。
95 系は 128 文字のようなので、それを制限とすることにしました。公開に
必要なドキュメントを書く時間がちょっと取れないので、取り敢えずこちらに
投稿しておきますので、可笑しな部分をご指摘頂ければ幸いです。
//GPG/PGP で暗号化
//対象は、
// 鶴亀では、添付ファイル
// 秀丸では編集中のファイル (こちらは GPG だけ対応+暗号化後の
// ファイルは、既にあっても上書き+標準の秘密鍵使用)
openreg "CURRENTUSER","Software\\Hidemaruo\\TuruKame\\Config";
if(result){
loaddll getregstr("TuruKameDir") + "tkinfo.dll";
if( dllfunc( "IsTuruKame" ) )goto TuruKame;
else goto Hidemaru;
}
else goto Hidemaru;
TuruKame:
if( getregnum("PgpProg")&1 )$$pgp = "gpg";
else $$pgp = "pgp";
closereg;
call CheckType;
call GetAddress;
$$adr = $$return;
##xattach = dllfunc( "CountCurrentHeader", "X-Attach" ) - 1;
$$home = dllfuncstr( "HomeDir" );
$$folder = $$home + dllfuncstr( "CurrentAccount" ) + "\\";
##main = hidemaruhandle( 0 );
//PGP の error を書き出すためのウィンドウを用意
if( !dllfunc( "NewMail" ) )goto Error;
showwindow 0;
moveto 0, 0;
gofileend;
delete;
beginsel;
//ここの添付ファイルの暗号化
while( ##xattach >= 0 ){
$$attach = dllfuncstr( "ExecAt", ##main, "CurrentHeader2",
"X-Attach", ##xattach );
if( existfile( $$folder + $$attach ) ){
call Basename $$attach;
if( $$return != "pgp_signature" && $$return != "pgp_encrypted"){
//PGP 暗号、書名は除外、「そのまま転送」は暗号化してもよいのか?
if( !dllfunc( "Bypass_CopyFile", $$folder + $$attach, $$home +
$$return, false) )goto Error;
//コマンドラインを短くするために、一旦「ホームディレクトリ」にコピー
$$cmdline = $$pgp + ".exe -e --yes" + $$adr + " -o \"" +
$$return + "." + $$pgp + "\" \"" + $$return + "\"";
if( strlen( $$cmdline ) < 128 ){
setclipboard $$cmdline;
run $$cmdline + " > con";//PGP の error を書き出す
beginsel;
if( !dllfunc( "ExecAt", ##main, "AddAttach", $$home +
$$return + "." + $$pgp ) )goto Error;
if( !dllfunc( "ExecAt", ##main, "UndoAttach", $$attach ) )
goto Error;
//一時ファイルの削除
if( !dllfunc( "Bypass_DeleteFile", $$home + $$return + "." +
$$pgp ) )goto Error;
if( !dllfunc( "Bypass_DeleteFile", $$home + $$return ) )
goto Error;
}
else message "ファイル名が長すぎます";
}
}
##xattach = ##xattach - 1;
}
if( linecount2 == 1 ){
//PGP の error が無かったので結果ウィンドウは閉じる
##sub = hidemaruhandle( 0 );
setactivehidemaru ##main;
closehidemaruforced ##sub;
}
else{
endsel;
clearupdated;
showwindow 1;
}
End:
freedll;
endmacro;
Error:
message "DLL 関数失敗";
goto End;
CheckType://mail type 等の確認
if( dllfunc( "IsTuruKameMain" ) )goto End;
##type = dllfunc( "MailType" );
if( ##type == 3 || ##type == 4 )
goto End;//送信済みを終了して良いか微妙
if( dllfunc( "CountCurrentHeader", "Bcc" ) ){
message "Bcc ヘッダが存在します";
goto End;
}
return;
GetAddress://email address の取得
##i = dllfunc( "CountCurrentHeader", "From" ) - 1;
while( ##i >= 0 ){
$$header = $$header + ", " +
dllfuncstr( "CurrentHeader2", "From", ##i );
##i = ##i - 1;
}
##i = dllfunc( "CountCurrentHeader", "To" ) - 1;
while( ##i >= 0 ){
$$header = $$header + ", " +
dllfuncstr( "CurrentHeader2", "To", ##i );
##i = ##i - 1;
}
##i = dllfunc( "CountCurrentHeader", "Cc" ) - 1;
while( ##i >= 0 ){
$$header = $$header + ", " +
dllfuncstr( "CurrentHeader2", "Cc", ##i );
##i = ##i - 1;
}
$$header = rightstr( $$header, strlen( $$header ) - 1 );
##i = dllfunc( "CountEmailList", $$header ) - 1;
while( ##i >= 0 ){
$$adr = $$adr + " -r " + dllfuncstr( "SetEmailOnly",
dllfuncstr( "GetEmailList", $$header, ##i ));
##i = ##i - 1;
}
if( strlen( $$adr ) >= 128 ){
message "送信先が多すぎます";
goto End;
}
return $$adr;
Basename://ファイル名だけを取り出し
call strstr2 $$1, "\\";
return rightstr( $$1, strlen( $$1 ) - ##return - 1 );
strstr2:// 文字列の後方から文字列を検索するサブルーチン
##RC = -1;
##Size = strlen($$2);
while( 1 ){
##Pos = strstr( $$1, $$2 );
if( ##Pos == -1 )break;
##RC = ##RC + ##Pos + ##Size;
$$1 = rightstr( $$1, strlen( $$1 ) - ##Pos - ##Size );
}
return ##RC;
Hidemaru:
freedll;
if(updated || filename == ""){
save;
if(!result){
message "未保存ファイルの暗号化は出来ません";
endmacro;
}
}
openreg "CURRENTUSER", "Software\\GNU\\GnuPG";
if(result){
$$path = getregstr("HomeDir") + "\\";
closereg;
}
else $$path = "C:\\gnupg\\";
run $$path + "gpg.exe --yes -e --default-recipient-self -o " + "\""
+ basename +".gpg\" \"" + basename + "\"";
endmacro;
|
|