Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Passing a pointer from the main function to the ioRead and ioDevctl functions of a ResourceManager: (2 Items)
   
Passing a pointer from the main function to the ioRead and ioDevctl functions of a ResourceManager  
Is it possible that, when I create the ResourceManager, to specify a pointer which the ResourceManager will provide it 
further as argument to the ioRead and ioDevctl functions I registered as callbacks?
I create a pointer to some data in the main function and I would like to avoid sharing it as global/static variable to 
those functions.

Thank you,
Gabriel
Re: Passing a pointer from the main function to the ioRead and ioDevctl functions of a ResourceManager  
Yes. You can store data on a per-device basis (e.g. one chunk for data for /dev/ser1 and a different chunk for /dev/
ser2) and this is done by extending the devices iofunc_attr_t attribute structure. You can also store data on a per-open
 basis (i.e. a different chunk of data for each client that calls open()) and this is done by extending the iofunc_ocb_t
 open control block. See the docs:
QNX Software Development Platform > Programming > Writing a Resource Manager > POSIX-Layer Data Structures > Extending 
the OCB and attribute structures
Those docs also talk about extending the mount structure, which would be at a higher level yet.
-Steve