

| |
C
Sample Code
#include "gdspub.h"
USHORT
GDSReturnCode;
LPGDSCB
lpGDScb;
LPUCHAR
encodeMsgBuf;
LPUCHAR
decodeMsgBuf;
UCHAR MsgId[15];
UCHAR Version[3];
UCHAR SegId[7];
USHORT NestLevel;
UCHAR ElemId[5];
UCHAR ElemValue[50];
// Initialize Cache
UCHAR lpDbPath[15] =
"C:\\SDS\\MDRDB\\";
MDR_Key_Node
CacheList[3] = {{"AIRAALSADAVAIL", "05", 3},
{"TORAALRESRSP03", "", 3},
{"AIRAALSAD0PNR0", "", 3}};
GDSReturnCode = GDSInitCache((char *)lpDbPath, 5, CacheList);
// Open SDS Control
Block
lpGDScb = GDSOpen (
"C:\\SDS\\MDRDB\\", &GDSReturnCode );
// Encode SDS Message
GDSReturnCode = GDSPutMsgID ( lpGDScb, "AIRAALSADAVAIL",
"05" );
GDSReturnCode
= GDSPutAction (
lpGDScb, "REQ/TRY");
GDSReturnCode
= GDSPutApplID (
lpGDScb, "MYAPPLID");
GDSReturnCode
= GDSPutSubsetID (
lpGDScb, "SUB1");
GDSReturnCode
= GDSPutSeg ( lpGDScb,
"AVSPF0", 0 );
GDSReturnCode
= GDSPutElem ( lpGDScb, "007V", "F" );
GDSReturnCode
= GDSPutElem ( lpGDScb, "01ZT", "16" );
GDSReturnCode
= GDSPutElem ( lpGDScb, "007V", "Y" );
GDSReturnCode
= GDSPutElem ( lpGDScb, "01ZT", "119" );
GDSReturnCode
= GDSPutElem ( lpGDScb, "01L9", "10:00AM" );
GDSReturnCode =
GDSPutElem ( lpGDScb, "012U", "9JUL" );
encodeMsgBuf
= (LPUCHAR) malloc ( GDSGetMsgSize ( lpGDScb ) + 1 );
GDSReturnCode
= GDSGetMsg ( lpGDScb, encodeMsgBuf );
// The encoded SDS
message is:
//
"00100080AIRAALSADAVAIL05A^REQ/TRYS^MYAPPLIDM^SUB1AVSPF00FY1611910:00AM9JUL"
// Decode SDS message
//
Assuming decodeBufMsg has a valid copy of SDS message from Sabre.
if ( (GDSReturnCode
= GDSAllocMsg ( lpGDScb, decodeBufMsg ) == GDS_OK )
{
GDSReturnCode = GDSGetMsgID ( lpGDScb, MsgId, Version );
while(GDSReturnCode = GDSGetNextSeg ( lpGDScb, SegId, &NestLevel
) == GDS_OK)
{
while(GDSReturnCode =
GDSGetNextElem ( lpGDScb, ElemId, ElemValue ) == GDS_OK)
{
// Business logic here
}
}
}
//
Close SDS Control Block
GDSReturnCode = GDSClose ( lpGDScb );
|