f5bec105bc2139ad1e5ef8ff4905dca2e494a40c
[platform/core/connectivity/nfc-manager-neard.git] / src / clientlib / include / net_nfc_data.h
1 /*
2   * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7
8   *     http://floralicense.org/license/
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17
18 #include <net_nfc_typedef.h>
19
20
21 #ifndef __NET_NFC_DATA_H__
22 #define __NET_NFC_DATA_H__
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28
29 /**
30
31 @addtogroup NET_NFC_MANAGER_INFO
32 @{
33         This document is for the APIs reference document
34
35         NFC Manager defines are defined in <nfc-manager-def.h>
36
37         @li @c #net_nfc_initialize                  Initialize the nfc device.
38
39 */
40
41 /**
42         create data handler only.
43
44         @param[out]     data            data handler
45
46         @return         return the result of this operation
47
48         @exception NET_NFC_NULL_PARAMETER               parameter(s) has(have) illigal NULL pointer(s)
49         @exception NET_NFC_ALLOC_FAIL                   memory allocation is failed
50 */
51
52 net_nfc_error_e net_nfc_create_data_only (data_h* data);
53
54 /**
55         create data handler with initial values, bytes will be copied into the data handler.
56
57         @param[out]     data            data handler
58         @param[in]      bytes   binary data
59         @param[in]      length  size of binary data;
60
61         @return         return the result of this operation
62
63         @exception NET_NFC_NULL_PARAMETER               parameter(s) has(have) illigal NULL pointer(s)
64         @exception NET_NFC_ALLOC_FAIL                   memory allocation is failed
65 */
66 net_nfc_error_e net_nfc_create_data (data_h* data, const uint8_t* bytes, const uint32_t length);
67
68 /**
69         get the byes and length from data handler. data handler assume bytes may have '0x0' value.
70         that's why this function also provides the length.
71
72         @param[in]      data            data handler
73         @param[out]     bytes   binary pointer (it returns the direct pointer of handler's data) do not free this
74         @param[out]     length  length of the binary data;
75
76         @return         return the result of this operation
77
78         @exception NET_NFC_NULL_PARAMETER               parameter(s) has(have) illigal NULL pointer(s)
79 */
80 net_nfc_error_e net_nfc_get_data (const data_h data, uint8_t** bytes, uint32_t * length);
81
82 /**
83         replace the data handler with given bytes. binary data (bytes) will be copied to data hander.
84         application should free or use local variable for given byte pointer.
85
86         @param[in]      data            data handler
87         @param[in]      bytes   binary data
88         @param[in]      length  size of binary data
89
90         @return         return the result of this operation
91
92         @exception NET_NFC_NULL_PARAMETER               parameter(s) has(have) illigal NULL pointer(s)
93 */
94
95 net_nfc_error_e net_nfc_set_data (const data_h data, const uint8_t* bytes, const uint32_t length);
96
97 /**
98         get length of data handler's bytes.
99
100         @param[in]      data            data handler
101
102         @return         length of bytes length
103
104         @exception      0 is returned if data is NULL
105 */
106
107 uint32_t net_nfc_get_data_length (const data_h data);
108
109 /**
110         get pointer of the handler's bytes (do not free this. it wll be freed when the application call "net_nfc_free_data" function
111
112         @param[in]      data            data handler
113
114         @return         the pointer of bytes.
115
116         @exception      NULL is returned if data is NULL
117 */
118
119 uint8_t * net_nfc_get_data_buffer (const data_h data);
120
121 /**
122         free data handler. (it also free the copied bytes)
123
124         @param[in]      data            data handler
125
126         @return         return the result of this operation
127
128         @exception NET_NFC_NULL_PARAMETER               parameter(s) has(have) illigal NULL pointer(s)
129 */
130
131 net_nfc_error_e net_nfc_free_data (data_h data);
132
133
134
135 /**
136 @}
137 */
138 #ifdef __cplusplus
139 }
140 #endif
141
142
143 #endif
144