{"size": 2417, "ext": "scrbl", "max_stars_repo_path": "doc/utils/tlv.scrbl", "max_stars_repo_name": "david135/sagittarius-scheme", "max_stars_repo_stars_event_min_datetime": "2015-11-07T07:13:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T03:35:14.000Z", "max_issues_repo_path": "doc/utils/tlv.scrbl", "max_issues_repo_name": "david135/sagittarius-scheme", "max_issues_repo_issues_event_min_datetime": "2016-04-28T21:59:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T08:42:21.000Z", "max_forks_repo_path": "doc/utils/tlv.scrbl", "max_forks_repo_name": "david135/sagittarius-scheme", "max_forks_repo_forks_event_min_datetime": "2016-12-28T12:41:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-26T20:52:02.000Z"}
{"max_stars_count": 39, "max_issues_count": 3, "max_forks_count": 4, "avg_line_length": 35.0289855072, "max_line_length": 80, "alphanum_fraction": 0.7356226727}
@; -*- mode:scribble; coding: utf-8; -*-

@subsection[:tag "util.tlv"]{(tlv) - TLV library}

@define[Library]{@name{(tlv)}}
@desc{This library provides TLV (tag length value) data operation procedures.
}
@; not yet
@;@define[Function]{@name{make-tlv-parser} @args{format :rest options}}
@;@desc{Creates an TLV parser of given @args{format} type.}

@subsubsection{High level APIs}

@define[Function]{@name{make-emv-tlv-parser}
 @args{:key (object-builder tlv-builder)}}
@desc{Creates EMV type TLV parser.

This procedure returns a procedure which accepts a binary port as its argument.

The keyword argument @code{object-builder} specifies how to construct a TLV
object. The default value is @code{tlv-builder}.
}

@define[Function]{@name{tlv-object?} @args{o}}
@desc{Returns #t if the given object is TLV object otherwise #f.}

@define[Function]{@name{tlv-tag} @args{tlv}}
@desc{Returns TLV tag of given TLV object @var{tlv}.}

@define[Function]{@name{tlv-data} @args{tlv}}
@desc{Returns TLV binary data if the given TLV object @var{tlv} is not
constructed, otherwise #f.}

@define[Function]{@name{tlv-components} @args{tlv}}
@desc{Returns TLV components of given TLV object @var{tlv}. If the @var{tlv}
is not constructed, this returns @code{()}.}

@define[Function]{@name{tlv->bytevector} @agrs{tlv}}
@desc{Converts given TLV object @var{tlv} to bytevector.}

@define[Function]{@name{write-tlv}
 @agrs{tlv :optional (out (current-output-port))}}
@desc{@var{out} must be binary output port.

Writes given TLV object @var{tlv} to @var{out} as TLV data.
}

@define[Function]{@name{dump-tlv} @args{:optional (out (current-output-port))}}
@desc{Dump given TLV object @var{tlv} as human readable form.}

@subsubsection{Custom object builder}

Sometimes default TLV object is not convenient to use. Then users can create
own object from TLV data passing own object builder to the
@code{make-emv-tlv-parser} procedure.

@define[Function]{@name{tlv-builder} @args{first-byte tag data constructed?}}
@desc{Default TLV object builder. User should not use this procedure directly.

@var{first-byte} is the first byte of the leading TLV object.

@var{tag} is the read tag of the TLV object.

@var{data} is either a list of TLV object or bytevector. User can check it with
@var{constructed?} argument.

@var{constructed?} indicates if the TLV object is constructed or not. If this is
#t then @var{data} is a list of TLV objects.
}