Search code examples
gsoaplabwindows

Does LabWindows/CVI have something similar to _setmode() for setting the file (or stream) translation mode to binary or text?


I am using gSoap to generate ANSI C source code, that I would like to build within the LabWindows/CVI environment, on a Windows 7, 64 bit OS. The gSoap file stdsoap2.c includes several instances of the _setmode() function, with the following prototype:

int _setmode (int fd, int mode);

Where fd is a file descriptor, and mode is set to either _O_TEXT or _O_BINARY.

Oddly enough, even though LW/CVI contains an interface to Microsoft's SDK, this SDK does not contain a prototype to _setmode in any of its included header files, even though the help link to the SDK contains information on the function.

Is anyone aware of the method in LabWindows/CVI used to set file (or stream) translation mode to text, or binary.

Thanks, Ryyker


Solution

  • It sounds like you just want to open a file as either ASCII or binary. So you should be able to replace the instances of _setmode() with the LW/CVI OpenFile() function as described here. Here's a short example reading a file as binary.

    char filename = "path//to//file.ext"
    int result;
    result = OpenFile(filename, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY); 
    
    if (result < 0)
        // Error, notify user.
    else
        // No error.
    

    Also note this warning from the page:

    Caution The Windows SDK also contains an OpenFile function. If you include windows.h and do not include formatio.h, you will get compile errors if you call OpenFile.