Annotation of 43BSDReno/contrib/isode-beta/others/quipu/uips/ufn/pipe.c, revision 1.1.1.1

1.1       root        1: /* pipe.c - ufn talks to dish */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/quipu/uips/ufn/RCS/pipe.c,v 7.0 90/06/13 18:52:42 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/quipu/uips/ufn/RCS/pipe.c,v 7.0 90/06/13 18:52:42 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       pipe.c,v $
                     12:  * Revision 7.0  90/06/13  18:52:42  mrose
                     13:  * *** empty log message ***
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                               NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: 
                     28: 
                     29: #include <stdio.h>
                     30: #include <signal.h>
                     31: #include "internet.h"
                     32: 
                     33: /*    DISH */
                     34: 
                     35: int    dish (command)
                     36: char   *command;
                     37: {
                     38:     int            cc,
                     39:            n;
                     40:     char    buffer[BUFSIZ];
                     41:     static int sd;
                     42:     static int dish_running = NOTOK;
                     43:     static struct sockaddr_in sin;
                     44: 
                     45:     if (dish_running == NOTOK) {
                     46:        if (get_dish_sock (&sin, 0) != 0) {
                     47:                (void) fprintf (stderr,"can't get dish socket\n");
                     48: bye_bye:;
                     49:                (void) fprintf (stderr,"Can't invoke '%s'\n",command);
                     50:                exit (-1);
                     51:        }
                     52: 
                     53:        dish_running = OK;
                     54:     }
                     55: 
                     56:     if ((sd = start_tcp_client ((struct sockaddr_in *) 0, 0)) == NOTOK) {
                     57:        (void) fprintf (stderr,"Unable to start tcp client\n");
                     58:        goto bye_bye;
                     59:     }
                     60:     if (join_tcp_server (sd, &sin) == NOTOK) {
                     61:        (void) close_tcp_socket (sd);
                     62:        (void) fprintf (stderr,"unable to join to tcp socket\n");
                     63:        goto bye_bye;
                     64:     }
                     65: 
                     66:     n = send (sd, command, cc = strlen (command), 0);
                     67: 
                     68:     if (n != cc) {
                     69:            (void) fprintf (stderr,"write to DUA failed\n");
                     70:            goto bye_bye;
                     71:     }
                     72: 
                     73:     for (;;) {
                     74:        if ((cc = recv (sd, buffer, sizeof buffer - 1, 0)) == NOTOK) {
                     75:            (void) fprintf (stderr,"read from DUA failed\n");
                     76:            goto bye_bye;
                     77:        }
                     78: 
                     79:        buffer[cc] = NULL;
                     80:        if (cc == OK) 
                     81:            break;
                     82: 
                     83:        switch (buffer[0]) {
                     84:            case '1':
                     85:            case '2':
                     86:            case '3':
                     87:                (void) write (1,buffer + 1, cc - 1);
                     88:                            
                     89:                while ((cc = recv (sd, buffer, sizeof buffer - 1, 0)) > OK)
                     90:                        (void) write (1,buffer + 1, cc - 1);
                     91: 
                     92:                break;
                     93: 
                     94:            default:
                     95:                (void) fprintf (stderr, "Dish is asking difficult questions (%s)!!!",buffer + 1);
                     96:                break;
                     97:        }
                     98:        break;
                     99:     }
                    100: 
                    101:     (void) close_tcp_socket (sd);
                    102: }
                    103: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.