H,
I need to call an API with the follwoing prototype:
I have no knowledge of the content of the API function itself but it is unimportant. The API should receive values from the network into p_deviceSize and p_device.
p_deviceSize is used as input/output. Upon input it gets the max elements of device array. Upon output, the actual size of the device array.
p_device is a structure of array elements
as follows:
deviceName which is a char[256] element used as an output
deviceKey which is a char[16] element used as an output
and to my question:
1st, the API is currently not applicable because there is no network to return values so what i want to do is write a stub function that will simulate the returning of values into the API's parameters.
How is the correct way to create the CountDevices_t structure? is it correct to create the structures like the below?
In this case it is easy to write a stub that will simulate values to each member of the structures, however this is not what the API intended.
How is the correct way to create the CountDevices_t structure?
How to implement a stub function to fill that structure where BYTE * actually points to a structure of array? casting a pDevices_t to and array member of p_device?
Hope the question is clear.
Thanks in advance.
Eran
I need to call an API with the follwoing prototype:
Code:
unsigned long CountDevices (BYTE *p_deviceSize,BYTE *p_device );
p_deviceSize is used as input/output. Upon input it gets the max elements of device array. Upon output, the actual size of the device array.
p_device is a structure of array elements
as follows:
deviceName which is a char[256] element used as an output
deviceKey which is a char[16] element used as an output
and to my question:
1st, the API is currently not applicable because there is no network to return values so what i want to do is write a stub function that will simulate the returning of values into the API's parameters.
How is the correct way to create the CountDevices_t structure? is it correct to create the structures like the below?
Code:
typedef struct pDevices_s
{
char deviceName[256];
char deviceKey[16];
}pDevices_t;
typedef struct CountDevices_s
{
BYTE p_devicesSize;
pDevices_t p_device;
}CountDevices_t;
How is the correct way to create the CountDevices_t structure?
How to implement a stub function to fill that structure where BYTE * actually points to a structure of array? casting a pDevices_t to and array member of p_device?
Hope the question is clear.
Thanks in advance.
Eran
Comment