ONCRPC restricted us to remote procedures that accept a single parameter and return a single parameter. (Might not be true now but stick to this restriction)
Instead of starting with IDL (like Example 1 & 2), start wtih API.h and generate ONCRPC middle-layer automatically. Keep (or share) the same local implementation between RPC server and RPC client.
Similar to non-RPC application, the below files are manaully created. Create RPC middle-layer to integrate the local APIs defined in cl_calc.h.
cl_common.c/h : RPC Client handler cl_calc.c/h : functions declaration, definition. cl_client.c : client main program
CL is an imaginary product name for example 3.
- cpp cl_calc.h -o cl_calc.i
- pycparser to generate AST
- AST visitor extracts typdef & *** fucntion declaration *** out of AST
- generate IDL & RPC middle-layer Interface
The following files are generated from cl_calc.h
- CL.x (ONCRPC IDL)
- CL_proc.c (Client Middlelayer)
- CL_svc_proc.c (Server Middlelayer)
- CL_proc.h
CL.x generates :
- CL.h
- CL_svc.c
- CL_clnt.c
- CL_xdr.c
Complete C99 parser in pure Python
pycparser installation. ( powered by PLY )
pip install --index-url=https://pypi.python.org/simple/ pycparser