9 void pass(int from, int to);
13 * Connect to given datakit port
15 main(int argc, char *argv[])
20 char *cp, *devdir, *buf;
23 fprint(2, "usage: %s destination network service\n", argv[0]);
24 exits("incorrect number of arguments");
26 if(!(cp = malloc((long)(strlen(argv[1])+strlen(argv[2])+strlen(argv[3])+8)))) {
28 exits("malloc failed");
30 sprint(cp, "%s!%s!%s", argv[2], argv[1], argv[3]);
31 if (dial(cp, &devdir, 0) < 0) {
32 fprint(2, "dialing %s\n", cp);
38 * Initialize the input fd, and copy bytes.
41 if(!(buf = malloc((long)(strlen(devdir)+6)))) {
43 exits("malloc failed");
45 sprint(buf, "%s/data", devdir);
47 fd1=open(buf, OWRITE);
49 print("can't open", buf);
50 exits("can't open port");
53 switch(cpid = fork()){
55 perror("fork failed");
60 pass(fd0, 1); /* from remote */
68 pass(0, fd1); /* to remote */
77 pass(int from, int to)
83 while ((n=read(from, buf, sizeof(buf))) > 0) {
84 if (n==1 && tot==0 && *buf=='\0')
87 if (write(to, buf, n)!=n) {
88 perror("pass write error");
89 exits("pass write error");