文件io和伪终端的p/invoke声明 [英] Declarations of p/invoke for file io and pseudo terminal
问题描述
我想使用文件io函数(打开,读取,写入)和伪终端( http://linux.die.net/man/4/pts )(单声道)的功能(grantpt,unlockpt,ptsname).
i want to use the file io functions (open, read, write) and the pseudo-terminal(http://linux.die.net/man/4/pts) functions (grantpt, unlockpt, ptsname) from mono.
转换参数和返回值很简单(不过,如果您可以验证它们,我将不胜感激),但是我找不到对应的库.
translating the arguments and return values is trivial (still, i would appreciate it if you could verify them) but i can't find the corresponding librarys.
我的linux发行版是ARM(Raspberry PI)上的Arch Linux. 由于ARM平台只有32位,因此我只能将int32用于int/size_t等
My linux distribution is Arch Linux on ARM (Raspberry PI). As the ARM Platform is only 32-Bit, i can just use int32 for int/size_t, etc
非常感谢您.
internal class LinuxNativeMethods
{
//int open(const char *pathname, int flags);
[DllImport("??.so")]
internal extern int open(string name, int flags);
//ssize_t read(int fd, void *buf, size_t count);
[DllImport("??.so")]
internal extern int read(int fd, byte[] buffer, int length);
//ssize_t write(int fd, const void *buf, size_t count);
[DllImport("??.so")]
internal extern int write(int fd, byte[] buffer, int length);
//int grantpt(int fd);
[DllImport("??.so")]
internal extern int grantpt(int fd);
//int unlockpt(int fd);
[DllImport("??.so")]
internal extern int unlockpt(int fd);
//i later marshall the pointer to a string
//char *ptsname(int fd);
[DllImport("??.so")]
internal extern IntPtr ptsname(int fd);
}
推荐答案
函数似乎在glibc中,因此dllimport看起来像这样:
The functions appear to be in glibc, so the dllimport would look something like this:
[DllImport("libc.so.6")]
这篇关于文件io和伪终端的p/invoke声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!