home_button product_button service_button support_button download_button whats_new_button company_button

Kermit File Transfer Protocol

+1 Software Engineering
2510-G Las Posas Road, Suite 438
Camarillo, California 93011


Table of Contents



1.
Introduction

2. Outstanding Issues
2.1 Current Outstanding Issues
2.2 Previous Outstanding Issues

3. Tree Charts

4. Cross Reference Tables

5. CM Version Description Report

6. CM Status Report

7. Module Documentation

8. Makefile

9. Profile_Data

10. Test Coverage
10.1 Integration Test Percentage (ITP) Graph
10.2 Test Coverage Bar Graph
10.3 Source Code Test Coverage

11. Software Metrics
11.1 Lines of Code (LOC) Graph
11.2 Average Cyclomatic Complexity (vg) Graph
11.3 Metrics4C Output

12. Change Requests
12.1 Number Of Open Change Requests Graph
12.2 Number Of Closed Change Requests Graph
12.3 Metrics4Project Output
12.4 Closed In Change Requests Table
12.5 Closed In Change Requests Details
12.6 Fixed In Change Requests Table
12.7 Fixed In Change Requests Details
12.8 Open Change Requests Table By Number
12.9 Open Change Requests Table By Priority
12.10 Open Change Requests Table By Status
12.11 Open Change Requests Table By Longevity
12.12 Open Change Requests Table By Assignment
12.13 Open Change Requests Details
12.14 Closed Change Requests Table
12.15 Closed Change Requests Details

13. Data Repository
13.1 Data Elements
13.2 Data Structures
13.3 Files
13.4 External Entities
13.5 Glossary
13.6 Personnel

14. Frequently Asked Questions (FAQ)

15. Conclusion

Appendices


1. Introduction

To generate this report, the following report options were selected:

for the following models:
    1. Project Model
    2. Tools Model
    3. Interrupts Model
    4. Objects Model
    5. Additional Model


2. Outstanding Issues

2.1 Current Outstanding Issues

Here is a list of improvements which still need to be made to this program: 1. Item one ... 2. Item two ... 3. Item three ...

2.2 Previous Outstanding Issues

Here is a list of previous issues, all of which have been implemented and tested.

3. Tree Charts

3.1 Tree Chart For Project Model


0  Kermit File Transfer Utility         kermit

1  Connect With Remote Host             connect

11  Check Parity Utility                 dopar

12  TTY Binary                           ttbin
121  Set Speed                            setspd
1211  Print Message On Standard Output     printmsg

13  TTY Release                          ttres

2  Print Message On Standard Output     printmsg

3  Receiving State Table Switcher       recsw

31  Recieve Data                         rdata
311  Put Data From Packet Into A File     bufemp
312  Print Contents Of Error Packet       prerrpkt
313  Read A Packet                        rpack
3131  Get Parity Adjusted Character        cinchr
31311  Get Character From Line              inchr
3132  Timer Interrupt Handler              clkint
3133  Get Character From Line              inchr
314  Send A Packet                        spack
3141  Check Parity Utility                 dopar

32  Recieve File Header                  rfile
321  Error                                error
3211  Print Message On Standard Output     printmsg
3212  Send A Packet                        spack
32121  Check Parity Utility                 dopar
322  Print Contents Of Error Packet       prerrpkt
323  Print Message On Standard Output     printmsg
324  Read A Packet                        rpack
3241  Get Parity Adjusted Character        cinchr
32411  Get Character From Line              inchr
3242  Timer Interrupt Handler              clkint
3243  Get Character From Line              inchr
325  Send A Packet                        spack
3251  Check Parity Utility                 dopar
326  Fill Data Array With Send-Init Parm  spar

33  Receive Initialization               rinit
331  Print Contents Of Error Packet       prerrpkt
332  Read A Packet                        rpack
3321  Get Parity Adjusted Character        cinchr
33211  Get Character From Line              inchr
3322  Timer Interrupt Handler              clkint
3323  Get Character From Line              inchr
333  Get Other Host's Send-Init Params    rpar
334  Send A Packet                        spack
3341  Check Parity Utility                 dopar
335  Fill Data Array With Send-Init Parm  spar

4  Send State Table Switcher            sendsw

41  Send Break (EOT)                     sbreak
411  Print Contents Of Error Packet       prerrpkt
412  Read A Packet                        rpack
4121  Get Parity Adjusted Character        cinchr
41211  Get Character From Line              inchr
4122  Timer Interrupt Handler              clkint
4123  Get Character From Line              inchr
413  Send A Packet                        spack
4131  Check Parity Utility                 dopar

42  Send File Data                       sdata
421  Get Buffer Of Data From File         bufill
422  Print Contents Of Error Packet       prerrpkt
423  Read A Packet                        rpack
4231  Get Parity Adjusted Character        cinchr
42311  Get Character From Line              inchr
4232  Timer Interrupt Handler              clkint
4233  Get Character From Line              inchr
424  Send A Packet                        spack
4241  Check Parity Utility                 dopar

43  Send End Of File (EOF)               seof
431  Get Next File In Group               gnxtfl
432  Print Contents Of Error Packet       prerrpkt
433  Read A Packet                        rpack
4331  Get Parity Adjusted Character        cinchr
43311  Get Character From Line              inchr
4332  Timer Interrupt Handler              clkint
4333  Get Character From Line              inchr
434  Send A Packet                        spack
4341  Check Parity Utility                 dopar

44  Send File Header                     sfile
441  Get Buffer Of Data From File         bufill
442  Error                                error
4421  Print Message On Standard Output     printmsg
4422  Send A Packet                        spack
44221  Check Parity Utility                 dopar
443  Print Contents Of Error Packet       prerrpkt
444  Print Message On Standard Output     printmsg
445  Read A Packet                        rpack
4451  Get Parity Adjusted Character        cinchr
44511  Get Character From Line              inchr
4452  Timer Interrupt Handler              clkint
4453  Get Character From Line              inchr
446  Send A Packet                        spack
4461  Check Parity Utility                 dopar

45  Send Initiate                        sinit
451  Flush Input                          flushinput
452  Print Contents Of Error Packet       prerrpkt
453  Read A Packet                        rpack
4531  Get Parity Adjusted Character        cinchr
45311  Get Character From Line              inchr
4532  Timer Interrupt Handler              clkint
4533  Get Character From Line              inchr
454  Get Other Host's Send-Init Params    rpar
455  Send A Packet                        spack
4551  Check Parity Utility                 dopar
456  Fill Data Array With Send-Init Parm  spar

5  TTY Binary                           ttbin

51  Set Speed                            setspd
511  Print Message On Standard Output     printmsg

6  TTY Handler For 4.1 Unix             ttopen

61  Print Message On Standard Output     printmsg

7  TTY Release                          ttres

8  Usage                                usage

3.2 Tree Chart For Tools Model


0  Tools Model                          kermit

3.3 Tree Chart For Interrupts Model


0  Interrupts Model                     kermit

3.4 Tree Chart For Objects Model


0  Objects Model                        kermit

3.5 Tree Chart For Additional Model


0  Additional Model                     kermit

1  Header Files                         Header_Files

11  Kermit                               kermit_


4. Cross Reference Tables

4.1 Cross Reference Table For Project Model

bufemp                                Put Data From Packet Into A File     311
bufill                                Get Buffer Of Data From File         421
bufill                                Get Buffer Of Data From File         441
cinchr                                Get Parity Adjusted Character        3131
cinchr                                Get Parity Adjusted Character        3241
cinchr                                Get Parity Adjusted Character        3321
cinchr                                Get Parity Adjusted Character        4121
cinchr                                Get Parity Adjusted Character        4231
cinchr                                Get Parity Adjusted Character        4331
cinchr                                Get Parity Adjusted Character        4451
cinchr                                Get Parity Adjusted Character        4531
clkint                                Timer Interrupt Handler              3132
clkint                                Timer Interrupt Handler              3242
clkint                                Timer Interrupt Handler              3322
clkint                                Timer Interrupt Handler              4122
clkint                                Timer Interrupt Handler              4232
clkint                                Timer Interrupt Handler              4332
clkint                                Timer Interrupt Handler              4452
clkint                                Timer Interrupt Handler              4532
connect                               Connect With Remote Host             1
dopar                                 Check Parity Utility                 11
dopar                                 Check Parity Utility                 3141
dopar                                 Check Parity Utility                 32121
dopar                                 Check Parity Utility                 3251
dopar                                 Check Parity Utility                 3341
dopar                                 Check Parity Utility                 4131
dopar                                 Check Parity Utility                 4241
dopar                                 Check Parity Utility                 4341
dopar                                 Check Parity Utility                 44221
dopar                                 Check Parity Utility                 4461
dopar                                 Check Parity Utility                 4551
error                                 Error                                321
error                                 Error                                442
flushinput                            Flush Input                          451
gnxtfl                                Get Next File In Group               431
inchr                                 Get Character From Line              31311
inchr                                 Get Character From Line              3133
inchr                                 Get Character From Line              32411
inchr                                 Get Character From Line              3243
inchr                                 Get Character From Line              33211
inchr                                 Get Character From Line              3323
inchr                                 Get Character From Line              41211
inchr                                 Get Character From Line              4123
inchr                                 Get Character From Line              42311
inchr                                 Get Character From Line              4233
inchr                                 Get Character From Line              43311
inchr                                 Get Character From Line              4333
inchr                                 Get Character From Line              44511
inchr                                 Get Character From Line              4453
inchr                                 Get Character From Line              45311
inchr                                 Get Character From Line              4533
kermit                                Kermit File Transfer Utility         0
prerrpkt                              Print Contents Of Error Packet       312
prerrpkt                              Print Contents Of Error Packet       322
prerrpkt                              Print Contents Of Error Packet       331
prerrpkt                              Print Contents Of Error Packet       411
prerrpkt                              Print Contents Of Error Packet       422
prerrpkt                              Print Contents Of Error Packet       432
prerrpkt                              Print Contents Of Error Packet       443
prerrpkt                              Print Contents Of Error Packet       452
printmsg                              Print Message On Standard Output     1211
printmsg                              Print Message On Standard Output     2
printmsg                              Print Message On Standard Output     3211
printmsg                              Print Message On Standard Output     323
printmsg                              Print Message On Standard Output     4421
printmsg                              Print Message On Standard Output     444
printmsg                              Print Message On Standard Output     511
printmsg                              Print Message On Standard Output     61
rdata                                 Recieve Data                         31
recsw                                 Receiving State Table Switcher       3
rfile                                 Recieve File Header                  32
rinit                                 Receive Initialization               33
rpack                                 Read A Packet                        313
rpack                                 Read A Packet                        324
rpack                                 Read A Packet                        332
rpack                                 Read A Packet                        412
rpack                                 Read A Packet                        423
rpack                                 Read A Packet                        433
rpack                                 Read A Packet                        445
rpack                                 Read A Packet                        453
rpar                                  Get Other Host's Send-Init Params    333
rpar                                  Get Other Host's Send-Init Params    454
sbreak                                Send Break (EOT)                     41
sdata                                 Send File Data                       42
sendsw                                Send State Table Switcher            4
seof                                  Send End Of File (EOF)               43
setspd                                Set Speed                            121
setspd                                Set Speed                            51
sfile                                 Send File Header                     44
sinit                                 Send Initiate                        45
spack                                 Send A Packet                        314
spack                                 Send A Packet                        3212
spack                                 Send A Packet                        325
spack                                 Send A Packet                        334
spack                                 Send A Packet                        413
spack                                 Send A Packet                        424
spack                                 Send A Packet                        434
spack                                 Send A Packet                        4422
spack                                 Send A Packet                        446
spack                                 Send A Packet                        455
spar                                  Fill Data Array With Send-Init Parm  326
spar                                  Fill Data Array With Send-Init Parm  335
spar                                  Fill Data Array With Send-Init Parm  456
ttbin                                 TTY Binary                           12
ttbin                                 TTY Binary                           5
ttopen                                TTY Handler For 4.1 Unix             6
ttres                                 TTY Release                          13
ttres                                 TTY Release                          7
usage                                 Usage                                8

4.2 Cross Reference Table For Tools Model

kermit                                Tools Model                          0

4.3 Cross Reference Table For Interrupts Model

kermit                                Interrupts Model                     0

4.4 Cross Reference Table For Objects Model

kermit                                Objects Model                        0

4.5 Cross Reference Table For Additional Model

Header_Files                          Header Files                         1
kermit                                Additional Model                     0
kermit_                               Kermit                               11


5. CM Version Description Report

 
Version Description Document (VDD) Report
-------------------------------------------------------------------------------
 
Project:	Kermit File Transfer Utility
Version:	Current
Report Date:	Thursday  May 14, 2003  09:04:45
 
Release	  File
-------	  ---------------------------------------------------------------------
1.1	  Header_Files.h
1.1	  bufemp.c
1.1	  bufill.c
1.1	  cinchr.c
1.1	  clkint.c
1.1	  connect.c
1.1	  dopar.c
1.1	  error.c
1.1	  flushinput.c
1.1	  gnxtfl.c
1.1	  inchr.c
1.1	  kermit.c
1.1	  kermit.h
1.1	  kermit_.h
1.1	  prerrpkt.c
1.1	  printmsg.c
1.1	  rdata.c
1.1	  recsw.c
1.1	  rfile.c
1.1	  rinit.c
1.1	  rpack.c
1.1	  rpar.c
1.1	  sbreak.c
1.1	  sdata.c
1.1	  sendsw.c
1.1	  seof.c
1.1	  setspd.c
1.1	  sfile.c
1.1	  sinit.c
1.1	  spack.c
1.1	  spar.c
1.1	  ttbin.c
1.1	  ttopen.c
1.1	  ttres.c
1.1	  usage.c
 
-------------------------------------------------------------------------------


6. CM Status Report

 
Current Status Report
-------------------------------------------------------------------------------
 
Project:	Kermit File Transfer Utility
Version:	Current
Report Date:	Thursday  May 14, 2003  09:04:17
 
User	Date/Time            S  Rel  File
-------	-------------------  -  ---  --------------------------------------------
john	2003/05/14 09:03:21  I  1.1  Header_Files.h
john	2003/05/14 09:03:24  I  1.1  bufemp.c
john	2003/05/14 09:03:13  I  1.1  bufill.c
john	2003/05/14 09:03:12  I  1.1  cinchr.c
john	2003/05/14 09:03:13  I  1.1  clkint.c
john	2003/05/14 09:03:16  I  1.1  connect.c
john	2003/05/14 09:03:14  I  1.1  dopar.c
john	2003/05/14 09:03:19  I  1.1  error.c
john	2003/05/14 09:03:19  I  1.1  flushinput.c
john	2003/05/14 09:03:08  I  1.1  gnxtfl.c
john	2003/05/14 09:03:23  I  1.1  inchr.c
john	2003/05/14 09:03:10  I  1.1  kermit.c
john	2003/05/14 09:03:10  I  1.1  kermit.h
john	2003/05/14 09:03:17  I  1.1  kermit_.h
john	2003/05/14 09:03:09  I  1.1  prerrpkt.c
john	2003/05/14 09:03:15  I  1.1  printmsg.c
john	2003/05/14 09:03:06  I  1.1  rdata.c
john	2003/05/14 09:03:14  I  1.1  recsw.c
john	2003/05/14 09:03:18  I  1.1  rfile.c
john	2003/05/14 09:03:15  I  1.1  rinit.c
john	2003/05/14 09:03:16  I  1.1  rpack.c
john	2003/05/14 09:03:24  I  1.1  rpar.c
john	2003/05/14 09:03:20  I  1.1  sbreak.c
john	2003/05/14 09:03:07  I  1.1  sdata.c
john	2003/05/14 09:03:11  I  1.1  sendsw.c
john	2003/05/14 09:03:07  I  1.1  seof.c
john	2003/05/14 09:03:09  I  1.1  setspd.c
john	2003/05/14 09:03:20  I  1.1  sfile.c
john	2003/05/14 09:03:21  I  1.1  sinit.c
john	2003/05/14 09:03:18  I  1.1  spack.c
john	2003/05/14 09:03:23  I  1.1  spar.c
john	2003/05/14 09:03:22  I  1.1  ttbin.c
john	2003/05/14 09:03:25  I  1.1  ttopen.c
john	2003/05/14 09:03:08  I  1.1  ttres.c
john	2003/05/14 09:03:06  I  1.1  usage.c
-------------------------------------------------------------------------------


7. Module Documentation

Next Module

Root Module

Cross Reference

Tree Charts

Table Of Contents

7.1 Module Header_Files.h

HEADER FILE

    Header_Files - Header Files

DESCRIPTION

    No description written for this module.
CALLED BY

CALLS

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:21
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:21 by john
    
    
    

SOURCE CODE (Header_Files.h Module Description)
___ Called By: This module is not called by other modules.
___ Calls: kermit_


Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.2 Module bufemp.c

FUNCTION NAME

    bufemp - Put Data From Packet Into A File

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:24
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:24 by john
    
    
    

SOURCE CODE (bufemp.c Module Description)
___ Called By: rdata
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *      b u f e m p
 *
 *  Put data from an incoming packet into a file.
 */

bufemp(buffer,len)
char  buffer[];                         /* Buffer */
int   len;                              /* Length */
{
    int i;                              /* Counter */
    char t;                             /* Character holder */

    for (i=0; i<len; i++)               /* Loop thru the data field */
    {
        t = buffer[i];                  /* Get character */
        if (t == MYQUOTE)               /* Control quote? */
        {                               /* Yes */
            t = buffer[++i];            /* Get the quoted character */
            if ((t & 0177) != MYQUOTE)  /* Low order bits match quote char? */
                t = ctl(t);             /* No, uncontrollify it */
        }
        if (t==CR && !image)            /* Don't pass CR if in image mode */
            continue;

        putc(t,fp);
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.3 Module bufill.c

FUNCTION NAME

    bufill - Get Buffer Of Data From File

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:13
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:13 by john
    
    
    

SOURCE CODE (bufill.c Module Description)
___ Called By: sdata * sfile
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *  b u f i l l
 *
 *  Get a bufferful of data from the file that's being sent.
 *  Only control-quoting is done; 8-bit & repeat count prefixes are
 *  not handled.
 */

bufill(buffer)
char buffer[];                          /* Buffer */
{
    int i,                              /* Loop index */
        t;                              /* Char read from file */
    char t7;                            /* 7-bit version of above */

    i = 0;                              /* Init data buffer pointer */
    while((t = getc(fp)) != EOF)        /* Get the next character */
    {
        t7 = unpar(t);                  /* Get low order 7 bits */

        if (t7 < SP || t7==DEL || t7==quote) /* Does this char require */
        {                                   /* special handling? */
            if (t=='\\n' && !image)
            {                           /* Do LF->CRLF mapping if !image */
                buffer[i++] = quote;
                buffer[i++] = ctl('\\r');
            }
            buffer[i++] = quote;        /* Quote the character */
            if (t7 != quote)
            {
                t = ctl(t);             /* and uncontrolify */
                t7 = ctl(t7);
            }
        }
        if (!parflg)
            buffer[i++] = t;            /* Deposit the character itself */
        else
            buffer[i++] = t7;

        if (i >= spsiz-8) return(i);    /* Check length */
    }
    if (i==0) return(EOF);              /* Wind up here only on EOF */
    return(i);                          /* Handle partial buffer */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.4 Module cinchr.c

FUNCTION NAME

    cinchr - Get Parity Adjusted Character

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:12
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:12 by john
    
    
    

SOURCE CODE (cinchr.c Module Description)
___ Called By: rpack
___ Calls: inchr

#include "kermit.h"
#include "kermit_.h"

/*
 * Get a parity adjusted character from the line, add it to the checksum
 * and return it.
 */

cinchr()
{
    char ch;

    ch = inchr();                       /* Get a character */
    cchksum += ch;                      /* Add to the checksum */
    return(ch);
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.5 Module clkint.c

FUNCTION NAME

    clkint - Timer Interrupt Handler

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:13
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:13 by john
    
    
    

SOURCE CODE (clkint.c Module Description)
___ Called By: rpack
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

clkint()                                /* Timer interrupt handler */
{
    longjmp(env,TRUE);                  /* Tell rpack to give up */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.6 Module connect.c

FUNCTION NAME

    connect - Connect With Remote Host

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:16
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:16 by john
    
    
    

SOURCE CODE (connect.c Module Description)
___ Called By: kermit
___ Calls: dopar * ttbin * ttres

#include "kermit.h"
#include "kermit_.h"

/*
 * connect command for "standard" unix
 *
 */

/*
 *  c o n n e c t
 *
 *  Establish a virtual terminal connection with the remote host, over an
 *  assigned tty line. 
 */

extern int remote, ttyfd, lecho;
extern char escchr;

connect()
{
    int pid,                            /* Holds process id of child */
        tt2fd,                          /* FD for the console tty */
        connected;                      /* Boolean connect flag */
    char bel = '\07',
        c;

    struct sgttyb oldcon;               /* [???] should this be here? */

    if (remote)                         /* Nothing to connect to in remote */
    {                                   /* mode, so just return */
        printmsg("No line specified for connection.");
        return;
    }

    tt2fd = ttopen(0);                  /* Open up the console */
    ttbin(tt2fd,&oldcon);               /* Put it in binary */

    pid = fork();           /* Start fork to get typeout from remote host */

    if (!pid)                   /* child1: read remote output */
    {
     while (1)
     {
      char c;
      read(ttyfd,&c,1);                 /* read a character */
      write(1,&c,1);                    /* write to terminal */
     }
    }
/* resume parent: read from terminal and send out port */
      printmsg("connected...\r");
      connected = TRUE;         /* Put us in "connect mode" */
      while (connected)
      {
          read(tt2fd,&c,1);             /* Get a character */
          c = unpar(c);         /* Turn off the parity */
          if (c == escchr)              /* Check for escape character */
          {
              read(tt2fd,&c,1);
              c = unpar(c);             /* Turn off the parity */
              if (c == escchr)
              {
                  c = dopar(c); /* Do parity if the user requested */
                  write(ttyfd,&c,1);
              }
              else
              switch (toupper(c))
              {
                  case 'C':
                      connected = FALSE;
                      write(tt2fd,"\r\n",2);
                      break;

                  case 'H':
                        {
                          char hlpbuf[100],e;
                          sprintf(hlpbuf,"\r\n C to close the connection\r\n");
                          write(tt2fd,hlpbuf,strlen(hlpbuf));
                          e = escchr;
                          if (e < ' ') {
                                write(tt2fd,"^",1);
                                e = ctl(e); }
                          sprintf(hlpbuf,"%c to send itself\r\n",e);
                          write(tt2fd,hlpbuf,strlen(hlpbuf));
                        }
                      break;

                  default:
                      write(tt2fd,&bel,1);
                      break;
              }
          }
          else
          {                             /* If not escape charater, */
              if (lecho) write(1,&c,1); /* Echo char if requested */
              c = dopar(c);             /* Do parity if the user requested */
              write(ttyfd,&c,1);        /* write it out */
              c = NULL;         /* Nullify it (why?) */
          }
      }
      kill(pid,9);                      /* Done, kill the child */
      while (wait(0) != -1);            /* and bury him */
      ttres(tt2fd,&oldcon);
      printmsg("disconnected.");
      return;                           /* Done */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.7 Module dopar.c

FUNCTION NAME

    dopar - Check Parity Utility

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:14
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:14 by john
    
    
    

SOURCE CODE (dopar.c Module Description)
___ Called By: connect * spack
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *      KERMIT utilities.
 */

dopar (ch)
char ch;
{
    int a;

    if (!parflg) return(ch);                    /* false, no parity */
    ch &= 0177;
    switch (parflg)
    {
        case 'm':  return(ch | 128);            /* Mark */
        case 's':  return(ch & 127);            /* Space */
        case 'o':  ch |= 128;                   /* Odd */
        case 'e':                               /* Even */
            a = (ch & 15) ^ ((ch >> 4) & 15);
            a = (a & 3) ^ ((a >> 2) & 3);
            a = (a & 1) ^ ((a >> 1) & 1);
            return((ch & 0177) | (a << 7));
        default:   return(ch);
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.8 Module error.c

FUNCTION NAME

    error - Error

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:19
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:19 by john
    
    
    

SOURCE CODE (error.c Module Description)
___ Called By: rfile * sfile
___ Calls: printmsg * spack

#include "kermit.h"
#include "kermit_.h"

/*
 *  e r r o r
 *
 *  Print error message.
 *
 *  If local, print error message with printmsg.
 *  If remote, send an error packet with the message.
 */

/*VARARGS1*/
error(fmt, a1, a2, a3, a4, a5)
char *fmt;
{
    char msg[80];
    int len;

    if (remote)
    {
        sprintf(msg,fmt,a1,a2,a3,a4,a5); /* Make it a string */
        len = strlen(msg);
        spack('E',n,len,msg);           /* Send the error packet */
    }
    else printmsg(fmt, a1, a2, a3, a4, a5);
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.9 Module flushinput.c

FUNCTION NAME

    flushinput - Flush Input

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:19
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:19 by john
    
    
    

SOURCE CODE (flushinput.c Module Description)
___ Called By: sinit
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *  f l u s h i n p u t
 *
 *  Dump all pending input to clear stacked up NACK's.
 *  (Implemented only for Berkeley Unix at this time).
 */

#if UCB4X&(~NO_FIONREAD)
flushinput()
{
    long int count;                     /* Number of bytes ready to read */
    long int i;                         /* Number of bytes to read in loop */

    ioctl(ttyfd, FIONREAD, &count);     /* See how many bytes pending read */
    if (!count) return;                 /* If zero, then no input to flush */

    while (count)                       /* Loop till all are flushed */
    {
        i = (count<sizeof(recpkt)) ?    /* Read min of count and size of */
            count : sizeof(recpkt);     /*  the read buffer */
        read(ttyfd, recpkt, i);         /* Read a bunch */
        count -= i;                     /* Subtract from amount to read */
    }
}

#endif	/* Added by +1ReverseC */

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.10 Module gnxtfl.c

FUNCTION NAME

    gnxtfl - Get Next File In Group

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:08
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:08 by john
    
    
    

SOURCE CODE (gnxtfl.c Module Description)
___ Called By: seof
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *  g n x t f l
 *
 *  Get next file in a file group
 */

gnxtfl()
{

#if VAX_VMS
    return FALSE;               /* Wildcarding doesn't work this way on VAX */
#endif
    if (debug) printf("   gnxtfl: filelist = \\"%s\\"\\n",*filelist);
    filnam = *(filelist++);
    if (filecount-- == 0) return FALSE; /* If no more, fail */
    else return TRUE;                   /* else succeed */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.11 Module inchr.c

FUNCTION NAME

    inchr - Get Character From Line

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:23
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:23 by john
    
    
    

SOURCE CODE (inchr.c Module Description)
___ Called By: cinchr * rpack
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 * Get a character from the line.  Do any necessary parity stripping
 * and return the character.  
 */

inchr()
{
    char ch;

    read(ttyfd,&ch,1);
    if (pktdeb)                         /* If debugging put a copy in file */
        fprintf(dpfp,"%c:%03o|",ch,ch);
    if(parflg) ch = unpar(ch);          /* Handle parity */
    return(ch);
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.12 Module kermit.c

FUNCTION NAME

    kermit - Kermit File Transfer Utility

DESCRIPTION

    No description written for this module.
USAGE EXAMPLE

    ./kermit

INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

    This is a root module.

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:10
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:10 by john
    
    
    

HEADER FILE (kermit.c Module Description)


SOURCE CODE (kermit.c Module Description)
___ Called By: This is the root module.
___ Calls: connect * printmsg * recsw * sendsw * ttbin * ttopen * ttres * usage

#include "kermit.h"
#include "kermit_.h"

main(argc,argv)
int argc;                           /* Character pointers to and count of */
char **argv;                            /* command line arguments */
{
    char *ttyname,                      /* tty name for LINE argument */
        *cp;                            /* char pointer */
    int cflg, rflg, sflg;               /* flags for CONNECT, RECEIVE, SEND */

    if (argc < 2) usage();              /* Make sure there's a command line */

    cp = *++argv; argv++; argc -= 2;    /* Set up pointers to args */

/*  Initialize these values and hope the first packet will get across OK */

    eol = CR;                           /* EOL for outgoing packets */
    quote = '#';                        /* Standard control-quote char "#" */
    pad = 0;                            /* No padding */
    padchar = NULL;                     /* Use null if any padding wanted */

    speed = cflg = sflg = rflg = 0;     /* Turn off all parse flags */
    ttyname = 0;                        /* Default is remote mode */

    pktdeb = FALSE;                     /* No packet file debugging */
    turn = DEFTRN;                      /* Default turnaround */
    lecho = DEFLCH;                     /* Default local echo */
    parflg = DEFPAR;                    /* Default parity */
    image = DEFIM;                      /* Default image mode */
    filnamcnv = DEFFNC;                 /* Default filename case conversion */

    escchr = DEFESC;                    /* Default escape character */
 
    while ((*cp) != NULL)               /* Parse characters in first arg. */
        switch (*cp++)
        {
            case 'c': cflg++; break;    /* C = Connect command */
            case 's': sflg++; break;    /* S = Send command */
            case 'r': rflg++; break;    /* R = Receive command */

            case 'd':                   /* D = Increment debug mode count */
                debug++; break;
                
            case 'f':
                filnamcnv = FALSE;      /* F = don't do case conversion */
                break;                  /*     on filenames */

            case 'i':                   /* I = Image (8-bit) mode */
                image = TRUE; break;

            case 'h':                   /* H = Half duplex mode */
                lecho = TRUE; break;

            case 't':                   /* T = Turnaround character (XON) */
                turn = TRUE; break;

            case 'l':                   /* L = specify tty line to use */
                if (argc--) ttyname = *argv++;
                else usage(); 
                if (debug) printf("Line to remote host is %s\n",ttyname); 
                break;
                
            case 'e':                   /* E = specify escape char */
                if (argc--) escchr = **argv++;
                else usage();
                if (debug) printf("Escape char is \"%c\"\n",escchr);
                break;
                
            case 'p':                   /* P = specify parity */
                if (argc--)
                    switch ((parflg = **argv++))
                    {
                        case 'n':  parflg = FALSE; break; /* None, no parity */
                        case 'e':
                        case 'm':
                        case 'o':
                        case 's':  break;
                        default:   parflg = FALSE; usage(); 
                    }
                else usage();
                if (debug) printf("Parity is %c\n",parflg);
                break;
                
            case 'z':                   /* Use packet file debugging */
                pktdeb = TRUE; break;

/* Move conditional commands to expansion command table */

            case 'b':                   /* B = specify baud rate */
#if UCB4X
                if (argc--) speed = atoi(*argv++);
                else usage();
                if (debug) printf("Line speed to remote host is %d\n",speed);
                break;
#else
                printmsg("Speed setting implemented for Unix only.");
                exit(1);
#endif
            default: usage();
        }

/* Done parsing */

    if ((cflg+sflg+rflg) != 1)          /* Only one command allowed */
        usage();

    if (ttyname)                        /* If LINE was specified, we */
    {                                   /* operate in local mode */
        ttyfd = ttopen(ttyname);        /* Open the tty line */
        ttbin(ttyfd,&oldtty);           /* Put the tty in binary mode */
        remote = FALSE;                 /* Indicate we're in local mode */
    }
    else                                /* No LINE specified so we operate */
    {                                   /* in remote mode (ie. controlling */
        ttyfd = ttopen(0);              /* tty is the communications line) */
        ttbin(ttyfd,&oldtty);           /* Put the tty in binary mode */
        remote = TRUE;
    }
    
/* All set up, now execute the command that was given. */

    if (!remote) printf("%s\n",sccsid+4);       /* print version # */
    if (pktdeb)                         /* Open packet file if requested */
        if ((dpfp=fopen("PACKET.LOG","w"))==NULL)
        {
            if (debug) printf("Cannot create PACKET.LOG\n");
            pktdeb = FALSE;             /* Say file not being used */
        }

    if (debug)
    {
        printf("Debugging level = %d\n\n",debug);
        if (pktdeb) printf("Logging all packets to PACKET.LOG\n\n");

        if (cflg) printf("Connect command\n\n");
        if (sflg) printf("Send command\n\n");
        if (rflg) printf("Receive command\n\n");
    }
  
    if (cflg) connect();                /* Connect command */

    if (sflg)                           /* Send command */ 
    {
        if (argc--) filnam = *argv++;   /* Get file to send */
        else
        {
            ttres(ttyfd,&oldtty);       /* Restore controlling tty's modes */
            usage();                    /* and give error */
        }
        fp = NULL;                      /* Indicate no file open yet */
        filelist = argv;                /* Set up the rest of the file list */
        filecount = argc;               /* Number of files left to send */
        nice(10);                       /* Keep I/O interrupts reasonable
                                           for other users...             */
        if (sendsw() == FALSE)          /* Send the file(s) */
            printmsg("Send failed.");   /* Report failure */
        else                            /*  or */
            printmsg("done.");          /* success */
    }

    if (rflg)                           /* Receive command */
    {
        nice(10);                       /* Keep I/O interrupts reasonable
                                           for other users...             */
        if (recsw() == FALSE)           /* Receive the file(s) */
            printmsg("Receive failed.");
        else                            /* Report failure */
            printmsg("done.");          /* or success */
    }
    ttres(ttyfd,&oldtty);               /* Restore controlling tty's modes */
    if (pktdeb) fclose(dpfp);           /* Close the debug file */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.13 Module kermit_.h

HEADER FILE

    kermit_ - Kermit

DESCRIPTION

    No description written for this module.
CALLED BY

CALLS

    This module does not call other modules.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:17
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:17 by john
    
    
    

SOURCE CODE (kermit_.h Module Description)
___ Called By: Header_Files
___ Calls: This module does not call other modules.



static char *sccsid = "@(#)Kermit version 3.1(0) 8/24/84";
/*
 *  K e r m i t  File Transfer Utility
 *
 *  UNIX Kermit, Columbia University, 1982, 1983, 1984
 *      Bill Catchings, Bob Cattani, Chris Maio, Frank da Cruz,
 *      Alan Crosswell, Jeff Damens
 *
 *  Also:   Jim Guyton, Rand Corporation
 *          Walter Underwood, Ford Aerospace
 *
 *  usage:  kermit c [lbphe line baud par escape-char]  to connect
 *          kermit s [ddiflbpt line baud par] file ...  to send files
 *          kermit r [ddiflbpt line baud par]           to receive files
 *
 *  where   c=connect, s=send, r=receive,
 *          d=debug, i=image mode, f=no filename conversion, l=tty line,
 *          b=baud rate, e=escape char, h=half duplex, t=turnaround char,
 *          p=parity, z=log packet transactions.
 *
 *  For remote Kermit, format is either:
 *          kermit r                                    to receive files
 *  or      kermit s file ...                           to send files
 *
 */

/*
 *  Modification History:
 *
 *  Aug 84 David Mutterer - Add definition for UNIX System 5 Version 2.
 *
 *  July 84 Bill Catchings and Jeff Damens - Add necessary commands for
 *      communicating with IBM mainframes (t,p,h).  Also started to
 *      make it more modular.  Eventually all conditionals should be
 *      removed.  After that we will go to a LEX version which will
 *      implement all the states needed for a full server version.  A
 *      command parser is also needed.  Limited VAX VMS support was also
 *      added (no connect command).  Link together KERMIT.C, KER%%%.C
 *      (UNX for all present UNIX versions, VMS for VAX VMS) and KERCN%.C
 *      (V for Venix on the Pro and U for UNIX this module not used for
 *      VMS).
 *
 *  May 21 84 - Roy Smith (CUCS), strip parity from checksum in rpack()
 *
 *  Oct. 17 Included fixes from Alan Crosswell (CUCCA) for IBM_UTS:
 *          - Changed MYEOL character from \\n to \\r.
 *          - Change char to int in bufill so getc would return -1 on
 *            EOF instead of 255 (-1 truncated to 8 bits)
 *          - Added read() in rpack to eat the EOL character
 *          - Added fflush() call in printmsg to force the output
 *          NOTE: The last three changes are not conditionally compiled
 *                since they should work equally well on any system.
 *
 *          Changed Berkeley 4.x conditional compilation flag from
 *              UNIX4X to UCB4X.
 *          Added support for error packets and cleaned up the printing
 *              routines.
 */

/* Conditional compilation for different machines/operating systems */
/* One and only one of the following lines should be 1 */

#define UCB4X       1       /* Berkeley 4.x UNIX */
#define TOPS_20     0       /* TOPS-20 */
#define IBM_UTS     0       /* Amdahl UTS on IBM systems */
#define VAX_VMS     0       /* VAX/VMS */
#define S5V2        0       /* AT&T 5.2 UNIX */

/* Conditional compilation for the different Unix variants */
/* 0 means don't compile it, nonzero means do */
#if UCB4X
#define V6_LIBS     0       /* Dont't use retrofit libraries */
#define NO_FIONREAD 0       /* We have ioctl(FIONREAD,...) for flushinput() */
#define NO_TANDEM   0       /* We have TANDEM line discipline (xon/xoff) */
#endif

#if IBM_UTS
#define V6_LIBS     0       /* Don't use retrofit libraries */
#define NO_FIONREAD 1       /* No ioctl(FIONREAD,...) for flushinput() */
#define NO_TANDEM   1       /* No TANDEM line discipline (xon/xoff) */
#endif

#if TOPS_20
#define V6_LIBS     0       /* Don't use retrofit libraries */
#define NO_FIONREAD 1       /* No ioctl(FIONREAD,...) for flushinput() */
#define NO_TANDEM   1       /* No TANDEM line discipline (xon/xoff) */
#endif

#if VAX_VMS
#define V6_LIBS     0       /* Don't use retrofit libraries */
#define NO_FIONREAD 1       /* No ioctl(FIONREAD,...) for flushinput() */
#define NO_TANDEM   1       /* No TANDEM line discipline (xon/xoff) */
#endif

#if S5V2
#define UCB4X       1
#define V6_LIBS     0       /* Dont't use retrofit libraries */
#define NO_FIONREAD 1       /* We have ioctl(FIONREAD,...) for flushinput() */
#define NO_TANDEM   1       /* We have TANDEM line discipline (xon/xoff) */
#endif

#include <stdio.h>          /* Standard UNIX definitions */
#include <ctype.h>

#if V6_LIBS
#include <retrofit/sgtty.h>
#include <retrofit/signal.h>
#include <retrofit/setjmp.h>
#else
#include <signal.h>
#include <setjmp.h>
#endif

#if !(V6_LIBS | VAX_VMS)
#include <sgtty.h>
#endif

#if NO_TANDEM
#define TANDEM      0       /* define it to be nothing if it's unsupported */
#endif


/* Symbol Definitions */

#define MAXPACKSIZ  94      /* Maximum packet size */
#define SOH         1       /* Start of header */
#define CR          13      /* ASCII Carriage Return */
#define SP          32      /* ASCII space */
#define DEL         127     /* Delete (rubout) */
#define XON         17      /* ASCII XON */

#define MAXTRY      10      /* Times to retry a packet */
#define MYQUOTE     '#'     /* Quote character I will use */
#define MYPAD       0       /* Number of padding characters I will need */
#define MYPCHAR     0       /* Padding character I need (NULL) */

#define MYTIME      10      /* Seconds after which I should be timed out */
#define MAXTIM      60      /* Maximum timeout interval */
#define MINTIM      2       /* Minumum timeout interval */

#define TRUE        -1      /* Boolean constants */
#define FALSE       0

#define DEFESC      '^'     /* Default escape character for CONNECT */
#define DEFTRN      FALSE   /* Default turn around */
#define DEFLCH      FALSE   /* Default local echo */
#define DEFPAR      FALSE   /* Default parity */
#define DEFIM       FALSE   /* Default image mode */
#if UCB4X | VAX_VMS | IBM_UTS
#define DEFFNC      TRUE    /* Default file name conversion */
#else
#define DEFFNC      FALSE
#endif
#if IBM_UTS | VAX_VMS
#define MYEOL       '\\r'    /* End-Of-Line character for UTS or VMS systems */
#else
#define MYEOL       '\\n'    /* End-Of-Line character I need */
#endif




/* Macro Definitions */

/*
 * tochar: converts a control character to a printable one by adding a space.
 *
 * unchar: undoes tochar.
 *
 * ctl:    converts between control characters and printable characters by
 *         toggling the control bit (ie. ^A becomes A and A becomes ^A).
 *
 * unpar:  turns off the parity bit.
 */

#define tochar(ch)  ((ch) + ' ')
#define unchar(ch)  ((ch) - ' ')
#define ctl(ch)     ((ch) ^ 64 )
#define unpar(ch)   ((ch) & 127)

/* Conditional Global Variables */

#if VAX_VMS
int     confd,                  /* FD of the controlling terminal */
        ttnam,                  /* Line name pointer */
        oldtty[4],
        oldcon[4];
#else
struct  sgttyb
        oldtty;                 /* Controlling tty raw mode */
#endif

#include <stdio.h>
#include <ctype.h>

/* Global Variables */

int     size,               /* Size of present data */
        rpsiz,              /* Maximum receive packet size */
        spsiz,              /* Maximum send packet size */
        pad,                /* How much padding to send */
        timint,             /* Timeout for foreign host on sends */
        n,                  /* Packet number */
        numtry,             /* Times this packet retried */
        oldtry,             /* Times previous packet retried */
        ttyfd,              /* File descriptor of tty for I/O, 0 if remote */
        remote,             /* -1 means we're a remote kermit */
        image,              /* -1 means 8-bit mode */
        parflg,             /* TRUE means use parity specified */
        turn,               /* TRUE means look for turnaround char (XON) */
        lecho,              /* TRUE for locally echo chars in connect mode */
        debug,              /* Indicates level of debugging output (0=none) */
        pktdeb,             /* TRUE means log all packet to a file */
        filnamcnv,          /* -1 means do file name case conversions */
        speed,              /* speed to set */
        filecount;          /* Number of files left to send */

char    state,              /* Present state of the automaton */
        cchksum,            /* Our (computed) checksum */
        padchar,            /* Padding character to send */
        eol,                /* End-Of-Line character to send */
        escchr,             /* Connect command escape character */
        quote,              /* Quote character in incoming data */
        **filelist,         /* List of files to be sent */
        *filnam,            /* Current file name */
        recpkt[MAXPACKSIZ], /* Receive packet buffer */
        packet[MAXPACKSIZ]; /* Packet buffer */

FILE    *fp,                /* File pointer for current disk file */
        *dpfp;              /* File pointer for debugging packet log file */

jmp_buf env;                /* Environment ptr for timeout longjump */


/*
 *  m a i n
 *
 *  Main routine - parse command and options, set up the
 *  tty lines, and dispatch to the appropriate routine.
 */

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.14 Module prerrpkt.c

FUNCTION NAME

    prerrpkt - Print Contents Of Error Packet

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:09
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:09 by john
    
    
    

SOURCE CODE (prerrpkt.c Module Description)
___ Called By: rdata * rfile * rinit * sbreak * sdata * seof * sfile * sinit
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *  p r e r r p k t
 *
 *  Print contents of error packet received from remote host.
 */
prerrpkt(msg)
char *msg;
{
    printf("Kermit aborting with this error from remote host:\\n%s\\n",msg);
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.15 Module printmsg.c

FUNCTION NAME

    printmsg - Print Message On Standard Output

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:15
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:15 by john
    
    
    

SOURCE CODE (printmsg.c Module Description)
___ Called By: error * kermit * rfile * setspd * sfile * ttopen
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*
 *  p r i n t m s g
 *
 *  Print message on standard output if not remote.
 */

/*VARARGS1*/
printmsg(fmt, a1, a2, a3, a4, a5)
char *fmt;
{
    if (!remote)
    {
        printf("Kermit: ");
        printf(fmt,a1,a2,a3,a4,a5);
        printf("\\n");
        fflush(stdout);                 /* force output (UTS needs it) */
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.16 Module rdata.c

FUNCTION NAME

    rdata - Recieve Data

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:06
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:06 by john
    
    
    

SOURCE CODE (rdata.c Module Description)
___ Called By: recsw
___ Calls: bufemp * prerrpkt * rpack * spack

#include "kermit.h"
#include "kermit_.h"

/*
 *  r d a t a
 *
 *  Receive Data
 */

char rdata()
{
    int num, len;                       /* Packet number, length */
    if (numtry++ > MAXTRY) return('A'); /* "abort" if too many tries */

    switch(rpack(&len,&num,packet))     /* Get packet */
    {
        case 'D':                       /* Got Data packet */
            if (num != n)               /* Right packet? */
            {                           /* No */
                if (oldtry++ > MAXTRY)
                    return('A');        /* If too many tries, abort */
                if (num == ((n==0) ? 63:n-1)) /* Else check packet number */
                {                       /* Previous packet again? */
                    spack('Y',num,6,packet); /* Yes, re-ACK it */
                    numtry = 0;         /* Reset try counter */
                    return(state);      /* Don't write out data! */
                }
                else return('A');       /* sorry, wrong number */
            }
            /* Got data with right packet number */
            bufemp(packet,len);         /* Write the data to the file */
            spack('Y',n,0,0);           /* Acknowledge the packet */
            oldtry = numtry;            /* Reset the try counters */
            numtry = 0;                 /* ... */
            n = (n+1)%64;               /* Bump packet number, mod 64 */
            return('D');                /* Remain in data state */

        case 'F':                       /* Got a File Header */
            if (oldtry++ > MAXTRY)
                return('A');            /* If too many tries, "abort" */
            if (num == ((n==0) ? 63:n-1)) /* Else check packet number */
            {                           /* It was the previous one */
                spack('Y',num,0,0);     /* ACK it again */
                numtry = 0;             /* Reset try counter */
                return(state);          /* Stay in Data state */
            }
            else return('A');           /* Not previous packet, "abort" */

        case 'Z':                       /* End-Of-File */
            if (num != n) return('A');  /* Must have right packet number */
            spack('Y',n,0,0);           /* OK, ACK it. */
            fclose(fp);                 /* Close the file */
            n = (n+1)%64;               /* Bump packet number */
            return('F');                /* Go back to Receive File state */

        case 'E':                       /* Error packet received */
            prerrpkt(recpkt);           /* Print it out and */
            return('A');                /* abort */

        case FALSE:                     /* Didn't get packet */
            spack('N',n,0,0);           /* Return a NAK */
            return(state);              /* Keep trying */

        default:     return('A');       /* Some other packet, "abort" */
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.17 Module recsw.c

FUNCTION NAME

    recsw - Receiving State Table Switcher

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:14
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:14 by john
    
    
    

SOURCE CODE (recsw.c Module Description)
___ Called By: kermit
___ Calls: rdata * rfile * rinit

#include "kermit.h"
#include "kermit_.h"

/*
 *  r e c s w
 *
 *  This is the state table switcher for receiving files.
 */

recsw()
{
    char rinit(), rfile(), rdata();     /* Use these procedures */

    state = 'R';                        /* Receive-Init is the start state */
    n = 0;                              /* Initialize message number */
    numtry = 0;                         /* Say no tries yet */

    while(TRUE)
    {
        if (debug) printf(" recsw state: %c\n",state);
        switch(state)                   /* Do until done */
        {
            case 'R':   state = rinit(); break; /* Receive-Init */
            case 'F':   state = rfile(); break; /* Receive-File */
            case 'D':   state = rdata(); break; /* Receive-Data */
            case 'C':   return(TRUE);           /* Complete state */
            case 'A':   return(FALSE);          /* "Abort" state */
        }
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.18 Module rfile.c

FUNCTION NAME

    rfile - Recieve File Header

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:18
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:18 by john
    
    
    

SOURCE CODE (rfile.c Module Description)
___ Called By: recsw
___ Calls: error * prerrpkt * printmsg * rpack * spack * spar

#include "kermit.h"
#include "kermit_.h"

/*
 *  r f i l e
 *
 *  Receive File Header
 */

char rfile()
{
    int num, len;                       /* Packet number, length */
    char filnam1[50];                   /* Holds the converted file name */

    if (numtry++ > MAXTRY) return('A'); /* "abort" if too many tries */

    switch(rpack(&len,&num,packet))     /* Get a packet */
    {
        case 'S':                       /* Send-Init, maybe our ACK lost */
            if (oldtry++ > MAXTRY) return('A'); /* If too many tries "abort" */
            if (num == ((n==0) ? 63:n-1)) /* Previous packet, mod 64? */
            {                           /* Yes, ACK it again with  */
                spar(packet);           /* our Send-Init parameters */
                spack('Y',num,6,packet);
                numtry = 0;             /* Reset try counter */
                return(state);          /* Stay in this state */
            }
            else return('A');           /* Not previous packet, "abort" */

        case 'Z':                       /* End-Of-File */
            if (oldtry++ > MAXTRY) return('A');
            if (num == ((n==0) ? 63:n-1)) /* Previous packet, mod 64? */
            {                           /* Yes, ACK it again. */
                spack('Y',num,0,0);
                numtry = 0;
                return(state);          /* Stay in this state */
            }
            else return('A');           /* Not previous packet, "abort" */

        case 'F':                       /* File Header (just what we want) */
            if (num != n) return('A');  /* The packet number must be right */
            strcpy(filnam1, packet);    /* Copy the file name */

            if (filnamcnv)              /* Convert upper case to lower */
                for (filnam=filnam1; *filnam != '\0'; filnam++)
                    if (isupper(*filnam)) *filnam = tolower(*filnam);


            if ((fp=fopen(filnam1,"w"))==NULL) /* Try to open a new file */
            {
                error("Cannot create %s",filnam1); /* Give up if can't */
                return('A');
            }
            else                        /* OK, give message */
                printmsg("Receiving %s as %s",packet,filnam1);

            spack('Y',n,0,0);           /* Acknowledge the file header */
            oldtry = numtry;            /* Reset try counters */
            numtry = 0;                 /* ... */
            n = (n+1)%64;               /* Bump packet number, mod 64 */
            return('D');                /* Switch to Data state */

        case 'B':                       /* Break transmission (EOT) */
            if (num != n) return ('A'); /* Need right packet number here */
            spack('Y',n,0,0);           /* Say OK */
            return('C');                /* Go to complete state */

        case 'E':                       /* Error packet received */
            prerrpkt(recpkt);           /* Print it out and */
            return('A');                /* abort */

        case FALSE:                     /* Didn't get packet */
            spack('N',n,0,0);           /* Return a NAK */
            return(state);              /* Keep trying */

        default:    return ('A');       /* Some other packet, "abort" */
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.19 Module rinit.c

FUNCTION NAME

    rinit - Receive Initialization

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:15
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:15 by john
    
    
    

SOURCE CODE (rinit.c Module Description)
___ Called By: recsw
___ Calls: prerrpkt * rpack * rpar * spack * spar

#include "kermit.h"
#include "kermit_.h"

/*
 *  r i n i t
 *
 *  Receive Initialization
 */
  
char rinit()
{
    int len, num;                       /* Packet length, number */

    if (numtry++ > MAXTRY) return('A'); /* If too many tries, "abort" */

    switch(rpack(&len,&num,packet))     /* Get a packet */
    {
        case 'S':                       /* Send-Init */
            rpar(packet);               /* Get the other side's init data */
            spar(packet);               /* Fill up packet with my init info */
            spack('Y',n,6,packet);      /* ACK with my parameters */
            oldtry = numtry;            /* Save old try count */
            numtry = 0;                 /* Start a new counter */
            n = (n+1)%64;               /* Bump packet number, mod 64 */
            return('F');                /* Enter File-Receive state */

        case 'E':                       /* Error packet received */
            prerrpkt(recpkt);           /* Print it out and */
            return('A');                /* abort */

        case FALSE:                     /* Didn't get packet */
            spack('N',n,0,0);           /* Return a NAK */
            return(state);              /* Keep trying */

        default:     return('A');       /* Some other packet type, "abort" */
    }
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.20 Module rpack.c

FUNCTION NAME

    rpack - Read A Packet

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:16
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:16 by john
    
    
    

SOURCE CODE (rpack.c Module Description)
___ Called By: rdata * rfile * rinit * sbreak * sdata * seof * sfile * sinit
___ Calls: cinchr * clkint * inchr

#include "kermit.h"
#include "kermit_.h"

/*
 *  r p a c k
 *
 *  Read a Packet
 */

rpack(len,num,data)
int *len, *num;                         /* Packet length, number */
char *data;                             /* Packet data */
{
    int i, done;                        /* Data character number, loop exit */
    char t,                             /* Current input character */
        type,                           /* Packet type */
        rchksum;                        /* Checksum received from other host */

#if UCB4X                               /* TOPS-20 can't handle timeouts... */
    if (setjmp(env)) return FALSE;      /* Timed out, fail */
    signal(SIGALRM,clkint);             /* Setup the timeout */
    if ((timint > MAXTIM) || (timint < MINTIM)) timint = MYTIME;
    alarm(timint);
#endif /* UCB4X */

    if (pktdeb) fprintf(dpfp,"\nRpack:");
    while (inchr() != SOH);             /* Wait for packet header */

    done = FALSE;                       /* Got SOH, init loop */
    while (!done)                       /* Loop to get a packet */
    {
        cchksum = 0;
        if ((t = cinchr()) == SOH) continue; /* Resynchronize if SOH */
        *len = unchar(t)-3;             /* Character count */

        if ((t = cinchr()) == SOH) continue; /* Resynchronize if SOH */
        *num = unchar(t);               /* Packet number */

        if ((t = cinchr()) == SOH) continue; /* Resynchronize if SOH */
        type = t;                       /* Packet type */

/* Put len characters from the packet into the data buffer */

        for (i=0; i<*len; i++)
            if ((data[i] = cinchr()) == SOH) continue; /* Resynch if SOH */

        data[*len] = 0;                 /* Mark the end of the data */

        if ((t = inchr()) == SOH) continue; /* Resynchronize if SOH */
        rchksum = unchar(t);            /* Convert to numeric */
        done = TRUE;                    /* Got checksum, done */
    }

    if (turn)                           /* User requested trunaround char */
        while (inchr() != XON);         /* handling, spin until an XON */


#if UCB4X
    alarm(0);                           /* Disable the timer interrupt */
#endif

    if (debug>1)                        /* Display incoming packet */
    {
        if (data != NULL)
            data[*len] = '\0';          /* Null-terminate data to print it */
        printf("  rpack type: %c\n",type);
        printf("         num:  %d\n",*num);
        printf("         len:  %d\n",*len);
        if (data != NULL)
            printf("        data: \"%s\"\n",data);
    }
                                        /* Fold in bits 7,8 to compute */
    cchksum = (((cchksum&0300) >> 6)+cchksum)&077; /* final checksum */

    if (cchksum != rchksum) return(FALSE);

    return(type);                       /* All OK, return packet type */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.21 Module rpar.c

FUNCTION NAME

    rpar - Get Other Host's Send-Init Params

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

    This module does not call other modules.

MODULE IMPLEMENTED IN

    C

MODULE TESTED

    Module is NOT unit tested.

REVISION HISTORY

    Delta 1.1
    Created On: 2003/05/14 09:03:24
    Created By: john
    Change Requests: 
    Comments: date and time created 2003/05/14 09:03:24 by john
    
    
    

SOURCE CODE (rpar.c Module Description)
___ Called By: rinit * sinit
___ Calls: This module does not call other modules.

#include "kermit.h"
#include "kermit_.h"

/*  r p a r
 *
 *  Get the other host's send-init parameters
 *
 */

rpar(data)
char data[];
{
    spsiz = unchar(data[0]);            /* Maximum send packet size */
    timint = unchar(data[1]);           /* When I should time out */
    pad = unchar(data[2]);              /* Number of pads to send */
    padchar = ctl(data[3]);             /* Padding character to send */
    eol = unchar(data[4]);              /* EOL character I must send */
    quote = data[5];                    /* Incoming data quote character */
}

Next Module

Previous Module

Root Module

Top Module

Cross Reference

Tree Charts

Table Of Contents

7.22 Module sbreak.c

FUNCTION NAME

    sbreak - Send Break (EOT)

DESCRIPTION

    No description written for this module.
INPUTS

OUTPUTS

FUNCTION RETURNS

CALLED BY

CALLS

MODULE IMPLEMENTED IN

    C

MODULE TESTED