-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.c
executable file
·67 lines (49 loc) · 1.68 KB
/
demo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// DL ISO8583 library demo
//
#include "dl_iso8583.h"
#include "dl_iso8583_defs_1993.h"
#include "dl_output.h" // for 'DL_OUTPUT_Hex'
int main ( void )
{
DL_ISO8583_HANDLER isoHandler;
DL_ISO8583_MSG isoMsg;
DL_UINT8 packBuf[1000];
DL_UINT16 packedSize;
/* get ISO-8583 1993 handler */
DL_ISO8583_DEFS_1993_GetHandler(&isoHandler);
//
// Populate/Pack message
//
/* initialise ISO message */
DL_ISO8583_MSG_Init(NULL,0,&isoMsg);
/* set ISO message fields */
(void)DL_ISO8583_MSG_SetField_Str(0,"1234",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(2,"1234567890123456",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(4,"5699",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(11,"234",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(39,"4",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(41,"12345",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(42,"678901234",&isoMsg);
(void)DL_ISO8583_MSG_SetField_Str(125,"BLAH BLAH",&isoMsg);
/* output ISO message content */
DL_ISO8583_MSG_Dump(stdout,NULL,&isoHandler,&isoMsg);
/* pack ISO message */
(void)DL_ISO8583_MSG_Pack(&isoHandler,&isoMsg,packBuf,&packedSize);
/* free ISO message */
DL_ISO8583_MSG_Free(&isoMsg);
/* output packed message (in hex) */
DL_OUTPUT_Hex(stdout,NULL,packBuf,packedSize);
//
// Unpack message
//
/* initialise ISO message */
DL_ISO8583_MSG_Init(NULL,0,&isoMsg);
/* unpack ISO message */
(void)DL_ISO8583_MSG_Unpack(&isoHandler,packBuf,packedSize,&isoMsg);
/* output ISO message content */
DL_ISO8583_MSG_Dump(stdout,NULL,&isoHandler,&isoMsg);
/* free ISO message */
DL_ISO8583_MSG_Free(&isoMsg);
return 0;
}