Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1519 → Rev 1518

/uspace/trunk/libc/generic/io/stream.c
39,7 → 39,6
#include <ipc/services.h>
#include <console.h>
#include <unistd.h>
#include <async.h>
 
#define FDS 32
 
47,12 → 46,12
pwritefn_t w;
preadfn_t r;
void * param;
int phone;
} stream_t;
 
static int console_phone = -1;
static stream_t streams[FDS] = {{0, 0, 0, -1}};
int console_phone = -1;
 
stream_t streams[FDS] = {{0, 0, 0}};
 
static ssize_t write_stderr(void *param, const void *buf, size_t count)
{
return count;
64,7 → 63,7
size_t i = 0;
 
while (i < count) {
if (sync_send_2(streams[0].phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1) < 0) {
if (ipc_call_sync_2(console_phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1) < 0) {
return -1;
}
((char *)buf)[i++] = r0;
78,7 → 77,7
ipcarg_t r0,r1;
 
for (i = 0; i < count; i++)
send_call(streams[1].phone, CONSOLE_PUTCHAR, ((const char *)buf)[i]);
send_call(console_phone, CONSOLE_PUTCHAR, ((const char *)buf)[i]);
return count;
}
99,8 → 98,6
stream.r = read_stdin;
stream.param = 0;
stream.phone = console_phone;
return stream;
}
 
108,7 → 105,7
{
stream_t stream;
int res;
 
if (console_phone < 0) {
while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
usleep(10000);
141,6 → 138,8
}
if (!strcmp(fname, "stdout")) {
//streams[c].w = write_stdout;
//return c;
streams[c] = open_stdout();
return c;
}
172,9 → 171,3
return 0;
}
 
int get_fd_phone(int fd)
{
if (fd >= FDS || fd < 0)
return -1;
return streams[fd].phone;
}