Subversion Repositories HelenOS-historic

Rev

Rev 1010 | Rev 1363 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1010 Rev 1173
Line 35... Line 35...
35
 
35
 
36
int puts(const char * str)
36
int puts(const char * str)
37
{
37
{
38
    size_t count;
38
    size_t count;
39
   
39
   
-
 
40
    if (str == NULL) {
-
 
41
        return putnchars("(NULL)",6 );
-
 
42
    }
-
 
43
   
40
    for (count = 0; str[count] != 0; count++);
44
    for (count = 0; str[count] != 0; count++);
41
    if (write(1, (void * ) str, count) == count) {
45
    if (write(1, (void * ) str, count) == count) {
42
        if (write(1, &nl, 1) == 1)
46
        if (write(1, &nl, 1) == 1)
43
            return 0;
47
            return 0;
44
    }
48
    }
45
   
49
   
46
    return EOF;
50
    return EOF;
47
}
51
}
48
 
52
 
49
/** Put count chars from buffer to stdout without adding newline
53
/** Put count chars from buffer to stdout without adding newline
50
 * @param buf Buffer with size at least count bytes
54
 * @param buf Buffer with size at least count bytes - NULL pointer NOT allowed!
51
 * @param count
55
 * @param count
52
 * @return 0 on succes, EOF on fail
56
 * @return 0 on succes, EOF on fail
53
 */
57
 */
54
int putnchars(const char * buf, size_t count)
58
int putnchars(const char * buf, size_t count)
55
{
59
{
Line 77... Line 81...
77
    }
81
    }
78
   
82
   
79
    return EOF;
83
    return EOF;
80
}
84
}
81
 
85
 
-
 
86
int putchar(int c)
-
 
87
{
-
 
88
    unsigned char ch = c;
-
 
89
    if (write(1, (void *)&ch , 1) == 1) {
-
 
90
            return c;
-
 
91
    }
-
 
92
   
-
 
93
    return EOF;
-
 
94
}
-
 
95
 
82
ssize_t write(int fd, const void * buf, size_t count)
96
ssize_t write(int fd, const void * buf, size_t count)
83
{
97
{
84
    return (ssize_t) __SYSCALL3(SYS_IO, (sysarg_t) fd, (sysarg_t) buf, (sysarg_t) count);
98
    return (ssize_t) __SYSCALL3(SYS_IO, (sysarg_t) fd, (sysarg_t) buf, (sysarg_t) count);
85
}
99
}
86
 
100