FREEFARE(3)

πŸ’– FREEFARE πŸ’– β€” like, the generic target manipulation girlies (section 3 of the manual, library functions manual, iykyk)

okay so bestie, welcome to the Mifare card manipulation library, aka libfreefare, and you link against it with -lfreefare. this page is all about the generic target manipulation functions and honestly? they ate. πŸŽ€


✨ SYNOPSIS ✨

#include <freefare.h>

MifareTag *
freefare_get_tags(nfc_device_t *device);

enum mifare_tag_type {
    ULTRALIGHT,
    CLASSIC_1K,
    CLASSIC_4K
};

enum mifare_tag_type
freefare_get_tag_type(MifareTag tag);

const char *
freefare_get_tag_friendly_name(MifareTag tag);

char *
freefare_get_tag_uid(MifareTag tag);

void
freefare_free_tag(MifareTag tags);

void
freefare_free_tags(MifareTag *tags);

🌸 DESCRIPTION 🌸

the freefare_*() family of functions is giving agnostic access to the MifareTag that's vibing on a given NFC device. no cap, it doesn't care what kind of tag it is, it just handles it. πŸ’…

freefare_get_tags() returns a NULL-terminated list of MifareTag present on device. this list has to be freed after usage, and you've got exactly two ways to do that bestie, pick your fighter:

  • calling the freefare_free_tags() function. literally every tag in the list gets automatically freed for you. so convenient. 🫢
  • calling the freefare_free_tag() function to free each tag in the list individually, and then freeing the list itself using the free() function.
⚠️ okay so listen, this part matters. because of the nature of the target detection process, any previously detected target will be in an inconsistent state after a call to freefare_get_tags(). it's the programmer's responsibility to free these targets before calling the freefare_get_tags() function. do not skip this. this is the vibe check. πŸ’€

information about a given MifareTag can be gathered using the freefare_get_tag_type(), freefare_get_tag_uid() and freefare_get_tag_friendly_name() functions. they're the little info-gathering trio and they're iconic. πŸ‘‘


⭐ RETURN VALUES ⭐

unless stated otherwise, all functions return a value greater than or equal to 0 on success or -1 on failure. that's it, that's the whole mood. πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹


πŸ‘‘ AUTHORS πŸ‘‘

these two literally built it, show some respect:

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

and that's the whole page bestie!! this came from the Debian crew, dated March 30, 2010 β€” yeah she's an older queen but she still slays πŸ’–βœ¨ go free your tags, stay consistent, and don't forget the NULL terminator. mwah πŸŽ€πŸ¦‹πŸ’