xref: /dflybsd-src/share/examples/sunrpc/msg/msg_proc.c (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /* @(#)msg_proc.c	2.1 88/08/11 4.0 RPCSRC */
2*86d7f5d3SJohn Marino /* $FreeBSD: src/share/examples/sunrpc/msg/msg_proc.c,v 1.2.12.1 2000/12/11 01:03:27 obrien Exp $ */
3*86d7f5d3SJohn Marino /* $DragonFly: src/share/examples/sunrpc/msg/msg_proc.c,v 1.2 2003/06/17 04:36:58 dillon Exp $ */
4*86d7f5d3SJohn Marino /*
5*86d7f5d3SJohn Marino  * msg_proc.c: implementation of the remote procedure "printmessage"
6*86d7f5d3SJohn Marino  */
7*86d7f5d3SJohn Marino #include <paths.h>
8*86d7f5d3SJohn Marino #include <stdio.h>
9*86d7f5d3SJohn Marino #include <rpc/rpc.h>	/* always need this here */
10*86d7f5d3SJohn Marino #include "msg.h"	/* need this too: msg.h will be generated by rpcgen */
11*86d7f5d3SJohn Marino 
12*86d7f5d3SJohn Marino /*
13*86d7f5d3SJohn Marino  * Remote verson of "printmessage"
14*86d7f5d3SJohn Marino  */
15*86d7f5d3SJohn Marino int *
printmessage_1(msg)16*86d7f5d3SJohn Marino printmessage_1(msg)
17*86d7f5d3SJohn Marino 	char **msg;
18*86d7f5d3SJohn Marino {
19*86d7f5d3SJohn Marino 	static int result; /* must be static! */
20*86d7f5d3SJohn Marino 	FILE *f;
21*86d7f5d3SJohn Marino 
22*86d7f5d3SJohn Marino 	f = fopen(_PATH_CONSOLE, "w");
23*86d7f5d3SJohn Marino 	if (f == NULL) {
24*86d7f5d3SJohn Marino 		result = 0;
25*86d7f5d3SJohn Marino 		return (&result);
26*86d7f5d3SJohn Marino 	}
27*86d7f5d3SJohn Marino 	fprintf(f, "%s\n", *msg);
28*86d7f5d3SJohn Marino 	fclose(f);
29*86d7f5d3SJohn Marino 	result = 1;
30*86d7f5d3SJohn Marino 	return (&result);
31*86d7f5d3SJohn Marino }
32