I need to call an API with the follwoing prototype:
Expand|Select|Wrap|Line Numbers
- 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?
Expand|Select|Wrap|Line Numbers
- 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