/* EWL2
 * Copyright © 2017 NXP.  All rights reserved.
 *
 */

 /*
  *	Routines
  *	--------
  *		__read_console
  *		__write_console
  *		__close_console
  *
  *	Implementation
  *	--------------
  *
  *		These routines just are stubs for when no IO is available.
  */

#include <ansi_parms.h>
#include <ewl_misra_types.h>
#include <extras/sys/stat.h>
#include "console_io.h"

int_t __attribute__((weak)) __read_console(__file_handle handle, uchar_t * buffer, size_t * count)
{
  return( (int_t)__io_error );
}


int_t __attribute__((weak)) __write_console(__file_handle handle, uchar_t * buffer, size_t * count)
{
  return( (int_t)__io_error );
}


int_t __attribute__((weak)) __close_console(__file_handle handle)
{
  return (int_t)__io_error;
}


/*
 * write - POSIX write
 *
 */
int __attribute__((weak)) write ( int h, void *buf, unsigned len)
{
  return -1;
}


/*
 * read - POSIX read
 *
 */
int __attribute__((weak)) read ( int h, void *buf, unsigned len)
{
  return -1;
}

/*
 * lseek - POSIX lseek
 *
 */
long __attribute__((weak)) lseek (int h, long offset, int whence)
{
    return -1;
}

/*
 * open - POSIX open
 *
 */
int __attribute__((weak)) open( const char *path, int access, ... )
{
  return -1;
}

/*
 * close - POSIX close
 *
 */

int __attribute__((weak)) close (int h)
{
    return -1;
}

/*
 * fstat - POSIX fstat (not supported)
 *
 */

int __attribute__((weak)) fstat(int h, struct stat *buf)
{
    return -1;
}
