t_int32 PSPReturnXMLError (PSPTransactionId_t * pTrSet, DOM XMLNode) { t_int32 iErrCode; t_char8 *pXmlBuffer = NULL; if (!XMLNode) { return CNTRLXML_BADPARAM; } if ((iErrCode = CNTRLXMLtoBuffer (XMLNode, &pXmlBuffer)) != CNTRLXML_SUCCESS) { XML_Error ("Failed to load result DOM."); return CNTRLXML_FAILURE; } if ((iErrCode = PSPReturnXMLErrorString (pTrSet, pXmlBuffer)) != CNTRLXML_SUCCESS) { XML_Error ("PSPReturnXMLErrorString Failed"); } XML_DebugArg ("pXmlBuffer=", pXmlBuffer); XMLBUFFERFREE (pXmlBuffer); return CNTRLXML_SUCCESS; }
/*********************************************************************** * Function Name : CNTRLXMLGETReqHandler * Description : This function calls the registered callback functions against the XML file URL * Input : regUrl - XML file URL * pOutXMLStr - Response XML buffer * Output : none * Return value : CNTRLXML_SUCCESS, CNTRLXML_FAILURE, CNTRLXML_BADPARAM ***********************************************************************/ t_char8 CNTRLXMLGETReqHandler (t_char8 * pInXMLFile, t_void * pAppData, t_char8 ** pOutXMLStr) { XMLTEMPLATE_CALLBACK_HANDLER pCbfun; t_int32 retStatus = CNTRLXML_SUCCESS; if (!pInXMLFile) { XML_Error ("pInXMLFile is NULL"); return CNTRLXML_BADPARAM; } XML_DebugArg ("Look up for tag = ", pInXMLFile); pCbfun = xmlHashLookup (hTable, pInXMLFile); if (pCbfun != NULL) { XML_DebugArg ("Found function for tag =", pInXMLFile); retStatus = (*pCbfun) (pInXMLFile, pAppData); if (retStatus != CNTRLXML_SUCCESS) { XML_Error ("GET Request CbkFunction Failed"); if(pXMLErrorStr) { *pOutXMLStr = xmlStrdup ((const xmlChar *) pXMLErrorStr); XML_DebugArg ("*pOutXMLStr=", *pOutXMLStr); XMLBUFFERFREE (pXMLErrorStr); pXMLErrorStr = NULL; return CNTRLXML_SUCCESS; } *pOutXMLStr = NULL; return CNTRLXML_FAILURE; } /**pOutXMLStr = (t_char8*) T_malloc(T_strlen(pXMLResultStr)+1); of_strcpy(*pOutXMLStr, pXMLResultStr);*/ *pOutXMLStr = xmlStrdup ((const xmlChar *) pXMLResultStr); XML_DebugArg ("*pOutXMLStr=", *pOutXMLStr); XMLBUFFERFREE (pXMLResultStr); pXMLResultStr = NULL; return CNTRLXML_SUCCESS; } return CNTRLXML_FAILURE; }
/*********************************************************************** * Function Name : PSPReturnXMLResultString * Description : This function appends given result XML string(xmlStr) * to the Result XML buffer. * Input : pTrSet - Transaction Set * xmlStr - Result XML string to be appended * Output : none * Return value : CNTRLXML_SUCCESS, CNTRLXML_BADPARAM, CNTRLXML_FAILURE ***********************************************************************/ t_int32 PSPReturnXMLResultString (PSPTransactionId_t * pTrSet, XML_STR pInXMLStr) { t_char8 xmlDeclare[] = "<?xml version=\"1.0\"encoding=\"UTF-8\"?>\n<result><Transaction status=\'ok\'>"; t_char8 xmlEndDecl[] = "</Transaction></result>"; if (!pInXMLStr) { XML_Error ("BAD Input Parameters"); return CNTRLXML_BADPARAM; } if (IsValidTransaction (pTrSet)) { /* * Transaction based XML processing. */ if (pXMLResultStr == NULL) { pXMLResultStr = xmlStrdup ((const xmlChar *) xmlDeclare); } if (!pTransList) /*If no transaction in progress */ { pXMLResultStr = xmlStrcat (pXMLResultStr, (const xmlChar *) pInXMLStr); pXMLResultStr = xmlStrcat (pXMLResultStr, (const xmlChar *) xmlEndDecl); } else { pXMLResultStr = xmlStrcat (pXMLResultStr, (const xmlChar *) pInXMLStr); } } else { /* * Non-Transaction XML processing. */ XML_Debug ("Non-Transaction based XML processing"); /* XML_DebugArg ("pInXMLStr =", pInXMLStr);*/ if (pXMLResultStr == NULL || T_strnicmp (pInXMLStr, "<html>", 6) == 0) { pXMLResultStr = xmlStrdup ((const xmlChar *) pInXMLStr); } else { if (T_strnicmp (pXMLResultStr, "<html>", 6) != 0) pXMLResultStr = xmlStrcat (pXMLResultStr, (const xmlChar *) pInXMLStr); } } return CNTRLXML_SUCCESS; }
/********************************************************************** * Function Name: PSPInitXmlModsetTable * Desription : This functions Initializes the HashTable for Modset * Input : None * Output : xmlHashTableptr * Return Value : None ***********************************************************************/ t_int32 PSPInitXmlModsetTable (t_void) { pModSetTable = xmlHashCreate (MAX_HASH_SIZE); if (pModSetTable == NULL) { XML_Error ("xml Modset Table is not created"); return CNTRLXML_FAILURE; } /* XMLMain_RegisterAll(); *//*This will be called from xmlhtphdlr.c. */ return CNTRLXML_SUCCESS; }
/*********************************************************************** * Function Name: CNTRLXMLRegisterModsets * Desription : This functions Register Modset entry to Hash Table * Input : pModsetName - Modset Name * funptr - Call back function pointer * Output : Success or Failure * Return Value : None ***********************************************************************/ t_int32 CNTRLXMLRegisterModsets (t_char8 * pModsetName, t_void * strPtr) { int val; XML_DebugArg ("pModsetName = ", pModsetName); if (pModSetTable == NULL) { XML_Error ("Xml Module Hash Table does not exist"); return CNTRLXML_FAILURE; } val = xmlHashAddEntry (pModSetTable, pModsetName, strPtr); if (val != 0) { XML_DebugArg (pModsetName, "is already exist in Hash"); return CNTRLXML_FAILURE; } return CNTRLXML_SUCCESS; }
/// do actual parse, firing events a& returning true if all went well /// need to create expat parser each time we dparse as its a one shot device bool ParserImpl :: Parse( const string & s ) { if ( mExpat ) { XML_ParserFree( mExpat ); } mExpat = XML_ParserCreate( 0 ); XML_SetElementHandler( mExpat, StartElementHandler, EndElementHandler ); XML_SetCharacterDataHandler( mExpat, CharDataHandler ); XML_SetUserData( mExpat, this ); unsigned int err = XML_Parse( mExpat, s.c_str(), s.size(), 1 ); if ( err == 0 ) { mErrorCode = XML_GetErrorCode( mExpat ); mErrorMsg = XML_ErrorString( XML_Error( err ) ); mErrorLine = XML_GetCurrentLineNumber( mExpat ); } return err != 0; }
/*********************************************************************** * Function Name : PSPReturnXMLErrorString * Description : This function appends given error XML string(xmlStr) * to the Result XML buffer. * Input : pTrSet - Transaction Set * xmlStr - Error XML string to be appended * Output : none * Return value : CNTRLXML_SUCCESS, CNTRLXML_BADPARAM, CNTRLXML_FAILURE ***********************************************************************/ t_int32 PSPReturnXMLErrorString (PSPTransactionId_t * pTrSet, XML_STR pInXMLStr) { t_char8 xmlDeclare[] = "<?xml version=\"1.0\"encoding=\"UTF-8\"?>\n<result><Transaction status=\'error\'>"; t_char8 xmlEndDecl[] = "</Transaction></result>"; if (!pInXMLStr) { XML_Error ("Bad Input Parameters"); return CNTRLXML_BADPARAM; } if (IsValidTransaction (pTrSet)) { /* * Transaction based XML processing. */ XML_Debug ("Transaction based XML processing."); /* XML_Debug("Master tr_id = %d", (int)pTrSet->MasterTrId); */ if (pXMLErrorStr == NULL) { /*of_strcpy(pXMLErrorStr, xmlDeclare); */ pXMLErrorStr = xmlStrdup ((const xmlChar *) xmlDeclare); } if (!pTransList) /*If no transaction in progress */ { /*T_strcat(pXMLErrorStr, pInXMLStr); T_strcat(pXMLErrorStr, xmlEndDecl); */ pXMLErrorStr = xmlStrcat (pXMLErrorStr, pInXMLStr); pXMLErrorStr = xmlStrcat (pXMLErrorStr, xmlEndDecl); } else { /*T_strcat(pXMLErrorStr, pInXMLStr); */ pXMLErrorStr = xmlStrcat (pXMLErrorStr, pInXMLStr); } } else { /* * Non-Transaction XML processing. */ XML_Debug ("Non-Transaction XML processing."); if (pXMLErrorStr == NULL) { pXMLErrorStr = xmlStrdup ((const xmlChar *) pInXMLStr); } else { /*pXMLErrorStr = (XML_STR) T_malloc(T_strlen(pInXMLStr) + 1); */ /*of_strcpy(pXMLErrorStr, pInXMLStr); */ pXMLErrorStr = xmlStrcat (pXMLErrorStr, pInXMLStr); /*free(pInXMLStr); */ } } XML_DebugArg ("pXMLErrorStr = ", pXMLErrorStr); return CNTRLXML_SUCCESS; }
int tt0137_lt_process(request_rec *r, struct global_struct *gbp, char *stdout_buffer) { gbp->sendbuf0137 = (tt0137_st_send *)malloc(sizeof(tt0137_st_send)); gbp->recvbuf0137 = (tt0137_st_recv *)malloc(sizeof(tt0137_st_recv)); gbp->sendbufcat = malloc(tt0137_LAN_SEND_BUF_LEN + 1); if (gbp->sendbufcat == NULL) { ap_rprintf(r, "Isufficient memory available\n"); exit(1); } gbp->recvbufcat = malloc(tt0137_LAN_RECV_BUF_LEN + 1); if (gbp->recvbufcat == NULL) { ap_rprintf(r, "Isufficient memory available\n"); exit(1); } memset(gbp->sendbufcat, '\0', tt0137_LAN_SEND_BUF_LEN + 1); memset(gbp->recvbufcat, '\0', tt0137_LAN_RECV_BUF_LEN + 1); memset(gbp->sendbuf0137, '\0', sizeof(tt0137_st_send)); strcpy(gbp->sendbuf0137->request_id, "XML"); strcpy(gbp->sendbuf0137->record_id, "0137"); get_tag_data("COMPANY", gbp->sendbuf0137->company,gbp,stdout_buffer); get_tag_data("DIVISION", gbp->sendbuf0137->division,gbp,stdout_buffer); get_tag_data("UID", gbp->sendbuf0137->userid,gbp,stdout_buffer); strcpy(gbp->sendbuf0137->ip_address, r->connection->remote_ip); get_tag_data("COPY_CUSTOMIZE", gbp->sendbuf0137->custom_flag,gbp,stdout_buffer); get_tag_data("COPY_SHIP_TO", gbp->sendbuf0137->shipto_flag,gbp,stdout_buffer); get_tag_data("COPY_GIFT_WRAP", gbp->sendbuf0137->giftwrap_flag,gbp,stdout_buffer); get_tag_data("COPY_SOURCE", gbp->sendbuf0137->source_flag,gbp,stdout_buffer); get_tag_data("COPY_COMMENTS", gbp->sendbuf0137->comment_flag,gbp,stdout_buffer); if(tt0137_CatSendStr(gbp, gbp->sendbufcat, gbp->sendbuf0137) == tt0137_LAN_SEND_BUF_LEN) { if((gbp->sock = sga_connect( gbp->hphost, gbp->webport, gbp->webexec, &(gbp->rc),r,gbp)) == INVALID_SOCKET) { XML_Error("sga_connect","failed to connect","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->sendbuf0137); free (gbp->recvbuf0137); return(-1); } //ap_rprintf(r,"HOST %s PORT %s SENDBUF %s",gbp->hphost, gbp->webport,gbp->sendbufcat); if((gbp->rc = sga_send(gbp->sock, gbp->sendbufcat, tt0137_LAN_SEND_BUF_LEN,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_send","failed to send","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->sendbuf0137); free (gbp->recvbuf0137); return(-1); } if((gbp->rc = sga_recv(gbp->sock, gbp->recvbufcat, tt0137_LAN_RECV_BUF_LEN,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_recv","failed to receive","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->sendbuf0137); free (gbp->recvbuf0137); return(-1); } if((gbp->rc = sga_send(gbp->sock, gbp->confirmbuf, 5,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_send","failed to send ack","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->sendbuf0137); free (gbp->recvbuf0137); return(-1); } /* gbp->rc = sga_recv(sock, gbp->confirmbuf, 5); */ sga_close2(gbp->sock, (int)USE_SHUTDOWN,r,gbp); //ap_rprintf(r,"RECVBUF %s",gbp->recvbufcat); tt0137_ParceRecvStr(gbp->recvbuf0137, gbp->recvbufcat,r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->sendbuf0137); free (gbp->recvbuf0137); } else { XML_Error("tt0137_CatSendStr","Failed filling the send buffer","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->sendbuf0137); free (gbp->recvbuf0137); return(-1); } return(0); }
int ft0006_lt_process(request_rec *r, struct global_struct *gbp, char *stdout_buffer) { gbp->ftsendbuf0006 = (ft0006_st_send *)malloc(sizeof(ft0006_st_send)); gbp->ftrecvbuf0006 = (ft0006_st_recv *)malloc(sizeof(ft0006_st_recv)); gbp->sendbufcat = malloc(ft0006_LAN_SEND_BUF_LEN + 1); if (gbp->sendbufcat == NULL) { ap_rprintf(r, "Isufficient memory available\n"); exit(1); } gbp->recvbufcat = malloc(ft0006_LAN_RECV_BUF_LEN + 1); if (gbp->recvbufcat == NULL) { ap_rprintf(r, "Isufficient memory available\n"); exit(1); } memset(gbp->sendbufcat, '\0', ft0006_LAN_SEND_BUF_LEN + 1); memset(gbp->recvbufcat, '\0', ft0006_LAN_RECV_BUF_LEN + 1); memset(gbp->ftsendbuf0006, '\0', sizeof(ft0006_st_send)); sprintf(gbp->confirmbuf, " "); strcpy(gbp->ftsendbuf0006->request_id, "XML"); strcpy(gbp->ftsendbuf0006->record_id, "0006"); strcpy(gbp->ftsendbuf0006->ip_address, r->connection->remote_ip); get_tag_data("COMPANY", gbp->ftsendbuf0006->company,gbp,stdout_buffer); get_tag_data("DIVISION", gbp->ftsendbuf0006->division,gbp,stdout_buffer); get_tag_data("UID", gbp->ftsendbuf0006->userid,gbp,stdout_buffer); get_tag_data("PAGE_NUM", gbp->ftsendbuf0006->page_no,gbp,stdout_buffer); get_tag_data("PAGE_COUNT", gbp->ftsendbuf0006->page_cnt,gbp,stdout_buffer); if(ft0006_CatSendStr(gbp, gbp->sendbufcat, gbp->ftsendbuf0006) == ft0006_LAN_SEND_BUF_LEN) { if((gbp->sock = sga_connect(gbp->hphost, gbp->fvfport, gbp->webexec, &(gbp->rc),r,gbp)) == INVALID_SOCKET) { XML_Error("sga_connect","failed to connect","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0006); free (gbp->ftrecvbuf0006); return(-1); } if((gbp->rc = sga_send(gbp->sock, gbp->sendbufcat, ft0006_LAN_SEND_BUF_LEN,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_send","failed to send","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0006); free (gbp->ftrecvbuf0006); return(-1); } if((gbp->rc = sga_recv(gbp->sock, gbp->recvbufcat, ft0006_LAN_RECV_BUF_LEN,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_recv","failed to receive","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0006); free (gbp->ftrecvbuf0006); return(-1); } // Do an additional send and recieve for confirmation if((gbp->rc = sga_send(gbp->sock, gbp->confirmbuf, 5,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_send","failed to send ack","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0006); free (gbp->ftrecvbuf0006); return(-1); } /* gbp->rc = sga_recv(sock, gbp->confirmbuf, 5); */ sga_close2(gbp->sock, (int)USE_SHUTDOWN,r,gbp); ft0006_ParceRecvStr(gbp->ftrecvbuf0006, gbp->recvbufcat,r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0006); free (gbp->ftrecvbuf0006); } else { XML_Error("ft0006_CatSendStr","Failed filling the send buffer","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0006); free (gbp->ftrecvbuf0006); return(-1); } return(0); }
int ft0024_lt_process(request_rec *r, struct global_struct *gbp, char *stdout_buffer) { gbp->ftsendbuf0024 = (ft0024_st_send *)malloc(sizeof(ft0024_st_send)); gbp->ftrecvbuf0024 = (ft0024_st_recv *)malloc(sizeof(ft0024_st_recv)); gbp->sendbufcat = malloc(ft0024_LAN_SEND_BUF_LEN + 1); if (gbp->sendbufcat == NULL) { ap_rprintf(r, "Isufficient memory available\n"); exit(1); } gbp->recvbufcat = malloc(ft0024_LAN_RECV_BUF_LEN + 1); if (gbp->recvbufcat == NULL) { ap_rprintf(r, "Isufficient memory available\n"); exit(1); } memset(gbp->sendbufcat, '\0', ft0024_LAN_SEND_BUF_LEN + 1); memset(gbp->recvbufcat, '\0', ft0024_LAN_RECV_BUF_LEN + 1); memset(gbp->ftsendbuf0024, '\0', sizeof(ft0024_st_send)); sprintf(gbp->confirmbuf, " "); strcpy(gbp->ftsendbuf0024->request_id, "XML"); strcpy(gbp->ftsendbuf0024->record_id, "0024"); strcpy(gbp->ftsendbuf0024->ip_address, r->connection->remote_ip); get_tag_data("COMPANY", gbp->ftsendbuf0024->company,gbp,stdout_buffer); get_tag_data("DIVISION", gbp->ftsendbuf0024->division,gbp,stdout_buffer); get_tag_data("UID", gbp->ftsendbuf0024->userid,gbp,stdout_buffer); get_tag_data("PAGE_NUM", gbp->ftsendbuf0024->page_no,gbp,stdout_buffer); get_tag_data("PAGE_COUNT", gbp->ftsendbuf0024->page_cnt,gbp,stdout_buffer); get_tag_data("ITEM_NUM", gbp->ftsendbuf0024->item_no,gbp,stdout_buffer); get_tag_data("ITEM_QTY", gbp->ftsendbuf0024->item_qty,gbp,stdout_buffer); get_tag_data("CUSTOMER_NUM", gbp->ftsendbuf0024->cust_no,gbp,stdout_buffer); get_tag_data("OFFER_NUM", gbp->ftsendbuf0024->offer_no,gbp,stdout_buffer); get_tag_data("CUSTOMER_TYPE", gbp->ftsendbuf0024->cust_type,gbp,stdout_buffer); get_tag_data("CONTRACT", gbp->ftsendbuf0024->contract,gbp,stdout_buffer); for (gbp->i = 0; gbp->i < ft0024_VAR_COMP_LOOP; gbp->i++) { sprintf(gbp->tagname, "VAR_ITEM_%d", gbp->i+1); get_tag_data(gbp->tagname, gbp->ftsendbuf0024->var_item_no[gbp->i],gbp,stdout_buffer); sprintf(gbp->tagname, "VAR_QTY_%d", gbp->i+1); get_tag_data(gbp->tagname, gbp->ftsendbuf0024->var_item_qty[gbp->i],gbp,stdout_buffer); sprintf(gbp->tagname, "VAR_PRICE_%d", gbp->i+1); get_tag_data(gbp->tagname, gbp->ftsendbuf0024->var_item_price[gbp->i],gbp,stdout_buffer); } get_tag_data("SHOP_TYPE", gbp->ftsendbuf0024->shop_type,gbp,stdout_buffer); get_tag_data("SHIPTO_COUNT", gbp->ftsendbuf0024->shipto_cnt,gbp,stdout_buffer); if(ft0024_CatSendStr(gbp, gbp->sendbufcat, gbp->ftsendbuf0024) == ft0024_LAN_SEND_BUF_LEN) { if((gbp->sock = sga_connect(gbp->hphost, gbp->fvfport, gbp->webexec, &(gbp->rc),r,gbp)) == INVALID_SOCKET) { XML_Error("sga_connect","failed to connect","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0024); free (gbp->ftrecvbuf0024); return(-1); } if((gbp->rc = sga_send(gbp->sock, gbp->sendbufcat, ft0024_LAN_SEND_BUF_LEN,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_send","failed to send","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0024); free (gbp->ftrecvbuf0024); return(-1); } if((gbp->rc = sga_recv(gbp->sock, gbp->recvbufcat, ft0024_LAN_RECV_BUF_LEN,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_recv","failed to receive","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0024); free (gbp->ftrecvbuf0024); return(-1); } // Do an additional send and recieve for confirmation if((gbp->rc = sga_send(gbp->sock, gbp->confirmbuf, 5,r,gbp)) == SOCKET_ERROR) { XML_Error("sga_send","failed to send ack","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0024); free (gbp->ftrecvbuf0024); return(-1); } /* gbp->rc = sga_recv(sock, gbp->confirmbuf, 5); */ sga_close2(gbp->sock, (int)USE_SHUTDOWN,r,gbp); ft0024_ParceRecvStr(gbp->ftrecvbuf0024, gbp->recvbufcat,r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0024); free (gbp->ftrecvbuf0024); } else { XML_Error("ft0024_CatSendStr","Failed filling the send buffer","communications","-1",r,gbp); free (gbp->sendbufcat); free (gbp->recvbufcat); free (gbp->ftsendbuf0024); free (gbp->ftrecvbuf0024); return(-1); } return(0); }