Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c8211849 in mainline


Ignore:
Timestamp:
2017-12-08T21:03:35Z (4 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
a99cbc1e
Parents:
c19a5a59
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-07 23:08:49)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:03:35)
Message:

Return number of characters separately from error code in console IO.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/con_srv.c

    rc19a5a59 rc8211849  
    9393        }
    9494
    95         rc = srv->srvs->ops->read(srv, buf, size);
    96         if (rc < 0) {
     95        size_t nread;
     96        rc = srv->srvs->ops->read(srv, buf, size, &nread);
     97        if (rc != EOK) {
    9798                async_answer_0(rcallid, rc);
    9899                async_answer_0(callid, rc);
     
    101102        }
    102103
    103         async_data_read_finalize(rcallid, buf, size);
     104        async_data_read_finalize(rcallid, buf, nread);
    104105        free(buf);
    105106
    106         if (rc >= 0)
    107                 async_answer_1(callid, EOK, rc);
    108         else
    109                 async_answer_0(callid, rc);
     107        async_answer_1(callid, EOK, nread);
    110108}
    111109
     
    128126        }
    129127
    130         rc = srv->srvs->ops->write(srv, data, size);
     128        size_t nwritten = 0;
     129        rc = srv->srvs->ops->write(srv, data, size, &nwritten);
    131130        free(data);
    132131
    133         if (rc >= 0)
    134                 async_answer_1(callid, EOK, rc);
    135         else
    136                 async_answer_0(callid, rc);
     132        async_answer_1(callid, rc, nwritten);
    137133}
    138134
  • uspace/lib/c/include/io/con_srv.h

    rc19a5a59 rc8211849  
    6969        int (*open)(con_srvs_t *, con_srv_t *);
    7070        int (*close)(con_srv_t *);
    71         int (*read)(con_srv_t *, void *, size_t);
    72         int (*write)(con_srv_t *, void *, size_t);
     71        int (*read)(con_srv_t *, void *, size_t, size_t *);
     72        int (*write)(con_srv_t *, void *, size_t, size_t *);
    7373        void (*sync)(con_srv_t *);
    7474        void (*clear)(con_srv_t *);
  • uspace/lib/gui/terminal.c

    rc19a5a59 rc8211849  
    6464static int term_open(con_srvs_t *, con_srv_t *);
    6565static int term_close(con_srv_t *);
    66 static int term_read(con_srv_t *, void *, size_t);
    67 static int term_write(con_srv_t *, void *, size_t);
     66static int term_read(con_srv_t *, void *, size_t, size_t *);
     67static int term_write(con_srv_t *, void *, size_t, size_t *);
    6868static void term_sync(con_srv_t *);
    6969static void term_clear(con_srv_t *);
     
    386386}
    387387
    388 static int term_read(con_srv_t *srv, void *buf, size_t size)
     388static int term_read(con_srv_t *srv, void *buf, size_t size, size_t *nread)
    389389{
    390390        terminal_t *term = srv_to_terminal(srv);
     
    431431        }
    432432       
    433         return size;
     433        *nread = size;
     434        return EOK;
    434435}
    435436
     
    462463}
    463464
    464 static int term_write(con_srv_t *srv, void *data, size_t size)
     465static int term_write(con_srv_t *srv, void *data, size_t size, size_t *nwritten)
    465466{
    466467        terminal_t *term = srv_to_terminal(srv);
     
    470471                term_write_char(term, str_decode(data, &off, size));
    471472       
    472         return size;
     473        *nwritten = size;
     474        return EOK;
    473475}
    474476
  • uspace/srv/hid/console/console.c

    rc19a5a59 rc8211849  
    119119static int cons_open(con_srvs_t *, con_srv_t *);
    120120static int cons_close(con_srv_t *);
    121 static int cons_read(con_srv_t *, void *, size_t);
    122 static int cons_write(con_srv_t *, void *, size_t);
     121static int cons_read(con_srv_t *, void *, size_t, size_t *);
     122static int cons_write(con_srv_t *, void *, size_t, size_t *);
    123123static void cons_sync(con_srv_t *);
    124124static void cons_clear(con_srv_t *);
     
    338338}
    339339
    340 static int cons_read(con_srv_t *srv, void *buf, size_t size)
     340static int cons_read(con_srv_t *srv, void *buf, size_t size, size_t *nread)
    341341{
    342342        uint8_t *bbuf = buf;
     
    378378        }
    379379       
    380         return size;
    381 }
    382 
    383 static int cons_write(con_srv_t *srv, void *data, size_t size)
     380        *nread = size;
     381        return EOK;
     382}
     383
     384static int cons_write(con_srv_t *srv, void *data, size_t size, size_t *nwritten)
    384385{
    385386        console_t *cons = srv_to_console(srv);
     
    389390                cons_write_char(cons, str_decode(data, &off, size));
    390391       
    391         return size;
     392        *nwritten = size;
     393        return EOK;
    392394}
    393395
  • uspace/srv/hid/remcons/remcons.c

    rc19a5a59 rc8211849  
    7272static int remcons_open(con_srvs_t *, con_srv_t *);
    7373static int remcons_close(con_srv_t *);
    74 static int remcons_write(con_srv_t *, void *, size_t);
     74static int remcons_write(con_srv_t *, void *, size_t, size_t *);
    7575static void remcons_sync(con_srv_t *);
    7676static void remcons_clear(con_srv_t *);
     
    137137}
    138138
    139 static int remcons_write(con_srv_t *srv, void *data, size_t size)
     139static int remcons_write(con_srv_t *srv, void *data, size_t size, size_t *nwritten)
    140140{
    141141        telnet_user_t *user = srv_to_user(srv);
     
    146146                return rc;
    147147
    148         return size;
     148        *nwritten = size;
     149        return EOK;
    149150}
    150151
Note: See TracChangeset for help on using the changeset viewer.