void printf(const char *str, ...) { va_list arglist; va_start(arglist, str); int p = 0; while (str[p] != NULL) { if (str[p] == '%') { const char nextone = str[p + 1]; if (nextone == '%') { terminal_putchar('%'); } else if (nextone == 's') { terminal_putstring(va_arg(arglist, const char*)); } else if (nextone == 'd') { // As of right now, we have no method of dynamic allocation, and thus must unfortunately have an array of considerable size and hope it's enough. //But I think 128 digits is plenty for now, considering that a number that is 64 bits long can only go as far as 20 digits! char theletters[128]; if (itoa(va_arg(arglist, int), 10, theletters)) { terminal_putstring(theletters); }; } else if (nextone == 'b') { char theletters[128]; if (itoa(va_arg(arglist, int), 2, theletters)) { terminal_putstring(theletters); }; }
void Alo_Main(multiboot_data *multibootdata) { HAL_init(multibootdata); terminal_putstring("Hello to Alo 2!\n"); terminal_putstring(" Just testing newlines....\n"); terminal_printf("-13 when put through itoa is: %d.", -13); terminal_printf("My name is %s.", "Alex"); terminal_printf("Today is %s %d, %d. It is a %s. It is %d:%d:%d military time.", GetMonth(), GetDayInMonth(), GetYear(), GetWeekDay(), GetHour(), GetMinute(), GetSecond()); /*testtimer.limit = 100; testtimer.func = OneSecondHandler; secondtimer.limit = 200; secondtimer.func = TheResponse; Timer_Register_Timer(&testtimer); Timer_Register_Timer(&secondtimer); */ /* int test = 8/(6 - (3 * 2)); */ };