[comp.unix.wizards] Sun callrpc

phadke@nunki.usc.edu (Sandeep Phadke) (06/15/90)

This works for me. The order of the include files is important.
I got it from the latest manuals Chap.3 Rev.A, May 88.

#include <stdio.h>
#include <rpc/rpc.h>
#include <utmp.h>
#include <rpcsvc/rusers.h>

main(argc, argv)
        int argc; char **argv;
{
        unsigned long nusers;

        if (argc < 2) {
                fprintf(stderr, "usage: %s hostname\n", argv[0]);
                exit(-1);
        }
        if (callrpc(argv[1], RUSERSPROG, RUSERSVERS, RUSERSPROC_NUM,
                        xdr_void , 0, xdr_u_long, &nusers)) {

                fprintf(stderr, "error: callrpc\n");
                exit(1);
        }
        printf("%d users on %s\n", nusers, argv[1]);
        exit(0);
}

--Sandeep Phadke