#include #include #include "countchar.h" /* Generated by rpcgen */ /* CpSc 824 Desc: example of Client program that calls the countchar rpc on a remote node using high level rpc_call() function. Usage: countmain node character-string character where: node is the remote node to execute this on, character_string is the string to be searched, character is the string to be searched for. */ main (argc,argv) int argc; char *argv[]; { enum clnt_stat status; int *numptr; stringdata parms; /* defined in countchar.x */ nextcount *countlist, list; buftype bufptr; if (argc != 4 ) { printf("Usage: countmain node character-string character\n"); exit(1); } /* RPC CALL 1 -- invoke countchar */ printf("Getting ready to call countchar\n"); parms.findch = *argv[3]; parms.buf = argv[2]; /* Count occurences of given character */ numptr = (int *) malloc(sizeof(int)); *numptr = -1; if ((status=rpc_call(argv[1], COUNTCHARPROG, COUNTVERS, COUNTCHAR, (xdrproc_t) xdr_stringdata, (caddr_t) &parms, (xdrproc_t) xdr_int, (caddr_t) numptr, "netpath")) != RPC_SUCCESS) { clnt_perrno(status); exit(1); } printf("Back from countchar\n"); if (*numptr == -1) { printf("Error counting characters\n"); exit(1); } printf("Returned count=%d\n",*numptr); printf("Done\n");fflush(stdout); exit(0); }