2006-07-16 15:36:31 +00:00
|
|
|
#include "user.h"
|
|
|
|
|
2006-06-27 14:35:53 +00:00
|
|
|
int
|
|
|
|
puts(char *s)
|
2006-07-16 15:36:31 +00:00
|
|
|
{
|
2006-08-11 13:55:18 +00:00
|
|
|
return write(1, s, strlen(s));
|
2006-06-27 14:35:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-16 16:00:03 +00:00
|
|
|
char*
|
|
|
|
strcpy(char *s, char *t)
|
|
|
|
{
|
|
|
|
char *os;
|
|
|
|
|
|
|
|
os = s;
|
|
|
|
while((*s++ = *t++) != 0)
|
|
|
|
;
|
|
|
|
return os;
|
|
|
|
}
|
2006-08-11 13:55:18 +00:00
|
|
|
|
|
|
|
unsigned int
|
|
|
|
strlen(char *s)
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
for(n = 0; s[n]; n++)
|
|
|
|
;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2006-08-12 11:38:57 +00:00
|
|
|
void *
|
|
|
|
memset(void *dst, int c, unsigned int n)
|
|
|
|
{
|
|
|
|
char *d = (char *) dst;
|
|
|
|
|
|
|
|
while(n-- > 0)
|
|
|
|
*d++ = c;
|
|
|
|
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2006-08-11 13:55:18 +00:00
|
|
|
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;
|
|
|
|
}
|