|
|
Archives of the TeradataForum
Message Posted: Thu, 02 Sep 2004 @ 17:09:50 GMT
Subj: | | Re: FAST EXPORT Replace function |
|
From: | | Coffing Christopher L |
Sree
Below is C source for an outmode to clean up a fastexport result set.
If you have someone that understands C then you should be able to follow the code and get what you need out of it.
Best Regards
Chris Coffing
AFKS O&M Lead Teradata DBA
Certified Teradata Master
Module FExpOracle.c
-------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// #define DBUG 1
// #define BPHEXDUMP 1
#define FALSE 0
#define TRUE 1
#define COL_NAME_LEN 30
#define COL_FORMAT_LEN 30
#define COL_TYPE_LEN 2
#define SERIOUS_ERROR 12
typedef struct __col_info_def
{
char col_name[COL_NAME_LEN];
char col_format[COL_FORMAT_LEN];
char col_type[COL_TYPE_LEN];
int col_len;
char nullable;
short decimal_total_digits;
short decimal_fraction_digits;
} col_info_def;
/**************************************************************************************/
void bp_hex_dump(unsigned char c_buf[], int len)
/**************************************************************************************/
{ /* Start of bp_hex_dump */
register short i;
int temp;
#ifndef BPHEXDUMP
return;
#endif
printf("Length = %i\n",len);
for (i = 0; i < len; i++)
{
temp = c_buf[i];
printf("%2.2x ",temp);
}
printf("\n");
} /* End of bp_hex_dump */
/**************************************************************************************/
void format_signed(__int64 temp64,col_info_def *col_info,char c_temp[])
/**************************************************************************************/
{ /* Start of format_signed */
register short i;
short decimal_places,
len,
missing,
offset,
start;
char c_temp2[129];
if (col_info->decimal_fraction_digits == 0)
{ /* No fraction */
sprintf(c_temp,"%I64i\0",temp64);
#ifdef DBUG
printf("%s ",c_temp);
#endif
return;
} /* End of no fraction */
sprintf(c_temp2,"%I64i\0",temp64);
len = strlen(c_temp2);
#ifdef DBUG
printf("%s ",c_temp2);
#endif
decimal_places = col_info->decimal_fraction_digits;
if (((decimal_places >= len) && (c_temp2[0] != '-'))
|| ((decimal_places >= (len -1)) && (c_temp2[0] == '-')))
{ /* We need to insert some zeroes */
offset = 0;
if (c_temp2[0] == '-')
{ /* We have a sign */
c_temp[offset++] = '-';
c_temp[offset++] = '.';
start = 1;
} /* End of we have a sign */
else
{ /* We don't have a sign */
c_temp[offset++] = '.';
start = 0;
} /* End of we don't have a sign */
missing = decimal_places - (len - start);
for (i = 0; i < decimal_places; i++)
{ /* Move the digits */
if (i < missing)
c_temp[offset++] = '0';
else
c_temp[offset++] = c_temp2[start++];
} /* End of move the digits */
c_temp[offset] = '\0';
} /* End of we need to insert some zeroes */
else
{ /* Insert the decimal point */
memcpy(c_temp,c_temp2,(len - decimal_places));
offset = len - decimal_places;
c_temp[offset++] = '.';
memcpy(&c_temp[offset],&c_temp2[len - decimal_places],decimal_places);
c_temp[len + 1] = '\0';
} /* End of insert the decimal point */
} /* End of format_signed */
/**************************************************************************************/
void format_unsigned(unsigned __int64 utemp64,col_info_def
*col_info,char c_temp[])
/**************************************************************************************/
{ /* Start of format_unsigned */
register short i;
short decimal_places,
len,
missing,
offset,
start;
char c_temp2[129];
if (col_info->decimal_fraction_digits == 0)
{ /* No fraction */
sprintf(c_temp,"%I64u\0",utemp64);
#ifdef DBUG
printf("%s ",c_temp);
#endif
return;
} /* End of no fraction */
sprintf(c_temp2,"%I64u\0",utemp64);
len = strlen(c_temp2);
#ifdef DBUG
printf("%s ",c_temp2);
#endif
decimal_places = col_info->decimal_fraction_digits;
if (decimal_places >= len)
{ /* We need to insert some zeroes */
offset = 0;
c_temp[offset++] = '.';
start = 0;
missing = decimal_places - (len - start);
for (i = 0; i < decimal_places; i++)
{ /* Move the digits */
if (i < missing)
c_temp[offset++] = '0';
else
c_temp[offset++] = c_temp2[start++];
} /* End of move the digits */
c_temp[offset] = '\0';
} /* End of we need to insert some zeroes */
else
{ /* Insert the decimal point */
memcpy(c_temp,c_temp2,(len - decimal_places));
offset = len - decimal_places;
c_temp[offset++] = '.';
memcpy(&c_temp[offset],&c_temp2[len - decimal_places],decimal_places);
c_temp[len + 1] = '\0';
} /* End of insert the decimal point */
} /* End of format_unsigned */
/**************************************************************************************/
void format_decimal_1(char in_buf[],col_info_def *col_info,char c_temp[])
/**************************************************************************************/
{ /* Start of format_decimal_1 */
register short i;
short has_sign;
unsigned char uschar;
short stemp;
unsigned short ustemp;
__int64 temp64;
unsigned __int64 utemp64;
has_sign = FALSE;
for (i = 0; i < COL_FORMAT_LEN; i++)
if (col_info->col_format[i] == '-')
has_sign = TRUE;
if (has_sign)
{
stemp = in_buf[0];
temp64 = stemp;
format_signed(temp64,col_info,c_temp);
}
else
{
memcpy(&uschar,in_buf,1);
ustemp = uschar;
utemp64 = ustemp;
format_unsigned(utemp64,col_info,c_temp);
}
} /* End of format_decimal_1 */
/**************************************************************************************/
void format_decimal_2(char in_buf[],col_info_def *col_info,char
c_temp[])
/**************************************************************************************/
{ /* Start of format_decimal_2 */
register short i;
short has_sign;
short stemp;
unsigned short ustemp;
__int64 temp64;
unsigned __int64 utemp64;
has_sign = FALSE;
for (i = 0; i < COL_FORMAT_LEN; i++)
if (col_info->col_format[i] == '-')
has_sign = TRUE;
if (has_sign)
{
memcpy((char *)&stemp,in_buf,2);
temp64 = stemp;
format_signed(temp64,col_info,c_temp);
}
else
{
memcpy((char *)&ustemp,in_buf,2);
utemp64 = ustemp;
format_unsigned(utemp64,col_info,c_temp);
}
} /* End of format_decimal_2 */
/**************************************************************************************/
void format_decimal_4(char in_buf[],col_info_def *col_info,char c_temp[])
/**************************************************************************************/
{ /* Start of format_decimal_4 */
register short i;
short has_sign;
int itemp;
unsigned int uitemp;
__int64 temp64;
unsigned __int64 utemp64;
has_sign = FALSE;
for (i = 0; i < COL_FORMAT_LEN; i++)
if (col_info->col_format[i] == '-')
has_sign = TRUE;
if (has_sign)
{
memcpy((char *)&itemp,in_buf,4);
temp64 = itemp;
format_signed(temp64,col_info,c_temp);
}
else
{
memcpy((char *)&uitemp,in_buf,4);
utemp64 = uitemp;
format_unsigned(utemp64,col_info,c_temp);
}
} /* End of format_decimal_4 */
/**************************************************************************************/
void format_decimal_8(char in_buf[],col_info_def *col_info,char c_temp[])
/**************************************************************************************/
{ /* Start of format_decimal_8 */
register short i;
short has_sign;
__int64 temp64;
unsigned __int64 utemp64;
has_sign = FALSE;
for (i = 0; i < COL_FORMAT_LEN; i++)
if (col_info->col_format[i] == '-')
has_sign = TRUE;
if (has_sign)
{
memcpy((char *)&temp64,in_buf,8);
format_signed(temp64,col_info,c_temp);
}
else
{
memcpy((char *)&utemp64,in_buf,8);
format_unsigned(utemp64,col_info,c_temp);
}
} /* End of format_decimal_8 */
/**************************************************************************************/
short null_col(char buf[], short col)
/**************************************************************************************/
{ /* Start of null_col */
register short i,j;
char masks[8] =
{'\x80','\x40','\x20','\x10','\x08','\x04','\x02','\x01'};
i = col / 8;
j = col % 8;
if ((buf[i] & masks[j]) != '\0')
return(TRUE);
else
return(FALSE);
} /* End of null_col */
/**************************************************************************************/
short skip_col(col_info_def col_info[], short col)
/**************************************************************************************/
{ /* Start of skip_col */
if ((memcmp(col_info[col].col_name,"REMIS_DT_TM ",12)) == 0)
return(TRUE);
if ((memcmp(col_info[col].col_name,"REMIS_RBA ",10)) == 0)
return(TRUE);
return(FALSE);
} /* End of skip_col */
/**************************************************************************************/
void upshift(char buf[], short len)
/**************************************************************************************/
{ /* Start of upshift */
register short i;
for (i = 0; i < len; i++)
if ((buf[i] >= 'a') && (buf[i] <= 'z'))
buf[i] &= 0x5f;
} /* End of upshift */
/**************************************************************************************/
void flip_it(char buf[], short len)
/**************************************************************************************/
{ /* Start of flip_it */
register short i;
char c_temp;
for (i = 0; i < (len / 2); i++)
{
c_temp = buf[i];
buf[i] = buf[len - (i + 1)];
buf[len - (i + 1)] = c_temp;
}
} /* End of flip_it */
/**************************************************************************************/
void output_col_info(col_info_def col_info[],int num_cols)
/**************************************************************************************/
{ /* Start of output_col_info */
register short i;
printf("Total columns = %i\n",num_cols);
for (i = 0; i < num_cols; i++)
printf("%30.30s %30.30s %2.2s %i %c %i %i\n",
col_info[i].col_name,
col_info[i].col_format,
col_info[i].col_type,
col_info[i].col_len,
col_info[i].nullable,
col_info[i].decimal_total_digits,
col_info[i].decimal_fraction_digits);
} /* End of output_col_info */
/**************************************************************************************/
short add_col_info(char in_buf[], int in_len,
col_info_def col_info[], int *num_cols)
/**************************************************************************************/
{ /* Start of add_col_info */
short temp;
int i;
/* Move the values */
i = *num_cols;
temp = 1;
memcpy(col_info[i].col_name,&in_buf[temp],COL_NAME_LEN);
temp += COL_NAME_LEN;
upshift(col_info[i].col_name,COL_NAME_LEN);
memcpy(col_info[i].col_format,&in_buf[temp],COL_FORMAT_LEN);
temp += COL_FORMAT_LEN;
memcpy(col_info[i].col_type,&in_buf[temp],COL_TYPE_LEN);
temp += COL_TYPE_LEN;
memcpy((char *)&col_info[i].col_len,&in_buf[temp],4);
temp += 4;
col_info[i].nullable = in_buf[temp++];
if ((memcmp(col_info[i].col_type,"D ",2)) == 0)
{ /* Decimal Field */
memcpy((char*)&col_info[i].decimal_total_digits,&in_buf[temp],2);
temp += 2;
memcpy((char*)&col_info[i].decimal_fraction_digits,&in_buf[temp],2);
temp += 2;
} /* End of Decimal Field */
else
{ /* Not a Decimal Field */
col_info[i].decimal_total_digits = 0;
col_info[i].decimal_fraction_digits = 0;
} /* End of not a Decimal Field */
(*num_cols)++;
return(0); /* All OK */
} /* End of add_col_info */
/**************************************************************************************/
short format_output(char in_buf[],int *in_len,
char out_buf[],int *out_len,
col_info_def col_info[], int num_cols)
/**************************************************************************************/
{ /* Start of format_output */
register short i,j;
short stemp,
temp,
temp2;
unsigned short ustemp;
unsigned int uitemp;
int offset,
len,
itemp;
double ftemp;
char c_temp[129];
unsigned char uc_temp;
len = 0;
offset = (num_cols + 7) / 8;
for (i = 0; i < num_cols; i++)
{ /* Loop through the columns */
#ifdef DBUG
printf("Col = %i ",i);
#endif
/******************************************************************************/
if (skip_col(col_info,i))
{ /* Skip it */
offset += col_info[i].col_len;
} /* End of skip it */
else
/******************************************************************************/
if (null_col(in_buf,i))
{ /* Null Field */
// memcpy(&out_buf[len],"**NULL**",8);
// len += 8;
out_buf[len++] = '\t';
if (((memcmp(col_info[i].col_type,"BV",2)) == 0)
|| ((memcmp(col_info[i].col_type,"CV",2)) == 0)
|| ((memcmp(col_info[i].col_type,"I1",2)) == 0))
offset += 2;
else
if (((memcmp(col_info[i].col_type,"TS",2)) == 0)
&& (col_info[i].col_len == 10))
offset += 19; /* Kluge for Timestamp(0) */
else
offset += col_info[i].col_len;
} /* End of Null Field */
else
/******************************************************************************/
if (((memcmp(col_info[i].col_name,"CURR_NAT_STK_NR",16)) == 0)
|| ((memcmp(col_info[i].col_name,"SUBGRP_MSTR_NSN",16)) == 0))
{ /* Special for D200A */
#ifdef DBUG
memcpy(c_temp,&in_buf[offset],col_info[i].col_len);
c_temp[col_info[i].col_len] = '\0';
printf("%s ",c_temp);
#endif
temp = col_info[i].col_len;
if (temp > 4)
temp = 4;
temp2 = 1;
if (temp > 1)
{
for (j = 1; j < temp; j++)
if (in_buf[offset + j] != ' ')
temp2 = j + 1;
memcpy(&out_buf[len],&in_buf[offset],temp2);
len += temp2;
offset += temp;
}
out_buf[len++] = '\t';
temp = col_info[i].col_len - 4;
if (temp > 9)
temp = 9;
temp2 = 1;
if (temp > 1)
{
for (j = 1; j < temp; j++)
if (in_buf[offset + j] != ' ')
temp2 = j + 1;
memcpy(&out_buf[len],&in_buf[offset],temp2);
len += temp2;
offset += temp;
}
out_buf[len++] = '\t';
temp = col_info[i].col_len - 13;
if (temp > 2)
temp = 2;
temp2 = 1;
if (temp > 1)
{
for (j = 1; j < temp; j++)
if (in_buf[offset + j] != ' ')
temp2 = j + 1;
memcpy(&out_buf[len],&in_buf[offset],temp2);
len += temp2;
offset += temp;
}
out_buf[len++] = '\t';
} /* End of special for D200A */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"AT",2)) == 0)
{ /* Time Field */
temp = col_info[i].col_len;
if (temp > 8)
temp = 8; /* Oracle only supports up to time to seconds */
memcpy(&out_buf[len],&in_buf[offset],temp);
len += temp;
offset += col_info[i].col_len;
out_buf[len++] = '\t';
} /* End of Time Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"BF",2)) == 0)
{ /* Byte Fixed */
temp = col_info[i].col_len;
memset(c_temp,'\0',3);
for (j = 0; j < temp; j++)
{
uc_temp = in_buf[offset];
ustemp = uc_temp;
uitemp = ustemp;
sprintf(&out_buf[len],"%2.2X",uitemp);
len += 2;
offset++;
}
out_buf[len++] = '\t';
} /* End of Byte Fixed */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"BV",2)) == 0)
{ /* Byte Variable */
temp = col_info[i].col_len;
memcpy(&stemp,&in_buf[offset],2);
offset += 2;
if (stemp < temp)
temp = stemp;
for (j = 0; j < temp; j++)
{
uc_temp = in_buf[offset];
ustemp = uc_temp;
uitemp = ustemp;
sprintf(&out_buf[len],"%2.2X",uitemp);
len += 2;
offset++;
}
out_buf[len++] = '\t';
} /* End of Byte Variable */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"CF",2)) == 0)
{ /* Character Fixed */
temp = col_info[i].col_len;
temp2 = 1;
if (temp > 1)
for (j = 1; j < temp; j++)
if (in_buf[offset + j] != ' ')
temp2 = j + 1;
memcpy(&out_buf[len],&in_buf[offset],temp2);
len += temp2;
offset += col_info[i].col_len;
out_buf[len++] = '\t';
} /* End of Character Fixed */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"CV",2)) == 0)
{ /* Character Variable */
temp = col_info[i].col_len;
memcpy(&stemp,&in_buf[offset],2);
offset += 2;
if (stemp > temp)
stemp = temp;
temp2 = 1;
if (stemp > 1)
for (j = 1; j < stemp; j++)
if (in_buf[offset + j] != ' ')
temp2 = j + 1;
memcpy(&out_buf[len],&in_buf[offset],temp2);
len += temp2;
offset += stemp;
out_buf[len++] = '\t';
} /* End of Character Variable */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"D ",2)) == 0)
{ /* Decimal Field */
temp = col_info[i].col_len;
memset(c_temp,'\0',129);
switch (temp)
{ /* Start of switch */
case 1:
format_decimal_1(&in_buf[offset],&col_info[i],c_temp);
break;
case 2:
format_decimal_2(&in_buf[offset],&col_info[i],c_temp);
break;
case 4:
format_decimal_4(&in_buf[offset],&col_info[i],c_temp);
break;
case 8:
format_decimal_8(&in_buf[offset],&col_info[i],c_temp);
break;
default:
printf("ERROR Invalid Decimal Field Type %i\n",col_info[i].col_len);
break;
} /* End of switch */
temp = strlen(c_temp);
temp2 = 1;
for (j = 1; j < temp; j++)
if (c_temp[j] > ' ')
temp2 = j + 1;
memcpy(&out_buf[len],c_temp,temp2);
len += temp2;
offset += col_info[i].col_len;
out_buf[len++] = '\t';
} /* End of Decimal Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"DA",2)) == 0)
{ /* Date Field */
memcpy((char *) &itemp,&in_buf[offset],4);
offset += 4;
memset(c_temp,'\0',20);
itemp += 19000000;
sprintf(c_temp,"%i",itemp);
memcpy(&out_buf[len],c_temp,4);
len += 4;
out_buf[len++] = '-';
memcpy(&out_buf[len],&c_temp[4],2);
len += 2;
out_buf[len++] = '-';
memcpy(&out_buf[len],&c_temp[6],2);
len += 2;
out_buf[len++] = '\t';
} /* End of Date Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"F ",2)) == 0)
{ /* Float Field */
memcpy((char *) &ftemp,&in_buf[offset],8);
offset += 8;
memset(c_temp,'\0',129);
sprintf(c_temp,"%f",ftemp);
temp = strlen(c_temp);
temp2 = 0;
for (j = 0; j < temp; j++)
{
if (c_temp[j] == '.')
temp2 = j + 1;
else
if ((temp2 != 0) && (c_temp[j] != '0'))
temp2 = j;
}
if (temp2 < (short) strlen(c_temp))
temp2++;
memcpy(&out_buf[len],c_temp,temp2);
len += temp2;
out_buf[len++] = '\t';
} /* End of Float Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"I ",2)) == 0)
{ /* Integer Field */
memcpy((char *) &itemp,&in_buf[offset],4);
offset += 4;
memset(c_temp,'\0',20);
sprintf(c_temp,"%i",itemp);
memcpy(&out_buf[len],c_temp,strlen(c_temp));
len += strlen(c_temp);
out_buf[len++] = '\t';
} /* End of Integer Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"I1",2)) == 0)
{ /* Integer 1-Byte Field */
uc_temp = in_buf[offset];
offset += 1;
memset(c_temp,'\0',20);
stemp = uc_temp;
itemp = stemp;
sprintf(c_temp,"%i",itemp);
memcpy(&out_buf[len],c_temp,strlen(c_temp));
len += strlen(c_temp);
out_buf[len++] = '\t';
} /* End of Integer 1-Byte Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"I2",2)) == 0)
{ /* Integer 2-Byte Field */
memcpy((char *) &stemp,&in_buf[offset],2);
offset += 2;
memset(c_temp,'\0',20);
itemp = stemp;
sprintf(c_temp,"%i",itemp);
memcpy(&out_buf[len],c_temp,strlen(c_temp));
len += strlen(c_temp);
out_buf[len++] = '\t';
} /* End of Integer 2-Byte Field */
else
/******************************************************************************/
if ((memcmp(col_info[i].col_type,"TS",2)) == 0)
{ /* Timestamp Field */
temp = col_info[i].col_len;
if (temp > 19)
temp = 19; /* Oracle only supports up to timestamp(0) */
if (temp == 10)
temp = 19; /* Kluge for timestamp(0) */
memcpy(&out_buf[len],&in_buf[offset],temp);
for (j = 0; j < temp; j++)
if (out_buf[len + j] == '/')
out_buf[len + j] = '-'; /* Fix Timestamp Format */
len += temp;
/* Patch to handle Teradata load problem with 60 as the seconds value */
if ((memcmp(&out_buf[len-2],"60",2)) == 0)
memcpy(&out_buf[len-2],"59",2);
out_buf[len++] = '\t';
if (col_info[i].col_len == 10)
offset += 19; /* Kluge for timestamp(0) */
else
offset += col_info[i].col_len;
} /* End of Timestamp Field */
else
/******************************************************************************/
{ /* Unknown Field Type */
printf("ERROR Unknown Field Type %2.2s\n",col_info[i].col_type);
out_buf[len++] = '\t';
} /* End of Unknown Field Type */
} /* End of loop through the columns */
/* Save the length while killing the last tab */
*out_len = len -1;
if (*out_len <= *in_len)
{
memcpy(in_buf,out_buf,*out_len);
*in_len = *out_len;
}
return(0); /* All OK */
} /* End of format_output */
/**************************************************************************************/
__declspec(dllexport) unsigned long int _dynamn(int *entry_code,
int *stmnt_num,
int *in_len,
char *in_buf,
int *out_len,
char *out_buf)
/**************************************************************************************/
{ /* Start of _dynamn */
static col_info_def *col_info_ptr;
static int num_cols,
min_out_len,
max_out_len;
static short first_col_def,
first_data;
short error;
switch (*entry_code)
{ /* Start of switch */
case 1: /* Initialize */
{
col_info_ptr = malloc (256 * sizeof(col_info_def));
num_cols = 0;
first_col_def = TRUE;
first_data = TRUE;
min_out_len = 999999999;
max_out_len = 0;
#ifdef DBUG
printf("Initialize ");
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i ",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
#endif
break;
}
case 2: /* Cleanup */
{
#ifdef DBUG
printf("Min Outlen = %i Max Outlen = %i\n",min_out_len,max_out_len);
#endif
free(col_info_ptr);
num_cols = 0;
#ifdef DBUG
printf("Cleanup ");
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i ",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
#endif
break;
}
case 3: /* Process Data */
{
if (out_buf == NULL)
{
printf("Outbuf is NULL\n");
*in_len = *out_len = 0;
return(SERIOUS_ERROR);
}
if ((*stmnt_num % 2) == 1)
{
if (first_col_def)
{ /* First column definition */
num_cols = 0;
first_col_def = FALSE;
first_data = TRUE;
} /* End of first column definition */
error = add_col_info(in_buf,*in_len,col_info_ptr,&num_cols);
*in_len = *out_len = 0; /* Kill the buffer */
if (error != 0)
return(SERIOUS_ERROR);
}
else
if ((*stmnt_num % 2) == 0)
{
if (num_cols < 1)
{
printf("ERROR - NO COLUMNS\n");
return(SERIOUS_ERROR);
}
if (first_data)
{
first_col_def = TRUE;
#ifdef DBUG
printf("Process Data ");
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
output_col_info(col_info_ptr,num_cols);
bp_hex_dump(in_buf,*in_len);
#endif
}
error = format_output(in_buf,in_len,out_buf,out_len,col_info_ptr,num_cols);
if (error != 0)
{
*out_len = *in_len = 0;
return(SERIOUS_ERROR);
}
#ifdef BPHEXDUMP
if (first_data)
bp_hex_dump(out_buf,*out_len);
#endif
#ifdef DBUG
if (*out_len < min_out_len)
min_out_len = *out_len;
if (*out_len > max_out_len)
max_out_len = *out_len;
#endif
if (*out_len <= *in_len)
memcpy(in_buf,out_buf,*out_len);
first_data = FALSE;
}
else
{
return(SERIOUS_ERROR);
}
break;
}
case 4: /* Checkpoint */
{
#ifdef DBUG
printf("Checkpoint ");
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i ",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
#endif
break;
}
case 5: /* DBC Restart - Close and Re-open Files */
{
#ifdef DBUG
printf("DBC Restart ");
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i ",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
#endif
break;
}
case 6: /* Host Restart */
{
#ifdef DBUG
printf("Host Restart ");
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i ",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
#endif
break;
}
default: /* Invalid entry_code */
{
printf("Invalid Entry Code code = %i ",*entry_code);
#ifdef DBUG
if (stmnt_num == NULL)
printf("NO stmnt_num ");
else
printf("stmnt_num = %i ",*stmnt_num);
if (in_len == NULL)
printf("NO in_len ");
else
printf("in_len = %i ",*in_len);
if (out_len == NULL)
printf("NO out_len\n");
else
printf("out_len = %i\n",*out_len);
#endif
return(SERIOUS_ERROR);
break;
}
} /* End of switch */
return(0);
} /* End of _dynamn */
| |