From 2c40326fff69f7c8cf89cde14b3a98bcaf55774b Mon Sep 17 00:00:00 2001 From: Ravi kumar Veeramally Date: Wed, 25 Jan 2012 15:41:49 +0200 Subject: [PATCH] target: Provide method to get tag from target structure --- include/target.h | 2 ++ src/target.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/target.h b/include/target.h index f42fe14..2228119 100644 --- a/include/target.h +++ b/include/target.h @@ -32,6 +32,8 @@ struct near_tag *near_target_add_tag(uint32_t adapter_idx, uint32_t target_idx, size_t data_length); +struct near_tag *near_target_get_tag(uint32_t adapter_idx, uint32_t target_idx); + enum near_target_sub_type near_target_get_subtype(uint32_t adapter_idx, uint32_t target_idx); uint8_t *near_target_get_nfcid(uint32_t adapter_idx, uint32_t target_idx, diff --git a/src/target.c b/src/target.c index 0c8e602..aeeed92 100644 --- a/src/target.c +++ b/src/target.c @@ -477,6 +477,24 @@ fail: return NULL; } +struct near_tag *near_target_get_tag(uint32_t adapter_idx, uint32_t target_idx) +{ + struct near_target *target; + char *path; + + path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH, + adapter_idx, target_idx); + if (path == NULL) + return NULL; + + target = g_hash_table_lookup(target_hash, path); + g_free(path); + if (target == NULL) + return NULL; + + return target->tag; +} + struct near_tag *near_target_add_tag(uint32_t adapter_idx, uint32_t target_idx, size_t data_length) { -- 2.7.4