08-30-2009 12:18 PM
08-31-2009 05:28 PM
09-02-2009 10:53 AM
09-03-2009 08:06 AM
09-03-2009 07:23 PM
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.
09-04-2009 10:56 AM
09-04-2009 10:15 PM
djgpp is open source but uses DOS calls, don't know if they would work with CVI.
setmode
http://www.delorie.com/bin/cvsweb.cgi/djgpp/src/libc/dos/io/setmode.c?rev=1.7
freopen
http://www.delorie.com/bin/cvsweb.cgi/djgpp/src/libc/ansi/stdio/freopen.c?rev=1.10
09-07-2009 03:40 AM
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 ?).
09-07-2009 01:11 PM
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:
| 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.
09-08-2009 02:13 AM
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...).