From 17a856577f9db766b8ef7099d0575d378dff5dd1 Mon Sep 17 00:00:00 2001 From: rtm Date: Fri, 11 Aug 2006 13:55:18 +0000 Subject: init creates console, opens 0/1/2, runs sh sh accepts 0-argument commands (like userfs) reads from console --- ulib.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'ulib.c') diff --git a/ulib.c b/ulib.c index d7e8934..ccb9fd6 100644 --- a/ulib.c +++ b/ulib.c @@ -3,17 +3,7 @@ int puts(char *s) { - return cons_puts(s); -} - -int -puts1(char *s) -{ - int i; - - for(i = 0; s[i]; i++) - cons_putc(s[i]); - return i; + return write(1, s, strlen(s)); } char* @@ -26,3 +16,30 @@ strcpy(char *s, char *t) ; return os; } + +unsigned int +strlen(char *s) +{ + int n = 0; + for(n = 0; s[n]; n++) + ; + return n; +} + +char * +gets(char *buf, int max) +{ + int i = 0, cc; + char c; + + while(i+1 < max){ + cc = read(0, &c, 1); + if(cc < 1) + break; + if(c == '\n' || c == '\r') + break; + buf[i++] = c; + } + buf[i] = '\0'; + return buf; +} -- cgit v1.2.3