Annotation of xinu/sys/TEST/test.c.fr, revision 1.1.1.1

1.1       root        1: /* test.c - main */
                      2: 
                      3: #include <conf.h>
                      4: #include <kernel.h>
                      5: #include <frame.h>
                      6: 
                      7: /*----------------------------------------------------------------------
                      8:  *  main  --  test network initialization
                      9:  *----------------------------------------------------------------------
                     10:  */
                     11: main()
                     12: {
                     13:        struct  frame   *fptr;
                     14:        int     i, len, pr();
                     15:        char    ch;
                     16: 
                     17:        kprintf("Testing frame I/O - PLEASE USE 1 FOR MACHINE ID\n");
                     18:        kprintf("Net 0: frbpool=%d, machid=%d\n",
                     19:                frbpool, fdata[0].fmachid);
                     20:        fptr = getbuf(frbpool);
                     21:        kprintf("Type a message and I'll send it around the net: ");
                     22:        gets(fptr->frdata);
                     23:        fptr->frlen = strlen(fptr->frdata)+3;
                     24:        kprintf("Sending message of %d bytes: %s\n",
                     25:                getflen(fptr), fptr->frdata);
                     26:        kprintf("Fsend returns %d\n", fsend(0, 1, fptr) );
                     27:        kprintf("Buffer obtained at %o\n", fptr=getbuf(frbpool) );
                     28:        kprintf("Attempting to read message...\n");
                     29:        fptr = freceive(0);
                     30:        len = getflen(fptr);
                     31:        kprintf("Got %d bytes: ", len);
                     32:        for (i=0 ; i < len-3 ; i++)
                     33:                if ((ch=fptr->frdata[i]) < ' ')
                     34:                        kprintf("^%c", ch|0100);
                     35:                else if (ch > 0177)
                     36:                        kprintf("#%c", ch&0177 );
                     37:                else
                     38:                        kprintf("%c",ch);
                     39:        kprintf("\n");
                     40:        kprintf("creating process to print incoming messages\n");
                     41:        resume( create(pr,200,19,"print",1,0) );
                     42:        kprintf("\nType a message at each prompt.\n");
                     43:        while(TRUE) {
                     44:                kprintf("Message to send: ");
                     45:                gets(fptr->frdata);
                     46:                if ( (i = strlen(fptr->frdata)+3) > 120 )
                     47:                        i = 120;
                     48:                fptr->frlen = i;
                     49:                fsend(0,1,fptr);
                     50:                fptr = getbuf(frbpool);
                     51:        }
                     52: }
                     53: pr(netid)
                     54: int netid;
                     55: {
                     56:        struct  frame   *fptr;
                     57:        int     i;
                     58: 
                     59:        kprintf(" P: Starting with netid=%d\n",netid);
                     60:        while (TRUE) {
                     61:                fptr = freceive(netid);
                     62:                i = getflen(fptr);
                     63:                fptr->frdata[i-3] = '\0';
                     64:                kprintf(" P: received %s\n", fptr->frdata);
                     65:                freebuf(fptr);
                     66:        }
                     67: }
                     68: 
                     69: P()
                     70: {
                     71:        prdumph();
                     72:        qdumph();
                     73: }

unix.superglobalmegacorp.com

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