Write up to SIZE bytes from buffer BUFFER to the data object. Return the number of characters written, or -1 on error. If an error occurs, errno is set.