source: trunk/athena/bin/write/writed.c @ 34

Revision 34, 1.5 KB checked in by wesommer, 39 years ago (diff)
Stripped even more; put file descriptors in the right place.
Line 
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.  The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6/*
7 * Copyright (c) 1985 Massachusetts Institute of Technology
8 * Note:  This is mostly fingerd.c with all occurances of
9 * "finger" changed to "write".
10 */
11#ifndef lint
12char copyright[] =
13"@(#) Copyright (c) 1983 Regents of the University of California.\n\
14 All rights reserved.\n";
15static char *rcsid_writed_c = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/write/writed.c,v 1.2 1985-12-08 22:03:31 wesommer Exp $";
16#endif not lint
17
18#ifndef lint
19static char sccsid[] = "@(#)writed.c    5.1 (Berkeley) 6/6/85";
20#endif not lint
21
22/*
23 * Write server.
24 */
25#include <sys/types.h>
26#include <netinet/in.h>
27
28#include <stdio.h>
29#include <ctype.h>
30
31main(argc, argv)
32        char *argv[];
33{
34        register char *sp;
35        char line[512];
36        struct sockaddr_in sin;
37        int i, p[2], pid, status;
38        FILE *fp;
39        char *av[10];
40
41
42        i = sizeof (sin);
43        if (getpeername(0, &sin, &i) < 0)
44                fatal(argv[0], "getpeername");
45        line[0] = '\0';
46
47        gets(line);
48        sp = line;
49        av[0] = "write";
50        av[1] = "-f";
51        i = 2;
52        while (1) {
53                while (isspace(*sp))
54                        sp++;
55                if (!*sp)
56                        break;
57                av[i++] = sp;
58                while (*sp && !isspace(*sp)) sp++;
59                if (*sp) *sp++ = '\0';
60        }
61        av[i] = 0;
62        /* Put the socket on stdin, stdout, and stderr */
63        dup2(0, 1);
64        dup2(0, 2);
65        execv("/bin/write", av);
66        _exit(1);
67}
68
69fatal(prog, s)
70        char *prog, *s;
71{
72
73        fprintf(stderr, "%s: ", prog);
74        perror(s);
75        exit(1);
76}
Note: See TracBrowser for help on using the repository browser.