37,18 → 37,17 |
#include <stdio.h> |
#include <io/io.h> |
|
static char nl = '\n'; |
const static char nl = '\n'; |
|
int puts(const char * str) |
int puts(const char *str) |
{ |
size_t count; |
|
if (str == NULL) { |
return putnchars("(NULL)",6 ); |
} |
if (str == NULL) |
return putnchars("(NULL)", 6); |
|
for (count = 0; str[count] != 0; count++); |
if (write(1, (void * ) str, count) == count) { |
if (write(1, (void *) str, count) == count) { |
if (write(1, &nl, 1) == 1) |
return 0; |
} |
61,11 → 60,10 |
* @param count |
* @return 0 on succes, EOF on fail |
*/ |
int putnchars(const char * buf, size_t count) |
int putnchars(const char *buf, size_t count) |
{ |
if (write(1, (void * ) buf, count) == count) { |
if (write(1, (void *) buf, count) == count) |
return 0; |
} |
|
return EOF; |
} |
73,18 → 71,16 |
/** Same as puts, but does not print newline at end |
* |
*/ |
int putstr(const char * str) |
int putstr(const char *str) |
{ |
size_t count; |
|
if (str == NULL) { |
return putnchars("(NULL)",6 ); |
} |
if (str == NULL) |
return putnchars("(NULL)", 6); |
|
for (count = 0; str[count] != 0; count++); |
if (write(1, (void * ) str, count) == count) { |
if (write(1, (void *) str, count) == count) |
return 0; |
} |
|
return EOF; |
} |
92,9 → 88,8 |
int putchar(int c) |
{ |
unsigned char ch = c; |
if (write(1, (void *)&ch , 1) == 1) { |
if (write(1, (void *) &ch, 1) == 1) |
return c; |
} |
|
return EOF; |
} |
102,9 → 97,8 |
int getchar(void) |
{ |
unsigned char c; |
if (read(0, (void *)&c , 1) == 1) { |
if (read(0, (void *) &c, 1) == 1) |
return c; |
} |
|
return EOF; |
} |