コード例 #1
0
ファイル: jsio.c プロジェクト: atifs/juise
static int
js_buffer_read_data (js_session_t *jsp, char *bp, int blen)
{
    int rc;

    if (js_max && blen > js_max)
	blen = js_max;

    if (jsp->js_rbuf) {
	int rlen = jsp->js_rlen - jsp->js_off;

	rc = MIN(rlen, blen);
	memcpy(bp, jsp->js_rbuf + jsp->js_roff, rc);
	if (rc <= rlen) {
	    /* Done with js_rbuf */
	    free(jsp->js_rbuf);
	    jsp->js_rbuf = NULL;
	    jsp->js_rlen = jsp->js_roff = 0;
	} else {
	    jsp->js_roff += blen;
	}

    } else {
	rc = read(jsp->js_stdin, bp, blen);
	if ((jsio_flags & JSIO_MEMDUMP) && rc > 0)
	    slaxMemDump("jsio: read", bp, rc, ">", 0);
    }

    return rc;
}
コード例 #2
0
ファイル: channel.c プロジェクト: routelastresort/juise
static int
mx_channel_write (mx_channel_t *mcp, const char *buf, unsigned long bufsiz)
{
    int len;

    len = libssh2_channel_write(mcp->mc_channel, buf, bufsiz);

    DBG_POLL("C%u write %d", mcp->mc_id, len);
    if (len > 0)
	slaxMemDump("chwrite: ", buf, len, ">", 0);

    return len;
}
コード例 #3
0
ファイル: channel.c プロジェクト: routelastresort/juise
static int
mx_channel_read (mx_channel_t *mcp, char *buf, unsigned long bufsiz)
{
    int len;

    len = libssh2_channel_read(mcp->mc_channel, buf, bufsiz);

    DBG_POLL("C%u read %d", mcp->mc_id, len);
    if (len > 0) {
	slaxMemDump("chread: ", buf, len, ">", 0);
    } else {
	if (len == LIBSSH2_ERROR_SOCKET_RECV) {
	    if (mcp->mc_session)
		mcp->mc_session->mss_base.ms_state = MSS_FAILED;
	}
    }

    return len;
}