c++ - How can I port DeviceIOControl to ioctl? -


in understanding, deviceiocontrol , ioctl same functions. both send control codes hardware , return responses. in effort reuse code, trying create function work in cross-platform manner. therefore, i've decided use deviceiocontrol api since fixed , specific. problem is: how map ioctl that?

i have:

int deviceiocontrol_issuecommand(devicehandle handle, int command, void *input, ssize_t sizeof_input, void *output, ssize_t sizeof_output, uint32_t *bytes_written){ #if systeminformation_iswindows     int result = deviceiocontrol(handle,command,input,sizeof_input,output,sizeof_output,bytes_written,0);     if (result == 0){         result = -1; //-1 new error return     }     return result; #else     int result = ioctl(handle, command, input); //this doesnt work!     return result; #endif }

any appreciated!

what asking not possible without lot of internal translation in deviceiocontrol_issuecommand. function calls different , expect different parameters , data. can work around declaring iocontrol class , adding member functions each type of io functionality want support.

class iocontrol { public:     void doiocontrolx();     void doiocontroly(int param1, int param2); }; 

then provide impelementation each platform need support. 1 windows deviceiocontrol calls , 1 systems support ioctl


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -