.\" Copyright (C) 2010 Romain Tartiere .\" .\" This program is free software: you can redistribute it and/or modify it .\" under the terms of the GNU Lesser General Public License as published by the .\" Free Software Foundation, either version 3 of the License, or (at your .\" option) any later version. .\" .\" This program is distributed in the hope that it will be useful, but WITHOUT .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for .\" more details. .\" .\" You should have received a copy of the GNU Lesser General Public License .\" along with this program. If not, see .\" .\" $Id$ .\" .Dd March 30, 2010 .Dt TLV 3 .Os .\" _ _ .\" | \ | | __ _ _ __ ___ ___ .\" | \| |/ _` | '_ ` _ \ / _ \ .\" | |\ | (_| | | | | | | __/ .\" |_| \_|\__,_|_| |_| |_|\___| .\" .Sh NAME .Nm tlv_encode , .Nm tlv_decode .Nd TLV Manipulation Functions .\" _ _ _ .\" | | (_) |__ _ __ __ _ _ __ _ _ .\" | | | | '_ \| '__/ _` | '__| | | | .\" | |___| | |_) | | | (_| | | | |_| | .\" |_____|_|_.__/|_| \__,_|_| \__, | .\" |___/ .Sh LIBRARY Mifare card manipulation library (libfreefare, \-lfreefare) .\" ____ _ .\" / ___| _ _ _ __ ___ _ __ ___(_)___ .\" \___ \| | | | '_ \ / _ \| '_ \/ __| / __| .\" ___) | |_| | | | | (_) | |_) \__ \ \__ \ .\" |____/ \__, |_| |_|\___/| .__/|___/_|___/ .\" |___/ |_| .Sh SYNOPSIS .In freefare.h .Ft "uint8_t *" .Fn tlv_encode "const uint8_t type" "const uint8_t *istream" "uint16_t isize" "size_t *osize" .Ft "uint8_t *" .Fn tlv_decode "const uint8_t *istream" "uint8_t *type" "uint16_t *size" .\" ____ _ _ _ .\" | _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __ .\" | | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \ .\" | |_| | __/\__ \ (__| | | | |_) | |_| | (_) | | | | .\" |____/ \___||___/\___|_| |_| .__/ \__|_|\___/|_| |_| .\" |_| .Sh DESCRIPTION The .Fn tlv_encode and .Fn tlv_decode functions are helpers to manipulate TLV (Text-Length-Value) data. .Pp The .Fn tlv_encode function converts the .Ar isize bytes long .Ar istream message into a TLV stream of type .Ar type and set the value of .Ar osize to the length of the returned stream. .Pp The .Fn tlv_decode function converts the .Ar istream TLV stream and set the .Ar type argument according to the type of the stream, and set the .Ar size argument to the length of the returned stream. .\" ____ _ _ .\" | _ \ ___| |_ _ _ _ __ _ __ __ ____ _| |_ _ ___ ___ .\" | |_) / _ \ __| | | | '__| '_ \ \ \ / / _` | | | | |/ _ \/ __| .\" | _ < __/ |_| |_| | | | | | | \ V / (_| | | |_| | __/\__ \ .\" |_| \_\___|\__|\__,_|_| |_| |_| \_/ \__,_|_|\__,_|\___||___/ .\" .Sh RETURN VALUES Both functions return memory allocated using .Xr malloc 3 which should be reclaimed using .Xr free 3 after usage. .\" ____ _ .\" / ___| ___ ___ __ _| |___ ___ .\" \___ \ / _ \/ _ \ / _` | / __|/ _ \ .\" ___) | __/ __/ | (_| | \__ \ (_) | .\" |____/ \___|\___| \__,_|_|___/\___/ .\" .Sh SEE ALSO .Xr freefare 3 , .Xr malloc 3 , .Xr free 3 .\" _ _ _ .\" / \ _ _| |_| |__ ___ _ __ ___ .\" / _ \| | | | __| '_ \ / _ \| '__/ __| .\" / ___ \ |_| | |_| | | | (_) | | \__ \ .\" /_/ \_\__,_|\__|_| |_|\___/|_| |___/ .\" .Sh AUTHORS .An Romain Tartiere Aq romain@blogreen.org .An Romuald Conty Aq romuald@libnfc.org