MIFARE_APPLICATION(3)
β¨ MIFARE_APPLICATION β the mifare application manipulation functions β¨
okay bestie so this is MIFARE_APPLICATION(3), from the Library Functions Manual, and it's literally the whole girlboss toolkit for managing applications inside a Mifare Application Directory. five functions, one directory, zero drama. let's go π
π LIBRARY
Mifare card manipulation library β that's libfreefare, and you link it with -lfreefare. slay. π
π¦ SYNOPSIS
#include <freefare.h>
MifareClassicSectorNumber *
mifare_application_alloc(Mad mad, MadAid aid, size_t size);
void
mifare_application_free(Mad mad, MadAid aid);
MifareClassicSectorNumber *
mifare_application_find(Mad mad, MadAid aid);
ssize_t
mifare_application_read(MifareTag tag, Mad mad, MadAid aid, void *buf,
size_t nbytes, MifareClassicKey key, MifareClassicKeyType key_type);
ssize_t
mifare_application_write(MifareTag tag, Mad mad, MadAid aid,
const void *buf, size_t nbytes, MifareClassicKey key,
MifareClassicKeyType key_type);
πΈ DESCRIPTION
the whole mifare_application_*() family is here to facilitate management of applications in a Mifare Application Directory. think of it as your little friend group of functions who all handle the same directory, but each one has her own job π
mifare_application_alloc()β she allocates enough sectors to storesizebytes for the Application Identifieraid, and hands you back the list of allocated sectors. not me making space for you bestie π₯Ίmifare_application_find()β the list of the sectors previously allocated foraidin amadcan be requested using her. she's giving "where did i put that" energy πmifare_application_free()β an application can be removed from amadusing her. she's the friend who helps you clean out your closet, iconic πmifare_application_read()β reads at mostnbytesof the application identified byaidin themadon thetag, and copies them intobuf. the function returns the amount of data it copied, or-1on error. she ate and left no crumbs πmifare_application_write()β writes at mostnbytesofbufin the application identified byaidon themadof thetag, and returns the quantity of data written, or-1on error. periodt π
π§ IMPLEMENTATION NOTES
lowkey important stuff, don't skip this part bestie:
- The
mifare_application_alloc()function will try to avoid wasting space and might not allocate sectors sequentially if a large amount of space is requested and the target has sectors of different size. she's doing her best with what she's got β¨ - The
nbytesargument ofmifare_application_read()andmifare_application_write()does not need to be aligned on blocks not sectors. yes, that's exactly what it says. no, don't overthink it π
π 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 vibe check β
π SEE ALSO
go read those too, iykyk π«Ά
β AUTHORS
- Romain Tartiere
<romain@blogreen.org> - Romuald Conty
<romuald@libnfc.org>
two legends, no cap π₯
okay so that's the whole page bestie!! it came from Debian, dated March 30, 2010 β yes she's an elder but she still serves π mwah, go allocate some sectors, you've got this πβ¨π¦
π¦ where this page comes from
- debian bookworm: libfreefare-doc 0.4.0-2.1 Β· LGPL-3.0-or-later
- debian trixie: libfreefare-doc 0.4.0-2.3 Β· LGPL-3.0-or-later
- nixos 26.05: libfreefare 0.4.0
- nixpkgs unstable: libfreefare 0.4.0
- ubuntu jammy: libfreefare-doc 0.4.0-2.1build1 Β· LGPL-3.0-or-later
- ubuntu noble: libfreefare-doc 0.4.0-2.3build2 Β· LGPL-3.0-or-later
- ubuntu questing: libfreefare-doc 0.4.0-2.3build2
- ubuntu resolute: libfreefare-doc 0.4.0-2.3build3 Β· LGPL-3.0-or-later
- ubuntu stonking: libfreefare-doc 0.4.0-2.4build1 Β· LGPL-3.0-or-later
- Copyright (C) 2010 Romain Tartiere
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms