/* ** Title: MMXImage ** SCCSid: %W% %E% %U% ** CCid: %W% %E% %U% ** Author: Informix Software, Inc. ** Created: 06/11/1998 14:48 ** Description: This is the generated 'C' file for the MMXImage DataBlade. ** Comments: Generated for project MMXImage.3.6 */ /* ** The following is placed here to insure ** that name "mangling" does not occur. */ #ifdef __cplusplus extern "C" { #endif /* Standard library includes. */ #include #include #include #include #include #define IMAGEBUFSIZE 128*128 /* Function prototypes. */ void MMXImage2x( byte * lpBackbufferMemory, int x_res, int y_res ); void CImage2x( byte * lpBackbufferMemory, int x_res, int y_res ); void MMXpick1of4( byte * lpSource, byte * lpDest, int width, int height ); void Cpick1of4( byte * lpSource, byte * lpDest, int width, int height ); /* Used by Informix GLS routines. */ #include /* Include when accessing the Informix API. */ #include /* This is the project include file. */ #include "MMXImage.h" /* {{FUNCTION(19b73867-d6b0-11d0-8874-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageAssign ** ** Description: ** ** This function is called when rows are inserted into the a table. ** You can provide special handling for the Image type here. ** Since the Image 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 Image returns Image. ** ** Parameters: ** ** Image * Gen_param1; Pointer to the input text. ** MI_FPARAM * Gen_fparam; Standard info - see DBDK docs. ** ** Return value: ** ** Image * The constructed UDT value. ** ** History: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageAssign FunctionId: 19b73867-d6b0-11d0-8874-00a0c9255cf3 ** ***************************************************************** */ Image * ImageAssign ( Image * Gen_param1, /* The UDT value. */ MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs. */ ) { MI_CONNECTION * Gen_Con; /* The current connection. */ mi_integer Gen_Index10; /* Array iterator */ Image * 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 ImageAssign." */ DBDK_TRACE_ERROR( "ImageAssign", 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->ImageHandle ) == 0 ) { /* ... increment its reference count. */ mi_lo_increfcount( Gen_Con, &Gen_InData->ImageHandle ); } /* Close the connection. */ mi_close( Gen_Con ); return Gen_InData; } /* }}FUNCTION (#3A2BEP3P) */ /* {{FUNCTION(19b73868-d6b0-11d0-8874-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageDestroy ** ** Description: ** ** This function is called when rows are removed from the a table. ** You can provide special handling for the Image type here. ** Since the Image 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 Image returns void. ** ** Parameters: ** ** Image * Gen_param1; Pointer to the input text. ** MI_FPARAM * Gen_fparam; Standard info - see DBDK docs. ** ** Return value: ** ** Image * The constructed UDT value. ** ** History: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageDestroy FunctionId: 19b73868-d6b0-11d0-8874-00a0c9255cf3 ** ***************************************************************** */ void ImageDestroy ( Image * Gen_param1, /* The UDT value. */ MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs. */ ) { MI_CONNECTION * Gen_Con; /* The current connection. */ mi_integer Gen_Index10; /* Array iterator */ Image * 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 ImageDestroy." */ DBDK_TRACE_ERROR( "ImageDestroy", 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->ImageHandle ) == 0 ) { /* ... decrement its reference count. */ mi_lo_decrefcount( Gen_Con, &Gen_InData->ImageHandle ); } /* Close the connection. */ mi_close( Gen_Con ); } /* }}FUNCTION (#3UJT17TA) */ /* {{FUNCTION(57b83300-38e1-11d1-888e-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageSend ** ** 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 Image returns mi_sendrecv. ** ** Parameters: ** ** Image * 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: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageSend FunctionId: 57b83300-38e1-11d1-888e-00a0c9255cf3 ** ***************************************************************** */ mi_sendrecv * ImageSend ( Image * Gen_param1, /* The UDT value */ MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs. */ ) { MI_CONNECTION * Gen_Con; /* The current connection. */ Image * Gen_InData; /* Pointer to the UDT value. */ Image * Gen_OutData; /* Pointer to the packet data. */ mi_sendrecv * Gen_RetVal; /* The return value. */ mi_integer Gen_Index10; /* Array iterator */ 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 ImageSend." */ DBDK_TRACE_ERROR( "ImageSend", 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( Image ) ); if( Gen_RetVal == 0 ) { /* ** Memory allocation has failed so issue ** the following message and quit. ** ** "Memory allocation has failed in ImageSend." */ DBDK_TRACE_ERROR( "ImageSend", ERRORMESG2, 10 ); /* not reached */ } /* Point to the output data. */ Gen_OutData = (Image *)mi_get_vardata( (mi_lvarchar *)Gen_RetVal ); /* Prepare the value for Gen_OutData->ImageHandle. */ mi_put_bytes( (mi_unsigned_char1 *)&Gen_OutData->ImageHandle, (char *) &Gen_InData->ImageHandle, DBDK_LOHSIZE ); /* Prepare the value for Gen_OutData->ImageWidth. */ mi_put_integer( (mi_unsigned_char1 *)&Gen_OutData->ImageWidth, Gen_InData->ImageWidth ); /* Prepare the value for Gen_OutData->ImageHeight. */ mi_put_integer( (mi_unsigned_char1 *)&Gen_OutData->ImageHeight, Gen_InData->ImageHeight ); for( Gen_Index10 = 0; Gen_Index10 < 1; ++Gen_Index10 ) { /* Prepare the value for Gen_OutData->ImageDescription[Gen_Index10]. */ mi_put_bytes( (mi_unsigned_char1 *)Gen_OutData->ImageDescription[Gen_Index10], (char *)Gen_InData->ImageDescription[Gen_Index10], 100 ); } /* Close the connection. */ mi_close( Gen_Con ); /* Return the UDT for transmission. */ return Gen_RetVal; } /* }}FUNCTION (#8H07P2OR) */ /* {{FUNCTION(57b83301-38e1-11d1-888e-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageReceive ** ** 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 Image returns Image. ** ** Parameters: ** ** mi_lvarchar * Gen_param1; Pointer to the input text. ** MI_FPARAM * Gen_fparam; Standard info - see DBDK docs. ** ** Return value: ** ** Image * The constructed UDT value. ** ** History: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageReceive FunctionId: 57b83301-38e1-11d1-888e-00a0c9255cf3 ** ***************************************************************** */ Image * ImageReceive ( mi_sendrecv * Gen_param1, /* The UDT value. */ MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs. */ ) { MI_CONNECTION * Gen_Con; /* The current connection. */ Image * Gen_RetVal; /* The return value. */ Image * Gen_InData; /* Packet data. */ Image * Gen_OutData; /* Output UDT value. */ mi_integer Gen_Index10; /* Array iterator */ 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 ImageReceive." */ DBDK_TRACE_ERROR( "ImageReceive", ERRORMESG1, 10 ); /* not reached */ } /* Point to the input data. */ Gen_InData = (Image *)mi_get_vardata( (mi_lvarchar *)Gen_param1 ); /* Allocate room for the UDT. */ Gen_RetVal = (Image *)mi_alloc( sizeof( Image ) ); if( Gen_RetVal == 0 ) { /* ** Memory allocation has failed so issue ** the following message and quit. ** ** "Memory allocation has failed in ImageReceive." */ DBDK_TRACE_ERROR( "ImageReceive", ERRORMESG2, 10 ); /* not reached */ } /* Point to the output data. */ Gen_OutData = (Image *)Gen_RetVal; /* Copy the attribute value(s) from the transmission parcel. */ /* Prepare the value for Gen_OutData->ImageHandle. */ mi_get_bytes( (mi_unsigned_char1 *)&Gen_InData->ImageHandle, (char *) &Gen_OutData->ImageHandle, DBDK_LOHSIZE ); /* Prepare the value for Gen_OutData->ImageWidth. */ mi_get_integer( (mi_unsigned_char1 *)&Gen_InData->ImageWidth, &Gen_OutData->ImageWidth ); /* Prepare the value for Gen_OutData->ImageHeight. */ mi_get_integer( (mi_unsigned_char1 *)&Gen_InData->ImageHeight, &Gen_OutData->ImageHeight ); /* Prepare the value for Gen_OutData->ImageDescription. */ for( Gen_Index10 = 0; Gen_Index10 < 1; ++Gen_Index10 ) { /* Prepare the value for Gen_InData->ImageDescription[Gen_Index10]. */ mi_get_bytes( (mi_unsigned_char1 *)Gen_InData->ImageDescription[Gen_Index10], (char *)Gen_OutData->ImageDescription[Gen_Index10], 100 ); } /* Return the transmitted UDT value. */ return Gen_RetVal; } /* }}FUNCTION (#VS9U67TN) */ /* {{FUNCTION(19b73869-d6b0-11d0-8874-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageLOhandles ** ** Description: ** ** Special Comments: ** ** Support routine for opaque type Image returns mi_bitvarying. ** ** Parameters: ** ** Image * 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: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageLOhandles FunctionId: 19b73869-d6b0-11d0-8874-00a0c9255cf3 ** ***************************************************************** */ mi_bitvarying * ImageLOhandles ( Image * Gen_param1, /* The UDT value. */ MI_FPARAM * Gen_fparam /* Standard info - see DBDK docs. */ ) { MI_CONNECTION * Gen_Con; /* The current connection. */ Image * 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. */ mi_integer Gen_Index10; /* Array iterator */ /* 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 ImageLOhandles." */ DBDK_TRACE_ERROR( "ImageLOhandles", 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->ImageHandle ) == 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 ImageLOhandles." */ DBDK_TRACE_ERROR( "ImageLOhandles", 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->ImageHandle ) == 0 ) { /* Save it. */ memcpy( &Gen_OutData->lol_handles[Gen_LOno++], &Gen_InData->ImageHandle, 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 (#8TETEQRD) */ /* {{FUNCTION(19b73861-d6b0-11d0-8874-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageInput ** ** Description: ** ** This function converts from the external representation of the ** UDT type Image to its internal representation. The external ** representation is a blank-separated list of values and the ** internal representation is a 'C' structure of type Image as ** defined in the header file. ** ** Since the Image 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. ** ** Values for large objects are the large object's file name. ** The file name must be enclosed in double quotes (i.e., "). ** ** Data for the mi_integer type is in the range [-32767, +32767]. ** Special Comments: ** ** Support routine for opaque type Image returns Image. ** ** Parameters: ** ** mi_lvarchar * Gen_param1; Pointer to the input text. ** MI_FPARAM * Gen_fparam; Standard info - see DBDK docs. ** ** Return value: ** ** Image * The constructed UDT value. ** ** History: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageInput FunctionId: 19b73861-d6b0-11d0-8874-00a0c9255cf3 ** ***************************************************************** */ Image * ImageInput ( 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. */ Image * Gen_OutData; /* Pointer to the output data. */ mi_integer Gen_DataLen; /* Length of the data in bytes. */ Image * Gen_RetVal; /* The return value. */ char Gen_LOFile[FILENAME_MAX];/* Store the file name here. */ MI_LODESC Gen_LoDesc; /* Large object descriptor. */ BITMAPFILEHEADER bf; /* BMP file header info. */ BITMAPINFO bi; /* BMP image header info. */ /* 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 ImageInput." */ DBDK_TRACE_ERROR( "ImageInput", ERRORMESG1, 10 ); /* not reached */ } /* ** Write to the trace file indicating ** that ImageInput has been called. */ DBDK_TRACE_ENTER( "ImageInput" ); /* Allocate memory room to build the UDT in. */ Gen_RetVal = (Image *)mi_alloc( sizeof( Image ) ); if( Gen_RetVal == 0 ) { /* ** Memory allocation has failed so issue ** the following message and quit. ** ** "Memory allocation has failed in ImageInput." */ DBDK_TRACE_ERROR( "ImageInput", ERRORMESG2, 10 ); /* not reached */ } /* Point to the input data. */ Gen_InData = (gl_mchar_t *)mi_get_vardata( Gen_param1 ); /* Point to the output data. */ Gen_OutData = (Image *)Gen_RetVal; /* Get the length of the input string. */ Gen_DataLen = mi_get_varlen( Gen_param1 ); /* Get the data value for Gen_OutData->ImageHandle. */ Gen_InData = Gen_sscanf( Gen_Con, "ImageInput", 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, "ImageInput", Gen_LOFile, &Gen_OutData->ImageHandle ); /* Open the large object's handle and read it. */ Gen_LoDesc = mi_large_object_open( Gen_Con, &Gen_OutData->ImageHandle, MI_LO_RDONLY ); if( Gen_LoDesc == MI_ERROR ) { /* ** An error has occurred while reading the large object. */ DBDK_TRACE_ERROR( "ImageInput", "MMX06", 0 ); mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); return (0); } /* Read the LO BMP file. */ if( mi_large_object_read( Gen_Con, Gen_LoDesc, (char *)&bf, sizeof(BITMAPFILEHEADER) ) == MI_ERROR || mi_large_object_read( Gen_Con, Gen_LoDesc, (char *)&bi, sizeof(BITMAPINFOHEADER) ) == MI_ERROR || mi_large_object_close( Gen_Con, Gen_LoDesc ) == MI_ERROR ) { /* ** An error has occurred while reading the large object. */ DBDK_TRACE_ERROR( "ImageInput", "MMX06", 0 ); mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); return (0); } /* ** Insure that the image dimensions are integral multiples of 64. */ if( (bi.bmiHeader.biWidth % 64 != 0) || (bi.bmiHeader.biHeight % 64 != 0) ) { /* ** Image dimensions, height and width, ** must be integral multiples of 64. */ DBDK_TRACE_ERROR( "ImageInput", "MMX03", 0 ); mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); return (0); } /* ** Insure that the image dimensions are equal. */ if( bi.bmiHeader.biWidth != bi.bmiHeader.biHeight ) { /* ** Image dimensions, height and width, ** must be equal to each other. */ DBDK_TRACE_ERROR( "ImageInput", "MMX05", 0 ); mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); return (0); } /* ** Make sure that the image is not too big to process. */ if(( bi.bmiHeader.biWidth * bi.bmiHeader.biHeight) > IMAGEBUFSIZE ) { /* ** Image too large. */ DBDK_TRACE_ERROR( "ImageInput", "MMX01", 0 ); mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); return (0); } /* ** Make sure that the data bits are uncompressed. */ if( bi.bmiHeader.biCompression != BI_RGB ) { /* ** The image can not be in image compressed format. */ DBDK_TRACE_ERROR( "ImageInput", "MMX02", 0 ); mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); return(0); } /* Get the data value for Gen_OutData->ImageWidth. */ Gen_OutData->ImageWidth = bi.bmiHeader.biWidth; /* Get the data value for Gen_OutData->ImageHeight. */ Gen_OutData->ImageHeight = bi.bmiHeader.biHeight; /* Get the data value for Gen_OutData->ImageDescription[0]. */ Gen_InData = Gen_sscanf( Gen_Con, "ImageInput", Gen_InData, mi_get_varlen( Gen_param1 ), 100, "%s %n", (char *)&Gen_OutData->ImageDescription[0] ); /* ** Write to the trace file indicating ** that ImageInput has successfully exited. */ DBDK_TRACE_EXIT( "ImageInput" ); /* Close the connection. */ mi_close( Gen_Con ); /* Return the UDT value. */ return Gen_RetVal; } /* }}FUNCTION (#H5QID1QH) */ /* {{FUNCTION(19b73862-d6b0-11d0-8874-00a0c9255cf3) (MergeSection) */ /**************************************************************** ** ** Function name: ** ** ImageOutput ** ** Description: ** ** This function converts from the internal representation of the ** UDT type Image to its external representation. The external ** representation is a blank-separated list of values and the ** internal representation is a 'C' structure of type Image 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., "). ** ** Data for the mi_integer type is in the range [-32767, +32767]. ** Special Comments: ** ** Support routine for opaque type Image returns mi_lvarchar. ** ** Parameters: ** ** Image * 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: ** ** 06/11/1998 - Generated by BladeSmith Version 3.60.TC1B1. ** ** Identification: ** ** Warning: Do not remove or modify this comment: ** ImageOutput FunctionId: 19b73862-d6b0-11d0-8874-00a0c9255cf3 ** ***************************************************************** */ mi_lvarchar * ImageOutput ( Image * 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. */ Image * 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]; /* The LO output file name. */ /* 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 ImageOutput." */ DBDK_TRACE_ERROR( "ImageOutput", ERRORMESG1, 10 ); /* not reached */ } /* ** Write to the trace file indicating ** that ImageOutput has been called. */ DBDK_TRACE_ENTER( "ImageOutput" ); /* Compute the maximum length of the text representation. */ Gen_CharLen = 1; /* Leave room for the NULL terminator. */ Gen_CharLen += 261; /* Add the length for Gen_OutData->ImageHandle. */ Gen_CharLen += 12; /* Add the length for Gen_OutData->ImageWidth. */ Gen_CharLen += 12; /* Add the length for Gen_OutData->ImageHeight. */ Gen_CharLen += 100 * 5; /* Add the length for Gen_OutData->ImageDescription[]. */ /* 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 ImageOutput." */ DBDK_TRACE_ERROR( "ImageOutput", ERRORMESG2, 10 ); /* not reached */ } /* Point to the input data. */ Gen_InData = Gen_param1; /* Point to the output data. */ Gen_OutData = mi_get_vardata( 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, "ImageOutput", Gen_LOFile, &Gen_InData->ImageHandle ); /* 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 ); /* Format the value for Gen_InData->ImageDescription[0]. */ sprintf( Gen_OutData, "\"%s\" ", Gen_InData->ImageDescription[0] ); 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 ); /* ** Write to the trace file indicating ** that ImageOutput has successfully exited. */ DBDK_TRACE_EXIT( "ImageOutput" ); /* Close the connection. */ mi_close( Gen_Con ); return Gen_RetVal; } /* }}FUNCTION (#H3TV8P33) */ #ifdef __cplusplus } #endif