I am trying to implements an NFS using RPC. Now my specification file looks something like this: (This is very a basic version of it :) )
struct input
{
char command[20];
char arg[10][10];
int numargs;
};
struct lsresult
{
char arr[50][256];
};
program NFSPROG
{
version NFSVERSION
{
lsresult ls(input) = 1;
int cd(input) = 2;
int mkdir(input) = 3;
int mkfile(input) = 4;
} = 1;
} = 0x21111111;
When I am trying to compile this Spec.x
using rpcgen
, I am getting an error like this:
char arg[10][10];
^^^^^^^^^^^^^^
Spec.x, line 4: expected ';'
What may be the reason for this? Can't I declare a 2D array inside a struct in RPC Specification? (Same error appeared when I tried to declare variables in this way: int a,b,c
in the struct!)
In termini of rpcgen, you need an array of strings, not a 2d array of chars. First, you have to typedef an argument type
typedef string arg<10>;
and then make an array of those arguments:
struct input
{
string command<20>;
arg args[10];
int numargs;
};
similar for lsresult:
typedef string filename<50>;
struct lsresult
{
filename arr[256];
};
That should work