Changeset 566f4cfb in mainline for uspace/lib/libc/generic/io
- Timestamp:
- 2009-04-24T08:01:05Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 402de0c
- Parents:
- ab1861a
- Location:
- uspace/lib/libc/generic/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/io/io.c
rab1861a r566f4cfb 39 39 #include <string.h> 40 40 #include <errno.h> 41 #include <console.h> 41 42 42 43 const static char nl = '\n'; … … 50 51 51 52 for (count = 0; str[count] != 0; count++); 52 if (write_stdout((void *) str, count) == count) { 53 if (write_stdout(&nl, 1) == 1) 53 54 if (console_write((void *) str, count) == count) { 55 if (console_write(&nl, 1) == 1) 54 56 return 0; 55 57 } … … 65 67 int putnchars(const char *buf, size_t count) 66 68 { 67 if ( write_stdout((void *) buf, count) == count)69 if (console_write((void *) buf, count) == count) 68 70 return 0; 69 71 … … 82 84 83 85 for (count = 0; str[count] != 0; count++); 84 if ( write_stdout((void *) str, count) == count)86 if (console_write((void *) str, count) == count) 85 87 return 0; 86 88 … … 97 99 return EOF; 98 100 99 if ( write_stdout((void *) buf, offs) == offs)101 if (console_write((void *) buf, offs) == offs) 100 102 return c; 101 103 … … 106 108 { 107 109 unsigned char c; 108 109 flush_stdout();110 111 console_flush(); 110 112 if (read_stdin((void *) &c, 1) == 1) 111 113 return c; … … 116 118 int fflush(FILE *f) 117 119 { 120 /* Dummy implementation */ 118 121 (void) f; 119 return flush_stdout(); 122 console_flush(); 123 return 0; 120 124 } 121 125 -
uspace/lib/libc/generic/io/stream.c
rab1861a r566f4cfb 50 50 #include <sys/types.h> 51 51 52 ssize_t write_stderr(const void *buf, size_t count)53 {54 return count;55 }56 57 52 ssize_t read_stdin(void *buf, size_t count) 58 53 { 59 int cons_phone = console_ phone_get(false);60 54 int cons_phone = console_open(false); 55 61 56 if (cons_phone >= 0) { 62 57 kbd_event_t ev; 63 58 int rc; 64 59 size_t i = 0; 65 60 66 61 while (i < count) { 67 62 do { … … 69 64 if (rc < 0) return -1; 70 65 } while (ev.c == 0 || ev.type == KE_RELEASE); 71 66 72 67 ((char *) buf)[i++] = ev.c; 73 68 } 74 69 return i; 75 } else {70 } else 76 71 return -1; 77 }78 }79 80 ssize_t write_stdout(const void *buf, size_t count)81 {82 int cons_phone = console_phone_get(false);83 int left, rc;84 85 if (cons_phone >= 0) {86 int i;87 88 left = count;89 while (left > 0) {90 rc = console_write(buf, left);91 if (rc < 0)92 break;93 buf += rc;94 left -= rc;95 }96 97 return count;98 } else99 return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count);100 }101 102 int flush_stdout(void)103 {104 console_flush();105 return 0;106 72 } 107 73 -
uspace/lib/libc/generic/io/vprintf.c
rab1861a r566f4cfb 39 39 #include <futex.h> 40 40 #include <async.h> 41 #include <console.h> 41 42 42 43 static atomic_t printf_futex = FUTEX_INITIALIZER; … … 51 52 prev = offset; 52 53 str_decode(str, &offset, size); 53 write_stdout(str + prev, offset - prev);54 console_write(str + prev, offset - prev); 54 55 chars++; 55 56 } … … 68 69 boff = 0; 69 70 chr_encode(str[chars], buf, &boff, 4); 70 write_stdout(buf, boff);71 console_write(buf, boff); 71 72 chars++; 72 73 offset += sizeof(wchar_t);
Note:
See TracChangeset
for help on using the changeset viewer.