Пример #1
0
size_t readframe (signed fd, void * memory, size_t extent)

{
	unsigned digits = 0;
	uint8_t * origin = (uint8_t *)(memory);
	uint8_t * offset = (uint8_t *)(memory);
	signed c = EOF;
	while ((extent) && ((c = fdgetc (fd)) != EOF) && (c != ';'))
	{
		if (isspace (c))
		{
			continue;
		}
		if (c == '#')
		{
			do
			{
				c = fdgetc (fd);
			}
			while ((c != '\n') && (c != EOF));
			continue;
		}
		if (c == '/')
		{
			c = fdgetc (fd);
			if (c == '/')
			{
				do
				{
					c = fdgetc (fd);
				}
				while ((c != '\n') && (c != EOF));
				continue;
			}
			if (c == '*')
			{
				while ((c != '/') && (c != EOF))
				{
					while ((c != '*') && (c != EOF))
					{
						c = fdgetc (fd);
					}
					c = fdgetc (fd);
				}
				continue;
			}
			continue;
		}
		if (isxdigit (c))
		{
			*offset = c;
			offset++;
			digits++;
			extent--;
			continue;
		}
		error (1, ENOTSUP, "Illegal hex digit '%c' (0x%02X) in source", c, c);
	}
	if (digits & 1)
	{
		error (1, ENOTSUP, "Odd number of hex digits (%d) in source", digits);
	}
	return (offset - origin);
}
Пример #2
0
Файл: stdio.c Проект: esxgx/uofw
int getchar(void)
{
    dbg_printf("Calling %s\n", __FUNCTION__);
    return fdgetc(STDIN);
}
Пример #3
0
size_t hexread(signed fd, void * memory, size_t extent)

{
	uint8_t * origin = (uint8_t *) (memory);
	uint8_t * offset = (uint8_t *) (memory);
	unsigned digits = 0;
	signed c = EOF;
	while ((extent) && ((c = fdgetc(fd)) != EOF) && (c != ';'))
	{
		if (isspace(c))
		{
			continue;
		}
		if (c == '#')
		{
			do 
			{
				c = fdgetc(fd);
			}
			while ((c != '\n') && (c != EOF));
			continue;
		}
		if (c == '/')
		{
			c = fdgetc(fd);
			if (c == '/')
			{
				do 
				{
					c = fdgetc(fd);
				}
				while ((c != '\n') && (c != EOF));
				continue;
			}
			if (c == '*')
			{
				while ((c != '/') && (c != EOF))
				{
					while ((c != '*') && (c != EOF))
					{
						c = fdgetc(fd);
					}
					c = fdgetc(fd);
				}
				continue;
			}
			continue;
		}
		if ((c >= '0') && (c <= '9'))
		{
			* offset *= 16;
			* offset += c - '0';
			if (digits++ & 1)
			{
				offset++;
				extent--;
			}
			continue;
		}
		if ((c >= 'A') && (c <= 'F'))
		{
			* offset *= 16;
			* offset += 10;
			* offset += c - 'A';
			if (digits++ & 1)
			{
				offset++;
				extent--;
			}
			continue;
		}
		if ((c >= 'a') && (c <= 'f'))
		{
			* offset *= 16;
			* offset += 10;
			* offset += c - 'a';
			if (digits++ & 1)
			{
				offset++;
				extent--;
			}
			continue;
		}

#if defined (BAILOUT)

		error (1, ENOTSUP, "Illegal hex digit '%c' (0x%02X) in source", c, c);

#else

		return ((size_t) (- 1));

#endif

	}
	if ((extent) && (digits & 1))
	{

#if defined (BAILOUT)

		error (1, ENOTSUP, "Odd number of hex digits (%d) in source", digits);

#else

		return ((size_t) (- 1));

#endif

	}

#if 0

	while ((c != ';') && (c != EOF))
	{
		c = fdgetc(fd);
	}

#endif

	return (offset - origin);
}
Пример #4
0
Файл: stdio.c Проект: esxgx/uofw
char *fdgets(char *s, int fd)
{
    dbg_printf("Calling %s\n", __FUNCTION__);
    char *end = s + 125;
    char *curS = s;
    for (;;)
    {
        char c = (char)fdgetc(fd);
        switch (c)
        {
        case '\026': // sync
            // 0808
            c = (char)fdgetc(fd);
            if (curS < end)
            {
                *(curS++) = c;
                if (sceKernelDebugEcho() != 0)
                    fdputc(c, (fd != STDIN ? fd : STDOUT));
            }
            else if (sceKernelDebugEcho() != 0)
                fdputc('\a', (fd != STDIN ? fd : STDOUT));
            break;
        case '\177': // DEL
        case '\b':
            // 0790
            // 0794
            if (s >= curS)
                break;
            curS--;
            if (sceKernelDebugEcho() != 0)
            {
                int realFd = (fd != STDIN ? fd : STDOUT);
                fdputc('\b', realFd);
                fdputc(' ' , realFd);
                fdputc('\b', realFd);
            }
            break;
        case -1:
            // 0740
            if (s == curS) {
                *curS = '\0';
                return NULL;
            }
        case '\n':
        case '\r':
            // 0748
            if (sceKernelDebugEcho() != 0)
                fdputc('\n', (fd != STDIN ? fd : STDOUT));
            *curS = '\0';
            return s;
        case '\t':
            c = ' ';
        default:
            // 06DC
            if ((look_ctype_table(c) & 0x97) != 0 && curS < end)
            {
                *(curS++) = c;
                if (sceKernelDebugEcho() != 0)
                    fdputc(c, (fd != STDIN ? fd : STDOUT));
            }
            else if (sceKernelDebugEcho() != 0)
                fdputc('\a', (fd != STDIN ? fd : STDOUT));
            break;
        }
    }
}