forked from xolatile/xhartae
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
/*
|
|
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
|
|
|
|
Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
|
|
And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
|
|
It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
|
|
*/
|
|
|
|
#ifndef CHAPTER_3_SOURCE
|
|
#define CHAPTER_3_SOURCE
|
|
|
|
#include "chapter_3.h"
|
|
|
|
void print (char * format, ...) {
|
|
va_list argument_array;
|
|
|
|
int offset, length;
|
|
|
|
int integer;
|
|
char * string;
|
|
double ieee754;
|
|
|
|
length = string_length (format);
|
|
|
|
va_start (argument_array, format);
|
|
|
|
for (offset = 0; offset != length; ++offset) {
|
|
if (format [offset] == '%') {
|
|
++offset;
|
|
if (format [offset] == '%') {
|
|
out ("%", 1);
|
|
} else if (format [offset] == 'i') {
|
|
integer = va_arg (argument_array, int);
|
|
echo (number_to_string (integer));
|
|
} else if (format [offset] == 'F') {
|
|
ieee754 = va_arg (argument_array, double);
|
|
echo (number_to_string ((int) ieee754));
|
|
} else if (format [offset] == 's') {
|
|
string = va_arg (argument_array, char *);
|
|
echo (string);
|
|
} else {
|
|
out ("?", 1);
|
|
}
|
|
} else if (format [offset] == '/') {
|
|
++offset;
|
|
if (format [offset] == '/') {
|
|
out ("/", 1);
|
|
}
|
|
} else {
|
|
out (& format [offset], 1);
|
|
}
|
|
}
|
|
|
|
va_end (argument_array);
|
|
}
|
|
|
|
void file_print (char * format, ...) {
|
|
(void) format;
|
|
return;
|
|
}
|
|
|
|
void string_print (char * format, ...) {
|
|
(void) format;
|
|
return;
|
|
}
|
|
|
|
#endif
|