rpcdb_svc.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Please do not edit this file.
  3. * It was generated using rpcgen.
  4. */
  5. #include "rpcdb.h"
  6. #include <memory.h>
  7. #include <netinet/in.h>
  8. #include <rpc/pmap_clnt.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <sys/socket.h>
  13. #ifndef SIG_PF
  14. #define SIG_PF void (*)(int)
  15. #endif
  16. void init_server();
  17. static void rpc_prog_1(struct svc_req *rqstp, register SVCXPRT *transp)
  18. {
  19. union {
  20. request rpc_call_1_arg;
  21. } argument;
  22. char *result;
  23. xdrproc_t _xdr_argument, _xdr_result;
  24. char *(*local)(char *, struct svc_req *);
  25. switch (rqstp->rq_proc) {
  26. case NULLPROC:
  27. (void)svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
  28. return;
  29. case rpc_call:
  30. _xdr_argument = (xdrproc_t)xdr_request;
  31. _xdr_result = (xdrproc_t)xdr_response;
  32. local = (char *(*)(char *, struct svc_req *))rpc_call_1_svc;
  33. break;
  34. default:
  35. svcerr_noproc(transp);
  36. return;
  37. }
  38. memset((char *)&argument, 0, sizeof(argument));
  39. if (!svc_getargs(transp, (xdrproc_t)_xdr_argument,
  40. (caddr_t)&argument)) {
  41. svcerr_decode(transp);
  42. return;
  43. }
  44. result = (*local)((char *)&argument, rqstp);
  45. if (result != NULL &&
  46. !svc_sendreply(transp, (xdrproc_t)_xdr_result, result)) {
  47. svcerr_systemerr(transp);
  48. }
  49. if (!svc_freeargs(transp, (xdrproc_t)_xdr_argument,
  50. (caddr_t)&argument)) {
  51. fprintf(stderr, "%s", "unable to free arguments");
  52. exit(1);
  53. }
  54. return;
  55. }
  56. int main(int argc, char **argv)
  57. {
  58. register SVCXPRT *transp;
  59. init_server();
  60. pmap_unset(RPC_PROG, RPC_VERS);
  61. transp = svcudp_create(RPC_ANYSOCK);
  62. if (transp == NULL) {
  63. fprintf(stderr, "%s", "cannot create udp service.");
  64. exit(1);
  65. }
  66. if (!svc_register(transp, RPC_PROG, RPC_VERS, rpc_prog_1,
  67. IPPROTO_UDP)) {
  68. fprintf(stderr, "%s",
  69. "unable to register (RPC_PROG, RPC_VERS, udp).");
  70. exit(1);
  71. }
  72. transp = svctcp_create(RPC_ANYSOCK, 0, 0);
  73. if (transp == NULL) {
  74. fprintf(stderr, "%s", "cannot create tcp service.");
  75. exit(1);
  76. }
  77. if (!svc_register(transp, RPC_PROG, RPC_VERS, rpc_prog_1,
  78. IPPROTO_TCP)) {
  79. fprintf(stderr, "%s",
  80. "unable to register (RPC_PROG, RPC_VERS, tcp).");
  81. exit(1);
  82. }
  83. svc_run();
  84. fprintf(stderr, "%s", "svc_run returned");
  85. exit(1);
  86. /* NOTREACHED */
  87. }