forked from blu-corner/codec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.cpp
More file actions
48 lines (40 loc) · 1.22 KB
/
simple.cpp
File metadata and controls
48 lines (40 loc) · 1.22 KB
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
#include <stdint.h>
#include <err.h>
#include <iostream>
#include "lseCodec.h"
#include "codec.h"
#include "codecFactory.h"
#include "cdr.h"
#include "fields.h"
using namespace std;
using namespace neueda;
int main ()
{
cdr d;
d.setString(MessageType, "A");
d.setString(UserName, "username");
d.setString(Password, "password");
d.setString(NewPassword, "password1");
d.setInteger(MessageVersion, 0);
cout << "prior to encoding lse logon message:" << endl;
cout << codec::prettyPrintCdr (d) << endl;
string err;
codec* lse;
codecFactory cf;
if (!cf.get ("lse", lse, err))
errx (1, "failed to retrieve lse codec %s", err.c_str ());
char buf[1024];
size_t used = 0;
codecState state;
cout << "\nencoding..." << endl;
state = lse->encode (d, buf, sizeof (buf), used);
if (state != GW_CODEC_SUCCESS)
errx (1, "encode error: %s", lse->getLastError ().c_str ());
cdr r;
used = 0;
state = lse->decode (r, buf, sizeof (buf), used);
if (state != GW_CODEC_SUCCESS)
errx (1, "decode error: %s", lse->getLastError ().c_str ());
cout << "\ndecoded (includes header fields):" << endl;
cout << codec::prettyPrintCdr (r) << endl;
}