示例#1
0
/* May need 256 bytes for older versions of MikeOS */
int readcons()
{
	os_input_string(console.ibuf.data, 256);
	os_print_newline();
	console.ibuf.offset = 0;
	strcat(console.ibuf.data, "\n");
	return strlen(console.ibuf.data);
}
示例#2
0
/* Unbuffered for now. */
int writecons(int ch)
{
	if (ch == '\n') {
		os_print_newline();
	} else {
		os_print_char(ch);
	}

	return ch;
}
示例#3
0
int printf(char *fmt, ...)
{
	int i = 0;
	int printed = 0;
	char *arg = (char*)&fmt + sizeof(char*);
	char *str;

	if (fmt[0] == '\0') {
		return 0;
	}

	do {
		if (fmt[i] == '\n') {
			os_print_newline();
			printed += 2;
			continue;
		} else if (fmt[i] != '%') {
			os_print_char(fmt[i]);
			printed++;
			continue;
		}

		switch (fmt[++i]) {
			case 'd':
			case 'i':
				str = os_sint_to_string(*(int*)arg);
				printed += os_string_length(str);
				os_print_string(str);
				arg += sizeof(int);
				break;

			case 'u':
				str = os_int_to_string(*(int*)arg);
				printed += os_string_length(str);
				os_print_string(str);
				arg += sizeof(int);
				break;

			case 'x':
			case 'X':
				os_print_4hex(*(int*)arg);
				printed += 4;
				arg += sizeof(int);
				break;

			case 'c':
				os_print_char(*arg);
				printed++;
				arg += sizeof(int);
				break;

			case 's':
				str = *(char**)arg;
				printed += os_string_length(str);
				os_print_string(str);
				arg += sizeof(char*);
				break;

			case 'p':
				os_print_string("0x");
				os_print_4hex(*(int*)arg);
				printed += 6;
				arg += sizeof(int);
				break;

			case 'n':
				*(int*)arg = printed;
				arg += sizeof(int*);
				break;

			case '%':
				os_print_char('%');
				printed++;
				break;
		}

	} while (fmt[++i]);

	return printed;
}
示例#4
0
int puts(char *str)
{
	os_print_string(str);
	os_print_newline();
	return os_string_length(str);
}
示例#5
0
char *gets(char *str)
{
	os_input_string(str, 256);
	os_print_newline();
	return str;
}