From cc29af37f108676ba6cdac4ac0531f6b7db9c263 Mon Sep 17 00:00:00 2001 From: Ingo Huerner Date: Tue, 26 Nov 2013 14:57:52 +0100 Subject: [PATCH] Corrected error codes in doxygen function doc; corrected problem with return value when using write key function for shared values --- include/persistence_client_custom.h | 57 ++--- include/persistence_client_library.h | 7 +- include/persistence_client_library_error_def.h | 5 +- include/persistence_client_library_file.h | 64 +++--- include/persistence_client_library_key.h | 76 ++++--- include_protected/crc32.h | 2 +- src/crc32.c | 2 +- src/persistence_client_library.c | 7 +- src/persistence_client_library_backup_filelist.c | 4 +- src/persistence_client_library_db_access.c | 14 +- src/persistence_client_library_dbus_service.c | 2 - src/persistence_client_library_file.c | 264 ++++++++++++----------- src/persistence_client_library_key.c | 18 +- test/persistence_client_library_test.c | 8 +- 14 files changed, 297 insertions(+), 233 deletions(-) diff --git a/include/persistence_client_custom.h b/include/persistence_client_custom.h index 3fc894e..56f5904 100644 --- a/include/persistence_client_custom.h +++ b/include/persistence_client_custom.h @@ -1,21 +1,23 @@ #ifndef PERSISTENCE_CLIENT_LIBRARY_CUSTOM_H #define PERSISTENCE_CLIENT_LIBRARY_CUSTOM_H -/**************************************************** - * persistence_custom.h - * Created on: 09-Jul-2012 11:38:03 - * Implementation of the Interface PersCustom - * Original author: ihuerner, G.Sagnes - * - * \file persistence_client_custom.h - * \brief Implementation of the Interface PersCustom - * - * \par Responsibility - * - SW-Subsystem: EG-SI - * - SW-Domain: Persistence - * - Interface Visibility: Protected - * \par change history - * \verbatim +/****************************************************************************** + * Project Persistency + * (c) copyright 2012 + * Company XS Embedded GmbH + *****************************************************************************/ +/****************************************************************************** + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed + * with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +******************************************************************************/ + /** + * @file persistence_client_custom.h + * @ingroup Persistence client library + * @author Ingo Huerner (XSe) / Guy Sagnes (Continental) + * @brief Header of the persistence client library custom plugin. + * Library provides an plugin API to extend persistence client library + * @par change history * Date Author Version Description * 2013.06.26 ihuerner 1.5.0.0 added description of parameters * 2013.01.06 ihuerner 1.4.0.0 plugin_handle_open and plugin_set_data changed from char* to const char* @@ -23,9 +25,8 @@ * 2012.10.16 gsagnes 1.2.0.0 add get_size, create_backup, restore_backup * 2012.10.04 gsagnes 1.1.0.0 add deinitialisation functionality (call during shutdown) * 2012.07.14 ihuerner 1.0.0.0 Initial version of the interface - * \endverbatim - * - ****************************************************/ + */ + /** \ingroup GEN_PERS_CLIENTLIB_INTERFACE API document * \{ @@ -51,14 +52,14 @@ The lower significant byte is equal 0 for released version only * * @param backup_id Name of the backup / identifier * - * @return positive value: backup success (size of backup, bytes); negative value: error + * @return positive value (0 or greater): backup success (size of backup, bytes); negative value: error */ int plugin_create_backup(const char* backup_id); /** * @brief deinitialize plugin (during shutdown) * - * @return positive value: init success; negative value: error + * @return positive value (0 or greater): init success; negative value: error */ int plugin_deinit(); @@ -67,7 +68,7 @@ int plugin_deinit(); * * @param path the path to the data to delete * - * @return positive value: delete success; negative value: error + * @return positive value (0 or greater): delete success; negative value: error */ int plugin_delete_data(const char* path); @@ -77,7 +78,7 @@ int plugin_delete_data(const char* path); * @param backup_id Name of the backup / identifier * @param size size of the buffer to return the identifier * - * @return positive value: success, length of identifier; negative value: error + * @return positive value (0 or greater): success, length of identifier; negative value: error */ int plugin_get_backup(char* backup_id, int size); @@ -86,7 +87,7 @@ int plugin_get_backup(char* backup_id, int size); * * @param path the path to the data * - * @return positive value: the size; negative value: error code + * @return positive value (0 or greater): the size; negative value: error code */ int plugin_get_size(const char* path); @@ -97,7 +98,7 @@ int plugin_get_size(const char* path); * @param buffer the buffer to store data * @param size the number of bytes to get data * - * @return positive value: size data read in bytes; negative value: error + * @return positive value (0 or greater): size data read in bytes; negative value: error */ int plugin_get_data(const char* path, char* buffer, int size); @@ -106,7 +107,7 @@ int plugin_get_data(const char* path, char* buffer, int size); * * @param handle the handle to close * - * @return positive value: successfully closed; negative value: error + * @return positive value (0 or greater): successfully closed; negative value: error */ int plugin_handle_close(int handle); @@ -117,7 +118,7 @@ int plugin_handle_close(int handle); * @param buffer the buffer to store data * @param size the number of bytes to get data * - * @return positive value: size data read in bytes; negative value: error + * @return positive value (0 or greater): size data read in bytes; negative value: error */ int plugin_handle_get_data(int handle, char* buffer, int size); @@ -128,7 +129,7 @@ int plugin_handle_get_data(int handle, char* buffer, int size); * @param flag open flags * @param mode the open mode * - * @return positive value: handle; negative value: error + * @return positive value (0 or greater): handle; negative value: error */ int plugin_handle_open(const char* path, int flag, int mode); @@ -155,7 +156,7 @@ int plugin_init(); * * @param backup_id Name of the backup / identifier * - * @return positive value: backup success (size of backup, bytes); negative value: error + * @return positive value (0 or greater): backup success (size of backup, bytes); negative value: error */ int plugin_restore_backup(const char* backup_id); diff --git a/include/persistence_client_library.h b/include/persistence_client_library.h index dbddfe8..4370158 100644 --- a/include/persistence_client_library.h +++ b/include/persistence_client_library.h @@ -65,8 +65,9 @@ extern "C" { * @param shutdownMode shutdown mode ::PCL_SHUTDOWN_TYPE_FAST or ::PCL_SHUTDOWN_TYPE_NORMAL * * @return positive value: success; - * On error a negative value will be returned with th follwoing error codes: - * ::EPERS_LOCKFS, ::EPERS_NOT_INITIALIZED, ::EPERS_INIT_DBUS_MAINLOOP, + * On error a negative value will be returned with th following error codes: + * ::EPERS_NOT_INITIALIZED, ::EPERS_INIT_DBUS_MAINLOOP, + * ::EPERS_REGISTER_LIFECYCLE, ::EPERS_REGISTER_ADMIN */ int pclInitLibrary(const char* appname, int shutdownMode); @@ -78,7 +79,7 @@ int pclInitLibrary(const char* appname, int shutdownMode); * @attention This function is currently N O T part of the GENIVI compliance specification * * @return positive value: success; - * On error a negative value will be returned with th follwoing error codes: ::EPERS_LOCKFS + * On error a negative value will be returned. */ int pclDeinitLibrary(void); diff --git a/include/persistence_client_library_error_def.h b/include/persistence_client_library_error_def.h index f23c6da..8a4a63f 100644 --- a/include/persistence_client_library_error_def.h +++ b/include/persistence_client_library_error_def.h @@ -27,7 +27,7 @@ extern "C" { #endif -// common error, for this error errno will be set +/// common error, for this error errno will be set #define EPERS_COMMON (-1) /// file system is locked #define EPERS_LOCKFS (-2) @@ -103,7 +103,8 @@ extern "C" { #define EPERS_REGISTER_ADMIN (-36) // registration on this key is not allowed #define EPERS_NOTIFY_NOT_ALLOWED (-37) - +// the requested resource is not a file +#define EPERS_RESOURCE_NO_FILE (-38) #ifdef __cplusplus } diff --git a/include/persistence_client_library_file.h b/include/persistence_client_library_file.h index 5f26eef..c357714 100644 --- a/include/persistence_client_library_file.h +++ b/include/persistence_client_library_file.h @@ -44,8 +44,10 @@ extern "C" { * * @param fd the file descriptor to close * - * @return zero on success. On error a negative value will be returned with th follwoing error codes: - * ::EPERS_LOCKFS, ::EPERS_MAXHANDLE + * @return zero on success. + * On error a negative value will be returned with th following error codes: + * ::EPERS_MAXHANDLE ::EPERS_COMMON + * If ::EPERS_COMMON will be returned errno will be set. */ int pclFileClose(int fd); @@ -56,7 +58,8 @@ int pclFileClose(int fd); * * @param fd the POSIX file descriptor * - * @return positive value. On error the negative value -1 will be returned + * @return positive value (0 or greater). On error ::EPERS_NOT_INITIALIZED, ::EPERS_COMMON + * If ::EPERS_COMMON will be returned errno will be set. */ int pclFileGetSize(int fd); @@ -85,9 +88,11 @@ void* pclFileMapData(void* addr, long size, long offset, int fd); * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node * @param seat_no the seat number * - * @return positive value: the POSIX file descriptor; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS, EPERS_MAXHANDLE, EPERS_NOKEY, EPERS_NOKEYDATA, EPERS_NOPRCTABLE or EPERS_COMMON, + * @return positive value (0 or greater): the POSIX file descriptor; + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS, ::EPERS_MAXHANDLE, ::EPERS_NOKEY, ::EPERS_NOKEYDATA, + * ::EPERS_NOPRCTABLE, ::EPERS_NOT_INITIALIZED, ::EPERS_COMMON + * If ::EPERS_COMMON will be returned errno will be set. */ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no); @@ -100,9 +105,10 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n * @param buffer buffer to read the data * @param buffer_size the size buffer for reading * - * @return positive value: the size read; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * @return positive value (0 or greater): the size read; + * On error a negative value will be returned with th following error codes: + * ::EPERS_NOT_INITIALIZED, ::EPERS_LOCKFS, ::EPERS_COMMON. + * If ::EPERS_COMMON will be returned errno will be set */ int pclFileReadData(int fd, void * buffer, int buffer_size); @@ -116,9 +122,10 @@ int pclFileReadData(int fd, void * buffer, int buffer_size); * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node * @param seat_no the seat number * - * @return positive value: success; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * @return positive value (0 or greater): success; + * On error a negative value will be returned with th following error codes: + * ::EPERS_NOT_INITIALIZED, ::EPERS_LOCKFS, ::EPERS_COMMON. + * If ::EPERS_COMMON will be returned errno will be set */ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no); @@ -137,9 +144,10 @@ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user SEEK_END The offset is set to the size of the file plus offset bytes. * - * @return positive value: resulting offset location; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * @return positive value (0 or greater): resulting offset location; + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS, ::EPERS_NOT_INITIALIZED, ::EPERS_COMMON. + * If ::EPERS_COMMON will be returned errno will be set */ int pclFileSeek(int fd, long int offset, int whence); @@ -152,8 +160,9 @@ int pclFileSeek(int fd, long int offset, int whence); * @param size the size in bytes to unmap * * @return on success 0; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS, EPERS_NOT_INITIALIZED, ::EPERS_COMMON. + * If ::EPERS_COMMON will be returned errno will be set */ int pclFileUnmapData(void* address, long size); @@ -166,9 +175,10 @@ int pclFileUnmapData(void* address, long size); * @param buffer the buffer to write * @param buffer_size the size of the buffer to write in bytes * - * @return positive value: bytes written; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * @return positive value (0 or greater): bytes written; + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS, ::EPERS_NOT_INITIALIZED or ::EPERS_COMMON + * If ::EPERS_COMMON will be returned errno will be set. */ int pclFileWriteData(int fd, const void * buffer, int buffer_size); @@ -186,9 +196,10 @@ int pclFileWriteData(int fd, const void * buffer, int buffer_size); * * @note the allocated memory for the path string will be freed in pclFileReleasePath * - * @return positive value on success, which must be used when pclFileReleasePath will be called - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * @return positive value (0 or greater) on success, which must be used when pclFileReleasePath will be called + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS or ::EPERS_COMMON + * If ::EPERS_COMMON will be returned errno will be set. */ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, char** path, unsigned int* size); @@ -200,9 +211,10 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int * * @note the allocated memory in pclFileCreatePath for the path will freed in the function * - * @return positive value: success; - * On error a negative value will be returned with th follwoing error codes: - * EPERS_LOCKFS or EPERS_COMMON + * @return positive value (0 or greater): success; + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS or ::EPERS_COMMON + * If ::EPERS_COMMON will be returned errno will be set. */ int pclFileReleasePath(int pathPandle); diff --git a/include/persistence_client_library_key.h b/include/persistence_client_library_key.h index facad06..fa9fa16 100644 --- a/include/persistence_client_library_key.h +++ b/include/persistence_client_library_key.h @@ -85,8 +85,8 @@ typedef struct _pclNotification_s * * @param notifyStruct structure for notifcation * - * @return positive value: success; - * On error a negative value will be returned with the following error codes: ::EPERS_LOCKFS + * @return positive value (0 or greater): success; + * On error a negative value will be returned with the following error codes: ::EPERS_LOCKFS */ typedef int(* pclChangeNotifyCallback_t)(pclNotification_s * notifyStruct); @@ -103,8 +103,9 @@ typedef int(* pclChangeNotifyCallback_t)(pclNotification_s * notifyStruct); * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node * @param seat_no the seat number * - * @return positive value: success; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS ::EPERS_NOTIFY_SIG + * @return positive value (0 or greater) : success; + * On error a negative value will be returned with the following error codes: + * ::EPERS_LOCKFS, ::EPERS_NOTIFY_SIG, ::EPERS_NOT_INITIALIZED, ::EPERS_BADPOL */ int pclKeyDelete(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no); @@ -118,8 +119,10 @@ int pclKeyDelete(unsigned int ldbid, const char* resource_id, unsigned int user_ * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node * @param seat_no the seat number * - * @return positive value: the size; On error a negative value will be returned with the following error codes: + * @return positive value (0 or greater): the size; + * On error a negative value will be returned with the following error codes: * ::EPERS_LOCKFS, ::EPERS_BADPOL, ::EPERS_NOKEY, ::EPERS_NOKEYDATA or ::EPERS_NOPRCTABLE + * ::EPERS_NOT_INITIALIZED */ int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no); @@ -128,8 +131,9 @@ int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user * * @param key_handle key value handle return by key_handle_open() * - * @return positive value: success; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS + * @return positive value (0 or greater): success; + * On error a negative value will be returned with the following error codes: + * ::EPERS_LOCKFS ::EPERS_MAXHANDLE ::EPERS_NOPLUGINFUNCT ::EPERS_NOT_INITIALIZED */ int pclKeyHandleClose(int key_handle); @@ -140,8 +144,10 @@ int pclKeyHandleClose(int key_handle); * * @param key_handle key value handle return by key_handle_open() * - * @return positive value: the size; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS + * @return positive value (0 or greater): the size; + * On error a negative value will be returned with the following error codes: + * ::EPERS_NOT_INITIALIZED ::EPERS_LOCKFS ::EPERS_NOPLUGINFUNCT ::EPERS_MAXHANDLE + * ::EPERS_NOKEY ::EPERS_DB_KEY_SIZE ::EPERS_NOPRCTABLE */ int pclKeyHandleGetSize(int key_handle); @@ -155,9 +161,9 @@ int pclKeyHandleGetSize(int key_handle); * @param user_no the user ID; user_no=0 can not be used as user-ID beacause ‘0’ is defined as System/node * @param seat_no the seat number * - * @return positive value: the key handle to access the value; + * @return positive value (0 or greater): the key handle to access the value; * On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS + * ::EPERS_NOT_INITIALIZED ::EPERS_NOPLUGINFUNCT :: */ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no); @@ -170,8 +176,9 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u * @param buffer the buffer for persistent data * @param buffer_size size of buffer for reading * - * @return positive value: the bytes read; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS + * @return positive value (0 or greater): the bytes read; + * On error a negative value will be returned with the following error codes: + * ::EPERS_NOT_INITIALIZED ::EPERS_NOPLUGINFUNCT ::EPERS_MAXHANDLE */ int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size); @@ -183,22 +190,28 @@ int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size) * @param key_handle key value handle return by key_handle_open() * @param callback notification callback * - * @return positive value: registration OK; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS ::EPERS_MAXHANDLE ::EPERS_NOTIFY_NOT_ALLOWED + * @return positive value (0 or greater): registration OK; + * On error a negative value will be returned with the following error codes: + * ::EPERS_NOT_INITIALIZED ::EPERS_MAXHANDLE ::EPERS_NOTIFY_NOT_ALLOWED */ int pclKeyHandleRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback); + + /** * @brief unregister a change notification for persistent data * * @param key_handle key value handle return by key_handle_open() * @param callback notification callback * - * @return positive value: registration OK; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS ::EPERS_MAXHANDLE ::EPERS_NOTIFY_NOT_ALLOWED + * @return positive value (0 or greater): registration OK; + * On error a negative value will be returned with the following error codes: + * ::EPERS_NOT_INITIALIZED ::EPERS_LOCKFS ::EPERS_MAXHANDLE ::EPERS_NOTIFY_NOT_ALLOWED */ int pclKeyHandleUnRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t callback); + + /** * @brief writes persistent data identified by key handle * @@ -207,8 +220,10 @@ int pclKeyHandleUnRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback * @param buffer_size the number of bytes to write (default max size is set to 16kB) * use environment variable PERS_MAX_KEY_VAL_DATA_SIZE to modify default size in bytes * - * @return positive value: the bytes written; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS ::EPERS_MAX_BUFF_SIZE ::EPERS_NOTIFY_SIG + * @return positive value (0 or greater): the bytes written; + * On error a negative value will be returned with the following error codes: + * ::EPERS_LOCKFS ::EPERS_MAX_BUFF_SIZE ::EPERS_NOTIFY_SIG ::EPERS_DB_VALUE_SIZE ::EPERS_DB_KEY_SIZE + * ::EPERS_NOPRCTABLE ::EPERS_DB_VALUE_SIZE */ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size); @@ -224,8 +239,9 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size * @param buffer the buffer to read the persistent data * @param buffer_size size of buffer for reading * - * @return positive value: the bytes read; On error a negative value will be returned with th follwoing error codes: - * ::EPERS_LOCKFS + * @return positive value (0 or greater): the bytes read; + * On error a negative value will be returned with th following error codes: + * ::EPERS_LOCKFS ::EPERS_NOT_INITIALIZED ::EPERS_BADPOL ::EPERS_NOPLUGINFUNCT */ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, unsigned char* buffer, int buffer_size); @@ -240,8 +256,9 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use * @param seat_no the seat number * @param callback notification callback * - * @return positive value: registration OK; On error a negative value will be returned with the following error codes: - * ::EPERS_RES_NO_KEY ::EPERS_NOKEYDATA ::EPERS_NOPRCTABLE ::EPERS_NOTIFY_NOT_ALLOWED + * @return positive value (0 or greater): registration OK; + * On error a negative value will be returned with the following error codes: + * ::EPERS_RES_NO_KEY ::EPERS_NOKEYDATA ::EPERS_NOPRCTABLE ::EPERS_NOTIFY_NOT_ALLOWED */ int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback); @@ -256,11 +273,14 @@ int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, un * @param seat_no the seat number * @param callback notification callback * - * @return positive value: registration OK; On error a negative value will be returned with the following error codes: - * ::EPERS_RES_NO_KEY ::EPERS_NOKEYDATA ::EPERS_NOPRCTABLE ::EPERS_NOTIFY_NOT_ALLOWED + * @return positive value (0 or greater): registration OK; + * On error a negative value will be returned with the following error codes: + * ::EPERS_RES_NO_KEY ::EPERS_NOKEYDATA ::EPERS_NOPRCTABLE ::EPERS_NOTIFY_NOT_ALLOWED */ int pclKeyUnRegisterNotifyOnChange( unsigned int ldbid, const char * resource_id, unsigned int user_no, unsigned int seat_no, pclChangeNotifyCallback_t callback); + + /** * @brief writes persistent data identified by ldbid and resource_id * @@ -272,11 +292,13 @@ int pclKeyUnRegisterNotifyOnChange( unsigned int ldbid, const char * resource_ * @param buffer_size the number of bytes to write (default max size is set to 16kB) * use environment variable PERS_MAX_KEY_VAL_DATA_SIZE to modify default size in bytes * - * @return positive value: the bytes written; On error a negative value will be returned with the following error codes: - * ::EPERS_LOCKFS ::EPERS_NOTIFY_NOT_ALLOWED + * @return positive value (0 or greater): the bytes written; + * On error a negative value will be returned with the following error codes: + * ::EPERS_LOCKFS ::EPERS_BADPOL ::EPERS_BUFLIMIT ::EPERS_DB_VALUE_SIZE ::EPERS_DB_KEY_SIZE ::EPERS_NOTIFY_SIG */ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no, unsigned char* buffer, int buffer_size); + /** \} */ #ifdef __cplusplus diff --git a/include_protected/crc32.h b/include_protected/crc32.h index 781e7eb..8a4e0b9 100644 --- a/include_protected/crc32.h +++ b/include_protected/crc32.h @@ -30,7 +30,7 @@ extern "C" { #include -const unsigned int crc32(unsigned int crc, const unsigned char *buf, size_t theSize); +const unsigned int pclCrc32(unsigned int crc, const unsigned char *buf, size_t theSize); #ifdef __cplusplus diff --git a/src/crc32.c b/src/crc32.c index 4283358..ad325ad 100644 --- a/src/crc32.c +++ b/src/crc32.c @@ -107,7 +107,7 @@ static unsigned int crc32_tab[] = 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -const unsigned int crc32(unsigned int crc, const unsigned char *buf, size_t theSize) +const unsigned int pclCrc32(unsigned int crc, const unsigned char *buf, size_t theSize) { const unsigned char *p = 0; unsigned int rval = 0; diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index f723083..3c70f02 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -89,6 +89,7 @@ int pclInitLibrary(const char* appName, int shutdownMode) if(setup_dbus_mainloop() == -1) { DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to setup main loop")); + pthread_mutex_unlock(&gDbusPendingRegMtx); return EPERS_DBUS_MAINLOOP; } @@ -98,6 +99,7 @@ int pclInitLibrary(const char* appName, int shutdownMode) if(register_lifecycle(shutdownMode) == -1) { DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to register to lifecycle dbus interface")); + pthread_mutex_unlock(&gDbusPendingRegMtx); return EPERS_REGISTER_LIFECYCLE; } } @@ -105,6 +107,7 @@ int pclInitLibrary(const char* appName, int shutdownMode) if(register_pers_admin_service() == -1) { DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to register to pers admin dbus interface")); + pthread_mutex_unlock(&gDbusPendingRegMtx); return EPERS_REGISTER_ADMIN; } @@ -188,7 +191,9 @@ int pclDeinitLibrary(void) DLT_STRING("- init counter: "), DLT_INT(gPclInitialized)); // unregister for lifecycle and persistence admin service dbus messages - rval = unregister_lifecycle(gShutdownMode); + if(gShutdownMode != PCL_SHUTDOWN_TYPE_NONE) + rval = unregister_lifecycle(gShutdownMode); + rval = unregister_pers_admin_service(); // unload custom client libraries diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c index d6c58f7..24cf12b 100644 --- a/src/persistence_client_library_backup_filelist.c +++ b/src/persistence_client_library_backup_filelist.c @@ -61,7 +61,6 @@ const char gCharLookup[] = 0,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, // from 020 (space) to 0x2F (?) 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, // from 040 (@) to 0x5F (_) 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1 // from 060 (') to 0x7E (~) - }; @@ -70,6 +69,7 @@ char* gpTokenArray[TOKENARRAYSIZE] = {0}; int gTokenCounter = 0; unsigned int gConfigFileSize = 0; + /// the rb tree static jsw_rbtree_t *gRb_tree_bl = NULL; @@ -136,7 +136,7 @@ void createAndStoreFileNames() item = malloc(sizeof(key_value_s)); if(item != NULL) { - item->key = crc32(0, (unsigned char*)path, strlen(path)); + item->key = pclCrc32(0, (unsigned char*)path, strlen(path)); // we don't need the path name here, we just need to know that this key is available in the tree item->value = ""; jsw_rbinsert(gRb_tree_bl, item); diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c index 8877a91..976fbdd 100644 --- a/src/persistence_client_library_db_access.c +++ b/src/persistence_client_library_db_access.c @@ -406,7 +406,12 @@ int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned if(PersistenceStorage_shared == info->configKey.storage) { - write_size = pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed); + int rval = pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed); + if(rval <= 0) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_write_key ==> failed to send notification signal")); + write_size = rval; + } } } else @@ -445,7 +450,12 @@ int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned if(write_size >= 0) // success ==> send deleted notification { - write_size = pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed); + int rval = pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed); + if(rval <= 0) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_write_key ==> failed to send notification signal")); + write_size = rval; + } } } else diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c index 86e53ae..9b86343 100644 --- a/src/persistence_client_library_dbus_service.c +++ b/src/persistence_client_library_dbus_service.c @@ -257,8 +257,6 @@ int setup_dbus_mainloop(void) const char *pAddress = getenv("PERS_CLIENT_DBUS_ADDRESS"); - // enable locking of data structures in the D-Bus library for multi threading. - dbus_threads_init_default(); dbus_error_init(&err); // wain until dbus main loop has been setup and running diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c index 8047c34..b065df9 100644 --- a/src/persistence_client_library_file.c +++ b/src/persistence_client_library_file.c @@ -144,10 +144,10 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n int shared_DB = 0; PersistenceInfo_s dbContext; - char dbKey[DbKeyMaxLen] = {0}; // database key - char dbPath[DbPathMaxLen] = {0}; // database location + char dbKey[DbKeyMaxLen] = {0}; // database key + char dbPath[DbPathMaxLen] = {0}; // database location char backupPath[DbKeyMaxLen] = {0}; // backup file - char csumPath[DbPathMaxLen] = {0}; // checksum file + char csumPath[DbPathMaxLen] = {0}; // checksum file //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileOpen: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); @@ -158,84 +158,89 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n // get database context: database path and database key shared_DB = get_db_context(&dbContext, resource_id, ResIsFile, dbKey, dbPath); - if( (shared_DB >= 0) // check valid database context - && (dbContext.configKey.type == PersistenceResourceType_file) ) // check if type matches + if(dbContext.configKey.type == PersistenceResourceType_file) // check if the resource is really a file { - int flags = dbContext.configKey.permission; - - // file will be opened writable, so check about data consistency - if( dbContext.configKey.permission != PersistencePermission_ReadOnly - && pclBackupNeeded(dbPath) ) + if(shared_DB >= 0) // check valid database context { - snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); - snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); + int flags = dbContext.configKey.permission; - if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1) + // file will be opened writable, so check about data consistency + if( (dbContext.configKey.permission != PersistencePermission_ReadOnly) + && pclBackupNeeded(dbPath) ) { - DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!")); - return -1; - } - } - - // open file - if(handle <= 0) // check if open is needed or already done in verifyConsistency - { - handle = open(dbPath, flags); - } + snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); + snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); + if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!")); + return -1; + } + } - if(handle != -1) - { - if(handle < MaxPersHandle) + // open file + if(handle <= 0) // check if open is needed or already done in verifyConsistency { - __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag + handle = open(dbPath, flags); + } - if(dbContext.configKey.permission != PersistencePermission_ReadOnly) + if(handle != -1) + { + if(handle < MaxPersHandle) { - strcpy(gFileHandleArray[handle].backupPath, backupPath); - strcpy(gFileHandleArray[handle].csumPath, csumPath); + __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag - gFileHandleArray[handle].backupCreated = 0; - gFileHandleArray[handle].permission = dbContext.configKey.permission; + if(dbContext.configKey.permission != PersistencePermission_ReadOnly) + { + strcpy(gFileHandleArray[handle].backupPath, backupPath); + strcpy(gFileHandleArray[handle].csumPath, csumPath); + + gFileHandleArray[handle].backupCreated = 0; + gFileHandleArray[handle].permission = dbContext.configKey.permission; + } + } + else + { + close(handle); + handle = EPERS_MAXHANDLE; } } - else + else // file does not exist, create file and folder { - close(handle); - handle = EPERS_MAXHANDLE; + handle = pclCreateFile(dbPath); } } - else // file does not exist, create file and folder + else // requested resource is not in the RCT, so create resource as local/cached. { + // assemble file string for local cached location + snprintf(dbPath, DbPathMaxLen, gLocalCacheFilePath, gAppId, user_no, seat_no, resource_id); handle = pclCreateFile(dbPath); - } - } - else - { - // assemble file string for local cached location - snprintf(dbPath, DbPathMaxLen, gLocalCacheFilePath, gAppId, user_no, seat_no, resource_id); - handle = pclCreateFile(dbPath); - if(handle != -1) - { - if(handle < MaxPersHandle) + if(handle != -1) { - snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); - snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); + if(handle < MaxPersHandle) + { + snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); + snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); - __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag - strcpy(gFileHandleArray[handle].backupPath, backupPath); - strcpy(gFileHandleArray[handle].csumPath, csumPath); - gFileHandleArray[handle].backupCreated = 0; - gFileHandleArray[handle].permission = PersistencePermission_ReadWrite; // make it writable - } - else - { - close(handle); - handle = EPERS_MAXHANDLE; + __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag + strcpy(gFileHandleArray[handle].backupPath, backupPath); + strcpy(gFileHandleArray[handle].csumPath, csumPath); + gFileHandleArray[handle].backupCreated = 0; + gFileHandleArray[handle].permission = PersistencePermission_ReadWrite; // make it writable + } + else + { + close(handle); + handle = EPERS_MAXHANDLE; + } } } } + else + { + handle = EPERS_RESOURCE_NO_FILE; + } } return handle; @@ -415,83 +420,88 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int // get database context: database path and database key shared_DB = get_db_context(&dbContext, resource_id, ResIsFile, dbKey, dbPath); - if( (shared_DB >= 0) // check valid database context - && (dbContext.configKey.type == PersistenceResourceType_file) ) // check if type matches + if( dbContext.configKey.type == PersistenceResourceType_file) // check if type matches { - int flags = dbContext.configKey.permission; - - // file will be opened writable, so check about data consistency - if( dbContext.configKey.permission != PersistencePermission_ReadOnly - && pclBackupNeeded(dbPath) ) + if(shared_DB >= 0) // check valid database context { - snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); - snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); + int flags = dbContext.configKey.permission; - if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1) + // file will be opened writable, so check about data consistency + if( dbContext.configKey.permission != PersistencePermission_ReadOnly + && pclBackupNeeded(dbPath) ) { - DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!")); - return -1; + snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); + snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); + + if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!")); + return -1; + } + // we don't need the file handle here + // the application calling this function must use the POSIX open() function to get an file descriptor + close(handle); } - // we don't need the file handle here - // the application calling this function must use the POSIX open() function to get an file descriptor - close(handle); - } - handle = get_persistence_handle_idx(); + handle = get_persistence_handle_idx(); - if(handle != -1) - { - if(handle < MaxPersHandle) + if(handle != -1) { - __sync_fetch_and_add(&gOpenHandleArray[handle], FileOpen); // set open flag + if(handle < MaxPersHandle) + { + __sync_fetch_and_add(&gOpenHandleArray[handle], FileOpen); // set open flag + + if(dbContext.configKey.permission != PersistencePermission_ReadOnly) + { + strcpy(gOssHandleArray[handle].backupPath, backupPath); + strcpy(gOssHandleArray[handle].csumPath, csumPath); + + gOssHandleArray[handle].backupCreated = 0; + gOssHandleArray[handle].permission = dbContext.configKey.permission; + } - if(dbContext.configKey.permission != PersistencePermission_ReadOnly) + *size = strlen(dbPath); + *path = malloc(*size); + memcpy(*path, dbPath, *size); + gOssHandleArray[handle].filePath = *path; + } + else { + set_persistence_handle_close_idx(handle); + handle = EPERS_MAXHANDLE; + } + } + } + else // requested resource is not in the RCT, so create resource as local/cached. + { + // assemble file string for local cached location + snprintf(dbPath, DbPathMaxLen, gLocalCacheFilePath, gAppId, user_no, seat_no, resource_id); + handle = get_persistence_handle_idx(); + + if(handle != -1) + { + if(handle < MaxPersHandle) + { + snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); + snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); + + __sync_fetch_and_add(&gOpenHandleArray[handle], FileOpen); // set open flag strcpy(gOssHandleArray[handle].backupPath, backupPath); strcpy(gOssHandleArray[handle].csumPath, csumPath); - gOssHandleArray[handle].backupCreated = 0; - gOssHandleArray[handle].permission = dbContext.configKey.permission; + gOssHandleArray[handle].permission = PersistencePermission_ReadWrite; // make it writable + } + else + { + set_persistence_handle_close_idx(handle); + handle = EPERS_MAXHANDLE; } - - *size = strlen(dbPath); - *path = malloc(*size); - memcpy(*path, dbPath, *size); - gOssHandleArray[handle].filePath = *path; - } - else - { - set_persistence_handle_close_idx(handle); - handle = EPERS_MAXHANDLE; } } } else { - // assemble file string for local cached location - snprintf(dbPath, DbPathMaxLen, gLocalCacheFilePath, gAppId, user_no, seat_no, resource_id); - - handle = get_persistence_handle_idx(); - - if(handle != -1) - { - if(handle < MaxPersHandle) - { - snprintf(backupPath, DbPathMaxLen, "%s%s", dbPath, "~"); - snprintf(csumPath, DbPathMaxLen, "%s%s", dbPath, "~.crc"); - - __sync_fetch_and_add(&gOpenHandleArray[handle], FileOpen); // set open flag - strcpy(gOssHandleArray[handle].backupPath, backupPath); - strcpy(gOssHandleArray[handle].csumPath, csumPath); - gOssHandleArray[handle].backupCreated = 0; - gOssHandleArray[handle].permission = PersistencePermission_ReadWrite; // make it writable - } - else - { - set_persistence_handle_close_idx(handle); - handle = EPERS_MAXHANDLE; - } - } + handle = EPERS_RESOURCE_NO_FILE; } } @@ -500,7 +510,7 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int -int pclFileReleasePath(int pathPandle) +int pclFileReleasePath(int pathHandle) { int rval = EPERS_NOT_INITIALIZED; @@ -508,22 +518,22 @@ int pclFileReleasePath(int pathPandle) if(gPclInitialized >= PCLinitialized) { - if(pathPandle < MaxPersHandle) + if(pathHandle < MaxPersHandle) { // check if a backup and checksum file needs to bel deleted - if( gFileHandleArray[pathPandle].permission != PersistencePermission_ReadOnly) + if( gFileHandleArray[pathHandle].permission != PersistencePermission_ReadOnly) { // remove backup file - remove(gOssHandleArray[pathPandle].backupPath); // we don't care about return value + remove(gOssHandleArray[pathHandle].backupPath); // we don't care about return value // remove checksum file - remove(gOssHandleArray[pathPandle].csumPath); // we don't care about return value + remove(gOssHandleArray[pathHandle].csumPath); // we don't care about return value } - free(gOssHandleArray[pathPandle].filePath); - __sync_fetch_and_sub(&gOpenHandleArray[pathPandle], FileClosed); // set closed flag - set_persistence_handle_close_idx(pathPandle); - gOssHandleArray[pathPandle].filePath = NULL; + free(gOssHandleArray[pathHandle].filePath); + __sync_fetch_and_sub(&gOpenHandleArray[pathHandle], FileClosed); // set closed flag + set_persistence_handle_close_idx(pathHandle); + gOssHandleArray[pathHandle].filePath = NULL; rval = 1; } else @@ -892,7 +902,7 @@ int pclCalcCrc32Csum(int fd, char crc32sum[]) while((rval = read(fd, buf, statBuf.st_size)) > 0) { unsigned int crc = 0; - crc = crc32(crc, (unsigned char*)buf, statBuf.st_size); + crc = pclCrc32(crc, (unsigned char*)buf, statBuf.st_size); snprintf(crc32sum, ChecksumBufSize-1, "%x", crc); } @@ -909,7 +919,7 @@ int pclCalcCrc32Csum(int fd, char crc32sum[]) int pclBackupNeeded(const char* path) { - return need_backup_key(crc32(0, (const unsigned char*)path, strlen(path))); + return need_backup_key(pclCrc32(0, (const unsigned char*)path, strlen(path))); } diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c index 6685877..acd3852 100644 --- a/src/persistence_client_library_key.c +++ b/src/persistence_client_library_key.c @@ -109,7 +109,7 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u int pclKeyHandleClose(int key_handle) { - int rval = 1; + int rval = EPERS_NOT_INITIALIZED; //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleClose: "), // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); @@ -146,10 +146,6 @@ int pclKeyHandleClose(int key_handle) rval = EPERS_MAXHANDLE; } } - else - { - rval = EPERS_NOT_INITIALIZED; - } return rval; } @@ -306,8 +302,14 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size if(size >= 0) // success ==> send change notification { - size = pers_send_Notification_Signal(gKeyHandleArray[key_handle].dbKey, - &(gKeyHandleArray[key_handle].info.context), pclNotifyStatus_changed); + int rval = pers_send_Notification_Signal(gKeyHandleArray[key_handle].dbKey, + &(gKeyHandleArray[key_handle].info.context), pclNotifyStatus_changed); + + if(rval <= 0) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleWriteData: error - failed to send notification")); + size = rval; + } } } else @@ -524,7 +526,7 @@ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int us && (dbContext.configKey.type == PersistenceResourceType_key)) { // get hash value of data to verify storing - hash_val_data = crc32(hash_val_data, buffer, buffer_size); + hash_val_data = pclCrc32(hash_val_data, buffer, buffer_size); // store data if( dbContext.configKey.storage < PersistenceStorage_LastEntry diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c index 6fc5992..789c9cc 100644 --- a/test/persistence_client_library_test.c +++ b/test/persistence_client_library_test.c @@ -186,7 +186,7 @@ START_TEST (test_GetDataHandle) fail_unless(strncmp((char*)buffer, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", ret-1) == 0, "Buffer not correctly read => 1"); size = pclKeyHandleGetSize(handle); - fail_unless(size = strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"")); + fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"")); // --------------------------------------------------------------------------------------------- @@ -199,7 +199,7 @@ START_TEST (test_GetDataHandle) fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document"); size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer)); - fail_unless(size = strlen(sysTimeBuffer)); + fail_unless(size == strlen(sysTimeBuffer)); // close ret = pclKeyHandleClose(handle2); // --------------------------------------------------------------------------------------------- @@ -319,6 +319,7 @@ START_TEST(test_SetData) */ //printf("Write data to trigger change notification\n"); ret = pclKeyWriteData(0x84, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data")); + fail_unless(ret == strlen("Test notify shared data"), "Wrong write size"); /** * Logical DB ID: 0x84 with user 2 and seat 1 @@ -328,6 +329,7 @@ START_TEST(test_SetData) */ //printf("Write data to trigger change notification\n"); ret = pclKeyWriteData(0x84, "links/last_link3", 3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data")); + fail_unless(ret == strlen("Test notify shared data"), "Wrong write size"); /** * Logical DB ID: 0x84 with user 2 and seat 1 @@ -337,6 +339,7 @@ START_TEST(test_SetData) */ //printf("Write data to trigger change notification\n"); ret = pclKeyWriteData(0x84, "links/last_link4", 4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data")); + fail_unless(ret == strlen("Test notify shared data"), "Wrong write size"); /*******************************************************************************************************************************************/ /*******************************************************************************************************************************************/ @@ -983,7 +986,6 @@ START_TEST(test_GetPath) END_TEST - static Suite * persistencyClientLib_suite() { Suite * s = suite_create("Persistency client library"); -- 2.7.4