メインコンテンツまでスキップ

付録 - Gopher プロトコルの BNF

付録​

Paul による Gopher プロトコルの NQBNF (Not Quite BNF).

注: これは Pascal 関係者が使用する修正版 BNF に若干の英語修飾語を加えたものである. '{}' で囲まれた内容はゼロ回以上繰り返すことができる. '[]' 内の内容は項目の集合を示す. '-' 演算子は集合の減法を示す.

ディレクトリエンティティ​

CR-LF     ::= ASCII Carriage Return Character followed by Line Feed
character.

Tab ::= ASCII Tab character.

NUL ::= ASCII NUL character.

UNASCII ::= ASCII - [Tab CR-LF NUL].

Lastline ::= '.'CR-LF.

TextBlock ::= Block of ASCII text not containing Lastline pattern.

Type ::= UNASCII.

RedType ::= '+'.

User_Name ::= {UNASCII}.

Selector ::= {UNASCII}.

Host ::= {{UNASCII - ['.']} '.'} {UNASCII - ['.']}.

注: これは RFC 1034 で定義された完全修飾ドメイン名である (例: gopher.micro.umn.edu). 名前に CR-LF, TAB, NUL を含むホストは自業自得である.

Digit     ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' .

DigitSeq ::= digit {digit}.

Port ::= DigitSeq.

注: Port は TCP ポート番号に対応し, その値は [0..65535] の範囲内であるべきである. ポート 70 は gopher に正式に割り当てられている.

DirEntity ::= Type User_Name Tab Selector Tab Host Tab Port CR-LF
{RedType User_Name Tab Selector Tab Host Tab Port CR-LF}

注:

多くの異なるクライアントが User_Name 字段を使用するため, この字段には印刷可能な文字のみを含めることが強く推奨される. ただし, 8 ビット文字を使用する場合は ISO Latin1 文字セットに準拠すべきである. ユーザー表示行の長さは 70 文字未満であるべきであり, 長すぎる行は一部の画面に収まらない可能性がある.

Selector 文字列は 255 文字を超えてはならない.

メニューエンティティ​

Menu      ::= {DirEntity} Lastline.

接続はクライアントまたはサーバのいずれかによって閉じられる (通常はサーバ).

メニュー取引 (型 1 の項目)​

C: Opens Connection
S: Accepts Connection
C: Sends Selector String
S: Sends Menu Entity

テキストファイルエンティティ​

TextFile  ::= {TextBlock} Lastline

注: 句点で始まる行には余分な句点を前置し, 伝送が早期に終了しないようにしなければならない. クライアントは行頭の余分な句点を除去すべきである.

TextFile 取引 (型 0 の項目)​

C: Opens Connection.
S: Accepts connection
C: Sends Selector String.
S: Sends TextFile Entity.

接続はクライアントまたはサーバのいずれかによって閉じられる (通常はサーバ).

注: クライアントは, サーバが Lastline を送信せずに接続を閉じる可能性に備えるべきである. これによりクライアントは fingerd サーバを使用できる.

全文検索取引 (型 7 の項目)​

Word      ::= {UNASCII - ' '}
BoolOp ::= 'and' | 'or' | 'not' | SPACE
SearchStr ::= Word {{SPACE BoolOp} SPACE Word}

C: Opens Connection.
C: Sends Selector String, Tab, Search String.
S: Sends Menu Entity.

注: 'and', 'or', 'not' 演算子がない場合, SPACE は暗黙の 'and' 演算子とみなされる. 式は左から右へ評価される. さらに, 現在実装されている検索エンジンや検索ゲートウェイのすべてが布尔演算子を実装しているわけではない.

バイナリファイル取引 (型 9 または 5 の項目)​

C: Opens Connection.
S: Accepts connection
C: Sends Selector String.
S: Sends a binary file and closes connection when done.

ディレクトリエンティティの構文意味​

クライアントは type 字段を次のように解釈すべきである:

0 The item is a TextFile Entity.​

1 The item is a Menu Entity.​

2 The information applies to a CSO phone book entity.​

3 Signals an error condition.​

4 Item is a Macintosh file encoded in BINHEX format​

5 Item is PC-DOS binary file of some sort. Client gets to decide.​

6 Item is a uuencoded file.​

7 The information applies to a Index Server.​

8 The information applies to a Telnet session.​

9 Item is a binary file. Client must decide what to do with it.​

+   The information applies to a duplicated server.  The information
contained within is a duplicate of the primary server. The primary
server is defined as the last DirEntity that is has a non-plus
"Type" field. The client should use the transaction as defined by
the primary server Type field.

g Item is a GIF graphic file.

I Item is some kind of image file. Client gets to decide.

T The information applies to a tn3270 based telnet session.
Connect to given host at given port. The name to login as at this
host is in the selector string.