Passa al contenuto principale

Appendice - BNF per il protocollo Gopher

Appendice​

NQBNF di Paul (Not Quite BNF) per il protocollo Gopher.

Nota: Si tratta di una BNF modificata (come usata dalla gente di Pascal) con alcuni modificatori inglesi. Il contenuto racchiuso tra '{}' può essere ripetuto zero o più volte. Il contenuto tra '[]' indica un insieme di elementi. L'operatore '-' indica la sottrazione di insiemi.

Entità Directory​

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 - ['.']}.

Nota: Questo è un nome di dominio completamente qualificato come definito nella RFC 1034 (ad es. gopher.micro.umn.edu). Gli host il cui nome contiene CR-LF, TAB o NUL si meritano quello che ottengono.

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

DigitSeq ::= digit {digit}.

Port ::= DigitSeq.

Nota: Port corrisponde al numero di porta TCP; il suo valore dovrebbe essere nell'intervallo [0..65535]; la porta 70 è ufficialmente assegnata a gopher.

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

Note:

È fortemente raccomandato che il campo User_Name contenga solo caratteri stampabili, poiché molti client diversi lo utilizzeranno. Tuttavia, se si usano caratteri a otto bit, questi dovrebbero essere conformi al set di caratteri ISO Latin1. La lunghezza della riga visualizzabile per l'utente dovrebbe essere inferiore a 70 caratteri; le righe più lunghe potrebbero non adattarsi ad alcuni schermi.

La stringa Selector non dovrebbe superare i 255 caratteri.

Entità Menu​

Menu      ::= {DirEntity} Lastline.

La connessione viene chiusa dal client o dal server (in genere dal server).

Transazione Menu (elemento di tipo 1)​

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

Entità Textfile​

TextFile  ::= {TextBlock} Lastline

Nota: Le righe che iniziano con un punto devono essere precedute da un punto aggiuntivo per garantire che la trasmissione non termini prematuramente. Il client dovrebbe rimuovere i punti aggiuntivi all'inizio della riga.

Transazione TextFile (elemento di tipo 0)​

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

La connessione viene chiusa dal client o dal server (in genere dal server).

Nota: Il client dovrebbe essere preparato al fatto che il server chiuda la connessione senza inviare il Lastline. Ciò consente al client di utilizzare i server fingerd.

Transazione di ricerca full-text (elemento di tipo 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.

Nota: In assenza degli operatori 'and', 'or' o 'not', uno SPACE è considerato un operatore 'and' implicito. L'espressione viene valutata da sinistra a destra. Inoltre, non tutti i motori di ricerca o gateway di ricerca attualmente implementati hanno implementato gli operatori booleani.

Transazione di file binario (elemento di tipo 9 o 5)​

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

Significato sintattico delle entità Directory​

Il client deve interpretare il campo type come segue:

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.