/* See the copyright notice (COPYRIGHT) in this directory. */

/*
 * NAME
 *	pg_print_conn()
 *
 * DESCRIPTION
 *	Output dbConn contents.
 *
 * DIAGNOSTICS
 *	Returns GDI_NOCONNECT or GDI_SUCCESS.
 *
 * FILES
 *	pg_print.c (this file)
 *
 * AUTHOR
 *	Jean T. Anderson, SAIC Open Systems Division
 */

#ifndef	lint
static char SccsId[] = "@(#)pg_print.c	16.1 8/3/93 Copyright (c) 1992-1993 Science Applications International Corporation";
#endif

#include "gdi_postgres.h"

/*
 * pg_print_conn ()
 *
 * Print the contents of a Postgres database connector to stdout.
 *
 * Public
 */

dbStatus
pg_print_conn (conn)
dbConn	*conn;
{
	int	i;

	if ((conn == NULL) || (conn->vendor_conn == NULL))
		return (gdi_warning_app (conn, GDI_NOCONNECT,
			"pg_print_conn: Not connected to database"));

	fprintf (stdout, "POSTGRES CONNECTOR = 0x%p\n", conn->vendor_conn);

	fprintf (stdout, "\n");

/*	fprintf (stdout, "\tsession_id = %d,\n", (int) PG_SESSION_ID (conn)); */

	fprintf (stdout, "\terr_log   = '%s',\n", PG_ERROR_LOG (conn));
	fprintf (stdout, "\terr_type   = '%c',\n", PG_ERROR_TYPE (conn));
	fprintf (stdout, "\terr_text   = '%s',\n", PG_ERROR_MSG (conn));
	fprintf (stdout, "\ttr_state   = '%d',\n", PG_TRAN (conn));

/*
 *	fprintf (stdout, "\ttemp_tables = {");
 *	for (p = PG_TEMP_TABLES (conn); p != NULL; p = p->next_t)
 *		fprintf (stdout, "'%s', ", p->name);
 *	fprintf (stdout, "NULL}\n");
 */

	fprintf (stdout, "\tnum_channels = %d,\n",(int) PG_NUM_CHANNELS (conn));

	for (i = 0; i < PG_NUM_CHANNELS (conn); i++)
	{
		fprintf(stdout, "\tnumber=%d\t", PG_PORT_NUM(conn, i) );
		fprintf(stdout, "\tname='%s'\n", PG_PORT_NAME(conn, i) );
	}

	fflush (stdout);
     
	return (GDI_SUCCESS);
}
