/* * This is sample code generated by rpcgen. * These are only templates and you can use them * as a guideline for developing your own functions. */ #include #include "userlookup.h" int l_byname( char* host, char *name ) { CLIENT *clnt; int *uid; clnt = clnt_create(host, ULKUP_PROG, ULKUP_VERSION, "udp"); if (clnt == NULL) { clnt_pcreateerror(host); exit(1); } uid = byname_1(&name, clnt); if (uid == NULL) { clnt_perror(clnt, "call failed:"); } clnt_destroy( clnt ); return(*uid); } char * l_bynum( char* host, int uid ) { CLIENT *clnt; username *name; clnt = clnt_create(host, ULKUP_PROG, ULKUP_VERSION, "udp"); if (clnt == NULL) { clnt_pcreateerror(host); exit(1); } name = bynum_1(&uid, clnt); if (name == NULL) { clnt_perror(clnt, "call failed:"); } clnt_destroy( clnt ); return(*name); } int main( int argc, char* argv[] ) { char *host; char *name; int uid; if(argc < 3) { printf("usage: %s server_host name_or_uid\n", argv[0]); exit(1); } host = argv[1]; name = argv[2]; if ((name[0]>='0')&&(name[0]<='9')) { uid = atoi(name); printf("UID %d, Name is %s\n",uid,l_bynum(host,uid)); } else { printf("Name %s, UID is %d\n",name,l_byname(host,name)); } return(0); }