Subversion Repositories HelenOS

Rev

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

Rev 2479 Rev 2495
Line 63... Line 63...
63
    return count;
63
    return count;
64
}
64
}
65
 
65
 
66
static ssize_t read_stdin(void *param, void *buf, size_t count)
66
static ssize_t read_stdin(void *param, void *buf, size_t count)
67
{
67
{
68
    ipcarg_t r0,r1;
68
    ipcarg_t r0, r1;
69
    size_t i = 0;
69
    size_t i = 0;
70
 
70
 
71
    while (i < count) {
71
    while (i < count) {
72
        if (async_req_2(streams[0].phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1) < 0) {
72
        if (async_req_2(streams[0].phone, CONSOLE_GETCHAR, 0, 0, &r0,
-
 
73
            &r1) < 0) {
73
            return -1;
74
            return -1;
74
        }
75
        }
75
        ((char *) buf)[i++] = r0;
76
        ((char *) buf)[i++] = r0;
76
    }
77
    }
77
    return i;
78
    return i;
Line 80... Line 81...
80
static ssize_t write_stdout(void *param, const void *buf, size_t count)
81
static ssize_t write_stdout(void *param, const void *buf, size_t count)
81
{
82
{
82
    int i;
83
    int i;
83
 
84
 
84
    for (i = 0; i < count; i++)
85
    for (i = 0; i < count; i++)
85
        async_msg(streams[1].phone, CONSOLE_PUTCHAR, ((const char *) buf)[i]);
86
        async_msg(streams[1].phone, CONSOLE_PUTCHAR,
-
 
87
            ((const char *) buf)[i]);
86
   
88
   
87
    return count;
89
    return count;
88
}
90
}
89
 
91
 
90
static stream_t open_stdin(void)
92
static stream_t open_stdin(void)
91
{
93
{
92
    stream_t stream;
94
    stream_t stream;
93
   
95
   
94
    if (console_phone < 0) {
96
    if (console_phone < 0) {
95
        while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
97
        while ((console_phone = ipc_connect_me_to(PHONE_NS,
-
 
98
            SERVICE_CONSOLE, 0)) < 0) {
96
            usleep(10000);
99
            usleep(10000);
97
        }
100
        }
98
    }
101
    }
99
   
102
   
100
    stream.r = read_stdin;
103
    stream.r = read_stdin;
Line 108... Line 111...
108
static stream_t open_stdout(void)
111
static stream_t open_stdout(void)
109
{
112
{
110
    stream_t stream;
113
    stream_t stream;
111
 
114
 
112
    if (console_phone < 0) {
115
    if (console_phone < 0) {
113
        while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
116
        while ((console_phone = ipc_connect_me_to(PHONE_NS,
-
 
117
            SERVICE_CONSOLE, 0)) < 0) {
114
            usleep(10000);
118
            usleep(10000);
115
        }
119
        }
116
    }
120
    }
117
   
121
   
118
    stream.r = NULL;
122
    stream.r = NULL;