LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I do the equivalent of setmode?

I am trying to use gSOAP to do some translation from DCOM to WSDL but CVI doesn't supply the setmode command. Is there a way to do this?
0 Kudos
Message 1 of 14
(5,095 Views)
I'm unfamiliar with setmode, can you point me to some documentation for it, so I may be able to find something equivalent?
Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 2 of 14
(5,070 Views)
I did find some resources about setmode type behavior implemented in ANSI C, the general concensus is that there is no good drop in replacement. Please take a look at this forum post http://groups.google.com/group/comp.os.msdos.djgpp/browse_thread/thread/60fb901381746832?pli=1  .
Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 4 of 14
(5,030 Views)

Is the source to the fopen/freopen functions available? I could then possibly create a setmode command. freopen does what I need but I don't have access to the file name and if stdout gets redirected there isn't a file name.

 

The gSOAP interface uses setmode internally since Borland and Microsoft support it but I'd like to stay with CVI for now.

0 Kudos
Message 5 of 14
(5,021 Views)
The source code from CVI is not available a this time. I also checked and was unable to find any source code for fopen/freopen on the internet, if you do find some, then please let us all know.
Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 6 of 14
(4,999 Views)
0 Kudos
Message 7 of 14
(4,990 Views)

the djgpp code for setmode() will certainly not work (i am pretty sure INT21 is not supported under windows). also, the code for freopen() seems clearly not standard compliant:  if the given path is null, it should reopen the same file, while the djgpp code exits with an error (or am i missing something ?).

0 Kudos
Message 8 of 14
(4,968 Views)

The djgpp code for freopen doesn't need to handle the possibility of a NULL for the file since setmode deals with that condition.

 

I don't see where CVI is described as implementing the changing of mode for freopen when supplied with a null. Does this occur? What version did this behavior start? I'm not at my computer with CVI so I can't test it. I've depended on the help file to accurately describe it and there is no mention of it.

 

http://zone.ni.com/reference/en-XX/help/370051K-01/cvi/cvifreopen/

 

quote:

Does the following:

  • Attempts to close the file that is associated with oldStream—failure to close the file successfully is ignored
  • Opens a file and associates it with the I/O stream that is pointed to by oldStream
  • Clears error and end-of-file indicators for the I/O stream
Note Note  This function is useful for redirecting the standard streams (stdin, stdout, stderr) to a file.

If the open operation fails, fopen returns NULL and sets errno to a nonzero value.

 

endquote

 

If it does support this behavior then it is the answer to the setmode question, it's not necessary, use freopen with a NULL string. They need to update the description to reflect this capability if it exists.

 

 

0 Kudos
Message 9 of 14
(4,953 Views)

i just tested with CVI 9.0: freopen fails miserably when provided with a NULL filename.

FATAL RUN-TIME ERROR:   "main.c", line 12, col 21, thread id 0x000000B8:   Null pointer argument to library function.

 

so, you may be screwed... unless you roll your own stream functions targeting your OS, taking into account all those peculiarities. it is not difficult, only cumbersome.

 

i always thought the so-called STREAM functions of the C runtime where badly specified and particularly impossible to extend, that's why i use my own layer on top of those functions, which allows me to create pseudo-streams targeting whatever i want (a console, a text control in a window, a file, a socket, a com port...).

0 Kudos
Message 10 of 14
(4,939 Views)