コード例 #1
0
ファイル: ssh.c プロジェクト: Pating/qemu-colo
static coroutine_fn int ssh_co_writev(BlockDriverState *bs,
                                      int64_t sector_num,
                                      int nb_sectors, QEMUIOVector *qiov)
{
    BDRVSSHState *s = bs->opaque;
    int ret;

    qemu_co_mutex_lock(&s->lock);
    ret = ssh_write(s, bs, sector_num * BDRV_SECTOR_SIZE,
                    nb_sectors * BDRV_SECTOR_SIZE, qiov);
    qemu_co_mutex_unlock(&s->lock);

    return ret;
}
コード例 #2
0
ファイル: newio.c プロジェクト: zhouqt/kbs
void oflush()
{
    if (obufsize) {
        if (convcode) {
            char *out;

            out = gb2big(outbuf, &obufsize, 0, getSession());
#ifdef SSHBBS
            if (ssh_write(0, out, obufsize) < 0)
#else
            if (write(0, out, obufsize) < 0)
#endif
                abort_bbs(0);
        } else
#ifdef SSHBBS
            if (ssh_write(0, outbuf, obufsize) < 0)
#else
            if (write(0, outbuf, obufsize) < 0)
#endif
                abort_bbs(0);
    }
    obufsize = 0;
}
コード例 #3
0
ファイル: newio.c プロジェクト: zhouqt/kbs
int raw_write(int fd,const char *buf, int len)
{
    static int lastcounter = 0;
    int nowcounter;
    static int bufcounter;
#ifndef SSHBBS
    int i, retlen=0;
#endif

#ifdef ZMODEM_RATE
    nowcounter = time(0);
    if (lastcounter == nowcounter) {
        if (bufcounter >= ZMODEM_RATE) {
            sleep(1);
            nowcounter = time(0);
            bufcounter = len;
        } else
            bufcounter += len;
    } else {
        /*
         * time clocked, clear bufcounter
         */
        bufcounter = len;
    }
    lastcounter = nowcounter;
#endif
#ifdef SSHBBS
    return ssh_write(fd, buf, len);
#else
    for (i = 0; i < len; i++) {
        int mylen;

        if ((unsigned char) buf[i] == 0xff)
            mylen = write(fd, "\xff\xff", 2);
        else if (buf[i] == 13)
            mylen = write(fd, "\x0d\x00", 2);
        else
            mylen = write(fd, &buf[i], 1);
        if (mylen < 0)
            break;
        retlen += mylen;
    }
    return retlen;
#endif
}