1 #ifndef PERSISTENCE_CLIENT_LIBRARY_FILE_H
2 #define PERSISTENCE_CLIENT_LIBRARY_FILE_H
4 /******************************************************************************
7 * Company XS Embedded GmbH
8 *****************************************************************************/
9 /******************************************************************************
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
12 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 ******************************************************************************/
15 * @file persistence_client_library_file.h
16 * @ingroup Persistence client library
17 * @author Ingo Huerner (XSe) / Guy Sagnes (Continental)
18 * @brief Header of the persistence client library.
19 * Library provides an API to access persistent data
22 /** \ingroup GEN_PERS */
23 /** \defgroup PERS_FILE Client: File access
26 /** \defgroup PERS_FILE_INTERFACE API document
34 #define PERSIST_FILEAPI_INTERFACE_VERSION (0x03010000U)
36 #include "persistence_client_library.h"
38 /** \defgroup PCL_FILE functions file access
43 * @brief close the given POSIX file descriptor
45 * @param fd the file descriptor to close
47 * @return zero on success. On error a negative value will be returned with th follwoing error codes:
48 * ::EPERS_LOCKFS, ::EPERS_MAXHANDLE
50 int pclFileClose(int fd);
55 * @brief get the size of the file given by the file descriptor
57 * @param fd the POSIX file descriptor
59 * @return positive value. On error the negative value -1 will be returned
61 int pclFileGetSize(int fd);
66 * @brief map a file into the memory
68 * @param addr if NULL, kernel chooses address
69 * @param size the size in bytes to map into the memory
70 * @param offset in the file to map
71 * @param fd the POSIX file descriptor of the file to map
73 * @return a pointer to the mapped area, or on error the value MAP_FAILED or
74 * EPERS_MAP_FAILEDLOCK if filesystem is currrently locked
76 void* pclFileMapData(void* addr, long size, long offset, int fd);
83 * @param ldbid logical database ID
84 * @param resource_id the resource ID
85 * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node
86 * @param seat_no the seat number
88 * @return positive value: the POSIX file descriptor;
89 * On error a negative value will be returned with th follwoing error codes:
90 * EPERS_LOCKFS, EPERS_MAXHANDLE, EPERS_NOKEY, EPERS_NOKEYDATA, EPERS_NOPRCTABLE or EPERS_COMMON,
92 int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no);
97 * @brief read persistent data from a file
99 * @param fd POSIX file descriptor
100 * @param buffer buffer to read the data
101 * @param buffer_size the size buffer for reading
103 * @return positive value: the size read;
104 * On error a negative value will be returned with th follwoing error codes:
105 * EPERS_LOCKFS or EPERS_COMMON
107 int pclFileReadData(int fd, void * buffer, int buffer_size);
112 * @brief remove the file
114 * @param ldbid logical database ID
115 * @param resource_id the resource ID
116 * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node
117 * @param seat_no the seat number
119 * @return positive value: success;
120 * On error a negative value will be returned with th follwoing error codes:
121 * EPERS_LOCKFS or EPERS_COMMON
123 int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no);
128 * @brief reposition the file descriptor
130 * @param fd the POSIX file descriptor
131 * @param offset the reposition offset
132 * @param whence the direction to reposition
134 The offset is set to offset bytes.
136 The offset is set to its current location plus offset bytes.
138 The offset is set to the size of the file plus offset bytes.
140 * @return positive value: resulting offset location;
141 * On error a negative value will be returned with th follwoing error codes:
142 * EPERS_LOCKFS or EPERS_COMMON
144 int pclFileSeek(int fd, long int offset, int whence);
149 * @brief unmap the file from the memory
151 * @param address the address to unmap
152 * @param size the size in bytes to unmap
154 * @return on success 0;
155 * On error a negative value will be returned with th follwoing error codes:
156 * EPERS_LOCKFS or EPERS_COMMON
158 int pclFileUnmapData(void* address, long size);
163 * @brief write persistent data to file
165 * @param fd the POSIX file descriptor
166 * @param buffer the buffer to write
167 * @param buffer_size the size of the buffer to write in bytes
169 * @return positive value: bytes written;
170 * On error a negative value will be returned with th follwoing error codes:
171 * EPERS_LOCKFS or EPERS_COMMON
173 int pclFileWriteData(int fd, const void * buffer, int buffer_size);
178 * @brief create a path to a file
180 * @param ldbid logical database ID
181 * @param resource_id the resource ID
182 * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node
183 * @param seat_no the seat number
184 * @param path the path to the file
185 * @param size the size of the path
187 * @note the allocated memory for the path string will be freed in tpclFileReleasePath
189 * @return positive value on success, which must be used when pclFileReleasePath will be called
190 * On error a negative value will be returned with th follwoing error codes:
191 * EPERS_LOCKFS or EPERS_COMMON
193 int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, char** path, unsigned int* size);
197 * @brief release a file path
199 * @param pathHandle the path to the file
201 * @note the allocated memory in pclFileCreatePath for the path will freed in the function
203 * @return positive value: success;
204 * On error a negative value will be returned with th follwoing error codes:
205 * EPERS_LOCKFS or EPERS_COMMON
207 int pclFileReleasePath(int pathPandle);
216 /** \} */ /* End of API */
217 /** \} */ /* End of MODULE */
220 #endif /* PERSISTENCY_CLIENT_LIBRARY_FILE_H */