1

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

ryyker
  • 22,849
  • 3
  • 43
  • 87

2 Answers2

1

Closing the loop on this question.
I could not use the only offered answer for the reason listed in my comment above.
Although I did use the SDK, it was not to select a different version of the OpenFile function, rather it was to support the use of a function that an auto-code generator used, _setmode() but that was not supported by my primary development environment (LabWindows/CVI).

So, in summary, my solution WAS to include the SDK to give me definition for _setmode as well as including the following in my non- auto-generated code:

#define _O_TEXT         0x4000  /* file mode is text (translated) */     
#define _O_BINARY       0x8000  /* file mode is binary (untranslated) */

So, with the caveat that this post describes what I actually did, I am going to mark the answer @gary offered as the answer, as it was in the ball park. Thanks @gary.

ryyker
  • 22,849
  • 3
  • 43
  • 87
0

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.

gary
  • 4,227
  • 3
  • 31
  • 58
  • Sorry for the long delay, but I would like to close the loop here. I have long since solved the problem. The reason I was not able to use your suggestion (albeit, for most scenarios, it was a good suggestion) was that I am using the gsoap code generator, therefore can not lightly choose to manually change auto-generated code without complicating matters every time we re-generate. What I did finally do is listed in my brief answer below. – ryyker Aug 21 '13 at 19:20