ano*_*nol 7 c development onc-rpc
我的/usr/include包含多个文件.x扩展名的文件,例如/usr/include/rpcsvc/rquota.x.
它们看起来像 C 源代码(在 中运行file /usr/include/rpcsvc/rquota.x结果C source, ASCII text),但它们不是有效的 C(例如program,version似乎关键字)。
它们究竟是什么?鉴于扩展名很短,很难用谷歌搜索,有些网站只是错误/不完整(例如维基百科说“旧的 DirectX 文件”)。
Ste*_*itt 13
它们是基于SunRPC的协议(RPC 代表远程过程调用)的描述。每个文件通常描述这些 RPC 使用的数据结构,以及实现它们的程序;例如,yppasswd.x描述了黄页密码更新协议,比较容易理解:
program YPPASSWDPROG {
version YPPASSWDVERS {
/*
* Update my passwd entry
*/
int
YPPASSWDPROC_UPDATE(yppasswd) = 1;
} = 1;
} = 100009;
struct passwd {
string pw_name<>; /* username */
string pw_passwd<>; /* encrypted password */
int pw_uid; /* user id */
int pw_gid; /* group id */
string pw_gecos<>; /* in real life name */
string pw_dir<>; /* home directory */
string pw_shell<>; /* default shell */
};
struct yppasswd {
string oldpass<>; /* unencrypted old password */
passwd newpw; /* new passwd entry */
};
Run Code Online (Sandbox Code Playgroud)
这声明了一个 RPC YP 密码更新过程,它将一个yppasswd结构体作为参数并返回一个int. 该文件还描述了yppasswd结构本身及其使用的passwd结构。
这些文件通常用于rpcgen生成存根服务器和客户端代码,然后可用于为协议和/或 RPC 客户端实现 RPC 服务器。它甚至可以生成示例客户端和服务器代码。
正如Kusalananda所指出的,rpcgen(1)联机帮助页有更多信息。
rpcgenLinux 系统手册中的片段:
rpcgen is a tool that generates C code to implement an RPC protocol. The
input to rpcgen is a language similar to C known as RPC Language (Remote
Procedure Call Language).
rpcgen is normally used as in the first synopsis where it takes an input
file and generates up to four output files. If the infile is named
proto.x, then rpcgen will generate a header file in proto.h, XDR routines
in proto_xdr.c, server-side stubs in proto_svc.c, and client-side stubs
in proto_clnt.c.
Run Code Online (Sandbox Code Playgroud)
见man rpcgen。
| 归档时间: |
|
| 查看次数: |
4735 次 |
| 最近记录: |