No empty .Rs/.Re
[netbsd-mini2440.git] / usr.sbin / ypserv / yppush / yppush_svc.c
bloba93af48d3804b03b5b6c3f6776ac9dbc33231b15
1 /* $NetBSD: yppush_svc.c,v 1.8 2009/04/19 06:06:40 lukem Exp $ */
3 /*
4 * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 #ifndef lint
31 __RCSID("$NetBSD: yppush_svc.c,v 1.8 2009/04/19 06:06:40 lukem Exp $");
32 #endif
35 * Originally from an rpcgen-generated file, then cleaned up
36 * by Jason R. Thorpe <thorpej@NetBSD.org>.
39 #include <sys/types.h>
40 #include <sys/socket.h>
42 #include <netinet/in.h>
44 #include <err.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <netdb.h>
48 #include <signal.h>
49 #include <string.h>
50 #include <syslog.h>
52 #include <rpc/rpc.h>
53 #include <rpc/xdr.h>
54 #include <rpcsvc/yp_prot.h>
56 #include "yppush.h"
58 #ifdef DEBUG
59 #define RPC_SVC_FG
60 #endif
62 #define _RPCSVC_CLOSEDOWN 120
63 int _rpcpmstart; /* Started by a port monitor ? */
64 int _rpcfdtype; /* Whether Stream or Datagram ? */
65 int _rpcsvcdirty; /* Still serving ? */
67 static void _msgout(const char *);
69 static
70 void _msgout(const char *msg)
72 #ifdef RPC_SVC_FG
73 if (_rpcpmstart)
74 syslog(LOG_ERR, "%s", msg);
75 else
76 warnx("%s", msg);
77 #else
78 syslog(LOG_ERR, "%s", msg);
79 #endif
82 void
83 yppush_xfrrespprog_1(struct svc_req *rqstp, SVCXPRT *transp)
85 union {
86 struct yppushresp_xfr yppushproc_xfrresp_1_arg;
87 } argument;
88 void *result;
89 xdrproc_t xdr_argument, xdr_result;
90 void *(*local)(void *, struct svc_req *);
92 _rpcsvcdirty = 1;
93 switch (rqstp->rq_proc) {
94 case YPPUSHPROC_NULL:
95 xdr_argument = xdr_void;
96 xdr_result = xdr_void;
97 local = yppushproc_null_1_svc;
98 break;
100 case YPPUSHPROC_XFRRESP:
101 xdr_argument = xdr_yppushresp_xfr;
102 xdr_result = xdr_void;
103 local = yppushproc_xfrresp_1_svc;
104 break;
106 default:
107 svcerr_noproc(transp);
108 _rpcsvcdirty = 0;
109 exit(1);
110 return;
113 (void) memset((char *)&argument, 0, sizeof (argument));
114 if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) {
115 svcerr_decode(transp);
116 _rpcsvcdirty = 0;
117 exit(1);
118 return;
121 result = (*local)(&argument, rqstp);
122 if (result != NULL && !svc_sendreply(transp, xdr_result, result))
123 svcerr_systemerr(transp);
125 if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) {
126 _msgout("unable to free arguments");
127 exit(1);
129 _rpcsvcdirty = 0;
130 if (rqstp->rq_proc != YPPUSHPROC_NULL)
131 exit(0);
132 return;