/* * 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 "rdict.h" char dict[DICTSIZ][MAXWORD + 1]; /* storage for a dictionary of words */ int nwords = 0; /* number of words in the dictionary */ char init_bool = 0; int initw(void) { if(init_bool) return 1; nwords = 0; init_bool = 1; return 0; } /* end of initw */ /* ------------------------------------------------------------------ * insertw -- insert a word in the dictionary * ------------------------------------------------------------------ */ int insertw(const char *word) { strcpy(dict[nwords%DICTSIZ], word); nwords++; return (nwords); } /* end of insertw */ /* ------------------------------------------------------------------ * deletew -- delete a word from the dictionary * ------------------------------------------------------------------ */ int deletew(const char *word) { int i; for (i = 0; i < nwords; i++) { if (strcmp(word, dict[i]) == 0) { nwords--; strcpy(dict[i], dict[nwords]); return (1); } } /* end of for */ return (0); } /* end of deletew */ /* ------------------------------------------------------------------ * lookupw -- look up a word in the dictionary * ------------------------------------------------------------------ */ int lookupw(const char *word) { int i; for (i = 0; i < nwords; i++) { if (strcmp(word, dict[i]) == 0) { return 0; } } /* end of for */ return 1; } /* end of lookupw */ int *initw_1_svc(void *argp, struct svc_req *rqstp) { static int result; /* * insert server code here */ result = initw(); return &result; } int *insertw_1_svc(char **argp, struct svc_req *rqstp) { static int result; /* * insert server code here */ result = insertw(*argp); return &result; } int *deletew_1_svc(char **argp, struct svc_req *rqstp) { static int result; /* * insert server code here */ result = deletew(*argp); return &result; } int *lookupw_1_svc(char **argp, struct svc_req *rqstp) { static int result; /* * insert server code here */ result = lookupw(*argp); return &result; }