yenc

package module
v0.0.0-...-c9630e5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-yenc

GoDoc License Go version

go-yenc is a yenc encoder and decoder library for Go.

Usage

Encoding

yenc.Encode(out io.Writer, in io.Reader, lineLength int, filename string) error

Encode uses a basic io.Reader to access the binary data to be encoded and an io.Writer that receives the encoded inforation.

The lineLength parameter determines the length of each encoded line. Per version 1.3 of the specification, the line length may be one character longer than this as an escape code cannot appear in isolation.

fileName contains the name of the original file being encoded. As the function utilizes low-level readers and writers, the name must be provided separately. The file name is encoded into the =ybegin header and is emitted by the Decode function

Decoding

yenc.Decode(out io.Writer, in io.Reader) error

The current implementation of Decode currently handles only single-part files. There are several improvements to the code underway.

Similar to Encode, Decode accepts a basic io.Reader which supplies the encoded data and a basic io.Writer which receives the decoded infomration.

Contributing

  1. Fork it
  2. Create a feature branch (git checkout -b new-feature)
  3. Commit changes (git commit -am "Added new feature xyz")
  4. Push the branch (git push origin new-feature)
  5. Create a new pull request.

Maintainers

License

Copyright 2020 MediaExchange.io
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

View Source
const (
	Answer byte = 0x2A // 42
	Escape byte = 0x3D // 61
	Crit   byte = 0x40 // 64

	Ybegin string = "=ybegin"
	Yend   string = "=yend"
	Ypart  string = "=ypart"
)

Variables

This section is empty.

Functions

func Decode

func Decode(out io.Writer, in io.Reader) (err error)

Decode converts ASCII text to binary data using the yEnd algorithm.

func Encode

func Encode(out io.Writer, in io.Reader, lineLength int, filename string) error

Encode writes ASCII characters that were encoded from binary input using the yEnc algorithm, made popular by binary Usenet groups. Any line length may be used, but the most commonly used value is 128 characters.

func IsCritical

func IsCritical(b byte) bool

IsCritical returns `true` if the byte is one of the "critical" values.

func ParseMarkerLine

func ParseMarkerLine(line string, prefix string) map[string]string

ParseMarkerLine parses a line that uses the format, `prefix key=value key=value...`

func ReadLine

func ReadLine(in *bufio.Reader) (buf bytes.Buffer, err error)

ReadLine reads a line delimited with either "\n" or "\r\n"

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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