summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJake Mannens <jake72360@gmail.com>2018-08-01 02:27:57 +1000
committerJake Mannens <jake72360@gmail.com>2018-08-01 02:27:57 +1000
commit8e933fac9fd068343bb602f13175c8d70a6c5768 (patch)
tree2d0c2ef1c1165d701d94617986e80c7598d0fc4d /lib
parent7babda5d4573d432441a416f880cb8cc8c15b55b (diff)
Defined EOF as -1 in stdio.h.
Implemented the sprintf() library function in lib/stdio.c which uses the vsprintf() function. Implemented a very primative controlling TTY for each process. This is achieved by a switch in the sys_puts system call which uses the 'ctty' element of the process' task structure to determine an appropriate I/O channel. A negative ctty value doesn't equate to any I/O channel effectively disabling the process' output. Added the sys_ctty system call which allows a process to set it's own ctty value. Removed the sys_rsputs system call. Output to serial is now performed by the process first setting it's ctty value to 1, then invoking sys_puts.
Diffstat (limited to 'lib')
-rw-r--r--lib/stdio.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/stdio.c b/lib/stdio.c
index a718ee4..67f0a54 100644
--- a/lib/stdio.c
+++ b/lib/stdio.c
@@ -3,7 +3,7 @@
#include <unistd.h>
_syscall1(int, puts, char*, s);
-_syscall1(int, rsputs, char*, s);
+_syscall1(int, ctty, int, ctty);
int printf(char *fmt, ...) {
int ret;
@@ -18,15 +18,13 @@ int printf(char *fmt, ...) {
return ret;
}
-int rsprintf(char *fmt, ...) {
+int sprintf(char *str, char *fmt, ...) {
int ret;
- char buf[1024];
va_list ap;
va_start(ap, fmt);
- ret = vsprintf(buf, fmt, ap);
+ ret = vsprintf(str, fmt, ap);
va_end(ap);
- rsputs(buf);
return ret;
}