Changeset b917098 in mainline for libc/generic/io/stream.c


Ignore:
Timestamp:
2006-06-02T16:33:42Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a805c24
Parents:
b1f51f0
Message:

Slowly porting tetris screen… not yet done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/io/stream.c

    rb1f51f0 rb917098  
    4040#include <console.h>
    4141#include <unistd.h>
     42#include <async.h>
    4243
    4344#define FDS 32
     
    4748        preadfn_t r;
    4849        void * param;
     50        int phone;
    4951} stream_t;
    5052
    51 int console_phone = -1;
    52 
    53 stream_t streams[FDS] = {{0, 0, 0}};
     53static int console_phone = -1;
     54static stream_t streams[FDS] = {{0, 0, 0, -1}};
    5455
    5556static ssize_t write_stderr(void *param, const void *buf, size_t count)
     
    6465
    6566        while (i < count) {
    66                 if (ipc_call_sync_2(console_phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1) < 0) {
     67                if (sync_send_2(streams[0].phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1) < 0) {
    6768                        return -1;
    6869                }
     
    7879
    7980        for (i = 0; i < count; i++)
    80                 send_call(console_phone, CONSOLE_PUTCHAR, ((const char *)buf)[i]);
     81                send_call(streams[1].phone, CONSOLE_PUTCHAR, ((const char *)buf)[i]);
    8182       
    8283        return count;
     
    99100        stream.r = read_stdin;
    100101        stream.param = 0;
     102        stream.phone = console_phone;
     103       
    101104        return stream;
    102105}
     
    106109        stream_t stream;
    107110        int res;
    108        
     111
    109112        if (console_phone < 0) {
    110113                while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
     
    139142       
    140143        if (!strcmp(fname, "stdout")) {
    141                 //streams[c].w = write_stdout;
    142                 //return c;
    143144                streams[c] = open_stdout();
    144145                return c;
     
    172173}
    173174
     175int get_fd_phone(int fd)
     176{
     177        if (fd >= FDS || fd < 0)
     178                return -1;
     179        return streams[fd].phone;
     180}
Note: See TracChangeset for help on using the changeset viewer.