/*
** Title: Pnt.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: danielh
** Created: 05/18/1999 18:52
** Description: This is a generated source file for the Circle DataBlade module.
** Comments: Generated for project Circle.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 "Circle.h"
/* {{FUNCTION(92e26272-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntSend
**
** 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 Pnt returns mi_sendrecv.
**
** Parameters:
**
** Pnt * 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:
** PntSend FunctionId: 92e26272-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
mi_sendrecv *
PntSend
(
Pnt * Gen_param1, /* The UDT value */
MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs.*/
)
{
MI_CONNECTION * Gen_Con; /* The current connection. */
Pnt * Gen_InData; /* Pointer to the UDT value. */
Pnt * 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 PntSend."
*/
DBDK_TRACE_ERROR( "PntSend", 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( Pnt ) );
if( Gen_RetVal == 0 )
{
/*
** Memory allocation has failed so issue
** the following message and quit.
**
** "Memory allocation has failed in PntSend."
*/
DBDK_TRACE_ERROR( "PntSend", ERRORMESG2, 10 );
/* not reached */
}
/* Point to the output data. */
Gen_OutData = (Pnt *)mi_get_vardata( (mi_lvarchar *)Gen_RetVal );
/* Prepare the value for Gen_OutData->x. */
mi_put_double_precision( (mi_unsigned_char1 *)&Gen_OutData->x, &Gen_InData->x);
/* Prepare the value for Gen_OutData->y. */
mi_put_double_precision( (mi_unsigned_char1 *)&Gen_OutData->y, &Gen_InData->y);
/* Close the connection. */
mi_close( Gen_Con );
/* Return the UDT for transmission. */
return Gen_RetVal;
}
/* }}FUNCTION (#ESFT) */
/* {{FUNCTION(92e26273-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntReceive
**
** 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 Pnt returns Pnt.
**
** Parameters:
**
** mi_lvarchar * Gen_param1; Pointer to the input text.
** MI_FPARAM * Gen_fparam; Standard info - see DBDK docs.
**
** Return value:
**
** Pnt * The constructed UDT value.
**
** History:
**
** 05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
** Warning: Do not remove or modify this comment:
** PntReceive FunctionId: 92e26273-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
Pnt *
PntReceive
(
mi_sendrecv * Gen_param1, /* The UDT value. */
MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs. */
)
{
MI_CONNECTION * Gen_Con; /* The current connection. */
Pnt * Gen_RetVal; /* The return value. */
Pnt * Gen_InData; /* Packet data. */
Pnt * 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 PntReceive."
*/
DBDK_TRACE_ERROR( "PntReceive", ERRORMESG1, 10 );
/* not reached */
}
/* Point to the input data. */
Gen_InData = (Pnt *)mi_get_vardata( (mi_lvarchar *)Gen_param1 );
/* Allocate room for the UDT. */
Gen_RetVal = (Pnt *)mi_alloc( sizeof( Pnt ) );
if( Gen_RetVal == 0 )
{
/*
** Memory allocation has failed so issue
** the following message and quit.
**
** "Memory allocation has failed in PntReceive."
*/
DBDK_TRACE_ERROR( "PntReceive", ERRORMESG2, 10 );
/* not reached */
}
/* Point to the output data. */
Gen_OutData = (Pnt *)Gen_RetVal;
/* Copy the attribute value(s) from the transmission parcel. */
/* Prepare the value for Gen_OutData->x. */
mi_get_double_precision( (mi_unsigned_char1 *)&Gen_InData->x, &Gen_OutData->x);
/* Prepare the value for Gen_OutData->y. */
mi_get_double_precision( (mi_unsigned_char1 *)&GenInData->y, &Gen_OutData->y);
/* Close the connection. */
mi_close( Gen_Con );
/* Return the transmitted UDT value. */
return Gen_RetVal;
}
/* }}FUNCTION (#LP4G) */
/* {{FUNCTION(92e26274-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntCompare
**
** 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:
**
** Pnt * Gen_param1; The first UDT value to compare.
** Pnt * 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:
** PntCompare FunctionId: 92e26274-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
mi_integer
PntCompare
(
Pnt * Gen_param1, /* The first UDT value to compare. */
Pnt * 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. */
Pnt * Gen_Value1; /* Pointer to the first value. */
Pnt * 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 PntCompare."
*/
DBDK_TRACE_ERROR( "PntCompare", 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 values. */
Gen_cc = Gen_Value1->x > Gen_Value2->x ? +1 :
Gen_Value1->x < Gen_Value2->x ? -1 :
0 ;
if( Gen_cc )
{
return Gen_cc < 0 ? -1 : 1;
}
/* Compare the two values. */
Gen_cc = Gen_Value1->y > Gen_Value2->y ? +1 :
Gen_Value1->y < Gen_Value2->y ? -1 :
0 ;
if( Gen_cc )
{
return Gen_cc < 0 ? -1 : 1;
}
/* Close the connection. */
mi_close( Gen_Con );
return 0;
}
/* }}FUNCTION (#SG0H) */
/* {{FUNCTION(92e26275-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntEqual
**
** Description:
**
** Determine if one UDT value is equal to another.
**
** Special Comments:
**
** Compares two fixed-sized opaque types for equality
**
** Parameters:
**
** Pnt * Gen_param1; The first UDT value to compare.
** Pnt * 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:
** PntEqual FunctionId: 92e26275-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
mi_boolean
PntEqual
(
Pnt * Gen_param1, /* The first UDT value to compare. */
Pnt * 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 == PntCompare( Gen_param1,
Gen_param2, Gen_fparam ));
}
/* }}FUNCTION (#B3H7) */
/* {{FUNCTION(92e26276-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntNotEqual
**
** Description:
**
** Determine if one UDT value is not equal to another.
**
** Special Comments:
**
** Compares two fixed-sized opaque types for non-equality
**
** Parameters:
**
** Pnt * Gen_param1; The first UDT value to compare.
** Pnt * 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:
** PntNotEqual FunctionId: 92e26276-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
mi_boolean
PntNotEqual
(
Pnt * Gen_param1, /* The first UDT value to compare. */
Pnt * 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 != PntCompare( Gen_param1,
Gen_param2, Gen_fparam ));
}
/* }}FUNCTION (#PUOO) */
/* {{FUNCTION(92e26277-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntInput
**
** Description:
**
** This function converts from the external representation of the
** UDT type Pnt to its internal representation. The external
** representation is a blank-separated list of values and the
** internal representation is a 'C' structure of type Pnt as
** defined in the header file.
**
**
** 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.
**
** Special Comments:
**
** Support routine for opaque type Pnt returns Pnt.
**
** Parameters:
**
** mi_lvarchar * Gen_param1; Pointer to the input text.
** MI_FPARAM * Gen_fparam; Standard info - see DBDK docs.
**
** Return value:
**
** Pnt * The constructed UDT value.
**
** History:
**
** 05/18/1999 - Generated by BladeSmith Version 4.00.517.
**
** Identification:
**
** Warning: Do not remove or modify this comment:
** PntInput FunctionId: 92e26277-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
Pnt *
PntInput
(
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. */
Pnt * Gen_OutData; /* Pointer to the output data. */
mi_integer Gen_DataLen; /* Length of the data in bytes. */
Pnt * 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 PntInput."
*/
DBDK_TRACE_ERROR( "PntInput", 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 = (Pnt *)mi_alloc( sizeof( Pnt ) );
if( Gen_RetVal == 0 )
{
/*
** Memory allocation has failed so issue
** the following message and quit.
**
** "Memory allocation has failed in PntInput."
*/
DBDK_TRACE_ERROR( "PntInput", ERRORMESG2, 10 );
/* not reached */
}
/* Point to the output data. */
Gen_OutData = (Pnt *)Gen_RetVal;
/* Get the mi_double_precision value for x. */
Gen_InData = Gen_sscanf( Gen_Con, "PntInput", Gen_InData,
Gen_DataLen - (Gen_InData - Gen_StartInData),
0, "%lf %n", (char *)&Gen_OutData->x );
/* Get the mi_double_precision value for y. */
Gen_InData = Gen_sscanf( Gen_Con, "PntInput", Gen_InData,
Gen_DataLen - (Gen_InData - Gen_StartInData),
0, "%lf %n", (char *)&Gen_OutData->y );
/* Close the connection. */
mi_close( Gen_Con );
/* Return the UDT value. */
return Gen_RetVal;
}
/* }}FUNCTION (#D2C1) */
/* {{FUNCTION(92e26271-0d7a-11d3-98b2-000000000000) (MergeSection) */
/*******************************************************************************
**
** Function name:
**
** PntOutput
**
** Description:
**
** This function converts from the internal representation of the
** UDT type Pnt to its external representation. The external
** representation is a blank-separated list of values and the
** internal representation is a 'C' structure of type Pnt as
** defined in the header file.
**
** Data can be retrieved from a table using an SQL select statement:
**
** select * from tablename;
**
** Special Comments:
**
** Support routine for opaque type Pnt returns mi_lvarchar.
**
** Parameters:
**
** Pnt * 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:
** PntOutput FunctionId: 92e26271-0d7a-11d3-98b2-000000000000
**
********************************************************************************
*/
UDREXPORT
mi_lvarchar *
PntOutput
(
Pnt * 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. */
Pnt * 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. */
/* 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 PntOutput."
*/
DBDK_TRACE_ERROR( "PntOutput", 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. */
+ 61 /* Add the length for x. */
+ 61 /* Add the length for y. */
;
/* 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 PntOutput."
*/
DBDK_TRACE_ERROR( "PntOutput", ERRORMESG2, 10 );
/* not reached */
}
/* Point to the output data. */
Gen_OutData = mi_get_vardata( Gen_RetVal );
/* Format the attribute value into the output string. */
/* Format the mi_double_precision value for x. */
sprintf( Gen_OutData, "%lg ", Gen_InData->x );
Gen_OutData += strlen( Gen_OutData );
/* Format the mi_double_precision value for y. */
sprintf( Gen_OutData, "%lg ", Gen_InData->y );
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( Gen_RetVal ));
mi_set_varlen ( Gen_RetVal, Gen_DataLen );
/* Close the connection. */
mi_close( Gen_Con );
/* Return the UDT value. */
return Gen_RetVal;
}
/* }}FUNCTION (#GT6K) */
#ifdef __cplusplus
}
#endif