예제 #1
0
파일: read.c 프로젝트: SupiSquirrel/Tempest
_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;
}
예제 #2
0
파일: read.c 프로젝트: SupiSquirrel/Tempest
_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;
}
예제 #3
0
파일: read.c 프로젝트: 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;
}
예제 #4
0
파일: read.c 프로젝트: SupiSquirrel/Tempest
int _read (int *f)
{
	char c;
	ptr_get(stdio_base,&c);
	return c;
}