TLV(3)

πŸ’– TLV(3) β€” Library Functions Manual πŸ’–

okay bestie, sit down, we're learning about TLV manipulation and it's genuinely not that deep, i promise 🫢


✨ NAME ✨

tlv_encode, tlv_decode β€” TLV Manipulation Functions


πŸ“š LIBRARY πŸ“š

Mifare card manipulation library (libfreefare, -lfreefare)


🌸 SYNOPSIS 🌸

#include <freefare.h>

uint8_t *
tlv_encode(const uint8_t type, const uint8_t *istream, uint16_t isize,
    size_t *osize);

uint8_t *
tlv_decode(const uint8_t *istream, uint8_t *type, uint16_t *size);

πŸ’… DESCRIPTION πŸ’…

so tlv_encode() and tlv_decode() are your little helper besties for messing with TLV (Text-Length-Value) data. no cap, that's literally it. they're the duo. the dynamic duo. 🀝

The tlv_encode() function takes your istream message β€” which is isize bytes long, okay, remember that β€” and converts it into a TLV stream of type type, and then sets the value of osize to the length of the returned stream. she's giving glow-up transformation ✨

The tlv_decode() function does the opposite vibe entirely: it takes the istream TLV stream, sets the type argument according to the type of the stream, and sets the size argument to the length of the returned stream. reverse uno card, iconic behaviour, we love to see it πŸ”₯


πŸŽ€ RETURN VALUES πŸŽ€

both functions return memory allocated using malloc(3), and bestie, you GOTTA reclaim that memory with free(3) after usage. this is not optional, this is not a suggestion, this is the law πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

freefare(3), malloc(3), free(3)


πŸ¦‹ AUTHORS πŸ¦‹

  • Romain Tartiere <romain@blogreen.org>
  • Romuald Conty <romuald@libnfc.org>

🌈 SIGN-OFF 🌈

that's the whole page, babes! this one's from Debian, dated March 30, 2010 β€” yes she's an elder but she still ate πŸ’… go free your malloc'd memory and hydrate, mwah πŸ’–πŸ§š