예제 #1
0
/*
 * pqPutnchar:
 *	write exactly len bytes to the current message
 */
int
pqPutnchar(const char *s, size_t len, PGconn *conn)
{
	if (pqPutMsgBytes(s, len, conn))
		return EOF;

	if (conn->Pfdebug)
	{
		fprintf(conn->Pfdebug, "To backend> ");
		fputnbytes(conn->Pfdebug, s, len);
		fprintf(conn->Pfdebug, "\n");
	}

	return 0;
}
예제 #2
0
파일: fe-misc.c 프로젝트: no0p/postgres
/*
 * pqSkipnchar:
 *	skip over len bytes in input buffer.
 *
 * Note: this is primarily useful for its debug output, which should
 * be exactly the same as for pqGetnchar.  We assume the data in question
 * will actually be used, but just isn't getting copied anywhere as yet.
 */
int
pqSkipnchar(size_t len, PGconn *conn)
{
    if (len > (size_t) (conn->inEnd - conn->inCursor))
        return EOF;

    if (conn->Pfdebug)
    {
        fprintf(conn->Pfdebug, "From backend (%lu)> ", (unsigned long) len);
        fputnbytes(conn->Pfdebug, conn->inBuffer + conn->inCursor, len);
        fprintf(conn->Pfdebug, "\n");
    }

    conn->inCursor += len;

    return 0;
}
예제 #3
0
/*
 * pqGetnchar:
 *	get a string of exactly len bytes in buffer s, no null termination
 */
int
pqGetnchar(char *s, size_t len, PGconn *conn)
{
	if (len > (size_t) (conn->inEnd - conn->inCursor))
		return EOF;

	memcpy(s, conn->inBuffer + conn->inCursor, len);
	/* no terminating null */

	conn->inCursor += len;

	if (conn->Pfdebug)
	{
		fprintf(conn->Pfdebug, "From backend (%lu)> ", (unsigned long) len);
		fputnbytes(conn->Pfdebug, s, len);
		fprintf(conn->Pfdebug, "\n");
	}

	return 0;
}