Example: lrs_save_param_ex
In this example, we want to send a packet containing information about the host, port and packet size in the following format:
((hostname=...)(port=...)(size=...))
The size argument is the length of the next packet in binary representation, but this parameter is optional, so it wasn't recorded.The recorded buffer is:
buff11 = "\x00\x00((hostname=...)(port=...))
We want to add a packet size for special cases:
char *ParamBuf = "(size=\x05)"
If it is a special case, save the size of the buffer to the parameter size_param.
if (TheSpecialCase == 1) {
lrs_save_param_ex("socket0", "user", ParamBuf, 0, strlen(ParamBuf),"ascii", "size_param");
}
else {
lrs_save_param_ex("socket0", "user", "", 0, 0, "ascii", "size_param");
}
In the data file, add the size parameter to the buffer buff11:
buff11 = "\x00\x00((hostname=...)(port=...)(<size_param>)"
To see additional examples of using parameters, see the Example: lrs_save_param .