Пример #1
0
int emu_file::ungetc(int c)
{
    // load the ZIP file now if we haven't yet
    if (compressed_file_ready())
        return 1;

    // read the data if we can
    if (m_file != NULL)
        return core_ungetc(c, m_file);

    return 1;
}
Пример #2
0
int emu_file::ungetc(int c)
{
	// load the ZIP file now if we haven't yet
	if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
		return 1;

	// read the data if we can
	if (m_file != NULL)
		return core_ungetc(c, m_file);

	return 1;
}
Пример #3
0
char *core_fgets(char *s, int n, core_file *file)
{
	char *cur = s;

	/* loop while we have characters */
	while (n > 0)
	{
		int c = core_fgetc(file);
		if (c == EOF)
			break;

		/* if there's a CR, look for an LF afterwards */
		if (c == 0x0d)
		{
			int c2 = core_fgetc(file);
			if (c2 != 0x0a)
				core_ungetc(c2, file);
			*cur++ = 0x0d;
			n--;
			break;
		}

		/* if there's an LF, reinterp as a CR for consistency */
		else if (c == 0x0a)
		{
			*cur++ = 0x0d;
			n--;
			break;
		}

		/* otherwise, pop the character in and continue */
		*cur++ = c;
		n--;
	}

	/* if we put nothing in, return NULL */
	if (cur == s)
		return NULL;

	/* otherwise, terminate */
	if (n > 0)
		*cur++ = 0;
	return s;
}