// ----------------------------------------------------------------------------- /// @file IODevice.c /// @brief Description // ----------------------------------------------------------------------------- // Micro-Key bv // Industrieweg 28, 9804 TG Noordhorn // Postbus 92, 9800 AB Zuidhorn // The Netherlands // Tel: +31 594 503020 // Fax: +31 594 505825 // Email: support@microkey.nl // Web: www.microkey.nl // ----------------------------------------------------------------------------- /// $Revision$ /// $Author$ /// $Date$ // (c) 2017 Micro-Key bv // ----------------------------------------------------------------------------- /// @file IODevice.c /// @ingroup {group_name} // ----------------------------------------------------------------------------- // Include files // ----------------------------------------------------------------------------- #include "IODevice.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Type definitions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // File-scope variables // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Function definitions // ----------------------------------------------------------------------------- ErrorStatus IODevice_construct (struct IODevice* self, ReadFunction read, WriteFunction write) { ErrorStatus returnValue = SUCCESS; self->_write = write; self->_read = read; return returnValue; } ErrorStatus IODevice_write(const struct IODevice* self, const char* buffer, size_t length) { ErrorStatus returnValue = SUCCESS; if (self->_write != NULL) { returnValue = self->_write(self, buffer, length); } return returnValue; } ErrorStatus IODevice_read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength) { ErrorStatus returnValue = SUCCESS; if (self->_read != NULL) { returnValue = self->_read(self, buffer, length, actualLength); } return returnValue; }