diff options
author | wollman <wollman@FreeBSD.org> | 1994-08-07 18:50:51 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1994-08-07 18:50:51 +0000 |
commit | da8387f131b31fd09269eb0025ceb4082c11001e (patch) | |
tree | dfb7a7e650f822f063680d1dff81d06252ea879e /share/examples/sunrpc/msg/printmsg.c | |
download | FreeBSD-src-da8387f131b31fd09269eb0025ceb4082c11001e.zip FreeBSD-src-da8387f131b31fd09269eb0025ceb4082c11001e.tar.gz |
Sun RPC demo programs from 4.4-Lite
Diffstat (limited to 'share/examples/sunrpc/msg/printmsg.c')
-rw-r--r-- | share/examples/sunrpc/msg/printmsg.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/share/examples/sunrpc/msg/printmsg.c b/share/examples/sunrpc/msg/printmsg.c new file mode 100644 index 0000000..dde55dd --- /dev/null +++ b/share/examples/sunrpc/msg/printmsg.c @@ -0,0 +1,43 @@ +/* @(#)printmsg.c 2.1 88/08/11 4.0 RPCSRC */ +/* + * printmsg.c: print a message on the console + */ +#include <stdio.h> + +main(argc, argv) + int argc; + char *argv[]; +{ + char *message; + + if (argc < 2) { + fprintf(stderr, "usage: %s <message>\n", argv[0]); + exit(1); + } + message = argv[1]; + + if (!printmessage(message)) { + fprintf(stderr, "%s: sorry, couldn't print your message\n", + argv[0]); + exit(1); + } + printf("Message delivered!\n"); +} + +/* + * Print a message to the console. + * Return a boolean indicating whether the message was actually printed. + */ +printmessage(msg) + char *msg; +{ + FILE *f; + + f = fopen("/dev/console", "w"); + if (f == NULL) { + return (0); + } + fprintf(f, "%s\n", msg); + fclose(f); + return(1); +} |