---
name: "freefare"
section: "3"
platform: "linux"
package: "libfreefare-doc"
version: "0.4.0-2.3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/freefare"
---

# freefare(3)

Generic target manipulation functions

## NAME

**freefare\_get\_tags**, **freefare\_get\_tag\_type**, **freefare\_get\_tag\_friendly\_name**, **freefare\_get\_tag\_uid**, **freefare\_free\_tag**, **freefare\_free\_tags** – Generic target manipulation functions

## LIBRARY

Mifare card manipulation library (libfreefare, -lfreefare)

## 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 allow agnostic access to the *MifareTag* present on a given NFC device.

**freefare\_get\_tags**() returns a NULL-terminated list of *MifareTag* present on *device*. This list has to be freed after usage by either:

- calling the **freefare\_free\_tags**() function.  All tags in the list are automatically freed;

- calling the **freefare\_free\_tag**() function to free each tag in the list individually, and freeing the list itself using the **free**() function.

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 is the programmer's responsibility to free these targets before calling the **freefare\_get\_tags**() function.

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.

## RETURN VALUES

Unless stated otherwise, all functions return a value greater than or equal to *0* on success or *-1* on failure.

## SEE ALSO

[free(3)](/free/3.md), [mifare\_classic(3)](/mifare_classic/3.md), [mifare\_ultralight(3)](/mifare_ultralight/3.md)

## AUTHORS

Romain Tartiere ⟨romain@blogreen.org⟩ Romuald Conty ⟨romuald@libnfc.org⟩
