LabWindows/CVI 是否有类似于 _setmode() 的功能用于将文件(或流)翻译模式设置为二进制或文本?

发布于 2024-11-19 17:56:26 字数 417 浏览 3 评论 0原文

我正在使用 gSoap 生成 ANSI C 源代码,我想在 Windows 7 64 位操作系统上的 LabWindows/CVI 环境中构建该源代码。 gSoap 文件 stdsoap2.c 包含 _setmode() 函数的多个实例,其原型如下:

int _setmode (int fd, int mode);

其中 fd 是文件描述符,mode 设置为 _O_TEXT 或 _O_BINARY。

奇怪的是,尽管 LW/CVI 包含 Microsoft SDK 的接口,但该 SDK 在其任何包含的头文件中都不包含 _setmode 的原型,即使 SDK 的帮助链接包含有关该函数的信息。

有谁知道 LabWindows/CVI 中用于将文件(或流)翻译模式设置为文本或二进制的方法。

谢谢, 雷克

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Hello爱情风 2024-11-26 17:56:26

结束这个问题的循环。
由于上面评论中列出的原因,我无法使用唯一提供的答案。
虽然我确实使用了 SDK,但并不是选择不同版本的 OpenFile 函数,而是支持使用自动代码生成器使用的函数 _setmode() 但我的主要开发环境 (LabWindows/CVI) 不支持。

因此,总而言之,我的解决方案是包含 SDK 来为我提供 _setmode 的定义,并在我的非自动生成的代码中包含以下内容:

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

因此,需要注意的是,这篇文章描述了我实际上的内容 em> 做了,我将把 @gary 提供的答案标记为答案,就像在球场上一样。谢谢@加里。

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.

你怎么这么可爱啊 2024-11-26 17:56:26

听起来您只想以 ASCII 或二进制形式打开文件。因此,您应该能够将 _setmode() 的实例替换为 LW/CVI OpenFile() 函数,如 此处。这是一个以二进制形式读取文件的简短示例。

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.

另请注意页面中的此警告:

注意 Windows SDK 还包含 OpenFile 函数。如果你
包含 windows.h 并且不包含 formatio.h,你将得到编译
如果调用 OpenFile,则会出现错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文