(PuTTYユーザマニュアル)D.1 OS間の移植性 - D.1 Cross-OS portability

http://the.earth.li/~sgtatham/putty/0.60/htmldoc/AppendixD.html#udp-portabilityの日本語訳。<< 付録D: PuTTYハッキングガイド - 目次に戻る - D.2 複数のバックエンドを同じように扱う >>

訳文

PuTTYWindowsにおいて有名ですが、もはやWindowsだけのアプリケーションスイートではありません。Unixへの移植は動作します。また、Macへの移植は進行中です。今後多くの移植が行われるかもしれません。

Despite Windows being its main area of fame, PuTTY is no longer a Windows-only application suite. It has a working Unix port; a Mac port is in progress; more ports may or may not happen at a later date.

したがって、ssh.cのような中心的なモジュールにWindows固有のコード埋め込むことは認められません。大変な労力をかけて中心的なモジュールからWindows固有の箇所を取り除き、それらの箇所をWindows固有のモジュールへ移動しました。Windows固有の要素を移植対象のコード中に大量に追加するような投稿はまず却下されます。

Therefore, embedding Windows-specific code in core modules such as ssh.c is not acceptable. We went to great lengths to remove all the Windows-specific stuff from our core modules, and to shift it out into Windows-specific modules. Adding large amounts of Windows-specific stuff in parts of the code that should be portable is almost guaranteed to make us reject a contribution.

PuTTYのソースの基盤はプラットフォーム固有のモジュールとプラットフォーム共通のモジュールに分かれています。Unix固有のモジュールはすべてunixサブディレクトリに含まれます。Mac固有のモジュールはmacサブディレクトリに含まれます。Windows固有のモジュールはwindowsサブディレクトリに含まれます。

The PuTTY source base is divided into platform-specific modules and platform-generic modules. The Unix-specific modules are all in the unix subdirectory; the Mac-specific modules are in the mac subdirectory; the Windows-specific modules are in the windows subdirectory.

メインのソースディレクトリ中のモジュールはすべて(特に各種バックエンドのコードはすべて)プラットフォーム共通です。我々はこれらをこの形で保ちたいと考えています。

All the modules in the main source directory - notably all of the code for the various back ends - are platform-generic. We want to keep them that way.

ANSI/ISO C(つまり、C99でなくオリジナルのC89/c90標準)に準拠することも必要になります。intやlong intなどの基本的な型のサイズを決めてかかってはいけません。ポインタのキャストによってエンディアンに依存する操作を行ってはいけません。その他にもいろいろあります。

This also means you should stick to what you are guaranteed by ANSI/ISO C (that is, the original C89/C90 standard, not C99). Try not to make assumptions about the precise size of basic types such as int and long int; don't use pointer casts to do endianness-dependent operations, and so on.

(ANCI Cの移植性について一つ二つ気にしてない点があります。具体的には、PuTTYコンパイルは32ビットかそれ以上のアーキテクチャで行うことが想定されています。したがって、intはANSI Cの保証する16バイト幅ではなく、少なくとも32ビット幅であることを想定しても問題ありません。また、実行する文字コードは表示可能なASCII文字の上位セットであることを想定しており、「\n」や「\r」のような制御文字の数値は想定していません。)

(There are one or two aspects of ANSI C portability which we don't care about. In particular, we expect PuTTY to be compiled on 32-bit architectures or bigger; so it's safe to assume that int is at least 32 bits wide, not just the 16 you are guaranteed by ANSI C. Similarly, we assume that the execution character encoding is a superset of the printable characters of ASCII, though we don't assume the numeric values of control characters, particularly '\n' and '\r'.)

<< 付録D: PuTTYハッキングガイド - 目次に戻る - D.2 複数のバックエンドを同じように扱う >>