⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_tpcc.c

📁 oracle数据库tpcc(在线事务处理能力)测试的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
void PutHTMLStrings( pPutStrStruct pStruct,char *szInput, int iInputSize,
	char **szOutput, int *iOutputSize )
{
   char *pIChar;
   char *pOChar;
   int iFieldSize;
   while( NULL != pStruct->szStr )
   {
      pIChar = pStruct->szStr;
      pOChar = szInput + pStruct->iIndex;
      iFieldSize = pStruct->iFieldSize;
      while( 0 != *pIChar && iFieldSize )
      {
/* '>' is the highest ACSII value of the special characters.*/
/* If '>' is greater than the character is question, check further. */
	 if( '>' > *pIChar )
	 {
	    if( '"' == *pIChar || '&' == *pIChar || '<' == *pIChar || '>' == *pIChar )
	    {
/* We have found at least one special character in the desired */
/* output string, go the the more expensive routine to build */
/* the desired output string. */
		HandlePanic( pStruct, szInput, iInputSize, szOutput,iOutputSize );
		return;
	    }
	    else
		*pOChar = *pIChar;
	 }
	 else
		*pOChar = *pIChar;
	 pIChar++;
	 pOChar++;
	 iFieldSize--;
      }
/* Fill in the remaining spaces in the field with blanks. */
      while( iFieldSize-- )
      *pOChar++ = ' ';
      pStruct++;
   }
/* The output string is the template and the length is unchanged
*/
   *szOutput = szInput;
   *iOutputSize = iInputSize;
   return;
}
/* FUNCTION: void TPCCDeliveryResponse( request_rec *req,
* int retcode,
* DeliveryData *deliveryData )
*
* PURPOSE: This function fills in the values and returns the
* response form to the browser.
*
* ARGUMENTS: request_rec *req
* int retcode return code from db
* DeliveryData *deliveryData pointer to the delivery
* data structure.
*
* RETURNS: none
*
* COMMENTS: none
*/
void TPCCDeliveryResponse( int retcode, pDeliveryData pDelivery,pDeliveryData
			   CompletedDeliveries[DELIVERY_RESPONSE_COUNT] )
{
   int ssCnt = 0;
   char *szOutput;
   int iOutputLen;
   PutStrStruct StrStruct[2];
   char *deliveryForm;
   request_rec *req;
   req = pDelivery->pCC;
   if ( ERR_DB_PENDING == retcode )
   {
	return;
   }
   else if ( ERR_DB_DEADLOCK_LIMIT == retcode )
   {
	SendErrorResponse( req, ERR_DELIVERY_NOT_PROCESSED,ERR_TYPE_WEBDLL, NULL,
			   pDelivery->w_id, pDelivery->ld_id,(pConnData)pDelivery );
	return;
   }
   else if ( ERR_DB_SUCCESS != retcode )
   {
	SendErrorResponse( req, ERR_DB_DELIVERY_NOT_QUEUED,ERR_TYPE_WEBDLL, NULL,
			   pDelivery->w_id, pDelivery->ld_id,(pConnData)pDelivery );
	return;
   }
   RESERVE_RESPONSE( DELIVERY_RESPONSE, deliveryForm );
   PutNumeric(WDID(pDelivery->w_id,pDelivery->ld_id),deliveryFormIndexesP[D_WDID].iLen,
		&deliveryForm[deliveryFormIndexesP[D_WDID].iStartIndex]);
   PutNumeric(pDelivery->w_id,deliveryFormIndexesP[D_WID].iLen,
		&deliveryForm[deliveryFormIndexesP[D_WID].iStartIndex]);
   PutNumeric(pDelivery->o_carrier_id,deliveryFormIndexesP[D_CAR].iLen,
		&deliveryForm[deliveryFormIndexesP[D_CAR].iStartIndex]);
   UNRESERVE_TRANSACTION_STRUCT( DELIVERY_TRANS, pDelivery );
   PUT_STRING(NULL, 0, 0, StrStruct[ssCnt]);
   PutHTMLStrings(StrStruct, deliveryForm,giResponseLen[DELIVERY_RESPONSE],
		&szOutput, &iOutputLen);
   SendResponse(req, szOutput, iOutputLen);
   UNRESERVE_RESPONSE( DELIVERY_RESPONSE, deliveryForm );
   if( szOutput != deliveryForm )
	UNRESERVE_PANIC_FORM( szOutput );
}
/* FUNCTION: void TPCCNewOrderResponse(request_rec *req,
* int retcode,
* NewOrderData *newOrderData )
*
* PURPOSE: This function fills in the values and returns the
* response form to the browser.
*
* ARGUMENTS: request_rec *req pointer to the structure
* that contains the internet
* service information.
* int retcode return status from the db.
* NewOrderData *newOrderData pointer to structure containing
* data about the current txn.
*
* RETURNS: none
*
* COMMENTS: none
*/
void TPCCNewOrderResponse( int retcode, pNewOrderData pNewOrder )
{
   int i;
   char szDate[] = "xx-xx-xxxx xx:xx:xx";
   char szBlanks[] = " ";
   char szDollar[] = "$";
   PutStrStruct StrStruct[133];
   int ssCnt = 0;
   int jj;
   int kk;
   int mm;
   char *newOrderForm;
   char *szOutput;
   int iOutputLen;
   BOOL bValid;
   char *execution_status;
   char szStatus[80];
   request_rec *req;
   req = pNewOrder->pCC;
   if ( ERR_DB_PENDING == retcode )
   {
	return;
   }
   else if ( ERR_DB_DEADLOCK_LIMIT == retcode )
   {
	SendErrorResponse( req, ERR_NEW_ORDER_NOT_PROCESSED,
			   ERR_TYPE_WEBDLL, NULL,
			   pNewOrder->w_id, pNewOrder->ld_id,
			   (pConnData)pNewOrder );
	return;
   }
   else if( ERR_DB_SUCCESS != retcode && ERR_DB_NOT_COMMITED != retcode )
   {
	sprintf( szStatus,"Item number is not valid, or DB error = %d",
		pNewOrder->dbstatus );
	SendErrorResponse( req, ERR_DB_ERROR,ERR_TYPE_WEBDLL, NULL,
			   pNewOrder->w_id, pNewOrder->ld_id,
			   (pConnData)pNewOrder );
	return;
   }
   else if ( ERR_DB_SUCCESS == retcode )
   {
	bValid = TRUE;
	execution_status = "Transaction commited.";
   }
   else if ( ERR_DB_NOT_COMMITED == retcode )
   {
	bValid = FALSE;
	execution_status = "Item number is not valid.";
   }
   RESERVE_RESPONSE( NEW_ORDER_RESPONSE, newOrderForm );
   if(bValid)
   {
      PutNumeric(WDID(pNewOrder->w_id,pNewOrder->ld_id),
         newOrderResponseIndexes[NO_WDID].iLen,
         &newOrderForm[newOrderResponseIndexes[NO_WDID].iStartIndex]);
      PutNumeric(pNewOrder->w_id,newOrderResponseIndexes[NO_WID].iLen,
         &newOrderForm[newOrderResponseIndexes[NO_WID].iStartIndex]);
      PutNumeric(pNewOrder->d_id,newOrderResponseIndexes[NO_DID].iLen,
         &newOrderForm[newOrderResponseIndexes[NO_DID].iStartIndex]);
/* put the date in if valid */
      PutNumeric(pNewOrder->o_entry_d.day, 2, &szDate[0]);
      PutNumeric(pNewOrder->o_entry_d.month, 2, &szDate[3]);
      PutNumeric(pNewOrder->o_entry_d.year, 4, &szDate[6]);
      PutNumeric(pNewOrder->o_entry_d.hour, 2, &szDate[11]);
      PutNumeric(pNewOrder->o_entry_d.minute, 2, &szDate[14]);
      PutNumeric(pNewOrder->o_entry_d.second, 2, &szDate[17]);
      memcpy(&newOrderForm[newOrderResponseIndexes[NO_DATE].iStartIndex],
   	  szDate, newOrderResponseIndexes[NO_DATE].iLen);
   }
   else
   {
/* put in blanks for the date if not valid */
      memcpy(&newOrderForm[newOrderResponseIndexes[NO_DATE].iStartIndex],
	szBlanks, newOrderResponseIndexes[NO_DATE].iLen);
   }
/* put in value for the customer id. */
   PutNumeric(pNewOrder->c_id,newOrderResponseIndexes[NO_CID].iLen,
	      &newOrderForm[newOrderResponseIndexes[NO_CID].iStartIndex]);
/* put in the values for the last name and credit rating */
   PUT_STRING(pNewOrder->c_last,newOrderResponseIndexes[NO_LAST].iLen,
	      newOrderResponseIndexes[NO_LAST].iStartIndex,StrStruct[ssCnt]);
   ssCnt++;
   PUT_STRING(pNewOrder->c_credit,newOrderResponseIndexes[NO_CREDIT].iLen,
	      newOrderResponseIndexes[NO_CREDIT].iStartIndex,StrStruct[ssCnt]);
   ssCnt++;
   if(bValid)
   {
/* put in the values */
	PutFloat2(pNewOrder->c_discount,newOrderResponseIndexes[NO_DISC].iLen,
		 &newOrderForm[newOrderResponseIndexes[NO_DISC].iStartIndex]);
	PutNumeric(pNewOrder->o_id,newOrderResponseIndexes[NO_OID].iLen,
		 &newOrderForm[newOrderResponseIndexes[NO_OID].iStartIndex]);
	PutNumeric(pNewOrder->o_ol_cnt,newOrderResponseIndexes[NO_LINES].iLen,
		 &newOrderForm[newOrderResponseIndexes[NO_LINES].iStartIndex]);
	PutFloat2(pNewOrder->w_tax,newOrderResponseIndexes[NO_W_TAX].iLen,
		 &newOrderForm[newOrderResponseIndexes[NO_W_TAX].iStartIndex]);
	PutFloat2(pNewOrder->d_tax,newOrderResponseIndexes[NO_D_TAX].iLen,
		 &newOrderForm[newOrderResponseIndexes[NO_D_TAX].iStartIndex]);
	for(i=0; i<pNewOrder->o_ol_cnt; i++)
	{
	   PutNumeric(pNewOrder->o_ol[i].ol_supply_w_id,
	     newOrderResponseIndexes[NO_S_WID+(i*8)].iLen,
	     &newOrderForm[newOrderResponseIndexes[NO_S_WID+(i*8)].iStartIndex]);
	   PutNumeric(pNewOrder->o_ol[i].ol_i_id,newOrderResponseIndexes[NO_IID+(i*8)].iLen,
	     &newOrderForm[newOrderResponseIndexes[NO_IID+(i*8)].iStartIndex]);
	   PUT_STRING(pNewOrder->o_ol[i].i_name,newOrderResponseIndexes[NO_INAME+(i*8)].iLen,
	     newOrderResponseIndexes[NO_INAME+(i*8)].iStartIndex,StrStruct[ssCnt]);
	   ssCnt++;
	   PutNumeric(pNewOrder->o_ol[i].ol_quantity,
	      newOrderResponseIndexes[NO_QTY+(i*8)].iLen,
	      &newOrderForm[newOrderResponseIndexes[NO_QTY+(i*8)].iStartIndex]);
           PutNumeric(pNewOrder->o_ol[i].s_quantity,
	      newOrderResponseIndexes[NO_STOCK+(i*8)].iLen,
	      &newOrderForm[newOrderResponseIndexes[NO_STOCK+(i*8)].iStartIndex]);
	   PUT_STRING(pNewOrder->o_ol[i].b_g,
	      newOrderResponseIndexes[NO_BG+(i*8)].iLen,
	      newOrderResponseIndexes[NO_BG+(i*8)].iStartIndex,StrStruct[ssCnt]);
	   ssCnt++;
	   memcpy(&newOrderForm[newOrderResponseIndexes[NO_PRICE+(i*8)].iStartIndex-1],szDollar, 1);
	   PutFloat2(pNewOrder->o_ol[i].i_price,
	      newOrderResponseIndexes[NO_PRICE+(i*8)].iLen,
	      &newOrderForm[newOrderResponseIndexes[NO_PRICE+(i*8)].iStartIndex]);
	   memcpy(&newOrderForm[newOrderResponseIndexes[NO_AMT+(i*8)].iStartIndex-1],szDollar, 1);
	   PutFloat2(pNewOrder->o_ol[i].ol_amount,
	      newOrderResponseIndexes[NO_AMT+(i*8)].iLen,
	      &newOrderForm[newOrderResponseIndexes[NO_AMT+(i*8)].iStartIndex]);
        }
/* need to blank out the rest of the unused item rows */
       jj = NO_AMT + ((i-1)*8) + 1;
       for(kk=i; kk<15; kk++)
       {
/* there are 8 items per row - 6 plain and 2 with $*/
          for(mm=0; mm<6; mm++)
          {
	     memcpy(&newOrderForm[newOrderResponseIndexes[jj].iStartIndex],
		 szBlanks, newOrderResponseIndexes[jj].iLen);
	     jj++;
          }
/* blank out the '$' for the blank $values */
          for(mm=0; mm<2; mm++)
          {
	     memcpy(&newOrderForm[newOrderResponseIndexes[jj].iStartIndex-1],
		 szBlanks, newOrderResponseIndexes[jj].iLen+1);
	     jj++;
          }
      }
   }
   else
   {
/* will need to blank out any fields not entered when not valid
*/
/* space for discount */
       memcpy(&newOrderForm[newOrderResponseIndexes[NO_DISC].iStartIndex],
		szBlanks, newOrderResponseIndexes[NO_DISC].iLen);
/*the actual order number */
       PutNumeric(pNewOrder->o_id,newOrderResponseIndexes[NO_OID].iLen,
		&newOrderForm[newOrderResponseIndexes[NO_OID].iStartIndex]);
/* space for number of lines, w_tax, and d_tax */
       for(kk=0; kk<3; kk++)
       {
	  memcpy(&newOrderForm[newOrderResponseIndexes[NO_LINES+kk].iStartIndex],
		szBlanks,newOrderResponseIndexes[NO_LINES+kk].iLen);
       }
/* spaces for each of the fields in the row items */
       jj = NO_S_WID;
       for(kk=0; kk<15; kk++)
       {
/* there are 8 items per row - 6 plain and 2 with $*/
	   for(mm=0; mm<6; mm++)
	   {
	      memcpy(&newOrderForm[newOrderResponseIndexes[jj].iStartIndex],
		szBlanks, newOrderResponseIndexes[jj].iLen);
	      jj++;
	   }
/* blank out the '$' for the blank $values */
	   for(mm=0; mm<2; mm++)
	   {
	      memcpy(&newOrderForm[newOrderResponseIndexes[jj].iStartIndex-1],
		szBlanks, newOrderResponseIndexes[jj].iLen+1);
		jj++;
	   }
       }
   }
/* output the execution status */
   PUT_STRING(execution_status,   newOrderResponseIndexes[NO_STAT].iLen,
   	      newOrderResponseIndexes[NO_STAT].iStartIndex,StrStruct[ssCnt]);
   ssCnt++;
   if(bValid)
   {
/* total */
      PutFloat2(pNewOrder->total_amount,newOrderResponseIndexes[NO_TOTAL].iLen,
                &newOrderForm[newOrderResponseIndexes[NO_TOTAL].iStartIndex]);
   }
   else
   {
/* put blanks for total */
      memcpy(&newOrderForm[newOrderResponseIndexes[NO_TOTAL].iStartIndex],
		szBlanks, newOrderResponseIndexes[NO_TOTAL].iLen);
   }
   PUT_STRING(NULL, 0, 0, StrStruct[ssCnt]);
   PutHTMLStrings(StrStruct, newOrderForm,giResponseLen[NEW_ORDER_RESPONSE],
   		  &szOutput, &iOutputLen);
   #ifdef FFE_DEBUG
	pNewOrder->iStage |= UNRESERVING;
   #endif
   UNRESERVE_TRANSACTION_STRUCT( NEW_ORDER_TRANS, pNewOrder );
   SendResponse(req, szOutput, iOutputLen);
   UNRESERVE_RESPONSE( NEW_ORDER_RESPONSE, newOrderForm );
   if( szOutput != newOrderForm )
      UNRESERVE_PANIC_FORM( szOutput );
}
/* FUNCTION: void TPCCPaymentResponse(request_rec *req,
* int retcode,
* PaymentData *paymentData)
*
* PURPOSE: This function fills in the values and returns the
* response form to the browser.
*
* ARGUMENTS: request_rec *req pointer to structure that
* contains internet service
* information.
* int retcode return status from the db call
* PaymentData *paymentData pointer to structure containing
* the data for this transaction.
*
* RETURNS: none
*
* COMMENTS: none
*/
void TPCCPaymentResponse( int retcode, pPaymentData pPayment )
{
   char *ptr;
   char szcdata[4][64];
   char szW_Zip[26];
   char szD_Zip[26];
   char szC_Zip[26];
   char szC_Phone[26];
   int i;
   int l;
   char *szZipPic = "XXXXX-XXXX";
   char szLongDate[] = "XX-XX-XXXX XX:XX:XX";
   char szDate[] = "xx-xx-xxxx";
   char szBlanks[] = "";
   PutStrStruct StrStruct[34];
   int ssCnt = 0;
   char *paymentForm;
   char *szOutput;
   int iOutputLen;
   request_rec *req;
   req = pPayment->pCC;
   if ( ERR_DB_PENDING == retcode )
   {
	return;
   }
   else if ( ERR_DB_DEADLOCK_LIMIT == retcode )
   {
	SendErrorResponse( req, ERR_PAYMENT_NOT_PROCESSED,
		ERR_TYPE_WEBDLL, NULL,pPayment->w_id, pPayment->ld_id,
		(pConnData)pPayment );
	return;
   }
   else if ( ERR_DB_NOT_COMMITED == retcode )
   {
	SendErrorResponse( req, ERR_PAYMENT_INVALID_CUSTOMER,
		ERR_TYPE_WEBDLL, NULL,pPayment->w_id, pPayment->ld_id,
		(pConnData)pPayment );
	return;
   }
   else if ( ERR_DB_SUCCESS != retcode )
   {
	SendErrorResponse( req, ERR_DB_ERROR,ERR_TYPE_WEBDLL, NULL,
		pPayment->w_id, pPayment->ld_id,(pConnData)pPayment );
	return;
   }
   RESERVE_RESPONSE( PAYMENT_RESPONSE, paymentForm );
   PutNumeric(WDID(pPayment->w_id,pPayment->ld_id),paymentResponseIndexes[PT_WDID].iLen,
		&paymentForm[paymentResponseIndexes[PT_WDID].iStartIndex]);
   PutNumeric(pPayment->h_date.day, 2,&szLongDate[0]);
   PutNumeric(pPayment->h_date.month, 2,&szLongDate[3]);
   PutNumeric(pPayment->h_date.year, 4,&szLongDate[6]);
   PutNumeric(pPayment->h_date.hour, 2,&szLongDate[11]);
   PutNumeric(pPayment->h_date.minute, 2,&szLongDate[14]);
   PutNumeric(pPayment->h_date.second, 2,&szLongDate[17]);
   memcpy(&paymentForm[paymentResponseIndexes[PT_LONG_DATE].iStartIndex],
	szLongDate, paymentResponseIndexes[PT_LONG_DATE].iLen);
   PutNumeric(pPayment->w_id,paymentResponseIndexes[PT_WID].i

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -