Poem.c generated source file

/*
** Title:          Poem.c
** SCCSid:         dbdktxa.ide, dbdk_tut, v11.10.UC1 07/07/05 10:31:18
** CCid:           dbdktxa.ide, dbdk_tut, v11.10.UC1 07/07/05 10:31:18
** Author:         
** Created:        05/18/1999 20:14
** Description:    This is a generated source file for the Poem DataBlade module.
** Comments:       Generated for project Poem.1.0
*/

/*
**  The following is placed here to insure
**  that name "mangling" does not occur.
*/
#ifdef __cplusplus

extern "C"
{

#endif

/* Standard library includes. */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>

/* Used by Informix GLS routines. */
#include <ifxgls.h>

/* Include when accessing the Informix API. */
#include <mi.h>

/* This is the project include file. */
#include "Poem.h"

/* {{FUNCTION(92e262ad-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemAssign
**
** Description:
**
**	This function is called when rows are inserted into the a table.
**	You can provide special handling for the Poem type here.

**	Since the Poem type contains an MI_LO_HANDLE attribute, code is
**	supplied here to maintain its reference count.  This insures
**	that the large object is not dropped while a record in the
**	database stores a pointer to it.
**
**	The assign and destroy functions must be present if the input
**	or output functions are used.  Missing this function will cause
**	SmartBlob error 12059.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns Poem.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	Poem *                            The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemAssign FunctionId: 92e262ad-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
Poem *
PoemAssign
(
Poem *                  Gen_param1,      /* The UDT value.                   */
MI_FPARAM *             Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.          */
	Poem *               Gen_InData;      /* The input UDT value.             */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemAssign."
		*/
		DBDK_TRACE_ERROR( "PoemAssign", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* If the LO is valid ... */
	if( mi_lo_validate( Gen_Con, &Gen_InData->poem ) == 0 )
	{
		/* ... increment its reference count. */
		mi_lo_increfcount( Gen_Con, &Gen_InData->poem );
	}
	
	/* Close the connection. */
	mi_close( Gen_Con );

	return Gen_InData;
}
/* }}FUNCTION (#OILD) */



/* {{FUNCTION(92e262ae-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemDestroy
**
** Description:
**
**	This function is called when rows are removed from the a table.
**	You can provide special handling for the Poem type here.

**	Since the Poem type contains a MI_LO_HANDLE attribute, code is
**	supplied here to maintain its reference count.  This insures
**	that the large object is not dropped while a record in the
**	database stores a pointer to it.
**
**	The assign and destroy functions must be present if the input
**	or output functions are used.  Missing this function will cause
**	SmartBlob error 12059.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns void.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemDestroy FunctionId: 92e262ae-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
void
PoemDestroy
(
Poem *                 Gen_param1,      /* The UDT value.                   */
MI_FPARAM *            Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.         */
	Poem *               Gen_InData;      /* The input UDT value.            */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemDestroy."
		*/
		DBDK_TRACE_ERROR( "PoemDestroy", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* If the LO is valid ... */
	if( mi_lo_validate( Gen_Con, &Gen_InData->poem ) == 0 )
	{
		/* ... decrement its reference count. */
		mi_lo_decrefcount( Gen_Con, &Gen_InData->poem );
	}
	
	/* Close the connection. */
	mi_close( Gen_Con );
}
/* }}FUNCTION (#B9TQ) */



/* {{FUNCTION(92e262a7-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemSend
**
** Description:
**
**	The binary send function is used to convert an instance of a
**	data type between its internal representation on the server and
**	on the client.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns mi_sendrecv.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_sendrecv *                     The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemSend FunctionId: 92e262a7-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_sendrecv *
PoemSend
(
Poem *                  Gen_param1,      /* The UDT value                    */
MI_FPARAM *             Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.          */
	Poem *               Gen_InData;      /* Pointer to the UDT value.        */
	Poem *               Gen_OutData;     /* Pointer to the packet data.      */
	mi_sendrecv *        Gen_RetVal;      /* The return value.                */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemSend."
		*/
		DBDK_TRACE_ERROR( "PoemSend", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* Allocate a new return value. */
	Gen_RetVal = (mi_sendrecv *)mi_new_var( sizeof( Poem ) );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemSend."
		*/
		DBDK_TRACE_ERROR( "PoemSend", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = (Poem *)mi_get_vardata( (mi_lvarchar *)Gen_RetVal );

	/* Prepare the value for Gen_OutData->poem. */
	mi_put_bytes( (mi_unsigned_char1 *)&Gen_OutData->poem, (char *) 
         &Gen_InData->poem, DBDK_LOHSIZE );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the UDT for transmission. */
	return Gen_RetVal;
}
/* }}FUNCTION (#C11M) */



/* {{FUNCTION(92e262a8-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemReceive
**
** Description:
**
**	The binary receive function is used to convert an instance of a
**	data type between its internal representation on the server and
**	on the client.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns Poem.
**
** Parameters:
**
**	mi_lvarchar *      Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	Poem *                            The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemReceive FunctionId: 92e262a8-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
Poem *
PoemReceive
(
mi_sendrecv *          Gen_param1,      /* The UDT value.                   */
MI_FPARAM *            Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.          */
	Poem *               Gen_RetVal;      /* The return value.                */
	Poem *               Gen_InData;      /* Packet data.                     */
	Poem *               Gen_OutData;     /* Output UDT value.                */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemReceive."
		*/
		DBDK_TRACE_ERROR( "PoemReceive", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = (Poem *)mi_get_vardata( (mi_lvarchar *)Gen_param1 );


	/* Allocate room for the UDT. */
	Gen_RetVal = (Poem *)mi_alloc( sizeof( Poem ) );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemReceive."
		*/
		DBDK_TRACE_ERROR( "PoemReceive", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = (Poem *)Gen_RetVal;

	/* Copy the attribute value(s) from the transmission parcel. */

	/* Prepare the value for Gen_OutData->poem. */
	mi_get_bytes( (mi_unsigned_char1 *)&Gen_InData->poem, (char *) 
        &Gen_OutData->poem, DBDK_LOHSIZE );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the transmitted UDT value. */
	return Gen_RetVal;
}
/* }}FUNCTION (#B7UE) */



/* {{FUNCTION(92e262aa-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemImportBinary
**
** Description:
**
**	The  importbinary  function is  used to  support  bulk copy of
**	binary data. This function is the same as the import function,
**	except that it  operates  on internal  representations of  the
**	data type.  This function is  usually only  provided for large
**	object  data types and is called by the LOAD BINARY command of
**	dbaccess.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns Poem.
**
** Parameters:
**
**	mi_bitvarying *    Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	Poem *                            The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemImportBinary FunctionId: 92e262aa-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
Poem *
PoemImportBinary
(
mi_bitvarying *         Gen_param1,      /* The input value.                 */
MI_FPARAM *             Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.          */
	Poem *               Gen_RetVal;      /* The return result.               */
	Poem *               Gen_InData;      /* The UDT input value.             */
	Poem *               Gen_OutData;     /* The transfer data.               */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemImportBinary."
		*/
		DBDK_TRACE_ERROR( "PoemImportBinary", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = (Poem *)mi_get_vardata( (mi_lvarchar *)Gen_param1 );

	/* Allocate a new UDT for the return result. */
	Gen_RetVal = (Poem *)mi_alloc( sizeof( Poem ) );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemImportBinary."
		*/
		DBDK_TRACE_ERROR( "PoemImportBinary", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = (Poem *)Gen_RetVal;

	/* Prepare the value for Gen_OutData->poem. */
	mi_get_bytes( (mi_unsigned_char1 *)&Gen_InData->poem, (char *) 
       &Gen_OutData->poem, DBDK_LOHSIZE );

	/* Close the connection. */
	mi_close( Gen_Con );

	return Gen_RetVal;
}
/* }}FUNCTION (#4N64) */



/* {{FUNCTION(92e262a9-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemExportBinary
**
** Description:
**
**	The  exportbinary  function  is  used  to  support  bulk  copy  of
**	binary  data.  This function is the same as  the export  function,
**	except that it  operates on  internal  representations of the data
**	type.  This  function is usually only  provided  for large  object
**	data types and is called by the UNLOAD BINARY command of dbaccess.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns mi_bitvarying.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_bitvarying *                   The exported UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemExportBinary FunctionId: 92e262a9-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_bitvarying *
PoemExportBinary
(
Poem *                 Gen_param1,      /* The UDT value.                   */
MI_FPARAM *            Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.         */
	mi_bitvarying *      Gen_RetVal;      /* The return value.               */
	Poem *               Gen_InData;      /* The transfer data.              */
	Poem *               Gen_OutData;     /* The output data.                */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemExportBinary."
		*/
		DBDK_TRACE_ERROR( "PoemExportBinary", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* Allocate the output parcel. */
	Gen_RetVal = (mi_bitvarying *)mi_new_var( sizeof( Poem ) );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemExportBinary."
		*/
		DBDK_TRACE_ERROR( "PoemExportBinary", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = (Poem *)mi_get_vardata( (mi_lvarchar *)Gen_RetVal );

	/* Prepare the value for Gen_OutData->poem. */
	mi_put_bytes( (mi_unsigned_char1 *)&Gen_OutData->poem, (char *) 
        &Gen_InData->poem, DBDK_LOHSIZE );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the UDT value. */
	return Gen_RetVal;
}
/* }}FUNCTION (#JJ7V) */



/* {{FUNCTION(92e262b0-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemCompare
**
** Description:
**
**	Perform the comparison operations required to compare two
**	UDT values.
**
**	This function returns zero if the two UDT values are equal and
**	a non-zero value otherwise.
**
** Special Comments:
**
**	Compares two fixed-sized opaque types
**
** Parameters:
**
**	Poem *             Gen_param1;    The first UDT value to compare.
**	Poem *             Gen_param2;    The second UDT value to compare.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_integer                        The comparison result.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemCompare FunctionId: 92e262b0-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_integer
PoemCompare
(
Poem *                  Gen_param1,      /* The first UDT value to compare.  */
Poem *                  Gen_param2,      /* The second UDT value to compare. */
MI_FPARAM *             Gen_fparam       /* Standard info - see DBDK docs.   */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.          */
	mi_integer           Gen_cc;          /* Numeric attribute difference.    */
	Poem *               Gen_Value1;      /* Pointer to the first value.      */
	Poem *               Gen_Value2;      /* Pointer to the second value.     */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemCompare."
		*/
		DBDK_TRACE_ERROR( "PoemCompare", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the data values that are to be compared. */
	Gen_Value1 = Gen_param1;
	Gen_Value2 = Gen_param2;

	/*
	** Compare  the  two  large  objects.  This
	** comparison  does  not  actually  compare
	** the  large   objects  themselves -  only
	** the  handles.  Additional  code  can  be
	** added here to compare the large objects.
	*/
	Gen_cc = mi_lo_ptr_cmp( Gen_Con, &Gen_Value1->poem, &Gen_Value2->poem );
	if( Gen_cc )
	{
		return Gen_cc == 0 ? 0 : 1;
	}

	/* Close the connection. */
	mi_close( Gen_Con );

	return 0;
}
/* }}FUNCTION (#IHAN) */



/* {{FUNCTION(92e262b1-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemEqual
**
** Description:
**
**	Determine if one UDT value is equal to another.
**
** Special Comments:
**
**	Compares two fixed-sized opaque types for equality
**
** Parameters:
**
**	Poem *             Gen_param1;    The first UDT value to compare.
**	Poem *             Gen_param2;    The second UDT value to compare.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_boolean                        The comparison result.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemEqual FunctionId: 92e262b1-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_boolean
PoemEqual
(
Poem *             Gen_param1,      /* The first UDT value to compare.         */
Poem *             Gen_param2,      /* The second UDT value to compare.        */
MI_FPARAM *        Gen_fparam       /* Standard info - see DBDK docs.          */
)
{
	/* Call Compare to perform the comparison. */
	return (mi_boolean)(0 == PoemCompare( Gen_param1,
			Gen_param2, Gen_fparam ));
}
/* }}FUNCTION (#A375) */



/* {{FUNCTION(92e262b2-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemNotEqual
**
** Description:
**
**	Determine if one UDT value is not equal to another.
**
** Special Comments:
**
**	Compares two fixed-sized opaque types for non-equality
**
** Parameters:
**
**	Poem *             Gen_param1;    The first UDT value to compare.
**	Poem *             Gen_param2;    The second UDT value to compare.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_boolean                        The comparison result.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemNotEqual FunctionId: 92e262b2-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_boolean
PoemNotEqual
(
Poem *         Gen_param1,      /* The first UDT value to compare.         */
Poem *         Gen_param2,      /* The second UDT value to compare.        */
MI_FPARAM *    Gen_fparam       /* Standard info - see DBDK docs.          */
)
{
	/* Call Compare to perform the comparison. */
	return (mi_boolean)(0 != PoemCompare( Gen_param1,
			Gen_param2, Gen_fparam ));
}
/* }}FUNCTION (#L515) */



/* {{FUNCTION(92e262af-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemLOhandles
**
** Description:
**
** Special Comments:
**
**	Support routine for opaque type Poem returns mi_bitvarying.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_bitvarying *                   The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemLOhandles FunctionId: 92e262af-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_bitvarying *
PoemLOhandles
(
Poem *             Gen_param1,      /* The UDT value.                        */
MI_FPARAM *        Gen_fparam       /* Standard info - see DBDK docs.        */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.         */
	Poem *               Gen_InData;      /* The UDT value.                  */
	MI_LO_LIST *         Gen_OutData;     /* Point to the output table.      */
	mi_integer           Gen_nLOs;        /* Number of LOs in UDT.           */
	mi_integer           Gen_LOno;        /* Index into the table.           */
	mi_bitvarying *      Gen_RetVal;      /* "Array" of LO handles.          */

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemLOhandles."
		*/
		DBDK_TRACE_ERROR( "PoemLOhandles", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* Initialize the number of LO handles that are valid. */
	Gen_LOno = Gen_nLOs = 0;

	/*
	** Validate any LO before using it. LOs
	** with invalid handles are simply ignored.
	*/
	/* If the LO is valid ... */
	if( mi_lo_validate( Gen_Con, &Gen_InData->poem ) == 0 )
	{
		/* Add it to the count. */
		Gen_nLOs++;
	}
	

	/*
	**	If there are any large objects,
	**	add them to the return array.
	*/
	if( Gen_nLOs )
	{
		/*
		** Allocate the return array. This will be a variable
		** length array of large object handles.
		*/
		Gen_RetVal = (mi_bitvarying *)mi_new_var(
						sizeof(mi_integer) + Gen_nLOs * DBDK_LOHSIZE );
		if( Gen_RetVal == 0 )
		{
			/*
			** Memory allocation has failed so issue
			** the following message and quit.
			**
			** 	"Memory allocation has failed in PoemLOhandles."
			*/
			DBDK_TRACE_ERROR( "PoemLOhandles", ERRORMESG2, 10 );

			/* not reached */
		}

		/* Point to the output LO table. */
		Gen_OutData = (MI_LO_LIST *)mi_get_vardata( (mi_lvarchar *)Gen_RetVal );

		/*
		** Validate any LO before using it. LOs
		** with invalid handles are simply ignored.
		*/
		/* If the LO is valid ... */
		if( mi_lo_validate( Gen_Con, &Gen_InData->poem ) == 0 )
		{
			/* Save it. */
			memcpy( &Gen_OutData->lol_handles[Gen_LOno++],
				&Gen_InData->poem, DBDK_LOHSIZE );
		}
		
		/* Save the number of LOs in the return structure. */
		Gen_OutData->lol_cnt = Gen_LOno;

		/* Close the connection. */
		mi_close( Gen_Con );

		/* Return the array of LO handles. */
		return Gen_RetVal;
	}
	else
	{
		/* Close the connection. */
		mi_close( Gen_Con );

		/* Return failure. */
		return 0;
	}
}
/* }}FUNCTION (#S3A1) */



/* {{FUNCTION(92e262ab-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemImportText
**
** Description:
**
**	The import function enables bulk copy for user-defined types.
**	When the  LOAD statement is  used from  dbaccess to copy data
**	from a file  into the database, the  server calls the  import
**	function to convert the  incoming  value  to the data  type's
**	internal format.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns Poem.
**
** Parameters:
**
**	mi_impexp *        Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	Poem *                            The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemImportText FunctionId: 92e262ab-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
Poem *
PoemImportText
(
mi_impexp *            Gen_param1,      /* The import text.                  */
MI_FPARAM *            Gen_fparam       /* Standard info - see DBDK docs.    */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.           */
	gl_mchar_t *         Gen_InData;      /* Pointer to the input data.        */
	gl_mchar_t *         Gen_StartInData; /* First value of Gen_InData.        */
	Poem *               Gen_OutData;     /* Pointer to the output data.       */
	mi_integer           Gen_DataLen;     /* Length of the data in bytes.      */
	Poem *               Gen_RetVal;      /* The return value.                 */
	char                 Gen_LOFile[FILENAME_MAX]; /* Store the file name here.*/

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemImportText."
		*/
		DBDK_TRACE_ERROR( "PoemImportText", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = (gl_mchar_t *)mi_get_vardata( (mi_lvarchar *) Gen_param1 );
	Gen_StartInData = Gen_InData;

	/* Get the length of the input string. */
	Gen_DataLen = mi_get_varlen( (mi_lvarchar *)Gen_param1 );

	/* Allocate a new UDT for the return result. */
	Gen_RetVal = (Poem *)mi_alloc( sizeof( Poem ) );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemImportText."
		*/
		DBDK_TRACE_ERROR( "PoemImportText", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = (Poem *)Gen_RetVal;

		/* Get the MI_LO_HANDLE data value for poem. */
		Gen_InData = Gen_sscanf( Gen_Con, "PoemImportText", Gen_InData,
						mi_get_varlen( (mi_lvarchar *) Gen_param1 ),
						sizeof(Gen_LOFile)-1,
						"%s %n",
						Gen_LOFile );
	
		/* Load the large object from the file. */
		Gen_LoadLOFromFile( Gen_Con, "PoemImportText", Gen_LOFile,
			&Gen_OutData->poem );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the UDT value. */
	return Gen_RetVal;
}
/* }}FUNCTION (#8CE4) */



/* {{FUNCTION(92e262ac-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemExportText
**
** Description:
**
**	The export function enables bulk copy for user-defined types.
**	When the UNLOAD statement is used from  dbaccess to copy data
**	from  the  database to a  file, the  server calls the  export
**	function  to convert the outcoming  value to the data  type's
**	external format.
**
** Special Comments:
**
**	Support routine for opaque type Poem returns mi_impexp.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_impexp *                       The exported UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemExportText FunctionId: 92e262ac-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_impexp *
PoemExportText
(
Poem *                 Gen_param1,      /* The UDT value.                  */
MI_FPARAM *            Gen_fparam       /* Standard info - see DBDK docs.  */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.        */
	mi_integer           Gen_CharLen;     /* Estimate maximum length.       */
	Poem *               Gen_InData;      /* Pointer to the input data.     */
	char *               Gen_OutData;     /* Pointer to the output data.    */
	mi_impexp *          Gen_RetVal;      /* The return result.             */
	mi_integer           Gen_DataLen;     /* The data length.               */
	char                 Gen_LOFile[FILENAME_MAX]/* Store the file name here.*/
	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemExportText."
		*/
		DBDK_TRACE_ERROR( "PoemExportText", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* Compute the maximum length of the text representation. */
	Gen_CharLen         =   1              /* Leave room for the NULL terminator.*/
	               + 261           /* Add the length for poem. */
		            ;

	/* Allocate the output parcel. */
	Gen_RetVal = (mi_impexp *)mi_new_var( Gen_CharLen );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemExportText."
		*/
		DBDK_TRACE_ERROR( "PoemExportText", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = mi_get_vardata( (mi_lvarchar *)Gen_RetVal );

	/* Format the attribute value into the output string. */

	/* Save the large object to disk. */
	strcpy( Gen_LOFile, LO_FN_MASK );
	Gen_StoreLOToFile( Gen_Con, "PoemExportText", Gen_LOFile, &Gen_InData->poem );
	
	/* Construct the return value: the LO's file name. */
	sprintf( Gen_OutData, "%s", Gen_LOFile );
	
	/* Advance past the formatted data. */
	Gen_OutData += strlen( Gen_OutData );

	/*
	** Compute the length of the data and
	** place it in the return structure.
	*/
	Gen_DataLen = (mi_integer)(Gen_OutData - mi_get_vardata( (mi_lvarchar *) 
       Gen_RetVal ));
	mi_set_varlen ( (mi_lvarchar *) Gen_RetVal, Gen_DataLen );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the UDT value. */
	return Gen_RetVal;
}
/* }}FUNCTION (#79TB) */



/* {{FUNCTION(92e262b3-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemInput
**
** Description:
**
**	This function converts from the external representation of the
**	UDT type Poem to its internal representation.   The external
**	representation is a blank-separated list of values and the
**	internal representation is a 'C' structure of type Poem as
**	defined in the header file.
**
**	Since the Poem type contains an MI_LO_HANDLE attribute, code
**	must be supplied here to maintain its reference count.  This insures
**	that the large object is not dropped while a record in the database
**	stores a pointer to it.
**
**	The assign and destroy functions must be present, and properly
**	registered, if the input or output functions are used.  Missing
**	these functions will cause SmartBlob error 12059.
**
**
**	Data can be inserted into a table using an SQL insert statement:
**
**		insert into tablename values ( 'value-list' );
**
**	value-list is a space-delimited list of values.
**
**	Selecting a large object will cause the large object to be written
**	to a file and the value returned for the large object will be its
**	file name.
**
**	Values for large objects are the large object's file name.
**	The file name must be enclosed in double quotes (i.e., ").
**
** Special Comments:
**
**	Support routine for opaque type Poem returns Poem.
**
** Parameters:
**
**	mi_lvarchar *      Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	Poem *                            The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemInput FunctionId: 92e262b3-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
Poem *
PoemInput
(
mi_lvarchar *          Gen_param1,      /* Pointer to the input text.        */
MI_FPARAM *            Gen_fparam       /* Standard info - see DBDK docs.    */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.           */
	gl_mchar_t *         Gen_InData;      /* Pointer to the input data.        */
	gl_mchar_t *         Gen_StartInData; /* First value of Gen_InData.        */
	Poem *               Gen_OutData;     /* Pointer to the output data.       */
	mi_integer           Gen_DataLen;     /* Length of the data in bytes.      */
	Poem *               Gen_RetVal;      /* The return value.                 */
	char                 Gen_LOFile[FILENAME_MAX]; /* Store the file name here.*/

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemInput."
		*/
		DBDK_TRACE_ERROR( "PoemInput", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = (gl_mchar_t *)mi_get_vardata( (mi_lvarchar *) Gen_param1 );
	Gen_StartInData = Gen_InData;

	/* Get the length of the input string. */
	Gen_DataLen = mi_get_varlen( Gen_param1 );

	/* Allocate a new UDT for the return result. */
	Gen_RetVal = (Poem *)mi_alloc( sizeof( Poem ) );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemInput."
		*/
		DBDK_TRACE_ERROR( "PoemInput", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = (Poem *)Gen_RetVal;

	/* Get the MI_LO_HANDLE data value for poem. */
	Gen_InData = Gen_sscanf( Gen_Con, "PoemInput", Gen_InData,
					mi_get_varlen( Gen_param1 ),
					sizeof(Gen_LOFile)-1,
					"%s %n",
					Gen_LOFile );
	
	/* Load the large object from the file. */
	Gen_LoadLOFromFile( Gen_Con, "PoemInput", Gen_LOFile,
		&Gen_OutData->poem );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the UDT value. */
	return Gen_RetVal;
}
/* }}FUNCTION (#PEM0) */



/* {{FUNCTION(92e262a6-0d7a-11d3-98b2-000000000000) (MergeSection) */

/*******************************************************************************
**
** Function name:
**
**	PoemOutput
**
** Description:
**
**	This function converts from the internal representation of the
**	UDT type Poem to its external representation.   The external
**	representation is a blank-separated list of values and the
**	internal representation is a 'C' structure of type Poem as
**	defined in the header file.
**
**	Data can be retrieved from a table using an SQL select statement:
**
**		select * from tablename;
**
**	Selecting a large object will cause the large object to be written
**	to a file and the value returned for the large object will be its
**	file name.
**
**	Values for large objects are the large object's file name.
**	The file name must be enclosed in double quotes (i.e., ").
**
** Special Comments:
**
**	Support routine for opaque type Poem returns mi_lvarchar.
**
** Parameters:
**
**	Poem *             Gen_param1;    Pointer to the input text.
**	MI_FPARAM *        Gen_fparam;    Standard info - see DBDK docs.
**
** Return value:
**
**	mi_lvarchar *                     The constructed UDT value.
**
** History:
**
**	05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
**	Warning: Do not remove or modify this comment:
**	    PoemOutput FunctionId: 92e262a6-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/

UDREXPORT
mi_lvarchar *
PoemOutput
(
Poem *                 Gen_param1,       /* The UDT value.                    */
MI_FPARAM *            Gen_fparam        /* Standard info - see DBDK docs.    */
)
{
	MI_CONNECTION *      Gen_Con;         /* The current connection.           */
	mi_integer           Gen_CharLen;     /* Estimate maximum length.          */
	Poem *               Gen_InData;      /* Pointer to the input data.        */
	char *               Gen_OutData;     /* Pointer to the output data.       */
	mi_lvarchar *        Gen_RetVal;      /* The return result.                */
	mi_integer           Gen_DataLen;     /* The data length.                  */
	char                 Gen_LOFile[FILENAME_MAX]; /* Store the file name here.*/

	/* Get the current connection handle. */
	Gen_Con = mi_open( NULL, NULL, NULL );

	/* Verify that the connection has been established. */
	if( Gen_Con == 0 )
	{
		/*
		** Opening the current connection has failed
		** so issue the following message and quit.
		**
		** 	"Connection has failed in PoemOutput."
		*/
		DBDK_TRACE_ERROR( "PoemOutput", ERRORMESG1, 10 );

		/* not reached */
	}

	/* Point to the input data. */
	Gen_InData = Gen_param1;

	/* Compute the maximum length of the text representation. */
	Gen_CharLen         =   1              /* Leave room for the NULL terminator.*/
	               + 261           /* Add the length for poem. */
		            ;

	/* Allocate room for the output string. */
	Gen_RetVal = mi_new_var( Gen_CharLen );
	if( Gen_RetVal == 0 )
	{
		/*
		** Memory allocation has failed so issue
		** the following message and quit.
		**
		** 	"Memory allocation has failed in PoemOutput."
		*/
		DBDK_TRACE_ERROR( "PoemOutput", ERRORMESG2, 10 );

		/* not reached */
	}

	/* Point to the output data. */
	Gen_OutData = mi_get_vardata( Gen_RetVal );

	/* Format the attribute value into the output string. */
{
char PoemStart[128];
char * pTag1 = NULL;
char * pTag2 = NULL;
MI_LO_FD LO_fd;

/* 
* Get the poem title: open the smart large object, read the first 127 bytes,
* look for the begin-title and end-title XML tags, then close the object.
*/
LO_fd = mi_lo_open( Gen_Con, &Gen_InData->poem, MI_LO_RANDOM | MI_LO_RDONLY );
if (LO_fd != MI_ERROR)
     {
     mi_lo_read( Gen_Con, LO_fd, PoemStart, 127);
     PoemStart[127] = 0;
     pTag1 = strstr( PoemStart, "<title>" );
     pTag2 = strstr( PoemStart, "</title>" );
     if (pTag2 != NULL)
          *pTag2 = 0;
     mi_lo_close( Gen_Con, LO_fd );
     }

/*
* Build the filename: if the title tags are found, use the poem title plus an
* ".xml" extension as the filename, otherwise, use the name "poem.xml". 
*/
if (pTag1 != NULL)
     {
     strcpy( Gen_LOFile, pTag1 + 7 );
     strcat(Gen_LOFile, ".xml!" );
     /* The "!" indicates that the filename need not be unique. */
     }
else
     strcpy( Gen_LOFile, "poem.xml" );

     }
	/* Save the large object to disk. */
	
	Gen_StoreLOToFile( Gen_Con, "PoemOutput", Gen_LOFile, &Gen_InData->poem );
	
	/* Construct the return value: the LO's file name. */
	sprintf( Gen_OutData, "%s", Gen_LOFile );
	
	/* Advance past the formatted data. */
	Gen_OutData += strlen( Gen_OutData );
	
	/* Insert a separator. */
	*Gen_OutData++ = ' ';

	/*
	** Compute the length of the data and
	** place it in the return structure.
	*/
	Gen_DataLen = (mi_integer)(Gen_OutData - mi_get_vardata( Gen_RetVal ));
	mi_set_varlen ( Gen_RetVal, Gen_DataLen );

	/* Close the connection. */
	mi_close( Gen_Con );

	/* Return the UDT value. */
	return Gen_RetVal;
}
/* }}FUNCTION (#FQKF) */



#ifdef __cplusplus

}

#endif