libgopher

package
v0.0.0-...-3f53507 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILE        = ItemType('0') // Item is a file
	DIRECTORY   = ItemType('1') // Item is a directory
	PHONEBOOK   = ItemType('2') // Item is a CSO phone-book server
	ERROR       = ItemType('3') // Error
	BINHEX      = ItemType('4') // Item is a BinHexed Macintosh file.
	DOSARCHIVE  = ItemType('5') // Item is DOS binary archive of some sort. (*)
	UUENCODED   = ItemType('6') // Item is a UNIX uuencoded file.
	INDEXSEARCH = ItemType('7') // Item is an Index-Search server.
	TELNET      = ItemType('8') // Item points to a text-based telnet session.
	BINARY      = ItemType('9') // Item is a binary file! (*)

	REDUNDANT = ItemType('+') // Item is a redundant server
	TN3270    = ItemType('T') // Item points to a text-based tn3270 session.
	GIF       = ItemType('g') // Item is a GIF format graphics file.
	IMAGE     = ItemType('I') // Item is some kind of image file.

	// non-standard
	INFO  = ItemType('i') // Item is an informational message
	HTML  = ItemType('h') // Item is a HTML document
	AUDIO = ItemType('s') // Item is an Audio file
	PNG   = ItemType('p') // Item is a PNG Image
	DOC   = ItemType('d') // Item is a Document
)

Item Types

View Source
const (
	// END represents the terminator used in directory responses
	END = byte('.')

	// TAB is the delimiter used to separate item response parts
	TAB = byte('\t')

	// CRLF is the delimiter used per line of response item
	CRLF = "\r\n"

	// DEFAULT is the default item type
	DEFAULT = BINARY
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

type Directory struct {
	Items []*Item `json:"items"`
}

Directory representes a Gopher Menu of Items

type Item

type Item struct {
	Type        ItemType `json:"type"`
	Description string   `json:"description"`
	Selector    string   `json:"selector"`
	Host        string   `json:"host"`
	Port        string   `json:"port"`

	// non-standard extensions (ignored by standard clients)
	Extras []string `json:"extras"`
}

Item describes an entry in a directory listing.

func ParseItem

func ParseItem(line string) (item *Item, err error)

ParseItem parses a line of text into an item

func (*Item) FetchDirectory

func (i *Item) FetchDirectory() (Directory, error)

FetchDirectory fetches directory information, not data. Calling this on an Item whose type is not DIRECTORY will return an error.

func (*Item) FetchFile

func (i *Item) FetchFile() (io.Reader, error)

FetchFile fetches data, not directory information. Calling this on a DIRECTORY Item type or unsupported type will return an error.

type ItemType

type ItemType byte

ItemType represents the type of an item

func (ItemType) String

func (it ItemType) String() string

Return a human friendly represation of an ItemType

type Response

type Response struct {
	Type ItemType
	Dir  Directory
	Body io.Reader
}

Response represents a Gopher resource that Items contains a non-empty array of Item(s) for directory types, otherwise the Body contains the fetched resource (file, image, etc).

func Get

func Get(uri string) (*Response, error)

Get fetches a Gopher resource by URI

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL