Ejemplo n.º 1
0
_STD_BEGIN

#pragma module_name = "?__read"

/*! \brief Reads a number of bytes, at most \a size, into the memory area
 *         pointed to by \a buffer.
 *
 * \param handle File handle to read from.
 * \param buffer Pointer to buffer to write read bytes to.
 * \param size Number of bytes to read.
 *
 * \return The number of bytes read, \c 0 at the end of the file, or
 *         \c _LLIO_ERROR on failure.
 */
size_t __read(int handle, unsigned char *buffer, size_t size)
{
	int nChars = 0;
	// This implementation only reads from stdin.
	// For all other file handles, it returns failure.
	if (handle != _LLIO_STDIN) {
		return _LLIO_ERROR;
	}
	for (; size > 0; --size) {
		ptr_get(stdio_base, (char*)buffer);
		buffer++;
		nChars++;
	}
	return nChars;
}
Ejemplo n.º 2
0
_read (int file, char * ptr, int len)
{
	int nChars = 0;

	if (file != 0) {
		return -1;
	}

	for (; len > 0; --len) {
		ptr_get(stdio_base, ptr);
		ptr++;
		nChars++;
	}
	return nChars;
}
Ejemplo n.º 3
0
Archivo: read.c Proyecto: JohsBL/MobRob
_read (int file, char * ptr, int len)
{
	int nChars = 0;

	if (file != 0)
		return -1;

	for (; len > 0; --len) {
		int c;
		ptr_get(stdio_base,&c);
		if (c < 0)
		break;
		*ptr++ = c;
		++nChars;
	}
	return nChars;
}
Ejemplo n.º 4
0
int _read (int *f)
{
	char c;
	ptr_get(stdio_base,&c);
	return c;
}